The display branch behind the session's tee: leaky queue ! valve [! decodebin3 ! video sink]. More...
#include <DecodingBranch.h>
Classes | |
| class | Listener |
| struct | StatsSample |
| What the branch measured for VideoStreamStats. More... | |
Public Member Functions | |
| DecodingBranch (const BranchContext &context, Listener &listener, bool lowLatency) | |
lowLatency: frames are shown as soon as decoded instead of at their presentation time. | |
| ~DecodingBranch () | |
| DecodingBranch (const DecodingBranch &)=delete | |
| DecodingBranch & | operator= (const DecodingBranch &)=delete |
| bool | build () |
| Adds the branch's leaky queue and closed valve behind the tee. | |
| void | reset () |
| Takes the video sink and decoder out of the pipeline, which must be in NULL, and releases the sink. | |
| void | setVideoSink (GstElement *sink) |
Decodes into sink from now on, or stops decoding for nullptr. | |
| void | onSourceStreaming () |
| The first frame reached the tee: inserts the decoder when a video sink is waiting for it. | |
| void | restartDecoder (const char *reason) |
| Replaces the decoder and resets the sink, leaving the rest of the pipeline (and a recording) running. | |
| void | onGraphicsDeviceServed () |
| bool | displaying () const |
| A decoder is inserted, so frames are due at the sink. | |
| GstElement * | valve () const |
| bool | isCurrent (GstObject *source) const |
| GstQgc::PathStats | sinkPathStats () const |
| StatsSample | sampleStats () |
| Not const: displayPath compares the sink's counts with the previous sample's. | |
| const QString & | decoderName () const |
| The factory of the decoder decodebin3 plugged last; empty while no decoder is inserted or it has plugged none. | |
| bool | hardwareDecoder () const |
| Whether decoderName() is a hardware decoder. | |
Static Public Attributes | |
| static constexpr int | kMaxDecoderRestarts = 3 |
The display branch behind the session's tee: leaky queue ! valve [! decodebin3 ! video sink].
Takes the receiver's video sink, inserts decodebin3 once the source streams and links its pad to the sink, asking upstream for a keyframe so the picture starts soon. Decoding is reported from the first frame that reaches the sink. A failing or stalled decoder is replaced without touching the rest of the pipeline; one that keeps failing, or that can't be inserted at all, is reported to the listener. A hardware decoder whose replacement brought no frame either is taken out of autoplug before the next one, so decodebin3 plugs the decoder ranked after it. The sink outlives the session: the branch holds a ref and takes it out of the pipeline again.
The queue drops the oldest frame when the decoder falls behind, so the tee (and with it the recording) never waits for the decoder. A decoder can't recover a dropped compressed frame, so after a drop the branch also drops delta frames until the next keyframe, which it requests: the picture freezes briefly instead of smearing for a whole GOP. It waits two seconds at most, and says so when no keyframe came, so a stream without keyframes goes on.
Threading: the receiver's worker, except the probes and the decoder's signal handlers (streaming threads), which hand their work to the worker through BranchContext::post().
Definition at line 35 of file DecodingBranch.h.
| DecodingBranch::DecodingBranch | ( | const BranchContext & | context, |
| Listener & | listener, | ||
| bool | lowLatency ) |
lowLatency: frames are shown as soon as decoded instead of at their presentation time.
Definition at line 165 of file DecodingBranch.cc.
Referenced by DecodingBranch(), and operator=().
| DecodingBranch::~DecodingBranch | ( | ) |
Definition at line 171 of file DecodingBranch.cc.
References reset().
|
delete |
References DecodingBranch().
|
nodiscard |
Adds the branch's leaky queue and closed valve behind the tee.
Definition at line 176 of file DecodingBranch.cc.
References GStreamer::adoptPad(), and GStreamer::Decoding.
|
inline |
The factory of the decoder decodebin3 plugged last; empty while no decoder is inserted or it has plugged none.
Definition at line 112 of file DecodingBranch.h.
|
inline |
A decoder is inserted, so frames are due at the sink.
Definition at line 96 of file DecodingBranch.h.
|
inline |
Whether decoderName() is a hardware decoder.
Definition at line 115 of file DecodingBranch.h.
| bool DecodingBranch::isCurrent | ( | GstObject * | source | ) | const |
Whether source is (inside) the current decoder or video sink, or the branch's queue or valve. Errors from anything else of the branch are left over from a replaced decoder.
Definition at line 294 of file DecodingBranch.cc.
| void DecodingBranch::onGraphicsDeviceServed | ( | ) |
The pipeline got the graphics device Qt renders with after its elements had asked for it (HwBuffers::kGraphicsDeviceServedMessage). A hardware decoder plugged meanwhile decodes on a device of its own, which it keeps, so its frames reach Qt through the CPU: replaces it by one that takes the pipeline's device. Not counted as a restart: the decoder didn't fail.
Definition at line 282 of file DecodingBranch.cc.
| void DecodingBranch::onSourceStreaming | ( | ) |
The first frame reached the tee: inserts the decoder when a video sink is waiting for it.
Definition at line 250 of file DecodingBranch.cc.
|
delete |
References DecodingBranch().
| void DecodingBranch::reset | ( | ) |
Takes the video sink and decoder out of the pipeline, which must be in NULL, and releases the sink.
Definition at line 202 of file DecodingBranch.cc.
Referenced by ~DecodingBranch().
| void DecodingBranch::restartDecoder | ( | const char * | reason | ) |
Replaces the decoder and resets the sink, leaving the rest of the pipeline (and a recording) running.
Definition at line 258 of file DecodingBranch.cc.
References kMaxDecoderRestarts.
| DecodingBranch::StatsSample DecodingBranch::sampleStats | ( | ) |
Not const: displayPath compares the sink's counts with the previous sample's.
Definition at line 309 of file DecodingBranch.cc.
References GstQgc::frameStats(), GstQgc::frameStatsField(), GstHw::kPathCount, GstQgc::sinkFramesField(), and GstHw::toString().
| void DecodingBranch::setVideoSink | ( | GstElement * | sink | ) |
Decodes into sink from now on, or stops decoding for nullptr.
Definition at line 213 of file DecodingBranch.cc.
References GStreamer::adoptElement(), GStreamer::adoptPad(), GStreamer::Decoding, GstQgc::frameStats(), GstQgc::frameStatsField(), GstHw::kPathCount, GStreamer::markBranch(), GstQgc::sinkFramesField(), and GstHwPathTelemetry::snapshot().
| GstQgc::PathStats DecodingBranch::sinkPathStats | ( | ) | const |
The frames the video sink delivered since setVideoSink(), from qgcqvideosink's "frame-stats", followed by the process-wide GPU-path counters since then (HwBuffers::extraPathStatsSince()); empty for other sinks.
Definition at line 299 of file DecodingBranch.cc.
References HwBuffers::extraPathStatsSince(), GstQgc::formatSinkStats(), GstQgc::frameStats(), and GstQgc::PathStats::line.
|
inline |
Definition at line 98 of file DecodingBranch.h.
|
staticconstexpr |
Definition at line 51 of file DecodingBranch.h.
Referenced by restartDecoder().