3 // Andrew Bachmann, 2002
5 // Some functions for general debugging and
6 // working around be media kit bugs.
11 // -------------------------------------------------------- //
13 // -------------------------------------------------------- //
15 void print_multistream_format(media_multistream_format
* format
) {
17 switch (format
->format
) {
18 case media_multistream_format::B_ANY
: fprintf(stderr
,"ANY"); break;
19 case media_multistream_format::B_VID
: fprintf(stderr
,"VID"); break;
20 case media_multistream_format::B_AVI
: fprintf(stderr
,"AVI"); break;
21 case media_multistream_format::B_MPEG1
: fprintf(stderr
,"MPEG1"); break;
22 case media_multistream_format::B_MPEG2
: fprintf(stderr
,"MPEG2"); break;
23 case media_multistream_format::B_QUICKTIME
: fprintf(stderr
,"QUICKTIME"); break;
24 default: fprintf(stderr
,"????"); break;
26 fprintf(stderr
," avg_bit_rate(%f) max_bit_rate(%f)",
27 format
->avg_bit_rate
,format
->max_bit_rate
);
28 fprintf(stderr
," avg_chunk_size(%i) max_chunk_size(%i)",
29 format
->avg_chunk_size
,format
->max_chunk_size
);
32 void print_media_format(media_format
* format
) {
34 switch (format
->type
) {
35 case B_MEDIA_NO_TYPE
: fprintf(stderr
,"NO_TYPE"); break;
36 case B_MEDIA_UNKNOWN_TYPE
: fprintf(stderr
,"UNKNOWN_TYPE"); break;
37 case B_MEDIA_RAW_AUDIO
: fprintf(stderr
,"RAW_AUDIO"); break;
38 case B_MEDIA_RAW_VIDEO
: fprintf(stderr
,"RAW_VIDEO"); break;
39 case B_MEDIA_VBL
: fprintf(stderr
,"VBL"); break;
40 case B_MEDIA_TIMECODE
: fprintf(stderr
,"TIMECODE"); break;
41 case B_MEDIA_MIDI
: fprintf(stderr
,"MIDI"); break;
42 case B_MEDIA_TEXT
: fprintf(stderr
,"TEXT"); break;
43 case B_MEDIA_HTML
: fprintf(stderr
,"HTML"); break;
44 case B_MEDIA_MULTISTREAM
: fprintf(stderr
,"MULTISTREAM"); break;
45 case B_MEDIA_PARAMETERS
: fprintf(stderr
,"PARAMETERS"); break;
46 case B_MEDIA_ENCODED_AUDIO
: fprintf(stderr
,"ENCODED_AUDIO"); break;
47 case B_MEDIA_ENCODED_VIDEO
: fprintf(stderr
,"ENCODED_VIDEO"); break;
48 default: fprintf(stderr
,"????"); break;
51 switch (format
->type
) {
52 case B_MEDIA_RAW_AUDIO
: fprintf(stderr
,"RAW_AUDIO"); break;
53 case B_MEDIA_RAW_VIDEO
: fprintf(stderr
,"RAW_VIDEO"); break;
54 case B_MEDIA_MULTISTREAM
: print_multistream_format(&format
->u
.multistream
); break;
55 case B_MEDIA_ENCODED_AUDIO
: fprintf(stderr
,"ENCODED_AUDIO"); break;
56 case B_MEDIA_ENCODED_VIDEO
: fprintf(stderr
,"ENCODED_VIDEO"); break;
57 default: fprintf(stderr
,"????"); break;
62 bool multistream_format_is_acceptible(
63 const media_multistream_format
& producer_format
,
64 const media_multistream_format
& consumer_format
)
66 // first check the format, if necessary
67 if (consumer_format
.format
!= media_multistream_format::B_ANY
) {
68 if (consumer_format
.format
!= producer_format
.format
) {
72 // then check the average bit rate
73 if (consumer_format
.avg_bit_rate
!= media_multistream_format::wildcard
.avg_bit_rate
) {
74 if (consumer_format
.avg_bit_rate
!= producer_format
.avg_bit_rate
) {
75 // do they have to match exactly? I don't know. assume yes.
79 // then check the maximum bit rate
80 if (consumer_format
.max_bit_rate
!= media_multistream_format::wildcard
.max_bit_rate
) {
81 if (consumer_format
.max_bit_rate
!= producer_format
.max_bit_rate
) {
82 // do they have to match exactly? I don't know. assume yes.
86 // then check the average chunk size
87 if (consumer_format
.avg_chunk_size
!= media_multistream_format::wildcard
.avg_chunk_size
) {
88 if (consumer_format
.avg_chunk_size
!= producer_format
.avg_chunk_size
) {
89 // do they have to match exactly? I don't know. assume yes.
93 // then check the maximum bit rate
94 if (consumer_format
.max_chunk_size
!= media_multistream_format::wildcard
.max_chunk_size
) {
95 if (consumer_format
.max_chunk_size
!= producer_format
.max_chunk_size
) {
96 // do they have to match exactly? I don't know. assume yes.
100 // should also check format specific fields, and others?
104 bool format_is_acceptible(
105 const media_format
& producer_format
,
106 const media_format
& consumer_format
)
108 // first check the type, if necessary
109 if (consumer_format
.type
!= B_MEDIA_UNKNOWN_TYPE
) {
110 if (consumer_format
.type
!= producer_format
.type
) {
113 switch (consumer_format
.type
) {
114 case B_MEDIA_MULTISTREAM
:
115 if (!multistream_format_is_acceptible(producer_format
.u
.multistream
,
116 consumer_format
.u
.multistream
)) {
121 fprintf(stderr
,"format_is_acceptible : unimplemented type.\n");
122 return format_is_compatible(producer_format
,consumer_format
);
126 // should also check non-type fields?