1 /*****************************************************************************
2 * libasf.c : asf stream demux module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001-2003 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #include <stdlib.h> /* malloc(), free() */
28 #include <vlc/input.h>
30 #include "codecs.h" /* BITMAPINFOHEADER, WAVEFORMATEX */
36 if( p ) {free( p ); p = NULL; }
38 #define GUID_FMT "0x%x-0x%x-0x%x-0x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x"
39 #define GUID_PRINT( guid ) \
43 (guid).v4[0],(guid).v4[1],(guid).v4[2],(guid).v4[3], \
44 (guid).v4[4],(guid).v4[5],(guid).v4[6],(guid).v4[7]
46 /****************************************************************************
48 ****************************************************************************/
49 static int ASF_ReadObject( stream_t *, asf_object_t *, asf_object_t * );
51 /****************************************************************************
53 ****************************************************************************/
54 void ASF_GetGUID( guid_t *p_guid, uint8_t *p_data )
56 p_guid->v1 = GetDWLE( p_data );
57 p_guid->v2 = GetWLE( p_data + 4);
58 p_guid->v3 = GetWLE( p_data + 6);
59 memcpy( p_guid->v4, p_data + 8, 8 );
62 int ASF_CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 )
64 if( (p_guid1->v1 != p_guid2->v1 )||
65 (p_guid1->v2 != p_guid2->v2 )||
66 (p_guid1->v3 != p_guid2->v3 )||
67 ( memcmp( p_guid1->v4, p_guid2->v4,8 )) )
71 return( 1 ); /* match */
74 /****************************************************************************
76 ****************************************************************************/
77 static int ASF_ReadObjectCommon( stream_t *s, asf_object_t *p_obj )
79 asf_object_common_t *p_common = (asf_object_common_t*)p_obj;
82 if( stream_Peek( s, &p_peek, 24 ) < 24 )
84 return( VLC_EGENERIC );
86 ASF_GetGUID( &p_common->i_object_id, p_peek );
87 p_common->i_object_size = GetQWLE( p_peek + 16 );
88 p_common->i_object_pos = stream_Tell( s );
89 p_common->p_next = NULL;
93 "found object guid: " GUID_FMT " size:"I64Fd,
94 GUID_PRINT( p_common->i_object_id ),
95 p_common->i_object_size );
98 return( VLC_SUCCESS );
101 static int ASF_NextObject( stream_t *s, asf_object_t *p_obj )
106 if( ASF_ReadObjectCommon( s, &obj ) )
108 return( VLC_EGENERIC );
113 if( p_obj->common.i_object_size <= 0 )
117 if( p_obj->common.p_father &&
118 p_obj->common.p_father->common.i_object_size != 0 )
120 if( p_obj->common.p_father->common.i_object_pos +
121 p_obj->common.p_father->common.i_object_size <
122 p_obj->common.i_object_pos + p_obj->common.i_object_size + 24 )
123 /* 24 is min size of an object */
130 return stream_Seek( s, p_obj->common.i_object_pos +
131 p_obj->common.i_object_size );
134 static void ASF_FreeObject_Null( asf_object_t *pp_obj )
139 static int ASF_ReadObject_Header( stream_t *s, asf_object_t *p_obj )
141 asf_object_header_t *p_hdr = (asf_object_header_t*)p_obj;
142 asf_object_t *p_subobj;
146 if( ( i_peek = stream_Peek( s, &p_peek, 30 ) ) < 30 )
148 return( VLC_EGENERIC );
151 p_hdr->i_sub_object_count = GetDWLE( p_peek + 24 );
152 p_hdr->i_reserved1 = p_peek[28];
153 p_hdr->i_reserved2 = p_peek[29];
154 p_hdr->p_first = NULL;
155 p_hdr->p_last = NULL;
159 "read \"header object\" subobj:%d, reserved1:%d, reserved2:%d",
160 p_hdr->i_sub_object_count,
162 p_hdr->i_reserved2 );
165 /* Cannot fail as peek succeed */
166 stream_Read( s, NULL, 30 );
168 /* Now load sub object */
171 p_subobj = malloc( sizeof( asf_object_t ) );
173 if( ASF_ReadObject( s, p_subobj, (asf_object_t*)p_hdr ) )
178 if( ASF_NextObject( s, p_subobj ) ) /* Go to the next object */
186 static int ASF_ReadObject_Data( stream_t *s, asf_object_t *p_obj )
188 asf_object_data_t *p_data = (asf_object_data_t*)p_obj;
192 if( ( i_peek = stream_Peek( s, &p_peek, 50 ) ) < 50 )
196 ASF_GetGUID( &p_data->i_file_id, p_peek + 24 );
197 p_data->i_total_data_packets = GetQWLE( p_peek + 40 );
198 p_data->i_reserved = GetWLE( p_peek + 48 );
202 "read \"data object\" file_id:" GUID_FMT " total data packet:"
204 GUID_PRINT( p_data->i_file_id ),
205 p_data->i_total_data_packets,
206 p_data->i_reserved );
212 static int ASF_ReadObject_Index( stream_t *s, asf_object_t *p_obj )
214 asf_object_index_t *p_index = (asf_object_index_t*)p_obj;
218 if( ( i_peek = stream_Peek( s, &p_peek, 56 ) ) < 56 )
222 ASF_GetGUID( &p_index->i_file_id, p_peek + 24 );
223 p_index->i_index_entry_time_interval = GetQWLE( p_peek + 40 );
224 p_index->i_max_packet_count = GetDWLE( p_peek + 48 );
225 p_index->i_index_entry_count = GetDWLE( p_peek + 52 );
226 p_index->index_entry = NULL; /* FIXME */
230 "read \"index object\" file_id:" GUID_FMT
231 " index_entry_time_interval:"I64Fd" max_packet_count:%d "
232 "index_entry_count:%ld",
233 GUID_PRINT( p_index->i_file_id ),
234 p_index->i_index_entry_time_interval,
235 p_index->i_max_packet_count,
236 (long int)p_index->i_index_entry_count );
242 static void ASF_FreeObject_Index( asf_object_t *p_obj )
244 asf_object_index_t *p_index = (asf_object_index_t*)p_obj;
246 FREE( p_index->index_entry );
249 static int ASF_ReadObject_file_properties( stream_t *s, asf_object_t *p_obj )
251 asf_object_file_properties_t *p_fp = (asf_object_file_properties_t*)p_obj;
255 if( ( i_peek = stream_Peek( s, &p_peek, 92) ) < 92 )
259 ASF_GetGUID( &p_fp->i_file_id, p_peek + 24 );
260 p_fp->i_file_size = GetQWLE( p_peek + 40 );
261 p_fp->i_creation_date = GetQWLE( p_peek + 48 );
262 p_fp->i_data_packets_count = GetQWLE( p_peek + 56 );
263 p_fp->i_play_duration = GetQWLE( p_peek + 64 );
264 p_fp->i_send_duration = GetQWLE( p_peek + 72 );
265 p_fp->i_preroll = GetQWLE( p_peek + 80 );
266 p_fp->i_flags = GetDWLE( p_peek + 88 );
267 p_fp->i_min_data_packet_size = GetDWLE( p_peek + 92 );
268 p_fp->i_max_data_packet_size = GetDWLE( p_peek + 96 );
269 p_fp->i_max_bitrate = GetDWLE( p_peek + 100 );
273 "read \"file properties object\" file_id:" GUID_FMT
274 " file_size:"I64Fd" creation_date:"I64Fd" data_packets_count:"
275 I64Fd" play_duration:"I64Fd" send_duration:"I64Fd" preroll:"
276 I64Fd" flags:%d min_data_packet_size:%d max_data_packet_size:%d "
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,
283 p_fp->i_max_bitrate );
289 static void ASF_FreeObject_metadata( asf_object_t *p_obj )
291 asf_object_metadata_t *p_meta =
292 (asf_object_metadata_t *)p_obj;
295 for( i = 0; i < p_meta->i_record_entries_count; i++ )
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 );
300 if( p_meta->record ) free( p_meta->record );
303 static int ASF_ReadObject_metadata( stream_t *s, asf_object_t *p_obj )
305 asf_object_metadata_t *p_meta =
306 (asf_object_metadata_t *)p_obj;
308 int i_peek, i_entries, i;
314 p_meta->i_record_entries_count = 0;
317 if( stream_Peek( s, &p_peek, p_meta->i_object_size ) <
318 (int)p_meta->i_object_size )
324 i_entries = GetWLE( p_peek + i_peek ); i_peek += 2;
325 for( i = 0; i < i_entries && i_peek < (int)p_meta->i_object_size -12; i++ )
327 asf_metadata_record_t record;
328 int i_name, i_data, j;
330 if( GetWLE( p_peek + i_peek ) != 0 )
332 ASF_FreeObject_metadata( p_obj );
337 record.i_stream = GetWLE( p_peek + i_peek ); i_peek += 2;
338 i_name = GetWLE( p_peek + i_peek ); i_peek += 2;
339 record.i_type = GetWLE( p_peek + i_peek ); i_peek += 2;
340 i_data = GetDWLE( p_peek + i_peek ); i_peek += 4;
342 if( record.i_type > ASF_METADATA_TYPE_WORD ||
343 i_peek + i_data + i_name > (int)p_meta->i_object_size )
345 ASF_FreeObject_metadata( p_obj );
354 record.psz_name = malloc( i_name/2 + 1 );
355 for( j = 0; j < i_name/2; j++ )
357 record.psz_name[j] = GetWLE( p_peek + i_peek ); i_peek += 2;
359 record.psz_name[j] = 0; /* just to make sure */
362 if( record.i_type == ASF_METADATA_TYPE_STRING )
364 record.p_data = malloc( i_data/2 + 1 );
365 record.i_data = i_data/2;
366 for( j = 0; j < i_data/2; j++ )
368 record.p_data[j] = GetWLE( p_peek + i_peek ); i_peek += 2;
370 record.p_data[j] = 0; /* just to make sure */
372 else if( record.i_type == ASF_METADATA_TYPE_BYTE )
374 record.p_data = malloc( i_data );
375 record.i_data = i_data;
376 memcpy( record.p_data, p_peek + i_peek, i_data );
381 if( record.i_type == ASF_METADATA_TYPE_QWORD )
383 record.i_val = GetQWLE( p_peek + i_peek ); i_peek += 8;
385 else if( record.i_type == ASF_METADATA_TYPE_DWORD )
387 record.i_val = GetDWLE( p_peek + i_peek ); i_peek += 4;
391 record.i_val = GetWLE( p_peek + i_peek ); i_peek += 2;
395 p_meta->i_record_entries_count++;
397 realloc( p_meta->record, p_meta->i_record_entries_count *
398 sizeof(asf_metadata_record_t) );
399 memcpy( &p_meta->record[p_meta->i_record_entries_count-1],
400 &record, sizeof(asf_metadata_record_t) );
405 "read \"metadata object\" %d entries",
406 p_meta->i_record_entries_count );
407 for( j = 0; j < p_meta->i_record_entries_count; j++ )
409 asf_metadata_record_t *p_rec = &p_meta->record[j];
411 if( p_rec->i_type == ASF_METADATA_TYPE_STRING )
412 msg_Dbg( s, " - %s=%s",
413 p_rec->psz_name, p_rec->p_data );
414 else if( p_rec->i_type == ASF_METADATA_TYPE_BYTE )
415 msg_Dbg( s, " - %s (%i bytes)",
416 p_rec->psz_name, p_rec->i_data );
418 msg_Dbg( s, " - %s="I64Fd,
419 p_rec->psz_name, p_rec->i_val );
426 static int ASF_ReadObject_header_extension( stream_t *s, asf_object_t *p_obj )
428 asf_object_header_extension_t *p_he =
429 (asf_object_header_extension_t *)p_obj;
433 if( ( i_peek = stream_Peek( s, &p_peek, p_he->i_object_size ) ) < 46)
437 ASF_GetGUID( &p_he->i_reserved1, p_peek + 24 );
438 p_he->i_reserved2 = GetWLE( p_peek + 40 );
439 p_he->i_header_extension_size = GetDWLE( p_peek + 42 );
440 if( p_he->i_header_extension_size )
442 p_he->p_header_extension_data =
443 malloc( p_he->i_header_extension_size );
444 memcpy( p_he->p_header_extension_data, p_peek + 46,
445 p_he->i_header_extension_size );
449 p_he->p_header_extension_data = NULL;
454 "read \"header extension object\" reserved1:" GUID_FMT
455 " reserved2:%d header_extension_size:%d",
456 GUID_PRINT( p_he->i_reserved1 ), p_he->i_reserved2,
457 p_he->i_header_extension_size );
460 if( !p_he->i_header_extension_size ) return VLC_SUCCESS;
462 /* Read the extension objects */
463 stream_Read( s, NULL, 46 );
466 asf_object_t *p_obj = malloc( sizeof( asf_object_t ) );
468 if( ASF_ReadObject( s, p_obj, (asf_object_t*)p_he ) )
474 if( ASF_NextObject( s, p_obj ) ) /* Go to the next object */
483 static void ASF_FreeObject_header_extension( asf_object_t *p_obj )
485 asf_object_header_extension_t *p_he =
486 (asf_object_header_extension_t *)p_obj;
488 FREE( p_he->p_header_extension_data );
491 static int ASF_ReadObject_stream_properties( stream_t *s, asf_object_t *p_obj )
493 asf_object_stream_properties_t *p_sp =
494 (asf_object_stream_properties_t*)p_obj;
498 if( ( i_peek = stream_Peek( s, &p_peek, p_sp->i_object_size ) ) < 74 )
502 ASF_GetGUID( &p_sp->i_stream_type, p_peek + 24 );
503 ASF_GetGUID( &p_sp->i_error_correction_type, p_peek + 40 );
504 p_sp->i_time_offset = GetQWLE( p_peek + 56 );
505 p_sp->i_type_specific_data_length = GetDWLE( p_peek + 64 );
506 p_sp->i_error_correction_data_length = GetDWLE( p_peek + 68 );
507 p_sp->i_flags = GetWLE( p_peek + 72 );
508 p_sp->i_stream_number = p_sp->i_flags&0x07f;
509 p_sp->i_reserved = GetDWLE( p_peek + 74 );
510 if( p_sp->i_type_specific_data_length )
512 p_sp->p_type_specific_data =
513 malloc( p_sp->i_type_specific_data_length );
514 memcpy( p_sp->p_type_specific_data, p_peek + 78,
515 p_sp->i_type_specific_data_length );
519 p_sp->p_type_specific_data = NULL;
521 if( p_sp->i_error_correction_data_length )
523 p_sp->p_error_correction_data =
524 malloc( p_sp->i_error_correction_data_length );
525 memcpy( p_sp->p_error_correction_data,
526 p_peek + 78 + p_sp->i_type_specific_data_length,
527 p_sp->i_error_correction_data_length );
531 p_sp->p_error_correction_data = NULL;
536 "read \"stream Properties object\" stream_type:" GUID_FMT
537 " error_correction_type:" GUID_FMT " time_offset:"I64Fd
538 " type_specific_data_length:%d error_correction_data_length:%d"
539 " flags:0x%x stream_number:%d",
540 GUID_PRINT( p_sp->i_stream_type ),
541 GUID_PRINT( p_sp->i_error_correction_type ),
543 p_sp->i_type_specific_data_length,
544 p_sp->i_error_correction_data_length,
546 p_sp->i_stream_number );
552 static void ASF_FreeObject_stream_properties( asf_object_t *p_obj )
554 asf_object_stream_properties_t *p_sp =
555 (asf_object_stream_properties_t*)p_obj;
557 FREE( p_sp->p_type_specific_data );
558 FREE( p_sp->p_error_correction_data );
562 static int ASF_ReadObject_codec_list( stream_t *s, asf_object_t *p_obj )
564 asf_object_codec_list_t *p_cl = (asf_object_codec_list_t*)p_obj;
566 uint8_t *p_peek, *p_data;
568 unsigned int i_codec;
570 if( ( i_peek = stream_Peek( s, &p_peek, p_cl->i_object_size ) ) < 44 )
575 ASF_GetGUID( &p_cl->i_reserved, p_peek + 24 );
576 p_cl->i_codec_entries_count = GetWLE( p_peek + 40 );
577 if( p_cl->i_codec_entries_count > 0 )
579 p_cl->codec = calloc( p_cl->i_codec_entries_count,
580 sizeof( asf_codec_entry_t ) );
581 memset( p_cl->codec, 0,
582 p_cl->i_codec_entries_count * sizeof( asf_codec_entry_t ) );
584 p_data = p_peek + 44;
585 for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ )
587 #define codec p_cl->codec[i_codec]
590 codec.i_type = GetWLE( p_data ); p_data += 2;
592 i_len = GetWLE( p_data ); p_data += 2;
593 codec.psz_name = calloc( sizeof( char ), i_len + 1);
594 for( i = 0; i < i_len; i++ )
596 codec.psz_name[i] = GetWLE( p_data + 2*i );
598 codec.psz_name[i_len] = '\0';
602 i_len = GetWLE( p_data ); p_data += 2;
603 codec.psz_description = calloc( sizeof( char ), i_len + 1);
604 for( i = 0; i < i_len; i++ )
606 codec.psz_description[i] = GetWLE( p_data + 2*i );
608 codec.psz_description[i_len] = '\0';
611 /* opaque information */
612 codec.i_information_length = GetWLE( p_data ); p_data += 2;
613 if( codec.i_information_length > 0 )
615 codec.p_information = malloc( codec.i_information_length );
616 memcpy( codec.p_information, p_data, codec.i_information_length );
617 p_data += codec.i_information_length;
621 codec.p_information = NULL;
632 msg_Dbg( s, "read \"codec list object\" reserved_guid:" GUID_FMT
633 " codec_entries_count:%d",
634 GUID_PRINT( p_cl->i_reserved ), p_cl->i_codec_entries_count );
636 for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ )
638 #define codec p_cl->codec[i_codec]
639 msg_Dbg( s, " - codec[%d] %s name:\"%s\" "
640 "description:\"%s\" information_length:%d",
641 i_codec, ( codec.i_type == ASF_CODEC_TYPE_VIDEO ) ?
642 "video" : ( ( codec.i_type == ASF_CODEC_TYPE_AUDIO ) ?
643 "audio" : "unknown" ),
644 codec.psz_name, codec.psz_description,
645 codec.i_information_length );
653 static void ASF_FreeObject_codec_list( asf_object_t *p_obj )
655 asf_object_codec_list_t *p_cl = (asf_object_codec_list_t*)p_obj;
656 unsigned int i_codec;
658 for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ )
660 #define codec p_cl->codec[i_codec]
661 FREE( codec.psz_name );
662 FREE( codec.psz_description );
663 FREE( codec.p_information );
669 /* Microsoft should go to hell. This time the length give number of bytes
670 * and for the some others object, length give char16 count ... */
671 static int ASF_ReadObject_content_description(stream_t *s, asf_object_t *p_obj)
673 asf_object_content_description_t *p_cd =
674 (asf_object_content_description_t *)p_obj;
675 uint8_t *p_peek, *p_data;
676 int i_peek, i_title, i_author, i_copyright, i_description, i_rating;
677 vlc_iconv_t cd = (vlc_iconv_t)-1;
680 size_t i_ibl, i_obl, i_len;
682 cd = vlc_iconv_open("UTF-8", "UTF-16LE");
683 if ( cd == (vlc_iconv_t)-1 ) {
684 msg_Err( s, "vlc_iconv_open failed" );
688 /* FIXME i_size*3 is the worst case. */
689 #define GETSTRINGW( psz_str, i_size ) \
690 psz_str = (char *)calloc( i_size*3+1, sizeof( char ) ); \
691 ib = (char *)p_data; \
695 i_len = vlc_iconv(cd, &ib, &i_ibl, &ob, &i_obl); \
698 if( ( i_peek = stream_Peek( s, &p_peek, p_cd->i_object_size ) ) < 34 )
702 p_data = p_peek + 24;
704 i_title = GetWLE( p_data ); p_data += 2;
705 i_author= GetWLE( p_data ); p_data += 2;
706 i_copyright = GetWLE( p_data ); p_data += 2;
707 i_description = GetWLE( p_data ); p_data += 2;
708 i_rating = GetWLE( p_data ); p_data += 2;
710 GETSTRINGW( p_cd->psz_title, i_title );
711 GETSTRINGW( p_cd->psz_author, i_author );
712 GETSTRINGW( p_cd->psz_copyright, i_copyright );
713 GETSTRINGW( p_cd->psz_description, i_description );
714 GETSTRINGW( p_cd->psz_rating, i_rating );
720 "Read \"content description object\" title:\"%s\" author:\"%s\" copyright:\"%s\" description:\"%s\" rating:\"%s\"",
724 p_cd->psz_description,
732 static void ASF_FreeObject_content_description( asf_object_t *p_obj)
734 asf_object_content_description_t *p_cd =
735 (asf_object_content_description_t *)p_obj;
737 FREE( p_cd->psz_title );
738 FREE( p_cd->psz_author );
739 FREE( p_cd->psz_copyright );
740 FREE( p_cd->psz_description );
741 FREE( p_cd->psz_rating );
745 static int ASF_ReadObject_language_list(stream_t *s, asf_object_t *p_obj)
747 asf_object_language_list_t *p_ll =
748 (asf_object_language_list_t*)p_obj;
749 uint8_t *p_peek, *p_data;
753 if( ( i_peek = stream_Peek( s, &p_peek, p_ll->i_object_size ) ) < 26 )
756 p_data = &p_peek[24];
758 p_ll->i_language = GetWLE( &p_data[0] ); p_data += 2;
759 if( p_ll->i_language > 0 )
761 p_ll->ppsz_language = calloc( p_ll->i_language, sizeof( char *) );
763 for( i = 0; i < p_ll->i_language; i++ )
766 int i_size = *p_data++;
769 psz = calloc( i_size/2 + 1, sizeof( char ) );
770 for( i_len = 0; i_len < i_size/2; i_len++ )
772 psz[i_len] = GetWLE( p_data + 2*i_len );
774 psz[i_size/2] = '\0'; \
777 p_ll->ppsz_language[i] = psz;
782 msg_Dbg( s, "Read \"language list object\" %d entries",
784 for( i = 0; i < p_ll->i_language; i++ )
785 msg_Dbg( s, " - '%s'",
786 p_ll->ppsz_language[i] );
791 static void ASF_FreeObject_language_list( asf_object_t *p_obj)
793 asf_object_language_list_t *p_ll =
794 (asf_object_language_list_t *)p_obj;
797 for( i = 0; i < p_ll->i_language; i++ )
798 FREE( p_ll->ppsz_language[i] );
799 FREE( p_ll->ppsz_language );
802 /* Stream bitrate properties */
803 static int ASF_ReadObject_stream_bitrate_properties( stream_t *s,
806 asf_object_stream_bitrate_properties_t *p_sb =
807 (asf_object_stream_bitrate_properties_t *)p_obj;
808 uint8_t *p_peek, *p_data;
812 if( ( i_peek = stream_Peek( s, &p_peek, p_sb->i_object_size ) ) < 26 )
815 p_data = &p_peek[24];
817 p_sb->i_bitrate = GetWLE( &p_data[0] ); p_data += 2;
818 if( p_sb->i_bitrate > 127 ) p_sb->i_bitrate = 127; /* Buggy ? */
819 for( i = 0; i < p_sb->i_bitrate; i++ )
821 p_sb->bitrate[i].i_stream_number = GetWLE( &p_data[0] )& 0x7f;
822 p_sb->bitrate[i].i_avg_bitrate = GetDWLE( &p_data[2] );
828 msg_Dbg( s,"Read \"stream bitrate properties object\"" );
829 for( i = 0; i < p_sb->i_bitrate; i++ )
831 msg_Dbg( s," - stream=%d bitrate=%d",
832 p_sb->bitrate[i].i_stream_number,
833 p_sb->bitrate[i].i_avg_bitrate );
838 static void ASF_FreeObject_stream_bitrate_properties( asf_object_t *p_obj)
842 static int ASF_ReadObject_extended_stream_properties( stream_t *s,
845 asf_object_extended_stream_properties_t *p_esp =
846 (asf_object_extended_stream_properties_t*)p_obj;
847 uint8_t *p_peek, *p_data;
850 if( ( i_peek = stream_Peek( s, &p_peek, p_esp->i_object_size ) ) < 88 )
853 p_data = &p_peek[24];
855 p_esp->i_start_time = GetQWLE( &p_data[0] );
856 p_esp->i_end_time = GetQWLE( &p_data[8] );
857 p_esp->i_data_bitrate = GetDWLE( &p_data[16] );
858 p_esp->i_buffer_size = GetDWLE( &p_data[20] );
859 p_esp->i_initial_buffer_fullness = GetDWLE( &p_data[24] );
860 p_esp->i_alternate_data_bitrate = GetDWLE( &p_data[28] );
861 p_esp->i_alternate_buffer_size = GetDWLE( &p_data[32] );
862 p_esp->i_alternate_initial_buffer_fullness = GetDWLE( &p_data[36] );
863 p_esp->i_maximum_object_size = GetDWLE( &p_data[40] );
864 p_esp->i_flags = GetDWLE( &p_data[44] );
865 p_esp->i_stream_number = GetWLE( &p_data[48] );
866 p_esp->i_language_index = GetWLE( &p_data[50] );
867 p_esp->i_average_time_per_frame= GetQWLE( &p_data[52] );
868 p_esp->i_stream_name_count = GetWLE( &p_data[60] );
869 p_esp->i_payload_extention_system_count = GetWLE( &p_data[62] );
873 p_esp->pi_stream_name_language = calloc( sizeof(int),
874 p_esp->i_stream_name_count );
875 p_esp->ppsz_stream_name = calloc( sizeof(char*),
876 p_esp->i_stream_name_count );
877 for( i = 0; i < p_esp->i_stream_name_count; i++ )
883 p_esp->pi_stream_name_language[i] = GetWLE( &p_data[0] );
884 i_size = GetWLE( &p_data[2] );
887 psz = calloc( i_size/2 + 1, sizeof( char ) );
888 for( i_len = 0; i_len < i_size/2; i_len++ )
890 psz[i_len] = GetWLE( p_data + 2*i_len );
892 psz[i_size/2] = '\0'; \
895 p_esp->ppsz_stream_name[i] = psz;
898 for( i = 0; i < p_esp->i_payload_extention_system_count; i++ )
901 int i_size = GetDWLE( &p_data[16 + 2] );
903 p_data += 16+2+4+i_size;
907 if( p_data < &p_peek[i_peek] )
910 /* Cannot fail as peek succeed */
911 stream_Read( s, NULL, p_data - p_peek );
913 p_sp = malloc( sizeof( asf_object_t ) );
915 if( ASF_ReadObject( s, p_sp, NULL ) )
921 /* This p_sp will be inserted by ReadRoot later */
922 p_esp->p_sp = (asf_object_stream_properties_t*)p_sp;
927 msg_Dbg( s, "Read \"extended stream properties object\":" );
928 msg_Dbg( s, " - start="I64Fd" end="I64Fd,
929 p_esp->i_start_time, p_esp->i_end_time );
930 msg_Dbg( s, " - data bitrate=%d buffer=%d initial fullness=%d",
931 p_esp->i_data_bitrate,
932 p_esp->i_buffer_size,
933 p_esp->i_initial_buffer_fullness );
934 msg_Dbg( s, " - alternate data bitrate=%d buffer=%d initial fullness=%d",
935 p_esp->i_alternate_data_bitrate,
936 p_esp->i_alternate_buffer_size,
937 p_esp->i_alternate_initial_buffer_fullness );
938 msg_Dbg( s, " - maximum object size=%d", p_esp->i_maximum_object_size );
939 msg_Dbg( s, " - flags=0x%x", p_esp->i_flags );
940 msg_Dbg( s, " - stream number=%d language=%d",
941 p_esp->i_stream_number, p_esp->i_language_index );
942 msg_Dbg( s, " - average time per frame="I64Fd,
943 p_esp->i_average_time_per_frame );
944 msg_Dbg( s, " - stream name count=%d", p_esp->i_stream_name_count );
945 for( i = 0; i < p_esp->i_stream_name_count; i++ )
946 msg_Dbg( s, " - lang id=%d name=%s",
947 p_esp->pi_stream_name_language[i],
948 p_esp->ppsz_stream_name[i] );
949 msg_Dbg( s, " - payload extention system count=%d",
950 p_esp->i_payload_extention_system_count );
954 static void ASF_FreeObject_extended_stream_properties( asf_object_t *p_obj)
956 asf_object_extended_stream_properties_t *p_esp =
957 (asf_object_extended_stream_properties_t *)p_obj;
960 for( i = 0; i < p_esp->i_stream_name_count; i++ )
961 FREE( p_esp->ppsz_stream_name[i] );
962 FREE( p_esp->pi_stream_name_language );
963 FREE( p_esp->ppsz_stream_name );
967 static int ASF_ReadObject_advanced_mutual_exclusion( stream_t *s,
970 asf_object_advanced_mutual_exclusion_t *p_ae =
971 (asf_object_advanced_mutual_exclusion_t *)p_obj;
972 uint8_t *p_peek, *p_data;
976 if( ( i_peek = stream_Peek( s, &p_peek, p_ae->i_object_size ) ) < 42 )
979 p_data = &p_peek[24];
981 ASF_GetGUID( &p_ae->type, &p_data[0] );
982 p_ae->i_stream_number_count = GetWLE( &p_data[16] );
985 p_ae->pi_stream_number = calloc( sizeof(int),
986 p_ae->i_stream_number_count );
987 for( i = 0; i < p_ae->i_stream_number_count; i++ )
989 p_ae->pi_stream_number[i] = GetWLE( p_data );
994 msg_Dbg( s, "Read \"advanced mutual exclusion object\"" );
995 for( i = 0; i < p_ae->i_stream_number_count; i++ )
996 msg_Dbg( s, " - stream=%d", p_ae->pi_stream_number[i] );
1000 static void ASF_FreeObject_advanced_mutual_exclusion( asf_object_t *p_obj)
1002 asf_object_advanced_mutual_exclusion_t *p_ae =
1003 (asf_object_advanced_mutual_exclusion_t *)p_obj;
1005 FREE( p_ae->pi_stream_number );
1009 static int ASF_ReadObject_stream_prioritization( stream_t *s,
1010 asf_object_t *p_obj)
1012 asf_object_stream_prioritization_t *p_sp =
1013 (asf_object_stream_prioritization_t *)p_obj;
1014 uint8_t *p_peek, *p_data;
1018 if( ( i_peek = stream_Peek( s, &p_peek, p_sp->i_object_size ) ) < 26 )
1019 return VLC_EGENERIC;
1021 p_data = &p_peek[24];
1023 p_sp->i_priority_count = GetWLE( &p_data[0] );
1026 p_sp->pi_priority_flag = calloc( sizeof(int), p_sp->i_priority_count );
1027 p_sp->pi_priority_stream_number =
1028 calloc( sizeof(int), p_sp->i_priority_count );
1030 for( i = 0; i < p_sp->i_priority_count; i++ )
1032 p_sp->pi_priority_stream_number[i] = GetWLE( p_data ); p_data += 2;
1033 p_sp->pi_priority_flag[i] = GetWLE( p_data ); p_data += 2;
1036 msg_Dbg( s, "Read \"stream prioritization object\"" );
1037 for( i = 0; i < p_sp->i_priority_count; i++ )
1038 msg_Dbg( s, " - Stream:%d flags=0x%x",
1039 p_sp->pi_priority_stream_number[i],
1040 p_sp->pi_priority_flag[i] );
1044 static void ASF_FreeObject_stream_prioritization( asf_object_t *p_obj)
1046 asf_object_stream_prioritization_t *p_sp =
1047 (asf_object_stream_prioritization_t *)p_obj;
1049 FREE( p_sp->pi_priority_stream_number );
1050 FREE( p_sp->pi_priority_flag );
1054 static int ASF_ReadObject_extended_content_description( stream_t *s,
1055 asf_object_t *p_obj)
1057 asf_object_extended_content_description_t *p_ec =
1058 (asf_object_extended_content_description_t *)p_obj;
1059 uint8_t *p_peek, *p_data;
1063 if( ( i_peek = stream_Peek( s, &p_peek, p_ec->i_object_size ) ) < 26 )
1064 return VLC_EGENERIC;
1066 p_data = &p_peek[24];
1068 p_ec->i_count = GetWLE( p_data ); p_data += 2;
1069 p_ec->ppsz_name = calloc( sizeof(char*), p_ec->i_count );
1070 p_ec->ppsz_value = calloc( sizeof(char*), p_ec->i_count );
1071 for( i = 0; i < p_ec->i_count; i++ )
1076 #define GETSTRINGW( psz_str, i_size ) \
1077 psz_str = calloc( i_size/2 + 1, sizeof( char ) ); \
1078 for( i_len = 0; i_len < i_size/2; i_len++ ) \
1080 psz_str[i_len] = GetWLE( p_data + 2*i_len ); \
1082 psz_str[i_size/2] = '\0';
1084 i_size = GetWLE( p_data ); p_data += 2;
1085 GETSTRINGW( p_ec->ppsz_name[i], i_size );
1089 i_type = GetWLE( p_data ); p_data += 2;
1090 i_size = GetWLE( p_data ); p_data += 2;
1093 GETSTRINGW( p_ec->ppsz_value[i], i_size );
1095 else if( i_type == 1 )
1099 p_ec->ppsz_value[i] = malloc( 2*i_size + 1 );
1100 for( j = 0; j < i_size; j++ )
1102 static const char hex[16] = "0123456789ABCDEF";
1103 p_ec->ppsz_value[i][2*j+0] = hex[p_data[0]>>4];
1104 p_ec->ppsz_value[i][2*j+1] = hex[p_data[0]&0xf];
1106 p_ec->ppsz_value[i][2*i_size] = '\0';
1108 else if( i_type == 2 )
1111 p_ec->ppsz_value[i] = strdup( *p_data ? "true" : "false" );
1113 else if( i_type == 3 )
1116 asprintf( &p_ec->ppsz_value[i], "%d", GetDWLE(p_data));
1118 else if( i_type == 4 )
1121 asprintf( &p_ec->ppsz_value[i], I64Fd, GetQWLE(p_data));
1123 else if( i_type == 5 )
1126 asprintf( &p_ec->ppsz_value[i], "%d", GetWLE(p_data));
1129 p_ec->ppsz_value[i] = NULL;
1140 msg_Dbg( s, "Read \"extended content description object\"" );
1141 for( i = 0; i < p_ec->i_count; i++ )
1142 msg_Dbg( s, " - '%s' = '%s'",
1144 p_ec->ppsz_value[i] );
1148 static void ASF_FreeObject_extended_content_description( asf_object_t *p_obj)
1150 asf_object_extended_content_description_t *p_ec =
1151 (asf_object_extended_content_description_t *)p_obj;
1154 for( i = 0; i < p_ec->i_count; i++ )
1156 FREE( p_ec->ppsz_name[i] );
1157 FREE( p_ec->ppsz_value[i] );
1163 static int ASF_ReadObject_XXX(stream_t *s, asf_object_t *p_obj)
1165 asf_object_XXX_t *p_XX =
1166 (asf_object_XXX_t *)p_obj;
1167 uint8_t *p_peek, *p_data;
1170 if( ( i_peek = stream_Peek( s, &p_peek, p_XX->i_object_size ) ) < XXX )
1171 return VLC_EGENERIC;
1173 p_data = &p_peek[24];
1177 "Read \"XXX object\"" );
1181 static void ASF_FreeObject_XXX( asf_object_t *p_obj)
1183 asf_object_XXX_t *p_XX =
1184 (asf_object_XXX_t *)p_obj;
1194 int (*ASF_ReadObject_function)( stream_t *, asf_object_t *p_obj );
1195 void (*ASF_FreeObject_function)( asf_object_t *p_obj );
1197 } ASF_Object_Function [] =
1199 { &asf_object_header_guid, ASF_OBJECT_HEADER,
1200 ASF_ReadObject_Header, ASF_FreeObject_Null },
1201 { &asf_object_data_guid, ASF_OBJECT_DATA,
1202 ASF_ReadObject_Data, ASF_FreeObject_Null },
1203 { &asf_object_index_guid, ASF_OBJECT_INDEX,
1204 ASF_ReadObject_Index, ASF_FreeObject_Index },
1205 { &asf_object_file_properties_guid, ASF_OBJECT_FILE_PROPERTIES,
1206 ASF_ReadObject_file_properties, ASF_FreeObject_Null },
1207 { &asf_object_stream_properties_guid, ASF_OBJECT_STREAM_PROPERTIES,
1208 ASF_ReadObject_stream_properties,ASF_FreeObject_stream_properties },
1209 { &asf_object_header_extension_guid, ASF_OBJECT_HEADER_EXTENSION,
1210 ASF_ReadObject_header_extension, ASF_FreeObject_header_extension},
1211 { &asf_object_metadata_guid, ASF_OBJECT_METADATA,
1212 ASF_ReadObject_metadata, ASF_FreeObject_metadata},
1213 { &asf_object_codec_list_guid, ASF_OBJECT_CODEC_LIST,
1214 ASF_ReadObject_codec_list, ASF_FreeObject_codec_list },
1215 { &asf_object_marker_guid, ASF_OBJECT_MARKER, NULL, NULL },
1216 { &asf_object_padding, ASF_OBJECT_PADDING, NULL, NULL },
1217 { &asf_object_content_description_guid, ASF_OBJECT_CONTENT_DESCRIPTION,
1218 ASF_ReadObject_content_description, ASF_FreeObject_content_description },
1219 { &asf_object_language_list, ASF_OBJECT_OTHER,
1220 ASF_ReadObject_language_list, ASF_FreeObject_language_list },
1221 { &asf_object_stream_bitrate_properties, ASF_OBJECT_OTHER,
1222 ASF_ReadObject_stream_bitrate_properties,
1223 ASF_FreeObject_stream_bitrate_properties },
1224 { &asf_object_extended_stream_properties, ASF_OBJECT_OTHER,
1225 ASF_ReadObject_extended_stream_properties,
1226 ASF_FreeObject_extended_stream_properties },
1227 { &asf_object_advanced_mutual_exclusion, ASF_OBJECT_OTHER,
1228 ASF_ReadObject_advanced_mutual_exclusion,
1229 ASF_FreeObject_advanced_mutual_exclusion },
1230 { &asf_object_stream_prioritization, ASF_OBJECT_OTHER,
1231 ASF_ReadObject_stream_prioritization,
1232 ASF_FreeObject_stream_prioritization },
1233 { &asf_object_extended_content_description, ASF_OBJECT_OTHER,
1234 ASF_ReadObject_extended_content_description,
1235 ASF_FreeObject_extended_content_description },
1237 { &asf_object_null_guid, 0, NULL, NULL }
1240 static int ASF_ReadObject( stream_t *s, asf_object_t *p_obj,
1241 asf_object_t *p_father )
1249 memset( p_obj, 0, sizeof( p_obj ) );
1251 if( ASF_ReadObjectCommon( s, p_obj ) )
1253 msg_Warn( s, "cannot read one asf object" );
1254 return VLC_EGENERIC;
1256 p_obj->common.p_father = p_father;
1257 p_obj->common.p_first = NULL;
1258 p_obj->common.p_next = NULL;
1259 p_obj->common.p_last = NULL;
1261 if( p_obj->common.i_object_size < 24 )
1263 msg_Warn( s, "found a corrupted asf object (size<24)" );
1264 return VLC_EGENERIC;
1267 /* find this object */
1268 for( i_index = 0; ; i_index++ )
1270 if( ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
1271 &p_obj->common.i_object_id ) ||
1272 ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
1273 &asf_object_null_guid ) )
1278 p_obj->common.i_type = ASF_Object_Function[i_index].i_type;
1280 /* Now load this object */
1281 if( ASF_Object_Function[i_index].ASF_ReadObject_function == NULL )
1283 msg_Warn( s, "unknown asf object (not loaded)" );
1284 i_result = VLC_SUCCESS;
1288 /* XXX ASF_ReadObject_function realloc *pp_obj XXX */
1290 (ASF_Object_Function[i_index].ASF_ReadObject_function)( s, p_obj );
1293 /* link this object with father */
1296 if( p_father->common.p_first )
1298 p_father->common.p_last->common.p_next = p_obj;
1302 p_father->common.p_first = p_obj;
1304 p_father->common.p_last = p_obj;
1310 static void ASF_FreeObject( stream_t *s, asf_object_t *p_obj )
1313 asf_object_t *p_child;
1315 if( !p_obj ) return;
1317 /* Free all child object */
1318 p_child = p_obj->common.p_first;
1321 asf_object_t *p_next;
1322 p_next = p_child->common.p_next;
1323 ASF_FreeObject( s, p_child );
1327 /* find this object */
1328 for( i_index = 0; ; i_index++ )
1330 if( ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
1331 &p_obj->common.i_object_id )||
1332 ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
1333 &asf_object_null_guid ) )
1339 /* Now free this object */
1340 if( ASF_Object_Function[i_index].ASF_FreeObject_function == NULL )
1343 "unknown asf object " GUID_FMT,
1344 GUID_PRINT( p_obj->common.i_object_id ) );
1350 "free asf object " GUID_FMT,
1351 GUID_PRINT( p_obj->common.i_object_id ) );
1353 (ASF_Object_Function[i_index].ASF_FreeObject_function)( p_obj );
1359 /*****************************************************************************
1360 * ASF_ObjectDumpDebug:
1361 *****************************************************************************/
1366 } ASF_ObjectDumpDebugInfo[] =
1368 { &asf_object_header_guid, "Header" },
1369 { &asf_object_data_guid, "Data" },
1370 { &asf_object_index_guid, "Index" },
1371 { &asf_object_file_properties_guid, "File Properties" },
1372 { &asf_object_stream_properties_guid, "Stream Properties" },
1373 { &asf_object_content_description_guid, "Content Description" },
1374 { &asf_object_header_extension_guid, "Header Extention" },
1375 { &asf_object_metadata_guid, "Metadata" },
1376 { &asf_object_codec_list_guid, "Codec List" },
1377 { &asf_object_marker_guid, "Marker" },
1378 { &asf_object_stream_type_audio, "Stream Type Audio" },
1379 { &asf_object_stream_type_video, "Stream Type Video" },
1380 { &asf_object_stream_type_command, "Stream Type Command" },
1381 { &asf_object_language_list, "Language List" },
1382 { &asf_object_stream_bitrate_properties, "Stream Bitrate Propoerties" },
1383 { &asf_object_padding, "Padding" },
1384 { &asf_object_extended_stream_properties, "Extended Stream Properties" },
1385 { &asf_object_advanced_mutual_exclusion, "Advanced Mutual Exclusion" },
1386 { &asf_object_stream_prioritization, "Stream Prioritization" },
1387 { &asf_object_extended_content_description, "Extended content description"},
1389 { NULL, "Unknown" },
1393 static void ASF_ObjectDumpDebug( vlc_object_t *p_obj,
1394 asf_object_common_t *p_node, int i_level )
1398 union asf_object_u *p_child;
1402 for( i = 0; ASF_ObjectDumpDebugInfo[i].p_id != NULL; i++ )
1404 if( ASF_CmpGUID( ASF_ObjectDumpDebugInfo[i].p_id,
1405 &p_node->i_object_id ) )
1408 psz_name = ASF_ObjectDumpDebugInfo[i].psz_name;
1410 memset( str, ' ', sizeof( str ) );
1411 for( i = 1; i < i_level; i++ )
1415 snprintf( str + 5*i_level, 1024,
1416 "+ '%s' GUID "GUID_FMT" size:"I64Fu"pos:"I64Fu,
1418 GUID_PRINT( p_node->i_object_id ),
1419 p_node->i_object_size, p_node->i_object_pos );
1421 msg_Dbg( p_obj, "%s", str );
1423 for( p_child = p_node->p_first; p_child != NULL;
1424 p_child = p_child->common.p_next )
1426 ASF_ObjectDumpDebug( p_obj, &p_child->common, i_level + 1 );
1430 /*****************************************************************************
1431 * ASF_ReadObjetRoot : parse the entire stream/file
1432 *****************************************************************************/
1433 asf_object_root_t *ASF_ReadObjectRoot( stream_t *s, int b_seekable )
1435 asf_object_root_t *p_root = malloc( sizeof( asf_object_root_t ) );
1436 asf_object_t *p_obj;
1438 p_root->i_type = ASF_OBJECT_ROOT;
1439 memcpy( &p_root->i_object_id, &asf_object_null_guid, sizeof( guid_t ) );
1440 p_root->i_object_pos = stream_Tell( s );
1441 p_root->i_object_size = 0;
1442 p_root->p_first = NULL;
1443 p_root->p_last = NULL;
1444 p_root->p_next = NULL;
1445 p_root->p_hdr = NULL;
1446 p_root->p_data = NULL;
1447 p_root->p_fp = NULL;
1448 p_root->p_index = NULL;
1449 p_root->p_metadata = NULL;
1453 p_obj = malloc( sizeof( asf_object_t ) );
1455 if( ASF_ReadObject( s, p_obj, (asf_object_t*)p_root ) )
1460 switch( p_obj->common.i_type )
1462 case( ASF_OBJECT_HEADER ):
1463 p_root->p_hdr = (asf_object_header_t*)p_obj;
1465 case( ASF_OBJECT_DATA ):
1466 p_root->p_data = (asf_object_data_t*)p_obj;
1468 case( ASF_OBJECT_INDEX ):
1469 p_root->p_index = (asf_object_index_t*)p_obj;
1472 msg_Warn( s, "unknow object found" );
1475 if( p_obj->common.i_type == ASF_OBJECT_DATA &&
1476 p_obj->common.i_object_size <= 50 )
1478 /* probably a dump of broadcasted asf */
1481 if( !b_seekable && p_root->p_hdr && p_root->p_data )
1483 /* For unseekable stream it's enough to play */
1487 if( ASF_NextObject( s, p_obj ) ) /* Go to the next object */
1493 if( p_root->p_hdr != NULL && p_root->p_data != NULL )
1495 p_root->p_fp = ASF_FindObject( p_root->p_hdr,
1496 &asf_object_file_properties_guid, 0 );
1500 asf_object_t *p_hdr_ext =
1501 ASF_FindObject( p_root->p_hdr,
1502 &asf_object_header_extension_guid, 0 );
1508 p_root->p_metadata =
1509 ASF_FindObject( p_hdr_ext,
1510 &asf_object_metadata_guid, 0 );
1511 /* Special case for broken designed file format :( */
1512 i_ext_stream = ASF_CountObject( p_hdr_ext,
1513 &asf_object_extended_stream_properties );
1514 for( i = 0; i < i_ext_stream; i++ )
1516 asf_object_t *p_esp =
1517 ASF_FindObject( p_hdr_ext,
1518 &asf_object_extended_stream_properties, i );
1519 if( p_esp->ext_stream.p_sp )
1521 asf_object_t *p_sp =
1522 (asf_object_t*)p_esp->ext_stream.p_sp;
1524 /* Insert this p_sp */
1525 p_root->p_hdr->p_last->common.p_next = p_sp;
1526 p_root->p_hdr->p_last = p_sp;
1528 p_sp->common.p_father = (asf_object_t*)p_root->p_hdr;
1533 ASF_ObjectDumpDebug( VLC_OBJECT(s),
1534 (asf_object_common_t*)p_root, 0 );
1537 msg_Warn( s, "cannot find file properties object" );
1541 ASF_FreeObjectRoot( s, p_root );
1545 void ASF_FreeObjectRoot( stream_t *s, asf_object_root_t *p_root )
1547 asf_object_t *p_obj;
1549 p_obj = p_root->p_first;
1552 asf_object_t *p_next;
1553 p_next = p_obj->common.p_next;
1554 ASF_FreeObject( s, p_obj );
1560 int __ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid )
1563 asf_object_t *p_child;
1565 if( !p_obj ) return( 0 );
1568 p_child = p_obj->common.p_first;
1571 if( ASF_CmpGUID( &p_child->common.i_object_id, p_guid ) )
1575 p_child = p_child->common.p_next;
1580 void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid,
1583 asf_object_t *p_child;
1585 p_child = p_obj->common.p_first;
1589 if( ASF_CmpGUID( &p_child->common.i_object_id, p_guid ) )
1599 p_child = p_child->common.p_next;