Commit f2d2bcbe authored by Val Doroshchuk's avatar Val Doroshchuk

pipeline and transparent rectangle

parent c498d487
......@@ -28,7 +28,7 @@ tmp
#include
src/gstreamer/qtgstreamerversion.h
QtGstreamer.version*
QtGstreamerExtras.version*
*-config*
config.*
.qmake.cache
......
......@@ -64,6 +64,7 @@ public Q_SLOTS:
QPointer<QMediaObject> mediaObject;
QPointer<QGstreamerPlayerSession> session;
QString pipeline;
QString videoSink;
bool showText = false;
QUrl textUri;
......@@ -158,6 +159,8 @@ void QGstreamerMediaPlayer::setMediaObject(QMediaObject *src)
if (!d->session)
return;
connect(d->session, &QGstreamerPlayerSession::pipelineDescChanged,
this, &QGstreamerMediaPlayer::pipelineChanged);
connect(d->session, &QGstreamerPlayerSession::videoSinkDescChanged,
this, &QGstreamerMediaPlayer::videoSinkChanged);
......@@ -194,6 +197,7 @@ void QGstreamerMediaPlayer::setMediaObject(QMediaObject *src)
// In case if these values've been applied
// before mediaObject is available.
setPipeline(d->pipeline);
setVideoSink(d->videoSink);
setShowText(d->showText);
setTextUri(d->textUri);
......@@ -203,6 +207,22 @@ void QGstreamerMediaPlayer::setMediaObject(QMediaObject *src)
emit mediaObjectChanged();
}
QString QGstreamerMediaPlayer::pipeline() const
{
Q_D(const QGstreamerMediaPlayer);
return d->session ? d->session->pipelineDesc() : d->pipeline;
}
void QGstreamerMediaPlayer::setPipeline(const QString &desc)
{
Q_D(QGstreamerMediaPlayer);
d->pipeline = desc;
if (d->session)
d->session->setPipelineDesc(desc);
}
QString QGstreamerMediaPlayer::videoSink() const
{
Q_D(const QGstreamerMediaPlayer);
......
......@@ -53,6 +53,7 @@ class Q_MULTIMEDIA_EXPORT QGstreamerMediaPlayer : public QObject
Q_PROPERTY(QObject* source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(QMediaObject* mediaObject READ mediaObject NOTIFY mediaObjectChanged SCRIPTABLE false DESIGNABLE false)
Q_PROPERTY(QString videoSink READ videoSink WRITE setVideoSink NOTIFY videoSinkChanged)
Q_PROPERTY(QString pipeline READ pipeline WRITE setPipeline NOTIFY pipelineChanged)
Q_PROPERTY(bool showText READ showText WRITE setShowText NOTIFY showTextChanged)
Q_PROPERTY(QUrl textUri READ textUri WRITE setTextUri NOTIFY textUriChanged)
Q_PROPERTY(QString textFont READ textFont WRITE setTextFont NOTIFY textFontChanged)
......@@ -74,6 +75,9 @@ public:
QMediaObject *mediaObject() const;
void setMediaObject(QMediaObject *source);
QString pipeline() const;
void setPipeline(const QString &name);
QString videoSink() const;
void setVideoSink(const QString &name);
......@@ -107,6 +111,7 @@ Q_SIGNALS:
void sourceChanged();
void mediaObjectChanged();
void videoSinkChanged();
void pipelineChanged();
void showTextChanged();
void textUriChanged();
......
......@@ -43,6 +43,7 @@
#include <QtQml/qqmlcomponent.h>
#include "qgstreamermediaplayer.h"
#include "qtransparentrectangle_p.h"
QT_BEGIN_NAMESPACE
......@@ -58,6 +59,7 @@ public:
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtGstreamerExtras"));
qmlRegisterType<QGstreamerMediaPlayer>(uri, 5, 12, "GstreamerMediaPlayer");
qmlRegisterType<QTransparentRectangle>(uri, 5, 12, "TransparentRectangle");
}
};
......
......@@ -2,10 +2,15 @@ CXX_MODULE = gstreamerextras
TARGET = declarative_gstreamer
TARGETPATH = QtGstreamerExtras
QT += gstreamerextras qtmultimediaquicktools-private multimedia-private
QT += gstreamerextras qtmultimediaquicktools-private multimedia-private quick-private
HEADERS += \
qtransparentrectangle_p.h
SOURCES += \
gstreamerextras.cpp
gstreamerextras.cpp \
qtransparentrectangle.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
......
......@@ -37,65 +37,29 @@
**
****************************************************************************/
#include "qtransparentvideobackend.h"
#include "qtransparentrectangle_p.h"
#include <private/qquickitem_p.h>
#include <private/qdeclarativevideooutput_p.h>
#include <private/qdeclarativevideooutput_render_p.h>
#include <private/qquickwindow_p.h>
#include <private/qsgadaptationlayer_p.h>
class QTransparentVideoRendererBackend : public QDeclarativeVideoRendererBackend
{
public:
QTransparentVideoRendererBackend(QDeclarativeVideoOutput *parent)
: QDeclarativeVideoRendererBackend(parent)
{}
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &changeData) override;
QSGNode *updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) override;
private:
QSGContext *m_context = nullptr;
};
void QTransparentVideoRendererBackend::itemChange(QQuickItem::ItemChange change,
const QQuickItem::ItemChangeData &changeData)
QTransparentRectangle::QTransparentRectangle(QQuickItem *parent)
: QQuickRectangle(parent)
{
Q_UNUSED(change);
if (!changeData.window)
return;
if (!m_context)
m_context = static_cast<QQuickWindowPrivate *>(QObjectPrivate::get(changeData.window))->context->sceneGraphContext();
QSurfaceFormat fmt = changeData.window->requestedFormat();
if (fmt.alphaBufferSize() != 8) {
fmt.setAlphaBufferSize(8);
changeData.window->setFormat(fmt);
}
}
QSGNode *QTransparentVideoRendererBackend::updatePaintNode(QSGNode *oldNode,
QQuickItem::UpdatePaintNodeData *data)
QSGNode *QTransparentRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
{
Q_UNUSED(data);
if (!m_context)
if (!window())
return nullptr;
QSGInternalRectangleNode *rect = static_cast<QSGInternalRectangleNode *>(oldNode);
if (!rect)
rect = m_context->createInternalRectangleNode();
rect->setColor(QColor(0, 0, 0, 0));
rect->setRect(QRectF(0, 0, q->width(), q->height()));
rect->update();
QSGInternalRectangleNode *node = static_cast<QSGInternalRectangleNode *>(oldNode);
if (!node) {
QSGContext *context = static_cast<QQuickWindowPrivate *>(QObjectPrivate::get(window()))->context->sceneGraphContext();
node = context->createInternalRectangleNode();
}
return rect;
}
node->setColor(QColor(0, 0, 0, 0));
node->setRect(QRectF(0, 0, width(), height()));
node->update();
QDeclarativeVideoBackend *QTransparentVideoNodeBackend::create(QDeclarativeVideoOutput *parent)
{
static QByteArray punch = qgetenv("QSG_VIDEOOUTPUT_PUNCH_HOLE");
static bool hole = (punch == "1" || punch == "true");
return hole ? new QTransparentVideoRendererBackend(parent) : nullptr;
return node;
}
......@@ -37,20 +37,35 @@
**
****************************************************************************/
#ifndef QTRANSPARENTVIDEOBACKEND_H
#define QTRANSPARENTVIDEOBACKEND_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <private/qdeclarativevideooutput_backend_p.h>
#ifndef QTRANSPARENTRECTANGLE_H
#define QTRANSPARENTRECTANGLE_H
#include <private/qquickrectangle_p.h>
QT_BEGIN_NAMESPACE
class QTransparentVideoNodeBackend : public QObject, public QDeclarativeVideoBackendFactoryInterface
class QTransparentRectangle : public QQuickRectangle
{
Q_OBJECT
Q_INTERFACES(QDeclarativeVideoBackendFactoryInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.declarativevideobackendfactory/5.2" FILE "transparentvideobackend.json")
Q_OBJECT
public:
QDeclarativeVideoBackend *create(QDeclarativeVideoOutput *parent) override;
QTransparentRectangle(QQuickItem *parent = nullptr);
protected:
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override;
private:
Q_DISABLE_COPY(QTransparentRectangle)
};
QT_END_NAMESPACE
......
TEMPLATE = subdirs
SUBDIRS += video
{
"Keys": ["transparentvideobackend"],
"Services": ["declarativevideobackend"]
}
TARGET = transparentvideobackend
QT += qtmultimediaquicktools-private quick-private
HEADERS += \
qtransparentvideobackend.h
SOURCES += \
qtransparentvideobackend.cpp
PLUGIN_TYPE = video/declarativevideobackend
PLUGIN_EXTENDS = quick
PLUGIN_CLASS_NAME = QTransparentVideoNodeBackend
load(qt_plugin)
TEMPLATE = subdirs
SUBDIRS += transparentvideobackend
......@@ -9,7 +9,3 @@ qtHaveModule(quick):qtConfig(opengl) {
SUBDIRS += \
src_imports
}
src_plugins.subdir = plugins
SUBDIRS += src_plugins
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment