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