Changeset 5c47e1504ebede6bda22b1ac721021ea4e341bd0

Show
Ignore:
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
  • include/vlc_meta.h

    r8dbb3f3 r5c47e15  
    2828#ifndef _VLC_META_H 
    2929#define _VLC_META_H 1 
     30 
     31#include <vlc_arrays.h> 
    3032 
    3133/* VLC meta name */ 
     
    7880    char *psz_trackid; 
    7981 
    80     int  i_extra; 
    81     char **ppsz_extra_name; 
    82     char **ppsz_extra_value; 
     82    vlc_dictionary_t extra_tags; 
    8383 
    8484    int i_status; 
     
    131131    m->psz_trackid = NULL; 
    132132 
    133     m->i_extra = 0; 
    134     m->ppsz_extra_name = NULL; 
    135     m->ppsz_extra_value = NULL; 
    136  
    137133    m->i_status = 0; 
     134    vlc_dictionary_init( &m->extra_tags, 32 /* "ought to be enough for anybody" */ ); 
    138135    return m; 
    139136} 
     
    141138static inline void vlc_meta_Delete( vlc_meta_t *m ) 
    142139{ 
    143     int i; 
    144  
    145140    free( m->psz_title ); 
    146141    free( m->psz_artist ); 
     
    160155    free( m->psz_trackid ); 
    161156    free( m->psz_arturl ); 
    162     for( i = 0; i < m->i_extra; i++ ) 
     157    vlc_dictionary_clear( &m->extra_tags ); 
     158    free( m ); 
     159
     160static 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 ) 
    163164    { 
    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 ); 
    166167    } 
    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) ); 
    177169} 
    178170 
    179171static inline void vlc_meta_Merge( vlc_meta_t *dst, const vlc_meta_t *src ) 
    180172{ 
    181     int i; 
    182173    if( !dst || !src ) return; 
    183174#define COPY_FIELD( a ) \ 
     
    204195    COPY_FIELD( arturl ); 
    205196#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++ ) 
    208202    { 
    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] ); 
    221208    } 
     209    free( ppsz_all_keys ); 
    222210} 
    223211 
  • src/input/es_out.c

    r70a8bb9 r5c47e15  
    613613 
    614614    /* 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 ) 
    616616        return; 
    617617    /* Find program */ 
     
    677677        input_Control( p_input, INPUT_ADD_INFO, psz_cat, _(VLC_META_PUBLISHER), psz_provider ); 
    678678    } 
    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 ); 
    681687 
    682688    free( psz_cat ); 
  • src/input/input.c

    r8329eb0 r5c47e15  
    25482548    /* A bit ugly */ 
    25492549    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 ) 
    25512551    { 
    25522552        p_meta = vlc_meta_New(); 
     
    25632563    if( p_meta ) 
    25642564    { 
    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 ); 
    25682573        vlc_meta_Delete( p_meta ); 
    25692574    }