1 /*****************************************************************************
2 * taglib.cpp: Taglib tag parser/writer
3 *****************************************************************************
4 * Copyright (C) 2003-2011 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Rafaël Carré <funman@videolanorg>
9 * Rémi Duraffort <ivoire@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
30 #include <vlc_common.h>
31 #include <vlc_plugin.h>
32 #include <vlc_demux.h> /* demux_meta_t */
33 #include <vlc_strings.h> /* vlc_b64_decode_binary */
34 #include <vlc_input.h> /* for attachment_new */
37 # include <vlc_charset.h>
46 #define VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c))
47 #define TAGLIB_VERSION VERSION_INT(TAGLIB_MAJOR_VERSION, \
48 TAGLIB_MINOR_VERSION, \
53 #include <tbytevector.h>
55 #if TAGLIB_VERSION >= VERSION_INT(1,7,0)
56 # define TAGLIB_HAVE_APEFILE_H
58 # ifdef TAGLIB_WITH_ASF // ASF pictures comes with v1.7.0
59 # define TAGLIB_HAVE_ASFPICTURE_H
69 #include <oggflacfile.h>
70 #include "../demux/vorbis.h"
72 #if TAGLIB_VERSION >= VERSION_INT(1,6,0)
73 # define TAGLIB_HAVE_AIFF_WAV_H
74 # include <aifffile.h>
77 # include <id3v2tag.h>
80 #if TAGLIB_VERSION >= VERSION_INT(1,6,1) && defined(TAGLIB_WITH_MP4)
81 # define TAGLIB_HAVE_MP4COVERTART_H
85 #include <speexfile.h>
86 #include <trueaudiofile.h>
87 #include <vorbisfile.h>
88 #include <wavpackfile.h>
90 #include <attachedpictureframe.h>
91 #include <textidentificationframe.h>
92 #include <uniquefileidentifierframe.h>
94 // taglib is not thread safe
95 static vlc_mutex_t taglib_lock = VLC_STATIC_MUTEX;
98 static int ReadMeta ( vlc_object_t * );
99 static int WriteMeta ( vlc_object_t * );
102 set_capability( "meta reader", 1000 )
103 set_callbacks( ReadMeta, NULL )
105 set_capability( "meta writer", 50 )
106 set_callbacks( WriteMeta, NULL )
109 using namespace TagLib;
111 static void ExtractTrackNumberValues( vlc_meta_t* p_meta, const char *psz_value )
113 unsigned int i_trknum, i_trktot;
114 if( sscanf( psz_value, "%u/%u", &i_trknum, &i_trktot ) == 2 )
117 snprintf( psz_trck, sizeof( psz_trck ), "%u", i_trknum );
118 vlc_meta_SetTrackNum( p_meta, psz_trck );
119 snprintf( psz_trck, sizeof( psz_trck ), "%u", i_trktot );
120 vlc_meta_Set( p_meta, vlc_meta_TrackTotal, psz_trck );
125 * Read meta information from APE tags
126 * @param tag: the APE tag
127 * @param p_demux_meta: the demuxer meta
128 * @param p_meta: the meta
130 static void ReadMetaFromAPE( APE::Tag* tag, demux_meta_t*, vlc_meta_t* p_meta )
133 #define SET( keyName, metaName ) \
134 item = tag->itemListMap()[keyName]; \
135 if( !item.isEmpty() ) vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) ); \
137 SET( "COPYRIGHT", Copyright );
138 SET( "LANGUAGE", Language );
139 SET( "PUBLISHER", Publisher );
144 item = tag->itemListMap()["TRACK"];
145 if( !item.isEmpty() )
147 ExtractTrackNumberValues( p_meta, item.toString().toCString( true ) );
152 #ifdef TAGLIB_HAVE_ASFPICTURE_H
154 * Read meta information from APE tags
155 * @param tag: the APE tag
156 * @param p_demux_meta: the demuxer meta
157 * @param p_meta: the meta
159 static void ReadMetaFromASF( ASF::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
162 ASF::AttributeList list = tag->attributeListMap()["WM/Picture"];
163 ASF::AttributeList::Iterator iter;
164 for( iter = list.begin(); iter != list.end(); iter++ )
166 const ASF::Picture asfPicture = (*iter).toPicture();
167 const ByteVector picture = asfPicture.picture();
168 const char *psz_mime = asfPicture.mimeType().toCString();
169 const char *p_data = picture.data();
170 const unsigned i_data = picture.size();
172 input_attachment_t *p_attachment;
174 if( asfPicture.description().size() > 0 )
175 psz_name = strdup( asfPicture.description().toCString( true ) );
178 if( asprintf( &psz_name, "%i", asfPicture.type() ) == -1 )
182 msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %u bytes",
183 psz_name, psz_mime, i_data );
185 p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
186 psz_name, p_data, i_data );
188 TAB_APPEND_CAST( (input_attachment_t**),
189 p_demux_meta->i_attachments, p_demux_meta->attachments,
194 if( asprintf( &psz_url, "attachment://%s",
195 p_attachment->psz_name ) == -1 )
197 vlc_meta_SetArtURL( p_meta, psz_url );
205 * Read meta information from id3v2 tags
206 * @param tag: the id3v2 tag
207 * @param p_demux_meta: the demuxer meta
208 * @param p_meta: the meta
210 static void ReadMetaFromId3v2( ID3v2::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
212 // Get the unique file identifier
213 ID3v2::FrameList list = tag->frameListMap()["UFID"];
214 ID3v2::FrameList::Iterator iter;
215 for( iter = list.begin(); iter != list.end(); iter++ )
217 ID3v2::UniqueFileIdentifierFrame* p_ufid =
218 dynamic_cast<ID3v2::UniqueFileIdentifierFrame*>(*iter);
221 const char *owner = p_ufid->owner().toCString();
222 if (!strcmp( owner, "http://musicbrainz.org" ))
224 /* ID3v2 UFID contains up to 64 bytes binary data
225 * but in our case it will be a '\0'
226 * terminated string */
228 int max_size = __MIN( p_ufid->identifier().size(), 63);
229 strncpy( psz_ufid, p_ufid->identifier().data(), max_size );
230 psz_ufid[max_size] = '\0';
231 vlc_meta_SetTrackID( p_meta, psz_ufid );
236 list = tag->frameListMap()["TXXX"];
237 for( iter = list.begin(); iter != list.end(); iter++ )
239 ID3v2::UserTextIdentificationFrame* p_txxx =
240 dynamic_cast<ID3v2::UserTextIdentificationFrame*>(*iter);
243 if( !strcmp( p_txxx->description().toCString( true ), "TRACKTOTAL" ) )
245 vlc_meta_Set( p_meta, vlc_meta_TrackTotal, p_txxx->fieldList().back().toCString( true ) );
248 vlc_meta_AddExtra( p_meta, p_txxx->description().toCString( true ),
249 p_txxx->fieldList().back().toCString( true ) );
252 // Get some more information
253 #define SET( tagName, metaName ) \
254 list = tag->frameListMap()[tagName]; \
255 if( !list.isEmpty() ) \
256 vlc_meta_Set##metaName( p_meta, \
257 (*list.begin())->toString().toCString( true ) );
259 SET( "TCOP", Copyright );
260 SET( "TENC", EncodedBy );
261 SET( "TLAN", Language );
262 SET( "TPUB", Publisher );
267 list = tag->frameListMap()["TRCK"];
268 if( !list.isEmpty() )
270 ExtractTrackNumberValues( p_meta, (*list.begin())->toString().toCString( true ) );
273 /* Preferred type of image
274 * The 21 types are defined in id3v2 standard:
275 * http://www.id3.org/id3v2.4.0-frames */
276 static const int pi_cover_score[] = {
278 5, /* 32x32 PNG image that should be used as the file icon */
279 4, /* File icon of a different size or format. */
280 20, /* Front cover image of the album. */
281 19, /* Back cover image of the album. */
282 13, /* Inside leaflet page of the album. */
283 18, /* Image from the album itself. */
284 17, /* Picture of the lead artist or soloist. */
285 16, /* Picture of the artist or performer. */
286 14, /* Picture of the conductor. */
287 15, /* Picture of the band or orchestra. */
288 9, /* Picture of the composer. */
289 8, /* Picture of the lyricist or text writer. */
290 7, /* Picture of the recording location or studio. */
291 10, /* Picture of the artists during recording. */
292 11, /* Picture of the artists during performance. */
293 6, /* Picture from a movie or video related to the track. */
294 1, /* Picture of a large, coloured fish. */
295 12, /* Illustration related to the track. */
296 3, /* Logo of the band or performer. */
297 2 /* Logo of the publisher (record company). */
299 #define PI_COVER_SCORE_SIZE (sizeof (pi_cover_score) / sizeof (pi_cover_score[0]))
302 // Try now to get embedded art
303 list = tag->frameListMap()[ "APIC" ];
307 TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
308 for( iter = list.begin(); iter != list.end(); iter++ )
310 ID3v2::AttachedPictureFrame* p_apic =
311 dynamic_cast<ID3v2::AttachedPictureFrame*>(*iter);
314 input_attachment_t *p_attachment;
316 const char *psz_mime;
317 char *psz_name, *psz_description;
319 // Get the mime and description of the image.
320 // If the description is empty, take the type as a description
321 psz_mime = p_apic->mimeType().toCString( true );
322 if( p_apic->description().size() > 0 )
323 psz_description = strdup( p_apic->description().toCString( true ) );
326 if( asprintf( &psz_description, "%i", p_apic->type() ) == -1 )
327 psz_description = NULL;
330 if( !psz_description )
332 psz_name = psz_description;
334 /* some old iTunes version not only sets incorrectly the mime type
335 * or the description of the image,
336 * but also embeds incorrectly the image.
337 * Recent versions seem to behave correctly */
338 if( !strncmp( psz_mime, "PNG", 3 ) ||
339 !strncmp( psz_name, "\xC2\x89PNG", 5 ) )
341 msg_Warn( p_demux_meta, "Invalid picture embedded by broken iTunes version" );
342 free( psz_description );
346 const ByteVector picture = p_apic->picture();
347 const char *p_data = picture.data();
348 const unsigned i_data = picture.size();
350 msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %u bytes",
351 psz_name, psz_mime, i_data );
353 p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
354 psz_description, p_data, i_data );
356 TAB_APPEND_CAST( (input_attachment_t**),
357 p_demux_meta->i_attachments, p_demux_meta->attachments,
359 free( psz_description );
361 unsigned i_pic_type = p_apic->type();
362 if( i_pic_type >= PI_COVER_SCORE_SIZE )
363 i_pic_type = 0; // Defaults to "Other"
365 if( pi_cover_score[i_pic_type] > i_score )
367 i_score = pi_cover_score[i_pic_type];
369 if( asprintf( &psz_url, "attachment://%s",
370 p_attachment->psz_name ) == -1 )
372 vlc_meta_SetArtURL( p_meta, psz_url );
380 * Read the meta information from XiphComments
381 * @param tag: the Xiph Comment
382 * @param p_demux_meta: the demuxer meta
383 * @param p_meta: the meta
385 static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
388 #define SET( keyName, metaName ) \
389 list = tag->fieldListMap()[keyName]; \
390 if( !list.isEmpty() ) \
391 vlc_meta_Set##metaName( p_meta, (*list.begin()).toCString( true ) );
393 SET( "COPYRIGHT", Copyright );
396 // Try now to get embedded art
397 StringList mime_list = tag->fieldListMap()[ "COVERARTMIME" ];
398 StringList art_list = tag->fieldListMap()[ "COVERART" ];
400 input_attachment_t *p_attachment;
402 if( mime_list.size() != 0 && art_list.size() != 0 )
404 // We get only the first covert art
405 if( mime_list.size() > 1 || art_list.size() > 1 )
406 msg_Warn( p_demux_meta, "Found %i embedded arts, so using only the first one",
409 const char* psz_name = "cover";
410 const char* psz_mime = mime_list[0].toCString(true);
411 const char* psz_description = "cover";
414 int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) );
416 msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %i bytes",
417 psz_name, psz_mime, i_data );
419 p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
420 psz_description, p_data, i_data );
425 art_list = tag->fieldListMap()[ "METADATA_BLOCK_PICTURE" ];
426 if( art_list.size() == 0 )
431 int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) );
432 p_attachment = ParseFlacPicture( p_data, i_data, 0, &type );
435 TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
436 TAB_APPEND_CAST( (input_attachment_t**),
437 p_demux_meta->i_attachments, p_demux_meta->attachments,
441 if( asprintf( &psz_url, "attachment://%s", p_attachment->psz_name ) != -1 ) {
442 vlc_meta_SetArtURL( p_meta, psz_url );
448 #ifdef TAGLIB_HAVE_MP4COVERTART_H
450 * Read the meta information from mp4 specific tags
451 * @param tag: the mp4 tag
452 * @param p_demux_meta: the demuxer meta
453 * @param p_meta: the meta
455 static void ReadMetaFromMP4( MP4::Tag* tag, demux_meta_t *p_demux_meta, vlc_meta_t* p_meta )
457 if( tag->itemListMap().contains("covr") )
459 MP4::CoverArtList list = tag->itemListMap()["covr"].toCoverArtList();
460 const char *psz_format = list[0].format() == MP4::CoverArt::PNG ? "image/png" : "image/jpeg";
462 msg_Dbg( p_demux_meta, "Found embedded art (%s) is %i bytes",
463 psz_format, list[0].data().size() );
465 TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
466 input_attachment_t *p_attachment =
467 vlc_input_attachment_New( "cover", psz_format, "cover",
468 list[0].data().data(), list[0].data().size() );
469 TAB_APPEND_CAST( (input_attachment_t**),
470 p_demux_meta->i_attachments, p_demux_meta->attachments,
472 vlc_meta_SetArtURL( p_meta, "attachment://cover" );
479 * Get the tags from the file using TagLib
480 * @param p_this: the demux object
481 * @return VLC_SUCCESS if the operation success
483 static int ReadMeta( vlc_object_t* p_this)
485 vlc_mutex_locker locker (&taglib_lock);
486 demux_meta_t* p_demux_meta = (demux_meta_t *)p_this;
487 demux_t* p_demux = p_demux_meta->p_demux;
491 p_demux_meta->p_meta = NULL;
492 if( strcmp( p_demux->psz_access, "file" ) )
495 char *psz_path = strdup( p_demux->psz_file );
499 #if defined(WIN32) || defined (UNDER_CE)
500 wchar_t *wpath = ToWide( psz_path );
506 f = FileRef( wpath );
509 f = FileRef( psz_path );
515 if( !f.tag() || f.tag()->isEmpty() )
518 p_demux_meta->p_meta = p_meta = vlc_meta_New();
523 // Read the tags from the file
524 Tag* p_tag = f.tag();
526 #define SET( tag, meta ) \
527 if( !p_tag->tag().isNull() && !p_tag->tag().isEmpty() ) \
528 vlc_meta_Set##meta( p_meta, p_tag->tag().toCString(true) )
529 #define SETINT( tag, meta ) \
533 snprintf( psz_tmp, 10, "%d", p_tag->tag() ); \
534 vlc_meta_Set##meta( p_meta, psz_tmp ); \
538 SET( artist, Artist );
540 SET( comment, Description );
542 SETINT( year, Date );
543 SETINT( track, TrackNum );
549 // Try now to read special tags
550 #ifdef TAGLIB_HAVE_APEFILE_H
551 if( APE::File* ape = dynamic_cast<APE::File*>(f.file()) )
554 ReadMetaFromAPE( ape->APETag(), p_demux_meta, p_meta );
558 #ifdef TAGLIB_HAVE_ASFPICTURE_H
559 if( ASF::File* asf = dynamic_cast<ASF::File*>(f.file()) )
562 ReadMetaFromASF( asf->tag(), p_demux_meta, p_meta );
566 if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
568 if( flac->ID3v2Tag() )
569 ReadMetaFromId3v2( flac->ID3v2Tag(), p_demux_meta, p_meta );
570 else if( flac->xiphComment() )
571 ReadMetaFromXiph( flac->xiphComment(), p_demux_meta, p_meta );
573 #ifdef TAGLIB_HAVE_MP4COVERTART_H
574 else if( MP4::File *mp4 = dynamic_cast<MP4::File*>(f.file()) )
577 ReadMetaFromMP4( mp4->tag(), p_demux_meta, p_meta );
580 else if( MPC::File* mpc = dynamic_cast<MPC::File*>(f.file()) )
583 ReadMetaFromAPE( mpc->APETag(), p_demux_meta, p_meta );
585 else if( MPEG::File* mpeg = dynamic_cast<MPEG::File*>(f.file()) )
587 if( mpeg->ID3v2Tag() )
588 ReadMetaFromId3v2( mpeg->ID3v2Tag(), p_demux_meta, p_meta );
589 else if( mpeg->APETag() )
590 ReadMetaFromAPE( mpeg->APETag(), p_demux_meta, p_meta );
592 else if( dynamic_cast<Ogg::File*>(f.file()) )
594 if( Ogg::FLAC::File* ogg_flac = dynamic_cast<Ogg::FLAC::File*>(f.file()))
595 ReadMetaFromXiph( ogg_flac->tag(), p_demux_meta, p_meta );
596 else if( Ogg::Speex::File* ogg_speex = dynamic_cast<Ogg::Speex::File*>(f.file()) )
597 ReadMetaFromXiph( ogg_speex->tag(), p_demux_meta, p_meta );
598 else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
599 ReadMetaFromXiph( ogg_vorbis->tag(), p_demux_meta, p_meta );
601 #ifdef TAGLIB_HAVE_AIFF_WAV_H
602 else if( dynamic_cast<RIFF::File*>(f.file()) )
604 if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )
605 ReadMetaFromId3v2( riff_aiff->tag(), p_demux_meta, p_meta );
606 else if( RIFF::WAV::File* riff_wav = dynamic_cast<RIFF::WAV::File*>(f.file()) )
607 ReadMetaFromId3v2( riff_wav->tag(), p_demux_meta, p_meta );
610 else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
612 if( trueaudio->ID3v2Tag() )
613 ReadMetaFromId3v2( trueaudio->ID3v2Tag(), p_demux_meta, p_meta );
615 else if( WavPack::File* wavpack = dynamic_cast<WavPack::File*>(f.file()) )
617 if( wavpack->APETag() )
618 ReadMetaFromAPE( wavpack->APETag(), p_demux_meta, p_meta );
626 * Write meta information to APE tags
627 * @param tag: the APE tag
628 * @param p_item: the input item
630 static void WriteMetaToAPE( APE::Tag* tag, input_item_t* p_item )
633 #define WRITE( metaName, keyName ) \
634 psz_meta = input_item_Get##metaName( p_item ); \
637 String key( keyName, String::UTF8 ); \
638 String value( psz_meta, String::UTF8 ); \
639 tag->addValue( key, value, true ); \
643 WRITE( Copyright, "COPYRIGHT" );
644 WRITE( Language, "LANGUAGE" );
645 WRITE( Publisher, "PUBLISHER" );
652 * Write meta information to id3v2 tags
653 * @param tag: the id3v2 tag
654 * @param p_input: the input item
656 static void WriteMetaToId3v2( ID3v2::Tag* tag, input_item_t* p_item )
659 #define WRITE( metaName, tagName ) \
660 psz_meta = input_item_Get##metaName( p_item ); \
663 ByteVector p_byte( tagName, 4 ); \
664 tag->removeFrames( p_byte ); \
665 ID3v2::TextIdentificationFrame* p_frame = \
666 new ID3v2::TextIdentificationFrame( p_byte, String::UTF8 ); \
667 p_frame->setText( psz_meta ); \
668 tag->addFrame( p_frame ); \
672 WRITE( Copyright, "TCOP" );
673 WRITE( EncodedBy, "TENC" );
674 WRITE( Language, "TLAN" );
675 WRITE( Publisher, "TPUB" );
682 * Write the meta information to XiphComments
683 * @param tag: the Xiph Comment
684 * @param p_input: the input item
686 static void WriteMetaToXiph( Ogg::XiphComment* tag, input_item_t* p_item )
689 #define WRITE( metaName, keyName ) \
690 psz_meta = input_item_Get##metaName( p_item ); \
693 String key( keyName, String::UTF8 ); \
694 String value( psz_meta, String::UTF8 ); \
695 tag->addField( key, value, true ); \
699 WRITE( Copyright, "COPYRIGHT" );
706 * Set the tags to the file using TagLib
707 * @param p_this: the demux object
708 * @return VLC_SUCCESS if the operation success
711 static int WriteMeta( vlc_object_t *p_this )
713 vlc_mutex_locker locker (&taglib_lock);
714 meta_export_t *p_export = (meta_export_t *)p_this;
715 input_item_t *p_item = p_export->p_item;
720 msg_Err( p_this, "Can't save meta data of an empty input" );
724 #if defined(WIN32) || defined (UNDER_CE)
725 wchar_t *wpath = ToWide( p_export->psz_file );
728 f = FileRef( wpath );
731 f = FileRef( p_export->psz_file );
734 if( f.isNull() || !f.tag() || f.file()->readOnly() )
736 msg_Err( p_this, "File %s can't be opened for tag writing",
737 p_export->psz_file );
741 msg_Dbg( p_this, "Writing metadata for %s", p_export->psz_file );
743 Tag *p_tag = f.tag();
747 #define SET( a, b ) \
748 psz_meta = input_item_Get ## a( p_item ); \
751 String tmp( psz_meta, String::UTF8 ); \
752 p_tag->set##b( tmp ); \
756 // Saving all common fields
757 // If the title is empty, use the name
758 SET( TitleFbName, Title );
759 SET( Artist, Artist );
761 SET( Description, Comment );
766 psz_meta = input_item_GetDate( p_item );
767 if( !EMPTY_STR(psz_meta) ) p_tag->setYear( atoi( psz_meta ) );
770 psz_meta = input_item_GetTrackNum( p_item );
771 if( !EMPTY_STR(psz_meta) ) p_tag->setTrack( atoi( psz_meta ) );
775 // Try now to write special tags
776 #ifdef TAGLIB_HAVE_APEFILE_H
777 if( APE::File* ape = dynamic_cast<APE::File*>(f.file()) )
780 WriteMetaToAPE( ape->APETag(), p_item );
784 if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
786 if( flac->ID3v2Tag() )
787 WriteMetaToId3v2( flac->ID3v2Tag(), p_item );
788 else if( flac->xiphComment() )
789 WriteMetaToXiph( flac->xiphComment(), p_item );
791 else if( MPC::File* mpc = dynamic_cast<MPC::File*>(f.file()) )
794 WriteMetaToAPE( mpc->APETag(), p_item );
796 else if( MPEG::File* mpeg = dynamic_cast<MPEG::File*>(f.file()) )
798 if( mpeg->ID3v2Tag() )
799 WriteMetaToId3v2( mpeg->ID3v2Tag(), p_item );
800 else if( mpeg->APETag() )
801 WriteMetaToAPE( mpeg->APETag(), p_item );
803 else if( dynamic_cast<Ogg::File*>(f.file()) )
805 if( Ogg::FLAC::File* ogg_flac = dynamic_cast<Ogg::FLAC::File*>(f.file()))
806 WriteMetaToXiph( ogg_flac->tag(), p_item );
807 else if( Ogg::Speex::File* ogg_speex = dynamic_cast<Ogg::Speex::File*>(f.file()) )
808 WriteMetaToXiph( ogg_speex->tag(), p_item );
809 else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
810 WriteMetaToXiph( ogg_vorbis->tag(), p_item );
812 #ifdef TAGLIB_HAVE_AIFF_WAV_H
813 else if( dynamic_cast<RIFF::File*>(f.file()) )
815 if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )
816 WriteMetaToId3v2( riff_aiff->tag(), p_item );
817 else if( RIFF::WAV::File* riff_wav = dynamic_cast<RIFF::WAV::File*>(f.file()) )
818 WriteMetaToId3v2( riff_wav->tag(), p_item );
821 else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
823 if( trueaudio->ID3v2Tag() )
824 WriteMetaToId3v2( trueaudio->ID3v2Tag(), p_item );
826 else if( WavPack::File* wavpack = dynamic_cast<WavPack::File*>(f.file()) )
828 if( wavpack->APETag() )
829 WriteMetaToAPE( wavpack->APETag(), p_item );
832 // Save the meta data