This is patch 3 out of 3 that addresses the issue with detecting carrier loss.
The first one added the raise-by-omission mechanism required for the NO_CARRIER event to function properly on formats like MPEG-TS, the second one added the NO_CARRIER event itself, and this third one provides an implementation for MPEG-TS. The implementation is fairly straightforward; set base_event_flags to NO_CARRIER to ensure that it's raised on every event flag reset, and clear it whenever any packets whatsoever are seen on the PID in question. It honors padding packets (0x1BE) which are sent by compliant muxers every few hundred ms regardless of whether there's been any data on the PID or not. This may result in NO_CARRIER being quite a spammy event if checked often, but the standards provide no other way of doing this -- PID timeouts are explicitly left implementation-specific (Though they're generally in the order of 1s). Regards, John Högberg
From 1bbc8c4cbcfc405c28004fb6ade4efb02adb5faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john.hogb...@ericsson.com> Date: Mon, 18 May 2015 11:19:05 +0200 Subject: [PATCH] mpegts: implement the NO_CARRIER event --- libavformat/mpegts.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 8f61f17..12d5f7f 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -648,10 +648,14 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, uint32_t stream_type, uint32_t prog_reg_desc) { avpriv_set_pts_info(st, 33, 1, 90000); + st->priv_data = pes; st->codec->codec_type = AVMEDIA_TYPE_DATA; st->codec->codec_id = AV_CODEC_ID_NONE; st->need_parsing = AVSTREAM_PARSE_FULL; + st->base_event_flags |= AVSTREAM_EVENT_FLAG_NO_CARRIER; + st->event_flags |= st->base_event_flags; + pes->st = st; pes->stream_type = stream_type; @@ -687,6 +691,8 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO; sub_st->codec->codec_id = AV_CODEC_ID_AC3; sub_st->need_parsing = AVSTREAM_PARSE_FULL; + sub_st->base_event_flags |= AVSTREAM_EVENT_FLAG_NO_CARRIER; + sub_st->event_flags |= sub_st->base_event_flags; sub_pes->sub_st = pes->sub_st = sub_st; } } @@ -840,6 +846,10 @@ static int mpegts_push_data(MpegTSFilter *filter, av_log(pes->stream, AV_LOG_TRACE, "pid=%x pes_code=%#x\n", pes->pid, code); + if(pes->st) { + pes->st->event_flags &= ~AVSTREAM_EVENT_FLAG_NO_CARRIER; + } + if ((pes->st && pes->st->discard == AVDISCARD_ALL && (!pes->sub_st || pes->sub_st->discard == AVDISCARD_ALL)) || @@ -1507,6 +1517,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type default: break; } + *pp = desc_end; return 0; } -- 2.1.0
_______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel