6#include <QtCore/QByteArray>
7#include <QtCore/QObject>
8#include <QtCore/QPointer>
10#include <QtCore/QString>
11#include <QtMultimedia/QMediaFormat>
12#include <QtMultimedia/QMediaRecorder>
13#include <QtQmlIntegration/QtQmlIntegration>
36 Q_PROPERTY(QString
name READ
name CONSTANT FINAL)
92 QMediaFormat::VideoCodec
codec = QMediaFormat::VideoCodec::Unspecified;
93 QMediaRecorder::Quality
quality = QMediaRecorder::HighQuality;
109 static QSize
presentedSize(
const QVideoFrame& frame, QSize pictureSize = {});
111 QString
name()
const {
return _name; }
224 void _onVideoOutputDestroyed();
230 bool _active =
false;
231 QPointer<QQuickItem> _videoOutput;
232 QMetaObject::Connection _videoOutputDestroyed;
234 bool _decoding =
false;
235 bool _recording =
false;
void statsChanged(const VideoStreamStats &stats)
void setVideoSize(QSize size)
void setName(const QString &name)
Names the stream in logs and pipeline dumps. Call once, before the first setActive(true).
QQuickItem * videoOutput() const
void videoSizeChanged(QSize size)
virtual void onStopRecording()=0
void setRecordingEncoding(const RecordingEncoding &encoding)
Stores encoding for the recordings that start from now on; one in progress keeps its own.
void recordingChanged(bool recording)
virtual void onVideoOutputChanged()=0
Also called when the current output is set again.
void setConfig(const Config &config)
virtual bool encodesRecordings() const
void startRecording(const QString &file, FileFormat format)
void setVideoOutput(QQuickItem *videoOutput)
VideoReceiver(QObject *parent=nullptr)
virtual void onStartRecording(const QString &file, FileFormat format)=0
const DisplayConfig & displayConfig() const
void stateChanged(VideoReceiver::State state)
void streamingChanged(bool streaming)
void setStats(const VideoStreamStats &stats)
Backends publish a new measurement, and an invalid one once the stream stops or reconnects.
QVideoSink * videoSink() const
The VideoOutput's QVideoSink, or nullptr.
virtual void onActiveChanged()=0
void recordingFinished(const QString &file, const QString &error)
A recording file closed. error is empty when the file was finalized cleanly.
void setDisplayConfig(const DisplayConfig &config)
Stores config for the display sink restart() builds next.
static QSize presentedSize(const QVideoFrame &frame, QSize pictureSize={})
FileFormat
Values are persisted by VideoSettings::recordingFormat.
void setActive(bool active)
Streams while true and the URI is set. False stops the stream, any pending reconnect and any recordin...
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)
virtual void onConfigChanged()=0
void recordingStarted(const QString &file)
A recording file opened: the first one after startRecording(), or the recording's next part.
void setDecoding(bool decoding)
void decodingChanged(bool decoding)
const RecordingEncoding & recordingEncoding() const
void setRecording(bool recording)
bool takeScreenshot(const QString &file, const VideoScreenshot::Exif &exif={})
void setState(State state)
static QString fileExtension(FileFormat format)
"mkv", "mov" or "mp4".
VideoStreamStats stats() const
The stream's health, measured about once a second while it streams; invalid while it doesn't.
virtual void onReconnectRequested()=0
const Config & config() const
~VideoReceiver() override
@ Reconnecting
Waiting out the backoff after a failure.
@ Streaming
Data is arriving.
@ Stopped
Inactive, no URI, or given up after a failure (autoReconnect off).
@ Connecting
Pipeline running, no data yet.
QSize videoSize() const
The size of the frames as they are presented, before the orientation the VideoOutput adds.
void errorOccurred(const QString &message)
virtual void onRestartRequested()=0
virtual bool onTakeScreenshot(const QString &file, const VideoScreenshot::Exif &exif)
takeScreenshot() with an output set: saves the frame on display, unless overridden.
std::chrono::seconds timeout
bool autoReconnect
Reconnect with backoff after a failure. Applies at once; changing any other field restarts the stream...
friend bool operator==(const Config &, const Config &)=default
How the display sink presents frames. Construct-only: a change applies when restart() rebuilds the si...
bool gpuZeroCopy
Off when the CPU video path or a software decoder is forced.
friend bool operator==(const DisplayConfig &, const DisplayConfig &)=default
QByteArray conversionElement
Converter element factory; empty for the backend's default.
bool disablePixelAspectRatio
QMediaFormat::VideoCodec codec
Tried first; Unspecified for the first codec that encodes.
QMediaRecorder::Quality quality
friend bool operator==(const RecordingEncoding &, const RecordingEncoding &)=default