Changeset 2d109a7702135ed31aa8e466ea9534abac9d2fd8

Show
Ignore:
Timestamp:
23/06/04 12:00:21 (4 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1087984821 +0000
git-parent:

[0011cc995beacfd93385fa9c17fdd096b7267285]

git-author:
Clément Stenac <zorglub@videolan.org> 1087984821 +0000
Message:

Fix id3 and id3tag (using meta)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/mpeg/mpga.c

    r3bcdafa r2d109a7  
    3030#include <vlc/input.h> 
    3131 
     32#include "vlc_meta.h" 
     33 
    3234/***************************************************************************** 
    3335 * Module descriptor 
     
    5961 
    6062    int             i_bitrate_avg;  /* extracted from Xing header */ 
     63 
     64    vlc_meta_t      *meta; 
    6165 
    6266    es_out_id_t     *p_es; 
     
    166170    } 
    167171 
    168     /* skip possible id3 header */ 
     172    p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) ); 
     173    p_sys->i_time = 1; 
     174    p_sys->i_bitrate_avg = 0; 
     175    p_sys->meta = NULL; 
     176 
     177    /* skip/parse possible id3 header */ 
    169178    if( ( p_id3 = module_Need( p_demux, "id3", NULL, 0 ) ) ) 
    170179    { 
     180        p_sys->meta = (vlc_meta_t *)p_demux->p_private; 
     181        /* temporary */ 
     182        msg_Dbg( p_demux, "Title : %s", 
     183                 vlc_meta_GetValue( p_sys->meta,VLC_META_TITLE ) ); 
     184        p_demux->p_private = NULL; 
    171185        module_Unneed( p_demux, p_id3 ); 
    172186    } 
     
    210224    p_demux->pf_demux   = Demux; 
    211225    p_demux->pf_control = Control; 
    212     p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) ); 
    213     p_sys->i_time = 1; 
    214     p_sys->i_bitrate_avg = 0; 
    215226 
    216227    es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'm', 'p', 'g', 'a' ) ); 
     
    389400{ 
    390401    demux_sys_t *p_sys  = p_demux->p_sys; 
    391     return demux2_vaControlHelper( p_demux->s, 
    392                                    0, -1, 
    393                                    p_sys->i_bitrate_avg, 1, i_query, args ); 
    394 
    395  
     402 
     403    vlc_meta_t **pp_meta; 
     404 
     405    switch( i_query ) 
     406    { 
     407        case DEMUX_GET_META: 
     408            pp_meta = (vlc_meta_t **)va_arg( args, vlc_meta_t** ); 
     409            *pp_meta = vlc_meta_Duplicate( p_sys->meta ); 
     410            return VLC_SUCCESS; 
     411 
     412        default: 
     413            return demux2_vaControlHelper( p_demux->s, 
     414                                           0, -1, 
     415                                           p_sys->i_bitrate_avg, 1, i_query, 
     416                                           args ); 
     417    } 
     418
     419 
  • modules/demux/util/id3.c

    rd82e9eb r2d109a7  
    5050static int SkipID3Tag( vlc_object_t *p_this ) 
    5151{ 
    52     input_thread_t *p_input = NULL
     52    demux_t *p_demux = (demux_t *)p_this
    5353    uint8_t *p_peek; 
    5454    int i_size; 
     
    5656    int b_footer; 
    5757 
    58     if ( p_this->i_object_type == VLC_OBJECT_INPUT ) 
    59     { 
    60         p_input = (input_thread_t *)p_this; 
    61     } 
    62     if( p_input == NULL ) 
    63     { 
    64         p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE ); 
    65         if( p_input == NULL ) 
    66         { 
    67             return VLC_EGENERIC; 
    68         } 
    69     } 
     58    p_demux->p_private = NULL; 
    7059 
    71     msg_Dbg( p_input, "checking for ID3 tag" ); 
     60    msg_Dbg( p_demux, "checking for ID3 tag" ); 
    7261 
    7362    /* get 10 byte id3 header */ 
    74     if( stream_Peek( p_input->s, &p_peek, 10 ) < 10 ) 
     63    if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) 
    7564    { 
    76         msg_Err( p_input, "cannot peek()" ); 
    77         vlc_object_release( p_input ); 
     65        msg_Err( p_demux, "cannot peek()" ); 
    7866        return VLC_EGENERIC; 
    7967    } 
     
    8169    if( p_peek[0] != 'I' || p_peek[1] != 'D' || p_peek[2] != '3' ) 
    8270    { 
    83         vlc_object_release( p_input ); 
    8471        return VLC_SUCCESS; 
    8572    } 
     
    9986 
    10087    /* Skip the entire tag */ 
    101     stream_Read( p_input->s, NULL, i_size ); 
     88    stream_Read( p_demux->s, NULL, i_size ); 
    10289 
    103     msg_Dbg( p_input, "ID3v2.%d revision %d tag found, skiping %d bytes", 
     90    msg_Dbg( p_demux, "ID3v2.%d revision %d tag found, skiping %d bytes", 
    10491             version, revision, i_size ); 
    10592 
    106     vlc_object_release( p_input ); 
    10793    return VLC_SUCCESS; 
    10894} 
  • modules/demux/util/id3tag.c

    r562ab59 r2d109a7  
    3232#include <vlc/input.h> 
    3333 
    34 #include "ninput.h" 
    35  
    3634#include <sys/types.h> 
     35 
     36#include "vlc_meta.h" 
    3737 
    3838#include <id3tag.h> 
     
    6060 * ParseID3Tag : parse an id3tag into the info structures 
    6161 *****************************************************************************/ 
    62 static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) 
     62static void ParseID3Tag( demux_t *p_demux, uint8_t *p_data, int i_size ) 
    6363{ 
    6464    struct id3_tag        *p_id3_tag; 
     
    6767    vlc_value_t val; 
    6868    int i; 
     69    input_thread_t *p_input; 
     70 
     71    p_input = vlc_object_find( p_demux, VLC_OBJECT_INPUT, 
     72                                FIND_PARENT ); 
     73    if( !p_input) 
     74    { 
     75        return VLC_EGENERIC; 
     76    } 
    6977 
    7078    var_Get( p_input, "demuxed-id3", &val ); 
    7179    if( val.b_bool ) 
    7280    { 
    73         msg_Dbg( p_input, "the ID3 tag was already parsed" ); 
     81        msg_Dbg( p_demux, "the ID3 tag was already parsed" ); 
    7482        return; 
    7583    } 
    7684 
    7785    val.b_bool = VLC_FALSE; 
     86 
    7887    p_id3_tag = id3_tag_parse( p_data, i_size ); 
    7988    i = 0; 
     
    93102                char *psz_endptr; 
    94103                i_genre = strtol( psz_temp, &psz_endptr, 10 ); 
    95                 if( psz_temp != psz_endptr && i_genre >= 0 && i_genre < NUM_GENRES ) 
    96                 { 
    97                     input_Control( p_input, INPUT_ADD_INFO, "ID3", 
    98                                    (char *)p_frame->description
    99                                   ppsz_genres[atoi(psz_temp)]); 
     104                if( psz_temp != psz_endptr && i_genre >= 0 && 
     105                                              i_genre < NUM_GENRES ) 
     106                { 
     107                    vlc_meta_Add( (vlc_meta_t *)p_demux->p_private
     108                                  VLC_META_GENRE, ppsz_genres[atoi(psz_temp)]); 
    100109                } 
    101110                else 
    102111                { 
    103                     input_Control( p_input, INPUT_ADD_INFO, "ID3", 
    104                                    (char *)p_frame->description, psz_temp); 
     112                    /* Unknown genre */ 
     113                    vlc_meta_Add( (vlc_meta_t *)p_demux->p_private, 
     114                                   VLC_META_GENRE, psz_temp ); 
    105115                } 
    106116            } 
    107117            else if ( !strcmp(p_frame->id, ID3_FRAME_TITLE ) ) 
    108118            { 
    109                 input_Control( p_input, INPUT_SET_NAME, psz_temp ); 
    110                 input_Control( p_input, INPUT_ADD_INFO, "ID3", 
    111                                (char *)p_frame->description, psz_temp ); 
     119                vlc_meta_Add( (vlc_meta_t *)p_demux->p_private, 
     120                               VLC_META_TITLE, psz_temp ); 
     121//              input_Control( p_demux, INPUT_SET_NAME, psz_temp ); 
    112122            } 
    113123            else if ( !strcmp(p_frame->id, ID3_FRAME_ARTIST ) ) 
    114124            { 
    115                 input_Control( p_input, INPUT_ADD_INFO, 
    116                                _("General"), _("Author"), psz_temp ); 
    117                 input_Control( p_input, INPUT_ADD_INFO, "ID3", 
    118                                (char *)p_frame->description, psz_temp ); 
     125                vlc_meta_Add( (vlc_meta_t *)p_demux->p_private, 
     126                               VLC_META_ARTIST, psz_temp ); 
    119127            } 
    120128            else 
    121129            { 
    122                 input_Control( p_input, INPUT_ADD_INFO, "ID3", 
     130                /* Unknown meta info */ 
     131                vlc_meta_Add( (vlc_meta_t *)p_demux->p_private, 
    123132                               (char *)p_frame->description, psz_temp ); 
    124133            } 
     
    130139 
    131140    val.b_bool = VLC_TRUE; 
    132     var_Change( p_input, "demuxed-id3", VLC_VAR_SETVALUE, &val, NULL ); 
     141    var_Change( p_demux, "demuxed-id3", VLC_VAR_SETVALUE, &val, NULL ); 
     142 
     143    vlc_object_release( p_input ); 
    133144} 
    134145 
     
    139150static int ParseID3Tags( vlc_object_t *p_this ) 
    140151{ 
    141     input_thread_t *p_input = NULL
     152    demux_t *p_demux = (demux_t *)p_this
    142153    uint8_t *p_peek; 
    143154    int i_size; 
    144155    int i_size2; 
    145  
    146     if ( p_this->i_object_type == VLC_OBJECT_INPUT ) 
    147     { 
    148         p_input = (input_thread_t *)p_this; 
    149     } 
    150     if( p_input == NULL ) 
    151     { 
    152         p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE ); 
    153         if( p_input == NULL ) 
    154         { 
    155             return VLC_EGENERIC; 
    156         } 
    157     } 
    158  
    159     msg_Dbg( p_input, "checking for ID3 tag" ); 
    160  
    161     if ( p_input->stream.b_seekable && 
    162          p_input->stream.i_method != INPUT_METHOD_NETWORK ) 
    163     { 
     156    vlc_bool_t b_seekable; 
     157 
     158    p_demux->p_private = (void *)vlc_meta_New(); 
     159 
     160    msg_Dbg( p_demux, "checking for ID3 tag" ); 
     161 
     162    stream_Control( p_demux->s, STREAM_CAN_FASTSEEK, &b_seekable ); 
     163    if( b_seekable ) 
     164    { 
     165        int64_t i_init; 
    164166        int64_t i_pos; 
    165167 
    166168        /*look for a ID3v1 tag at the end of the file*/ 
    167         i_pos = stream_Size( p_input->s ); 
     169        i_init = stream_Tell( p_demux->s ); 
     170        i_pos = stream_Size( p_demux->s ); 
    168171 
    169172        if ( i_pos >128 ) 
    170173        { 
    171             input_AccessReinit( p_input ); 
    172             p_input->pf_seek( p_input, i_pos - 128 ); 
     174            stream_Seek( p_demux->s, i_pos - 128 ); 
    173175 
    174176            /* get 10 byte id3 header */ 
    175             if( stream_Peek( p_input->s, &p_peek, 10 ) < 10 ) 
    176             { 
    177                 msg_Err( p_input, "cannot peek()" ); 
    178                 vlc_object_release( p_input ); 
     177            if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) 
     178            { 
     179                msg_Err( p_demux, "cannot peek()" ); 
    179180                return( VLC_EGENERIC ); 
    180181            } 
     
    184185            { 
    185186                /* peek the entire tag */ 
    186                 if ( stream_Peek( p_input->s, &p_peek, i_size2 ) < i_size2 ) 
    187                 { 
    188                     msg_Err( p_input, "cannot peek()" ); 
    189                     vlc_object_release( p_input ); 
     187                if ( stream_Peek( p_demux->s, &p_peek, i_size2 ) < i_size2 ) 
     188                { 
     189                    msg_Err( p_demux, "cannot peek()" ); 
    190190                    return( VLC_EGENERIC ); 
    191191                } 
    192                 msg_Dbg( p_input, "found ID3v1 tag" ); 
    193                 ParseID3Tag( p_input, p_peek, i_size2 ); 
     192                msg_Dbg( p_demux, "found ID3v1 tag" ); 
     193                ParseID3Tag( p_demux, p_peek, i_size2 ); 
    194194            } 
    195195 
    196196            /* look for ID3v2.4 tag at end of file */ 
    197197            /* get 10 byte ID3 footer */ 
    198             if( stream_Peek( p_input->s, &p_peek, 128 ) < 128 ) 
    199             { 
    200                 msg_Err( p_input, "cannot peek()" ); 
    201                 vlc_object_release( p_input ); 
     198            if( stream_Peek( p_demux->s, &p_peek, 128 ) < 128 ) 
     199            { 
     200                msg_Err( p_demux, "cannot peek()" ); 
    202201                return( VLC_EGENERIC ); 
    203202            } 
     
    205204            if ( i_size2 < 0  && i_pos > -i_size2 ) 
    206205            {                                        /* id3v2.4 footer found */ 
    207                 input_AccessReinit( p_input ); 
    208                 p_input->pf_seek( p_input, i_pos + i_size2 ); 
     206                stream_Seek( p_demux->s , i_pos + i_size2 ); 
    209207                /* peek the entire tag */ 
    210                 if ( stream_Peek( p_input->s, &p_peek, i_size2 ) < i_size2 ) 
    211                 { 
    212                     msg_Err( p_input, "cannot peek()" ); 
    213                     vlc_object_release( p_input ); 
     208                if ( stream_Peek( p_demux->s, &p_peek, i_size2 ) < i_size2 ) 
     209                { 
     210                    msg_Err( p_demux, "cannot peek()" ); 
    214211                    return( VLC_EGENERIC ); 
    215212                } 
    216                 msg_Dbg( p_input, "found ID3v2 tag at end of file" ); 
    217                 ParseID3Tag( p_input, p_peek, i_size2 ); 
     213                msg_Dbg( p_demux, "found ID3v2 tag at end of file" ); 
     214                ParseID3Tag( p_demux, p_peek, i_size2 ); 
    218215            } 
    219216        } 
    220         input_AccessReinit( p_input ); 
    221         p_input->pf_seek( p_input, 0 ); 
     217        stream_Seek( p_demux->s, i_init ); 
    222218    } 
    223219    /* get 10 byte id3 header */ 
    224     if( stream_Peek( p_input->s, &p_peek, 10 ) < 10 ) 
    225     { 
    226         msg_Err( p_input, "cannot peek()" ); 
    227         vlc_object_release( p_input ); 
     220    if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) 
     221    { 
     222        msg_Err( p_demux, "cannot peek()" ); 
    228223        return( VLC_EGENERIC ); 
    229224    } 
     
    232227    if ( i_size <= 0 ) 
    233228    { 
    234         vlc_object_release( p_input ); 
    235229        return( VLC_SUCCESS ); 
    236230    } 
     
    238232    /* Read the entire tag */ 
    239233    p_peek = malloc( i_size ); 
    240     if( !p_peek || stream_Read( p_input->s, p_peek, i_size ) < i_size ) 
    241     { 
    242         msg_Err( p_input, "cannot read ID3 tag" ); 
     234    if( !p_peek || stream_Read( p_demux->s, p_peek, i_size ) < i_size ) 
     235    { 
     236        msg_Err( p_demux, "cannot read ID3 tag" ); 
    243237        if( p_peek ) free( p_peek ); 
    244         vlc_object_release( p_input ); 
    245238        return( VLC_EGENERIC ); 
    246239    } 
    247240 
    248     ParseID3Tag( p_input, p_peek, i_size ); 
    249     msg_Dbg( p_input, "found ID3v2 tag" ); 
     241    ParseID3Tag( p_demux, p_peek, i_size ); 
     242    msg_Dbg( p_demux, "found ID3v2 tag" ); 
    250243 
    251244    free( p_peek ); 
    252     vlc_object_release( p_input ); 
    253245    return( VLC_SUCCESS ); 
    254246}