comparison mpegts.c @ 2136:b53a19eed95d libavformat

remove duplicate PAT scaning code and actual PAT scan also disabling the nonsense 3yr old rawts change (it would after the above chage totally break the demuxer if its left enabled)
author michael
date Mon, 04 Jun 2007 14:44:52 +0000
parents 9387d2dce86f
children f68b81777ac6
comparison
equal deleted inserted replaced
2135:9387d2dce86f 2136:b53a19eed95d
598 av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid); 598 av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid);
599 #endif 599 #endif
600 if (sid == 0x0000) { 600 if (sid == 0x0000) {
601 /* NIT info */ 601 /* NIT info */
602 } else { 602 } else {
603 new_service(ts, sid, NULL, NULL);
603 ts->stop_parse--; 604 ts->stop_parse--;
604 mpegts_open_section_filter(ts, pmt_pid, 605 mpegts_open_section_filter(ts, pmt_pid,
605 pmt_cb, ts, 1); 606 pmt_cb, ts, 1);
606 } 607 }
607 } 608 }
608 /* not found */ 609 /* not found */
609 ts->stop_parse++; 610 ts->stop_parse++;
610 611
611 mpegts_close_filter(ts, filter);
612 }
613
614 /* add all services found in the PAT */
615 static void pat_scan_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
616 {
617 MpegTSContext *ts = filter->u.section_filter.opaque;
618 SectionHeader h1, *h = &h1;
619 const uint8_t *p, *p_end;
620 int sid, pmt_pid;
621
622 #ifdef DEBUG_SI
623 av_log(ts->stream, AV_LOG_DEBUG, "PAT:\n");
624 av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len);
625 #endif
626 p_end = section + section_len - 4;
627 p = section;
628 if (parse_section_header(h, &p, p_end) < 0)
629 return;
630 if (h->tid != PAT_TID)
631 return;
632
633 for(;;) {
634 sid = get16(&p, p_end);
635 if (sid < 0)
636 break;
637 pmt_pid = get16(&p, p_end) & 0x1fff;
638 if (pmt_pid < 0)
639 break;
640 #ifdef DEBUG_SI
641 av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid);
642 #endif
643 if (sid == 0x0000) {
644 /* NIT info */
645 } else {
646 new_service(ts, sid, NULL, NULL);
647 }
648 }
649 ts->stop_parse = 1;
650
651 /* remove filter */
652 mpegts_close_filter(ts, filter); 612 mpegts_close_filter(ts, filter);
653 } 613 }
654 614
655 static void mpegts_set_service(MpegTSContext *ts) 615 static void mpegts_set_service(MpegTSContext *ts)
656 { 616 {
733 /* scan services in a transport stream by looking at the SDT */ 693 /* scan services in a transport stream by looking at the SDT */
734 static void mpegts_scan_sdt(MpegTSContext *ts) 694 static void mpegts_scan_sdt(MpegTSContext *ts)
735 { 695 {
736 mpegts_open_section_filter(ts, SDT_PID, 696 mpegts_open_section_filter(ts, SDT_PID,
737 sdt_cb, ts, 1); 697 sdt_cb, ts, 1);
738 }
739
740 /* scan services in a transport stream by looking at the PAT (better
741 than nothing !) */
742 static void mpegts_scan_pat(MpegTSContext *ts)
743 {
744 mpegts_open_section_filter(ts, PAT_PID,
745 pat_scan_cb, ts, 1);
746 } 698 }
747 699
748 static int64_t get_pts(const uint8_t *p) 700 static int64_t get_pts(const uint8_t *p)
749 { 701 {
750 int64_t pts; 702 int64_t pts;
1202 1154
1203 /* first do a scaning to get all the services */ 1155 /* first do a scaning to get all the services */
1204 url_fseek(pb, pos, SEEK_SET); 1156 url_fseek(pb, pos, SEEK_SET);
1205 mpegts_scan_sdt(ts); 1157 mpegts_scan_sdt(ts);
1206 1158
1207 if (ts->nb_services <= 0) { 1159 if (ts->nb_services <= 0 && 0) {
1208 mpegts_scan_pat(ts);
1209
1210 handle_packets(ts, s->probesize);
1211 }
1212
1213 if (ts->nb_services <= 0) {
1214 /* raw transport stream */ 1160 /* raw transport stream */
1215 ts->auto_guess = 1; 1161 ts->auto_guess = 1;
1216 s->ctx_flags |= AVFMTCTX_NOHEADER; 1162 s->ctx_flags |= AVFMTCTX_NOHEADER;
1217 goto do_pcr; 1163 goto do_pcr;
1218 } 1164 }
1219 1165
1220 url_fseek(pb, pos, SEEK_SET);
1221 mpegts_set_service(ts); 1166 mpegts_set_service(ts);
1222 1167
1223 handle_packets(ts, s->probesize); 1168 handle_packets(ts, s->probesize);
1224 /* if could not find service, enable auto_guess */ 1169 /* if could not find service, enable auto_guess */
1225 1170