]> git.sesse.net Git - vlc/blob - include/vlc_meta.h
* Fix id3tag new meta
[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_AUTHOR             N_("Author")
31 #define VLC_META_ARTIST             N_("Artist")
32 #define VLC_META_GENRE              N_("Genre")
33 #define VLC_META_COPYRIGHT          N_("Copyright")
34 #define VLC_META_COLLECTION         N_("Album/movie/show title")
35 #define VLC_META_SEQ_NUM            N_("Track number/position in set")
36 #define VLC_META_DESCRIPTION        N_("Description")
37 #define VLC_META_RATING             N_("Rating")
38 #define VLC_META_DATE               N_("Date")
39 #define VLC_META_SETTING            N_("Setting")
40 #define VLC_META_URL                N_("URL")
41 #define VLC_META_LANGUAGE           N_("Language")
42 #define VLC_META_NOW_PLAYING        N_("Now Playing")
43 #define VLC_META_PUBLISHER          N_("Publisher")
44 #define VLC_META_ENCODED_BY         N_("Encoded by")
45
46 #define VLC_META_CODEC_NAME         N_("Codec Name")
47 #define VLC_META_CODEC_DESCRIPTION  N_("Codec Description")
48
49 struct vlc_meta_t
50 {
51     char *psz_title;
52     char *psz_author;
53     char *psz_artist;
54     char *psz_genre;
55     char *psz_copyright;
56     char *psz_album;
57     char *psz_tracknum;
58     char *psz_description;
59     char *psz_rating;
60     char *psz_date;
61     char *psz_setting;
62     char *psz_url;
63     char *psz_language;
64     char *psz_nowplaying;
65     char *psz_publisher;
66     char *psz_encodedby;
67 #if 0
68     /* track meta information */
69     int         i_track;
70     vlc_meta_t  **track;
71 #endif
72 };
73
74 #define vlc_meta_Set( meta,var,val ) { \
75     if( meta->psz_##var ) free( meta->psz_##var ); \
76     meta->psz_##var = strdup( val ); }
77
78 #define vlc_meta_SetTitle( meta, b ) vlc_meta_Set( meta, title, b );
79 #define vlc_meta_SetArtist( meta, b ) vlc_meta_Set( meta, artist, b );
80 #define vlc_meta_SetAuthor( meta, b ) vlc_meta_Set( meta, author, b );
81 #define vlc_meta_SetGenre( meta, b ) vlc_meta_Set( meta, genre, b );
82 #define vlc_meta_SetCopyright( meta, b ) vlc_meta_Set( meta, copyright, b );
83 #define vlc_meta_SetAlbum( meta, b ) vlc_meta_Set( meta, album, b );
84 #define vlc_meta_SetTracknum( meta, b ) vlc_meta_Set( meta, tracknum, b );
85 #define vlc_meta_SetDescription( meta, b ) vlc_meta_Set( meta, description, b );
86 #define vlc_meta_SetRating( meta, b ) vlc_meta_Set( meta, rating, b );
87 #define vlc_meta_SetDate( meta, b ) vlc_meta_Set( meta, date, b );
88 #define vlc_meta_SetSetting( meta, b ) vlc_meta_Set( meta, setting, b );
89 #define vlc_meta_SetURL( meta, b ) vlc_meta_Set( meta, url, b );
90 #define vlc_meta_SetLanguage( meta, b ) vlc_meta_Set( meta, language, b );
91 #define vlc_meta_SetNowPlaying( meta, b ) vlc_meta_Set( meta, nowplaying, b );
92 #define vlc_meta_SetPublisher( meta, b ) vlc_meta_Set( meta, publisher, b );
93 #define vlc_meta_SetEncodedBy( meta, b ) vlc_meta_Set( meta, encodedby, b );
94
95 static inline vlc_meta_t *vlc_meta_New( void )
96 {
97     vlc_meta_t *m = (vlc_meta_t*)malloc( sizeof( vlc_meta_t ) );
98     if( !m ) return NULL;
99     m->psz_title = NULL;
100     m->psz_author = NULL;
101     m->psz_artist = NULL;
102     m->psz_genre = NULL;
103     m->psz_copyright = NULL;
104     m->psz_album = NULL;
105     m->psz_tracknum = NULL;
106     m->psz_description = NULL;
107     m->psz_rating = NULL;
108     m->psz_date = NULL;
109     m->psz_setting = NULL;
110     m->psz_url = NULL;
111     m->psz_language = NULL;
112     m->psz_nowplaying = NULL;
113     m->psz_publisher = NULL;
114     m->psz_encodedby = NULL;
115     return m;
116 }
117
118 static inline void vlc_meta_Delete( vlc_meta_t *m )
119 {
120     free( m->psz_title );
121     free( m->psz_author );
122     free( m->psz_artist );
123     free( m->psz_genre );
124     free( m->psz_copyright );
125     free( m->psz_album );
126     free( m->psz_tracknum );
127     free( m->psz_description );
128     free( m->psz_rating );
129     free( m->psz_date );
130     free( m->psz_setting );
131     free( m->psz_url );
132     free( m->psz_language );
133     free( m->psz_nowplaying );
134     free( m->psz_publisher );
135     free( m->psz_encodedby );
136
137     free( m );
138 }
139
140 static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src )
141 {
142     if( !dst || !src ) return;
143 #define COPY_FIELD( a ) \
144     if( src->psz_ ## a ) { \
145         if( dst->psz_ ## a ) free( dst->psz_## a ); \
146         dst->psz_##a = strdup( src->psz_##a ); \
147     }
148     COPY_FIELD( title );
149     COPY_FIELD( author );
150     COPY_FIELD( artist );
151     COPY_FIELD( genre );
152     COPY_FIELD( copyright );
153     COPY_FIELD( album );
154     COPY_FIELD( tracknum );
155     COPY_FIELD( description );
156     COPY_FIELD( rating );
157     COPY_FIELD( date );
158     COPY_FIELD( setting );
159     COPY_FIELD( url );
160     COPY_FIELD( language );
161     COPY_FIELD( nowplaying );
162     COPY_FIELD( publisher );
163     COPY_FIELD( encodedby );
164 }
165     /** \todo Track meta */
166
167 #endif