Changeset acdfa3528ac2065633045d17717c47dae07f6552

Show
Ignore:
Timestamp:
31/01/04 06:27:02 (5 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1075526822 +0000
git-parent:

[e1e8b00b688cf445e40dffa6e91f26a10ed295e4]

git-author:
Laurent Aimar <fenrir@videolan.org> 1075526822 +0000
Message:
  • asf: implemented DEMUX_GET_LENGTH and DEMUX_GET_META.
Files:

Legend:

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

    re4fe636 racdfa35  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002-2003 VideoLAN 
    5  * $Id: asf.c,v 1.50 2004/01/29 18:02:58 zorglub Exp $ 
     5 * $Id: asf.c,v 1.51 2004/01/31 05:27:02 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    3030#include <vlc/input.h> 
    3131 
    32 #include "vlc_playlist.h" 
     32#include "vlc_meta.h" 
    3333 
    3434#include "codecs.h"                        /* BITMAPINFOHEADER, WAVEFORMATEX */ 
     
    5252 * Local prototypes 
    5353 *****************************************************************************/ 
    54 static int  Demux   ( input_thread_t * ); 
     54static int Demux  ( input_thread_t * ); 
     55static int Control( input_thread_t *, int i_query, va_list args ); 
    5556 
    5657typedef struct asf_stream_s 
     
    8182    int64_t             i_data_begin; 
    8283    int64_t             i_data_end; 
     84 
     85    vlc_meta_t          *meta; 
    8386}; 
    8487 
     
    102105    vlc_bool_t      b_seekable; 
    103106 
    104     input_info_category_t *p_cat; 
    105     playlist_item_t *p_item = NULL; 
    106  
    107107    /* a little test to see if it could be a asf stream */ 
    108108    if( input_Peek( p_input, &p_peek, 16 ) < 16 ) 
     
    120120    /* Set p_input field */ 
    121121    p_input->pf_demux         = Demux; 
    122     p_input->pf_demux_control = demux_vaControlDefault
     122    p_input->pf_demux_control = Control
    123123    p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) ); 
    124124    memset( p_sys, 0, sizeof( demux_sys_t ) ); 
     
    286286    } 
    287287 
    288     /* We add all info about this stream */ 
    289     p_cat = input_InfoCategory( p_input, _("Asf") ); 
    290     playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_input, 
    291                                      VLC_OBJECT_PLAYLIST,  FIND_PARENT); 
    292     if( p_playlist ) 
    293     { 
    294         vlc_mutex_lock( &p_playlist->object_lock ); 
    295         p_item = playlist_ItemGetByPos( p_playlist, -1 ); 
    296         vlc_mutex_unlock( &p_playlist->object_lock ); 
    297     } 
    298     if( p_item ) 
    299     { 
    300         vlc_mutex_lock( &p_item->lock ); 
    301     } 
    302  
    303     if( p_sys->i_length > 0 ) 
    304     { 
    305         int64_t i_second = p_sys->i_length / (int64_t)1000000; 
    306  
    307         input_AddInfo( p_cat, _("Length"), "%d:%d:%d", 
    308                        (int)(i_second / 36000), 
    309                        (int)(( i_second / 60 ) % 60), 
    310                        (int)(i_second % 60) ); 
    311         if( p_item ) 
    312         { 
    313             playlist_ItemAddInfo( p_item, _("Asf"), _("Length"), 
    314                                "%d:%d:%d", 
    315                                (int)(i_second / 36000), 
    316                                (int)(( i_second / 60 ) % 60), 
    317                                (int)(i_second % 60) ); 
    318         } 
    319     } 
    320     input_AddInfo( p_cat, _("Number of streams"), "%d" , p_sys->i_streams ); 
    321     if( p_item ) 
    322     { 
    323         playlist_ItemAddInfo( p_item, _("Asf"),_("Number of streams"),"%d", 
    324                          p_sys->i_streams ); 
    325     } 
     288    /* Create meta informations */ 
     289    p_sys->meta = vlc_meta_New(); 
    326290 
    327291    if( ( p_cd = ASF_FindObject( p_sys->p_root->p_hdr, 
    328292                                 &asf_object_content_description_guid, 0 ) ) ) 
    329293    { 
    330         if( *p_cd->psz_title ) 
    331         { 
    332             input_AddInfo( p_cat, _("Title"), p_cd->psz_title ); 
    333             if( p_item ) 
    334             { 
    335                 playlist_ItemAddInfo( p_item, _("Asf"),_("Title"), 
    336                                   p_cd->psz_title ); 
    337                 playlist_ItemSetName( p_item, p_cd->psz_title ); 
    338             } 
    339         } 
    340         if( p_cd->psz_author ) 
    341         { 
    342             input_AddInfo( p_cat, _("Author"), p_cd->psz_author ); 
    343             if( p_item ) 
    344             { 
    345                 playlist_ItemAddInfo( p_item, _("Asf"),_("Author"), 
    346                                   p_cd->psz_author ); 
    347                 playlist_ItemAddInfo( p_item, _("General"),_("Author"), 
    348                                   p_cd->psz_author ); 
    349             } 
    350         } 
    351         if( p_cd->psz_copyright ) 
    352         { 
    353             input_AddInfo( p_cat, _("Copyright"), p_cd->psz_copyright ); 
    354             if( p_item ) 
    355             { 
    356                 playlist_ItemAddInfo( p_item, _("Asf"),  _("Copyright"), 
    357                                       p_cd->psz_copyright ); 
    358             } 
    359         } 
    360         if( *p_cd->psz_description ) 
    361         { 
    362             input_AddInfo( p_cat, _("Description"), p_cd->psz_description ); 
    363             if( p_item ) 
    364             { 
    365                 playlist_ItemAddInfo( p_item, _("Asf"),  _("Description"), 
    366                                       p_cd->psz_description ); 
    367             } 
    368         } 
    369         if( *p_cd->psz_rating ) 
    370         { 
    371             input_AddInfo( p_cat, _("Rating"), p_cd->psz_rating ); 
    372             if( p_item ) 
    373             { 
    374                 playlist_ItemAddInfo( p_item, _("Asf"),  _("Rating"), 
    375                                       p_cd->psz_rating ); 
    376             } 
    377         } 
    378     } 
    379  
    380     /* FIXME to port to new way */ 
     294        if( p_cd->psz_title && *p_cd->psz_title ) 
     295        { 
     296            vlc_meta_Add( p_sys->meta, VLC_META_TITLE, p_cd->psz_title ); 
     297        } 
     298        if( p_cd->psz_author && *p_cd->psz_author ) 
     299        { 
     300             vlc_meta_Add( p_sys->meta, VLC_META_AUTHOR, p_cd->psz_author ); 
     301        } 
     302        if( p_cd->psz_copyright && *p_cd->psz_copyright ) 
     303        { 
     304            vlc_meta_Add( p_sys->meta, VLC_META_COPYRIGHT, p_cd->psz_copyright ); 
     305        } 
     306        if( p_cd->psz_description && *p_cd->psz_description ) 
     307        { 
     308            vlc_meta_Add( p_sys->meta, VLC_META_DESCRIPTION, p_cd->psz_description ); 
     309        } 
     310        if( p_cd->psz_rating && *p_cd->psz_rating ) 
     311        { 
     312            vlc_meta_Add( p_sys->meta, VLC_META_RATING, p_cd->psz_rating ); 
     313        } 
     314    } 
    381315    for( i_stream = 0, i = 0; i < 128; i++ ) 
    382316    { 
    383         asf_object_codec_list_t *p_cl = 
    384             ASF_FindObject( p_sys->p_root->p_hdr, 
    385                             &asf_object_codec_list_guid, 0 ); 
     317        asf_object_codec_list_t *p_cl = ASF_FindObject( p_sys->p_root->p_hdr, 
     318                                                        &asf_object_codec_list_guid, 0 ); 
    386319 
    387320        if( p_sys->stream[i] ) 
    388321        { 
    389             char *psz_cat = malloc( strlen(_("Stream")) + 10 ); 
    390             sprintf( psz_cat, "%s %d", _("Stream"), i_stream ); 
    391             p_cat = input_InfoCategory( p_input, psz_cat); 
     322            vlc_meta_t *tk = vlc_meta_New(); 
     323            TAB_APPEND( p_sys->meta->i_track, p_sys->meta->track, tk ); 
    392324 
    393325            if( p_cl && i_stream < p_cl->i_codec_entries_count ) 
    394326            { 
    395                 input_AddInfo( p_cat, _("Codec name"), 
    396                                p_cl->codec[i_stream].psz_name ); 
    397                 input_AddInfo( p_cat, _("Codec description"), 
    398                                p_cl->codec[i_stream].psz_description ); 
    399                 if( p_item ) 
     327                if( p_cl->codec[i_stream].psz_name && 
     328                    *p_cl->codec[i_stream].psz_name ) 
    400329                { 
    401                     playlist_ItemAddInfo( p_item, psz_cat, _("Codec name"), 
    402                                       p_cl->codec[i_stream].psz_name ); 
    403                     playlist_ItemAddInfo( p_item, psz_cat, 
    404                                     _("Codec description"), 
    405                                      p_cl->codec[i_stream].psz_description ); 
     330                    vlc_meta_Add( tk, VLC_META_CODEC_NAME, 
     331                                  p_cl->codec[i_stream].psz_name ); 
    406332                } 
    407             } 
    408             free( psz_cat ); 
     333                if( p_cl->codec[i_stream].psz_description && 
     334                    *p_cl->codec[i_stream].psz_description ) 
     335                { 
     336                    vlc_meta_Add( tk, VLC_META_CODEC_DESCRIPTION, 
     337                                  p_cl->codec[i_stream].psz_description ); 
     338                } 
     339            } 
    409340            i_stream++; 
    410341        } 
    411342    } 
    412     if( p_item ) 
    413     { 
    414         vlc_mutex_unlock( &p_item->lock ); 
    415     } 
    416  
    417     if( p_playlist ) vlc_object_release( p_playlist ); 
    418343    return VLC_SUCCESS; 
    419344 
     
    523448    msg_Dbg( p_input, "freeing all memory" ); 
    524449 
     450    vlc_meta_Delete( p_sys->meta ); 
     451 
    525452    ASF_FreeObjectRoot( p_input->s, p_sys->p_root ); 
    526453    for( i_stream = 0; i_stream < 128; i_stream++ ) 
     
    540467} 
    541468 
     469/***************************************************************************** 
     470 * Control: 
     471 *****************************************************************************/ 
     472static int Control( input_thread_t *p_input, int i_query, va_list args ) 
     473{ 
     474    demux_sys_t *p_sys = p_input->p_demux_data; 
     475    int64_t     *pi64; 
     476    vlc_meta_t **pp_meta; 
     477 
     478    switch( i_query ) 
     479    { 
     480        case DEMUX_GET_LENGTH: 
     481            pi64 = (int64_t*)va_arg( args, int64_t * ); 
     482            *pi64 = p_sys->i_length; 
     483            return VLC_SUCCESS; 
     484 
     485        case DEMUX_GET_META: 
     486            pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** ); 
     487            *pp_meta = vlc_meta_Duplicate( p_sys->meta ); 
     488            return VLC_SUCCESS; 
     489 
     490        default: 
     491            return demux_vaControlDefault( p_input, i_query, args ); 
     492    } 
     493} 
    542494 
    543495/*****************************************************************************