25 #ifndef __METADATA_HANDLER_TAGLIB_H__
26 #define __METADATA_HANDLER_TAGLIB_H__
51 #define SONGBIRD_METADATAHANDLERTAGLIB_CONTRACTID \
52 "@songbirdnest.com/Songbird/MetadataHandler/Taglib;1"
53 #define SONGBIRD_METADATAHANDLERTAGLIB_CLASSNAME \
54 "Songbird Taglib Metadata Handler Component"
55 #define SONGBIRD_METADATAHANDLERTAGLIB_CID \
60 { 0x84, 0xe8, 0x92, 0x3f, 0x52, 0x15, 0xb9, 0x2a } \
71 #include <nsIChannel.h>
72 #include <nsICharsetDetectionObserver.h>
73 #include <nsIFileProtocolHandler.h>
74 #include <nsIResProtocolHandler.h>
76 #include <nsStringGlue.h>
79 #include <nsAutoPtr.h>
82 #include <sbIMetadataHandler.h>
83 #include <sbISeekableChannel.h>
84 #include <sbITagLibChannelFileIOManager.h>
91 #include <vorbisfile.h>
99 #include <xiphcomment.h>
100 #include <attachedpictureframe.h>
102 #include <nsAutoLock.h>
114 class nsICharsetDetector;
118 public nsICharsetDetectionObserver
133 static const long MAX_SCAN_BYTES = 100000;
151 nsCOMPtr<sbITagLibChannelFileIOManager>
152 mpTagLibChannelFileIOManager;
153 nsCOMPtr<nsIFileProtocolHandler>
154 mpFileProtocolHandler;
155 nsCOMPtr<nsIResProtocolHandler>
156 mpResourceProtocolHandler;
157 nsCOMPtr<sbIMutablePropertyArray> mpMetadataPropertyArray;
158 nsCOMPtr<nsIChannel> mpChannel;
159 nsCOMPtr<sbISeekableChannel>
161 nsCOMPtr<nsIURL> mpURL;
162 nsCString mMetadataChannelID;
163 PRBool mMetadataChannelRestart;
165 nsCString mMetadataPath;
180 sbAlbumArt() : type(0), dataLen(0),
data(nsnull) {
181 MOZ_COUNT_CTOR(sbAlbumArt);
184 MOZ_COUNT_DTOR(sbAlbumArt);
188 if (dataLen > 0 &&
data) {
194 nsTArray<nsAutoPtr<sbAlbumArt> > mCachedAlbumArt;
198 static PRLock* sTaglibLock;
203 NS_DECL_SBIMETADATAHANDLER
204 NS_DECL_SBISEEKABLECHANNELLISTENER
220 NS_IMETHOD
Notify(
const char* aCharset, nsDetectionConfident aConf);
229 static PRUint32 sNextChannelID;
232 nsresult ReadInternal(
233 PRInt32 *pReadCount);
234 nsresult WriteInternal(
235 PRInt32 *pWriteCount);
237 nsresult GetImageDataInternal(
239 nsACString &aMimeType,
243 nsresult SetImageDataInternal(
245 const nsAString &aURL);
247 nsresult RemoveAllImagesMP3(
248 TagLib::MPEG::File *aMPEGFile,
251 nsresult RemoveAllImagesOGG(
252 TagLib::Ogg::Vorbis::File *aMPEGFile,
255 nsresult ReadImageFile(
256 const nsAString &imageSpec,
258 PRUint32 &imageDataSize,
259 nsCString &imageMimeType);
261 nsresult WriteMP3Image(
262 TagLib::MPEG::File *aFile,
264 const nsAString &imageSpec);
266 nsresult WriteOGGImage(
267 TagLib::Ogg::Vorbis::File *aFile,
269 const nsAString &imageSpec);
271 nsresult WriteMP4Image(
272 TagLib::MP4::File *aFile,
274 const nsAString &imageSpec);
276 nsresult ReadImageID3v2(
277 TagLib::ID3v2::Tag *aTag,
279 nsACString &aMimeType,
283 nsresult ReadImageITunes(
284 TagLib::MP4::Tag *aTag,
285 nsACString &aMimeType,
289 nsresult ReadImageOgg(
290 TagLib::Ogg::XiphComment *aTag,
292 nsACString &aMimeType,
296 nsresult ReadImageFlac(
297 TagLib::FLAC::File *pTagFile,
299 nsACString &aMimeType,
306 TagLib::ID3v2::Tag *pTag,
309 void AddGracenoteMetadataMP3(
310 TagLib::MPEG::File *MPEGFile);
318 TagLib::APE::Tag *pTag);
326 TagLib::Ogg::XiphComment *pTag);
329 TagLib::Ogg::FieldListMap &fieldListMap,
330 const char *fieldName,
331 const char *metadataName);
333 void AddGracenoteMetadataXiph(
334 TagLib::Ogg::Vorbis::File *oggFile);
342 TagLib::MP4::Tag *pTag);
353 nsresult AcquireTaglibLock();
354 nsresult ReleaseTaglibLock();
356 nsresult CheckChannelRestart();
358 nsresult ReadMetadata();
362 nsACString& _retval);
364 nsresult RunCharsetDetector(
365 nsICharsetDetector *aDetector,
370 const char *aCharset,
375 nsresult AddSeparatedNumbers(
377 const char *baseProperty,
378 const char *countProperty);
381 TagLib::File *pTagFile,
382 const char *aCharset = 0);
384 PRBool ReadMPEGFile();
386 PRBool ReadASFFile();
388 PRBool ReadMP4File();
390 PRBool ReadOGGFile();
392 PRBool ReadOGAFile();
394 PRBool ReadFLACFile();
396 PRBool ReadMPCFile();
398 nsresult AddMetadataValue(
403 nsresult AddMetadataValue(
407 nsresult AddMetadataValue(
411 nsresult AddMetadataValue(
413 const nsAString &value);
415 void FixTrackDiscNumber(
424 TagLib::PropertyMap *properties);
425 nsresult WriteSeparatedNumbers(
426 TagLib::PropertyMap *properties,
428 const nsAString &baseProperty,
429 const nsAString &countProperty);
431 TagLib::APE::Tag *
tag);
433 TagLib::ASF::Tag *tag);
435 TagLib::ID3v1::Tag *tag);
437 TagLib::ID3v2::Tag *tag);
439 TagLib::MP4::Tag *tag);
440 nsresult WriteXiphComment(
441 TagLib::Ogg::XiphComment *tag);
449 nsCString mLastCharset;
450 nsDetectionConfident mLastConfidence;
457 std::string base64_encode(
unsigned char const* bytes_to_encode,
458 unsigned int in_len);
_updateTextAndScrollDataForFrame aContent
A listener interface for sbISeekableChannel.
dataSBGenres SBProperties tag
_updateTextAndScrollDataForFrame aData