]> git.sesse.net Git - vlc/blob - include/vlc_meta.h
Removes meta_export_t
[vlc] / include / vlc_meta.h
1 /*****************************************************************************
2  * vlc_meta.h: Stream meta-data
3  *****************************************************************************
4  * Copyright (C) 2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
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
24 #if !defined( __LIBVLC__ )
25   #error You are not libvlc or one of its plugins. You cannot include this file
26 #endif
27
28 #ifndef _VLC_META_H
29 #define _VLC_META_H 1
30
31 /* VLC meta name */
32 #define VLC_META_INFO_CAT           N_("Meta-information")
33 #define VLC_META_TITLE              N_("Title")
34 #define VLC_META_ARTIST             N_("Artist")
35 #define VLC_META_GENRE              N_("Genre")
36 #define VLC_META_COPYRIGHT          N_("Copyright")
37 #define VLC_META_COLLECTION         N_("Album/movie/show title")
38 #define VLC_META_SEQ_NUM            N_("Track number/position in set")
39 #define VLC_META_DESCRIPTION        N_("Description")
40 #define VLC_META_RATING             N_("Rating")
41 #define VLC_META_DATE               N_("Date")
42 #define VLC_META_SETTING            N_("Setting")
43 #define VLC_META_URL                N_("URL")
44 #define VLC_META_LANGUAGE           N_("Language")
45 #define VLC_META_NOW_PLAYING        N_("Now Playing")
46 #define VLC_META_PUBLISHER          N_("Publisher")
47 #define VLC_META_ENCODED_BY         N_("Encoded by")
48
49 #define VLC_META_ART_URL            N_("Art URL")
50
51 #define VLC_META_CODEC_NAME         N_("Codec Name")
52 #define VLC_META_CODEC_DESCRIPTION  N_("Codec Description")
53
54 #define ITEM_PREPARSED      0x01
55 #define ITEM_META_FETCHED   0x02
56 #define ITEM_ARTURL_FETCHED 0x04
57 #define ITEM_ART_FETCHED    0x08
58 #define ITEM_ART_NOTFOUND   0x10
59
60 struct vlc_meta_t
61 {
62     char *psz_title;
63     char *psz_artist;
64     char *psz_genre;
65     char *psz_copyright;
66     char *psz_album;
67     char *psz_tracknum;
68     char *psz_description;
69     char *psz_rating;
70     char *psz_date;
71     char *psz_setting;
72     char *psz_url;
73     char *psz_language;
74     char *psz_nowplaying;
75     char *psz_publisher;
76     char *psz_encodedby;
77     char *psz_arturl;
78     char *psz_trackid;
79
80     int  i_extra;
81     char **ppsz_extra_name;
82     char **ppsz_extra_value;
83
84     int i_status;
85
86 };
87
88 #define vlc_meta_Set( meta,var,val ) do { \
89     const char *str = val; \
90     if( meta->psz_##var ) free( meta->psz_##var ); \
91     meta->psz_##var = str ? strdup( str ) : NULL; } while(0)
92
93 #define vlc_meta_SetTitle( meta, b ) vlc_meta_Set( meta, title, b )
94 #define vlc_meta_SetArtist( meta, b ) vlc_meta_Set( meta, artist, b )
95 #define vlc_meta_SetGenre( meta, b ) vlc_meta_Set( meta, genre, b )
96 #define vlc_meta_SetCopyright( meta, b ) vlc_meta_Set( meta, copyright, b )
97 #define vlc_meta_SetAlbum( meta, b ) vlc_meta_Set( meta, album, b )
98 #define vlc_meta_SetTracknum( meta, b ) vlc_meta_Set( meta, tracknum, b )
99 #define vlc_meta_SetDescription( meta, b ) vlc_meta_Set( meta, description, b )
100 #define vlc_meta_SetRating( meta, b ) vlc_meta_Set( meta, rating, b )
101 #define vlc_meta_SetDate( meta, b ) vlc_meta_Set( meta, date, b )
102 #define vlc_meta_SetSetting( meta, b ) vlc_meta_Set( meta, setting, b )
103 #define vlc_meta_SetURL( meta, b ) vlc_meta_Set( meta, url, b )
104 #define vlc_meta_SetLanguage( meta, b ) vlc_meta_Set( meta, language, b )
105 #define vlc_meta_SetNowPlaying( meta, b ) vlc_meta_Set( meta, nowplaying, b )
106 #define vlc_meta_SetPublisher( meta, b ) vlc_meta_Set( meta, publisher, b )
107 #define vlc_meta_SetEncodedBy( meta, b ) vlc_meta_Set( meta, encodedby, b )
108 #define vlc_meta_SetArtURL( meta, b ) vlc_meta_Set( meta, arturl, b )
109 #define vlc_meta_SetTrackID( meta, b ) vlc_meta_Set( meta, trackid, b )
110
111 static inline vlc_meta_t *vlc_meta_New( void )
112 {
113     vlc_meta_t *m = (vlc_meta_t*)malloc( sizeof( vlc_meta_t ) );
114     if( !m ) return NULL;
115     m->psz_title = NULL;
116     m->psz_artist = NULL;
117     m->psz_genre = NULL;
118     m->psz_copyright = NULL;
119     m->psz_album = NULL;
120     m->psz_tracknum = NULL;
121     m->psz_description = NULL;
122     m->psz_rating = NULL;
123     m->psz_date = NULL;
124     m->psz_setting = NULL;
125     m->psz_url = NULL;
126     m->psz_language = NULL;
127     m->psz_nowplaying = NULL;
128     m->psz_publisher = NULL;
129     m->psz_encodedby = NULL;
130     m->psz_arturl = NULL;
131     m->psz_trackid = NULL;
132
133     m->i_extra = 0;
134     m->ppsz_extra_name = NULL;
135     m->ppsz_extra_value = NULL;
136
137     m->i_status = 0;
138     return m;
139 }
140
141 static inline void vlc_meta_Delete( vlc_meta_t *m )
142 {
143     int i;
144
145     free( m->psz_title );
146     free( m->psz_artist );
147     free( m->psz_genre );
148     free( m->psz_copyright );
149     free( m->psz_album );
150     free( m->psz_tracknum );
151     free( m->psz_description );
152     free( m->psz_rating );
153     free( m->psz_date );
154     free( m->psz_setting );
155     free( m->psz_url );
156     free( m->psz_language );
157     free( m->psz_nowplaying );
158     free( m->psz_publisher );
159     free( m->psz_encodedby );
160     free( m->psz_trackid );
161     free( m->psz_arturl );
162     for( i = 0; i < m->i_extra; i++ )
163     {
164         free( m->ppsz_extra_name[i] );
165         free( m->ppsz_extra_value[i] );
166     }
167     free( m->ppsz_extra_name );
168     free( m->ppsz_extra_value );
169
170     free( m );
171 }
172 static inline void vlc_meta_AddExtra( vlc_meta_t *m, const char *psz_name, const char *psz_value )
173 {
174     int i_extra = m->i_extra;
175     TAB_APPEND_CPP( char, m->i_extra, m->ppsz_extra_name,  strdup(psz_name) );
176     TAB_APPEND_CPP( char, i_extra,    m->ppsz_extra_value, strdup(psz_value) );
177 }
178
179 static inline void vlc_meta_Merge( vlc_meta_t *dst, const vlc_meta_t *src )
180 {
181     int i;
182     if( !dst || !src ) return;
183 #define COPY_FIELD( a ) \
184     if( src->psz_ ## a ) { \
185         if( dst->psz_ ## a ) free( dst->psz_## a ); \
186         dst->psz_##a = strdup( src->psz_##a ); \
187     }
188     COPY_FIELD( title );
189     COPY_FIELD( artist );
190     COPY_FIELD( genre );
191     COPY_FIELD( copyright );
192     COPY_FIELD( album );
193     COPY_FIELD( tracknum );
194     COPY_FIELD( description );
195     COPY_FIELD( rating );
196     COPY_FIELD( date );
197     COPY_FIELD( setting );
198     COPY_FIELD( url );
199     COPY_FIELD( language );
200     COPY_FIELD( nowplaying );
201     COPY_FIELD( publisher );
202     COPY_FIELD( encodedby );
203     COPY_FIELD( trackid );
204     COPY_FIELD( arturl );
205 #undef COPY_FIELD
206
207     for( i = 0; i < src->i_extra; i++ )
208     {
209         int j;
210         for( j = 0; j < dst->i_extra; j++ )
211         {
212             if( !strcmp( dst->ppsz_extra_name[j], src->ppsz_extra_name[i] ) )
213             {
214                 free( dst->ppsz_extra_value[j] );
215                 dst->ppsz_extra_value[j] = strdup( src->ppsz_extra_value[i] );
216                 break;
217             }
218         }
219         if( j >= dst->i_extra )
220             vlc_meta_AddExtra( dst, src->ppsz_extra_name[i], src->ppsz_extra_value[i] );
221     }
222 }
223
224 enum {
225     ALBUM_ART_WHEN_ASKED,
226     ALBUM_ART_WHEN_PLAYED,
227     ALBUM_ART_ALL
228 };
229
230 #define VLC_META_ENGINE_TITLE           0x00000001
231 #define VLC_META_ENGINE_ARTIST          0x00000004
232 #define VLC_META_ENGINE_GENRE           0x00000008
233 #define VLC_META_ENGINE_COPYRIGHT       0x00000010
234 #define VLC_META_ENGINE_COLLECTION      0x00000020
235 #define VLC_META_ENGINE_SEQ_NUM         0x00000040
236 #define VLC_META_ENGINE_DESCRIPTION     0x00000080
237 #define VLC_META_ENGINE_RATING          0x00000100
238 #define VLC_META_ENGINE_DATE            0x00000200
239 #define VLC_META_ENGINE_URL             0x00000400
240 #define VLC_META_ENGINE_LANGUAGE        0x00000800
241
242 #define VLC_META_ENGINE_ART_URL         0x00001000
243
244 #define VLC_META_ENGINE_MB_ARTIST_ID    0x00002000
245 #define VLC_META_ENGINE_MB_RELEASE_ID   0x00004000
246 #define VLC_META_ENGINE_MB_TRACK_ID     0x00008000
247 #define VLC_META_ENGINE_MB_TRM_ID       0x00010000
248
249 typedef struct meta_engine_sys_t meta_engine_sys_t;
250
251 struct meta_engine_t
252 {
253     VLC_COMMON_MEMBERS
254
255     module_t *p_module;
256
257     uint32_t i_mandatory; /**< Stuff which we really need to get */
258     uint32_t i_optional; /**< Stuff which we'd like to have */
259
260     input_item_t *p_item;
261 };
262
263 VLC_EXPORT(uint32_t, input_CurrentMetaFlags,( vlc_meta_t *p_meta ) );
264
265 #endif