Hi, libavformat currently doesn't provide any mechanism for detecting when a substream is no longer present but the stream as a whole is otherwise OK. Your best guess is to check when you last got any frames on it, which tends to work for video and audio but not for substreams that sometimes spend a long amount of time without presenting anything, like subtitles.
Why is this an issue? Formats like MPEG-TS and MSS in push/ingest mode have separate transports for each stream; audio, video, and subtitles come from separate sources. If one of these breaks you have a fairly big problem on your hands, but returning an error on av_read_frame would be a bad course of action -- it may just be that the broadcaster has switched to regional news or similar which lacks subtitles or only runs one audio track, and things will return to normal once it's over. Put shortly, the API user needs to know that something is potentially broken, but without preventing further processing of the stream. This is my fourth proposal for a method of carrier loss detection. I've given up the ideas of having it edge-triggered and trying to hide format-specifics from the API user, so it's now a level-triggered event denoting the presence of a carrier which can be queried if the format has the (new) AVFMT_SEPCARRIERS flag. -- AVFMT_SEPCARRIERS is a new flag denoting that the format has a separate carrier for each stream, e.g. a separate file, transport stream, or connection per stream. AVSTREAM_EVENT_FLAG_CARRIER_PRESENT is a new event indicating the presence of a given stream, and is relevant for formats with the above flag. Its operation is fairly simple; all it does is indicate that the stream was alive/present since the last time the event flags were cleared, and is distinct from there being actual data on the stream. -- If accepted I'll submit an implementation for MPEG-TS since I figure it's pointless to clutter the mailing list with it before that. Regards, John Högberg
From f96924fa78ac535b8cfc08fe26b3073edec48c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <[email protected]> Date: Mon, 25 May 2015 09:43:19 +0200 Subject: [PATCH] lavf: add a format flag for separate carriers, and an event for detecting carrier presence. AVFMT_SEPCARRIERS is a new format flag denoting that the format has a separate carrier for each stream, e.g. a separate file, transport stream, or connection per stream. AVSTREAM_EVENT_FLAG_CARRIER_PRESENT is a new event indicating the presence of a given stream, and is relevant for formats with the above flag. Its operation is fairly simple; all it does is indicate that the stream was alive/present since the last time the event flags were cleared, and is distinct from there being actual data on the stream. --- libavformat/avformat.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index aa11cff..e6b6a7a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -434,6 +434,9 @@ typedef struct AVProbeData { will be shifted in av_write_frame and av_interleaved_write_frame so they start from 0. */ +#define AVFMT_SEPCARRIERS 0x80000 /**< Format has separate carriers for each + stream, like separate connections, files, + or similar. */ /** * @addtogroup lavf_encoding @@ -531,7 +534,7 @@ typedef struct AVInputFormat { /** * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, - * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK. + * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEPCARRIERS. */ int flags; @@ -814,6 +817,13 @@ typedef struct AVStream { */ int event_flags; #define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata. +#define AVSTREAM_EVENT_FLAG_CARRIER_PRESENT 0x0002 /**< A carrier for this stream was present during the call. + This is distinct from there being data on the stream; it + simply means that the underlying carrier was present at + some point during the last call. + This event is only relevant for formats that have the + AVFMT_SEPCARRIERS flag, and should not be queried without + without a guard for that flag. */ /***************************************************************** * All fields below this line are not part of the public API. They -- 2.1.0
_______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
