Changeset 5c47e1504ebede6bda22b1ac721021ea4e341bd0
- Timestamp:
- 13/08/07 15:55:10
(1 year ago)
- Author:
- Pierre d'Herbemont <pdherbemont@videolan.org>
- git-committer:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1187013310 +0000
- git-parent:
[74da54252cce41e92c1957d87330405202ac41b6]
- git-author:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1187013310 +0000
- Message:
include/vlc_meta.h: Use the vlc_dictionary to store extra meta tags.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r8dbb3f3 |
r5c47e15 |
|
| 28 | 28 | #ifndef _VLC_META_H |
|---|
| 29 | 29 | #define _VLC_META_H 1 |
|---|
| | 30 | |
|---|
| | 31 | #include <vlc_arrays.h> |
|---|
| 30 | 32 | |
|---|
| 31 | 33 | /* VLC meta name */ |
|---|
| … | … | |
| 78 | 80 | char *psz_trackid; |
|---|
| 79 | 81 | |
|---|
| 80 | | int i_extra; |
|---|
| 81 | | char **ppsz_extra_name; |
|---|
| 82 | | char **ppsz_extra_value; |
|---|
| | 82 | vlc_dictionary_t extra_tags; |
|---|
| 83 | 83 | |
|---|
| 84 | 84 | int i_status; |
|---|
| … | … | |
| 131 | 131 | m->psz_trackid = NULL; |
|---|
| 132 | 132 | |
|---|
| 133 | | m->i_extra = 0; |
|---|
| 134 | | m->ppsz_extra_name = NULL; |
|---|
| 135 | | m->ppsz_extra_value = NULL; |
|---|
| 136 | | |
|---|
| 137 | 133 | m->i_status = 0; |
|---|
| | 134 | vlc_dictionary_init( &m->extra_tags, 32 /* "ought to be enough for anybody" */ ); |
|---|
| 138 | 135 | return m; |
|---|
| 139 | 136 | } |
|---|
| … | … | |
| 141 | 138 | static inline void vlc_meta_Delete( vlc_meta_t *m ) |
|---|
| 142 | 139 | { |
|---|
| 143 | | int i; |
|---|
| 144 | | |
|---|
| 145 | 140 | free( m->psz_title ); |
|---|
| 146 | 141 | free( m->psz_artist ); |
|---|
| … | … | |
| 160 | 155 | free( m->psz_trackid ); |
|---|
| 161 | 156 | free( m->psz_arturl ); |
|---|
| 162 | | for( i = 0; i < m->i_extra; i++ ) |
|---|
| | 157 | vlc_dictionary_clear( &m->extra_tags ); |
|---|
| | 158 | free( m ); |
|---|
| | 159 | } |
|---|
| | 160 | static inline void vlc_meta_AddExtra( vlc_meta_t *m, const char *psz_name, const char *psz_value ) |
|---|
| | 161 | { |
|---|
| | 162 | char * psz_oldvalue = (char *)vlc_dictionary_value_for_key( &m->extra_tags, psz_name ); |
|---|
| | 163 | if( psz_oldvalue != kVLCDictionaryNotFound ) |
|---|
| 163 | 164 | { |
|---|
| 164 | | free( m->ppsz_extra_name[i] ); |
|---|
| 165 | | free( m->ppsz_extra_value[i] ); |
|---|
| | 165 | free( psz_oldvalue ); |
|---|
| | 166 | vlc_dictionary_remove_value_for_key( &m->extra_tags, psz_name ); |
|---|
| 166 | 167 | } |
|---|
| 167 | | free( m->ppsz_extra_name ); |
|---|
| 168 | | free( m->ppsz_extra_value ); |
|---|
| 169 | | |
|---|
| 170 | | free( m ); |
|---|
| 171 | | } |
|---|
| 172 | | static inline void vlc_meta_AddExtra( vlc_meta_t *m, const char *psz_name, const char *psz_value ) |
|---|
| 173 | | { |
|---|
| 174 | | int i_extra = m->i_extra; |
|---|
| 175 | | TAB_APPEND_CPP( char, m->i_extra, m->ppsz_extra_name, strdup(psz_name) ); |
|---|
| 176 | | TAB_APPEND_CPP( char, i_extra, m->ppsz_extra_value, strdup(psz_value) ); |
|---|
| | 168 | vlc_dictionary_insert( &m->extra_tags, psz_name, strdup(psz_value) ); |
|---|
| 177 | 169 | } |
|---|
| 178 | 170 | |
|---|
| 179 | 171 | static inline void vlc_meta_Merge( vlc_meta_t *dst, const vlc_meta_t *src ) |
|---|
| 180 | 172 | { |
|---|
| 181 | | int i; |
|---|
| 182 | 173 | if( !dst || !src ) return; |
|---|
| 183 | 174 | #define COPY_FIELD( a ) \ |
|---|
| … | … | |
| 204 | 195 | COPY_FIELD( arturl ); |
|---|
| 205 | 196 | #undef COPY_FIELD |
|---|
| 206 | | |
|---|
| 207 | | for( i = 0; i < src->i_extra; i++ ) |
|---|
| | 197 | char ** ppsz_all_keys; |
|---|
| | 198 | int i; |
|---|
| | 199 | /* XXX: If speed up are needed, it is possible */ |
|---|
| | 200 | ppsz_all_keys = vlc_dictionary_all_keys( &src->extra_tags ); |
|---|
| | 201 | for( i = 0; ppsz_all_keys[i]; i++ ) |
|---|
| 208 | 202 | { |
|---|
| 209 | | int j; |
|---|
| 210 | | for( j = 0; j < dst->i_extra; j++ ) |
|---|
| 211 | | { |
|---|
| 212 | | if( !strcmp( dst->ppsz_extra_name[j], src->ppsz_extra_name[i] ) ) |
|---|
| 213 | | { |
|---|
| 214 | | free( dst->ppsz_extra_value[j] ); |
|---|
| 215 | | dst->ppsz_extra_value[j] = strdup( src->ppsz_extra_value[i] ); |
|---|
| 216 | | break; |
|---|
| 217 | | } |
|---|
| 218 | | } |
|---|
| 219 | | if( j >= dst->i_extra ) |
|---|
| 220 | | vlc_meta_AddExtra( dst, src->ppsz_extra_name[i], src->ppsz_extra_value[i] ); |
|---|
| | 203 | /* Always try to remove the previous value */ |
|---|
| | 204 | vlc_dictionary_remove_value_for_key( &dst->extra_tags, ppsz_all_keys[i] ); |
|---|
| | 205 | void * p_value = vlc_dictionary_value_for_key( &src->extra_tags, ppsz_all_keys[i] ); |
|---|
| | 206 | vlc_dictionary_insert( &dst->extra_tags, ppsz_all_keys[i], p_value ); |
|---|
| | 207 | free( ppsz_all_keys[i] ); |
|---|
| 221 | 208 | } |
|---|
| | 209 | free( ppsz_all_keys ); |
|---|
| 222 | 210 | } |
|---|
| 223 | 211 | |
|---|
| r70a8bb9 |
r5c47e15 |
|
| 613 | 613 | |
|---|
| 614 | 614 | /* Check against empty meta data (empty for what we handle) */ |
|---|
| 615 | | if( !p_meta->psz_title && !p_meta->psz_nowplaying && !p_meta->psz_publisher && p_meta->i_extra <= 0 ) |
|---|
| | 615 | if( !p_meta->psz_title && !p_meta->psz_nowplaying && !p_meta->psz_publisher && vlc_dictionary_keys_count( &p_meta->extra_tags ) <= 0 ) |
|---|
| 616 | 616 | return; |
|---|
| 617 | 617 | /* Find program */ |
|---|
| … | … | |
| 677 | 677 | input_Control( p_input, INPUT_ADD_INFO, psz_cat, _(VLC_META_PUBLISHER), psz_provider ); |
|---|
| 678 | 678 | } |
|---|
| 679 | | for( i = 0; i < p_meta->i_extra; i++ ) |
|---|
| 680 | | input_Control( p_input, INPUT_ADD_INFO, psz_cat, _(p_meta->ppsz_extra_name[i]), p_meta->ppsz_extra_value[i] ); |
|---|
| | 679 | char ** ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags ); |
|---|
| | 680 | for( i = 0; ppsz_all_keys[i]; i++ ) |
|---|
| | 681 | { |
|---|
| | 682 | input_Control( p_input, INPUT_ADD_INFO, psz_cat, _(ppsz_all_keys[i]), |
|---|
| | 683 | vlc_dictionary_value_for_key( &p_meta->extra_tags, ppsz_all_keys[i] ) ); |
|---|
| | 684 | free( ppsz_all_keys[i] ); |
|---|
| | 685 | } |
|---|
| | 686 | free( ppsz_all_keys ); |
|---|
| 681 | 687 | |
|---|
| 682 | 688 | free( psz_cat ); |
|---|
| r8329eb0 |
r5c47e15 |
|
| 2548 | 2548 | /* A bit ugly */ |
|---|
| 2549 | 2549 | p_meta = NULL; |
|---|
| 2550 | | if( p_item->p_meta->i_extra > 0 ) |
|---|
| | 2550 | if( vlc_dictionary_keys_count( &p_item->p_meta->extra_tags ) > 0 ) |
|---|
| 2551 | 2551 | { |
|---|
| 2552 | 2552 | p_meta = vlc_meta_New(); |
|---|
| … | … | |
| 2563 | 2563 | if( p_meta ) |
|---|
| 2564 | 2564 | { |
|---|
| 2565 | | for( i = 0; i < p_meta->i_extra; i++ ) |
|---|
| 2566 | | input_Control( p_input, INPUT_ADD_INFO, _(VLC_META_INFO_CAT), |
|---|
| 2567 | | _(p_meta->ppsz_extra_name[i]), "%s", p_meta->ppsz_extra_value[i] ); |
|---|
| | 2565 | char ** ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags ); |
|---|
| | 2566 | for( i = 0; ppsz_all_keys[i]; i++ ) |
|---|
| | 2567 | { |
|---|
| | 2568 | input_Control( p_input, INPUT_ADD_INFO, _(VLC_META_INFO_CAT), _(ppsz_all_keys[i]), |
|---|
| | 2569 | vlc_dictionary_value_for_key( &p_meta->extra_tags, ppsz_all_keys[i] ) ); |
|---|
| | 2570 | free( ppsz_all_keys[i] ); |
|---|
| | 2571 | } |
|---|
| | 2572 | free( ppsz_all_keys ); |
|---|
| 2568 | 2573 | vlc_meta_Delete( p_meta ); |
|---|
| 2569 | 2574 | } |
|---|