Also logs the receiver's worker, its PipelineSession with the branches, and PipelineDotDumper. More...
#include <GstVideoReceiver.h>
Public Member Functions | |
| GstVideoReceiver (QObject *parent=nullptr) | |
| ~GstVideoReceiver () override | |
| Finalizes a recording and stops the pipeline, waiting at most a few seconds for the worker. | |
| QString | decoderName () const |
| void | setHeartbeatInterval (std::chrono::milliseconds interval) |
| Public Member Functions inherited from VideoReceiver | |
| VideoReceiver (QObject *parent=nullptr) | |
| ~VideoReceiver () override | |
| QString | name () const |
| void | setName (const QString &name) |
| Names the stream in logs and pipeline dumps. Call once, before the first setActive(true). | |
| const Config & | config () const |
| const DisplayConfig & | displayConfig () const |
| bool | active () const |
| QQuickItem * | videoOutput () const |
| State | state () const |
| bool | streaming () const |
| bool | decoding () const |
| bool | recording () const |
| QSize | videoSize () const |
| The size of the frames as they are presented, before the orientation the VideoOutput adds. | |
| VideoStreamStats | stats () const |
| The stream's health, measured about once a second while it streams; invalid while it doesn't. | |
| void | setConfig (const Config &config) |
| void | setDisplayConfig (const DisplayConfig &config) |
Stores config for the display sink restart() builds next. | |
| virtual bool | encodesRecordings () const |
| const RecordingEncoding & | recordingEncoding () const |
| void | setRecordingEncoding (const RecordingEncoding &encoding) |
Stores encoding for the recordings that start from now on; one in progress keeps its own. | |
| void | setActive (bool active) |
| Streams while true and the URI is set. False stops the stream, any pending reconnect and any recording. | |
| virtual void | shutDown () |
| void | restart () |
| void | reconnectNow () |
| void | setVideoOutput (QQuickItem *videoOutput) |
| void | startRecording (const QString &file, FileFormat format) |
| void | stopRecording () |
| bool | takeScreenshot (const QString &file, const VideoScreenshot::Exif &exif={}) |
Static Public Attributes | |
| static constexpr std::chrono::seconds | kHeartbeatInterval {10} |
Protected Member Functions | |
| void | onConfigChanged () override |
| void | onActiveChanged () override |
| void | onRestartRequested () override |
| void | onReconnectRequested () override |
| void | onVideoOutputChanged () override |
| Also called when the current output is set again. | |
| void | onStartRecording (const QString &file, FileFormat format) override |
| void | onStopRecording () override |
| Protected Member Functions inherited from VideoReceiver | |
| virtual bool | onTakeScreenshot (const QString &file, const VideoScreenshot::Exif &exif) |
| takeScreenshot() with an output set: saves the frame on display, unless overridden. | |
| QVideoSink * | videoSink () const |
| The VideoOutput's QVideoSink, or nullptr. | |
| void | setState (State state) |
| void | setDecoding (bool decoding) |
| void | setRecording (bool recording) |
| void | setVideoSize (QSize size) |
| void | setStats (const VideoStreamStats &stats) |
| Backends publish a new measurement, and an invalid one once the stream stops or reconnects. | |
Friends | |
| class | GstVideoReceiverTestBase |
Additional Inherited Members | |
| Public Types inherited from VideoReceiver | |
| enum class | State : uint8_t { Stopped , Connecting , Streaming , Reconnecting } |
| enum class | FileFormat : uint8_t { Mkv = 0 , Mov = 1 , Mp4 = 2 } |
| Values are persisted by VideoSettings::recordingFormat. More... | |
| Signals inherited from VideoReceiver | |
| void | stateChanged (VideoReceiver::State state) |
| void | streamingChanged (bool streaming) |
| void | decodingChanged (bool decoding) |
| void | recordingChanged (bool recording) |
| void | recordingStarted (const QString &file) |
| A recording file opened: the first one after startRecording(), or the recording's next part. | |
| void | recordingFinished (const QString &file, const QString &error) |
A recording file closed. error is empty when the file was finalized cleanly. | |
| void | videoSizeChanged (QSize size) |
| void | statsChanged (const VideoStreamStats &stats) |
| void | errorOccurred (const QString &message) |
| Static Public Member Functions inherited from VideoReceiver | |
| static QString | fileExtension (FileFormat format) |
| "mkv", "mov" or "mp4". | |
| static QString | recordingComment () |
| The comment recordings carry, of GStreamer and of a USB camera alike: the application and its version. | |
| static bool | isValidFileFormat (int format) |
| static QSize | presentedSize (const QVideoFrame &frame, QSize pictureSize={}) |
Also logs the receiver's worker, its PipelineSession with the branches, and PipelineDotDumper.
The GStreamer VideoReceiver.
This GUI-thread facade owns the display sink, built from VideoSettings once there is an output to show and rebuilt by restart(), and binds it to the output's QVideoSink through a QGCQVideoSinkController. After every request it hands the whole GstReceiverRequest to a GstReceiverWorker on a thread of its own, which runs the pipeline (one PipelineSession per connection) and steers it towards what was asked for: reconnecting with backoff, replacing a failed decoder, resuming a recording in a new part. The worker reports its GstReceiverStatus and events back through queued signals, so every signal is emitted on the GUI thread.
A worker that waits for a streaming thread that never returns (a decoder deadlocked in its library, a recorder stuck in the kernel) serves no request any more, and nothing can stop its pipeline. The receiver notices that the worker runs none of the tasks it posts to it, which are its requests and, between them, a heartbeat: it then tells the user, once, through errorOccurred(), and reports State::Stopped without decoding unless frames still reach the output. It follows the worker again when that runs a task after all.
Definition at line 37 of file GstVideoReceiver.h.
|
explicit |
Definition at line 34 of file GstVideoReceiver.cc.
References GstReceiverWorker::errorOccurred(), VideoReceiver::errorOccurred(), GstReceiverWorker::graphicsDeviceLost(), kHeartbeatInterval, GstReceiverWorker::recordingFinished(), VideoReceiver::recordingFinished(), GstReceiverWorker::recordingStarted(), VideoReceiver::recordingStarted(), VideoReceiver::restart(), GstReceiverWorker::statusChanged(), GstReceiverWorker::taskDone(), and VideoReceiver::VideoReceiver().
|
override |
Finalizes a recording and stops the pipeline, waiting at most a few seconds for the worker.
Definition at line 61 of file GstVideoReceiver.cc.
References GstReceiverWorker::shutdown().
|
inline |
Factory name of the decoder decodebin3 plugged last; empty while the stream has no decoder: before it streams, without a video output, and while a decoder is being replaced. For tests.
Definition at line 53 of file GstVideoReceiver.h.
|
overrideprotectedvirtual |
Implements VideoReceiver.
Definition at line 92 of file GstVideoReceiver.cc.
|
overrideprotectedvirtual |
Implements VideoReceiver.
Definition at line 87 of file GstVideoReceiver.cc.
|
overrideprotectedvirtual |
Implements VideoReceiver.
Definition at line 108 of file GstVideoReceiver.cc.
|
overrideprotectedvirtual |
Implements VideoReceiver.
Definition at line 97 of file GstVideoReceiver.cc.
References VideoReceiver::videoSink().
|
overrideprotectedvirtual |
Implements VideoReceiver.
Definition at line 133 of file GstVideoReceiver.cc.
|
overrideprotectedvirtual |
Implements VideoReceiver.
Definition at line 140 of file GstVideoReceiver.cc.
|
overrideprotectedvirtual |
Also called when the current output is set again.
Implements VideoReceiver.
Definition at line 114 of file GstVideoReceiver.cc.
References VideoReceiver::videoOutput(), and VideoReceiver::videoSink().
| void GstVideoReceiver::setHeartbeatInterval | ( | std::chrono::milliseconds | interval | ) |
Checks the worker every interval from now on, instead of kHeartbeatInterval. For tests, which can't wait that long.
Definition at line 82 of file GstVideoReceiver.cc.
|
friend |
Definition at line 69 of file GstVideoReceiver.h.
References GstVideoReceiverTestBase, and VideoReceiver::videoSink().
Referenced by GstVideoReceiverTestBase.
|
staticconstexpr |
How often the receiver checks that its worker runs what it is posted, and posts it a heartbeat when that is nothing else.
Definition at line 45 of file GstVideoReceiver.h.
Referenced by GstVideoReceiver().