1 /*****************************************************************************
2 * taglib.cpp: Taglib tag parser/writer
3 *****************************************************************************
4 * Copyright (C) 2003-2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include <vlc/input.h>
32 static int ReadMeta ( vlc_object_t * );
35 set_capability( "meta reader", 1000 );
36 set_callbacks( ReadMeta, NULL );
39 bool checkID3Image( const TagLib::ID3v2::Tag *tag )
41 TagLib::ID3v2::FrameList l = tag->frameListMap()[ "APIC" ];
46 static int ReadMeta( vlc_object_t *p_this )
48 demux_t *p_demux = (demux_t *)p_this;
50 if( !strncmp( p_demux->psz_access, "file", 4 ) )
52 if( !p_demux->p_private )
53 p_demux->p_private = (void*)vlc_meta_New();
54 TagLib::FileRef f( p_demux->psz_path );
55 if( !f.isNull() && f.tag() )
57 TagLib::Tag *tag = f.tag();
58 vlc_meta_t *p_meta = (vlc_meta_t *)(p_demux->p_private );
60 vlc_meta_SetTitle( p_meta, tag->title().toCString( true ) );
61 vlc_meta_SetArtist( p_meta, tag->artist().toCString( true ) );
63 if( TagLib::MPEG::File *mpeg =
64 dynamic_cast<TagLib::MPEG::File *>(f.file() ) )
66 if( mpeg->ID3v2Tag() && checkID3Image( mpeg->ID3v2Tag() ) )
68 fprintf( stderr, "%s has APIC\n", p_meta->psz_title );
69 vlc_meta_SetArtURL( p_meta, "APIC" ); /// Means that the interface will use us to actually fetch it