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
71 void setDAR(gint, gint);
72 void getDAR(gint *, gint *);
73 void setForceAspectRatio(bool);
74 bool getForceAspectRatio();
76 QSharedPointer<QtGLVideoItemInterface> getInterface() { return proxy; };
77 /* private for C interface ... */
78 QtGLVideoItemPrivate *priv;
81 void itemInitialized();
84 void handleWindowChanged(QQuickWindow * win);
85 void onSceneGraphInitialized();
86 void onSceneGraphInvalidated();
89 QSGNode * updatePaintNode (QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData);
93 friend class InitializeSceneGraph;
94 void setViewportSize(const QSize &size);
98 bool m_openGlContextInitialized;
100 QSharedPointer<QtGLVideoItemInterface> proxy;
103 #endif /* __QT_ITEM_H__ */