QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstVideoReceiver.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <functional>
5
6#include <QtCore/QLoggingCategory>
7#include <QtCore/QMetaObject>
8#include <QtCore/QString>
9
10#include "GstReceiverRequest.h"
11#include "GstScoped.h"
12#include "VideoReceiver.h"
13
15class GstVideoReceiverTestBase;
17class QThread;
18class QTimer;
19
21Q_DECLARE_LOGGING_CATEGORY(GstVideoReceiverLog)
22
23
38{
39 Q_OBJECT
40
41public:
44 // Above the worker's longest waits in a row: a recording's end (3 s), RTSP TEARDOWN (1 s), a TCP connect (3 s).
45 static constexpr std::chrono::seconds kHeartbeatInterval{10};
46
47 explicit GstVideoReceiver(QObject* parent = nullptr);
49 ~GstVideoReceiver() override;
50
53 QString decoderName() const { return _decoderName; }
54
57 void setHeartbeatInterval(std::chrono::milliseconds interval);
58
59protected:
60 void onConfigChanged() override;
61 void onActiveChanged() override;
62 void onRestartRequested() override;
63 void onReconnectRequested() override;
64 void onVideoOutputChanged() override;
65 void onStartRecording(const QString& file, FileFormat format) override;
66 void onStopRecording() override;
67
68private:
70
72 void _postToWorker(std::function<void(GstReceiverWorker&)> task);
74 void _postRequest();
75 void _onWorkerStatus(const GstReceiverStatus& status);
76 void _applyStatus(const GstReceiverStatus& status);
78 void _checkWorker();
79 void _onWorkerTaskDone();
81 void _applyStuckStatus(bool frameShown);
83 bool _buildDisplaySink(QVideoSink* videoSink);
84 void _releaseDisplaySink();
86 void _bindVideoSink(QVideoSink* videoSink);
87
88 QThread* _workerThread = nullptr;
89 GstReceiverWorker* _worker = nullptr;
91 GstReceiverRequest _request;
92 GStreamer::GstElementPtr _displaySink;
93 QGCQVideoSinkController* _sinkController = nullptr;
94 QMetaObject::Connection _videoSizeConnection;
95 QString _decoderName;
96
97 QTimer* const _heartbeatTimer;
98 quint64 _tasksPosted = 0;
99 quint64 _tasksDone = 0;
101 quint64 _tasksDoneAtCheck = 0;
103 int _stalledChecks = 0;
104 bool _workerStuck = false;
106 GstReceiverStatus _workerStatus;
108 bool _frameShown = false;
109};
Also logs the receiver's worker, its PipelineSession with the branches, and PipelineDotDumper.
QString decoderName() const
GstVideoReceiver(QObject *parent=nullptr)
static constexpr std::chrono::seconds kHeartbeatInterval
friend class GstVideoReceiverTestBase
VideoReceiver(QObject *parent=nullptr)
QVideoSink * videoSink() const
The VideoOutput's QVideoSink, or nullptr.
std::unique_ptr< GstElement, GstObjectDeleter > GstElementPtr
Definition GstScoped.h:60
Everything the receiver asks for, as it stands after each of its requests.
What the worker reports, as it stands after each change.