Mercurial > libavformat.hg
comparison mpegts.c @ 1724:940907f49a33 libavformat
"converts printf's to avlog's" patch by Daniel Kristjansson / danielk mrl.nyu edu
another 1 year old patch forgoten by mans
trailing whitespace removial by me
author | michael |
---|---|
date | Tue, 23 Jan 2007 21:41:30 +0000 |
parents | 08322a7e3804 |
children | 63bb140936c0 |
comparison
equal
deleted
inserted
replaced
1723:3c592c941858 | 1724:940907f49a33 |
---|---|
160 { | 160 { |
161 MpegTSFilter *filter; | 161 MpegTSFilter *filter; |
162 MpegTSSectionFilter *sec; | 162 MpegTSSectionFilter *sec; |
163 | 163 |
164 #ifdef DEBUG_SI | 164 #ifdef DEBUG_SI |
165 printf("Filter: pid=0x%x\n", pid); | 165 av_log(NULL, AV_LOG_DEBUG, "Filter: pid=0x%x\n", pid); |
166 #endif | 166 #endif |
167 if (pid >= NB_PID_MAX || ts->pids[pid]) | 167 if (pid >= NB_PID_MAX || ts->pids[pid]) |
168 return NULL; | 168 return NULL; |
169 filter = av_mallocz(sizeof(MpegTSFilter)); | 169 filter = av_mallocz(sizeof(MpegTSFilter)); |
170 if (!filter) | 170 if (!filter) |
355 char *provider_name, char *name) | 355 char *provider_name, char *name) |
356 { | 356 { |
357 MpegTSService *service; | 357 MpegTSService *service; |
358 | 358 |
359 #ifdef DEBUG_SI | 359 #ifdef DEBUG_SI |
360 printf("new_service: sid=0x%04x provider='%s' name='%s'\n", | 360 av_log(NULL, AV_LOG_DEBUG, "new_service: " |
361 "sid=0x%04x provider='%s' name='%s'\n", | |
361 sid, provider_name, name); | 362 sid, provider_name, name); |
362 #endif | 363 #endif |
363 | 364 |
364 service = av_mallocz(sizeof(MpegTSService)); | 365 service = av_mallocz(sizeof(MpegTSService)); |
365 if (!service) | 366 if (!service) |
382 int desc_list_len, desc_len, desc_tag; | 383 int desc_list_len, desc_len, desc_tag; |
383 int comp_page = 0, anc_page = 0; /* initialize to kill warnings */ | 384 int comp_page = 0, anc_page = 0; /* initialize to kill warnings */ |
384 char language[4]; | 385 char language[4]; |
385 | 386 |
386 #ifdef DEBUG_SI | 387 #ifdef DEBUG_SI |
387 printf("PMT:\n"); | 388 av_log(NULL, AV_LOG_DEBUG, "PMT: len %i\n", section_len); |
388 av_hex_dump(stdout, (uint8_t *)section, section_len); | 389 av_hex_dump(stdout, (uint8_t *)section, section_len); |
389 #endif | 390 #endif |
390 p_end = section + section_len - 4; | 391 p_end = section + section_len - 4; |
391 p = section; | 392 p = section; |
392 if (parse_section_header(h, &p, p_end) < 0) | 393 if (parse_section_header(h, &p, p_end) < 0) |
393 return; | 394 return; |
394 #ifdef DEBUG_SI | 395 #ifdef DEBUG_SI |
395 printf("sid=0x%x sec_num=%d/%d\n", h->id, h->sec_num, h->last_sec_num); | 396 av_log(NULL, AV_LOG_DEBUG, "sid=0x%x sec_num=%d/%d\n", |
397 h->id, h->sec_num, h->last_sec_num); | |
396 #endif | 398 #endif |
397 if (h->tid != PMT_TID || (ts->req_sid >= 0 && h->id != ts->req_sid) ) | 399 if (h->tid != PMT_TID || (ts->req_sid >= 0 && h->id != ts->req_sid) ) |
398 return; | 400 return; |
399 | 401 |
400 pcr_pid = get16(&p, p_end) & 0x1fff; | 402 pcr_pid = get16(&p, p_end) & 0x1fff; |
401 if (pcr_pid < 0) | 403 if (pcr_pid < 0) |
402 return; | 404 return; |
403 ts->pcr_pid = pcr_pid; | 405 ts->pcr_pid = pcr_pid; |
404 #ifdef DEBUG_SI | 406 #ifdef DEBUG_SI |
405 printf("pcr_pid=0x%x\n", pcr_pid); | 407 av_log(NULL, AV_LOG_DEBUG, "pcr_pid=0x%x\n", pcr_pid); |
406 #endif | 408 #endif |
407 program_info_length = get16(&p, p_end) & 0xfff; | 409 program_info_length = get16(&p, p_end) & 0xfff; |
408 if (program_info_length < 0) | 410 if (program_info_length < 0) |
409 return; | 411 return; |
410 p += program_info_length; | 412 p += program_info_length; |
441 desc_len = get8(&p, desc_list_end); | 443 desc_len = get8(&p, desc_list_end); |
442 desc_end = p + desc_len; | 444 desc_end = p + desc_len; |
443 if (desc_end > desc_list_end) | 445 if (desc_end > desc_list_end) |
444 break; | 446 break; |
445 #ifdef DEBUG_SI | 447 #ifdef DEBUG_SI |
446 printf("tag: 0x%02x len=%d\n", desc_tag, desc_len); | 448 av_log(NULL, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n", |
449 desc_tag, desc_len); | |
447 #endif | 450 #endif |
448 switch(desc_tag) { | 451 switch(desc_tag) { |
449 case DVB_SUBT_DESCID: | 452 case DVB_SUBT_DESCID: |
450 if (stream_type == STREAM_TYPE_PRIVATE_DATA) | 453 if (stream_type == STREAM_TYPE_PRIVATE_DATA) |
451 stream_type = STREAM_TYPE_SUBTITLE_DVB; | 454 stream_type = STREAM_TYPE_SUBTITLE_DVB; |
471 p = desc_end; | 474 p = desc_end; |
472 } | 475 } |
473 p = desc_list_end; | 476 p = desc_list_end; |
474 | 477 |
475 #ifdef DEBUG_SI | 478 #ifdef DEBUG_SI |
476 printf("stream_type=%d pid=0x%x\n", stream_type, pid); | 479 av_log(NULL, AV_LOG_DEBUG, "stream_type=%d pid=0x%x\n", |
480 stream_type, pid); | |
477 #endif | 481 #endif |
478 | 482 |
479 /* now create ffmpeg stream */ | 483 /* now create ffmpeg stream */ |
480 switch(stream_type) { | 484 switch(stream_type) { |
481 case STREAM_TYPE_AUDIO_MPEG1: | 485 case STREAM_TYPE_AUDIO_MPEG1: |
522 SectionHeader h1, *h = &h1; | 526 SectionHeader h1, *h = &h1; |
523 const uint8_t *p, *p_end; | 527 const uint8_t *p, *p_end; |
524 int sid, pmt_pid; | 528 int sid, pmt_pid; |
525 | 529 |
526 #ifdef DEBUG_SI | 530 #ifdef DEBUG_SI |
527 printf("PAT:\n"); | 531 av_log(NULL, AV_LOG_DEBUG, "PAT:\n"); |
528 av_hex_dump(stdout, (uint8_t *)section, section_len); | 532 av_hex_dump(stdout, (uint8_t *)section, section_len); |
529 #endif | 533 #endif |
530 p_end = section + section_len - 4; | 534 p_end = section + section_len - 4; |
531 p = section; | 535 p = section; |
532 if (parse_section_header(h, &p, p_end) < 0) | 536 if (parse_section_header(h, &p, p_end) < 0) |
540 break; | 544 break; |
541 pmt_pid = get16(&p, p_end) & 0x1fff; | 545 pmt_pid = get16(&p, p_end) & 0x1fff; |
542 if (pmt_pid < 0) | 546 if (pmt_pid < 0) |
543 break; | 547 break; |
544 #ifdef DEBUG_SI | 548 #ifdef DEBUG_SI |
545 printf("sid=0x%x pid=0x%x\n", sid, pmt_pid); | 549 av_log(NULL, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid); |
546 #endif | 550 #endif |
547 if (sid == 0x0000) { | 551 if (sid == 0x0000) { |
548 /* NIT info */ | 552 /* NIT info */ |
549 } else { | 553 } else { |
550 if (ts->req_sid == sid) { | 554 if (ts->req_sid == sid) { |
571 int sid, pmt_pid; | 575 int sid, pmt_pid; |
572 char *provider_name, *name; | 576 char *provider_name, *name; |
573 char buf[256]; | 577 char buf[256]; |
574 | 578 |
575 #ifdef DEBUG_SI | 579 #ifdef DEBUG_SI |
576 printf("PAT:\n"); | 580 av_log(NULL, AV_LOG_DEBUG, "PAT:\n"); |
577 av_hex_dump(stdout, (uint8_t *)section, section_len); | 581 av_hex_dump(stdout, (uint8_t *)section, section_len); |
578 #endif | 582 #endif |
579 p_end = section + section_len - 4; | 583 p_end = section + section_len - 4; |
580 p = section; | 584 p = section; |
581 if (parse_section_header(h, &p, p_end) < 0) | 585 if (parse_section_header(h, &p, p_end) < 0) |
589 break; | 593 break; |
590 pmt_pid = get16(&p, p_end) & 0x1fff; | 594 pmt_pid = get16(&p, p_end) & 0x1fff; |
591 if (pmt_pid < 0) | 595 if (pmt_pid < 0) |
592 break; | 596 break; |
593 #ifdef DEBUG_SI | 597 #ifdef DEBUG_SI |
594 printf("sid=0x%x pid=0x%x\n", sid, pmt_pid); | 598 av_log(NULL, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid); |
595 #endif | 599 #endif |
596 if (sid == 0x0000) { | 600 if (sid == 0x0000) { |
597 /* NIT info */ | 601 /* NIT info */ |
598 } else { | 602 } else { |
599 /* add the service with a dummy name */ | 603 /* add the service with a dummy name */ |
632 const uint8_t *p, *p_end, *desc_list_end, *desc_end; | 636 const uint8_t *p, *p_end, *desc_list_end, *desc_end; |
633 int onid, val, sid, desc_list_len, desc_tag, desc_len, service_type; | 637 int onid, val, sid, desc_list_len, desc_tag, desc_len, service_type; |
634 char *name, *provider_name; | 638 char *name, *provider_name; |
635 | 639 |
636 #ifdef DEBUG_SI | 640 #ifdef DEBUG_SI |
637 printf("SDT:\n"); | 641 av_log(NULL, AV_LOG_DEBUG, "SDT:\n"); |
638 av_hex_dump(stdout, (uint8_t *)section, section_len); | 642 av_hex_dump(stdout, (uint8_t *)section, section_len); |
639 #endif | 643 #endif |
640 | 644 |
641 p_end = section + section_len - 4; | 645 p_end = section + section_len - 4; |
642 p = section; | 646 p = section; |
670 desc_len = get8(&p, desc_list_end); | 674 desc_len = get8(&p, desc_list_end); |
671 desc_end = p + desc_len; | 675 desc_end = p + desc_len; |
672 if (desc_end > desc_list_end) | 676 if (desc_end > desc_list_end) |
673 break; | 677 break; |
674 #ifdef DEBUG_SI | 678 #ifdef DEBUG_SI |
675 printf("tag: 0x%02x len=%d\n", desc_tag, desc_len); | 679 av_log(NULL, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n", |
680 desc_tag, desc_len); | |
676 #endif | 681 #endif |
677 switch(desc_tag) { | 682 switch(desc_tag) { |
678 case 0x48: | 683 case 0x48: |
679 service_type = get8(&p, p_end); | 684 service_type = get8(&p, p_end); |
680 if (service_type < 0) | 685 if (service_type < 0) |
1232 /* tune to first service found */ | 1237 /* tune to first service found */ |
1233 for(i=0; i<ts->nb_services && ts->set_service_ret; i++){ | 1238 for(i=0; i<ts->nb_services && ts->set_service_ret; i++){ |
1234 service = ts->services[i]; | 1239 service = ts->services[i]; |
1235 sid = service->sid; | 1240 sid = service->sid; |
1236 #ifdef DEBUG_SI | 1241 #ifdef DEBUG_SI |
1237 printf("tuning to '%s'\n", service->name); | 1242 av_log(NULL, AV_LOG_DEBUG, "tuning to '%s'\n", service->name); |
1238 #endif | 1243 #endif |
1239 | 1244 |
1240 /* now find the info for the first service if we found any, | 1245 /* now find the info for the first service if we found any, |
1241 otherwise try to filter all PATs */ | 1246 otherwise try to filter all PATs */ |
1242 | 1247 |
1256 goto goto_auto_guess; | 1261 goto goto_auto_guess; |
1257 } | 1262 } |
1258 } | 1263 } |
1259 | 1264 |
1260 #ifdef DEBUG_SI | 1265 #ifdef DEBUG_SI |
1261 printf("tuning done\n"); | 1266 av_log(NULL, AV_LOG_DEBUG, "tuning done\n"); |
1262 #endif | 1267 #endif |
1263 } | 1268 } |
1264 s->ctx_flags |= AVFMTCTX_NOHEADER; | 1269 s->ctx_flags |= AVFMTCTX_NOHEADER; |
1265 } else { | 1270 } else { |
1266 AVStream *st; | 1271 AVStream *st; |
1307 ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; | 1312 ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; |
1308 s->bit_rate = (TS_PACKET_SIZE * 8) * 27e6 / ts->pcr_incr; | 1313 s->bit_rate = (TS_PACKET_SIZE * 8) * 27e6 / ts->pcr_incr; |
1309 st->codec->bit_rate = s->bit_rate; | 1314 st->codec->bit_rate = s->bit_rate; |
1310 st->start_time = ts->cur_pcr; | 1315 st->start_time = ts->cur_pcr; |
1311 #if 0 | 1316 #if 0 |
1312 printf("start=%0.3f pcr=%0.3f incr=%d\n", | 1317 av_log(NULL, AV_LOG_DEBUG, "start=%0.3f pcr=%0.3f incr=%d\n", |
1313 st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr); | 1318 st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr); |
1314 #endif | 1319 #endif |
1315 } | 1320 } |
1316 | 1321 |
1317 url_fseek(pb, pos, SEEK_SET); | 1322 url_fseek(pb, pos, SEEK_SET); |