⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libasf.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
    asf_object_language_list_t *p_ll =        (asf_object_language_list_t *)p_obj;    int i;    for( i = 0; i < p_ll->i_language; i++ )        FREE( p_ll->ppsz_language[i] );    FREE( p_ll->ppsz_language );}/* Stream bitrate properties */static int ASF_ReadObject_stream_bitrate_properties( stream_t *s,                                                     asf_object_t *p_obj){    asf_object_stream_bitrate_properties_t *p_sb =        (asf_object_stream_bitrate_properties_t *)p_obj;    uint8_t *p_peek, *p_data;    int i_peek;    int i;    if( ( i_peek = stream_Peek( s, &p_peek, p_sb->i_object_size ) ) < 26 )       return VLC_EGENERIC;    p_data = &p_peek[24];    p_sb->i_bitrate = GetWLE( &p_data[0] ); p_data += 2;    if( p_sb->i_bitrate > 127 ) p_sb->i_bitrate = 127;  /* Buggy ? */    for( i = 0; i < p_sb->i_bitrate; i++ )    {        p_sb->bitrate[i].i_stream_number = GetWLE( &p_data[0] )& 0x7f;        p_sb->bitrate[i].i_avg_bitrate = GetDWLE( &p_data[2] );        p_data += 2+4;    }#ifdef ASF_DEBUG    msg_Dbg( s,"read \"stream bitrate properties object\"" );    for( i = 0; i < p_sb->i_bitrate; i++ )    {        msg_Dbg( s,"  - stream=%d bitrate=%d",                 p_sb->bitrate[i].i_stream_number,                 p_sb->bitrate[i].i_avg_bitrate );     }#endif    return VLC_SUCCESS;}static void ASF_FreeObject_stream_bitrate_properties( asf_object_t *p_obj){}static int ASF_ReadObject_extended_stream_properties( stream_t *s,                                                      asf_object_t *p_obj){    asf_object_extended_stream_properties_t *p_esp =        (asf_object_extended_stream_properties_t*)p_obj;    uint8_t *p_peek, *p_data;    int i_peek, i;    if( ( i_peek = stream_Peek( s, &p_peek, p_esp->i_object_size ) ) < 88 )       return VLC_EGENERIC;    p_data = &p_peek[24];    p_esp->i_start_time = GetQWLE( &p_data[0] );    p_esp->i_end_time = GetQWLE( &p_data[8] );    p_esp->i_data_bitrate = GetDWLE( &p_data[16] );    p_esp->i_buffer_size = GetDWLE( &p_data[20] );    p_esp->i_initial_buffer_fullness = GetDWLE( &p_data[24] );    p_esp->i_alternate_data_bitrate = GetDWLE( &p_data[28] );    p_esp->i_alternate_buffer_size = GetDWLE( &p_data[32] );    p_esp->i_alternate_initial_buffer_fullness = GetDWLE( &p_data[36] );    p_esp->i_maximum_object_size = GetDWLE( &p_data[40] );    p_esp->i_flags = GetDWLE( &p_data[44] );    p_esp->i_stream_number = GetWLE( &p_data[48] );    p_esp->i_language_index = GetWLE( &p_data[50] );    p_esp->i_average_time_per_frame= GetQWLE( &p_data[52] );    p_esp->i_stream_name_count = GetWLE( &p_data[60] );    p_esp->i_payload_extension_system_count = GetWLE( &p_data[62] );    p_data += 64;    p_esp->pi_stream_name_language = calloc( sizeof(int),                                             p_esp->i_stream_name_count );    p_esp->ppsz_stream_name = calloc( sizeof(char*),                                      p_esp->i_stream_name_count );    for( i = 0; i < p_esp->i_stream_name_count; i++ )    {        int i_size;        char *psz;        int i_len;        p_esp->pi_stream_name_language[i] = GetWLE( &p_data[0] );        i_size = GetWLE( &p_data[2] );        p_data += 2;         psz = calloc( i_size/2 + 1, sizeof( char ) );        for( i_len = 0; i_len < i_size/2; i_len++ )        {            psz[i_len] = GetWLE( p_data + 2*i_len );        }        psz[i_size/2] = '\0'; \        p_data += i_size;        p_esp->ppsz_stream_name[i] = psz;    }    for( i = 0; i < p_esp->i_payload_extension_system_count; i++ )    {        /* Skip them */        int i_size = GetDWLE( &p_data[16 + 2] );        p_data += 16+2+4+i_size;    }    p_esp->p_sp = NULL;    if( p_data < &p_peek[i_peek] )    {        asf_object_t *p_sp;        /* Cannot fail as peek succeed */        stream_Read( s, NULL, p_data - p_peek );                p_sp = malloc( sizeof( asf_object_t ) );        if( ASF_ReadObject( s, p_sp, NULL ) )        {            free( p_sp );        }        else        {            /* This p_sp will be inserted by ReadRoot later */            p_esp->p_sp = (asf_object_stream_properties_t*)p_sp;        }    }#ifdef ASF_DEBUG    msg_Dbg( s, "read \"extended stream properties object\":" );    msg_Dbg( s, "  - start="I64Fd" end="I64Fd,             p_esp->i_start_time, p_esp->i_end_time );    msg_Dbg( s, "  - data bitrate=%d buffer=%d initial fullness=%d",             p_esp->i_data_bitrate,             p_esp->i_buffer_size,             p_esp->i_initial_buffer_fullness );    msg_Dbg( s, "  - alternate data bitrate=%d buffer=%d initial fullness=%d",             p_esp->i_alternate_data_bitrate,             p_esp->i_alternate_buffer_size,             p_esp->i_alternate_initial_buffer_fullness );    msg_Dbg( s, "  - maximum object size=%d", p_esp->i_maximum_object_size );    msg_Dbg( s, "  - flags=0x%x", p_esp->i_flags );    msg_Dbg( s, "  - stream number=%d language=%d",             p_esp->i_stream_number, p_esp->i_language_index );    msg_Dbg( s, "  - average time per frame="I64Fd,             p_esp->i_average_time_per_frame );    msg_Dbg( s, "  - stream name count=%d", p_esp->i_stream_name_count );    for( i = 0; i < p_esp->i_stream_name_count; i++ )        msg_Dbg( s, "     - lang id=%d name=%s",                 p_esp->pi_stream_name_language[i],                 p_esp->ppsz_stream_name[i] );    msg_Dbg( s, "  - payload extension system count=%d",             p_esp->i_payload_extension_system_count );#endif    return VLC_SUCCESS;}static void ASF_FreeObject_extended_stream_properties( asf_object_t *p_obj){    asf_object_extended_stream_properties_t *p_esp =        (asf_object_extended_stream_properties_t *)p_obj;    int i;    for( i = 0; i < p_esp->i_stream_name_count; i++ )        FREE( p_esp->ppsz_stream_name[i] );    FREE( p_esp->pi_stream_name_language );    FREE( p_esp->ppsz_stream_name );}static int ASF_ReadObject_advanced_mutual_exclusion( stream_t *s,                                                     asf_object_t *p_obj){    asf_object_advanced_mutual_exclusion_t *p_ae =        (asf_object_advanced_mutual_exclusion_t *)p_obj;    uint8_t *p_peek, *p_data;    int i_peek;    int i;    if( ( i_peek = stream_Peek( s, &p_peek, p_ae->i_object_size ) ) < 42 )       return VLC_EGENERIC;    p_data = &p_peek[24];    ASF_GetGUID( &p_ae->type, &p_data[0] );    p_ae->i_stream_number_count = GetWLE( &p_data[16] );    p_data += 16 + 2;    p_ae->pi_stream_number = calloc( sizeof(int),                                     p_ae->i_stream_number_count );    for( i = 0; i < p_ae->i_stream_number_count; i++ )    {        p_ae->pi_stream_number[i] = GetWLE( p_data );        p_data += 2;    }        #ifdef ASF_DEBUG    msg_Dbg( s, "read \"advanced mutual exclusion object\"" );    for( i = 0; i < p_ae->i_stream_number_count; i++ )        msg_Dbg( s, "  - stream=%d", p_ae->pi_stream_number[i] );#endif    return VLC_SUCCESS;}static void ASF_FreeObject_advanced_mutual_exclusion( asf_object_t *p_obj){    asf_object_advanced_mutual_exclusion_t *p_ae =        (asf_object_advanced_mutual_exclusion_t *)p_obj;    FREE( p_ae->pi_stream_number );}static int ASF_ReadObject_stream_prioritization( stream_t *s,                                                 asf_object_t *p_obj){    asf_object_stream_prioritization_t *p_sp =        (asf_object_stream_prioritization_t *)p_obj;    uint8_t *p_peek, *p_data;    int i_peek;    int i;    if( ( i_peek = stream_Peek( s, &p_peek, p_sp->i_object_size ) ) < 26 )       return VLC_EGENERIC;    p_data = &p_peek[24];    p_sp->i_priority_count = GetWLE( &p_data[0] );    p_data += 2;    p_sp->pi_priority_flag = calloc( sizeof(int), p_sp->i_priority_count );    p_sp->pi_priority_stream_number =                             calloc( sizeof(int), p_sp->i_priority_count );    for( i = 0; i < p_sp->i_priority_count; i++ )    {        p_sp->pi_priority_stream_number[i] = GetWLE( p_data ); p_data += 2;        p_sp->pi_priority_flag[i] = GetWLE( p_data ); p_data += 2;    }#ifdef ASF_DEBUG    msg_Dbg( s, "read \"stream prioritization object\"" );    for( i = 0; i < p_sp->i_priority_count; i++ )        msg_Dbg( s, "  - Stream:%d flags=0x%x",                 p_sp->pi_priority_stream_number[i],                 p_sp->pi_priority_flag[i] );#endif    return VLC_SUCCESS;}static void ASF_FreeObject_stream_prioritization( asf_object_t *p_obj){    asf_object_stream_prioritization_t *p_sp =        (asf_object_stream_prioritization_t *)p_obj;    FREE( p_sp->pi_priority_stream_number );    FREE( p_sp->pi_priority_flag );}static int ASF_ReadObject_extended_content_description( stream_t *s,                                                        asf_object_t *p_obj){    asf_object_extended_content_description_t *p_ec =        (asf_object_extended_content_description_t *)p_obj;    uint8_t *p_peek, *p_data;    int i_peek;    int i;    if( ( i_peek = stream_Peek( s, &p_peek, p_ec->i_object_size ) ) < 26 )       return VLC_EGENERIC;    p_data = &p_peek[24];    p_ec->i_count = GetWLE( p_data ); p_data += 2;    p_ec->ppsz_name = calloc( sizeof(char*), p_ec->i_count );    p_ec->ppsz_value = calloc( sizeof(char*), p_ec->i_count );    for( i = 0; i < p_ec->i_count; i++ )    {        int i_size;        int i_type;        int i_len;#define GETSTRINGW( psz_str, i_size ) \       psz_str = calloc( i_size/2 + 1, sizeof( char ) ); \       for( i_len = 0; i_len < i_size/2; i_len++ ) \       { \           psz_str[i_len] = GetWLE( p_data + 2*i_len ); \       } \       psz_str[i_size/2] = '\0';        i_size = GetWLE( p_data ); p_data += 2;        GETSTRINGW( p_ec->ppsz_name[i], i_size );        p_data += i_size;        /* Grrr */        i_type = GetWLE( p_data ); p_data += 2;        i_size = GetWLE( p_data ); p_data += 2;        if( i_type == 0 )        {            GETSTRINGW( p_ec->ppsz_value[i], i_size );        }        else if( i_type == 1 )        {            int j;            /* Byte array */            p_ec->ppsz_value[i] = malloc( 2*i_size + 1 );            for( j = 0; j < i_size; j++ )            {                static const char hex[16] = "0123456789ABCDEF";                p_ec->ppsz_value[i][2*j+0] = hex[p_data[0]>>4];                p_ec->ppsz_value[i][2*j+1] = hex[p_data[0]&0xf];            }            p_ec->ppsz_value[i][2*i_size] = '\0';        }        else if( i_type == 2 )        {            /* Bool */            p_ec->ppsz_value[i] = strdup( *p_data ? "true" : "false" );        }        else if( i_type == 3 )        {            /* DWord */            asprintf( &p_ec->ppsz_value[i], "%d", GetDWLE(p_data));        }        else if( i_type == 4 )        {            /* QWord */            asprintf( &p_ec->ppsz_value[i], I64Fd, GetQWLE(p_data));        }        else if( i_type == 5 )        {            /* Word */            asprintf( &p_ec->ppsz_value[i], "%d", GetWLE(p_data));        }        else            p_ec->ppsz_value[i] = NULL;        p_data += i_size;        #undef GETSTRINGW    }#ifdef ASF_DEBUG    msg_Dbg( s, "read \"extended content description object\"" );    for( i = 0; i < p_ec->i_count; i++ )        msg_Dbg( s, "  - '%s' = '%s'",                 p_ec->ppsz_name[i],                 p_ec->ppsz_value[i] );#endif    return VLC_SUCCESS;}static void ASF_FreeObject_extended_content_description( asf_object_t *p_obj){    asf_object_extended_content_description_t *p_ec =        (asf_object_extended_content_description_t *)p_obj;    int i;    for( i = 0; i < p_ec->i_count; i++ )    {        FREE( p_ec->ppsz_name[i] );        FREE( p_ec->ppsz_value[i] );    }    FREE( p_ec->ppsz_name );    FREE( p_ec->ppsz_value );}#if 0static int ASF_ReadObject_XXX(stream_t *s, asf_object_t *p_obj){    asf_object_XXX_t *p_XX =        (asf_object_XXX_t *)p_obj;    uint8_t *p_peek, *p_data;    int i_peek;    if( ( i_peek = stream_Peek( s, &p_peek, p_XX->i_object_size ) ) < XXX )       return VLC_EGENERIC;    p_data = &p_peek[24];#ifdef ASF_DEBUG    msg_Dbg( s,             "Read \"XXX object\"" );#endif    return VLC_SUCCESS;}static void ASF_FreeObject_XXX( asf_object_t *p_obj){    asf_object_XXX_t *p_XX =        (asf_object_XXX_t *)p_obj;}#endif/* */static struct{    const guid_t  *p_id;    int     i_type;    int     (*ASF_ReadObject_function)( stream_t *, asf_object_t *p_obj );    void    (*ASF_FreeObject_function)( asf_object_t *p_obj );} ASF_Object_Function [] =

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -