]> git.sesse.net Git - vlc/blob - modules/meta_engine/taglib.cpp
Move the meta readers to the correct folder, and use them for all parsing
[vlc] / modules / meta_engine / taglib.cpp
1 /*****************************************************************************
2  * taglib.cpp: Taglib tag parser/writer
3  *****************************************************************************
4  * Copyright (C) 2003-2006 the VideoLAN team
5  * $Id: rtsp.c 16204 2006-08-03 16:58:10Z zorglub $
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23 #include <vlc/vlc.h>
24 #include <vlc/input.h>
25 #include <vlc_meta.h>
26
27 #include <fileref.h>
28 #include <tag.h>
29
30 static int  ReadMeta ( vlc_object_t * );
31
32 vlc_module_begin();
33     set_capability( "meta reader", 1000 );
34     set_callbacks( ReadMeta, NULL );
35 vlc_module_end();
36  
37 static int ReadMeta( vlc_object_t *p_this )
38 {
39     demux_t *p_demux = (demux_t *)p_this;
40
41     if( !strncmp( p_demux->psz_access, "file", 4 ) )
42     {
43         if( !p_demux->p_private )
44             p_demux->p_private = (void*)vlc_meta_New();
45         TagLib::FileRef f( p_demux->psz_path );
46         if( !f.isNull() && f.tag() )
47         {
48             TagLib::Tag *tag = f.tag();
49             vlc_meta_t *p_meta = (vlc_meta_t *)(p_demux->p_private );
50
51             vlc_meta_SetTitle( p_meta, tag->title().toCString( true ) );
52             vlc_meta_SetArtist( p_meta, tag->artist().toCString( true ) );
53             return VLC_SUCCESS;
54         }
55     }
56     return VLC_EGENERIC;
57 }