#include "libavutil/crc.h"#include "avformat.h"#include "mpegts.h"Go to the source code of this file.
Data Structures | |
| struct | MpegTSPESFilter |
| struct | MpegTSSectionFilter |
| struct | MpegTSFilter |
| struct | Program_t |
| struct | MpegTSContext |
| struct | PESContext |
| struct | SectionHeader |
Defines | |
| #define | MAX_SCAN_PACKETS 32000 |
| #define | MAX_RESYNC_SIZE 4096 |
| #define | REGISTRATION_DESCRIPTOR 5 |
| #define | MAX_PIDS_PER_PROGRAM 64 |
| #define | PES_START_SIZE 9 |
| #define | MAX_PES_HEADER_SIZE (9 + 255) |
| #define | CHECK_COUNT 10 |
| #define | MAX_PACKET_READAHEAD ((128 * 1024) / 188) |
Typedefs | |
| typedef PESContext | PESContext |
| typedef MpegTSFilter | MpegTSFilter |
| typedef void | PESCallback (MpegTSFilter *f, const uint8_t *buf, int len, int is_start) |
| typedef void | SectionCallback (MpegTSFilter *f, const uint8_t *buf, int len) |
| typedef void | SetServiceCallback (void *opaque, int ret) |
Enumerations | |
| enum | MpegTSFilterType { MPEGTS_PES, MPEGTS_SECTION } |
| enum | MpegTSState { MPEGTS_HEADER = 0, MPEGTS_PESHEADER_FILL, MPEGTS_PAYLOAD, MPEGTS_SKIP } |
Functions | |
| static PESContext * | add_pes_stream (MpegTSContext *ts, int pid, int pcr_pid, int stream_type) |
| static AVStream * | new_pes_av_stream (PESContext *pes, uint32_t code) |
| void | av_set_program_name (AVProgram *program, char *provider_name, char *name) |
| void | av_program_add_stream_index (AVFormatContext *ac, int progid, unsigned int idx) |
| static void | clear_program (MpegTSContext *ts, unsigned int programid) |
| static void | clear_programs (MpegTSContext *ts) |
| static void | add_pat_entry (MpegTSContext *ts, unsigned int programid) |
| static void | add_pid_to_pmt (MpegTSContext *ts, unsigned int programid, unsigned int pid) |
| static int | discard_pid (MpegTSContext *ts, unsigned int pid) |
| discard_pid() decides if the pid is to be discarded according to caller's programs selection | |
| static void | write_section_data (AVFormatContext *s, MpegTSFilter *tss1, const uint8_t *buf, int buf_size, int is_start) |
| static MpegTSFilter * | mpegts_open_section_filter (MpegTSContext *ts, unsigned int pid, SectionCallback *section_cb, void *opaque, int check_crc) |
| static MpegTSFilter * | mpegts_open_pes_filter (MpegTSContext *ts, unsigned int pid, PESCallback *pes_cb, void *opaque) |
| static void | mpegts_close_filter (MpegTSContext *ts, MpegTSFilter *filter) |
| static int | analyze (const uint8_t *buf, int size, int packet_size, int *index) |
| static int | get_packet_size (const uint8_t *buf, int size) |
| static int | get8 (const uint8_t **pp, const uint8_t *p_end) |
| static int | get16 (const uint8_t **pp, const uint8_t *p_end) |
| static char * | getstr8 (const uint8_t **pp, const uint8_t *p_end) |
| static int | parse_section_header (SectionHeader *h, const uint8_t **pp, const uint8_t *p_end) |
| static void | pmt_cb (MpegTSFilter *filter, const uint8_t *section, int section_len) |
| static void | pat_cb (MpegTSFilter *filter, const uint8_t *section, int section_len) |
| static void | mpegts_set_service (MpegTSContext *ts) |
| static void | sdt_cb (MpegTSFilter *filter, const uint8_t *section, int section_len) |
| static void | mpegts_scan_sdt (MpegTSContext *ts) |
| static int64_t | get_pts (const uint8_t *p) |
| static void | mpegts_push_data (MpegTSFilter *filter, const uint8_t *buf, int buf_size, int is_start) |
| static void | handle_packet (MpegTSContext *ts, const uint8_t *packet) |
| static int | mpegts_resync (ByteIOContext *pb) |
| static int | read_packet (ByteIOContext *pb, uint8_t *buf, int raw_packet_size) |
| static int | handle_packets (MpegTSContext *ts, int nb_packets) |
| static int | mpegts_probe (AVProbeData *p) |
| static int | parse_pcr (int64_t *ppcr_high, int *ppcr_low, const uint8_t *packet) |
| static int | mpegts_read_header (AVFormatContext *s, AVFormatParameters *ap) |
| static int | mpegts_raw_read_packet (AVFormatContext *s, AVPacket *pkt) |
| static int | mpegts_read_packet (AVFormatContext *s, AVPacket *pkt) |
| static int | mpegts_read_close (AVFormatContext *s) |
| static int64_t | mpegts_get_pcr (AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit) |
| static int | read_seek (AVFormatContext *s, int stream_index, int64_t target_ts, int flags) |
| MpegTSContext * | mpegts_parse_open (AVFormatContext *s) |
| int | mpegts_parse_packet (MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len) |
| void | mpegts_parse_close (MpegTSContext *ts) |
Variables | |
| AVInputFormat | mpegts_demuxer |
| AVInputFormat | mpegts_demuxer |
| AVInputFormat | mpegtsraw_demuxer |
| #define CHECK_COUNT 10 |
| #define MAX_PACKET_READAHEAD ((128 * 1024) / 188) |
| #define MAX_RESYNC_SIZE 4096 |
| #define PES_START_SIZE 9 |
| typedef struct MpegTSFilter MpegTSFilter |
| typedef void PESCallback(MpegTSFilter *f, const uint8_t *buf, int len, int is_start) |
| typedef struct PESContext PESContext |
| typedef void SectionCallback(MpegTSFilter *f, const uint8_t *buf, int len) |
| typedef void SetServiceCallback(void *opaque, int ret) |
| enum MpegTSFilterType |
| enum MpegTSState |
Definition at line 126 of file mpegts.c.
00126 { 00127 MPEGTS_HEADER = 0, 00128 MPEGTS_PESHEADER_FILL, 00129 MPEGTS_PAYLOAD, 00130 MPEGTS_SKIP, 00131 };
| static void add_pat_entry | ( | MpegTSContext * | ts, | |
| unsigned int | programid | |||
| ) | [static] |
Definition at line 170 of file mpegts.c.
References av_realloc(), Program_t::id, Program_t::nb_pids, MpegTSContext::nb_prg, and MpegTSContext::prg.
Referenced by pat_cb().
00171 { 00172 Program_t *p; 00173 void *tmp = av_realloc(ts->prg, (ts->nb_prg+1)*sizeof(Program_t)); 00174 if(!tmp) 00175 return; 00176 ts->prg = tmp; 00177 p = &ts->prg[ts->nb_prg]; 00178 p->id = programid; 00179 p->nb_pids = 0; 00180 ts->nb_prg++; 00181 }
| static PESContext * add_pes_stream | ( | MpegTSContext * | ts, | |
| int | pid, | |||
| int | pcr_pid, | |||
| int | stream_type | |||
| ) | [static] |
Definition at line 990 of file mpegts.c.
References av_free(), av_mallocz(), mpegts_open_pes_filter(), mpegts_push_data(), PESContext::pcr_pid, PESContext::pid, MpegTSContext::stream, PESContext::stream, PESContext::stream_type, and PESContext::ts.
Referenced by handle_packet(), and pmt_cb().
00991 { 00992 MpegTSFilter *tss; 00993 PESContext *pes; 00994 00995 /* if no pid found, then add a pid context */ 00996 pes = av_mallocz(sizeof(PESContext)); 00997 if (!pes) 00998 return 0; 00999 pes->ts = ts; 01000 pes->stream = ts->stream; 01001 pes->pid = pid; 01002 pes->pcr_pid = pcr_pid; 01003 pes->stream_type = stream_type; 01004 tss = mpegts_open_pes_filter(ts, pid, mpegts_push_data, pes); 01005 if (!tss) { 01006 av_free(pes); 01007 return 0; 01008 } 01009 return pes; 01010 }
| static void add_pid_to_pmt | ( | MpegTSContext * | ts, | |
| unsigned int | programid, | |||
| unsigned int | pid | |||
| ) | [static] |
Definition at line 183 of file mpegts.c.
References Program_t::id, MpegTSContext::nb_prg, NULL, and MpegTSContext::prg.
Referenced by pat_cb(), and pmt_cb().
00184 { 00185 int i; 00186 Program_t *p = NULL; 00187 for(i=0; i<ts->nb_prg; i++) { 00188 if(ts->prg[i].id == programid) { 00189 p = &ts->prg[i]; 00190 break; 00191 } 00192 } 00193 if(!p) 00194 return; 00195 00196 if(p->nb_pids >= MAX_PIDS_PER_PROGRAM) 00197 return; 00198 p->pids[p->nb_pids++] = pid; 00199 }
| static int analyze | ( | const uint8_t * | buf, | |
| int | size, | |||
| int | packet_size, | |||
| int * | index | |||
| ) | [static] |
Definition at line 342 of file mpegts.c.
Referenced by get_packet_size(), and mpegts_probe().
00342 { 00343 int stat[packet_size]; 00344 int i; 00345 int x=0; 00346 int best_score=0; 00347 00348 memset(stat, 0, packet_size*sizeof(int)); 00349 00350 for(x=i=0; i<size-3; i++){ 00351 if(buf[i] == 0x47 && !(buf[i+1] & 0x80) && (buf[i+3] & 0x30)){ 00352 stat[x]++; 00353 if(stat[x] > best_score){ 00354 best_score= stat[x]; 00355 if(index) *index= x; 00356 } 00357 } 00358 00359 x++; 00360 if(x == packet_size) x= 0; 00361 } 00362 00363 return best_score; 00364 }
| void av_program_add_stream_index | ( | AVFormatContext * | ac, | |
| int | progid, | |||
| unsigned int | idx | |||
| ) |
Definition at line 2678 of file libavformat/utils.c.
References av_realloc(), AVProgram::id, AVFormatContext::nb_programs, AVProgram::nb_stream_indexes, NULL, AVFormatContext::programs, and AVProgram::stream_index.
Referenced by pmt_cb().
02679 { 02680 int i, j; 02681 AVProgram *program=NULL; 02682 void *tmp; 02683 02684 for(i=0; i<ac->nb_programs; i++){ 02685 if(ac->programs[i]->id != progid) 02686 continue; 02687 program = ac->programs[i]; 02688 for(j=0; j<program->nb_stream_indexes; j++) 02689 if(program->stream_index[j] == idx) 02690 return; 02691 02692 tmp = av_realloc(program->stream_index, sizeof(unsigned int)*(program->nb_stream_indexes+1)); 02693 if(!tmp) 02694 return; 02695 program->stream_index = tmp; 02696 program->stream_index[program->nb_stream_indexes++] = idx; 02697 return; 02698 } 02699 }
| void av_set_program_name | ( | AVProgram * | program, | |
| char * | provider_name, | |||
| char * | name | |||
| ) |
Definition at line 2308 of file libavformat/utils.c.
References av_free(), av_strdup(), and AVProgram::provider_name.
Referenced by sdt_cb().
02309 { 02310 assert(!provider_name == !name); 02311 if(name){ 02312 av_free(program->provider_name); 02313 av_free(program-> name); 02314 program->provider_name = av_strdup(provider_name); 02315 program-> name = av_strdup( name); 02316 } 02317 }
| static void clear_program | ( | MpegTSContext * | ts, | |
| unsigned int | programid | |||
| ) | [static] |
Definition at line 155 of file mpegts.c.
References Program_t::id, Program_t::nb_pids, MpegTSContext::nb_prg, and MpegTSContext::prg.
Referenced by pmt_cb().
00156 { 00157 int i; 00158 00159 for(i=0; i<ts->nb_prg; i++) 00160 if(ts->prg[i].id == programid) 00161 ts->prg[i].nb_pids = 0; 00162 }
| static void clear_programs | ( | MpegTSContext * | ts | ) | [static] |
Definition at line 164 of file mpegts.c.
References av_freep(), MpegTSContext::nb_prg, and MpegTSContext::prg.
Referenced by mpegts_read_close(), and pat_cb().
| static int discard_pid | ( | MpegTSContext * | ts, | |
| unsigned int | pid | |||
| ) | [static] |
discard_pid() decides if the pid is to be discarded according to caller's programs selection
| ts | : - TS context | |
| pid | : - pid |
Definition at line 209 of file mpegts.c.
References AVDISCARD_ALL, AVProgram::discard, Program_t::id, AVProgram::id, MpegTSContext::nb_prg, Program_t::pids, MpegTSContext::prg, AVFormatContext::programs, and MpegTSContext::stream.
Referenced by handle_packet().
00210 { 00211 int i, j, k; 00212 int used = 0, discarded = 0; 00213 Program_t *p; 00214 for(i=0; i<ts->nb_prg; i++) { 00215 p = &ts->prg[i]; 00216 for(j=0; j<p->nb_pids; j++) { 00217 if(p->pids[j] != pid) 00218 continue; 00219 //is program with id p->id set to be discarded? 00220 for(k=0; k<ts->stream->nb_programs; k++) { 00221 if(ts->stream->programs[k]->id == p->id) { 00222 if(ts->stream->programs[k]->discard == AVDISCARD_ALL) 00223 discarded++; 00224 else 00225 used++; 00226 } 00227 } 00228 } 00229 } 00230 00231 return !used && discarded; 00232 }
| static int get16 | ( | const uint8_t ** | pp, | |
| const uint8_t * | p_end | |||
| ) | [inline, static] |
| static int get8 | ( | const uint8_t ** | pp, | |
| const uint8_t * | p_end | |||
| ) | [inline, static] |
| static int get_packet_size | ( | const uint8_t * | buf, | |
| int | size | |||
| ) | [static] |
Definition at line 367 of file mpegts.c.
References analyze(), NULL, TS_DVHS_PACKET_SIZE, TS_FEC_PACKET_SIZE, and TS_PACKET_SIZE.
Referenced by mpegts_read_header().
00368 { 00369 int score, fec_score, dvhs_score; 00370 00371 if (size < (TS_FEC_PACKET_SIZE * 5 + 1)) 00372 return -1; 00373 00374 score = analyze(buf, size, TS_PACKET_SIZE, NULL); 00375 dvhs_score = analyze(buf, size, TS_DVHS_PACKET_SIZE, NULL); 00376 fec_score= analyze(buf, size, TS_FEC_PACKET_SIZE, NULL); 00377 // av_log(NULL, AV_LOG_DEBUG, "score: %d, dvhs_score: %d, fec_score: %d \n", score, dvhs_score, fec_score); 00378 00379 if (score > fec_score && score > dvhs_score) return TS_PACKET_SIZE; 00380 else if(dvhs_score > score && dvhs_score > fec_score) return TS_DVHS_PACKET_SIZE; 00381 else if(score < fec_score && dvhs_score < fec_score) return TS_FEC_PACKET_SIZE; 00382 else return -1; 00383 }
| static int64_t get_pts | ( | const uint8_t * | p | ) | [static] |
| static char* getstr8 | ( | const uint8_t ** | pp, | |
| const uint8_t * | p_end | |||
| ) | [static] |
Definition at line 421 of file mpegts.c.
References av_malloc(), get8(), len, and NULL.
Referenced by sdt_cb().
00422 { 00423 int len; 00424 const uint8_t *p; 00425 char *str; 00426 00427 p = *pp; 00428 len = get8(&p, p_end); 00429 if (len < 0) 00430 return NULL; 00431 if ((p + len) > p_end) 00432 return NULL; 00433 str = av_malloc(len + 1); 00434 if (!str) 00435 return NULL; 00436 memcpy(str, p, len); 00437 str[len] = '\0'; 00438 p += len; 00439 *pp = p; 00440 return str; 00441 }
| static void handle_packet | ( | MpegTSContext * | ts, | |
| const uint8_t * | packet | |||
| ) | [static] |
Definition at line 1013 of file mpegts.c.
References add_pes_stream(), MpegTSContext::auto_guess, AV_RB16, discard_pid(), MpegTSFilter::last_cc, len, MPEGTS_SECTION, NULL, AVFormatContext::pb, MpegTSPESFilter::pes_cb, MpegTSFilter::pes_filter, MpegTSContext::pids, MpegTSContext::pos47, MpegTSContext::raw_packet_size, MpegTSContext::stream, TS_PACKET_SIZE, MpegTSFilter::type, MpegTSFilter::u, url_ftell(), and write_section_data().
Referenced by handle_packets(), and mpegts_parse_packet().
01014 { 01015 AVFormatContext *s = ts->stream; 01016 MpegTSFilter *tss; 01017 int len, pid, cc, cc_ok, afc, is_start; 01018 const uint8_t *p, *p_end; 01019 01020 pid = AV_RB16(packet + 1) & 0x1fff; 01021 if(pid && discard_pid(ts, pid)) 01022 return; 01023 is_start = packet[1] & 0x40; 01024 tss = ts->pids[pid]; 01025 if (ts->auto_guess && tss == NULL && is_start) { 01026 add_pes_stream(ts, pid, -1, 0); 01027 tss = ts->pids[pid]; 01028 } 01029 if (!tss) 01030 return; 01031 01032 /* continuity check (currently not used) */ 01033 cc = (packet[3] & 0xf); 01034 cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc)); 01035 tss->last_cc = cc; 01036 01037 /* skip adaptation field */ 01038 afc = (packet[3] >> 4) & 3; 01039 p = packet + 4; 01040 if (afc == 0) /* reserved value */ 01041 return; 01042 if (afc == 2) /* adaptation field only */ 01043 return; 01044 if (afc == 3) { 01045 /* skip adapation field */ 01046 p += p[0] + 1; 01047 } 01048 /* if past the end of packet, ignore */ 01049 p_end = packet + TS_PACKET_SIZE; 01050 if (p >= p_end) 01051 return; 01052 01053 ts->pos47= url_ftell(ts->stream->pb) % ts->raw_packet_size; 01054 01055 if (tss->type == MPEGTS_SECTION) { 01056 if (is_start) { 01057 /* pointer field present */ 01058 len = *p++; 01059 if (p + len > p_end) 01060 return; 01061 if (len && cc_ok) { 01062 /* write remaining section bytes */ 01063 write_section_data(s, tss, 01064 p, len, 0); 01065 /* check whether filter has been closed */ 01066 if (!ts->pids[pid]) 01067 return; 01068 } 01069 p += len; 01070 if (p < p_end) { 01071 write_section_data(s, tss, 01072 p, p_end - p, 1); 01073 } 01074 } else { 01075 if (cc_ok) { 01076 write_section_data(s, tss, 01077 p, p_end - p, 0); 01078 } 01079 } 01080 } else { 01081 tss->u.pes_filter.pes_cb(tss, 01082 p, p_end - p, is_start); 01083 } 01084 }
| static int handle_packets | ( | MpegTSContext * | ts, | |
| int | nb_packets | |||
| ) | [static] |
Definition at line 1132 of file mpegts.c.
References handle_packet(), AVFormatContext::pb, MpegTSContext::raw_packet_size, read_packet(), MpegTSContext::stop_parse, MpegTSContext::stream, and TS_PACKET_SIZE.
Referenced by mpegts_read_header(), and mpegts_read_packet().
01133 { 01134 AVFormatContext *s = ts->stream; 01135 ByteIOContext *pb = s->pb; 01136 uint8_t packet[TS_PACKET_SIZE]; 01137 int packet_num, ret; 01138 01139 ts->stop_parse = 0; 01140 packet_num = 0; 01141 for(;;) { 01142 if (ts->stop_parse>0) 01143 break; 01144 packet_num++; 01145 if (nb_packets != 0 && packet_num >= nb_packets) 01146 break; 01147 ret = read_packet(pb, packet, ts->raw_packet_size); 01148 if (ret != 0) 01149 return ret; 01150 handle_packet(ts, packet); 01151 } 01152 return 0; 01153 }
| static void mpegts_close_filter | ( | MpegTSContext * | ts, | |
| MpegTSFilter * | filter | |||
| ) | [static] |
Definition at line 330 of file mpegts.c.
References av_free(), av_freep(), filter(), MPEGTS_SECTION, NULL, and MpegTSContext::pids.
Referenced by mpegts_read_close(), pat_cb(), and pmt_cb().
00331 { 00332 int pid; 00333 00334 pid = filter->pid; 00335 if (filter->type == MPEGTS_SECTION) 00336 av_freep(&filter->u.section_filter.section_buf); 00337 00338 av_free(filter); 00339 ts->pids[pid] = NULL; 00340 }
| static int64_t mpegts_get_pcr | ( | AVFormatContext * | s, | |
| int | stream_index, | |||
| int64_t * | ppos, | |||
| int64_t | pos_limit | |||
| ) | [static] |
Definition at line 1383 of file mpegts.c.
References AV_NOPTS_VALUE, AV_RB16, get_buffer(), parse_pcr(), AVFormatContext::pb, MpegTSContext::pos47, AVStream::priv_data, AVFormatContext::priv_data, MpegTSContext::raw_packet_size, AVFormatContext::streams, TS_PACKET_SIZE, and url_fseek().
01385 { 01386 MpegTSContext *ts = s->priv_data; 01387 int64_t pos, timestamp; 01388 uint8_t buf[TS_PACKET_SIZE]; 01389 int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid; 01390 const int find_next= 1; 01391 pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; 01392 if (find_next) { 01393 for(;;) { 01394 url_fseek(s->pb, pos, SEEK_SET); 01395 if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) 01396 return AV_NOPTS_VALUE; 01397 if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && 01398 parse_pcr(×tamp, &pcr_l, buf) == 0) { 01399 break; 01400 } 01401 pos += ts->raw_packet_size; 01402 } 01403 } else { 01404 for(;;) { 01405 pos -= ts->raw_packet_size; 01406 if (pos < 0) 01407 return AV_NOPTS_VALUE; 01408 url_fseek(s->pb, pos, SEEK_SET); 01409 if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) 01410 return AV_NOPTS_VALUE; 01411 if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && 01412 parse_pcr(×tamp, &pcr_l, buf) == 0) { 01413 break; 01414 } 01415 } 01416 } 01417 *ppos = pos; 01418 01419 return timestamp; 01420 }
| static MpegTSFilter* mpegts_open_pes_filter | ( | MpegTSContext * | ts, | |
| unsigned int | pid, | |||
| PESCallback * | pes_cb, | |||
| void * | opaque | |||
| ) | [static] |
Definition at line 308 of file mpegts.c.
References av_mallocz(), filter(), MPEGTS_PES, NB_PID_MAX, NULL, MpegTSPESFilter::opaque, MpegTSPESFilter::pes_cb, and MpegTSContext::pids.
Referenced by add_pes_stream().
00311 { 00312 MpegTSFilter *filter; 00313 MpegTSPESFilter *pes; 00314 00315 if (pid >= NB_PID_MAX || ts->pids[pid]) 00316 return NULL; 00317 filter = av_mallocz(sizeof(MpegTSFilter)); 00318 if (!filter) 00319 return NULL; 00320 ts->pids[pid] = filter; 00321 filter->type = MPEGTS_PES; 00322 filter->pid = pid; 00323 filter->last_cc = -1; 00324 pes = &filter->u.pes_filter; 00325 pes->pes_cb = pes_cb; 00326 pes->opaque = opaque; 00327 return filter; 00328 }
| static MpegTSFilter* mpegts_open_section_filter | ( | MpegTSContext * | ts, | |
| unsigned int | pid, | |||
| SectionCallback * | section_cb, | |||
| void * | opaque, | |||
| int | check_crc | |||
| ) | [static] |
Definition at line 276 of file mpegts.c.
References av_free(), av_log(), AV_LOG_DEBUG, av_malloc(), av_mallocz(), MpegTSSectionFilter::check_crc, filter(), MAX_SECTION_SIZE, MPEGTS_SECTION, NB_PID_MAX, NULL, MpegTSSectionFilter::opaque, MpegTSContext::pids, MpegTSSectionFilter::section_buf, MpegTSSectionFilter::section_cb, and MpegTSContext::stream.
Referenced by mpegts_scan_sdt(), mpegts_set_service(), and pat_cb().
00280 { 00281 MpegTSFilter *filter; 00282 MpegTSSectionFilter *sec; 00283 00284 #ifdef DEBUG_SI 00285 av_log(ts->stream, AV_LOG_DEBUG, "Filter: pid=0x%x\n", pid); 00286 #endif 00287 if (pid >= NB_PID_MAX || ts->pids[pid]) 00288 return NULL; 00289 filter = av_mallocz(sizeof(MpegTSFilter)); 00290 if (!filter) 00291 return NULL; 00292 ts->pids[pid] = filter; 00293 filter->type = MPEGTS_SECTION; 00294 filter->pid = pid; 00295 filter->last_cc = -1; 00296 sec = &filter->u.section_filter; 00297 sec->section_cb = section_cb; 00298 sec->opaque = opaque; 00299 sec->section_buf = av_malloc(MAX_SECTION_SIZE); 00300 sec->check_crc = check_crc; 00301 if (!sec->section_buf) { 00302 av_free(filter); 00303 return NULL; 00304 } 00305 return filter; 00306 }
| void mpegts_parse_close | ( | MpegTSContext * | ts | ) |
Definition at line 1489 of file mpegts.c.
References av_free(), NB_PID_MAX, and MpegTSContext::pids.
Referenced by rtp_parse_close().
01490 { 01491 int i; 01492 01493 for(i=0;i<NB_PID_MAX;i++) 01494 av_free(ts->pids[i]); 01495 av_free(ts); 01496 }
| MpegTSContext* mpegts_parse_open | ( | AVFormatContext * | s | ) |
Definition at line 1448 of file mpegts.c.
References MpegTSContext::auto_guess, av_mallocz(), NULL, MpegTSContext::raw_packet_size, MpegTSContext::stream, and TS_PACKET_SIZE.
Referenced by rtp_parse_open().
01449 { 01450 MpegTSContext *ts; 01451 01452 ts = av_mallocz(sizeof(MpegTSContext)); 01453 if (!ts) 01454 return NULL; 01455 /* no stream case, currently used by RTP */ 01456 ts->raw_packet_size = TS_PACKET_SIZE; 01457 ts->stream = s; 01458 ts->auto_guess = 1; 01459 return ts; 01460 }
| int mpegts_parse_packet | ( | MpegTSContext * | ts, | |
| AVPacket * | pkt, | |||
| const uint8_t * | buf, | |||
| int | len | |||
| ) |
Definition at line 1464 of file mpegts.c.
References handle_packet(), MpegTSContext::pkt, MpegTSContext::stop_parse, and TS_PACKET_SIZE.
Referenced by rtp_parse_packet().
01466 { 01467 int len1; 01468 01469 len1 = len; 01470 ts->pkt = pkt; 01471 ts->stop_parse = 0; 01472 for(;;) { 01473 if (ts->stop_parse>0) 01474 break; 01475 if (len < TS_PACKET_SIZE) 01476 return -1; 01477 if (buf[0] != 0x47) { 01478 buf++; 01479 len--; 01480 } else { 01481 handle_packet(ts, buf); 01482 buf += TS_PACKET_SIZE; 01483 len -= TS_PACKET_SIZE; 01484 } 01485 } 01486 return len1 - len; 01487 }
| static int mpegts_probe | ( | AVProbeData * | p | ) | [static] |
Definition at line 1155 of file mpegts.c.
References analyze(), AVPROBE_SCORE_MAX, AVProbeData::buf, AVProbeData::buf_size, CHECK_COUNT, AVProbeData::filename, match_ext(), NULL, size, TS_DVHS_PACKET_SIZ