Mercurial > libavformat.hg
comparison mpegts.c @ 2112:e6b06336f94b libavformat
get rid of one layer of callback obfuscation
author | michael |
---|---|
date | Sat, 02 Jun 2007 23:11:17 +0000 |
parents | 4aafc6050f39 |
children | eb0513a0c1b6 |
comparison
equal
deleted
inserted
replaced
2111:4aafc6050f39 | 2112:e6b06336f94b |
---|---|
109 /** number of PMTs in the last PAT seen */ | 109 /** number of PMTs in the last PAT seen */ |
110 int nb_services; | 110 int nb_services; |
111 /** list of PMTs in the last PAT seen */ | 111 /** list of PMTs in the last PAT seen */ |
112 MpegTSService **services; | 112 MpegTSService **services; |
113 | 113 |
114 /* set service context (XXX: allocated it ?) */ | |
115 SetServiceCallback *set_service_cb; | |
116 void *set_service_opaque; | |
117 /** filter for the PAT */ | 114 /** filter for the PAT */ |
118 MpegTSFilter *pat_filter; | 115 MpegTSFilter *pat_filter; |
119 /** filter for the PMT for the MPEG program number specified by req_sid */ | 116 /** filter for the PMT for the MPEG program number specified by req_sid */ |
120 MpegTSFilter *pmt_filter; | 117 MpegTSFilter *pmt_filter; |
121 /** MPEG program number of stream we want to decode */ | 118 /** MPEG program number of stream we want to decode */ |
527 st->codec->sub_id = (anc_page << 16) | comp_page; | 524 st->codec->sub_id = (anc_page << 16) | comp_page; |
528 } | 525 } |
529 } | 526 } |
530 } | 527 } |
531 /* all parameters are there */ | 528 /* all parameters are there */ |
532 ts->set_service_cb(ts->set_service_opaque, 0); | 529 ts->stop_parse=1; |
533 mpegts_close_filter(ts, ts->pmt_filter); | 530 mpegts_close_filter(ts, ts->pmt_filter); |
534 ts->pmt_filter = NULL; | 531 ts->pmt_filter = NULL; |
535 } | 532 } |
536 | 533 |
537 static void pat_cb(void *opaque, const uint8_t *section, int section_len) | 534 static void pat_cb(void *opaque, const uint8_t *section, int section_len) |
571 goto found; | 568 goto found; |
572 } | 569 } |
573 } | 570 } |
574 } | 571 } |
575 /* not found */ | 572 /* not found */ |
576 ts->set_service_cb(ts->set_service_opaque, -1); | 573 ts->stop_parse=1; |
577 | 574 |
578 found: | 575 found: |
579 mpegts_close_filter(ts, ts->pat_filter); | 576 mpegts_close_filter(ts, ts->pat_filter); |
580 ts->pat_filter = NULL; | 577 ts->pat_filter = NULL; |
581 } | 578 } |
631 /* remove filter */ | 628 /* remove filter */ |
632 mpegts_close_filter(ts, ts->pat_filter); | 629 mpegts_close_filter(ts, ts->pat_filter); |
633 ts->pat_filter = NULL; | 630 ts->pat_filter = NULL; |
634 } | 631 } |
635 | 632 |
636 static void mpegts_set_service(MpegTSContext *ts, int sid, | 633 static void mpegts_set_service(MpegTSContext *ts, int sid) |
637 SetServiceCallback *set_service_cb, void *opaque) | 634 { |
638 { | |
639 ts->set_service_cb = set_service_cb; | |
640 ts->set_service_opaque = opaque; | |
641 ts->req_sid = sid; | 635 ts->req_sid = sid; |
642 ts->pat_filter = mpegts_open_section_filter(ts, PAT_PID, | 636 ts->pat_filter = mpegts_open_section_filter(ts, PAT_PID, |
643 pat_cb, ts, 1); | 637 pat_cb, ts, 1); |
644 } | 638 } |
645 | 639 |
1156 else | 1150 else |
1157 return 0; | 1151 return 0; |
1158 #endif | 1152 #endif |
1159 } | 1153 } |
1160 | 1154 |
1161 static void set_service_cb(void *opaque, int ret) | |
1162 { | |
1163 MpegTSContext *ts = opaque; | |
1164 ts->stop_parse = 1; | |
1165 } | |
1166 | |
1167 /* return the 90 kHz PCR and the extension for the 27 MHz PCR. return | 1155 /* return the 90 kHz PCR and the extension for the 27 MHz PCR. return |
1168 (-1) if not available */ | 1156 (-1) if not available */ |
1169 static int parse_pcr(int64_t *ppcr_high, int *ppcr_low, | 1157 static int parse_pcr(int64_t *ppcr_high, int *ppcr_low, |
1170 const uint8_t *packet) | 1158 const uint8_t *packet) |
1171 { | 1159 { |
1264 | 1252 |
1265 /* now find the info for the first service if we found any, | 1253 /* now find the info for the first service if we found any, |
1266 otherwise try to filter all PATs */ | 1254 otherwise try to filter all PATs */ |
1267 | 1255 |
1268 url_fseek(pb, pos, SEEK_SET); | 1256 url_fseek(pb, pos, SEEK_SET); |
1269 mpegts_set_service(ts, sid, set_service_cb, ts); | 1257 mpegts_set_service(ts, sid); |
1270 | 1258 |
1271 handle_packets(ts, s->probesize); | 1259 handle_packets(ts, s->probesize); |
1272 } | 1260 } |
1273 /* if could not find service, enable auto_guess */ | 1261 /* if could not find service, enable auto_guess */ |
1274 | 1262 |