Mercurial > libavformat.hg
comparison asf.c @ 904:5d3dc3a6bbe7 libavformat
audio in dvr-ms demuxing support by (John Donaghy <johnfdonaghy gmail com<)
author | michael |
---|---|
date | Fri, 20 Jan 2006 23:48:16 +0000 |
parents | edbe5c3717f9 |
children | 0566e2d915ef |
comparison
equal
deleted
inserted
replaced
903:68bc3ca12e79 | 904:5d3dc3a6bbe7 |
---|---|
58 else PRINT_IF_GUID(g, data_header); | 58 else PRINT_IF_GUID(g, data_header); |
59 else PRINT_IF_GUID(g, index_guid); | 59 else PRINT_IF_GUID(g, index_guid); |
60 else PRINT_IF_GUID(g, head1_guid); | 60 else PRINT_IF_GUID(g, head1_guid); |
61 else PRINT_IF_GUID(g, head2_guid); | 61 else PRINT_IF_GUID(g, head2_guid); |
62 else PRINT_IF_GUID(g, my_guid); | 62 else PRINT_IF_GUID(g, my_guid); |
63 else PRINT_IF_GUID(g, ext_stream_header); | |
64 else PRINT_IF_GUID(g, extended_content_header); | |
65 else PRINT_IF_GUID(g, ext_stream_embed_stream_header); | |
66 else PRINT_IF_GUID(g, ext_stream_audio_stream); | |
63 else | 67 else |
64 printf("(GUID: unknown) "); | 68 printf("(GUID: unknown) "); |
65 printf("0x%08x, 0x%04x, 0x%04x, {", g->v1, g->v2, g->v3); | 69 printf("0x%08x, 0x%04x, 0x%04x, {", g->v1, g->v2, g->v3); |
66 for(i=0;i<8;i++) | 70 for(i=0;i<8;i++) |
67 printf(" 0x%02x,", g->v4[i]); | 71 printf(" 0x%02x,", g->v4[i]); |
184 asf->nb_packets = asf->hdr.packets_count; | 188 asf->nb_packets = asf->hdr.packets_count; |
185 } else if (!memcmp(&g, &stream_header, sizeof(GUID))) { | 189 } else if (!memcmp(&g, &stream_header, sizeof(GUID))) { |
186 int type, total_size, type_specific_size, sizeX; | 190 int type, total_size, type_specific_size, sizeX; |
187 unsigned int tag1; | 191 unsigned int tag1; |
188 int64_t pos1, pos2; | 192 int64_t pos1, pos2; |
193 int test_for_ext_stream_audio; | |
189 | 194 |
190 pos1 = url_ftell(pb); | 195 pos1 = url_ftell(pb); |
191 | 196 |
192 st = av_new_stream(s, 0); | 197 st = av_new_stream(s, 0); |
193 if (!st) | 198 if (!st) |
199 st->priv_data = asf_st; | 204 st->priv_data = asf_st; |
200 st->start_time = asf->hdr.preroll; | 205 st->start_time = asf->hdr.preroll; |
201 st->duration = asf->hdr.send_time / | 206 st->duration = asf->hdr.send_time / |
202 (10000000 / 1000) - st->start_time; | 207 (10000000 / 1000) - st->start_time; |
203 get_guid(pb, &g); | 208 get_guid(pb, &g); |
209 | |
210 test_for_ext_stream_audio = 0; | |
204 if (!memcmp(&g, &audio_stream, sizeof(GUID))) { | 211 if (!memcmp(&g, &audio_stream, sizeof(GUID))) { |
205 type = CODEC_TYPE_AUDIO; | 212 type = CODEC_TYPE_AUDIO; |
206 } else if (!memcmp(&g, &video_stream, sizeof(GUID))) { | 213 } else if (!memcmp(&g, &video_stream, sizeof(GUID))) { |
207 type = CODEC_TYPE_VIDEO; | 214 type = CODEC_TYPE_VIDEO; |
208 } else if (!memcmp(&g, &command_stream, sizeof(GUID))) { | 215 } else if (!memcmp(&g, &command_stream, sizeof(GUID))) { |
209 type = CODEC_TYPE_UNKNOWN; | 216 type = CODEC_TYPE_UNKNOWN; |
217 } else if (!memcmp(&g, &ext_stream_embed_stream_header, sizeof(GUID))) { | |
218 test_for_ext_stream_audio = 1; | |
219 type = CODEC_TYPE_UNKNOWN; | |
210 } else { | 220 } else { |
211 goto fail; | 221 goto fail; |
212 } | 222 } |
213 get_guid(pb, &g); | 223 get_guid(pb, &g); |
214 total_size = get_le64(pb); | 224 total_size = get_le64(pb); |
217 st->id = get_le16(pb) & 0x7f; /* stream id */ | 227 st->id = get_le16(pb) & 0x7f; /* stream id */ |
218 // mapping of asf ID to AV stream ID; | 228 // mapping of asf ID to AV stream ID; |
219 asf->asfid2avid[st->id] = s->nb_streams - 1; | 229 asf->asfid2avid[st->id] = s->nb_streams - 1; |
220 | 230 |
221 get_le32(pb); | 231 get_le32(pb); |
232 | |
233 if (test_for_ext_stream_audio) { | |
234 get_guid(pb, &g); | |
235 if (!memcmp(&g, &ext_stream_audio_stream, sizeof(GUID))) { | |
236 type = CODEC_TYPE_AUDIO; | |
237 get_guid(pb, &g); | |
238 get_le32(pb); | |
239 get_le32(pb); | |
240 get_le32(pb); | |
241 get_guid(pb, &g); | |
242 get_le32(pb); | |
243 } | |
244 } | |
245 | |
222 st->codec->codec_type = type; | 246 st->codec->codec_type = type; |
223 if (type == CODEC_TYPE_AUDIO) { | 247 if (type == CODEC_TYPE_AUDIO) { |
224 get_wav_header(pb, st->codec, type_specific_size); | 248 get_wav_header(pb, st->codec, type_specific_size); |
225 st->need_parsing = 1; | 249 st->need_parsing = 1; |
226 /* We have to init the frame size at some point .... */ | 250 /* We have to init the frame size at some point .... */ |
257 default: | 281 default: |
258 /* This is probably wrong, but it prevents a crash later */ | 282 /* This is probably wrong, but it prevents a crash later */ |
259 st->codec->frame_size = 1; | 283 st->codec->frame_size = 1; |
260 break; | 284 break; |
261 } | 285 } |
262 } else { | 286 } else if (type == CODEC_TYPE_VIDEO) { |
263 get_le32(pb); | 287 get_le32(pb); |
264 get_le32(pb); | 288 get_le32(pb); |
265 get_byte(pb); | 289 get_byte(pb); |
266 size = get_le16(pb); /* size */ | 290 size = get_le16(pb); /* size */ |
267 sizeX= get_le32(pb); /* size */ | 291 sizeX= get_le32(pb); /* size */ |
347 if (strcmp(name,"WM/Track")==0) s->track = value_num + 1; | 371 if (strcmp(name,"WM/Track")==0) s->track = value_num + 1; |
348 if (strcmp(name,"WM/TrackNumber")==0) s->track = value_num; | 372 if (strcmp(name,"WM/TrackNumber")==0) s->track = value_num; |
349 } | 373 } |
350 av_free(name); | 374 av_free(name); |
351 } | 375 } |
352 #if 0 | 376 } else if (!memcmp(&g, &ext_stream_header, sizeof(GUID))) { |
377 int ext_len, payload_ext_ct, stream_ct; | |
378 uint32_t ext_d; | |
379 int64_t pos_ex_st, pos_curr; | |
380 pos_ex_st = url_ftell(pb); | |
381 | |
382 get_le64(pb); | |
383 get_le64(pb); | |
384 get_le32(pb); | |
385 get_le32(pb); | |
386 get_le32(pb); | |
387 get_le32(pb); | |
388 get_le32(pb); | |
389 get_le32(pb); | |
390 get_le32(pb); | |
391 get_le32(pb); | |
392 get_le16(pb); | |
393 get_le16(pb); | |
394 get_le64(pb); | |
395 stream_ct = get_le16(pb); | |
396 payload_ext_ct = get_le16(pb); | |
397 | |
398 for (i=0; i<stream_ct; i++){ | |
399 get_le16(pb); | |
400 ext_len = get_le16(pb); | |
401 url_fseek(pb, ext_len, SEEK_CUR); | |
402 } | |
403 | |
404 for (i=0; i<payload_ext_ct; i++){ | |
405 get_guid(pb, &g); | |
406 ext_d=get_le16(pb); | |
407 ext_len=get_le32(pb); | |
408 url_fseek(pb, ext_len, SEEK_CUR); | |
409 } | |
410 | |
411 // there could be a optional stream properties object to follow | |
412 // if so the next iteration will pick it up | |
353 } else if (!memcmp(&g, &head1_guid, sizeof(GUID))) { | 413 } else if (!memcmp(&g, &head1_guid, sizeof(GUID))) { |
354 int v1, v2; | 414 int v1, v2; |
355 get_guid(pb, &g); | 415 get_guid(pb, &g); |
356 v1 = get_le32(pb); | 416 v1 = get_le32(pb); |
357 v2 = get_le16(pb); | 417 v2 = get_le16(pb); |
418 #if 0 | |
358 } else if (!memcmp(&g, &codec_comment_header, sizeof(GUID))) { | 419 } else if (!memcmp(&g, &codec_comment_header, sizeof(GUID))) { |
359 int len, v1, n, num; | 420 int len, v1, n, num; |
360 char str[256], *q; | 421 char str[256], *q; |
361 char tag[16]; | 422 char tag[16]; |
362 | 423 |