Configure.ac and NEWS are now 1.1.0
[vlc/solaris.git] / modules / meta_engine / taglib.cpp
blob6ec8d8dbf8f4c0a7bc3ca2159f9bb9a2685ce1d6
1 /*****************************************************************************
2 * taglib.cpp: Taglib tag parser/writer
3 *****************************************************************************
4 * Copyright (C) 2003-2009 the VideoLAN team
5 * $Id$
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 *****************************************************************************/
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
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>
39 #ifdef WIN32
40 # include <io.h>
41 #else
42 # include <unistd.h>
43 #endif
46 // Taglib headers
47 #include <fileref.h>
48 #include <tag.h>
49 #include <tbytevector.h>
51 #include <apetag.h>
52 #include <id3v2tag.h>
53 #include <xiphcomment.h>
55 #include <flacfile.h>
56 #include <mpcfile.h>
57 #include <mpegfile.h>
58 #include <oggfile.h>
59 #include <oggflacfile.h>
61 #ifdef TAGLIB_WITH_ASF
62 # include <aifffile.h>
63 # include <wavfile.h>
64 #endif
66 #ifdef TAGLIB_WITH_MP4
67 # include <mp4file.h>
68 #endif
70 #include <speexfile.h>
71 #include <trueaudiofile.h>
72 #include <vorbisfile.h>
73 #include <wavpackfile.h>
75 #include <attachedpictureframe.h>
76 #include <textidentificationframe.h>
77 #include <uniquefileidentifierframe.h>
80 // Local functions
81 static int ReadMeta ( vlc_object_t * );
82 static int WriteMeta ( vlc_object_t * );
84 vlc_module_begin ()
85 set_capability( "meta reader", 1000 )
86 set_callbacks( ReadMeta, NULL )
87 add_submodule ()
88 set_capability( "meta writer", 50 )
89 set_callbacks( WriteMeta, NULL )
90 vlc_module_end ()
92 using namespace TagLib;
95 /**
96 * Read meta informations from APE tags
97 * @param tag: the APE tag
98 * @param p_demux; the demux object
99 * @param p_demux_meta: the demuxer meta
100 * @param p_meta: the meta
102 static void ReadMetaFromAPE( APE::Tag* tag, demux_t* p_demux, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
104 APE::Item item;
105 #define SET( keyName, metaName ) \
106 item = tag->itemListMap()[keyName]; \
107 vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) );\
109 SET( "COPYRIGHT", Copyright );
110 SET( "LANGUAGE", Language );
111 SET( "PUBLISHER", Publisher );
113 #undef SET
119 * Read meta information from id3v2 tags
120 * @param tag: the id3v2 tag
121 * @param p_demux; the demux object
122 * @param p_demux_meta: the demuxer meta
123 * @param p_meta: the meta
125 static void ReadMetaFromId3v2( ID3v2::Tag* tag, demux_t* p_demux, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
127 // Get the unique file identifier
128 ID3v2::FrameList list = tag->frameListMap()["UFID"];
129 ID3v2::FrameList::Iterator iter;
130 for( iter = list.begin(); iter != list.end(); iter++ )
132 ID3v2::UniqueFileIdentifierFrame* p_ufid =
133 dynamic_cast<ID3v2::UniqueFileIdentifierFrame*>(*iter);
134 const char *owner = p_ufid->owner().toCString();
135 if (!strcmp( owner, "http://musicbrainz.org" ))
137 /* ID3v2 UFID contains up to 64 bytes binary data
138 * but in our case it will be a '\0'
139 * terminated string */
140 char psz_ufid[64];
141 int max_size = __MIN( p_ufid->identifier().size(), 63);
142 strncpy( psz_ufid, p_ufid->identifier().data(), max_size );
143 psz_ufid[max_size] = '\0';
144 vlc_meta_SetTrackID( p_meta, psz_ufid );
148 // Get the use text
149 list = tag->frameListMap()["TXXX"];
150 for( iter = list.begin(); iter != list.end(); iter++ )
152 ID3v2::UserTextIdentificationFrame* p_txxx =
153 dynamic_cast<ID3v2::UserTextIdentificationFrame*>(*iter);
154 vlc_meta_AddExtra( p_meta, p_txxx->description().toCString( true ),
155 p_txxx->fieldList().toString().toCString( true ) );
158 // Get some more informations
159 #define SET( tagName, metaName ) \
160 list = tag->frameListMap()[tagName]; \
161 if( !list.isEmpty() ) \
162 vlc_meta_Set##metaName( p_meta, \
163 (*list.begin())->toString().toCString( true ) );
165 SET( "TCOP", Copyright );
166 SET( "TENC", EncodedBy );
167 SET( "TLAN", Language );
168 SET( "TPUB", Publisher );
170 #undef SET
172 /* Preferred type of image
173 * The 21 types are defined in id3v2 standard:
174 * http://www.id3.org/id3v2.4.0-frames */
175 static const int pi_cover_score[] = {
176 0, /* Other */
177 5, /* 32x32 PNG image that should be used as the file icon */
178 4, /* File icon of a different size or format. */
179 20, /* Front cover image of the album. */
180 19, /* Back cover image of the album. */
181 13, /* Inside leaflet page of the album. */
182 18, /* Image from the album itself. */
183 17, /* Picture of the lead artist or soloist. */
184 16, /* Picture of the artist or performer. */
185 14, /* Picture of the conductor. */
186 15, /* Picture of the band or orchestra. */
187 9, /* Picture of the composer. */
188 8, /* Picture of the lyricist or text writer. */
189 7, /* Picture of the recording location or studio. */
190 10, /* Picture of the artists during recording. */
191 11, /* Picture of the artists during performance. */
192 6, /* Picture from a movie or video related to the track. */
193 1, /* Picture of a large, coloured fish. */
194 12, /* Illustration related to the track. */
195 3, /* Logo of the band or performer. */
196 2 /* Logo of the publisher (record company). */
198 int i_score = -1;
200 // Try now to get embedded art
201 list = tag->frameListMap()[ "APIC" ];
202 if( list.isEmpty() )
203 return;
205 TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
206 for( iter = list.begin(); iter != list.end(); iter++ )
208 ID3v2::AttachedPictureFrame* p_apic =
209 dynamic_cast<ID3v2::AttachedPictureFrame*>(*iter);
210 input_attachment_t *p_attachment;
212 const char *psz_mime;
213 char *psz_name, *psz_description;
215 // Get the mime and description of the image.
216 // If the description is empty, take the type as a description
217 psz_mime = p_apic->mimeType().toCString( true );
218 if( p_apic->description().size() > 0 )
219 psz_description = strdup( p_apic->description().toCString( true ) );
220 else
222 if( asprintf( &psz_description, "%i", p_apic->type() ) == -1 )
223 psz_description = NULL;
226 if( !psz_description )
227 continue;
228 psz_name = psz_description;
230 /* some old iTunes version not only sets incorrectly the mime type
231 * or the description of the image,
232 * but also embeds incorrectly the image.
233 * Recent versions seem to behave correctly */
234 if( !strncmp( psz_mime, "PNG", 3 ) ||
235 !strncmp( psz_name, "\xC2\x89PNG", 5 ) )
237 msg_Warn( p_demux_meta, "Invalid picture embedded by broken iTunes version" );
238 free( psz_description );
239 continue;
242 const ByteVector picture = p_apic->picture();
243 const char *p_data = picture.data();
244 const unsigned i_data = picture.size();
246 msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %u bytes",
247 psz_name, psz_mime, i_data );
249 p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
250 psz_description, p_data, i_data );
251 if( p_attachment )
252 TAB_APPEND_CAST( (input_attachment_t**),
253 p_demux_meta->i_attachments, p_demux_meta->attachments,
254 p_attachment );
255 free( psz_description );
257 if( pi_cover_score[p_apic->type()] > i_score )
259 i_score = pi_cover_score[p_apic->type()];
260 char *psz_url;
261 if( asprintf( &psz_url, "attachment://%s",
262 p_attachment->psz_name ) == -1 )
263 continue;
264 vlc_meta_SetArtURL( p_meta, psz_url );
265 free( psz_url );
273 * Read the meta informations from XiphComments
274 * @param tag: the Xiph Comment
275 * @param p_demux; the demux object
276 * @param p_demux_meta: the demuxer meta
277 * @param p_meta: the meta
279 static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_t* p_demux, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
281 #define SET( keyName, metaName ) \
282 StringList list = tag->fieldListMap()[keyName]; \
283 if( !list.isEmpty() ) \
284 vlc_meta_Set##metaName( p_meta, (*list.begin()).toCString( true ) );
286 SET( "COPYRIGHT", Copyright );
287 #undef SET
289 // Try now to get embedded art
290 StringList mime_list = tag->fieldListMap()[ "COVERARTMIME" ];
291 StringList art_list = tag->fieldListMap()[ "COVERART" ];
293 // We get only the first covert art
294 if( mime_list.size() > 1 || art_list.size() > 1 )
295 msg_Warn( p_demux_meta, "Found %i embedded arts, so using only the first one",
296 art_list.size() );
297 else if( mime_list.size() == 0 || art_list.size() == 0 )
298 return;
300 input_attachment_t *p_attachment;
302 const char* psz_name = "cover";
303 const char* psz_mime = mime_list[0].toCString(true);
304 const char* psz_description = "cover";
306 uint8_t *p_data;
307 int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) );
309 msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %i bytes",
310 psz_name, psz_mime, i_data );
312 TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
313 p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
314 psz_description, p_data, i_data );
315 free( p_data );
317 TAB_APPEND_CAST( (input_attachment_t**),
318 p_demux_meta->i_attachments, p_demux_meta->attachments,
319 p_attachment );
321 vlc_meta_SetArtURL( p_meta, "attachment://cover" );
324 #ifdef TAGLIB_WITH_MP4
325 static void ReadMetaFromMP4( MP4::Tag* tag, demux_t *p_demux, demux_meta_t *p_demux_meta, vlc_meta_t* p_meta )
327 if( tag->itemListMap().contains("covr") )
329 MP4::CoverArtList list = tag->itemListMap()["covr"].toCoverArtList();
330 const char *psz_format = list[0].format() == MP4::CoverArt::PNG ? "image/png" : "image/jpeg";
332 TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments );
333 input_attachment_t *p_attachment =
334 vlc_input_attachment_New( "cover", psz_format, "cover",
335 list[0].data().data(), list[0].data().size() );
336 TAB_APPEND_CAST( (input_attachment_t**),
337 p_demux_meta->i_attachments, p_demux_meta->attachments,
338 p_attachment );
339 vlc_meta_SetArtURL( p_meta, "attachment://cover" );
342 #endif
345 * Get the tags from the file using TagLib
346 * @param p_this: the demux object
347 * @return VLC_SUCCESS if the operation success
349 static int ReadMeta( vlc_object_t* p_this)
351 demux_meta_t* p_demux_meta = (demux_meta_t *)p_this;
352 demux_t* p_demux = p_demux_meta->p_demux;
353 vlc_meta_t* p_meta;
354 FileRef f;
356 p_demux_meta->p_meta = NULL;
359 #if defined(WIN32) || defined (UNDER_CE)
360 wchar_t wpath[MAX_PATH + 1];
361 if( !MultiByteToWideChar( CP_UTF8, 0, p_demux->psz_path, -1, wpath, MAX_PATH) )
362 return VLC_EGENERIC;
363 wpath[MAX_PATH] = L'\0';
364 f = FileRef( wpath );
365 #else
366 const char* local_name = ToLocale( p_demux->psz_path );
367 if( !local_name )
368 return VLC_EGENERIC;
369 f = FileRef( local_name );
370 LocaleFree( local_name );
371 #endif
373 if( f.isNull() )
374 return VLC_EGENERIC;
375 if( !f.tag() || f.tag()->isEmpty() )
376 return VLC_EGENERIC;
378 p_demux_meta->p_meta = p_meta = vlc_meta_New();
379 if( !p_meta )
380 return VLC_ENOMEM;
383 // Read the tags from the file
384 Tag* p_tag = f.tag();
386 #define SET( tag, meta ) \
387 if( !p_tag->tag().isNull() && !p_tag->tag().isEmpty() ) \
388 vlc_meta_Set##meta( p_meta, p_tag->tag().toCString(true) )
389 #define SETINT( tag, meta ) \
390 if( p_tag->tag() ) \
392 char psz_tmp[10]; \
393 snprintf( psz_tmp, 10, "%d", p_tag->tag() ); \
394 vlc_meta_Set##meta( p_meta, psz_tmp ); \
397 SET( title, Title );
398 SET( artist, Artist );
399 SET( album, Album );
400 SET( comment, Description );
401 SET( genre, Genre );
402 SETINT( year, Date );
403 SETINT( track, TrackNum );
405 #undef SETINT
406 #undef SET
409 // Try now to read special tags
410 if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
412 if( flac->ID3v2Tag() )
413 ReadMetaFromId3v2( flac->ID3v2Tag(), p_demux, p_demux_meta, p_meta );
414 else if( flac->xiphComment() )
415 ReadMetaFromXiph( flac->xiphComment(), p_demux, p_demux_meta, p_meta );
417 #ifdef TAGLIB_WITH_MP4
418 else if( MP4::File *mp4 = dynamic_cast<MP4::File*>(f.file()) )
420 if( mp4->tag() )
421 ReadMetaFromMP4( mp4->tag(), p_demux, p_demux_meta, p_meta );
423 #endif
424 else if( MPC::File* mpc = dynamic_cast<MPC::File*>(f.file()) )
426 if( mpc->APETag() )
427 ReadMetaFromAPE( mpc->APETag(), p_demux, p_demux_meta, p_meta );
429 else if( MPEG::File* mpeg = dynamic_cast<MPEG::File*>(f.file()) )
431 if( mpeg->ID3v2Tag() )
432 ReadMetaFromId3v2( mpeg->ID3v2Tag(), p_demux, p_demux_meta, p_meta );
433 else if( mpeg->APETag() )
434 ReadMetaFromAPE( mpeg->APETag(), p_demux, p_demux_meta, p_meta );
436 else if( Ogg::File* ogg = dynamic_cast<Ogg::File*>(f.file()) )
438 if( Ogg::FLAC::File* ogg_flac = dynamic_cast<Ogg::FLAC::File*>(f.file()))
439 ReadMetaFromXiph( ogg_flac->tag(), p_demux, p_demux_meta, p_meta );
440 else if( Ogg::Speex::File* ogg_speex = dynamic_cast<Ogg::Speex::File*>(f.file()) )
441 ReadMetaFromXiph( ogg_speex->tag(), p_demux, p_demux_meta, p_meta );
442 else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
443 ReadMetaFromXiph( ogg_vorbis->tag(), p_demux, p_demux_meta, p_meta );
445 #ifdef TAGLIB_WITH_ASF
446 else if( RIFF::File* riff = dynamic_cast<RIFF::File*>(f.file()) )
448 if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )
449 ReadMetaFromId3v2( riff_aiff->tag(), p_demux, p_demux_meta, p_meta );
450 else if( RIFF::WAV::File* riff_wav = dynamic_cast<RIFF::WAV::File*>(f.file()) )
451 ReadMetaFromId3v2( riff_wav->tag(), p_demux, p_demux_meta, p_meta );
453 #endif
454 else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
456 if( trueaudio->ID3v2Tag() )
457 ReadMetaFromId3v2( trueaudio->ID3v2Tag(), p_demux, p_demux_meta, p_meta );
459 else if( WavPack::File* wavpack = dynamic_cast<WavPack::File*>(f.file()) )
461 if( wavpack->APETag() )
462 ReadMetaFromAPE( wavpack->APETag(), p_demux, p_demux_meta, p_meta );
465 return VLC_SUCCESS;
471 * Write meta informations to APE tags
472 * @param tag: the APE tag
473 * @param p_item: the input item
475 static void WriteMetaToAPE( APE::Tag* tag, input_item_t* p_item )
477 char* psz_meta;
478 #define WRITE( metaName, keyName ) \
479 psz_meta = input_item_Get##metaName( p_item ); \
480 if( psz_meta ) \
482 String key( keyName, String::UTF8 ); \
483 String value( psz_meta, String::UTF8 ); \
484 tag->addValue( key, value, true ); \
486 free( psz_meta );
488 WRITE( Copyright, "COPYRIGHT" );
489 WRITE( Language, "LANGUAGE" );
490 WRITE( Publisher, "PUBLISHER" );
492 #undef WRITE
498 * Write meta information to id3v2 tags
499 * @param tag: the id3v2 tag
500 * @param p_input: the input item
502 static void WriteMetaToId3v2( ID3v2::Tag* tag, input_item_t* p_item )
504 char* psz_meta;
505 #define WRITE( metaName, tagName ) \
506 psz_meta = input_item_Get##metaName( p_item ); \
507 if( psz_meta ) \
509 ByteVector p_byte( tagName, 4 ); \
510 tag->removeFrames( p_byte ); \
511 ID3v2::TextIdentificationFrame* p_frame = \
512 new ID3v2::TextIdentificationFrame( p_byte, String::UTF8 ); \
513 p_frame->setText( psz_meta ); \
514 tag->addFrame( p_frame ); \
516 free( psz_meta );
518 WRITE( Copyright, "TCOP" );
519 WRITE( EncodedBy, "TENC" );
520 WRITE( Language, "TLAN" );
521 WRITE( Publisher, "TPUB" );
523 #undef WRITE
529 * Write the meta informations to XiphComments
530 * @param tag: the Xiph Comment
531 * @param p_input: the input item
533 static void WriteMetaToXiph( Ogg::XiphComment* tag, input_item_t* p_item )
535 char* psz_meta;
536 #define WRITE( metaName, keyName ) \
537 psz_meta = input_item_Get##metaName( p_item ); \
538 if( psz_meta ) \
540 String key( keyName, String::UTF8 ); \
541 String value( psz_meta, String::UTF8 ); \
542 tag->addField( key, value, true ); \
544 free( psz_meta );
546 WRITE( Copyright, "COPYRIGHT" );
548 #undef WRITE
554 * Set the tags to the file using TagLib
555 * @param p_this: the demux object
556 * @return VLC_SUCCESS if the operation success
559 static int WriteMeta( vlc_object_t *p_this )
561 meta_export_t *p_export = (meta_export_t *)p_this;
562 input_item_t *p_item = p_export->p_item;
563 FileRef f;
565 if( !p_item )
567 msg_Err( p_this, "Can't save meta data of an empty input" );
568 return VLC_EGENERIC;
571 #if defined(WIN32) || defined (UNDER_CE)
572 wchar_t wpath[MAX_PATH + 1];
573 if( !MultiByteToWideChar( CP_UTF8, 0, p_export->psz_file, -1, wpath, MAX_PATH) )
574 return VLC_EGENERIC;
575 wpath[MAX_PATH] = L'\0';
576 f = FileRef( wpath );
577 #else
578 const char* local_name = ToLocale( p_export->psz_file );
579 if( !local_name )
580 return VLC_EGENERIC;
581 f = FileRef( local_name );
582 LocaleFree( local_name );
583 #endif
585 if( f.isNull() || !f.tag() || f.file()->readOnly() )
587 msg_Err( p_this, "File %s can't be opened for tag writing",
588 p_export->psz_file );
589 return VLC_EGENERIC;
592 msg_Dbg( p_this, "Writing metadata for %s", p_export->psz_file );
594 Tag *p_tag = f.tag();
596 char *psz_meta;
598 #define SET( a, b ) \
599 psz_meta = input_item_Get ## a( p_item ); \
600 if( psz_meta ) \
602 String tmp( psz_meta, String::UTF8 ); \
603 p_tag->set##b( tmp ); \
605 free( psz_meta );
607 // Saving all common fields
608 // If the title is empty, use the name
609 SET( TitleFbName, Title );
610 SET( Artist, Artist );
611 SET( Album, Album );
612 SET( Description, Comment );
613 SET( Genre, Genre );
615 #undef SET
617 psz_meta = input_item_GetDate( p_item );
618 if( psz_meta ) p_tag->setYear( atoi( psz_meta ) );
619 free( psz_meta );
621 psz_meta = input_item_GetTrackNum( p_item );
622 if( psz_meta ) p_tag->setTrack( atoi( psz_meta ) );
623 free( psz_meta );
626 // Try now to write special tags
627 if( FLAC::File* flac = dynamic_cast<FLAC::File*>(f.file()) )
629 if( flac->ID3v2Tag() )
630 WriteMetaToId3v2( flac->ID3v2Tag(), p_item );
631 else if( flac->xiphComment() )
632 WriteMetaToXiph( flac->xiphComment(), p_item );
634 else if( MPC::File* mpc = dynamic_cast<MPC::File*>(f.file()) )
636 if( mpc->APETag() )
637 WriteMetaToAPE( mpc->APETag(), p_item );
639 else if( MPEG::File* mpeg = dynamic_cast<MPEG::File*>(f.file()) )
641 if( mpeg->ID3v2Tag() )
642 WriteMetaToId3v2( mpeg->ID3v2Tag(), p_item );
643 else if( mpeg->APETag() )
644 WriteMetaToAPE( mpeg->APETag(), p_item );
646 else if( Ogg::File* ogg = dynamic_cast<Ogg::File*>(f.file()) )
648 if( Ogg::FLAC::File* ogg_flac = dynamic_cast<Ogg::FLAC::File*>(f.file()))
649 WriteMetaToXiph( ogg_flac->tag(), p_item );
650 else if( Ogg::Speex::File* ogg_speex = dynamic_cast<Ogg::Speex::File*>(f.file()) )
651 WriteMetaToXiph( ogg_speex->tag(), p_item );
652 else if( Ogg::Vorbis::File* ogg_vorbis = dynamic_cast<Ogg::Vorbis::File*>(f.file()) )
653 WriteMetaToXiph( ogg_vorbis->tag(), p_item );
655 #ifdef TAGLIB_WITH_ASF
656 else if( RIFF::File* riff = dynamic_cast<RIFF::File*>(f.file()) )
658 if( RIFF::AIFF::File* riff_aiff = dynamic_cast<RIFF::AIFF::File*>(f.file()) )
659 WriteMetaToId3v2( riff_aiff->tag(), p_item );
660 else if( RIFF::WAV::File* riff_wav = dynamic_cast<RIFF::WAV::File*>(f.file()) )
661 WriteMetaToId3v2( riff_wav->tag(), p_item );
663 #endif
664 else if( TrueAudio::File* trueaudio = dynamic_cast<TrueAudio::File*>(f.file()) )
666 if( trueaudio->ID3v2Tag() )
667 WriteMetaToId3v2( trueaudio->ID3v2Tag(), p_item );
669 else if( WavPack::File* wavpack = dynamic_cast<WavPack::File*>(f.file()) )
671 if( wavpack->APETag() )
672 WriteMetaToAPE( wavpack->APETag(), p_item );
675 // Save the meta data
676 f.save();
678 return VLC_SUCCESS;