QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
qt6glitem.h
Go to the documentation of this file.
1/*
2 * GStreamer
3 * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef __QT6_GL_ITEM_H__
22#define __QT6_GL_ITEM_H__
23
24#include <gst/gst.h>
25#include <gst/gl/gl.h>
26
27#include "gstqt6gl.h"
28#include <QtCore/QMutex>
29#include <QtQuick/QQuickItem>
30#include <QtGui/QOpenGLContext>
31#include <QtGui/QOpenGLFunctions>
32#include <QtQuick/QQuickWindow>
33
35
36class Qt6GLVideoItem;
37
38class Qt6GLVideoItemInterface : public QObject
39{
40 Q_OBJECT
41 QML_ELEMENT
42public:
43 Qt6GLVideoItemInterface (Qt6GLVideoItem *w) : qt_item (w), lock() {};
44
45 void invalidateRef();
46
47 void setSink (GstElement * sink);
48 void setBuffer (GstBuffer * buffer);
49 gboolean setCaps (GstCaps *caps);
50 gboolean initWinSys ();
51 GstGLContext *getQtContext();
52 GstGLContext *getContext();
53 GstGLDisplay *getDisplay();
54 Qt6GLVideoItem *videoItem () { return qt_item; };
55
56 void setDAR(gint, gint);
57 void getDAR(gint *, gint *);
58 void setForceAspectRatio(bool);
60private:
61 Qt6GLVideoItem *qt_item;
62 QMutex lock;
63};
64
65class Qt6GLVideoItem : public QQuickItem, protected QOpenGLFunctions
66{
67 Q_OBJECT
68 QML_ELEMENT
69
70 Q_PROPERTY(bool itemInitialized
71 READ itemInitialized
73 Q_PROPERTY(bool forceAspectRatio
74 READ getForceAspectRatio
75 WRITE setForceAspectRatio
77
78public:
81
82 void setDAR(gint, gint);
83 void getDAR(gint *, gint *);
84 void setForceAspectRatio(bool);
85 bool getForceAspectRatio();
86 bool itemInitialized();
87
88 QSharedPointer<Qt6GLVideoItemInterface> getInterface() { return proxy; };
89 /* private for C interface ... */
91
92Q_SIGNALS:
95
96private Q_SLOTS:
97 void handleWindowChanged(QQuickWindow * win);
98 void onSceneGraphInitialized();
99 void onSceneGraphInvalidated();
100
101protected:
102 QSGNode * updatePaintNode (QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) override;
103 void releaseResources() override;
104 void wheelEvent(QWheelEvent *) override;
105 void hoverEnterEvent(QHoverEvent *) override;
106 void hoverLeaveEvent (QHoverEvent *) override;
107 void hoverMoveEvent (QHoverEvent *) override;
108 void mousePressEvent(QMouseEvent*) override;
109 void mouseReleaseEvent(QMouseEvent*) override;
110 void touchEvent(QTouchEvent*) override;
111
112private:
113
114 void setViewportSize(const QSize &size);
115 void shareContext();
116
117 void fitStreamToAllocatedSize(GstVideoRectangle * result);
118 QPointF mapPointToStreamSize(QPointF);
119
120 void sendMouseEvent(QMouseEvent * event, gboolean is_press);
121
122 quint32 mousePressedButton;
123 bool mouseHovering;
124
125 QSharedPointer<Qt6GLVideoItemInterface> proxy;
126};
127
128#endif /* __QT_GL_ITEM_H__ */
struct _GstElement GstElement
Qt6GLVideoItem * videoItem()
Definition qt6glitem.h:54
GstGLDisplay * getDisplay()
Definition qt6glitem.cc:702
void getDAR(gint *, gint *)
Definition qt6glitem.cc:722
void setBuffer(GstBuffer *buffer)
Definition qt6glitem.cc:477
gboolean setCaps(GstCaps *caps)
Definition qt6glitem.cc:649
Qt6GLVideoItemInterface(Qt6GLVideoItem *w)
Definition qt6glitem.h:43
void setDAR(gint, gint)
Definition qt6glitem.cc:713
GstGLContext * getContext()
Definition qt6glitem.cc:691
void setForceAspectRatio(bool)
Definition qt6glitem.cc:731
void setSink(GstElement *sink)
Definition qt6glitem.cc:465
GstGLContext * getQtContext()
Definition qt6glitem.cc:680
void mouseReleaseEvent(QMouseEvent *) override
Definition qt6glitem.cc:459
void hoverEnterEvent(QHoverEvent *) override
Definition qt6glitem.cc:422
void hoverLeaveEvent(QHoverEvent *) override
Definition qt6glitem.cc:428
void mousePressEvent(QMouseEvent *) override
Definition qt6glitem.cc:452
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override
Definition qt6glitem.cc:274
void forceAspectRatioChanged(bool)
void itemInitializedChanged()
void wheelEvent(QWheelEvent *) override
Definition qt6glitem.cc:416
void hoverMoveEvent(QHoverEvent *) override
Definition qt6glitem.cc:434
void releaseResources() override
Definition qt6glitem.cc:643
void touchEvent(QTouchEvent *) override
Definition qt6glitem.cc:440