Changeset 6c84da28c658041cf1d9090d4414f0b5acfc947b

Show
Ignore:
Timestamp:
10/09/04 13:35:42 (4 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1094816142 +0000
git-parent:

[55cab795f441f0962044912e91645f1dfc723013]

git-author:
Gildas Bazin <gbazin@videolan.org> 1094816142 +0000
Message:

* commit modules/demux/asf/*: load and parse the metadata object + coding style changes.

Files:

Legend:

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

    radcebba r6c84da2  
    11/***************************************************************************** 
    2  * libasf.c : 
     2 * libasf.c : asf stream demux module for vlc 
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2003 VideoLAN 
    55 * $Id$ 
     6 * 
    67 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     8 *          Gildas Bazin <gbazin@videolan.org> 
    79 * 
    810 * This program is free software; you can redistribute it and/or modify 
     
    4547 * 
    4648 ****************************************************************************/ 
    47 static int ASF_ReadObject( stream_t *, 
    48                            asf_object_t *p_obj,  asf_object_t *p_father ); 
    49  
     49static int ASF_ReadObject( stream_t *, asf_object_t *,  asf_object_t * ); 
    5050 
    5151/**************************************************************************** 
     
    8888    p_common->i_object_pos  = stream_Tell( s ); 
    8989    p_common->p_next = NULL; 
     90 
    9091#ifdef ASF_DEBUG 
    9192    msg_Dbg( (vlc_object_t*)s, 
     
    114115        return VLC_EGENERIC; 
    115116    } 
    116     if( p_obj->common.p_father && p_obj->common.p_father->common.i_object_size != 0 ) 
    117     { 
    118         if( p_obj->common.p_father->common.i_object_pos + p_obj->common.p_father->common.i_object_size < 
     117    if( p_obj->common.p_father && 
     118        p_obj->common.p_father->common.i_object_size != 0 ) 
     119    { 
     120        if( p_obj->common.p_father->common.i_object_pos + 
     121            p_obj->common.p_father->common.i_object_size < 
    119122                p_obj->common.i_object_pos + p_obj->common.i_object_size + 24 ) 
    120123                                /* 24 is min size of an object */ 
     
    125128    } 
    126129 
    127     return stream_Seek( s, 
    128                         p_obj->common.i_object_pos + 
    129                            p_obj->common.i_object_size ); 
     130    return stream_Seek( s, p_obj->common.i_object_pos + 
     131                        p_obj->common.i_object_size ); 
    130132} 
    131133 
     
    152154    p_hdr->p_first = NULL; 
    153155    p_hdr->p_last  = NULL; 
     156 
    154157#ifdef ASF_DEBUG 
    155158    msg_Dbg( (vlc_object_t*)s, 
     
    159162             p_hdr->i_reserved2 ); 
    160163#endif 
    161     /* Cannot failed as peek succeed */ 
     164 
     165    /* Cannot fail as peek succeed */ 
    162166    stream_Read( s, NULL, 30 ); 
    163167 
     
    165169    for( ; ; ) 
    166170    { 
    167         p_subobj = malloc( sizeof( asf_object_t ) ); 
     171        p_subobj = malloc( sizeof( asf_object_t ) ); 
    168172 
    169173        if( ASF_ReadObject( s, p_subobj, (asf_object_t*)p_hdr ) ) 
    170174        { 
     175            free( p_subobj ); 
    171176            break; 
    172177        } 
     
    192197    p_data->i_total_data_packets = GetQWLE( p_peek + 40 ); 
    193198    p_data->i_reserved = GetWLE( p_peek + 48 ); 
     199 
    194200#ifdef ASF_DEBUG 
    195201    msg_Dbg( (vlc_object_t*)s, 
     
    200206             p_data->i_reserved ); 
    201207#endif 
     208 
    202209    return VLC_SUCCESS; 
    203210} 
     
    229236            (long int)p_index->i_index_entry_count ); 
    230237#endif 
     238 
    231239    return VLC_SUCCESS; 
    232240} 
     241 
    233242static void ASF_FreeObject_Index( asf_object_t *p_obj ) 
    234243{ 
     
    267276            I64Fd" flags:%d min_data_packet_size:%d max_data_packet_size:%d " 
    268277            "max_bitrate:%d", 
    269             GUID_PRINT( p_fp->i_file_id ), 
    270             p_fp->i_file_size, 
    271             p_fp->i_creation_date, 
    272             p_fp->i_data_packets_count, 
    273             p_fp->i_play_duration, 
    274             p_fp->i_send_duration, 
    275             p_fp->i_preroll, 
    276             p_fp->i_flags, 
    277             p_fp->i_min_data_packet_size, 
    278             p_fp->i_max_data_packet_size, 
     278            GUID_PRINT( p_fp->i_file_id ), p_fp->i_file_size, 
     279            p_fp->i_creation_date, p_fp->i_data_packets_count, 
     280            p_fp->i_play_duration, p_fp->i_send_duration, 
     281            p_fp->i_preroll, p_fp->i_flags, 
     282            p_fp->i_min_data_packet_size, p_fp->i_max_data_packet_size, 
    279283            p_fp->i_max_bitrate ); 
    280284#endif 
     285 
    281286    return VLC_SUCCESS; 
    282287} 
    283288 
    284 static int ASF_ReadObject_header_extention( stream_t *s, asf_object_t *p_obj ) 
    285 
    286     asf_object_header_extention_t *p_he = (asf_object_header_extention_t*)p_obj; 
     289static void ASF_FreeObject_metadata( asf_object_t *p_obj ) 
     290
     291    asf_object_metadata_t *p_meta = 
     292        (asf_object_metadata_t *)p_obj; 
     293    unsigned int i; 
     294 
     295    for( i = 0; i < p_meta->i_record_entries_count; i++ ) 
     296    { 
     297        if( p_meta->record[i].psz_name ) free( p_meta->record[i].psz_name ); 
     298        if( p_meta->record[i].p_data ) free( p_meta->record[i].p_data ); 
     299    } 
     300    if( p_meta->record ) free( p_meta->record ); 
     301
     302 
     303static int ASF_ReadObject_metadata( stream_t *s, asf_object_t *p_obj ) 
     304
     305    asf_object_metadata_t *p_meta = 
     306        (asf_object_metadata_t *)p_obj; 
     307 
     308    int i_peek, i_entries, i; 
     309    uint8_t *p_peek; 
     310 
     311    p_meta->i_record_entries_count = 0; 
     312    p_meta->record = 0; 
     313 
     314    if( stream_Peek( s, &p_peek, p_meta->i_object_size ) < 
     315        (int)p_meta->i_object_size ) 
     316    { 
     317       return VLC_EGENERIC; 
     318    } 
     319 
     320    i_peek = 24; 
     321    i_entries = GetWLE( p_peek + i_peek ); i_peek += 2; 
     322    for( i = 0; i < i_entries && i_peek < (int)p_meta->i_object_size -12; i++ ) 
     323    { 
     324        asf_metadata_record_t record; 
     325        int i_name, i_data, j; 
     326 
     327        if( GetWLE( p_peek + i_peek ) != 0 ) 
     328        { 
     329            ASF_FreeObject_metadata( p_obj ); 
     330            return VLC_EGENERIC; 
     331        } 
     332 
     333        i_peek += 2; 
     334        record.i_stream = GetWLE( p_peek + i_peek ); i_peek += 2; 
     335        i_name = GetWLE( p_peek + i_peek ); i_peek += 2; 
     336        record.i_type = GetWLE( p_peek + i_peek ); i_peek += 2; 
     337        i_data = GetDWLE( p_peek + i_peek ); i_peek += 4; 
     338 
     339        if( record.i_type > ASF_METADATA_TYPE_WORD || 
     340            i_peek + i_data + i_name > (int)p_meta->i_object_size ) 
     341        { 
     342            ASF_FreeObject_metadata( p_obj ); 
     343            return VLC_EGENERIC; 
     344        } 
     345 
     346        record.i_val = 0; 
     347        record.i_data = 0; 
     348        record.p_data = 0; 
     349 
     350        /* get name */ 
     351        record.psz_name = malloc( i_name/2 ); 
     352        for( j = 0; j < i_name/2; j++ ) 
     353        { 
     354            record.psz_name[j] = GetWLE( p_peek + i_peek ); i_peek += 2; 
     355        } 
     356 
     357        /* get data */ 
     358        if( record.i_type == ASF_METADATA_TYPE_STRING ) 
     359        { 
     360            record.p_data = malloc( i_data/2 ); 
     361            record.i_data = i_data/2; 
     362            for( j = 0; j < i_data/2; j++ ) 
     363            { 
     364                record.p_data[j] = GetWLE( p_peek + i_peek ); i_peek += 2; 
     365            } 
     366 
     367            msg_Dbg( s, "metadata: %s=%s", record.psz_name, record.p_data ); 
     368        } 
     369        else if( record.i_type == ASF_METADATA_TYPE_BYTE ) 
     370        { 
     371            record.p_data = malloc( i_data ); 
     372            record.i_data = i_data; 
     373            memcpy( record.p_data, p_peek + i_peek, i_data ); 
     374            p_peek += i_data; 
     375 
     376            msg_Dbg( s, "metadata: %s (%i bytes)", record.psz_name, 
     377                     record.i_data ); 
     378        } 
     379        else 
     380        { 
     381            if( record.i_type == ASF_METADATA_TYPE_QWORD ) 
     382            { 
     383                record.i_val = GetQWLE( p_peek + i_peek ); i_peek += 8; 
     384            } 
     385            else if( record.i_type == ASF_METADATA_TYPE_DWORD ) 
     386            { 
     387                record.i_val = GetDWLE( p_peek + i_peek ); i_peek += 4; 
     388            } 
     389            else 
     390            { 
     391                record.i_val = GetWLE( p_peek + i_peek ); i_peek += 2; 
     392            } 
     393 
     394            msg_Dbg( s, "metadata: %s=%i", record.psz_name, record.i_val ); 
     395        } 
     396 
     397        p_meta->i_record_entries_count++; 
     398        p_meta->record = 
     399            realloc( p_meta->record, p_meta->i_record_entries_count * 
     400                     sizeof(asf_metadata_record_t) ); 
     401        memcpy( &p_meta->record[p_meta->i_record_entries_count-1], 
     402                &record, sizeof(asf_metadata_record_t) ); 
     403    } 
     404 
     405    return VLC_SUCCESS; 
     406
     407 
     408static int ASF_ReadObject_header_extension( stream_t *s, asf_object_t *p_obj ) 
     409
     410    asf_object_header_extension_t *p_he = 
     411        (asf_object_header_extension_t *)p_obj; 
    287412    int     i_peek; 
    288413    uint8_t *p_peek; 
     
    294419    ASF_GetGUID( &p_he->i_reserved1, p_peek + 24 ); 
    295420    p_he->i_reserved2 = GetWLE( p_peek + 40 ); 
    296     p_he->i_header_extention_size = GetDWLE( p_peek + 42 ); 
    297     if( p_he->i_header_extention_size ) 
    298     { 
    299         p_he->p_header_extention_data = malloc( p_he->i_header_extention_size ); 
    300         memcpy( p_he->p_header_extention_data, 
    301                 p_peek + 46, 
    302                 p_he->i_header_extention_size ); 
     421    p_he->i_header_extension_size = GetDWLE( p_peek + 42 ); 
     422    if( p_he->i_header_extension_size ) 
     423    { 
     424        p_he->p_header_extension_data = 
     425            malloc( p_he->i_header_extension_size ); 
     426        memcpy( p_he->p_header_extension_data, p_peek + 46, 
     427                p_he->i_header_extension_size ); 
    303428    } 
    304429    else 
    305430    { 
    306         p_he->p_header_extention_data = NULL; 
    307     } 
     431        p_he->p_header_extension_data = NULL; 
     432    } 
     433 
    308434#ifdef ASF_DEBUG 
    309435    msg_Dbg( (vlc_object_t*)s, 
    310             "read \"header extention object\" reserved1:" GUID_FMT " reserved2:%d header_extention_size:%d", 
    311             GUID_PRINT( p_he->i_reserved1 )
    312             p_he->i_reserved2, 
    313             p_he->i_header_extention_size ); 
     436            "read \"header extension object\" reserved1:" GUID_FMT 
     437            " reserved2:%d header_extension_size:%d"
     438            GUID_PRINT( p_he->i_reserved1 ), p_he->i_reserved2, 
     439            p_he->i_header_extension_size ); 
    314440#endif 
     441 
     442    if( !p_he->i_header_extension_size ) return VLC_SUCCESS; 
     443 
     444    /* Read the extension objects */ 
     445    stream_Read( s, NULL, 46 ); 
     446    for( ; ; ) 
     447    { 
     448        asf_object_t *p_obj = malloc( sizeof( asf_object_t ) ); 
     449 
     450        if( ASF_ReadObject( s, p_obj, (asf_object_t*)p_he ) ) 
     451        { 
     452            free( p_obj ); 
     453            break; 
     454        } 
     455 
     456        if( ASF_NextObject( s, p_obj ) ) /* Go to the next object */ 
     457        { 
     458            break; 
     459        } 
     460    } 
     461 
    315462    return VLC_SUCCESS; 
    316463} 
    317 static void ASF_FreeObject_header_extention( asf_object_t *p_obj ) 
    318 
    319     asf_object_header_extention_t *p_he = (asf_object_header_extention_t*)p_obj; 
    320  
    321     FREE( p_he->p_header_extention_data ); 
     464 
     465static void ASF_FreeObject_header_extension( asf_object_t *p_obj ) 
     466
     467    asf_object_header_extension_t *p_he = 
     468        (asf_object_header_extension_t *)p_obj; 
     469 
     470    FREE( p_he->p_header_extension_data ); 
    322471} 
    323472 
     
    343492    if( p_sp->i_type_specific_data_length ) 
    344493    { 
    345         p_sp->p_type_specific_data = malloc( p_sp->i_type_specific_data_length ); 
    346         memcpy( p_sp->p_type_specific_data, 
    347                 p_peek + 78, 
     494        p_sp->p_type_specific_data = 
     495            malloc( p_sp->i_type_specific_data_length ); 
     496        memcpy( p_sp->p_type_specific_data, p_peek + 78, 
    348497                p_sp->i_type_specific_data_length ); 
    349498    } 
     
    354503    if( p_sp->i_error_correction_data_length ) 
    355504    { 
    356         p_sp->p_error_correction_data = malloc( p_sp->i_error_correction_data_length ); 
     505        p_sp->p_error_correction_data = 
     506            malloc( p_sp->i_error_correction_data_length ); 
    357507        memcpy( p_sp->p_error_correction_data, 
    358508                p_peek + 78 + p_sp->i_type_specific_data_length, 
     
    463613 
    464614#ifdef ASF_DEBUG 
    465     msg_Dbg( (vlc_object_t*)s, 
    466             "read \"codec list object\" reserved_guid:" GUID_FMT " codec_entries_count:%d", 
    467             GUID_PRINT( p_cl->i_reserved ), 
    468             p_cl->i_codec_entries_count ); 
     615    msg_Dbg( s, "read \"codec list object\" reserved_guid:" GUID_FMT 
     616             " codec_entries_count:%d", 
     617            GUID_PRINT( p_cl->i_reserved ), p_cl->i_codec_entries_count ); 
    469618 
    470619    for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ ) 
    471620    { 
    472621#define codec p_cl->codec[i_codec] 
    473         msg_Dbg( (vlc_object_t*)s, 
    474                  "read \"codec list object\" codec[%d] %s name:\"%s\" description:\"%s\" information_length:%d", 
    475                  i_codec, 
    476                  ( codec.i_type == ASF_CODEC_TYPE_VIDEO ) ? "video" : ( ( codec.i_type == ASF_CODEC_TYPE_AUDIO ) ? "audio" : "unknown" ), 
    477                  codec.psz_name
    478                  codec.psz_description, 
     622        msg_Dbg( s, "read \"codec list object\" codec[%d] %s name:\"%s\" " 
     623                 "description:\"%s\" information_length:%d", 
     624                 i_codec, ( codec.i_type == ASF_CODEC_TYPE_VIDEO ) ? 
     625                 "video" : ( ( codec.i_type == ASF_CODEC_TYPE_AUDIO ) ? 
     626                 "audio" : "unknown" )
     627                 codec.psz_name, codec.psz_description, 
    479628                 codec.i_information_length ); 
     629#undef  codec 
    480630    } 
    481631#endif 
     632 
    482633    return VLC_SUCCESS; 
    483634} 
     
    494645        FREE( codec.psz_description ); 
    495646        FREE( codec.p_information ); 
    496  
    497647#undef  codec 
    498648    } 
     
    505655{ 
    506656    asf_object_content_description_t *p_cd = 
    507                                     (asf_object_content_description_t*)p_obj; 
    508     int     i_peek; 
     657        (asf_object_content_description_t *)p_obj; 
    509658    uint8_t *p_peek, *p_data; 
    510  
    511     int i_len; 
    512     int i_title; 
    513     int i_author; 
    514     int i_copyright; 
    515     int i_description; 
    516     int i_rating; 
     659    int i_peek; 
     660    int i_len, i_title, i_author, i_copyright, i_description, i_rating; 
    517661 
    518662#define GETSTRINGW( psz_str, i_size ) \ 
     
    560704{ 
    561705    asf_object_content_description_t *p_cd = 
    562                                     (asf_object_content_description_t*)p_obj; 
     706        (asf_object_content_description_t *)p_obj; 
    563707 
    564708    FREE( p_cd->psz_title ); 
     
    575719    int     (*ASF_ReadObject_function)( stream_t *, asf_object_t *p_obj ); 
    576720    void    (*ASF_FreeObject_function)( asf_object_t *p_obj ); 
     721 
    577722} ASF_Object_Function [] = 
    578723{ 
    579     { &asf_object_header_guid,            ASF_OBJECT_TYPE_HEADER,             ASF_ReadObject_Header, ASF_FreeObject_Null }, 
    580     { &asf_object_data_guid,              ASF_OBJECT_TYPE_DATA,               ASF_ReadObject_Data,   ASF_FreeObject_Null }, 
    581     { &asf_object_index_guid,             ASF_OBJECT_TYPE_INDEX,              ASF_ReadObject_Index,  ASF_FreeObject_Index }, 
    582     { &asf_object_file_properties_guid,   ASF_OBJECT_TYPE_FILE_PROPERTIES,    ASF_ReadObject_file_properties,  ASF_FreeObject_Null }, 
    583     { &asf_object_stream_properties_guid, ASF_OBJECT_TYPE_STREAM_PROPERTIES,  ASF_ReadObject_stream_properties,ASF_FreeObject_stream_properties }, 
    584     { &asf_object_header_extention_guid,  ASF_OBJECT_TYPE_EXTENTION_HEADER,   ASF_ReadObject_header_extention, ASF_FreeObject_header_extention}, 
    585     { &asf_object_codec_list_guid,        ASF_OBJECT_TYPE_CODEC_LIST,         ASF_ReadObject_codec_list,       ASF_FreeObject_codec_list }, 
    586     { &asf_object_marker_guid,            ASF_OBJECT_TYPE_MARKER,             NULL,                  NULL }, 
    587     { &asf_object_content_description_guid, ASF_OBJECT_TYPE_CONTENT_DESCRIPTION, ASF_ReadObject_content_description, ASF_FreeObject_content_description }, 
    588  
    589     { &asf_object_null_guid,   0,                      NULL,                  NULL } 
     724    { &asf_object_header_guid, ASF_OBJECT_TYPE_HEADER, 
     725      ASF_ReadObject_Header, ASF_FreeObject_Null }, 
     726    { &asf_object_data_guid, ASF_OBJECT_TYPE_DATA, 
     727      ASF_ReadObject_Data, ASF_FreeObject_Null }, 
     728    { &asf_object_index_guid, ASF_OBJECT_TYPE_INDEX, 
     729      ASF_ReadObject_Index, ASF_FreeObject_Index }, 
     730    { &asf_object_file_properties_guid, ASF_OBJECT_TYPE_FILE_PROPERTIES, 
     731      ASF_ReadObject_file_properties, ASF_FreeObject_Null }, 
     732    { &asf_object_stream_properties_guid, ASF_OBJECT_TYPE_STREAM_PROPERTIES, 
     733      ASF_ReadObject_stream_properties,ASF_FreeObject_stream_properties }, 
     734    { &asf_object_header_extension_guid, ASF_OBJECT_TYPE_HEADER_EXTENSION, 
     735      ASF_ReadObject_header_extension, ASF_FreeObject_header_extension}, 
     736    { &asf_object_metadata_guid, ASF_OBJECT_TYPE_METADATA, 
     737      ASF_ReadObject_metadata, ASF_FreeObject_metadata}, 
     738    { &asf_object_codec_list_guid, ASF_OBJECT_TYPE_CODEC_LIST, 
     739      ASF_ReadObject_codec_list, ASF_FreeObject_codec_list }, 
     740    { &asf_object_marker_guid, ASF_OBJECT_TYPE_MARKER, 
     741      NULL, NULL }, 
     742    { &asf_object_content_description_guid, ASF_OBJECT_TYPE_CONTENT_DESCRIPTION, 
     743      ASF_ReadObject_content_description, ASF_FreeObject_content_description }, 
     744 
     745    { &asf_object_null_guid, 0, NULL, NULL } 
    590746}; 
    591747 
    592 static int ASF_ReadObject( stream_t *s, 
    593                            asf_object_t *p_obj, asf_object_t *p_father ) 
     748static int ASF_ReadObject( stream_t *s, asf_object_t *p_obj, 
     749                           asf_object_t *p_father ) 
    594750{ 
    595751    int i_result; 
    596752    int i_index; 
    597753 
    598     if( !p_obj ) 
    599     { 
    600         return( 0 ); 
    601     } 
     754    if( !p_obj ) return( 0 ); 
     755 
    602756    if( ASF_ReadObjectCommon( s, p_obj ) ) 
    603757    { 
     
    610764    p_obj->common.p_last = NULL; 
    611765 
    612  
    613766    if( p_obj->common.i_object_size < 24 ) 
    614767    { 
     
    616769        return VLC_EGENERIC; 
    617770    } 
     771 
    618772    /* find this object */ 
    619773    for( i_index = 0; ; i_index++ ) 
    620774    { 
    621775        if( ASF_CmpGUID( ASF_Object_Function[i_index].p_id, 
    622                      &p_obj->common.i_object_id )|| 
     776                         &p_obj->common.i_object_id ) || 
    623777            ASF_CmpGUID( ASF_Object_Function[i_index].p_id, 
    624                      &asf_object_null_guid ) ) 
     778                         &asf_object_null_guid ) ) 
    625779        { 
    626780            break; 
     
    664818    asf_object_t *p_child; 
    665819 
    666     if( !p_obj ) 
    667     { 
    668         return; 
    669     } 
     820    if( !p_obj ) return; 
    670821 
    671822    /* Free all child object */ 
     
    730881    p_root->p_fp    = NULL; 
    731882    p_root->p_index = NULL; 
     883    p_root->p_hdr_ext = NULL; 
     884    p_root->p_metadata = NULL; 
    732885 
    733886    for( ; ; ) 
    734887    { 
    735         p_obj = malloc( sizeof( asf_object_t ) ); 
     888        p_obj = malloc( sizeof( asf_object_t ) ); 
    736889 
    737890        if( ASF_ReadObject( s, p_obj, (asf_object_t*)p_root ) ) 
    738891        { 
     892            free( p_obj ); 
    739893            break; 
    740894        } 
     
    750904                p_root->p_index = (asf_object_index_t*)p_obj; 
    751905                break; 
     906            case( ASF_OBJECT_TYPE_HEADER_EXTENSION ): 
     907                p_root->p_hdr_ext = (asf_object_header_extension_t*)p_obj; 
     908                break; 
    752909            default: 
    753910                msg_Warn( (vlc_object_t*)s, "unknow object found" ); 
     
    762919        if( !b_seekable && p_root->p_hdr && p_root->p_data ) 
    763920        { 
    764             /* For unseekable stream it's enouth to play */ 
     921            /* For unseekable stream it's enough to play */ 
    765922            break; 
    766923        } 
     
    779936        if( p_root->p_fp ) 
    780937        { 
     938 
     939            if( p_root->p_hdr_ext != NULL ) 
     940            { 
     941                p_root->p_metadata = 
     942                    ASF_FindObject( p_root->p_hdr_ext, 
     943                                    &asf_object_metadata_guid, 0 ); 
     944            } 
     945 
    781946            return p_root; 
    782947        } 
     
    809974    asf_object_t *p_child; 
    810975 
    811     if( !p_obj ) 
    812     { 
    813         return( 0 ); 
    814     } 
     976    if( !p_obj ) return( 0 ); 
    815977 
    816978    i_count = 0; 
     
    827989} 
    828990 
    829 void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number ) 
     991void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, 
     992                        int i_number ) 
    830993{ 
    831994    asf_object_t *p_child; 
     
    8491012    return( NULL ); 
    8501013} 
    851  
  • modules/demux/asf/libasf.h

    rffdca9a r6c84da2  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2003 VideoLAN 
    5  * $Id: libasf.h,v 1.8 2004/01/25 20:05:28 hartman Exp
     5 * $Id
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 * 
     
    4040#define ASF_OBJECT_TYPE_FILE_PROPERTIES     0x0005 
    4141#define ASF_OBJECT_TYPE_STREAM_PROPERTIES   0x0006 
    42 #define ASF_OBJECT_TYPE_EXTENTION_HEADER    0x0007 
     42#define ASF_OBJECT_TYPE_HEADER_EXTENSION    0x0007 
    4343#define ASF_OBJECT_TYPE_CODEC_LIST          0x0008 
    4444#define ASF_OBJECT_TYPE_MARKER              0x0009 
    4545#define ASF_OBJECT_TYPE_CONTENT_DESCRIPTION 0x000a 
     46#define ASF_OBJECT_TYPE_METADATA            0x000b 
    4647 
    4748static const guid_t asf_object_null_guid = 
     
    5455 
    5556static const guid_t asf_object_header_guid = 
    56 
    57     0x75B22630, 
    58     0x668E, 
    59     0x11CF, 
    60     { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C } 
    61 }; 
     57{0x75B22630, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}}; 
    6258 
    6359static const guid_t asf_object_data_guid = 
    64 
    65     0x75B22636, 
    66     0x668E, 
    67     0x11CF, 
    68     { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C } 
    69 }; 
    70  
    71  
     60{0x75B22636, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}}; 
    7261 
    7362static const guid_t asf_object_index_guid = 
    74 
    75     0x33000890, 
    76     0xE5B1, 
    77     0x11CF, 
    78     { 0x89,0xF4, 0x00,0xA0,0xC9,0x03,0x49,0xCB } 
    79 }; 
     63{0x33000890, 0xE5B1, 0x11CF, {0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB}}; 
    8064 
    8165static const guid_t asf_object_file_properties_guid = 
    82 
    83     0x8cabdca1, 
    84     0xa947, 
    85     0x11cf, 
    86     { 0x8e,0xe4, 0x00,0xC0,0x0C,0x20,0x53,0x65 } 
    87  
    88 }; 
     66{0x8cabdca1, 0xa947, 0x11cf, {0x8e, 0xe4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}}; 
     67 
    8968static const guid_t asf_object_stream_properties_guid = 
    90 
    91     0xB7DC0791, 
    92     0xA9B7, 
    93     0x11CF, 
    94     { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 } 
    95  
    96 }; 
     69{0xB7DC0791, 0xA9B7, 0x11CF, {0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}}; 
    9770 
    9871static const guid_t asf_object_content_description_guid = 
    99 
    100     0x75B22633, 
    101     0x668E, 
    102     0x11CF, 
    103     { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c } 
    104 }; 
    105  
    106 static const guid_t asf_object_header_extention_guid = 
    107 
    108    0x5FBF03B5, 
    109    0xA92E, 
    110    0x11CF, 
    111    { 0x8E,0xE3, 0x00,0xC0,0x0C,0x20,0x53,0x65 } 
    112 }; 
     72{0x75B22633, 0x668E, 0x11CF, {0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}; 
     73 
     74static const guid_t asf_object_header_extension_guid = 
     75{0x5FBF03B5, 0xA92E, 0x11CF, {0x8E, 0xE3, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}}; 
     76 
     77static const guid_t asf_object_metadata_guid = 
     78{0xC5F8CBEA, 0x5BAF, 0x4877, {0x84, 0x67, 0xAA, 0x8C, 0x44, 0xFA, 0x4C, 0xCA}}; 
    11379 
    11480static const guid_t asf_object_codec_list_guid = 
    115 
    116     0x86D15240, 
    117     0x311D, 
    118     0x11D0, 
    119     { 0xA3,0xA4, 0x00,0xA0,0xC9,0x03,0x48,0xF6 } 
    120 }; 
     81{0x86D15240, 0x311D, 0x11D0, {0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}}; 
    12182 
    12283static const guid_t asf_object_marker_guid = 
    123 
    124     0xF487CD01, 
    125     0xA951, 
    126     0x11CF, 
    127     { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 } 
    128  
    129 }; 
     84{0xF487CD01, 0xA951, 0x11CF, {0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}}; 
    13085 
    13186static const guid_t asf_object_stream_type_audio = 
    132 
    133     0xF8699E40, 
    134     0x5B4D, 
    135     0x11CF, 
    136     { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B } 
    137 }; 
     87{0xF8699E40, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}}; 
    13888 
    13989static const guid_t asf_object_stream_type_video = 
    140 
    141     0xbc19efc0, 
    142     0x5B4D, 
    143     0x11CF, 
    144     { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B } 
    145 }; 
     90{0xbc19efc0, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}}; 
    14691 
    14792static const guid_t asf_object_stream_type_command = 
    148 
    149     0x59DACFC0, 
    150     0x59E6, 
    151     0x11D0, 
    152     { 0xA3,0xAC, 0x00,0xA0,0xC9,0x03,0x48,0xF6 } 
    153 }; 
    154  
    155 #define ASF_OBJECT_COMMON           \ 
    156     int          i_type;            \ 
    157     guid_t       i_object_id;       \ 
    158     uint64_t     i_object_size;     \ 
    159     uint64_t     i_object_pos;      \ 
     93{0x59DACFC0, 0x59E6, 0x11D0, {0xA3, 0xAC, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}}; 
     94 
     95#define ASF_OBJECT_COMMON          \ 
     96    int          i_type;           \ 
     97    guid_t       i_object_id;      \ 
     98    uint64_t     i_object_size;    \ 
     99    uint64_t     i_object_pos;     \ 
    160100    union asf_object_u *p_father;  \ 
    161101    union asf_object_u *p_first;   \ 
     
    254194} asf_object_stream_properties_t; 
    255195 
    256 typedef struct asf_object_header_extention_s 
     196typedef struct asf_object_header_extension_s 
    257197{ 
    258198    ASF_OBJECT_COMMON 
     
    260200    guid_t      i_reserved1; 
    261201    uint16_t    i_reserved2; 
    262     uint32_t    i_header_extention_size; 
    263     uint8_t     *p_header_extention_data; 
    264  
    265 } asf_object_header_extention_t; 
     202    uint32_t    i_header_extension_size; 
     203    uint8_t     *p_header_extension_data; 
     204 
     205} asf_object_header_extension_t; 
     206 
     207#define ASF_METADATA_TYPE_STRING 0x0000 
     208#define ASF_METADATA_TYPE_BYTE   0x0001 
     209#define ASF_METADATA_TYPE_BOOL   0x0002 
     210#define ASF_METADATA_TYPE_DWORD  0x0003 
     211#define ASF_METADATA_TYPE_QWORD  0x0004 
     212#define ASF_METADATA_TYPE_WORD   0x0005 
     213 
     214typedef struct asf_metadata_record_s 
     215
     216    uint16_t    i_stream; 
     217    uint16_t    i_type; 
     218    char        *psz_name; 
     219 
     220    int64_t i_val; 
     221    int i_data; 
     222    uint8_t *p_data; 
     223 
     224} asf_metadata_record_t; 
     225 
     226typedef struct asf_object_metadata_s 
     227
     228    ASF_OBJECT_COMMON 
     229 
     230    uint32_t i_record_entries_count; 
     231    asf_metadata_record_t *record; 
     232 
     233} asf_object_metadata_t; 
    266234 
    267235typedef struct asf_objec_content_description_s 
     
    281249    uint16_t i_length; 
    282250    uint16_t *i_char; 
     251 
    283252} string16_t; 
    284253 
     
    340309    /* could be NULL if !b_seekable or not-present */ 
    341310    asf_object_index_t  *p_index; 
     311    asf_object_header_extension_t *p_hdr_ext; 
    342312 
    343313    /* from asf_object_header_t */ 
    344314    asf_object_file_properties_t *p_fp; 
    345      
     315 
     316    /* from asf_object_header_extension_t */ 
     317    asf_object_metadata_t *p_metadata; 
     318 
    346319} asf_object_root_t; 
    347320 
     
    358331    asf_object_file_properties_t    file_properties; 
    359332    asf_object_stream_properties_t  stream_properties; 
    360     asf_object_header_extention_t   header_extention; 
     333    asf_object_header_extension_t   header_extension; 
     334    asf_object_metadata_t           metadata; 
    361335    asf_object_codec_list_t         codec_list; 
    362336    asf_object_marker_t             marker; 
     
    365339 
    366340 
    367  
    368 void ASF_GetGUID         ( guid_t *p_guid, uint8_t *p_data ); 
    369 int  ASF_CmpGUID         ( const guid_t *p_guid1, const guid_t *p_guid2 ); 
     341void ASF_GetGUID( guid_t *p_guid, uint8_t *p_data ); 
     342int  ASF_CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 ); 
    370343 
    371344asf_object_root_t *ASF_ReadObjectRoot( stream_t *, int b_seekable ); 
    372 void               ASF_FreeObjectRoot  ( stream_t *, asf_object_root_t *p_root ); 
     345void               ASF_FreeObjectRoot( stream_t *, asf_object_root_t *p_root ); 
    373346 
    374347#define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b ) 
    375 int  __ASF_CountObject   ( asf_object_t *p_obj, const guid_t *p_guid ); 
     348int  __ASF_CountObject ( asf_object_t *p_obj, const guid_t *p_guid ); 
    376349 
    377350#define ASF_FindObject( a, b, c )  __ASF_FindObject( (asf_object_t*)(a), b, c ) 
    378 void *__ASF_FindObject   ( asf_object_t *p_obj, const guid_t *p_guid, int i_number ); 
    379  
     351void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number );