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