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

#include <QtMultimediaVideoReceiver.h>

Inheritance diagram for QtMultimediaVideoReceiver:
Collaboration diagram for QtMultimediaVideoReceiver:

Classes

struct  Source
 What QMediaPlayer plays for a stream URI: a URL, or for RTP over UDP an SDP description of it. More...

Public Member Functions

 QtMultimediaVideoReceiver (QObject *parent=nullptr)
 ~QtMultimediaVideoReceiver () override
bool encodesRecordings () const override
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.
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 Member Functions

static std::optional< Source > playerSource (const QString &uri)
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={})

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 QtMultimediaVideoReceiverTest

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)

Detailed Description

A network video stream played by Qt Multimedia's QMediaPlayer (FFmpeg): the receiver of builds without GStreamer, and of VideoSettings::videoBackend's Qt Multimedia choice. Plays RTSP, MPEG-TS over UDP or TCP, and H.264 or H.265 RTP over UDP with payload type 96, which an SDP description tells FFmpeg about. Records by encoding the frames it displays anew (QtVideoRecorder), as recordingEncoding() says: only while an output displays the stream, and after a reconnect in the same file.

Streaming once the first frame arrives; decoding while frames reach the output. A stream that errors, ends, or shows no frame for the config's timeout while displaying (5 s more for the first, while FFmpeg probes the stream) has failed: its StreamSupervisor reconnects it after 1 s, doubling up to 30 s, while autoReconnect is on, and it stops with errorOccurred() otherwise. A UDP port nobody sends to yet hasn't failed: once FFmpeg gives up on it, the receiver listens again at once, for as long as it takes.

Definition at line 30 of file QtMultimediaVideoReceiver.h.

Constructor & Destructor Documentation

◆ QtMultimediaVideoReceiver()

◆ ~QtMultimediaVideoReceiver()

QtMultimediaVideoReceiver::~QtMultimediaVideoReceiver ( )
override

Definition at line 103 of file QtMultimediaVideoReceiver.cc.

Member Function Documentation

◆ encodesRecordings()

bool QtMultimediaVideoReceiver::encodesRecordings ( ) const
inlineoverridevirtual

True for a receiver that encodes its recordings anew, as recordingEncoding() says: a USB camera, or Qt Multimedia's player. False for one that records the stream as it arrives.

Reimplemented from VideoReceiver.

Definition at line 56 of file QtMultimediaVideoReceiver.h.

◆ onActiveChanged()

void QtMultimediaVideoReceiver::onActiveChanged ( )
overrideprotectedvirtual

Implements VideoReceiver.

Definition at line 160 of file QtMultimediaVideoReceiver.cc.

References VideoReceiver::active().

◆ onConfigChanged()

void QtMultimediaVideoReceiver::onConfigChanged ( )
overrideprotectedvirtual

◆ onReconnectRequested()

void QtMultimediaVideoReceiver::onReconnectRequested ( )
overrideprotectedvirtual

Implements VideoReceiver.

Definition at line 173 of file QtMultimediaVideoReceiver.cc.

◆ onRestartRequested()

void QtMultimediaVideoReceiver::onRestartRequested ( )
overrideprotectedvirtual

Implements VideoReceiver.

Definition at line 168 of file QtMultimediaVideoReceiver.cc.

◆ onStartRecording()

void QtMultimediaVideoReceiver::onStartRecording ( const QString & file,
FileFormat format )
overrideprotectedvirtual

◆ onStopRecording()

void QtMultimediaVideoReceiver::onStopRecording ( )
overrideprotectedvirtual

Implements VideoReceiver.

Definition at line 212 of file QtMultimediaVideoReceiver.cc.

◆ onVideoOutputChanged()

void QtMultimediaVideoReceiver::onVideoOutputChanged ( )
overrideprotectedvirtual

Also called when the current output is set again.

Implements VideoReceiver.

Definition at line 184 of file QtMultimediaVideoReceiver.cc.

References VideoReceiver::videoSink().

◆ playerSource()

std::optional< QtMultimediaVideoReceiver::Source > QtMultimediaVideoReceiver::playerSource ( const QString & uri)
static

The source for uri, one of VideoStreamResolver's: rtsp(s):// and tcp:// as they are, rtspt:// as rtsp:// over TCP, as GStreamer plays it, mpegts:// as udp://, and udp:// (H.264) or udp265:// (H.265) RTP as an SDP description. Other URLs play as they are; nullopt for an invalid one.

Definition at line 115 of file QtMultimediaVideoReceiver.cc.

References VideoStreamUri::transportFor().

◆ QtMultimediaVideoReceiverTest

friend class QtMultimediaVideoReceiverTest
friend

Definition at line 34 of file QtMultimediaVideoReceiver.h.

References QtMultimediaVideoReceiverTest.

Referenced by QtMultimediaVideoReceiverTest.


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