8#include <QtCore/QString>
79 [[nodiscard]]
bool build();
119 void _insertDecoder();
121 [[nodiscard]]
bool _tryInsertDecoder();
123 void _removeDecoder();
124 void _linkDecoderPad(GstPad* pad);
126 void _demoteFailedDecoder();
127 void _onFirstFrame(quint64 insertion);
128 void _setDecoding(
bool decoding);
129 void _setDecoderName(
const QString& name);
132 void _retireSinkCounts();
134 void _countLateFrames();
136 static void _onQueueOverrun(
GstElement* queue, gpointer data);
137 static GstPadProbeReturn _gateProbe(GstPad* pad, GstPadProbeInfo* info, gpointer data);
138 static GstPadProbeReturn _sinkProbe(GstPad* pad, GstPadProbeInfo* info, gpointer data);
139 static void _onDecoderPadAdded(
GstElement* decoder, GstPad* pad, gpointer data);
140 static void _onDecoderElementAdded(GstBin* decodebin, GstBin* subBin,
GstElement* element, gpointer data);
144 const bool _lowLatency;
155 std::array<quint64, GstHw::kPathCount> _pathFramesAtSample{};
157 quint64 _retiredFramesDisplayed = 0;
158 quint64 _retiredFramesSuperseded = 0;
159 quint64 _retiredGpuFallbacks = 0;
162 quint64 _lateFramesDropped = 0;
163 quint64 _sinkLateFramesSeen = 0;
164 QString _displayPath;
165 GStreamer::PadProbe _sinkFrameProbe;
166 GStreamer::PadProbe _keyframeGate;
167 GStreamer::ScopedSignal _decoderPadAdded;
168 GStreamer::ScopedSignal _decoderElementAdded;
171 std::atomic<quint64> _overruns = 0;
173 std::atomic<bool> _gateClosed =
false;
175 std::atomic<qint64> _gateClosedAtMs = 0;
177 std::atomic<bool> _gateTimeoutWarned =
false;
179 std::atomic<quint64> _framesDropped = 0;
181 std::atomic<quint64> _insertions = 0;
183 bool _streaming =
false;
184 bool _decoding =
false;
185 int _restartsWithoutFrame = 0;
186 quint64 _decoderRestarts = 0;
187 QString _decoderName;
188 bool _hardwareDecoder =
false;
190 std::shared_ptr<GstElement> _pluggedDecoder;
struct _GstElement GstElement
virtual void onDecodingChanged(bool decoding)=0
virtual void onDecoderFailing()=0
virtual void onDecoderNameChanged(const QString &name)=0
GstElement * valve() const
bool displaying() const
A decoder is inserted, so frames are due at the sink.
bool hardwareDecoder() const
Whether decoderName() is a hardware decoder.
const QString & decoderName() const
The factory of the decoder decodebin3 plugged last; empty while no decoder is inserted or it has plug...
void onSourceStreaming()
The first frame reached the tee: inserts the decoder when a video sink is waiting for it.
static constexpr int kMaxDecoderRestarts
DecodingBranch(const DecodingBranch &)=delete
bool build()
Adds the branch's leaky queue and closed valve behind the tee.
void onGraphicsDeviceServed()
void reset()
Takes the video sink and decoder out of the pipeline, which must be in NULL, and releases the sink.
GstQgc::PathStats sinkPathStats() const
DecodingBranch & operator=(const DecodingBranch &)=delete
bool isCurrent(GstObject *source) const
void setVideoSink(GstElement *sink)
Decodes into sink from now on, or stops decoding for nullptr.
StatsSample sampleStats()
Not const: displayPath compares the sink's counts with the previous sample's.
void restartDecoder(const char *reason)
Replaces the decoder and resets the sink, leaving the rest of the pipeline (and a recording) running.
DecodingBranch(const BranchContext &context, Listener &listener, bool lowLatency)
lowLatency: frames are shown as soon as decoded instead of at their presentation time.
The tee ! queue ! valve head every tee branch starts with.
std::unique_ptr< GstStructure, GstStructureDeleter > GstStructurePtr
std::unique_ptr< GstElement, GstObjectDeleter > GstElementPtr
GstVideoSink that pushes decoded frames into a Qt QVideoSink; sole sink in qgcvideosinkbin....
What the branch measured for VideoStreamStats.
quint64 framesDisplayed
Since the branch was built: frames the video sink delivered that no newer frame replaced before displ...
quint64 gpuFallbacks
Since the branch was built: frames a GPU path was tried for but the CPU delivered.
quint64 decoderRestarts
Since the branch was built: decoders replaced by restartDecoder().
Every counter and fallback reason at one instant; a reader's baseline for counts since then.
Formatted per-path frame counts + the total delivered through GPU paths.