3 * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
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.
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.
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.
25 #include <gst/gl/gl.h>
28 #include <QtCore/QMutex>
29 #include <QtQuick/QQuickItem>
30 #include <QtGui/QOpenGLContext>
31 #include <QtGui/QOpenGLFunctions>
33 typedef struct _QtGLVideoItemPrivate QtGLVideoItemPrivate;
37 class QtGLVideoItemInterface : public QObject
41 QtGLVideoItemInterface (QtGLVideoItem *w) : qt_item (w), lock() {};
45 void setBuffer (GstBuffer * buffer);
46 gboolean setCaps (GstCaps *caps);
47 gboolean initWinSys ();
48 GstGLContext *getQtContext();
49 GstGLContext *getContext();
50 GstGLDisplay *getDisplay();
51 QtGLVideoItem *videoItem () { return qt_item; };
53 void setDAR(gint, gint);
54 void getDAR(gint *, gint *);
55 void setForceAspectRatio(bool);
56 bool getForceAspectRatio();
58 QtGLVideoItem *qt_item;
62 class InitializeSceneGraph;
64 class QtGLVideoItem : public QQuickItem, protected QOpenGLFunctions
68 Q_PROPERTY(bool itemInitialized
70 NOTIFY itemInitializedChanged)
76 void setDAR(gint, gint);
77 void getDAR(gint *, gint *);
78 void setForceAspectRatio(bool);
79 bool getForceAspectRatio();
80 bool itemInitialized();
82 QSharedPointer<QtGLVideoItemInterface> getInterface() { return proxy; };
83 /* private for C interface ... */
84 QtGLVideoItemPrivate *priv;
87 void itemInitializedChanged();
90 void handleWindowChanged(QQuickWindow * win);
91 void onSceneGraphInitialized();
92 void onSceneGraphInvalidated();
95 QSGNode * updatePaintNode (QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData);
99 friend class InitializeSceneGraph;
100 void setViewportSize(const QSize &size);
103 QSize m_viewportSize;
104 bool m_openGlContextInitialized;
106 QSharedPointer<QtGLVideoItemInterface> proxy;
109 #endif /* __QT_ITEM_H__ */