]> git.sesse.net Git - vlc/blob - modules/meta_engine/taglib.cpp
taglib: improve the module to read metas from RIFF files.
[vlc] / modules / meta_engine / taglib.cpp
1 /*****************************************************************************
2  * taglib.cpp: Taglib tag parser/writer
3  *****************************************************************************
4  * Copyright (C) 2003-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Rafaël Carré <funman@videolanorg>
9  *          Rémi Duraffort <ivoire@videolan.org>
10  *
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.
15  *
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.
20  *
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  *****************************************************************************/
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <vlc_common.h>
31 #include <vlc_plugin.h>
32 #include <vlc_playlist.h>
33 #include <vlc_meta.h>
34 #include <vlc_demux.h>
35 #include <vlc_strings.h>
36 #include <vlc_charset.h>
37 #include <vlc_url.h>
38
39 #ifdef WIN32
40 # include <io.h>
41 #else
42 # include <unistd.h>
43 #endif
44
45
46 // Taglib headers
47 #include <fileref.h>
48 #include <tag.h>
49 #include <tbytevector.h>
50
51 #include <apetag.h>
52 #include <id3v2tag.h>
53 #include <xiphcomment.h>
54
55 #include <flacfile.h>
56 #include <mpcfile.h>
57 #include <mpegfile.h>
58 #include <oggfile.h>
59 #include <oggflacfile.h>
60 #include <speexfile.h>
61 #include <trueaudiofile.h>
62 #include <vorbisfile.h>
63 #include <wavpackfile.h>
64
65 #include <attachedpictureframe.h>
66 #include <textidentificationframe.h>
67 #include <uniquefileidentifierframe.h>
68
69
70 // Local functions
71 static int ReadMeta    ( vlc_object_t * );
72 static int WriteMeta   ( vlc_object_t * );
73
74 vlc_module_begin ()
75     set_capability( "meta reader", 1000 )
76     set_callbacks( ReadMeta, NULL )
77     add_submodule ()
78         set_capability( "meta writer", 50 )
79         set_callbacks( WriteMeta, NULL )
80 vlc_module_end ()
81
82 using namespace TagLib;
83
84
85 /**
86  * Read meta informations from APE tags
87  * @param tag: the APE tag
88  * @param p_demux; the demux object
89  * @param p_demux_meta: the demuxer meta
90  * @param p_meta: the meta
91  */
92 static void ReadMetaFromAPE( APE::Tag* tag, demux_t* p_demux, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
93 {
94     APE::Item item;
95 #define SET( keyName, metaName ) \
96     item = tag->itemListMap()[keyName]; \
97     vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) );\
98
99     SET( "COPYRIGHT", Copyright );
100     SET( "LANGUAGE", Language );
101     SET( "PUBLISHER", Publisher );
102
103 #undef SET
104 }
105
106
107
108 /**
109  * Read meta information from id3v2 tags
110  * @param tag: the id3v2 tag
111  * @param p_demux; the demux object
112  * @param p_demux_meta: the demuxer meta
113  * @param p_meta: the meta
114  */
115 static void ReadMetaFromId3v2( ID3v2::Tag* tag, demux_t* p_demux, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
116 {
117     // Get the unique file identifier
118     ID3v2::FrameList list = tag->frameListMap()["UFID"];
119     ID3v2::FrameList::Iterator iter;
120     for( iter = list.begin(); iter != list.end(); iter++ )
121     {
122         ID3v2::UniqueFileIdentifierFrame* p_ufid =
123                 dynamic_cast<ID3v2::UniqueFileIdentifierFrame*>(*iter);
124         const char *owner = p_ufid->owner().toCString();
125         if (!strcmp( owner, "http://musicbrainz.org" ))
126         {
127             /* ID3v2 UFID contains up to 64 bytes binary data
128              * but in our case it will be a '\0'
129              * terminated string */
130             char psz_ufid[64];
131             int max_size = __MIN( p_ufid->identifier().size(), 63);
132             strncpy( psz_ufid, p_ufid->identifier().data(), max_size );
133             psz_ufid[max_size] = '\0';
134             vlc_meta_SetTrackID( p_meta, psz_ufid );
135         }
136     }
137
138     // Get the use text
139     list = tag->frameListMap()["TXXX"];
140     for( iter = list.begin(); iter != list.end(); iter++ )
141     {
142         ID3v2::UserTextIdentificationFrame* p_txxx =
143                 dynamic_cast<ID3v2::UserTextIdentificationFrame*>(*iter);
144         vlc_meta_AddExtra( p_meta, p_txxx->description().toCString( true ),
145                            p_txxx->fieldList().toString().toCString( true ) );
146     }
147
148     // Get some more informations
149 #define SET( tagName, metaName )                                               \
150     list = tag->frameListMap()[tagName];                                       \
151     if( !list.isEmpty() )                                                      \
152         vlc_meta_Set##metaName( p_meta,                                        \
153                                 (*list.begin())->toString().toCString( true ) );
154
155     SET( "TCOP", Copyright );
156     SET( "TENC", EncodedBy );
157     SET( "TLAN", Language );
158     SET( "TPUB", Publisher );
159
160 #undef SET
161
162     /* Preferred type of image
163      * The 21 types are defined in id3v2 standard:
164      * http://www.id3.org/id3v2.4.0-frames */
165     static const int pi_cover_score[] = {
166         0,  /* Other */
167         5,  /* 32x32 PNG image that should be used as the file icon */
168         4,  /* File icon of a different size or format. */
169         20, /* Front cover image of the album. */
170         19, /* Back cover image of the album. */
171         13, /* Inside leaflet page of the album. */
172         18, /* Image from the album itself. */
173         17, /* Picture of the lead artist or soloist. */
174         16, /* Picture of the artist or performer. */
175         14, /* Picture of the conductor. */
176         15, /* Picture of the band or orchestra. */
177         9,  /* Picture of the composer. */
178         8,  /* Picture of the lyricist or text writer. */
179         7,  /* Picture of the recording location or studio. */
180         10, /* Picture of the artists during recording. */
181         11, /* Picture of the artists during performance. */
182         6,  /* Picture from a movie or video related to the track. */
183         1,  /* Picture of a large, coloured fish. */
184         12, /* Illustration related to the track. */
185         3,  /* Logo of the band or performer. */
186         2   /* Logo of the publisher (record company). */
187     };
188     int i_score = -1;
189
190     // Try now to get embedded art
191     list = tag->frameListMap()[ "APIC" ];
192     if( list.isEmpty() )
193         return;
194
195     TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
196     for( iter = list.begin(); iter != list.end(); iter++ )
197     {
198         ID3v2::AttachedPictureFrame* p_apic =
199             dynamic_cast<ID3v2::AttachedPictureFrame*>(*iter);
200         input_attachment_t *p_attachment;
201
202         const char *psz_mime;
203         char *psz_name, *psz_description;
204
205         // Get the mime and description of the image.
206         // If the description is empty, take the type as a description
207         psz_mime = p_apic->mimeType().toCString( true );
208         if( p_apic->description().size() > 0 )
209             psz_description = strdup( p_apic->description().toCString( true ) );
210         else
211         {
212             if( asprintf( &psz_description, "%i", p_apic->type() ) == -1 )
213                 psz_description = NULL;
214         }
215
216         if( !psz_description )
217             continue;
218         psz_name = psz_description;
219
220         /* some old iTunes version not only sets incorrectly the mime type
221          * or the description of the image,
222          * but also embeds incorrectly the image.
223          * Recent versions seem to behave correctly */
224         if( !strncmp( psz_mime, "PNG", 3 ) ||
225             !strncmp( psz_name, "\xC2\x89PNG", 5 ) )
226         {
227             msg_Warn( p_demux_meta, "Invalid picture embedded by broken iTunes version" );
228             free( psz_description );
229             continue;
230         }
231
232         const ByteVector picture = p_apic->picture();
233         const char *p_data = picture.data();
234         const unsigned i_data = picture.size();
235
236         msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %u bytes",
237                  psz_name, psz_mime, i_data );
238
239         p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
240                                 psz_description, p_data, i_data );
241         if( p_attachment )
242             TAB_APPEND_CAST( (input_attachment_t**),
243                              p_demux_meta->i_attachments, p_demux_meta->attachments,
244                              p_attachment );
245         free( psz_description );
246
247         if( pi_cover_score[p_apic->type()] > i_score )
248         {
249             i_score = pi_cover_score[p_apic->type()];
250             char *psz_url;
251             if( asprintf( &psz_url, "attachment://%s",
252                           p_attachment->psz_name ) == -1 )
253                 continue;
254             vlc_meta_SetArtURL( p_meta, psz_url );
255             free( psz_url );
256         }
257     }
258 }
259
260
261
262 /**
263  * Read the meta informations from XiphComments
264  * @param tag: the Xiph Comment
265  * @param p_demux; the demux object
266  * @param p_demux_meta: the demuxer meta
267  * @param p_meta: the meta
268  */
269 static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_t* p_demux, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
270 {
271 #define SET( keyName, metaName )                                               \
272     StringList list = tag->fieldListMap()[keyName];                            \
273     if( !list.isEmpty() )                                                      \
274         vlc_meta_Set##metaName( p_meta, (*list.begin()).toCString( true ) );
275
276     SET( "COPYRIGHT", Copyright );
277 #undef SET
278
279     // Try now to get embedded art
280     StringList mime_list = tag->fieldListMap()[ "COVERARTMIME" ];
281     StringList art_list = tag->fieldListMap()[ "COVERART" ];
282
283     // We get only the first covert art
284     if( mime_list.size() > 1 || art_list.size() > 1 )
285         msg_Warn( p_demux_meta, "Found %i embedded arts, so using only the first one",
286                   art_list.size() );
287     else if( mime_list.size() == 0 || art_list.size() == 0 )
288         return;
289
290     input_attachment_t *p_attachment;
291
292     const char* psz_name = "cover";
293     const char* psz_mime = mime_list[0].toCString(true);
294     const char* psz_description = "cover";
295
296     uint8_t *p_data;
297     int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) );
298
299     msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %i bytes",
300              psz_name, psz_mime, i_data );
301
302     TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
303               p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
304               psz_description, p_data, i_data );
305     free( p_data );
306
307     TAB_APPEND_CAST( (input_attachment_t**),
308                      p_demux_meta->i_attachments, p_demux_meta->attachments,
309                      p_attachment );
310
311     vlc_meta_SetArtURL( p_meta, "attachment://cover" );
312 }
313
314
315
316 /**
317  * Get the tags from the file using TagLib
318  * @param p_this: the demux object
319  * @return VLC_SUCCESS if the operation success
320  */
321 static int ReadMeta( vlc_object_t* p_this)
322 {
323     demux_meta_t*   p_demux_meta = (demux_meta_t *)p_this;
324     demux_t*        p_demux = p_demux_meta->p_demux;
325     vlc_meta_t*     p_meta;
326     FileRef f;
327
328     p_demux_meta->p_meta = NULL;
329
330
331 #if defined(WIN32) || defined (UNDER_CE)
332     wchar_t wpath[MAX_PATH + 1];
333     if( !MultiByteToWideChar( CP_UTF8, 0, p_demux->psz_path, -1, wpath, MAX_PATH) )
334         return VLC_EGENERIC;
335     wpath[MAX_PATH] = L'\0';
336     f = FileRef( wpath );
337 #else
338     const char* local_name = ToLocale( p_demux->psz_path );
339     if( !local_name )
340         return VLC_EGENERIC;
341     f = FileRef( local_name );
342     LocaleFree( local_name );
343 #endif
344
345     if( f.isNull() )
346         return VLC_EGENERIC;
347     if( !f.tag() || f.tag()->isEmpty() )
348         return VLC_EGENERIC;
349
350     p_demux_meta->p_meta = p_meta = vlc_meta_New();
351     if( !p_meta )
352         return VLC_ENOMEM;
353
354
355     // Read the tags from the file
356     Tag* p_tag = f.tag();
357
358 #define SET( tag, meta )                                                       \
359     if( !p_tag->tag().isNull() && !p_tag->tag().isEmpty() )                    \
360         vlc_meta_Set##meta( p_meta, p_tag->tag().toCString(true) )
361 #define SETINT( tag, meta )                                                    \
362     if( p_tag->tag() )                                                         \
363     {                                                                          \
364         char psz_tmp[10];                                                      \
365         snprintf( psz_tmp, 10, "%d", p_tag->tag() );                           \
366         vlc_meta_Set##meta( p_meta, psz_tmp );                                 \
367     }
368
369     SET( title, Title );
370     SET( artist, Artist );
371     SET( album, Album );
372     SET( comment, Description );
373     SET( genre, Genre );
374     SETINT( year, Date );
375     SETINT( track, TrackNum );
376
377 #undef SETINT
378 #undef SET
379
380
381     // Try now to read special tags
382     if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
383     {
384         if( flac->ID3v2Tag() )
385             ReadMetaFromId3v2( flac->ID3v2Tag(), p_demux, p_demux_meta, p_meta );
386         else if( flac->xiphComment() )
387             ReadMetaFromXiph( flac->xiphComment(), p_demux, p_demux_meta, p_meta );
388     }
389     else if( MPC::File* mpc = dynamic_cast<MPC::File*>(f.file()) )
390     {
391         if( mpc->APETag() )
392             ReadMetaFromAPE( mpc->APETag(), p_demux, p_demux_meta, p_meta );
393     }
394     else if( MPEG::File* mpeg = dynamic_cast<MPEG::File*>(f.file()) )
395     {
396         if( mpeg->ID3v2Tag() )
397             ReadMetaFromId3v2( mpeg->ID3v2Tag(), p_demux, p_demux_meta, p_meta );
398         else if( mpeg->APETag() )
399             ReadMetaFromAPE( mpeg->APETag(), p_demux, p_demux_meta, p_meta );
400     }
401     else if( Ogg::File* ogg = dynamic_cast<Ogg::File*>(f.file()) )
402     {
403         if( Ogg::FLAC::File* ogg_flac = dynamic_cast<Ogg::FLAC::File*>(f.file()))
404             ReadMetaFromXiph( ogg_flac->tag(), p_demux, p_demux_meta, p_meta );
405         else if( Ogg::Speex::File* ogg_speex = dynamic_cast<Ogg::Speex::File*>(f.file()) )
406             ReadMetaFromXiph( ogg_speex->tag(), p_demux, p_demux_meta, p_meta );
407         else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
408             ReadMetaFromXiph( ogg_vorbis->tag(), p_demux, p_demux_meta, p_meta );
409     }
410 #ifdef TAGLIB_WITH_ASF
411     else if( RIFF::File* riff = dynamic_cast<RIFF::File*>(f.file()) )
412     {
413         if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )
414             ReadMetaFromId3v2( riff_aiff->tag(), p_demux, p_demux_meta, p_meta );
415         else if( RIFF::WAV::File* riff_wav = dynamic_cast<RIFF::WAV::File*>(f.file()) )
416             ReadMetaFromId3v2( riff_wav->tag(), p_demux, p_demux_meta, p_meta );
417     }
418 #endif
419     else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
420     {
421         if( trueaudio->ID3v2Tag() )
422             ReadMetaFromId3v2( trueaudio->ID3v2Tag(), p_demux, p_demux_meta, p_meta );
423     }
424     else if( WavPack::File* wavpack = dynamic_cast<WavPack::File*>(f.file()) )
425     {
426         if( wavpack->APETag() )
427             ReadMetaFromAPE( wavpack->APETag(), p_demux, p_demux_meta, p_meta );
428     }
429
430     return VLC_SUCCESS;
431 }
432
433
434
435 /**
436  * Write meta informations to APE tags
437  * @param tag: the APE tag
438  * @param p_item: the input item
439  */
440 static void WriteMetaToAPE( APE::Tag* tag, input_item_t* p_item )
441 {
442     char* psz_meta;
443 #define WRITE( metaName, keyName )                      \
444     psz_meta = input_item_Get##metaName( p_item );      \
445     if( psz_meta )                                      \
446     {                                                   \
447         String key( keyName, String::UTF8 );            \
448         String value( psz_meta, String::UTF8 );         \
449         tag->addValue( key, value, true );              \
450     }                                                   \
451     free( psz_meta );
452
453     WRITE( Copyright, "COPYRIGHT" );
454     WRITE( Language, "LANGUAGE" );
455     WRITE( Publisher, "PUBLISHER" );
456
457 #undef WRITE
458 }
459
460
461
462 /**
463  * Write meta information to id3v2 tags
464  * @param tag: the id3v2 tag
465  * @param p_input: the input item
466  */
467 static void WriteMetaToId3v2( ID3v2::Tag* tag, input_item_t* p_item )
468 {
469     char* psz_meta;
470 #define WRITE( metaName, tagName )                                            \
471     psz_meta = input_item_Get##metaName( p_item );                            \
472     if( psz_meta )                                                            \
473     {                                                                         \
474         ByteVector p_byte( tagName, 4 );                                      \
475         tag->removeFrames( p_byte );                                         \
476         ID3v2::TextIdentificationFrame* p_frame =                             \
477             new ID3v2::TextIdentificationFrame( p_byte, String::UTF8 );       \
478         p_frame->setText( psz_meta );                                         \
479         tag->addFrame( p_frame );                                             \
480     }                                                                         \
481     free( psz_meta );
482
483     WRITE( Copyright, "TCOP" );
484     WRITE( EncodedBy, "TENC" );
485     WRITE( Language,  "TLAN" );
486     WRITE( Publisher, "TPUB" );
487
488 #undef WRITE
489 }
490
491
492
493 /**
494  * Write the meta informations to XiphComments
495  * @param tag: the Xiph Comment
496  * @param p_input: the input item
497  */
498 static void WriteMetaToXiph( Ogg::XiphComment* tag, input_item_t* p_item )
499 {
500     char* psz_meta;
501 #define WRITE( metaName, keyName )                      \
502     psz_meta = input_item_Get##metaName( p_item );      \
503     if( psz_meta )                                      \
504     {                                                   \
505         String key( keyName, String::UTF8 );            \
506         String value( psz_meta, String::UTF8 );         \
507         tag->addField( key, value, true );              \
508     }                                                   \
509     free( psz_meta );
510
511     WRITE( Copyright, "COPYRIGHT" );
512
513 #undef WRITE
514 }
515
516
517
518 /**
519  * Set the tags to the file using TagLib
520  * @param p_this: the demux object
521  * @return VLC_SUCCESS if the operation success
522  */
523
524 static int WriteMeta( vlc_object_t *p_this )
525 {
526     meta_export_t *p_export = (meta_export_t *)p_this;
527     input_item_t *p_item = p_export->p_item;
528     FileRef f;
529
530     if( !p_item )
531     {
532         msg_Err( p_this, "Can't save meta data of an empty input" );
533         return VLC_EGENERIC;
534     }
535
536     char *export_file = strdup(p_export->psz_file);
537     if( decode_URI( export_file ) == NULL )
538     {
539         free( export_file );
540         return VLC_EGENERIC;
541     }
542
543 #if defined(WIN32) || defined (UNDER_CE)
544     wchar_t wpath[MAX_PATH + 1];
545     if( !MultiByteToWideChar( CP_UTF8, 0, export_file , -1, wpath, MAX_PATH) )
546         return VLC_EGENERIC;
547     wpath[MAX_PATH] = L'\0';
548     f = FileRef( wpath );
549 #else
550     const char* local_name = ToLocale( export_file );
551     if( !local_name )
552     {
553         free( export_file );
554         return VLC_EGENERIC;
555     }
556     f = FileRef( local_name );
557     LocaleFree( local_name );
558 #endif
559
560     if( f.isNull() || !f.tag() || f.file()->readOnly() )
561     {
562         msg_Err( p_this, "File %s can't be opened for tag writing",
563             export_file );
564         free( export_file );
565         return VLC_EGENERIC;
566     }
567
568     msg_Dbg( p_this, "Writing metadata for %s", export_file );
569     free( export_file );
570
571     Tag *p_tag = f.tag();
572
573     char *psz_meta;
574
575 #define SET( a, b )                                         \
576     if( b )                                                 \
577     {                                                       \
578         String* psz_tmp = new String( b, String::UTF8 );    \
579         p_tag->set##a( *psz_tmp );                          \
580         delete psz_tmp;                                     \
581     }
582
583     // Saving all common fields
584     // If the title is empty, use the name
585     psz_meta = input_item_GetTitleFbName( p_item );
586     SET( Title, psz_meta );
587     free( psz_meta );
588
589     psz_meta = input_item_GetArtist( p_item );
590     SET( Artist, psz_meta );
591     free( psz_meta );
592
593     psz_meta = input_item_GetAlbum( p_item );
594     SET( Album, psz_meta );
595     free( psz_meta );
596
597     psz_meta = input_item_GetDescription( p_item );
598     SET( Comment, psz_meta );
599     free( psz_meta );
600
601     psz_meta = input_item_GetGenre( p_item );
602     SET( Genre, psz_meta );
603     free( psz_meta );
604
605 #undef SET
606
607     psz_meta = input_item_GetDate( p_item );
608     if( psz_meta ) p_tag->setYear( atoi( psz_meta ) );
609     free( psz_meta );
610
611     psz_meta = input_item_GetTrackNum( p_item );
612     if( psz_meta ) p_tag->setTrack( atoi( psz_meta ) );
613     free( psz_meta );
614
615
616     // Try now to write special tags
617     if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
618     {
619         if( flac->ID3v2Tag() )
620             WriteMetaToId3v2( flac->ID3v2Tag(), p_item );
621         else if( flac->xiphComment() )
622             WriteMetaToXiph( flac->xiphComment(), p_item );
623     }
624     else if( MPC::File* mpc = dynamic_cast<MPC::File*>(f.file()) )
625     {
626         if( mpc->APETag() )
627             WriteMetaToAPE( mpc->APETag(), p_item );
628     }
629     else if( MPEG::File* mpeg = dynamic_cast<MPEG::File*>(f.file()) )
630     {
631         if( mpeg->ID3v2Tag() )
632             WriteMetaToId3v2( mpeg->ID3v2Tag(), p_item );
633         else if( mpeg->APETag() )
634             WriteMetaToAPE( mpeg->APETag(), p_item );
635     }
636     else if( Ogg::File* ogg = dynamic_cast<Ogg::File*>(f.file()) )
637     {
638         if( Ogg::FLAC::File* ogg_flac = dynamic_cast<Ogg::FLAC::File*>(f.file()))
639             WriteMetaToXiph( ogg_flac->tag(), p_item );
640         else if( Ogg::Speex::File* ogg_speex = dynamic_cast<Ogg::Speex::File*>(f.file()) )
641             WriteMetaToXiph( ogg_speex->tag(), p_item );
642         else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
643             WriteMetaToXiph( ogg_vorbis->tag(), p_item );
644     }
645     else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
646     {
647         if( trueaudio->ID3v2Tag() )
648             WriteMetaToId3v2( trueaudio->ID3v2Tag(), p_item );
649     }
650     else if( WavPack::File* wavpack = dynamic_cast<WavPack::File*>(f.file()) )
651     {
652         if( wavpack->APETag() )
653             WriteMetaToAPE( wavpack->APETag(), p_item );
654     }
655
656     // Save the meta data
657     f.save();
658
659     return VLC_SUCCESS;
660 }
661