]> git.sesse.net Git - vlc/blob - include/vlc_meta.h
Merge author/artist
[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
55 struct vlc_meta_t
56 {
57     char *psz_title;
58     char *psz_artist;
59     char *psz_genre;
60     char *psz_copyright;
61     char *psz_album;
62     char *psz_tracknum;
63     char *psz_description;
64     char *psz_rating;
65     char *psz_date;
66     char *psz_setting;
67     char *psz_url;
68     char *psz_language;
69     char *psz_nowplaying;
70     char *psz_publisher;
71     char *psz_encodedby;
72     char *psz_arturl;
73
74     int i_status;
75 #if 0
76     /* track meta information */
77     int         i_track;
78     vlc_meta_t  **track;
79 #endif
80 };
81
82 #define vlc_meta_Set( meta,var,val ) { \
83     if( meta->psz_##var ) free( meta->psz_##var ); \
84     meta->psz_##var = strdup( val ); }
85
86 #define vlc_meta_SetTitle( meta, b ) vlc_meta_Set( meta, title, b );
87 #define vlc_meta_SetArtist( meta, b ) vlc_meta_Set( meta, artist, b );
88 #define vlc_meta_SetGenre( meta, b ) vlc_meta_Set( meta, genre, b );
89 #define vlc_meta_SetCopyright( meta, b ) vlc_meta_Set( meta, copyright, b );
90 #define vlc_meta_SetAlbum( meta, b ) vlc_meta_Set( meta, album, b );
91 #define vlc_meta_SetTracknum( meta, b ) vlc_meta_Set( meta, tracknum, b );
92 #define vlc_meta_SetDescription( meta, b ) vlc_meta_Set( meta, description, b );
93 #define vlc_meta_SetRating( meta, b ) vlc_meta_Set( meta, rating, b );
94 #define vlc_meta_SetDate( meta, b ) vlc_meta_Set( meta, date, b );
95 #define vlc_meta_SetSetting( meta, b ) vlc_meta_Set( meta, setting, b );
96 #define vlc_meta_SetURL( meta, b ) vlc_meta_Set( meta, url, b );
97 #define vlc_meta_SetLanguage( meta, b ) vlc_meta_Set( meta, language, b );
98 #define vlc_meta_SetNowPlaying( meta, b ) vlc_meta_Set( meta, nowplaying, b );
99 #define vlc_meta_SetPublisher( meta, b ) vlc_meta_Set( meta, publisher, b );
100 #define vlc_meta_SetEncodedBy( meta, b ) vlc_meta_Set( meta, encodedby, b );
101 #define vlc_meta_SetArtURL( meta, b ) vlc_meta_Set( meta, arturl, b );
102
103 static inline vlc_meta_t *vlc_meta_New( void )
104 {
105     vlc_meta_t *m = (vlc_meta_t*)malloc( sizeof( vlc_meta_t ) );
106     if( !m ) return NULL;
107     m->psz_title = NULL;
108     m->psz_artist = NULL;
109     m->psz_genre = NULL;
110     m->psz_copyright = NULL;
111     m->psz_album = NULL;
112     m->psz_tracknum = NULL;
113     m->psz_description = NULL;
114     m->psz_rating = NULL;
115     m->psz_date = NULL;
116     m->psz_setting = NULL;
117     m->psz_url = NULL;
118     m->psz_language = NULL;
119     m->psz_nowplaying = NULL;
120     m->psz_publisher = NULL;
121     m->psz_encodedby = NULL;
122     m->psz_arturl = NULL;
123     m->i_status = 0;
124     return m;
125 }
126
127 static inline void vlc_meta_Delete( vlc_meta_t *m )
128 {
129     free( m->psz_title );
130     free( m->psz_artist );
131     free( m->psz_genre );
132     free( m->psz_copyright );
133     free( m->psz_album );
134     free( m->psz_tracknum );
135     free( m->psz_description );
136     free( m->psz_rating );
137     free( m->psz_date );
138     free( m->psz_setting );
139     free( m->psz_url );
140     free( m->psz_language );
141     free( m->psz_nowplaying );
142     free( m->psz_publisher );
143     free( m->psz_encodedby );
144     free( m->psz_arturl );
145
146     free( m );
147 }
148
149 static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src )
150 {
151     if( !dst || !src ) return;
152 #define COPY_FIELD( a ) \
153     if( src->psz_ ## a ) { \
154         if( dst->psz_ ## a ) free( dst->psz_## a ); \
155         dst->psz_##a = strdup( src->psz_##a ); \
156     }
157     COPY_FIELD( title );
158     COPY_FIELD( artist );
159     COPY_FIELD( genre );
160     COPY_FIELD( copyright );
161     COPY_FIELD( album );
162     COPY_FIELD( tracknum );
163     COPY_FIELD( description );
164     COPY_FIELD( rating );
165     COPY_FIELD( date );
166     COPY_FIELD( setting );
167     COPY_FIELD( url );
168     COPY_FIELD( language );
169     COPY_FIELD( nowplaying );
170     COPY_FIELD( publisher );
171     COPY_FIELD( encodedby );
172     COPY_FIELD( arturl );
173 }
174     /** \todo Track meta */
175
176 enum {
177     ALBUM_ART_NEVER,
178     ALBUM_ART_WHEN_ASKED,
179     ALBUM_ART_WHEN_PLAYED,
180     ALBUM_ART_ALL };
181
182 struct meta_export_t
183 {
184     input_item_t *p_item;
185     const char *psz_file;
186 };
187
188 #define VLC_META_ENGINE_TITLE           0x00000001
189 #define VLC_META_ENGINE_ARTIST          0x00000004
190 #define VLC_META_ENGINE_GENRE           0x00000008
191 #define VLC_META_ENGINE_COPYRIGHT       0x00000010
192 #define VLC_META_ENGINE_COLLECTION      0x00000020
193 #define VLC_META_ENGINE_SEQ_NUM         0x00000040
194 #define VLC_META_ENGINE_DESCRIPTION     0x00000080
195 #define VLC_META_ENGINE_RATING          0x00000100
196 #define VLC_META_ENGINE_DATE            0x00000200
197 #define VLC_META_ENGINE_URL             0x00000400
198 #define VLC_META_ENGINE_LANGUAGE        0x00000800
199
200 #define VLC_META_ENGINE_ART_URL         0x00001000
201
202 #define VLC_META_ENGINE_MB_ARTIST_ID    0x00002000
203 #define VLC_META_ENGINE_MB_RELEASE_ID   0x00004000
204 #define VLC_META_ENGINE_MB_TRACK_ID     0x00008000
205 #define VLC_META_ENGINE_MB_TRM_ID       0x00010000
206
207 typedef struct meta_engine_sys_t meta_engine_sys_t;
208
209 struct meta_engine_t
210 {
211     VLC_COMMON_MEMBERS
212
213     module_t *p_module;
214
215     uint32_t i_mandatory; /**< Stuff which we really need to get */
216     uint32_t i_optional; /**< Stuff which we'd like to have */
217
218     input_item_t *p_item;
219 };
220
221 VLC_EXPORT(uint32_t, input_CurrentMetaFlags,( vlc_meta_t *p_meta ) );
222
223 #endif