00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _VLC_META_H
00025 #define _VLC_META_H 1
00026
00027
00028 #define VLC_META_TITLE N_("Title")
00029 #define VLC_META_AUTHOR N_("Author")
00030 #define VLC_META_ARTIST N_("Artist")
00031 #define VLC_META_GENRE N_("Genre")
00032 #define VLC_META_COPYRIGHT N_("Copyright")
00033 #define VLC_META_DESCRIPTION N_("Description")
00034 #define VLC_META_RATING N_("Rating")
00035 #define VLC_META_DATE N_("Date")
00036 #define VLC_META_SETTING N_("Setting")
00037 #define VLC_META_URL N_("URL")
00038 #define VLC_META_LANGUAGE N_("Language")
00039 #define VLC_META_NOW_PLAYING N_("Now Playing")
00040
00041 #define VLC_META_CDDB_ARTIST N_("CDDB Artist")
00042 #define VLC_META_CDDB_CATEGORY N_("CDDB Category")
00043 #define VLC_META_CDDB_DISCID N_("CDDB Disc ID")
00044 #define VLC_META_CDDB_EXT_DATA N_("CDDB Extended Data")
00045 #define VLC_META_CDDB_GENRE N_("CDDB Genre")
00046 #define VLC_META_CDDB_YEAR N_("CDDB Year")
00047 #define VLC_META_CDDB_TITLE N_("CDDB Title")
00048
00049 #define VLC_META_CDTEXT_ARRANGER N_("CD-Text Arranger")
00050 #define VLC_META_CDTEXT_COMPOSER N_("CD-Text Composer")
00051 #define VLC_META_CDTEXT_DISCID N_("CD-Text Disc ID")
00052 #define VLC_META_CDTEXT_GENRE N_("CD-Text Genre")
00053 #define VLC_META_CDTEXT_MESSAGE N_("CD-Text Message")
00054 #define VLC_META_CDTEXT_SONGWRITER N_("CD-Text Songwriter")
00055 #define VLC_META_CDTEXT_PERFORMER N_("CD-Text Performer")
00056 #define VLC_META_CDTEXT_TITLE N_("CD-Text Title")
00057
00058 #define VLC_META_ISO_APPLICATION_ID N_("ISO-9660 Application ID")
00059 #define VLC_META_ISO_PREPARER N_("ISO-9660 Preparer")
00060 #define VLC_META_ISO_PUBLISHER N_("ISO-9660 Publisher")
00061 #define VLC_META_ISO_VOLUME N_("ISO-9660 Volume")
00062 #define VLC_META_ISO_VOLUMESET N_("ISO-9660 Volume Set")
00063
00064 #define VLC_META_CODEC_NAME N_("Codec Name")
00065 #define VLC_META_CODEC_DESCRIPTION N_("Codec Description")
00066
00067 struct vlc_meta_t
00068 {
00069
00070 int i_meta;
00071 char **name;
00072 char **value;
00073
00074
00075 int i_track;
00076 vlc_meta_t **track;
00077 };
00078
00079 static inline vlc_meta_t *vlc_meta_New( void )
00080 {
00081 vlc_meta_t *m = (vlc_meta_t*)malloc( sizeof( vlc_meta_t ) );
00082
00083 m->i_meta = 0;
00084 m->name = NULL;
00085 m->value = NULL;
00086
00087 m->i_track= 0;
00088 m->track = NULL;
00089
00090 return m;
00091 }
00092
00093 static inline void vlc_meta_Delete( vlc_meta_t *m )
00094 {
00095 int i;
00096 for( i = 0; i < m->i_meta; i++ )
00097 {
00098 free( m->name[i] );
00099 free( m->value[i] );
00100 }
00101 if( m->name ) free( m->name );
00102 if( m->value ) free( m->value );
00103
00104 for( i = 0; i < m->i_track; i++ )
00105 {
00106 vlc_meta_Delete( m->track[i] );
00107 }
00108 if( m->track ) free( m->track );
00109 free( m );
00110 }
00111
00112 static inline void vlc_meta_Add( vlc_meta_t *m,
00113 const char *name, const char *value )
00114 {
00115 m->name = (char**)realloc( m->name, sizeof(char*) * ( m->i_meta + 1 ) );
00116 m->name[m->i_meta] = strdup( name );
00117
00118 m->value = (char**)realloc( m->value, sizeof(char*) * ( m->i_meta + 1 ) );
00119 m->value[m->i_meta] = strdup( value );
00120
00121 m->i_meta++;
00122 }
00123
00124 static inline vlc_meta_t *vlc_meta_Duplicate( vlc_meta_t *src )
00125 {
00126 vlc_meta_t *dst = vlc_meta_New();
00127 int i;
00128 for( i = 0; i < src->i_meta; i++ )
00129 {
00130 vlc_meta_Add( dst, src->name[i], src->value[i] );
00131 }
00132 for( i = 0; i < src->i_track; i++ )
00133 {
00134 vlc_meta_t *tk = vlc_meta_Duplicate( src->track[i] );
00135
00136 dst->track = (vlc_meta_t**)realloc( dst->track, sizeof( vlc_meta_t* ) * (dst->i_track+1) );
00137 dst->track[dst->i_track++] = tk;
00138 }
00139 return dst;
00140 }
00141
00142 static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src )
00143 {
00144 int i, j;
00145 for( i = 0; i < src->i_meta; i++ )
00146 {
00147
00148 for( j = 0; j < dst->i_meta; j++ )
00149 {
00150 if( !strcmp( src->name[i], dst->name[j] ) ) break;
00151 }
00152 if( j < dst->i_meta )
00153 {
00154 if( dst->value[j] ) free( dst->value[j] );
00155 dst->value[j] = strdup( src->value[i] );
00156 }
00157 else vlc_meta_Add( dst, src->name[i], src->value[i] );
00158 }
00159 }
00160
00161 static inline char *vlc_meta_GetValue( vlc_meta_t *m, const char *name )
00162 {
00163 int i;
00164
00165 for( i = 0; i < m->i_meta; i++ )
00166 {
00167 if( !strcmp( m->name[i], name ) )
00168 {
00169 char *value = NULL;
00170 if( m->value[i] ) value = strdup( m->value[i] );
00171 return value;
00172 }
00173 }
00174 return NULL;
00175 }
00176
00177 #endif