#include <VideoStreamController.h>
Public Types | |
| using | Role = VideoStreamResolver::Role |
| The source is shown in a tile of the video view, rather than as the main picture or with it. | |
Signals | |
| void | roleChanged () |
| void | tileChanged () |
| void | displayNameChanged () |
| void | decodingChanged () |
| void | reconnectingChanged () |
| void | recordingChanged (bool recording) |
| void | encodesRecordingsChanged () |
| void | videoSizeChanged () |
| void | rotationChanged () |
| void | aspectRatioChanged () |
| void | statsChanged () |
| void | streamInfoChanged () |
| void | uriChanged () |
| void | recordingStarted (const QString &file) |
| void | recordingFinished (const QString &file, const QString &error) |
| void | errorOccurred (const QString &message) |
Public Member Functions | |
| VideoStreamController (Role role, VideoSettings *videoSettings, QObject *parent=nullptr, VideoReceiver *ownReceiver=nullptr) | |
ownReceiver, when given, is the source's receiver for good; the source takes ownership of it. | |
| ~VideoStreamController () override | |
| Role | role () const |
| void | setRole (Role role) |
| Makes a stream in a tile the primary stream, or the reverse. What the source plays stays. | |
| bool | tile () const |
| void | setTile (bool tile) |
| QString | displayName () const |
| void | setDisplayName (const QString &displayName) |
| QString | name () const |
| void | setName (const QString &name) |
| Names a source that has no receiver yet. | |
| QString | taggedFile (const QString &file) const |
file for this source: the thermal stream's name goes before the extension, "<base>.thermalVideo.<ext>". | |
| VideoReceiver * | receiver () const |
| void | setReceiver (VideoReceiver *receiver) |
| void | shutDown () |
| QGCVideoStreamInfo * | streamInfo () const |
| void | setStreamInfo (QGCVideoStreamInfo *streamInfo) |
| The stream the camera advertises for this role, which takes precedence over the manual settings. | |
| void | setCamera (const QString &camera) |
| void | setEnabled (bool enabled) |
| The stream plays while it is enabled and configured(). | |
| bool | configured () const |
| void | scheduleApply () |
| void | stop () |
| Disables the stream and stops the receiver now. | |
| void | restart () |
| Reconnects now and rebuilds the receiver's display sink, so construct-only sink settings apply. | |
| void | reconnectNow () |
| VideoReceiver::reconnectNow(): the stream's source is likely back, so a reconnect doesn't wait out its backoff. | |
| QQuickItem * | videoOutput () const |
| Q_INVOKABLE void | registerVideoOutput (QQuickItem *videoOutput) |
| Q_INVOKABLE void | unregisterVideoOutput (QQuickItem *videoOutput) |
| void | setDisplaySuspended (bool suspended) |
| bool | active () const |
| True when the receiver is active, accepting startRecording(). | |
| void | startRecording (const QString &file, VideoReceiver::FileFormat format) |
| void | stopRecording () |
| bool | encodesRecordings () const |
| void | setRecordingEncoding (const VideoReceiver::RecordingEncoding &encoding) |
| VideoReceiver::setRecordingEncoding(), for the receiver and for each one set later. | |
| bool | canTakeScreenshot () const |
| True while the stream is streaming into a registered output. | |
| bool | takeScreenshot (const QString &file, const VideoScreenshot::Exif &exif={}) const |
| bool | decoding () const |
| bool | reconnecting () const |
| bool | recording () const |
| int | rotation () const |
| QSize | videoSize () const |
| The size the stream is shown at: the receiver's video size, turned by rotation(). | |
| double | aspectRatio () const |
| VideoStreamStats | stats () const |
| The receiver's VideoReceiver::stats(); invalid without a receiver. | |
| QString | uri () const |
| QString | transport () const |
One video source: the primary stream, the thermal stream, the local camera or a stream shown in a tile. Resolves the source's config from the video settings and the vehicle camera's advertised stream, drives the source's VideoReceiver, and connects the receiver to the QML VideoOutput that displays it.
A stream's receiver comes from the video backend, and goes when the backend changes: setReceiver(). The local camera's is the source's for good, given to its constructor.
VideoManager says where the source is shown. The primary stream and a stream in a tile change places, role for role, when the tile's stream becomes the one to display: each goes on playing what it plays.
The VideoOutput registers itself: registerVideoOutput() once it is created and again after it moved to another window, unregisterVideoOutput() when it is destroyed (see VideoStreamOutput.qml). The registration outlives receivers, so an output registered before the video backend is ready is attached once a receiver exists. An output that registers as another one leaves takes the stream over from it: the receiver, which decodes only into an output, is never without one in between.
Definition at line 33 of file VideoStreamController.h.
The source is shown in a tile of the video view, rather than as the main picture or with it.
What the user knows the source by: the camera's and the stream's names, the video source, or the local camera.
Definition at line 57 of file VideoStreamController.h.
| VideoStreamController::VideoStreamController | ( | Role | role, |
| VideoSettings * | videoSettings, | ||
| QObject * | parent = nullptr, | ||
| VideoReceiver * | ownReceiver = nullptr ) |
ownReceiver, when given, is the source's receiver for good; the source takes ownership of it.
Definition at line 49 of file VideoStreamController.cc.
References aspectRatioChanged(), Fact::rawValueChanged(), role(), and setReceiver().
|
overridedefault |
| bool VideoStreamController::active | ( | ) | const |
True when the receiver is active, accepting startRecording().
Definition at line 407 of file VideoStreamController.cc.
Referenced by VideoRecordingService::startRecording().
| double VideoStreamController::aspectRatio | ( | ) | const |
Of the stream as shown: from the decoded frames, else the camera's advertised resolution, else the aspect ratio setting (primary) or 1.
Definition at line 465 of file VideoStreamController.cc.
References videoSize().
|
signal |
Referenced by setReceiver(), setRole(), and VideoStreamController().
| bool VideoStreamController::canTakeScreenshot | ( | ) | const |
True while the stream is streaming into a registered output.
Definition at line 439 of file VideoStreamController.cc.
Referenced by VideoManager::grabImage().
|
inline |
Definition at line 107 of file VideoStreamController.h.
| bool VideoStreamController::decoding | ( | ) | const |
Definition at line 449 of file VideoStreamController.cc.
Referenced by setReceiver().
|
signal |
Referenced by setReceiver().
|
inline |
Definition at line 73 of file VideoStreamController.h.
Referenced by setDisplayName().
|
signal |
Referenced by setDisplayName().
| bool VideoStreamController::encodesRecordings | ( | ) | const |
True when the receiver encodes the source's recordings anew (VideoReceiver::encodesRecordings()), which the recording codec and quality settings then govern. False without a receiver.
Definition at line 426 of file VideoStreamController.cc.
Referenced by setReceiver().
|
signal |
Referenced by setReceiver().
|
signal |
Referenced by setReceiver().
|
inline |
"videoContent", "thermalVideo", "uvcCamera" or the name given to a tile's stream: names the receiver, and tags the thermal stream's files. The source keeps the name it started with when its role changes.
Definition at line 79 of file VideoStreamController.h.
Referenced by registerVideoOutput(), VideoManager::selectSource(), setDisplaySuspended(), setName(), setReceiver(), taggedFile(), and unregisterVideoOutput().
|
inline |
Definition at line 87 of file VideoStreamController.h.
Referenced by setReceiver().
|
inline |
True while the stream, lost after it was decoded, is being recovered: its last frame is still worth showing. False again once it decodes, when the receiver gives up, and after a stop or a change of URI.
Definition at line 151 of file VideoStreamController.h.
|
signal |
| void VideoStreamController::reconnectNow | ( | ) |
VideoReceiver::reconnectNow(): the stream's source is likely back, so a reconnect doesn't wait out its backoff.
Definition at line 313 of file VideoStreamController.cc.
| bool VideoStreamController::recording | ( | ) | const |
Definition at line 454 of file VideoStreamController.cc.
Referenced by recordingChanged(), and setReceiver().
|
signal |
References recording().
Referenced by setReceiver().
|
signal |
Referenced by setReceiver().
|
signal |
Referenced by setReceiver().
| void VideoStreamController::registerVideoOutput | ( | QQuickItem * | videoOutput | ) |
Displays the stream in videoOutput, a QML VideoOutput, replacing any other. Registering the current output again re-attaches it: a VideoOutput that moved to another window must do this.
Definition at line 350 of file VideoStreamController.cc.
References name(), and videoOutput().
| void VideoStreamController::restart | ( | ) |
Reconnects now and rebuilds the receiver's display sink, so construct-only sink settings apply.
Definition at line 305 of file VideoStreamController.cc.
|
inline |
Definition at line 64 of file VideoStreamController.h.
Referenced by VideoRecordingService::addSource(), setRole(), and VideoStreamController().
|
signal |
Referenced by setRole().
|
inline |
The clockwise rotation, in degrees, the camera reports for the stream (VIDEO_STREAM_INFORMATION.rotation), which the outputs showing it add to the frames' own: 0, 90, 180 or 270, and 0 for any other angle or without a camera's stream.
Definition at line 158 of file VideoStreamController.h.
|
signal |
| void VideoStreamController::scheduleApply | ( | ) |
Pushes the current config and enabled state to the receiver on the next event loop pass. Calls before then coalesce into one update.
Definition at line 258 of file VideoStreamController.cc.
Referenced by setCamera(), setEnabled(), and setRole().
| void VideoStreamController::setCamera | ( | const QString & | camera | ) |
The attached local camera the camera source plays, by its description, which is its config's URI; empty for none. The stream settings aren't a camera's: its config changes with the camera alone.
Definition at line 224 of file VideoStreamController.cc.
References scheduleApply().
| void VideoStreamController::setDisplayName | ( | const QString & | displayName | ) |
Definition at line 86 of file VideoStreamController.cc.
References displayName(), and displayNameChanged().
| void VideoStreamController::setDisplaySuspended | ( | bool | suspended | ) |
Keeps the registered output from the receiver while suspended, as while the application is in the background: a receiver without an output decodes nothing, and goes on recording.
Definition at line 388 of file VideoStreamController.cc.
References name().
| void VideoStreamController::setEnabled | ( | bool | enabled | ) |
The stream plays while it is enabled and configured().
Definition at line 232 of file VideoStreamController.cc.
References scheduleApply().
|
inline |
Names a source that has no receiver yet.
Definition at line 82 of file VideoStreamController.h.
References name().
| void VideoStreamController::setReceiver | ( | VideoReceiver * | receiver | ) |
Takes ownership of receiver, replacing (and deleting) the current one; nullptr just deletes it. Nothing for a source with a receiver of its own.
Definition at line 113 of file VideoStreamController.cc.
References aspectRatioChanged(), decoding(), VideoReceiver::decodingChanged(), decodingChanged(), encodesRecordings(), encodesRecordingsChanged(), VideoReceiver::errorOccurred(), errorOccurred(), name(), receiver(), recording(), VideoReceiver::recordingChanged(), recordingChanged(), VideoReceiver::recordingFinished(), recordingFinished(), VideoReceiver::recordingStarted(), recordingStarted(), VideoReceiver::stateChanged(), stats(), VideoReceiver::statsChanged(), statsChanged(), videoSize(), VideoReceiver::videoSizeChanged(), and videoSizeChanged().
Referenced by shutDown(), and VideoStreamController().
| void VideoStreamController::setRecordingEncoding | ( | const VideoReceiver::RecordingEncoding & | encoding | ) |
VideoReceiver::setRecordingEncoding(), for the receiver and for each one set later.
Definition at line 431 of file VideoStreamController.cc.
| void VideoStreamController::setRole | ( | Role | role | ) |
Makes a stream in a tile the primary stream, or the reverse. What the source plays stays.
Definition at line 67 of file VideoStreamController.cc.
References aspectRatioChanged(), role(), roleChanged(), and scheduleApply().
| void VideoStreamController::setStreamInfo | ( | QGCVideoStreamInfo * | streamInfo | ) |
The stream the camera advertises for this role, which takes precedence over the manual settings.
Definition at line 193 of file VideoStreamController.cc.
References QGCVideoStreamInfo::infoChanged(), and streamInfo().
| void VideoStreamController::setTile | ( | bool | tile | ) |
Definition at line 78 of file VideoStreamController.cc.
References tile(), and tileChanged().
| void VideoStreamController::shutDown | ( | ) |
Stops the source for good, before the application goes away: deletes its receiver, or shuts down (VideoReceiver::shutDown()) one of its own.
Definition at line 102 of file VideoStreamController.cc.
References setReceiver().
Referenced by VideoManager::cleanup().
| void VideoStreamController::startRecording | ( | const QString & | file, |
| VideoReceiver::FileFormat | format ) |
Definition at line 412 of file VideoStreamController.cc.
Referenced by VideoRecordingService::startRecording().
| VideoStreamStats VideoStreamController::stats | ( | ) | const |
The receiver's VideoReceiver::stats(); invalid without a receiver.
Definition at line 478 of file VideoStreamController.cc.
Referenced by setReceiver().
|
signal |
Referenced by setReceiver().
| void VideoStreamController::stop | ( | ) |
Disables the stream and stops the receiver now.
Definition at line 299 of file VideoStreamController.cc.
Referenced by VideoManager::stopVideo().
| void VideoStreamController::stopRecording | ( | ) |
Definition at line 419 of file VideoStreamController.cc.
Referenced by VideoRecordingService::stopRecording().
| QGCVideoStreamInfo * VideoStreamController::streamInfo | ( | ) | const |
Definition at line 188 of file VideoStreamController.cc.
Referenced by setStreamInfo().
|
signal |
| QString VideoStreamController::taggedFile | ( | const QString & | file | ) | const |
file for this source: the thermal stream's name goes before the extension, "<base>.thermalVideo.<ext>".
Definition at line 94 of file VideoStreamController.cc.
References RecordingPlan::insertBeforeExtension(), and name().
Referenced by VideoManager::grabImage(), and VideoRecordingService::recordingFile().
| bool VideoStreamController::takeScreenshot | ( | const QString & | file, |
| const VideoScreenshot::Exif & | exif = {} ) const |
Definition at line 444 of file VideoStreamController.cc.
Referenced by VideoManager::grabImage().
|
inline |
Definition at line 69 of file VideoStreamController.h.
Referenced by VideoManager::grabImage(), VideoManager::selectSource(), setTile(), and VideoRecordingService::startRecording().
|
signal |
Referenced by setTile().
| QString VideoStreamController::transport | ( | ) | const |
How the stream arrives, from its URI: "RTSP", "RTP/UDP (H.264)", "MPEG-TS/TCP", ...; empty without a stream, and for the local camera.
Definition at line 491 of file VideoStreamController.cc.
References VideoStreamResolver::transportName().
| void VideoStreamController::unregisterVideoOutput | ( | QQuickItem * | videoOutput | ) |
Stops displaying in videoOutput, if it is the registered output. The receiver is told on the next event loop pass, unless another output registered by then.
Definition at line 366 of file VideoStreamController.cc.
References name(), and videoOutput().
| QString VideoStreamController::uri | ( | ) | const |
The URI the receiver plays, without user info or query values, for display, or the local camera's description; empty without a stream or a camera.
Definition at line 483 of file VideoStreamController.cc.
References QGCNetworkHelper::redactedUrlForLogging().
|
signal |
| QQuickItem * VideoStreamController::videoOutput | ( | ) | const |
Definition at line 345 of file VideoStreamController.cc.
Referenced by registerVideoOutput(), and unregisterVideoOutput().
| QSize VideoStreamController::videoSize | ( | ) | const |
The size the stream is shown at: the receiver's video size, turned by rotation().
Definition at line 459 of file VideoStreamController.cc.
Referenced by aspectRatio(), and setReceiver().
|
signal |
Referenced by setReceiver().