QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VideoReceiver.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QObject>
4#include <QtCore/QSize>
5#include <QtCore/QTimer>
6#include <QtQmlIntegration/QtQmlIntegration>
7
9class QQuickItem;
10
11class VideoReceiver : public QObject
12{
13 Q_OBJECT
14 QML_ELEMENT
15 QML_UNCREATABLE("")
16public:
17 explicit VideoReceiver(QObject *parent = nullptr)
18 : QObject(parent)
19 {}
20
21 bool isThermal() const { return (_name == QStringLiteral("thermalVideo")); }
22
23 void *sink() { return _sink; }
24 QQuickItem *widget() { return _widget; }
25 QString name() const { return _name; }
26 QString uri() const { return _uri; }
27 bool started() const { return _started; }
28 bool lowLatency() const { return _lowLatency; }
30 QString recordingOutput() const { return _recordingOutput; }
31
32 virtual void setSink(void *sink) { if (sink != _sink) { _sink = sink; emit sinkChanged(_sink); } }
33 virtual void setWidget(QQuickItem *widget) { if (widget != _widget) { _widget = widget; emit widgetChanged(_widget); } }
34 void setName(const QString &name) { if (name != _name) { _name = name; emit nameChanged(_name); } }
35 void setUri(const QString &uri) { if (uri != _uri) { _uri = uri; emit uriChanged(_uri); } }
39
40 // QMediaFormat::FileFormat
48 Q_ENUM(FILE_FORMAT)
49 static bool isValidFileFormat(FILE_FORMAT format) { return ((format >= FILE_FORMAT_MIN) && (format <= FILE_FORMAT_MAX)); }
50
60 Q_ENUM(STATUS)
61 static bool isValidStatus(STATUS status) { return ((status >= STATUS_MIN) && (status <= STATUS_MAX)); }
62
63signals:
64 void timeout();
65 void streamingChanged(bool active);
66 void decodingChanged(bool active);
67 void recordingChanged(bool active);
68 void recordingStarted(const QString &filename);
69 void videoSizeChanged(QSize size);
70
71 void sinkChanged(void *sink);
72 void nameChanged(const QString &name);
73 void uriChanged(const QString &uri);
77 void widgetChanged(QQuickItem *widget);
78
79 void onStartComplete(STATUS status);
80 void onStopComplete(STATUS status);
86
87public slots:
88 virtual void start(uint32_t timeout) = 0;
89 virtual void stop() = 0;
90 virtual void startDecoding(void *sink) = 0;
91 virtual void stopDecoding() = 0;
92 virtual void startRecording(const QString &videoFile, FILE_FORMAT format) = 0;
93 virtual void stopRecording() = 0;
94 virtual void takeScreenshot(const QString &imageFile) = 0;
95
96protected:
97 void *_sink = nullptr;
98 QQuickItem *_widget = nullptr;
100 QString _name;
101 QString _uri;
102 bool _started = false;
103 bool _decoding = false;
104 bool _recording = false;
105 bool _streaming = false;
106 bool _lowLatency = false;
107 bool _resetVideoSink = false;
108 bool _endOfStream = false;
109 bool _removingDecoder = false;
110 bool _removingRecorder = false;
111 // buffer:
112 // -1 - disable buffer and video sync
113 // 0 - default buffer length
114 // N - buffer length, ms
115 int _buffer = 0;
119 uint32_t _signalDepth = 0;
120 uint32_t _timeout = 0;
122
123 // bool _initialized = false;
124 // bool _fullScreen = false;
125 // QSize _videoSize;
126 // QString _imageFile;
127};
Encapsulates the contents of a VIDEO_STREAM_INFORMATION message.
void recordingStarted(const QString &filename)
QTimer _watchdogTimer
bool lowLatency() const
QGCVideoStreamInfo * _videoStreamInfo
void setLowLatency(bool lowLatency)
void setName(const QString &name)
void videoSizeChanged(QSize size)
void sinkChanged(void *sink)
void streamingChanged(bool active)
qint64 _lastSourceFrameTime
void nameChanged(const QString &name)
virtual void stopRecording()=0
virtual void startRecording(const QString &videoFile, FILE_FORMAT format)=0
static bool isValidStatus(STATUS status)
uint32_t _timeout
bool started() const
VideoReceiver(QObject *parent=nullptr)
qint64 _lastVideoFrameTime
QQuickItem * widget()
void lowLatencyChanged(bool lowLatency)
QString uri() const
QString _recordingOutput
void recordingChanged(bool active)
void onStartRecordingComplete(STATUS status)
void videoStreamInfoChanged()
virtual void setSink(void *sink)
bool isThermal() const
virtual void start(uint32_t timeout)=0
void onTakeScreenshotComplete(STATUS status)
void decodingChanged(bool active)
void onStartComplete(STATUS status)
void startedChanged(bool started)
void setStarted(bool started)
void setUri(const QString &uri)
static bool isValidFileFormat(FILE_FORMAT format)
void widgetChanged(QQuickItem *widget)
QString name() const
void onStopDecodingComplete(STATUS status)
virtual void setWidget(QQuickItem *widget)
virtual void startDecoding(void *sink)=0
void onStopRecordingComplete(STATUS status)
void uriChanged(const QString &uri)
virtual void stopDecoding()=0
QString recordingOutput() const
void setVideoStreamInfo(QGCVideoStreamInfo *videoStreamInfo)
void onStartDecodingComplete(STATUS status)
QQuickItem * _widget
void onStopComplete(STATUS status)
virtual void stop()=0
virtual void takeScreenshot(const QString &imageFile)=0
QGCVideoStreamInfo * videoStreamInfo()
uint32_t _signalDepth