QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VideoStreamController Class Reference

#include <VideoStreamController.h>

Inheritance diagram for VideoStreamController:
Collaboration diagram for VideoStreamController:

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

Detailed Description

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.

Member Typedef Documentation

◆ Role

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.

Constructor & Destructor Documentation

◆ VideoStreamController()

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().

◆ ~VideoStreamController()

VideoStreamController::~VideoStreamController ( )
overridedefault

Member Function Documentation

◆ active()

bool VideoStreamController::active ( ) const

True when the receiver is active, accepting startRecording().

Definition at line 407 of file VideoStreamController.cc.

Referenced by VideoRecordingService::startRecording().

◆ aspectRatio()

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().

◆ aspectRatioChanged

void VideoStreamController::aspectRatioChanged ( )
signal

◆ canTakeScreenshot()

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().

◆ configured()

bool VideoStreamController::configured ( ) const
inline

Definition at line 107 of file VideoStreamController.h.

◆ decoding()

bool VideoStreamController::decoding ( ) const

Definition at line 449 of file VideoStreamController.cc.

Referenced by setReceiver().

◆ decodingChanged

void VideoStreamController::decodingChanged ( )
signal

Referenced by setReceiver().

◆ displayName()

QString VideoStreamController::displayName ( ) const
inline

Definition at line 73 of file VideoStreamController.h.

Referenced by setDisplayName().

◆ displayNameChanged

void VideoStreamController::displayNameChanged ( )
signal

Referenced by setDisplayName().

◆ encodesRecordings()

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().

◆ encodesRecordingsChanged

void VideoStreamController::encodesRecordingsChanged ( )
signal

Referenced by setReceiver().

◆ errorOccurred

void VideoStreamController::errorOccurred ( const QString & message)
signal

Referenced by setReceiver().

◆ name()

QString VideoStreamController::name ( ) const
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().

◆ receiver()

VideoReceiver * VideoStreamController::receiver ( ) const
inline

Definition at line 87 of file VideoStreamController.h.

Referenced by setReceiver().

◆ reconnecting()

bool VideoStreamController::reconnecting ( ) const
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.

◆ reconnectingChanged

void VideoStreamController::reconnectingChanged ( )
signal

◆ reconnectNow()

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.

◆ recording()

bool VideoStreamController::recording ( ) const

Definition at line 454 of file VideoStreamController.cc.

Referenced by recordingChanged(), and setReceiver().

◆ recordingChanged

void VideoStreamController::recordingChanged ( bool recording)
signal

References recording().

Referenced by setReceiver().

◆ recordingFinished

void VideoStreamController::recordingFinished ( const QString & file,
const QString & error )
signal

Referenced by setReceiver().

◆ recordingStarted

void VideoStreamController::recordingStarted ( const QString & file)
signal

Referenced by setReceiver().

◆ registerVideoOutput()

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().

◆ restart()

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.

◆ role()

Role VideoStreamController::role ( ) const
inline

◆ roleChanged

void VideoStreamController::roleChanged ( )
signal

Referenced by setRole().

◆ rotation()

int VideoStreamController::rotation ( ) const
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.

◆ rotationChanged

void VideoStreamController::rotationChanged ( )
signal

◆ scheduleApply()

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().

◆ setCamera()

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().

◆ setDisplayName()

void VideoStreamController::setDisplayName ( const QString & displayName)

Definition at line 86 of file VideoStreamController.cc.

References displayName(), and displayNameChanged().

◆ setDisplaySuspended()

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().

◆ setEnabled()

void VideoStreamController::setEnabled ( bool enabled)

The stream plays while it is enabled and configured().

Definition at line 232 of file VideoStreamController.cc.

References scheduleApply().

◆ setName()

void VideoStreamController::setName ( const QString & name)
inline

Names a source that has no receiver yet.

Definition at line 82 of file VideoStreamController.h.

References name().

◆ setReceiver()

◆ setRecordingEncoding()

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.

◆ setRole()

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().

◆ setStreamInfo()

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().

◆ setTile()

void VideoStreamController::setTile ( bool tile)

Definition at line 78 of file VideoStreamController.cc.

References tile(), and tileChanged().

◆ shutDown()

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().

◆ startRecording()

void VideoStreamController::startRecording ( const QString & file,
VideoReceiver::FileFormat format )

Definition at line 412 of file VideoStreamController.cc.

Referenced by VideoRecordingService::startRecording().

◆ stats()

VideoStreamStats VideoStreamController::stats ( ) const

The receiver's VideoReceiver::stats(); invalid without a receiver.

Definition at line 478 of file VideoStreamController.cc.

Referenced by setReceiver().

◆ statsChanged

void VideoStreamController::statsChanged ( )
signal

Referenced by setReceiver().

◆ stop()

void VideoStreamController::stop ( )

Disables the stream and stops the receiver now.

Definition at line 299 of file VideoStreamController.cc.

Referenced by VideoManager::stopVideo().

◆ stopRecording()

void VideoStreamController::stopRecording ( )

Definition at line 419 of file VideoStreamController.cc.

Referenced by VideoRecordingService::stopRecording().

◆ streamInfo()

QGCVideoStreamInfo * VideoStreamController::streamInfo ( ) const

Definition at line 188 of file VideoStreamController.cc.

Referenced by setStreamInfo().

◆ streamInfoChanged

void VideoStreamController::streamInfoChanged ( )
signal

◆ taggedFile()

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().

◆ takeScreenshot()

bool VideoStreamController::takeScreenshot ( const QString & file,
const VideoScreenshot::Exif & exif = {} ) const

Definition at line 444 of file VideoStreamController.cc.

Referenced by VideoManager::grabImage().

◆ tile()

bool VideoStreamController::tile ( ) const
inline

◆ tileChanged

void VideoStreamController::tileChanged ( )
signal

Referenced by setTile().

◆ transport()

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().

◆ unregisterVideoOutput()

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().

◆ uri()

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().

◆ uriChanged

void VideoStreamController::uriChanged ( )
signal

◆ videoOutput()

QQuickItem * VideoStreamController::videoOutput ( ) const

Definition at line 345 of file VideoStreamController.cc.

Referenced by registerVideoOutput(), and unregisterVideoOutput().

◆ videoSize()

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().

◆ videoSizeChanged

void VideoStreamController::videoSizeChanged ( )
signal

Referenced by setReceiver().


The documentation for this class was generated from the following files: