1 /*****************************************************************************
2 * libasf.c : asf stream demux module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001-2003 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA 02111, 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;
311 p_meta->i_record_entries_count = 0;
314 if( stream_Peek( s, &p_peek, p_meta->i_object_size ) <
315 (int)p_meta->i_object_size )
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++ )
324 asf_metadata_record_t record;
325 int i_name, i_data, j;
327 if( GetWLE( p_peek + i_peek ) != 0 )
329 ASF_FreeObject_metadata( p_obj );
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;
339 if( record.i_type > ASF_METADATA_TYPE_WORD ||
340 i_peek + i_data + i_name > (int)p_meta->i_object_size )
342 ASF_FreeObject_metadata( p_obj );
351 record.psz_name = malloc( i_name/2 + 1 );
352 for( j = 0; j < i_name/2; j++ )
354 record.psz_name[j] = GetWLE( p_peek + i_peek ); i_peek += 2;
356 record.psz_name[j] = 0; /* just to make sure */
359 if( record.i_type == ASF_METADATA_TYPE_STRING )
361 record.p_data = malloc( i_data/2 + 1 );
362 record.i_data = i_data/2;
363 for( j = 0; j < i_data/2; j++ )
365 record.p_data[j] = GetWLE( p_peek + i_peek ); i_peek += 2;
367 record.p_data[j] = 0; /* just to make sure */
369 else if( record.i_type == ASF_METADATA_TYPE_BYTE )
371 record.p_data = malloc( i_data );
372 record.i_data = i_data;
373 memcpy( record.p_data, p_peek + i_peek, i_data );
378 if( record.i_type == ASF_METADATA_TYPE_QWORD )
380 record.i_val = GetQWLE( p_peek + i_peek ); i_peek += 8;
382 else if( record.i_type == ASF_METADATA_TYPE_DWORD )
384 record.i_val = GetDWLE( p_peek + i_peek ); i_peek += 4;
388 record.i_val = GetWLE( p_peek + i_peek ); i_peek += 2;
392 p_meta->i_record_entries_count++;
394 realloc( p_meta->record, p_meta->i_record_entries_count *
395 sizeof(asf_metadata_record_t) );
396 memcpy( &p_meta->record[p_meta->i_record_entries_count-1],
397 &record, sizeof(asf_metadata_record_t) );
402 "read \"metadata object\" %d entries",
403 p_meta->i_record_entries_count );
404 for( i = 0; i < p_meta->i_record_entries_count; i++ )
406 asf_metadata_record_t *p_rec = &p_meta->record[i];
408 if( p_rec->i_type == ASF_METADATA_TYPE_STRING )
409 msg_Dbg( s, " - %s=%s",
410 p_rec->psz_name, p_rec->p_data );
411 else if( p_rec->i_type == ASF_METADATA_TYPE_BYTE )
412 msg_Dbg( s, " - %s (%i bytes)",
413 p_rec->psz_name, p_rec->i_data );
415 msg_Dbg( s, " - %s="I64Fd,
416 p_rec->psz_name, p_rec->i_val );
423 static int ASF_ReadObject_header_extension( stream_t *s, asf_object_t *p_obj )
425 asf_object_header_extension_t *p_he =
426 (asf_object_header_extension_t *)p_obj;
430 if( ( i_peek = stream_Peek( s, &p_peek, p_he->i_object_size ) ) < 46)
434 ASF_GetGUID( &p_he->i_reserved1, p_peek + 24 );
435 p_he->i_reserved2 = GetWLE( p_peek + 40 );
436 p_he->i_header_extension_size = GetDWLE( p_peek + 42 );
437 if( p_he->i_header_extension_size )
439 p_he->p_header_extension_data =
440 malloc( p_he->i_header_extension_size );
441 memcpy( p_he->p_header_extension_data, p_peek + 46,
442 p_he->i_header_extension_size );
446 p_he->p_header_extension_data = NULL;
451 "read \"header extension object\" reserved1:" GUID_FMT
452 " reserved2:%d header_extension_size:%d",
453 GUID_PRINT( p_he->i_reserved1 ), p_he->i_reserved2,
454 p_he->i_header_extension_size );
457 if( !p_he->i_header_extension_size ) return VLC_SUCCESS;
459 /* Read the extension objects */
460 stream_Read( s, NULL, 46 );
463 asf_object_t *p_obj = malloc( sizeof( asf_object_t ) );
465 if( ASF_ReadObject( s, p_obj, (asf_object_t*)p_he ) )
471 if( ASF_NextObject( s, p_obj ) ) /* Go to the next object */
480 static void ASF_FreeObject_header_extension( asf_object_t *p_obj )
482 asf_object_header_extension_t *p_he =
483 (asf_object_header_extension_t *)p_obj;
485 FREE( p_he->p_header_extension_data );
488 static int ASF_ReadObject_stream_properties( stream_t *s, asf_object_t *p_obj )
490 asf_object_stream_properties_t *p_sp =
491 (asf_object_stream_properties_t*)p_obj;
495 if( ( i_peek = stream_Peek( s, &p_peek, p_sp->i_object_size ) ) < 74 )
499 ASF_GetGUID( &p_sp->i_stream_type, p_peek + 24 );
500 ASF_GetGUID( &p_sp->i_error_correction_type, p_peek + 40 );
501 p_sp->i_time_offset = GetQWLE( p_peek + 56 );
502 p_sp->i_type_specific_data_length = GetDWLE( p_peek + 64 );
503 p_sp->i_error_correction_data_length = GetDWLE( p_peek + 68 );
504 p_sp->i_flags = GetWLE( p_peek + 72 );
505 p_sp->i_stream_number = p_sp->i_flags&0x07f;
506 p_sp->i_reserved = GetDWLE( p_peek + 74 );
507 if( p_sp->i_type_specific_data_length )
509 p_sp->p_type_specific_data =
510 malloc( p_sp->i_type_specific_data_length );
511 memcpy( p_sp->p_type_specific_data, p_peek + 78,
512 p_sp->i_type_specific_data_length );
516 p_sp->p_type_specific_data = NULL;
518 if( p_sp->i_error_correction_data_length )
520 p_sp->p_error_correction_data =
521 malloc( p_sp->i_error_correction_data_length );
522 memcpy( p_sp->p_error_correction_data,
523 p_peek + 78 + p_sp->i_type_specific_data_length,
524 p_sp->i_error_correction_data_length );
528 p_sp->p_error_correction_data = NULL;
533 "read \"stream Properties object\" stream_type:" GUID_FMT
534 " error_correction_type:" GUID_FMT " time_offset:"I64Fd
535 " type_specific_data_length:%d error_correction_data_length:%d"
536 " flags:0x%x stream_number:%d",
537 GUID_PRINT( p_sp->i_stream_type ),
538 GUID_PRINT( p_sp->i_error_correction_type ),
540 p_sp->i_type_specific_data_length,
541 p_sp->i_error_correction_data_length,
543 p_sp->i_stream_number );
549 static void ASF_FreeObject_stream_properties( asf_object_t *p_obj )
551 asf_object_stream_properties_t *p_sp =
552 (asf_object_stream_properties_t*)p_obj;
554 FREE( p_sp->p_type_specific_data );
555 FREE( p_sp->p_error_correction_data );
559 static int ASF_ReadObject_codec_list( stream_t *s, asf_object_t *p_obj )
561 asf_object_codec_list_t *p_cl = (asf_object_codec_list_t*)p_obj;
563 uint8_t *p_peek, *p_data;
565 unsigned int i_codec;
567 if( ( i_peek = stream_Peek( s, &p_peek, p_cl->i_object_size ) ) < 44 )
572 ASF_GetGUID( &p_cl->i_reserved, p_peek + 24 );
573 p_cl->i_codec_entries_count = GetWLE( p_peek + 40 );
574 if( p_cl->i_codec_entries_count > 0 )
576 p_cl->codec = calloc( p_cl->i_codec_entries_count,
577 sizeof( asf_codec_entry_t ) );
578 memset( p_cl->codec, 0,
579 p_cl->i_codec_entries_count * sizeof( asf_codec_entry_t ) );
581 p_data = p_peek + 44;
582 for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ )
584 #define codec p_cl->codec[i_codec]
587 codec.i_type = GetWLE( p_data ); p_data += 2;
589 i_len = GetWLE( p_data ); p_data += 2;
590 codec.psz_name = calloc( sizeof( char ), i_len + 1);
591 for( i = 0; i < i_len; i++ )
593 codec.psz_name[i] = GetWLE( p_data + 2*i );
595 codec.psz_name[i_len] = '\0';
599 i_len = GetWLE( p_data ); p_data += 2;
600 codec.psz_description = calloc( sizeof( char ), i_len + 1);
601 for( i = 0; i < i_len; i++ )
603 codec.psz_description[i] = GetWLE( p_data + 2*i );
605 codec.psz_description[i_len] = '\0';
608 /* opaque information */
609 codec.i_information_length = GetWLE( p_data ); p_data += 2;
610 if( codec.i_information_length > 0 )
612 codec.p_information = malloc( codec.i_information_length );
613 memcpy( codec.p_information, p_data, codec.i_information_length );
614 p_data += codec.i_information_length;
618 codec.p_information = NULL;
629 msg_Dbg( s, "read \"codec list object\" reserved_guid:" GUID_FMT
630 " codec_entries_count:%d",
631 GUID_PRINT( p_cl->i_reserved ), p_cl->i_codec_entries_count );
633 for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ )
635 #define codec p_cl->codec[i_codec]
636 msg_Dbg( s, " - codec[%d] %s name:\"%s\" "
637 "description:\"%s\" information_length:%d",
638 i_codec, ( codec.i_type == ASF_CODEC_TYPE_VIDEO ) ?
639 "video" : ( ( codec.i_type == ASF_CODEC_TYPE_AUDIO ) ?
640 "audio" : "unknown" ),
641 codec.psz_name, codec.psz_description,
642 codec.i_information_length );
650 static void ASF_FreeObject_codec_list( asf_object_t *p_obj )
652 asf_object_codec_list_t *p_cl = (asf_object_codec_list_t*)p_obj;
653 unsigned int i_codec;
655 for( i_codec = 0; i_codec < p_cl->i_codec_entries_count; i_codec++ )
657 #define codec p_cl->codec[i_codec]
658 FREE( codec.psz_name );
659 FREE( codec.psz_description );
660 FREE( codec.p_information );
666 /* Microsoft should go to hell. This time the length give number of bytes
667 * and for the some others object, length give char16 count ... */
668 static int ASF_ReadObject_content_description(stream_t *s, asf_object_t *p_obj)
670 asf_object_content_description_t *p_cd =
671 (asf_object_content_description_t *)p_obj;
672 uint8_t *p_peek, *p_data;
674 int i_len, i_title, i_author, i_copyright, i_description, i_rating;
676 #define GETSTRINGW( psz_str, i_size ) \
677 psz_str = calloc( i_size/2 + 1, sizeof( char ) ); \
678 for( i_len = 0; i_len < i_size/2; i_len++ ) \
680 psz_str[i_len] = GetWLE( p_data + 2*i_len ); \
682 psz_str[i_size/2] = '\0'; \
685 if( ( i_peek = stream_Peek( s, &p_peek, p_cd->i_object_size ) ) < 34 )
689 p_data = p_peek + 24;
691 i_title = GetWLE( p_data ); p_data += 2;
692 i_author= GetWLE( p_data ); p_data += 2;
693 i_copyright = GetWLE( p_data ); p_data += 2;
694 i_description = GetWLE( p_data ); p_data += 2;
695 i_rating = GetWLE( p_data ); p_data += 2;
697 GETSTRINGW( p_cd->psz_title, i_title );
698 GETSTRINGW( p_cd->psz_author, i_author );
699 GETSTRINGW( p_cd->psz_copyright, i_copyright );
700 GETSTRINGW( p_cd->psz_description, i_description );
701 GETSTRINGW( p_cd->psz_rating, i_rating );
707 "Read \"content description object\" title:\"%s\" author:\"%s\" copyright:\"%s\" description:\"%s\" rating:\"%s\"",
711 p_cd->psz_description,
717 static void ASF_FreeObject_content_description( asf_object_t *p_obj)
719 asf_object_content_description_t *p_cd =
720 (asf_object_content_description_t *)p_obj;
722 FREE( p_cd->psz_title );
723 FREE( p_cd->psz_author );
724 FREE( p_cd->psz_copyright );
725 FREE( p_cd->psz_description );
726 FREE( p_cd->psz_rating );
730 static int ASF_ReadObject_language_list(stream_t *s, asf_object_t *p_obj)
732 asf_object_language_list_t *p_ll =
733 (asf_object_language_list_t*)p_obj;
734 uint8_t *p_peek, *p_data;
738 if( ( i_peek = stream_Peek( s, &p_peek, p_ll->i_object_size ) ) < 26 )
741 p_data = &p_peek[24];
743 p_ll->i_language = GetWLE( &p_data[0] ); p_data += 2;
744 if( p_ll->i_language > 0 )
746 p_ll->ppsz_language = calloc( p_ll->i_language, sizeof( char *) );
748 for( i = 0; i < p_ll->i_language; i++ )
751 int i_size = *p_data++;
754 psz = calloc( i_size/2 + 1, sizeof( char ) );
755 for( i_len = 0; i_len < i_size/2; i_len++ )
757 psz[i_len] = GetWLE( p_data + 2*i_len );
759 psz[i_size/2] = '\0'; \
762 p_ll->ppsz_language[i] = psz;
767 msg_Dbg( s, "Read \"language list object\" %d entries",
769 for( i = 0; i < p_ll->i_language; i++ )
770 msg_Dbg( s, " - '%s'",
771 p_ll->ppsz_language[i] );
776 static void ASF_FreeObject_language_list( asf_object_t *p_obj)
778 asf_object_language_list_t *p_ll =
779 (asf_object_language_list_t *)p_obj;
782 for( i = 0; i < p_ll->i_language; i++ )
783 FREE( p_ll->ppsz_language[i] );
784 FREE( p_ll->ppsz_language );
787 /* Stream bitrate properties */
788 static int ASF_ReadObject_stream_bitrate_properties( stream_t *s,
791 asf_object_stream_bitrate_properties_t *p_sb =
792 (asf_object_stream_bitrate_properties_t *)p_obj;
793 uint8_t *p_peek, *p_data;
797 if( ( i_peek = stream_Peek( s, &p_peek, p_sb->i_object_size ) ) < 26 )
800 p_data = &p_peek[24];
802 p_sb->i_bitrate = GetWLE( &p_data[0] ); p_data += 2;
803 if( p_sb->i_bitrate > 127 ) p_sb->i_bitrate = 127; /* Buggy ? */
804 for( i = 0; i < p_sb->i_bitrate; i++ )
806 p_sb->bitrate[i].i_stream_number = GetWLE( &p_data[0] )& 0x7f;
807 p_sb->bitrate[i].i_avg_bitrate = GetDWLE( &p_data[2] );
813 msg_Dbg( s,"Read \"stream bitrate properties object\"" );
814 for( i = 0; i < p_sb->i_bitrate; i++ )
816 msg_Dbg( s," - stream=%d bitrate=%d",
817 p_sb->bitrate[i].i_stream_number,
818 p_sb->bitrate[i].i_avg_bitrate );
823 static void ASF_FreeObject_stream_bitrate_properties( asf_object_t *p_obj)
827 static int ASF_ReadObject_extended_stream_properties( stream_t *s,
830 asf_object_extended_stream_properties_t *p_esp =
831 (asf_object_extended_stream_properties_t*)p_obj;
832 uint8_t *p_peek, *p_data;
835 if( ( i_peek = stream_Peek( s, &p_peek, p_esp->i_object_size ) ) < 88 )
838 p_data = &p_peek[24];
840 p_esp->i_start_time = GetQWLE( &p_data[0] );
841 p_esp->i_end_time = GetQWLE( &p_data[8] );
842 p_esp->i_data_bitrate = GetDWLE( &p_data[16] );
843 p_esp->i_buffer_size = GetDWLE( &p_data[20] );
844 p_esp->i_initial_buffer_fullness = GetDWLE( &p_data[24] );
845 p_esp->i_alternate_data_bitrate = GetDWLE( &p_data[28] );
846 p_esp->i_alternate_buffer_size = GetDWLE( &p_data[32] );
847 p_esp->i_alternate_initial_buffer_fullness = GetDWLE( &p_data[36] );
848 p_esp->i_maximum_object_size = GetDWLE( &p_data[40] );
849 p_esp->i_flags = GetDWLE( &p_data[44] );
850 p_esp->i_stream_number = GetWLE( &p_data[48] );
851 p_esp->i_language_index = GetWLE( &p_data[50] );
852 p_esp->i_average_time_per_frame= GetQWLE( &p_data[52] );
853 p_esp->i_stream_name_count = GetWLE( &p_data[60] );
854 p_esp->i_payload_extention_system_count = GetWLE( &p_data[62] );
858 p_esp->pi_stream_name_language = calloc( sizeof(int),
859 p_esp->i_stream_name_count );
860 p_esp->ppsz_stream_name = calloc( sizeof(char*),
861 p_esp->i_stream_name_count );
862 for( i = 0; i < p_esp->i_stream_name_count; i++ )
868 p_esp->pi_stream_name_language[i] = GetWLE( &p_data[0] );
869 i_size = GetWLE( &p_data[2] );
872 psz = calloc( i_size/2 + 1, sizeof( char ) );
873 for( i_len = 0; i_len < i_size/2; i_len++ )
875 psz[i_len] = GetWLE( p_data + 2*i_len );
877 psz[i_size/2] = '\0'; \
880 p_esp->ppsz_stream_name[i] = psz;
883 for( i = 0; i < p_esp->i_payload_extention_system_count; i++ )
886 int i_size = GetDWLE( &p_data[16 + 2] );
888 p_data += 16+2+4+i_size;
892 if( p_data < &p_peek[i_peek] )
895 /* Cannot fail as peek succeed */
896 stream_Read( s, NULL, p_data - p_peek );
898 p_sp = malloc( sizeof( asf_object_t ) );
900 if( ASF_ReadObject( s, p_sp, NULL ) )
906 /* This p_sp will be inserted by ReadRoot later */
912 msg_Dbg( s, "Read \"extended stream properties object\":" );
913 msg_Dbg( s, " - start="I64Fd" end="I64Fd,
914 p_esp->i_start_time, p_esp->i_end_time );
915 msg_Dbg( s, " - data bitrate=%d buffer=%d initial fullness=%d",
916 p_esp->i_data_bitrate,
917 p_esp->i_buffer_size,
918 p_esp->i_initial_buffer_fullness );
919 msg_Dbg( s, " - alternate data bitrate=%d buffer=%d initial fullness=%d",
920 p_esp->i_alternate_data_bitrate,
921 p_esp->i_alternate_buffer_size,
922 p_esp->i_alternate_initial_buffer_fullness );
923 msg_Dbg( s, " - maximum object size=%d", p_esp->i_maximum_object_size );
924 msg_Dbg( s, " - flags=0x%x", p_esp->i_flags );
925 msg_Dbg( s, " - stream number=%d language=%d",
926 p_esp->i_stream_number, p_esp->i_language_index );
927 msg_Dbg( s, " - average time per frame="I64Fd,
928 p_esp->i_average_time_per_frame );
929 msg_Dbg( s, " - stream name count=%d", p_esp->i_stream_name_count );
930 for( i = 0; i < p_esp->i_stream_name_count; i++ )
931 msg_Dbg( s, " - lang id=%d name=%s",
932 p_esp->pi_stream_name_language[i],
933 p_esp->ppsz_stream_name[i] );
934 msg_Dbg( s, " - payload extention system count=%d",
935 p_esp->i_payload_extention_system_count );
939 static void ASF_FreeObject_extended_stream_properties( asf_object_t *p_obj)
941 asf_object_extended_stream_properties_t *p_esp =
942 (asf_object_extended_stream_properties_t *)p_obj;
945 for( i = 0; i < p_esp->i_stream_name_count; i++ )
946 FREE( p_esp->ppsz_stream_name[i] );
947 FREE( p_esp->pi_stream_name_language );
948 FREE( p_esp->ppsz_stream_name );
952 static int ASF_ReadObject_advanced_mutual_exclusion( stream_t *s,
955 asf_object_advanced_mutual_exclusion_t *p_ae =
956 (asf_object_advanced_mutual_exclusion_t *)p_obj;
957 uint8_t *p_peek, *p_data;
961 if( ( i_peek = stream_Peek( s, &p_peek, p_ae->i_object_size ) ) < 42 )
964 p_data = &p_peek[24];
966 ASF_GetGUID( &p_ae->type, &p_data[0] );
967 p_ae->i_stream_number_count = GetWLE( &p_data[16] );
970 p_ae->pi_stream_number = calloc( sizeof(int),
971 p_ae->i_stream_number_count );
972 for( i = 0; i < p_ae->i_stream_number_count; i++ )
974 p_ae->pi_stream_number[i] = GetWLE( p_data );
979 msg_Dbg( s, "Read \"advanced mutual exclusion object\"" );
980 for( i = 0; i < p_ae->i_stream_number_count; i++ )
981 msg_Dbg( s, " - stream=%d", p_ae->pi_stream_number[i] );
985 static void ASF_FreeObject_advanced_mutual_exclusion( asf_object_t *p_obj)
987 asf_object_advanced_mutual_exclusion_t *p_ae =
988 (asf_object_advanced_mutual_exclusion_t *)p_obj;
990 FREE( p_ae->pi_stream_number );
994 static int ASF_ReadObject_stream_prioritization( stream_t *s,
997 asf_object_stream_prioritization_t *p_sp =
998 (asf_object_stream_prioritization_t *)p_obj;
999 uint8_t *p_peek, *p_data;
1003 if( ( i_peek = stream_Peek( s, &p_peek, p_sp->i_object_size ) ) < 26 )
1004 return VLC_EGENERIC;
1006 p_data = &p_peek[24];
1008 p_sp->i_priority_count = GetWLE( &p_data[0] );
1011 p_sp->pi_priority_flag = calloc( sizeof(int), p_sp->i_priority_count );
1012 p_sp->pi_priority_stream_number =
1013 calloc( sizeof(int), p_sp->i_priority_count );
1015 for( i = 0; i < p_sp->i_priority_count; i++ )
1017 p_sp->pi_priority_stream_number[i] = GetWLE( p_data ); p_data += 2;
1018 p_sp->pi_priority_flag[i] = GetWLE( p_data ); p_data += 2;
1021 msg_Dbg( s, "Read \"stream prioritization object\"" );
1022 for( i = 0; i < p_sp->i_priority_count; i++ )
1023 msg_Dbg( s, " - Stream:%d flags=0x%x",
1024 p_sp->pi_priority_stream_number[i],
1025 p_sp->pi_priority_flag[i] );
1029 static void ASF_FreeObject_stream_prioritization( asf_object_t *p_obj)
1031 asf_object_stream_prioritization_t *p_sp =
1032 (asf_object_stream_prioritization_t *)p_obj;
1034 FREE( p_sp->pi_priority_stream_number );
1035 FREE( p_sp->pi_priority_flag );
1039 static int ASF_ReadObject_extended_content_description( stream_t *s,
1040 asf_object_t *p_obj)
1042 asf_object_extended_content_description_t *p_ec =
1043 (asf_object_extended_content_description_t *)p_obj;
1044 uint8_t *p_peek, *p_data;
1048 if( ( i_peek = stream_Peek( s, &p_peek, p_ec->i_object_size ) ) < 26 )
1049 return VLC_EGENERIC;
1051 p_data = &p_peek[24];
1053 p_ec->i_count = GetWLE( p_data ); p_data += 2;
1054 p_ec->ppsz_name = calloc( sizeof(char*), p_ec->i_count );
1055 p_ec->ppsz_value = calloc( sizeof(char*), p_ec->i_count );
1056 for( i = 0; i < p_ec->i_count; i++ )
1061 #define GETSTRINGW( psz_str, i_size ) \
1062 psz_str = calloc( i_size/2 + 1, sizeof( char ) ); \
1063 for( i_len = 0; i_len < i_size/2; i_len++ ) \
1065 psz_str[i_len] = GetWLE( p_data + 2*i_len ); \
1067 psz_str[i_size/2] = '\0';
1069 i_size = GetWLE( p_data ); p_data += 2;
1070 GETSTRINGW( p_ec->ppsz_name[i], i_size );
1074 i_type = GetWLE( p_data ); p_data += 2;
1075 i_size = GetWLE( p_data ); p_data += 2;
1078 GETSTRINGW( p_ec->ppsz_value[i], i_size );
1080 else if( i_type == 1 )
1084 p_ec->ppsz_value[i] = malloc( 2*i_size + 1 );
1085 for( j = 0; j < i_size; j++ )
1087 static const char hex[16] = "0123456789ABCDEF";
1088 p_ec->ppsz_value[i][2*j+0] = hex[p_data[0]>>4];
1089 p_ec->ppsz_value[i][2*j+1] = hex[p_data[0]&0xf];
1091 p_ec->ppsz_value[i][2*i_size] = '\0';
1093 else if( i_type == 2 )
1096 p_ec->ppsz_value[i] = strdup( *p_data ? "true" : "false" );
1098 else if( i_type == 3 )
1101 asprintf( &p_ec->ppsz_value[i], "%d", GetDWLE(p_data));
1103 else if( i_type == 4 )
1106 asprintf( &p_ec->ppsz_value[i], I64Fd, GetQWLE(p_data));
1108 else if( i_type == 5 )
1111 asprintf( &p_ec->ppsz_value[i], "%d", GetWLE(p_data));
1114 p_ec->ppsz_value[i] = NULL;
1125 msg_Dbg( s, "Read \"extended content description object\"" );
1126 for( i = 0; i < p_ec->i_count; i++ )
1127 msg_Dbg( s, " - '%s' = '%s'",
1129 p_ec->ppsz_value[i] );
1133 static void ASF_FreeObject_extended_content_description( asf_object_t *p_obj)
1135 asf_object_extended_content_description_t *p_ec =
1136 (asf_object_extended_content_description_t *)p_obj;
1139 for( i = 0; i < p_ec->i_count; i++ )
1141 FREE( p_ec->ppsz_name[i] );
1142 FREE( p_ec->ppsz_value[i] );
1148 static int ASF_ReadObject_XXX(stream_t *s, asf_object_t *p_obj)
1150 asf_object_XXX_t *p_XX =
1151 (asf_object_XXX_t *)p_obj;
1152 uint8_t *p_peek, *p_data;
1155 if( ( i_peek = stream_Peek( s, &p_peek, p_XX->i_object_size ) ) < XXX )
1156 return VLC_EGENERIC;
1158 p_data = &p_peek[24];
1162 "Read \"XXX object\"" );
1166 static void ASF_FreeObject_XXX( asf_object_t *p_obj)
1168 asf_object_XXX_t *p_XX =
1169 (asf_object_XXX_t *)p_obj;
1179 int (*ASF_ReadObject_function)( stream_t *, asf_object_t *p_obj );
1180 void (*ASF_FreeObject_function)( asf_object_t *p_obj );
1182 } ASF_Object_Function [] =
1184 { &asf_object_header_guid, ASF_OBJECT_HEADER,
1185 ASF_ReadObject_Header, ASF_FreeObject_Null },
1186 { &asf_object_data_guid, ASF_OBJECT_DATA,
1187 ASF_ReadObject_Data, ASF_FreeObject_Null },
1188 { &asf_object_index_guid, ASF_OBJECT_INDEX,
1189 ASF_ReadObject_Index, ASF_FreeObject_Index },
1190 { &asf_object_file_properties_guid, ASF_OBJECT_FILE_PROPERTIES,
1191 ASF_ReadObject_file_properties, ASF_FreeObject_Null },
1192 { &asf_object_stream_properties_guid, ASF_OBJECT_STREAM_PROPERTIES,
1193 ASF_ReadObject_stream_properties,ASF_FreeObject_stream_properties },
1194 { &asf_object_header_extension_guid, ASF_OBJECT_HEADER_EXTENSION,
1195 ASF_ReadObject_header_extension, ASF_FreeObject_header_extension},
1196 { &asf_object_metadata_guid, ASF_OBJECT_METADATA,
1197 ASF_ReadObject_metadata, ASF_FreeObject_metadata},
1198 { &asf_object_codec_list_guid, ASF_OBJECT_CODEC_LIST,
1199 ASF_ReadObject_codec_list, ASF_FreeObject_codec_list },
1200 { &asf_object_marker_guid, ASF_OBJECT_MARKER, NULL, NULL },
1201 { &asf_object_padding, ASF_OBJECT_PADDING, NULL, NULL },
1202 { &asf_object_content_description_guid, ASF_OBJECT_CONTENT_DESCRIPTION,
1203 ASF_ReadObject_content_description, ASF_FreeObject_content_description },
1204 { &asf_object_language_list, ASF_OBJECT_OTHER,
1205 ASF_ReadObject_language_list, ASF_FreeObject_language_list },
1206 { &asf_object_stream_bitrate_properties, ASF_OBJECT_OTHER,
1207 ASF_ReadObject_stream_bitrate_properties,
1208 ASF_FreeObject_stream_bitrate_properties },
1209 { &asf_object_extended_stream_properties, ASF_OBJECT_OTHER,
1210 ASF_ReadObject_extended_stream_properties,
1211 ASF_FreeObject_extended_stream_properties },
1212 { &asf_object_advanced_mutual_exclusion, ASF_OBJECT_OTHER,
1213 ASF_ReadObject_advanced_mutual_exclusion,
1214 ASF_FreeObject_advanced_mutual_exclusion },
1215 { &asf_object_stream_prioritization, ASF_OBJECT_OTHER,
1216 ASF_ReadObject_stream_prioritization,
1217 ASF_FreeObject_stream_prioritization },
1218 { &asf_object_extended_content_description, ASF_OBJECT_OTHER,
1219 ASF_ReadObject_extended_content_description,
1220 ASF_FreeObject_extended_content_description },
1222 { &asf_object_null_guid, 0, NULL, NULL }
1225 static int ASF_ReadObject( stream_t *s, asf_object_t *p_obj,
1226 asf_object_t *p_father )
1234 memset( p_obj, 0, sizeof( p_obj ) );
1236 if( ASF_ReadObjectCommon( s, p_obj ) )
1238 msg_Warn( s, "cannot read one asf object" );
1239 return VLC_EGENERIC;
1241 p_obj->common.p_father = p_father;
1242 p_obj->common.p_first = NULL;
1243 p_obj->common.p_next = NULL;
1244 p_obj->common.p_last = NULL;
1246 if( p_obj->common.i_object_size < 24 )
1248 msg_Warn( s, "found a corrupted asf object (size<24)" );
1249 return VLC_EGENERIC;
1252 /* find this object */
1253 for( i_index = 0; ; i_index++ )
1255 if( ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
1256 &p_obj->common.i_object_id ) ||
1257 ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
1258 &asf_object_null_guid ) )
1263 p_obj->common.i_type = ASF_Object_Function[i_index].i_type;
1265 /* Now load this object */
1266 if( ASF_Object_Function[i_index].ASF_ReadObject_function == NULL )
1268 msg_Warn( s, "unknown asf object (not loaded)" );
1269 i_result = VLC_SUCCESS;
1273 /* XXX ASF_ReadObject_function realloc *pp_obj XXX */
1275 (ASF_Object_Function[i_index].ASF_ReadObject_function)( s, p_obj );
1278 /* link this object with father */
1281 if( p_father->common.p_first )
1283 p_father->common.p_last->common.p_next = p_obj;
1287 p_father->common.p_first = p_obj;
1289 p_father->common.p_last = p_obj;
1295 static void ASF_FreeObject( stream_t *s, asf_object_t *p_obj )
1298 asf_object_t *p_child;
1300 if( !p_obj ) return;
1302 /* Free all child object */
1303 p_child = p_obj->common.p_first;
1306 asf_object_t *p_next;
1307 p_next = p_child->common.p_next;
1308 ASF_FreeObject( s, p_child );
1312 /* find this object */
1313 for( i_index = 0; ; i_index++ )
1315 if( ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
1316 &p_obj->common.i_object_id )||
1317 ASF_CmpGUID( ASF_Object_Function[i_index].p_id,
1318 &asf_object_null_guid ) )
1324 /* Now free this object */
1325 if( ASF_Object_Function[i_index].ASF_FreeObject_function == NULL )
1328 "unknown asf object " GUID_FMT,
1329 GUID_PRINT( p_obj->common.i_object_id ) );
1335 "free asf object " GUID_FMT,
1336 GUID_PRINT( p_obj->common.i_object_id ) );
1338 (ASF_Object_Function[i_index].ASF_FreeObject_function)( p_obj );
1344 /*****************************************************************************
1345 * ASF_ObjectDumpDebug:
1346 *****************************************************************************/
1351 } ASF_ObjectDumpDebugInfo[] =
1353 { &asf_object_header_guid, "Header" },
1354 { &asf_object_data_guid, "Data" },
1355 { &asf_object_index_guid, "Index" },
1356 { &asf_object_file_properties_guid, "File Properties" },
1357 { &asf_object_stream_properties_guid, "Stream Properties" },
1358 { &asf_object_content_description_guid, "Content Description" },
1359 { &asf_object_header_extension_guid, "Header Extention" },
1360 { &asf_object_metadata_guid, "Metadata" },
1361 { &asf_object_codec_list_guid, "Codec List" },
1362 { &asf_object_marker_guid, "Marker" },
1363 { &asf_object_stream_type_audio, "Stream Type Audio" },
1364 { &asf_object_stream_type_video, "Stream Type Video" },
1365 { &asf_object_stream_type_command, "Stream Type Command" },
1366 { &asf_object_language_list, "Language List" },
1367 { &asf_object_stream_bitrate_properties, "Stream Bitrate Propoerties" },
1368 { &asf_object_padding, "Padding" },
1369 { &asf_object_extended_stream_properties, "Extended Stream Properties" },
1370 { &asf_object_advanced_mutual_exclusion, "Advanced Mutual Exclusion" },
1371 { &asf_object_stream_prioritization, "Stream Prioritization" },
1372 { &asf_object_extended_content_description, "Extended content description"},
1374 { NULL, "Unknown" },
1378 static void ASF_ObjectDumpDebug( vlc_object_t *p_obj,
1379 asf_object_common_t *p_node, int i_level )
1383 union asf_object_u *p_child;
1387 for( i = 0; ASF_ObjectDumpDebugInfo[i].p_id != NULL; i++ )
1389 if( ASF_CmpGUID( ASF_ObjectDumpDebugInfo[i].p_id,
1390 &p_node->i_object_id ) )
1393 psz_name = ASF_ObjectDumpDebugInfo[i].psz_name;
1395 memset( str, ' ', sizeof( str ) );
1396 for( i = 1; i < i_level; i++ )
1400 snprintf( str + 5*i_level, 1024,
1401 "+ '%s' GUID "GUID_FMT" size:"I64Fu"pos:"I64Fu,
1403 GUID_PRINT( p_node->i_object_id ),
1404 p_node->i_object_size, p_node->i_object_pos );
1406 msg_Dbg( p_obj, "%s", str );
1408 for( p_child = p_node->p_first; p_child != NULL;
1409 p_child = p_child->common.p_next )
1411 ASF_ObjectDumpDebug( p_obj, &p_child->common, i_level + 1 );
1415 /*****************************************************************************
1416 * ASF_ReadObjetRoot : parse the entire stream/file
1417 *****************************************************************************/
1418 asf_object_root_t *ASF_ReadObjectRoot( stream_t *s, int b_seekable )
1420 asf_object_root_t *p_root = malloc( sizeof( asf_object_root_t ) );
1421 asf_object_t *p_obj;
1423 p_root->i_type = ASF_OBJECT_ROOT;
1424 memcpy( &p_root->i_object_id, &asf_object_null_guid, sizeof( guid_t ) );
1425 p_root->i_object_pos = stream_Tell( s );
1426 p_root->i_object_size = 0;
1427 p_root->p_first = NULL;
1428 p_root->p_last = NULL;
1429 p_root->p_next = NULL;
1430 p_root->p_hdr = NULL;
1431 p_root->p_data = NULL;
1432 p_root->p_fp = NULL;
1433 p_root->p_index = NULL;
1434 p_root->p_metadata = NULL;
1438 p_obj = malloc( sizeof( asf_object_t ) );
1440 if( ASF_ReadObject( s, p_obj, (asf_object_t*)p_root ) )
1445 switch( p_obj->common.i_type )
1447 case( ASF_OBJECT_HEADER ):
1448 p_root->p_hdr = (asf_object_header_t*)p_obj;
1450 case( ASF_OBJECT_DATA ):
1451 p_root->p_data = (asf_object_data_t*)p_obj;
1453 case( ASF_OBJECT_INDEX ):
1454 p_root->p_index = (asf_object_index_t*)p_obj;
1457 msg_Warn( s, "unknow object found" );
1460 if( p_obj->common.i_type == ASF_OBJECT_DATA &&
1461 p_obj->common.i_object_size <= 50 )
1463 /* probably a dump of broadcasted asf */
1466 if( !b_seekable && p_root->p_hdr && p_root->p_data )
1468 /* For unseekable stream it's enough to play */
1472 if( ASF_NextObject( s, p_obj ) ) /* Go to the next object */
1478 if( p_root->p_hdr != NULL && p_root->p_data != NULL )
1480 p_root->p_fp = ASF_FindObject( p_root->p_hdr,
1481 &asf_object_file_properties_guid, 0 );
1485 asf_object_t *p_hdr_ext =
1486 ASF_FindObject( p_root->p_hdr,
1487 &asf_object_header_extension_guid, 0 );
1493 p_root->p_metadata =
1494 ASF_FindObject( p_hdr_ext,
1495 &asf_object_metadata_guid, 0 );
1496 /* Special case for broken designed file format :( */
1497 i_ext_stream = ASF_CountObject( p_hdr_ext,
1498 &asf_object_extended_stream_properties );
1499 for( i = 0; i < i_ext_stream; i++ )
1501 asf_object_t *p_esp =
1502 ASF_FindObject( p_hdr_ext,
1503 &asf_object_extended_stream_properties, i );
1504 if( p_esp->ext_stream.p_sp )
1506 asf_object_t *p_sp =
1507 (asf_object_t*)p_esp->ext_stream.p_sp;
1509 /* Insert this p_sp */
1510 p_root->p_hdr->p_last->common.p_next = p_sp;
1511 p_root->p_hdr->p_last = p_sp;
1513 p_sp->common.p_father = (asf_object_t*)p_root->p_hdr;
1518 ASF_ObjectDumpDebug( VLC_OBJECT(s),
1519 (asf_object_common_t*)p_root, 0 );
1522 msg_Warn( s, "cannot find file properties object" );
1526 ASF_FreeObjectRoot( s, p_root );
1530 void ASF_FreeObjectRoot( stream_t *s, asf_object_root_t *p_root )
1532 asf_object_t *p_obj;
1534 p_obj = p_root->p_first;
1537 asf_object_t *p_next;
1538 p_next = p_obj->common.p_next;
1539 ASF_FreeObject( s, p_obj );
1545 int __ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid )
1548 asf_object_t *p_child;
1550 if( !p_obj ) return( 0 );
1553 p_child = p_obj->common.p_first;
1556 if( ASF_CmpGUID( &p_child->common.i_object_id, p_guid ) )
1560 p_child = p_child->common.p_next;
1565 void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid,
1568 asf_object_t *p_child;
1570 p_child = p_obj->common.p_first;
1574 if( ASF_CmpGUID( &p_child->common.i_object_id, p_guid ) )
1584 p_child = p_child->common.p_next;