QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCQVideoSinkController.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QList>
4#include <QtCore/QMetaObject>
5#include <QtCore/QMutex>
6#include <QtCore/QObject>
7#include <QtCore/QPointer>
8#include <QtCore/QSize>
9#include <QtCore/QString>
10#include <QtCore/QTimer>
11#include <gst/gst.h>
12
13class QQuickVideoOutput;
14class QVideoSink;
15
20class QGCQVideoSinkController : public QObject
21{
22 Q_OBJECT
23
24 Q_PROPERTY(quint64 frameCount READ frameCount NOTIFY frameCountsChanged)
25 Q_PROPERTY(QString negotiatedFormat READ negotiatedFormat NOTIFY negotiationChanged)
27
28public:
31 QGCQVideoSinkController(GstElement* element, QObject* parent = nullptr);
32 ~QGCQVideoSinkController() override;
33
35 static QList<QGCQVideoSinkController*> controllersOf(const QObject* receiver);
36
39 static void syncActiveToWindowVisibility(QObject* receiver, QQuickVideoOutput* videoOutput);
40
41 // setActive(false) drops frames at the element; setVideoSink swaps the destination under
42 // GST_OBJECT_LOCK. QPointer so a caller-thread destruction race is caught here, not in GObject.
43 void setActive(bool active);
44 void setVideoSink(QPointer<QVideoSink> sink);
45
48 void prepareForRelease();
49
50 const GstElement* element() const noexcept;
51 void updateNegotiation(const QString& format, const QSize& resolution);
52
53 quint64 frameCount() const noexcept;
54 QString negotiatedFormat() const;
55 QSize negotiatedResolution() const;
56
57public slots:
60 void refreshLatency();
61
62signals:
65
66private:
67 void _releaseElementBinding() noexcept;
68 void _onEmitTimer();
69
70 GstElement* _element = nullptr; // owned ref
71 QMetaObject::Connection _sinkDestroyedConnection;
72 bool _bindingReleased = false;
73 QTimer _emitTimer;
74
75 mutable QMutex _stateMutex;
76 QString _negotiatedFormat;
77 QSize _negotiatedResolution;
78 quint64 _lastEmittedFrameTotal = 0;
79};
struct _GstElement GstElement
static QList< QGCQVideoSinkController * > controllersOf(const QObject *receiver)
A receiver's owning controllers — direct children only, never a deep QObject-tree walk.
const GstElement * element() const noexcept
void updateNegotiation(const QString &format, const QSize &resolution)
void setVideoSink(QPointer< QVideoSink > sink)
quint64 frameCount() const noexcept
static void syncActiveToWindowVisibility(QObject *receiver, QQuickVideoOutput *videoOutput)