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();
|
|
|
|
|
2020-04-15 09:38:04 +00:00
|
|
|
void setSink (GstElement * sink);
|
2017-07-12 05:29:32 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
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)
|
2021-03-31 08:52:14 +00:00
|
|
|
Q_PROPERTY(bool forceAspectRatio
|
|
|
|
READ getForceAspectRatio
|
|
|
|
WRITE setForceAspectRatio
|
|
|
|
NOTIFY forceAspectRatioChanged)
|
2017-09-06 07:59:56 +00:00
|
|
|
|
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();
|
2021-03-31 08:52:14 +00:00
|
|
|
void forceAspectRatioChanged(bool);
|
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:
|
2021-07-05 15:12:57 +00:00
|
|
|
QSGNode * updatePaintNode (QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) override;
|
2020-04-15 09:38:04 +00:00
|
|
|
void wheelEvent(QWheelEvent *) override;
|
|
|
|
void hoverEnterEvent(QHoverEvent *) override;
|
|
|
|
void hoverLeaveEvent (QHoverEvent *) override;
|
|
|
|
void hoverMoveEvent (QHoverEvent *) override;
|
|
|
|
void mousePressEvent(QMouseEvent*) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent*) override;
|
2015-07-06 13:10:51 +00:00
|
|
|
|
|
|
|
private:
|
2017-07-12 05:29:32 +00:00
|
|
|
|
2015-07-06 13:10:51 +00:00
|
|
|
void setViewportSize(const QSize &size);
|
|
|
|
void shareContext();
|
|
|
|
|
2020-04-15 09:38:04 +00:00
|
|
|
void fitStreamToAllocatedSize(GstVideoRectangle * result);
|
|
|
|
QPointF mapPointToStreamSize(QPointF);
|
|
|
|
|
|
|
|
void sendMouseEvent(QMouseEvent * event, const gchar * type);
|
2021-07-30 10:21:46 +00:00
|
|
|
|
|
|
|
quint32 mousePressedButton;
|
|
|
|
bool mouseHovering;
|
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__ */
|