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_charset.h> /* ToLocale, LocaleFree */
35 #include <vlc_input.h> /* for attachment_new */
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>
71 #if TAGLIB_VERSION >= VERSION_INT(1,6,0)
72 # define TAGLIB_HAVE_AIFF_WAV_H
73 # include <aifffile.h>
76 # include <id3v2tag.h>
79 #if TAGLIB_VERSION >= VERSION_INT(1,6,1) && defined(TAGLIB_WITH_MP4)
80 # define TAGLIB_HAVE_MP4COVERTART_H
84 #include <speexfile.h>
85 #include <trueaudiofile.h>
86 #include <vorbisfile.h>
87 #include <wavpackfile.h>
89 #include <attachedpictureframe.h>
90 #include <textidentificationframe.h>
91 #include <uniquefileidentifierframe.h>
93 // taglib is not thread safe
94 static vlc_mutex_t taglib_lock
= VLC_STATIC_MUTEX
;
97 static int ReadMeta ( vlc_object_t
* );
98 static int WriteMeta ( vlc_object_t
* );
101 set_capability( "meta reader", 1000 )
102 set_callbacks( ReadMeta
, NULL
)
104 set_capability( "meta writer", 50 )
105 set_callbacks( WriteMeta
, NULL
)
108 using namespace TagLib
;
112 * Read meta information from APE tags
113 * @param tag: the APE tag
114 * @param p_demux_meta: the demuxer meta
115 * @param p_meta: the meta
117 static void ReadMetaFromAPE( APE::Tag
* tag
, demux_meta_t
*, vlc_meta_t
* p_meta
)
120 #define SET( keyName, metaName ) \
121 item = tag->itemListMap()[keyName]; \
122 if( !item.isEmpty() ) vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) ); \
124 SET( "COPYRIGHT", Copyright );
125 SET( "LANGUAGE", Language
);
126 SET( "PUBLISHER", Publisher
);
132 #ifdef TAGLIB_HAVE_ASFPICTURE_H
134 * Read meta information from APE tags
135 * @param tag: the APE tag
136 * @param p_demux_meta: the demuxer meta
137 * @param p_meta: the meta
139 static void ReadMetaFromASF( ASF::Tag
* tag
, demux_meta_t
* p_demux_meta
, vlc_meta_t
* p_meta
)
142 ASF::AttributeList list
= tag
->attributeListMap()["WM/Picture"];
143 ASF::AttributeList::Iterator iter
;
144 for( iter
= list
.begin(); iter
!= list
.end(); iter
++ )
146 const ASF::Picture asfPicture
= (*iter
).toPicture();
147 const ByteVector picture
= asfPicture
.picture();
148 const char *psz_mime
= asfPicture
.mimeType().toCString();
149 const char *p_data
= picture
.data();
150 const unsigned i_data
= picture
.size();
152 input_attachment_t
*p_attachment
;
154 if( asfPicture
.description().size() > 0 )
155 psz_name
= strdup( asfPicture
.description().toCString( true ) );
158 if( asprintf( &psz_name
, "%i", asfPicture
.type() ) == -1 )
162 msg_Dbg( p_demux_meta
, "Found embedded art: %s (%s) is %u bytes",
163 psz_name
, psz_mime
, i_data
);
165 p_attachment
= vlc_input_attachment_New( psz_name
, psz_mime
,
166 psz_name
, p_data
, i_data
);
168 TAB_APPEND_CAST( (input_attachment_t
**),
169 p_demux_meta
->i_attachments
, p_demux_meta
->attachments
,
174 if( asprintf( &psz_url
, "attachment://%s",
175 p_attachment
->psz_name
) == -1 )
177 vlc_meta_SetArtURL( p_meta
, psz_url
);
185 * Read meta information from id3v2 tags
186 * @param tag: the id3v2 tag
187 * @param p_demux_meta: the demuxer meta
188 * @param p_meta: the meta
190 static void ReadMetaFromId3v2( ID3v2::Tag
* tag
, demux_meta_t
* p_demux_meta
, vlc_meta_t
* p_meta
)
192 // Get the unique file identifier
193 ID3v2::FrameList list
= tag
->frameListMap()["UFID"];
194 ID3v2::FrameList::Iterator iter
;
195 for( iter
= list
.begin(); iter
!= list
.end(); iter
++ )
197 ID3v2::UniqueFileIdentifierFrame
* p_ufid
=
198 dynamic_cast<ID3v2::UniqueFileIdentifierFrame
*>(*iter
);
201 const char *owner
= p_ufid
->owner().toCString();
202 if (!strcmp( owner
, "http://musicbrainz.org" ))
204 /* ID3v2 UFID contains up to 64 bytes binary data
205 * but in our case it will be a '\0'
206 * terminated string */
208 int max_size
= __MIN( p_ufid
->identifier().size(), 63);
209 strncpy( psz_ufid
, p_ufid
->identifier().data(), max_size
);
210 psz_ufid
[max_size
] = '\0';
211 vlc_meta_SetTrackID( p_meta
, psz_ufid
);
216 list
= tag
->frameListMap()["TXXX"];
217 for( iter
= list
.begin(); iter
!= list
.end(); iter
++ )
219 ID3v2::UserTextIdentificationFrame
* p_txxx
=
220 dynamic_cast<ID3v2::UserTextIdentificationFrame
*>(*iter
);
223 vlc_meta_AddExtra( p_meta
, p_txxx
->description().toCString( true ),
224 p_txxx
->fieldList().back().toCString( true ) );
227 // Get some more information
228 #define SET( tagName, metaName ) \
229 list = tag->frameListMap()[tagName]; \
230 if( !list.isEmpty() ) \
231 vlc_meta_Set##metaName( p_meta, \
232 (*list.begin())->toString().toCString( true ) );
234 SET( "TCOP", Copyright
);
235 SET( "TENC", EncodedBy
);
236 SET( "TLAN", Language
);
237 SET( "TPUB", Publisher
);
241 /* Preferred type of image
242 * The 21 types are defined in id3v2 standard:
243 * http://www.id3.org/id3v2.4.0-frames */
244 static const int pi_cover_score
[] = {
246 5, /* 32x32 PNG image that should be used as the file icon */
247 4, /* File icon of a different size or format. */
248 20, /* Front cover image of the album. */
249 19, /* Back cover image of the album. */
250 13, /* Inside leaflet page of the album. */
251 18, /* Image from the album itself. */
252 17, /* Picture of the lead artist or soloist. */
253 16, /* Picture of the artist or performer. */
254 14, /* Picture of the conductor. */
255 15, /* Picture of the band or orchestra. */
256 9, /* Picture of the composer. */
257 8, /* Picture of the lyricist or text writer. */
258 7, /* Picture of the recording location or studio. */
259 10, /* Picture of the artists during recording. */
260 11, /* Picture of the artists during performance. */
261 6, /* Picture from a movie or video related to the track. */
262 1, /* Picture of a large, coloured fish. */
263 12, /* Illustration related to the track. */
264 3, /* Logo of the band or performer. */
265 2 /* Logo of the publisher (record company). */
267 #define PI_COVER_SCORE_SIZE (sizeof (pi_cover_score) / sizeof (pi_cover_score[0]))
270 // Try now to get embedded art
271 list
= tag
->frameListMap()[ "APIC" ];
275 TAB_INIT( p_demux_meta
->i_attachments
, p_demux_meta
->attachments
);
276 for( iter
= list
.begin(); iter
!= list
.end(); iter
++ )
278 ID3v2::AttachedPictureFrame
* p_apic
=
279 dynamic_cast<ID3v2::AttachedPictureFrame
*>(*iter
);
282 input_attachment_t
*p_attachment
;
284 const char *psz_mime
;
285 char *psz_name
, *psz_description
;
287 // Get the mime and description of the image.
288 // If the description is empty, take the type as a description
289 psz_mime
= p_apic
->mimeType().toCString( true );
290 if( p_apic
->description().size() > 0 )
291 psz_description
= strdup( p_apic
->description().toCString( true ) );
294 if( asprintf( &psz_description
, "%i", p_apic
->type() ) == -1 )
295 psz_description
= NULL
;
298 if( !psz_description
)
300 psz_name
= psz_description
;
302 /* some old iTunes version not only sets incorrectly the mime type
303 * or the description of the image,
304 * but also embeds incorrectly the image.
305 * Recent versions seem to behave correctly */
306 if( !strncmp( psz_mime
, "PNG", 3 ) ||
307 !strncmp( psz_name
, "\xC2\x89PNG", 5 ) )
309 msg_Warn( p_demux_meta
, "Invalid picture embedded by broken iTunes version" );
310 free( psz_description
);
314 const ByteVector picture
= p_apic
->picture();
315 const char *p_data
= picture
.data();
316 const unsigned i_data
= picture
.size();
318 msg_Dbg( p_demux_meta
, "Found embedded art: %s (%s) is %u bytes",
319 psz_name
, psz_mime
, i_data
);
321 p_attachment
= vlc_input_attachment_New( psz_name
, psz_mime
,
322 psz_description
, p_data
, i_data
);
324 TAB_APPEND_CAST( (input_attachment_t
**),
325 p_demux_meta
->i_attachments
, p_demux_meta
->attachments
,
327 free( psz_description
);
329 unsigned i_pic_type
= p_apic
->type();
330 if( i_pic_type
>= PI_COVER_SCORE_SIZE
)
331 i_pic_type
= 0; // Defaults to "Other"
333 if( pi_cover_score
[i_pic_type
] > i_score
)
335 i_score
= pi_cover_score
[i_pic_type
];
337 if( asprintf( &psz_url
, "attachment://%s",
338 p_attachment
->psz_name
) == -1 )
340 vlc_meta_SetArtURL( p_meta
, psz_url
);
348 * Read the meta information from XiphComments
349 * @param tag: the Xiph Comment
350 * @param p_demux_meta: the demuxer meta
351 * @param p_meta: the meta
353 static void ReadMetaFromXiph( Ogg::XiphComment
* tag
, demux_meta_t
* p_demux_meta
, vlc_meta_t
* p_meta
)
356 #define SET( keyName, metaName ) \
357 list = tag->fieldListMap()[keyName]; \
358 if( !list.isEmpty() ) \
359 vlc_meta_Set##metaName( p_meta, (*list.begin()).toCString( true ) );
361 SET( "COPYRIGHT", Copyright
);
364 // Try now to get embedded art
365 StringList mime_list
= tag
->fieldListMap()[ "COVERARTMIME" ];
366 StringList art_list
= tag
->fieldListMap()[ "COVERART" ];
368 // We get only the first covert art
369 if( mime_list
.size() > 1 || art_list
.size() > 1 )
370 msg_Warn( p_demux_meta
, "Found %i embedded arts, so using only the first one",
372 else if( mime_list
.size() == 0 || art_list
.size() == 0 )
375 input_attachment_t
*p_attachment
;
377 const char* psz_name
= "cover";
378 const char* psz_mime
= mime_list
[0].toCString(true);
379 const char* psz_description
= "cover";
382 int i_data
= vlc_b64_decode_binary( &p_data
, art_list
[0].toCString(true) );
384 msg_Dbg( p_demux_meta
, "Found embedded art: %s (%s) is %i bytes",
385 psz_name
, psz_mime
, i_data
);
387 TAB_INIT( p_demux_meta
->i_attachments
, p_demux_meta
->attachments
);
388 p_attachment
= vlc_input_attachment_New( psz_name
, psz_mime
,
389 psz_description
, p_data
, i_data
);
392 TAB_APPEND_CAST( (input_attachment_t
**),
393 p_demux_meta
->i_attachments
, p_demux_meta
->attachments
,
396 vlc_meta_SetArtURL( p_meta
, "attachment://cover" );
400 #ifdef TAGLIB_HAVE_MP4COVERTART_H
402 * Read the meta information from mp4 specific tags
403 * @param tag: the mp4 tag
404 * @param p_demux_meta: the demuxer meta
405 * @param p_meta: the meta
407 static void ReadMetaFromMP4( MP4::Tag
* tag
, demux_meta_t
*p_demux_meta
, vlc_meta_t
* p_meta
)
409 if( tag
->itemListMap().contains("covr") )
411 MP4::CoverArtList list
= tag
->itemListMap()["covr"].toCoverArtList();
412 const char *psz_format
= list
[0].format() == MP4::CoverArt::PNG
? "image/png" : "image/jpeg";
414 msg_Dbg( p_demux_meta
, "Found embedded art (%s) is %i bytes",
415 psz_format
, list
[0].data().size() );
417 TAB_INIT( p_demux_meta
->i_attachments
, p_demux_meta
->attachments
);
418 input_attachment_t
*p_attachment
=
419 vlc_input_attachment_New( "cover", psz_format
, "cover",
420 list
[0].data().data(), list
[0].data().size() );
421 TAB_APPEND_CAST( (input_attachment_t
**),
422 p_demux_meta
->i_attachments
, p_demux_meta
->attachments
,
424 vlc_meta_SetArtURL( p_meta
, "attachment://cover" );
431 * Get the tags from the file using TagLib
432 * @param p_this: the demux object
433 * @return VLC_SUCCESS if the operation success
435 static int ReadMeta( vlc_object_t
* p_this
)
437 vlc_mutex_locker
locker (&taglib_lock
);
438 demux_meta_t
* p_demux_meta
= (demux_meta_t
*)p_this
;
439 demux_t
* p_demux
= p_demux_meta
->p_demux
;
443 p_demux_meta
->p_meta
= NULL
;
444 if( strcmp( p_demux
->psz_access
, "file" ) )
447 char *psz_path
= strdup( p_demux
->psz_file
);
451 #if defined(WIN32) || defined (UNDER_CE)
452 wchar_t *wpath
= ToWide( psz_path
);
458 f
= FileRef( wpath
);
461 const char* local_name
= ToLocale( psz_path
);
467 f
= FileRef( local_name
);
468 LocaleFree( local_name
);
474 if( !f
.tag() || f
.tag()->isEmpty() )
477 p_demux_meta
->p_meta
= p_meta
= vlc_meta_New();
482 // Read the tags from the file
483 Tag
* p_tag
= f
.tag();
485 #define SET( tag, meta ) \
486 if( !p_tag->tag().isNull() && !p_tag->tag().isEmpty() ) \
487 vlc_meta_Set##meta( p_meta, p_tag->tag().toCString(true) )
488 #define SETINT( tag, meta ) \
492 snprintf( psz_tmp, 10, "%d", p_tag->tag() ); \
493 vlc_meta_Set##meta( p_meta, psz_tmp ); \
497 SET( artist
, Artist
);
499 SET( comment
, Description
);
501 SETINT( year
, Date
);
502 SETINT( track
, TrackNum
);
508 // Try now to read special tags
509 #ifdef TAGLIB_HAVE_APEFILE_H
510 if( APE::File
* ape
= dynamic_cast<APE::File
*>(f
.file()) )
513 ReadMetaFromAPE( ape
->APETag(), p_demux_meta
, p_meta
);
517 #ifdef TAGLIB_HAVE_ASFPICTURE_H
518 if( ASF::File
* asf
= dynamic_cast<ASF::File
*>(f
.file()) )
521 ReadMetaFromASF( asf
->tag(), p_demux_meta
, p_meta
);
525 if( FLAC::File
* flac
= dynamic_cast<FLAC::File
*>(f
.file()) )
527 if( flac
->ID3v2Tag() )
528 ReadMetaFromId3v2( flac
->ID3v2Tag(), p_demux_meta
, p_meta
);
529 else if( flac
->xiphComment() )
530 ReadMetaFromXiph( flac
->xiphComment(), p_demux_meta
, p_meta
);
532 #ifdef TAGLIB_HAVE_MP4COVERTART_H
533 else if( MP4::File
*mp4
= dynamic_cast<MP4::File
*>(f
.file()) )
536 ReadMetaFromMP4( mp4
->tag(), p_demux_meta
, p_meta
);
539 else if( MPC::File
* mpc
= dynamic_cast<MPC::File
*>(f
.file()) )
542 ReadMetaFromAPE( mpc
->APETag(), p_demux_meta
, p_meta
);
544 else if( MPEG::File
* mpeg
= dynamic_cast<MPEG::File
*>(f
.file()) )
546 if( mpeg
->ID3v2Tag() )
547 ReadMetaFromId3v2( mpeg
->ID3v2Tag(), p_demux_meta
, p_meta
);
548 else if( mpeg
->APETag() )
549 ReadMetaFromAPE( mpeg
->APETag(), p_demux_meta
, p_meta
);
551 else if( dynamic_cast<Ogg::File
*>(f
.file()) )
553 if( Ogg::FLAC::File
* ogg_flac
= dynamic_cast<Ogg::FLAC::File
*>(f
.file()))
554 ReadMetaFromXiph( ogg_flac
->tag(), p_demux_meta
, p_meta
);
555 else if( Ogg::Speex::File
* ogg_speex
= dynamic_cast<Ogg::Speex::File
*>(f
.file()) )
556 ReadMetaFromXiph( ogg_speex
->tag(), p_demux_meta
, p_meta
);
557 else if( Ogg::Vorbis::File
* ogg_vorbis
= dynamic_cast<Ogg::Vorbis::File
*>(f
.file()) )
558 ReadMetaFromXiph( ogg_vorbis
->tag(), p_demux_meta
, p_meta
);
560 #ifdef TAGLIB_HAVE_AIFF_WAV_H
561 else if( dynamic_cast<RIFF::File
*>(f
.file()) )
563 if( RIFF::AIFF::File
* riff_aiff
= dynamic_cast<RIFF::AIFF::File
*>(f
.file()) )
564 ReadMetaFromId3v2( riff_aiff
->tag(), p_demux_meta
, p_meta
);
565 else if( RIFF::WAV::File
* riff_wav
= dynamic_cast<RIFF::WAV::File
*>(f
.file()) )
566 ReadMetaFromId3v2( riff_wav
->tag(), p_demux_meta
, p_meta
);
569 else if( TrueAudio::File
* trueaudio
= dynamic_cast<TrueAudio::File
*>(f
.file()) )
571 if( trueaudio
->ID3v2Tag() )
572 ReadMetaFromId3v2( trueaudio
->ID3v2Tag(), p_demux_meta
, p_meta
);
574 else if( WavPack::File
* wavpack
= dynamic_cast<WavPack::File
*>(f
.file()) )
576 if( wavpack
->APETag() )
577 ReadMetaFromAPE( wavpack
->APETag(), p_demux_meta
, p_meta
);
585 * Write meta information to APE tags
586 * @param tag: the APE tag
587 * @param p_item: the input item
589 static void WriteMetaToAPE( APE::Tag
* tag
, input_item_t
* p_item
)
592 #define WRITE( metaName, keyName ) \
593 psz_meta = input_item_Get##metaName( p_item ); \
596 String key( keyName, String::UTF8 ); \
597 String value( psz_meta, String::UTF8 ); \
598 tag->addValue( key, value, true ); \
602 WRITE( Copyright
, "COPYRIGHT" );
603 WRITE( Language
, "LANGUAGE" );
604 WRITE( Publisher
, "PUBLISHER" );
611 * Write meta information to id3v2 tags
612 * @param tag: the id3v2 tag
613 * @param p_input: the input item
615 static void WriteMetaToId3v2( ID3v2::Tag
* tag
, input_item_t
* p_item
)
618 #define WRITE( metaName, tagName ) \
619 psz_meta = input_item_Get##metaName( p_item ); \
622 ByteVector p_byte( tagName, 4 ); \
623 tag->removeFrames( p_byte ); \
624 ID3v2::TextIdentificationFrame* p_frame = \
625 new ID3v2::TextIdentificationFrame( p_byte, String::UTF8 ); \
626 p_frame->setText( psz_meta ); \
627 tag->addFrame( p_frame ); \
631 WRITE( Copyright
, "TCOP" );
632 WRITE( EncodedBy
, "TENC" );
633 WRITE( Language
, "TLAN" );
634 WRITE( Publisher
, "TPUB" );
641 * Write the meta information to XiphComments
642 * @param tag: the Xiph Comment
643 * @param p_input: the input item
645 static void WriteMetaToXiph( Ogg::XiphComment
* tag
, input_item_t
* p_item
)
648 #define WRITE( metaName, keyName ) \
649 psz_meta = input_item_Get##metaName( p_item ); \
652 String key( keyName, String::UTF8 ); \
653 String value( psz_meta, String::UTF8 ); \
654 tag->addField( key, value, true ); \
658 WRITE( Copyright
, "COPYRIGHT" );
665 * Set the tags to the file using TagLib
666 * @param p_this: the demux object
667 * @return VLC_SUCCESS if the operation success
670 static int WriteMeta( vlc_object_t
*p_this
)
672 vlc_mutex_locker
locker (&taglib_lock
);
673 meta_export_t
*p_export
= (meta_export_t
*)p_this
;
674 input_item_t
*p_item
= p_export
->p_item
;
679 msg_Err( p_this
, "Can't save meta data of an empty input" );
683 #if defined(WIN32) || defined (UNDER_CE)
684 wchar_t *wpath
= ToWide( p_export
->psz_file
);
687 f
= FileRef( wpath
);
690 const char* local_name
= ToLocale( p_export
->psz_file
);
693 f
= FileRef( local_name
);
694 LocaleFree( local_name
);
697 if( f
.isNull() || !f
.tag() || f
.file()->readOnly() )
699 msg_Err( p_this
, "File %s can't be opened for tag writing",
700 p_export
->psz_file
);
704 msg_Dbg( p_this
, "Writing metadata for %s", p_export
->psz_file
);
706 Tag
*p_tag
= f
.tag();
710 #define SET( a, b ) \
711 psz_meta = input_item_Get ## a( p_item ); \
714 String tmp( psz_meta, String::UTF8 ); \
715 p_tag->set##b( tmp ); \
719 // Saving all common fields
720 // If the title is empty, use the name
721 SET( TitleFbName
, Title
);
722 SET( Artist
, Artist
);
724 SET( Description
, Comment
);
729 psz_meta
= input_item_GetDate( p_item
);
730 if( !EMPTY_STR(psz_meta
) ) p_tag
->setYear( atoi( psz_meta
) );
733 psz_meta
= input_item_GetTrackNum( p_item
);
734 if( !EMPTY_STR(psz_meta
) ) p_tag
->setTrack( atoi( psz_meta
) );
738 // Try now to write special tags
739 #ifdef TAGLIB_HAVE_APEFILE_H
740 if( APE::File
* ape
= dynamic_cast<APE::File
*>(f
.file()) )
743 WriteMetaToAPE( ape
->APETag(), p_item
);
747 if( FLAC::File
* flac
= dynamic_cast<FLAC::File
*>(f
.file()) )
749 if( flac
->ID3v2Tag() )
750 WriteMetaToId3v2( flac
->ID3v2Tag(), p_item
);
751 else if( flac
->xiphComment() )
752 WriteMetaToXiph( flac
->xiphComment(), p_item
);
754 else if( MPC::File
* mpc
= dynamic_cast<MPC::File
*>(f
.file()) )
757 WriteMetaToAPE( mpc
->APETag(), p_item
);
759 else if( MPEG::File
* mpeg
= dynamic_cast<MPEG::File
*>(f
.file()) )
761 if( mpeg
->ID3v2Tag() )
762 WriteMetaToId3v2( mpeg
->ID3v2Tag(), p_item
);
763 else if( mpeg
->APETag() )
764 WriteMetaToAPE( mpeg
->APETag(), p_item
);
766 else if( dynamic_cast<Ogg::File
*>(f
.file()) )
768 if( Ogg::FLAC::File
* ogg_flac
= dynamic_cast<Ogg::FLAC::File
*>(f
.file()))
769 WriteMetaToXiph( ogg_flac
->tag(), p_item
);
770 else if( Ogg::Speex::File
* ogg_speex
= dynamic_cast<Ogg::Speex::File
*>(f
.file()) )
771 WriteMetaToXiph( ogg_speex
->tag(), p_item
);
772 else if( Ogg::Vorbis::File
* ogg_vorbis
= dynamic_cast<Ogg::Vorbis::File
*>(f
.file()) )
773 WriteMetaToXiph( ogg_vorbis
->tag(), p_item
);
775 #ifdef TAGLIB_HAVE_AIFF_WAV_H
776 else if( dynamic_cast<RIFF::File
*>(f
.file()) )
778 if( RIFF::AIFF::File
* riff_aiff
= dynamic_cast<RIFF::AIFF::File
*>(f
.file()) )
779 WriteMetaToId3v2( riff_aiff
->tag(), p_item
);
780 else if( RIFF::WAV::File
* riff_wav
= dynamic_cast<RIFF::WAV::File
*>(f
.file()) )
781 WriteMetaToId3v2( riff_wav
->tag(), p_item
);
784 else if( TrueAudio::File
* trueaudio
= dynamic_cast<TrueAudio::File
*>(f
.file()) )
786 if( trueaudio
->ID3v2Tag() )
787 WriteMetaToId3v2( trueaudio
->ID3v2Tag(), p_item
);
789 else if( WavPack::File
* wavpack
= dynamic_cast<WavPack::File
*>(f
.file()) )
791 if( wavpack
->APETag() )
792 WriteMetaToAPE( wavpack
->APETag(), p_item
);
795 // Save the meta data