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 <gst/gst.h>
4
5#include <QtCore/QMetaObject>
6#include <QtCore/QObject>
7#include <QtCore/QPointer>
8#include <QtCore/QSize>
9#include <QtQuick/QQuickItem>
10
11#include "GstScoped.h"
12
13class QVideoSink;
14
19class QGCQVideoSinkController : public QObject
20{
21 Q_OBJECT
22
23public:
26 QGCQVideoSinkController(GstElement* element, QObject* parent = nullptr);
27 ~QGCQVideoSinkController() override;
28
29 // setActive(false) drops frames at the element; setVideoSink swaps the destination under
30 // GST_OBJECT_LOCK. QPointer so a caller-thread destruction race is caught here, not in GObject.
31 // Releasing a binding (swap, null, prepareForRelease, destruction) also clears the released QVideoSink's
32 // current frame so it stops pinning a GstSample/decoder buffer.
33 // Without a QVideoSink the element is inactive whatever was asked for; binding one again goes on with what
34 // setActive() asked for last (the window's visibility while following one), which is active to begin with.
35 void setActive(bool active);
36 void setVideoSink(QPointer<QVideoSink> sink);
37
40 void followWindowVisibility(QQuickItem* videoOutput);
41
44 void prepareForRelease();
45
48 void releaseFrame();
49
52 QSize pictureSize() const;
53
54private:
55 void _releaseElementBinding();
56 void _clearVideoSinkFrame();
57 void _applyWindowVisibility();
58
60 QPointer<QVideoSink> _videoSink;
61 QMetaObject::Connection _sinkDestroyedConnection;
62 bool _bindingReleased = false;
64 bool _active = true;
65
66 QPointer<QQuickItem> _videoOutput;
67 QMetaObject::Connection _visibilityConnection;
68};
struct _GstElement GstElement
QGCQVideoSinkController(GstElement *element, QObject *parent=nullptr)
void setVideoSink(QPointer< QVideoSink > sink)
void followWindowVisibility(QQuickItem *videoOutput)
std::unique_ptr< GstElement, GstObjectDeleter > GstElementPtr
Definition GstScoped.h:60