2015-07-06 13:10:51 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __QT_ITEM_H__
|
|
|
|
#define __QT_ITEM_H__
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/gl/gl.h>
|
2015-09-02 13:45:07 +00:00
|
|
|
|
|
|
|
#include "gstqtgl.h"
|
2017-07-12 05:29:32 +00:00
|
|
|
#include <QtCore/QMutex>
|
2015-09-14 17:14:37 +00:00
|
|
|
#include <QtQuick/QQuickItem>
|
|
|
|
#include <QtGui/QOpenGLContext>
|
|
|
|
#include <QtGui/QOpenGLFunctions>
|
2015-07-06 13:10:51 +00:00
|
|
|
|
|
|
|
typedef struct _QtGLVideoItemPrivate QtGLVideoItemPrivate;
|
|
|
|
|
2017-07-12 05:29:32 +00:00
|
|
|
class QtGLVideoItem;
|
|
|
|
|
|
|
|
class QtGLVideoItemInterface : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QtGLVideoItemInterface (QtGLVideoItem *w) : qt_item (w), lock() {};
|
|
|
|
|
|
|
|
void invalidateRef();
|
|
|
|
|
|
|
|
void setBuffer (GstBuffer * buffer);
|
|
|
|
gboolean setCaps (GstCaps *caps);
|
|
|
|
gboolean initWinSys ();
|
|
|
|
GstGLContext *getQtContext();
|
|
|
|
GstGLContext *getContext();
|
|
|
|
GstGLDisplay *getDisplay();
|
|
|
|
QtGLVideoItem *videoItem () { return qt_item; };
|
|
|
|
|
|
|
|
void setDAR(gint, gint);
|
|
|
|
void getDAR(gint *, gint *);
|
|
|
|
void setForceAspectRatio(bool);
|
|
|
|
bool getForceAspectRatio();
|
|
|
|
private:
|
|
|
|
QtGLVideoItem *qt_item;
|
|
|
|
QMutex lock;
|
|
|
|
};
|
|
|
|
|
2016-01-24 14:40:37 +00:00
|
|
|
class InitializeSceneGraph;
|
|
|
|
|
2015-07-06 13:10:51 +00:00
|
|
|
class QtGLVideoItem : public QQuickItem, protected QOpenGLFunctions
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2017-09-06 07:59:56 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(bool itemInitialized
|
|
|
|
READ itemInitialized
|
|
|
|
NOTIFY itemInitializedChanged)
|
|
|
|
|
2015-07-06 13:10:51 +00:00
|
|
|
public:
|
|
|
|
QtGLVideoItem();
|
|
|
|
~QtGLVideoItem();
|
|
|
|
|
|
|
|
void setDAR(gint, gint);
|
|
|
|
void getDAR(gint *, gint *);
|
|
|
|
void setForceAspectRatio(bool);
|
|
|
|
bool getForceAspectRatio();
|
2017-09-06 07:59:56 +00:00
|
|
|
bool itemInitialized();
|
2015-07-06 13:10:51 +00:00
|
|
|
|
2017-07-12 05:29:32 +00:00
|
|
|
QSharedPointer<QtGLVideoItemInterface> getInterface() { return proxy; };
|
2015-07-06 13:10:51 +00:00
|
|
|
/* private for C interface ... */
|
|
|
|
QtGLVideoItemPrivate *priv;
|
|
|
|
|
2017-05-21 14:01:14 +00:00
|
|
|
Q_SIGNALS:
|
2017-09-06 07:59:56 +00:00
|
|
|
void itemInitializedChanged();
|
2017-05-21 14:01:14 +00:00
|
|
|
|
2015-07-06 13:10:51 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void handleWindowChanged(QQuickWindow * win);
|
|
|
|
void onSceneGraphInitialized();
|
|
|
|
void onSceneGraphInvalidated();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QSGNode * updatePaintNode (QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData);
|
|
|
|
|
|
|
|
private:
|
2017-07-12 05:29:32 +00:00
|
|
|
|
2016-01-24 14:40:37 +00:00
|
|
|
friend class InitializeSceneGraph;
|
2015-07-06 13:10:51 +00:00
|
|
|
void setViewportSize(const QSize &size);
|
|
|
|
void shareContext();
|
|
|
|
|
|
|
|
QSize m_viewportSize;
|
2016-01-24 14:40:37 +00:00
|
|
|
bool m_openGlContextInitialized;
|
2015-07-06 13:10:51 +00:00
|
|
|
|
2017-07-12 05:29:32 +00:00
|
|
|
QSharedPointer<QtGLVideoItemInterface> proxy;
|
|
|
|
};
|
2015-07-06 13:10:51 +00:00
|
|
|
|
|
|
|
#endif /* __QT_ITEM_H__ */
|