1 /*****************************************************************************
2 * vlc_meta.h: Stream meta-data
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
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.
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.
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 *****************************************************************************/
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")
45 #define VLC_META_CDDB_ARTIST N_("CDDB Artist")
46 #define VLC_META_CDDB_CATEGORY N_("CDDB Category")
47 #define VLC_META_CDDB_DISCID N_("CDDB Disc ID")
48 #define VLC_META_CDDB_EXT_DATA N_("CDDB Extended Data")
49 #define VLC_META_CDDB_GENRE N_("CDDB Genre")
50 #define VLC_META_CDDB_YEAR N_("CDDB Year")
51 #define VLC_META_CDDB_TITLE N_("CDDB Title")
53 #define VLC_META_CDTEXT_ARRANGER N_("CD-Text Arranger")
54 #define VLC_META_CDTEXT_COMPOSER N_("CD-Text Composer")
55 #define VLC_META_CDTEXT_DISCID N_("CD-Text Disc ID")
56 #define VLC_META_CDTEXT_GENRE N_("CD-Text Genre")
57 #define VLC_META_CDTEXT_MESSAGE N_("CD-Text Message")
58 #define VLC_META_CDTEXT_SONGWRITER N_("CD-Text Songwriter")
59 #define VLC_META_CDTEXT_PERFORMER N_("CD-Text Performer")
60 #define VLC_META_CDTEXT_TITLE N_("CD-Text Title")
62 #define VLC_META_ISO_APPLICATION_ID N_("ISO-9660 Application ID")
63 #define VLC_META_ISO_PREPARER N_("ISO-9660 Preparer")
64 #define VLC_META_ISO_PUBLISHER N_("ISO-9660 Publisher")
65 #define VLC_META_ISO_VOLUME N_("ISO-9660 Volume")
66 #define VLC_META_ISO_VOLUMESET N_("ISO-9660 Volume Set")
68 #define VLC_META_CODEC_NAME N_("Codec Name")
69 #define VLC_META_CODEC_DESCRIPTION N_("Codec Description")
73 /* meta name/value pairs */
78 /* track meta information */
83 static inline vlc_meta_t *vlc_meta_New( void )
85 vlc_meta_t *m = (vlc_meta_t*)malloc( sizeof( vlc_meta_t ) );
97 static inline void vlc_meta_Delete( vlc_meta_t *m )
100 for( i = 0; i < m->i_meta; i++ )
105 if( m->name ) free( m->name );
106 if( m->value ) free( m->value );
108 for( i = 0; i < m->i_track; i++ )
110 vlc_meta_Delete( m->track[i] );
112 if( m->track ) free( m->track );
116 static inline void vlc_meta_Add( vlc_meta_t *m,
117 const char *name, const char *value )
119 m->name = (char**)realloc( m->name, sizeof(char*) * ( m->i_meta + 1 ) );
120 m->name[m->i_meta] = strdup( name );
122 m->value = (char**)realloc( m->value, sizeof(char*) * ( m->i_meta + 1 ) );
123 m->value[m->i_meta] = strdup( value );
128 static inline vlc_meta_t *vlc_meta_Duplicate( vlc_meta_t *src )
130 vlc_meta_t *dst = vlc_meta_New();
132 for( i = 0; i < src->i_meta; i++ )
134 vlc_meta_Add( dst, src->name[i], src->value[i] );
136 for( i = 0; i < src->i_track; i++ )
138 vlc_meta_t *tk = vlc_meta_Duplicate( src->track[i] );
140 dst->track = (vlc_meta_t**)realloc( dst->track, sizeof( vlc_meta_t* ) * (dst->i_track+1) );
141 dst->track[dst->i_track++] = tk;
146 static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src )
149 for( i = 0; i < src->i_meta; i++ )
151 /* Check if dst contains the entry */
152 for( j = 0; j < dst->i_meta; j++ )
154 if( !strcmp( src->name[i], dst->name[j] ) ) break;
156 if( j < dst->i_meta )
158 if( dst->value[j] ) free( dst->value[j] );
159 dst->value[j] = strdup( src->value[i] );
161 else vlc_meta_Add( dst, src->name[i], src->value[i] );
165 static inline char *vlc_meta_GetValue( vlc_meta_t *m, const char *name )
169 for( i = 0; i < m->i_meta; i++ )
171 if( !strcmp( m->name[i], name ) )
174 if( m->value[i] ) value = strdup( m->value[i] );