diff options
author | Marton Balint <cus@passwd.hu> | 2014-03-02 04:47:17 +0400 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2014-03-22 16:55:01 +0400 |
commit | d83a5b52184f12d8be995dfb4682e43cbb828100 (patch) | |
tree | ef2fa87fd0afc7d1f506f7a0d9ad9f5621cb4eda /libavformat | |
parent | 6bab55b84c8b5c6eec9593ad0bbedab8204f6e89 (diff) |
mpegts: add pcr filter for tracking standalone pcr pids
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mpegts.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 05ed940604..8a5d8c721d 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -55,6 +55,7 @@ enum MpegTSFilterType { MPEGTS_PES, MPEGTS_SECTION, + MPEGTS_PCR, }; typedef struct MpegTSFilter MpegTSFilter; @@ -467,6 +468,11 @@ static MpegTSFilter *mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid, return filter; } +static MpegTSFilter *mpegts_open_pcr_filter(MpegTSContext *ts, unsigned int pid) +{ + return mpegts_open_filter(ts, pid, MPEGTS_PCR); +} + static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter) { int pid; @@ -1824,6 +1830,9 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len p = desc_list_end; } + if (!ts->pids[pcr_pid]) + mpegts_open_pcr_filter(ts, pcr_pid); + out: for (i = 0; i < mp4_descr_count; i++) av_free(mp4_descr[i].dec_config_descr); @@ -2029,7 +2038,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) } } - if (!has_payload) + if (!has_payload && tss->type != MPEGTS_PCR) return 0; p = packet + 4; if (has_adaptation) { @@ -2038,7 +2047,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) } /* if past the end of packet, ignore */ p_end = packet + TS_PACKET_SIZE; - if (p >= p_end) + if (p > p_end || (p == p_end && tss->type != MPEGTS_PCR)) return 0; pos = avio_tell(ts->stream->pb); @@ -2096,9 +2105,11 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet) if (parse_pcr(&pcr_h, &pcr_l, packet) == 0) tss->last_pcr = pcr_h * 300 + pcr_l; // Note: The position here points actually behind the current packet. - if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start, - pos - ts->raw_packet_size)) < 0) - return ret; + if (tss->type == MPEGTS_PES) { + if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start, + pos - ts->raw_packet_size)) < 0) + return ret; + } } return 0; |