📄 libasf.c
字号:
}#ifdef ASF_DEBUG msg_Dbg( s, "read \"metadata object\" %d entries", p_meta->i_record_entries_count ); for( i = 0; i < p_meta->i_record_entries_count; i++ ) { asf_metadata_record_t *p_rec = &p_meta->record[i]; if( p_rec->i_type == ASF_METADATA_TYPE_STRING ) msg_Dbg( s, " - %s=%s", p_rec->psz_name, p_rec->p_data ); else if( p_rec->i_type == ASF_METADATA_TYPE_BYTE ) msg_Dbg( s, " - %s (%i bytes)", p_rec->psz_name, p_rec->i_data ); else msg_Dbg( s, " - %s="I64Fd, p_rec->psz_name, p_rec->i_val ); }#endif return VLC_SUCCESS;}static int ASF_ReadObject_header_extension( stream_t *s, asf_object_t *p_obj ){ asf_object_header_extension_t *p_he = (asf_object_header_extension_t *)p_obj; int i_peek; uint8_t *p_peek; if( ( i_peek = stream_Peek( s, &p_peek, p_he->i_object_size ) ) < 46) { return VLC_EGENERIC; } ASF_GetGUID( &p_he->i_reserved1, p_peek + 24 ); p_he->i_reserved2 = GetWLE( p_peek + 40 ); p_he->i_header_extension_size = GetDWLE( p_peek + 42 ); if( p_he->i_header_extension_size ) { p_he->p_header_extension_data = malloc( p_he->i_header_extension_size ); memcpy( p_he->p_header_extension_data, p_peek + 46, p_he->i_header_extension_size ); } else { p_he->p_header_extension_data = NULL; }#ifdef ASF_DEBUG msg_Dbg( s, "read \"header extension object\" reserved1:" GUID_FMT " reserved2:%d header_extension_size:%d", GUID_PRINT( p_he->i_reserved1 ), p_he->i_reserved2, p_he->i_header_extension_size );#endif if( !p_he->i_header_extension_size ) return VLC_SUCCESS; /* Read the extension objects */ stream_Read( s, NULL, 46 ); for( ; ; ) { asf_object_t *p_obj = malloc( sizeof( asf_object_t ) ); if( ASF_ReadObject( s, p_obj, (asf_object_t*)p_he ) ) { free( p_obj ); break; } if( ASF_NextObject( s, p_obj ) ) /* Go to the next object */ { break; } } return VLC_SUCCESS;}static void ASF_FreeObject_header_extension( asf_object_t *p_obj ){ asf_object_header_extension_t *p_he = (asf_object_header_extension_t *)p_obj; FREE( p_he->p_header_extension_data );}static int ASF_ReadObject_stream_properties( stream_t *s, asf_object_t *p_obj ){ asf_object_stream_properties_t *p_sp = (asf_object_stream_properties_t*)p_obj; int i_peek; uint8_t *p_peek; if( ( i_peek = stream_Peek( s, &p_peek, p_sp->i_object_size ) ) < 74 ) { return VLC_EGENERIC; } ASF_GetGUID( &p_sp->i_stream_type, p_peek + 24 ); ASF_GetGUID( &p_sp->i_error_correction_type, p_peek + 40 ); p_sp->i_time_offset = GetQWLE( p_peek + 56 ); p_sp->i_type_specific_data_length = GetDWLE( p_peek + 64 ); p_sp->i_error_correction_data_length = GetDWLE( p_peek + 68 ); p_sp->i_flags = GetWLE( p_peek + 72 ); p_sp->i_stream_number = p_sp->i_flags&0x07f; p_sp->i_reserved = GetDWLE( p_peek + 74 ); if( p_sp->i_type_specific_data_length ) { p_sp->p_type_specific_data = malloc( p_sp->i_type_specific_data_length ); memcpy( p_sp->p_type_specific_data, p_peek + 78, p_sp->i_type_specific_data_length ); } else { p_sp->p_type_specific_data = NULL; } if( p_sp->i_error_correction_data_length ) { p_sp->p_error_correction_data = malloc( p_sp->i_error_correction_data_length ); memcpy( p_sp->p_error_correction_data, p_peek + 78 + p_sp->i_type_specific_data_length, p_sp->i_error_correction_data_length ); } else { p_sp->p_error_correction_data = NULL; }#ifdef ASF_DEBUG msg_Dbg( s, "read \"stream Properties object\" stream_type:" GUID_FMT " error_correction_type:" GUID_FMT " time_offset:"I64Fd " type_specific_data_length:%d error_correction_data_length:%d" " flags:0x%x stream_number:%d", GUID_PRINT( p_sp->i_stream_type ), GUID_PRINT( p_sp->i_error_correction_type ), p_sp->i_time_offset, p_sp->i_type_specific_data_length, p_sp->i_error_correction_data_length, p_sp->i_flags, p_sp->i_stream_number );#endif return VLC_SUCCESS;}static void ASF_FreeObject_stream_properties( asf_object_t *p_obj ){ asf_object_stream_properties_t *p_sp = (asf_object_stream_properties_t*)p_obj; FREE( p_sp->p_type_specific_data ); FREE( p_sp->p_error_correction_data );}static int ASF_ReadObject_codec_list( stream_t *s, asf_object_t *p_obj ){ asf_object_codec_list_t *p_cl = (asf_object_codec_list_t*)p_obj; int i_peek; uint8_t *p_peek, *p_data; unsigned int i_codec; if( ( i_peek = stream_Peek( s, &p_peek, p_cl->i_object_size ) ) < 44 ) { return VLC_EGENERIC; } ASF_GetGUID( &p_cl->i_reserved, p_peek + 24 ); p_cl->i_codec_entries_count = GetWLE( p_peek + 40 ); if( p_cl->i_codec_entries_count > 0 ) { p_cl->codec = calloc( p_cl->i_codec_entries_count, sizeof( asf_codec_entry_t ) ); memset( p_cl->codec, 0, p_cl->i_codec_entries_count * sizeof( asf_codec_entry_t ) ); p_data = p_peek + 44; for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ ) {#define codec p_cl->codec[i_codec] int i_len, i; codec.i_type = GetWLE( p_data ); p_data += 2; /* codec name */ i_len = GetWLE( p_data ); p_data += 2; codec.psz_name = calloc( sizeof( char ), i_len + 1); for( i = 0; i < i_len; i++ ) { codec.psz_name[i] = GetWLE( p_data + 2*i ); } codec.psz_name[i_len] = '\0'; p_data += 2 * i_len; /* description */ i_len = GetWLE( p_data ); p_data += 2; codec.psz_description = calloc( sizeof( char ), i_len + 1); for( i = 0; i < i_len; i++ ) { codec.psz_description[i] = GetWLE( p_data + 2*i ); } codec.psz_description[i_len] = '\0'; p_data += 2 * i_len; /* opaque information */ codec.i_information_length = GetWLE( p_data ); p_data += 2; if( codec.i_information_length > 0 ) { codec.p_information = malloc( codec.i_information_length ); memcpy( codec.p_information, p_data, codec.i_information_length ); p_data += codec.i_information_length; } else { codec.p_information = NULL; }#undef codec } } else { p_cl->codec = NULL; }#ifdef ASF_DEBUG msg_Dbg( s, "read \"codec list object\" reserved_guid:" GUID_FMT " codec_entries_count:%d", GUID_PRINT( p_cl->i_reserved ), p_cl->i_codec_entries_count ); for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ ) {#define codec p_cl->codec[i_codec] msg_Dbg( s, " - codec[%d] %s name:\"%s\" " "description:\"%s\" information_length:%d", i_codec, ( codec.i_type == ASF_CODEC_TYPE_VIDEO ) ? "video" : ( ( codec.i_type == ASF_CODEC_TYPE_AUDIO ) ? "audio" : "unknown" ), codec.psz_name, codec.psz_description, codec.i_information_length );#undef codec }#endif return VLC_SUCCESS;}static void ASF_FreeObject_codec_list( asf_object_t *p_obj ){ asf_object_codec_list_t *p_cl = (asf_object_codec_list_t*)p_obj; unsigned int i_codec; for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ ) {#define codec p_cl->codec[i_codec] FREE( codec.psz_name ); FREE( codec.psz_description ); FREE( codec.p_information );#undef codec } FREE( p_cl->codec );}/* Microsoft should go to hell. This time the length give number of bytes * and for the some others object, length give char16 count ... */static int ASF_ReadObject_content_description(stream_t *s, asf_object_t *p_obj){ asf_object_content_description_t *p_cd = (asf_object_content_description_t *)p_obj; uint8_t *p_peek, *p_data; int i_peek; int i_len, i_title, i_author, i_copyright, i_description, i_rating;#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'; \ p_data += i_size; if( ( i_peek = stream_Peek( s, &p_peek, p_cd->i_object_size ) ) < 34 ) { return VLC_EGENERIC; } p_data = p_peek + 24; i_title = GetWLE( p_data ); p_data += 2; i_author= GetWLE( p_data ); p_data += 2; i_copyright = GetWLE( p_data ); p_data += 2; i_description = GetWLE( p_data ); p_data += 2; i_rating = GetWLE( p_data ); p_data += 2; GETSTRINGW( p_cd->psz_title, i_title ); GETSTRINGW( p_cd->psz_author, i_author ); GETSTRINGW( p_cd->psz_copyright, i_copyright ); GETSTRINGW( p_cd->psz_description, i_description ); GETSTRINGW( p_cd->psz_rating, i_rating );#undef GETSTRINGW#ifdef ASF_DEBUG msg_Dbg( s, "Read \"content description object\" title:\"%s\" author:\"%s\" copyright:\"%s\" description:\"%s\" rating:\"%s\"", p_cd->psz_title, p_cd->psz_author, p_cd->psz_copyright, p_cd->psz_description, p_cd->psz_rating );#endif return VLC_SUCCESS;}static void ASF_FreeObject_content_description( asf_object_t *p_obj){ asf_object_content_description_t *p_cd = (asf_object_content_description_t *)p_obj; FREE( p_cd->psz_title ); FREE( p_cd->psz_author ); FREE( p_cd->psz_copyright ); FREE( p_cd->psz_description ); FREE( p_cd->psz_rating );}/* Language list: */static int ASF_ReadObject_language_list(stream_t *s, asf_object_t *p_obj){ asf_object_language_list_t *p_ll = (asf_object_language_list_t*)p_obj; uint8_t *p_peek, *p_data; int i_peek; int i; if( ( i_peek = stream_Peek( s, &p_peek, p_ll->i_object_size ) ) < 26 ) return VLC_EGENERIC; p_data = &p_peek[24]; p_ll->i_language = GetWLE( &p_data[0] ); p_data += 2; if( p_ll->i_language > 0 ) { p_ll->ppsz_language = calloc( p_ll->i_language, sizeof( char *) ); for( i = 0; i < p_ll->i_language; i++ ) { char *psz; int i_size = *p_data++; int i_len; 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_ll->ppsz_language[i] = psz; } }#ifdef ASF_DEBUG msg_Dbg( s, "Read \"language list object\" %d entries", p_ll->i_language ); for( i = 0; i < p_ll->i_language; i++ ) msg_Dbg( s, " - '%s'", p_ll->ppsz_language[i] );#endif return VLC_SUCCESS;}static void ASF_FreeObject_language_list( asf_object_t *p_obj){ 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -