Allow plugins to override the QML VideoOutput type.
Move QDeclarativeVideoOutput to the private QtMultimediaQuickTools library to make the QDeclarativeVideoOutputBackend interface implementable by a plugin. Change-Id: I763c483a1fc9ec56dc7b8be0bc71523f029a36ee Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
a52f552d42
commit
60fb11d9a2
@@ -45,9 +45,10 @@
|
|||||||
#include <QtQml/qqmlcomponent.h>
|
#include <QtQml/qqmlcomponent.h>
|
||||||
#include "qsoundeffect.h"
|
#include "qsoundeffect.h"
|
||||||
|
|
||||||
|
#include <private/qdeclarativevideooutput_p.h>
|
||||||
|
|
||||||
#include "qdeclarativemediametadata_p.h"
|
#include "qdeclarativemediametadata_p.h"
|
||||||
#include "qdeclarativeaudio_p.h"
|
#include "qdeclarativeaudio_p.h"
|
||||||
#include "qdeclarativevideooutput_p.h"
|
|
||||||
#include "qdeclarativeradio_p.h"
|
#include "qdeclarativeradio_p.h"
|
||||||
#include "qdeclarativeradiodata_p.h"
|
#include "qdeclarativeradiodata_p.h"
|
||||||
#include "qdeclarativecamera_p.h"
|
#include "qdeclarativecamera_p.h"
|
||||||
|
|||||||
@@ -3,13 +3,6 @@ QT += qml quick network multimedia-private qtmultimediaquicktools-private
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
qdeclarativeaudio_p.h \
|
qdeclarativeaudio_p.h \
|
||||||
qdeclarativemediametadata_p.h \
|
qdeclarativemediametadata_p.h \
|
||||||
qdeclarativevideooutput_p.h \
|
|
||||||
qdeclarativevideooutput_backend_p.h \
|
|
||||||
qdeclarativevideooutput_render_p.h \
|
|
||||||
qdeclarativevideooutput_window_p.h \
|
|
||||||
qsgvideonode_i420.h \
|
|
||||||
qsgvideonode_rgb.h \
|
|
||||||
qsgvideonode_texture.h \
|
|
||||||
qdeclarativeradio_p.h \
|
qdeclarativeradio_p.h \
|
||||||
qdeclarativeradiodata_p.h \
|
qdeclarativeradiodata_p.h \
|
||||||
qdeclarativecamera_p.h \
|
qdeclarativecamera_p.h \
|
||||||
@@ -25,12 +18,6 @@ HEADERS += \
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
multimedia.cpp \
|
multimedia.cpp \
|
||||||
qdeclarativeaudio.cpp \
|
qdeclarativeaudio.cpp \
|
||||||
qdeclarativevideooutput.cpp \
|
|
||||||
qdeclarativevideooutput_render.cpp \
|
|
||||||
qdeclarativevideooutput_window.cpp \
|
|
||||||
qsgvideonode_i420.cpp \
|
|
||||||
qsgvideonode_rgb.cpp \
|
|
||||||
qsgvideonode_texture.cpp \
|
|
||||||
qdeclarativeradio.cpp \
|
qdeclarativeradio.cpp \
|
||||||
qdeclarativeradiodata.cpp \
|
qdeclarativeradiodata.cpp \
|
||||||
qdeclarativecamera.cpp \
|
qdeclarativecamera.cpp \
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include <QtCore/qsize.h>
|
#include <QtCore/qsize.h>
|
||||||
#include <QtQuick/qquickitem.h>
|
#include <QtQuick/qquickitem.h>
|
||||||
#include <QtQuick/qsgnode.h>
|
#include <QtQuick/qsgnode.h>
|
||||||
|
#include <private/qtmultimediaquickdefs_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ class QAbstractVideoSurface;
|
|||||||
class QDeclarativeVideoOutput;
|
class QDeclarativeVideoOutput;
|
||||||
class QMediaService;
|
class QMediaService;
|
||||||
|
|
||||||
class QDeclarativeVideoBackend
|
class Q_MULTIMEDIAQUICK_EXPORT QDeclarativeVideoBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit QDeclarativeVideoBackend(QDeclarativeVideoOutput *parent)
|
explicit QDeclarativeVideoBackend(QDeclarativeVideoOutput *parent)
|
||||||
@@ -82,6 +83,15 @@ protected:
|
|||||||
QPointer<QMediaService> m_service;
|
QPointer<QMediaService> m_service;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class QDeclarativeVideoBackendFactoryInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual QDeclarativeVideoBackend *create(QDeclarativeVideoOutput *parent) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define QDeclarativeVideoBackendFactoryInterface_iid "org.qt-project.qt.declarativevideobackendfactory/5.2"
|
||||||
|
Q_DECLARE_INTERFACE(QDeclarativeVideoBackendFactoryInterface, QDeclarativeVideoBackendFactoryInterface_iid)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper - returns true if the given orientation has the same aspect as the default (e.g. 180*n)
|
* Helper - returns true if the given orientation has the same aspect as the default (e.g. 180*n)
|
||||||
*/
|
*/
|
||||||
@@ -48,6 +48,8 @@
|
|||||||
#include <QtQuick/qquickitem.h>
|
#include <QtQuick/qquickitem.h>
|
||||||
#include <QtCore/qpointer.h>
|
#include <QtCore/qpointer.h>
|
||||||
|
|
||||||
|
#include <private/qtmultimediaquickdefs_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QMediaObject;
|
class QMediaObject;
|
||||||
@@ -55,7 +57,7 @@ class QMediaService;
|
|||||||
class QDeclarativeVideoBackend;
|
class QDeclarativeVideoBackend;
|
||||||
class QVideoOutputOrientationHandler;
|
class QVideoOutputOrientationHandler;
|
||||||
|
|
||||||
class QDeclarativeVideoOutput : public QQuickItem
|
class Q_MULTIMEDIAQUICK_EXPORT QDeclarativeVideoOutput : public QQuickItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(QDeclarativeVideoOutput)
|
Q_DISABLE_COPY(QDeclarativeVideoOutput)
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
virtual QSGVideoNode *createNode(const QVideoSurfaceFormat &format) = 0;
|
virtual QSGVideoNode *createNode(const QVideoSurfaceFormat &format) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define QSGVideoNodeFactoryInterface_iid "org.qt-project.qt.sgvideonodefactory/5.0"
|
#define QSGVideoNodeFactoryInterface_iid "org.qt-project.qt.sgvideonodefactory/5.2"
|
||||||
Q_DECLARE_INTERFACE(QSGVideoNodeFactoryInterface, QSGVideoNodeFactoryInterface_iid)
|
Q_DECLARE_INTERFACE(QSGVideoNodeFactoryInterface, QSGVideoNodeFactoryInterface_iid)
|
||||||
|
|
||||||
class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNodeFactoryPlugin : public QObject, public QSGVideoNodeFactoryInterface
|
class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNodeFactoryPlugin : public QObject, public QSGVideoNodeFactoryInterface
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <private/qvideooutputorientationhandler_p.h>
|
#include <private/qvideooutputorientationhandler_p.h>
|
||||||
#include <QtMultimedia/qmediaobject.h>
|
#include <QtMultimedia/qmediaobject.h>
|
||||||
#include <QtMultimedia/qmediaservice.h>
|
#include <QtMultimedia/qmediaservice.h>
|
||||||
|
#include <private/qmediapluginloader_p.h>
|
||||||
|
|
||||||
//#define DEBUG_VIDEOITEM
|
//#define DEBUG_VIDEOITEM
|
||||||
|
|
||||||
@@ -211,12 +212,28 @@ void QDeclarativeVideoOutput::setSource(QObject *source)
|
|||||||
emit sourceChanged();
|
emit sourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, videoBackendFactoryLoader,
|
||||||
|
(QDeclarativeVideoBackendFactoryInterface_iid, QLatin1String("video/declarativevideobackend"), Qt::CaseInsensitive))
|
||||||
|
|
||||||
bool QDeclarativeVideoOutput::createBackend(QMediaService *service)
|
bool QDeclarativeVideoOutput::createBackend(QMediaService *service)
|
||||||
{
|
{
|
||||||
bool backendAvailable = false;
|
bool backendAvailable = false;
|
||||||
m_backend.reset(new QDeclarativeVideoRendererBackend(this));
|
|
||||||
if (m_backend->init(service))
|
foreach (QObject *instance, videoBackendFactoryLoader()->instances(QLatin1String("declarativevideobackend"))) {
|
||||||
backendAvailable = true;
|
if (QDeclarativeVideoBackendFactoryInterface *plugin = qobject_cast<QDeclarativeVideoBackendFactoryInterface*>(instance)) {
|
||||||
|
m_backend.reset(plugin->create(this));
|
||||||
|
if (m_backend && m_backend->init(service)) {
|
||||||
|
backendAvailable = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!backendAvailable) {
|
||||||
|
m_backend.reset(new QDeclarativeVideoRendererBackend(this));
|
||||||
|
if (m_backend->init(service))
|
||||||
|
backendAvailable = true;
|
||||||
|
}
|
||||||
|
|
||||||
// QDeclarativeVideoWindowBackend only works when there is a service with a QVideoWindowControl.
|
// QDeclarativeVideoWindowBackend only works when there is a service with a QVideoWindowControl.
|
||||||
// Without service, the QDeclarativeVideoRendererBackend should always work.
|
// Without service, the QDeclarativeVideoRendererBackend should always work.
|
||||||
@@ -46,6 +46,8 @@
|
|||||||
#include <QtGui/QOpenGLFunctions>
|
#include <QtGui/QOpenGLFunctions>
|
||||||
#include <QtGui/QOpenGLShaderProgram>
|
#include <QtGui/QOpenGLShaderProgram>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_I420::supportedPixelFormats(
|
QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_I420::supportedPixelFormats(
|
||||||
QAbstractVideoBuffer::HandleType handleType) const
|
QAbstractVideoBuffer::HandleType handleType) const
|
||||||
{
|
{
|
||||||
@@ -324,3 +326,5 @@ void QSGVideoMaterialShader_YUV420::updateState(const RenderState &state,
|
|||||||
if (state.isMatrixDirty())
|
if (state.isMatrixDirty())
|
||||||
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
|
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
@@ -45,6 +45,8 @@
|
|||||||
#include <private/qsgvideonode_p.h>
|
#include <private/qsgvideonode_p.h>
|
||||||
#include <QtMultimedia/qvideosurfaceformat.h>
|
#include <QtMultimedia/qvideosurfaceformat.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QSGVideoMaterial_YUV420;
|
class QSGVideoMaterial_YUV420;
|
||||||
class QSGVideoNode_I420 : public QSGVideoNode
|
class QSGVideoNode_I420 : public QSGVideoNode
|
||||||
{
|
{
|
||||||
@@ -70,5 +72,6 @@ public:
|
|||||||
QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
|
QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QSGVIDEONODE_I420_H
|
#endif // QSGVIDEONODE_I420_H
|
||||||
@@ -46,6 +46,8 @@
|
|||||||
#include <QtGui/QOpenGLFunctions>
|
#include <QtGui/QOpenGLFunctions>
|
||||||
#include <QtGui/QOpenGLShaderProgram>
|
#include <QtGui/QOpenGLShaderProgram>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_RGB::supportedPixelFormats(
|
QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_RGB::supportedPixelFormats(
|
||||||
QAbstractVideoBuffer::HandleType handleType) const
|
QAbstractVideoBuffer::HandleType handleType) const
|
||||||
{
|
{
|
||||||
@@ -283,3 +285,5 @@ void QSGVideoMaterialShader_RGB::updateState(const RenderState &state,
|
|||||||
if (state.isMatrixDirty())
|
if (state.isMatrixDirty())
|
||||||
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
|
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
@@ -45,6 +45,8 @@
|
|||||||
#include <private/qsgvideonode_p.h>
|
#include <private/qsgvideonode_p.h>
|
||||||
#include <QtMultimedia/qvideosurfaceformat.h>
|
#include <QtMultimedia/qvideosurfaceformat.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QSGVideoMaterial_RGB;
|
class QSGVideoMaterial_RGB;
|
||||||
|
|
||||||
class QSGVideoNode_RGB : public QSGVideoNode
|
class QSGVideoNode_RGB : public QSGVideoNode
|
||||||
@@ -70,5 +72,6 @@ public:
|
|||||||
QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
|
QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QSGVIDEONODE_RGB_H
|
#endif // QSGVIDEONODE_RGB_H
|
||||||
@@ -46,6 +46,8 @@
|
|||||||
#include <QtGui/QOpenGLFunctions>
|
#include <QtGui/QOpenGLFunctions>
|
||||||
#include <QtGui/QOpenGLShaderProgram>
|
#include <QtGui/QOpenGLShaderProgram>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_Texture::supportedPixelFormats(
|
QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_Texture::supportedPixelFormats(
|
||||||
QAbstractVideoBuffer::HandleType handleType) const
|
QAbstractVideoBuffer::HandleType handleType) const
|
||||||
{
|
{
|
||||||
@@ -265,3 +267,5 @@ void QSGVideoMaterialShader_Texture::updateState(const RenderState &state,
|
|||||||
if (state.isMatrixDirty())
|
if (state.isMatrixDirty())
|
||||||
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
|
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
@@ -45,6 +45,8 @@
|
|||||||
#include <private/qsgvideonode_p.h>
|
#include <private/qsgvideonode_p.h>
|
||||||
#include <QtMultimedia/qvideosurfaceformat.h>
|
#include <QtMultimedia/qvideosurfaceformat.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QSGVideoMaterial_Texture;
|
class QSGVideoMaterial_Texture;
|
||||||
|
|
||||||
class QSGVideoNode_Texture : public QSGVideoNode
|
class QSGVideoNode_Texture : public QSGVideoNode
|
||||||
@@ -70,5 +72,6 @@ public:
|
|||||||
QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
|
QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -11,10 +11,24 @@ DEFINES += QT_BUILD_QTMM_QUICK_LIB
|
|||||||
INCLUDEPATH += ../multimedia/qtmultimediaquicktools_headers/
|
INCLUDEPATH += ../multimedia/qtmultimediaquicktools_headers/
|
||||||
|
|
||||||
PRIVATE_HEADERS += \
|
PRIVATE_HEADERS += \
|
||||||
|
../multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_p.h \
|
||||||
|
../multimedia/qtmultimediaquicktools_headers/qdeclarativevideooutput_backend_p.h \
|
||||||
../multimedia/qtmultimediaquicktools_headers/qsgvideonode_p.h \
|
../multimedia/qtmultimediaquicktools_headers/qsgvideonode_p.h \
|
||||||
../multimedia/qtmultimediaquicktools_headers/qtmultimediaquickdefs_p.h
|
../multimedia/qtmultimediaquicktools_headers/qtmultimediaquickdefs_p.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
qsgvideonode_p.cpp
|
qsgvideonode_p.cpp \
|
||||||
|
qdeclarativevideooutput.cpp \
|
||||||
|
qdeclarativevideooutput_render.cpp \
|
||||||
|
qdeclarativevideooutput_window.cpp \
|
||||||
|
qsgvideonode_i420.cpp \
|
||||||
|
qsgvideonode_rgb.cpp \
|
||||||
|
qsgvideonode_texture.cpp
|
||||||
|
|
||||||
HEADERS += $$PRIVATE_HEADERS
|
HEADERS += \
|
||||||
|
$$PRIVATE_HEADERS \
|
||||||
|
qdeclarativevideooutput_render_p.h \
|
||||||
|
qdeclarativevideooutput_window_p.h \
|
||||||
|
qsgvideonode_i420.h \
|
||||||
|
qsgvideonode_rgb.h \
|
||||||
|
qsgvideonode_texture.h
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ TARGET = tst_qdeclarativevideooutput
|
|||||||
QT += multimedia-private qml testlib quick
|
QT += multimedia-private qml testlib quick
|
||||||
CONFIG += testcase
|
CONFIG += testcase
|
||||||
|
|
||||||
OTHER_FILES += \
|
|
||||||
../../../../src/imports/multimedia/qdeclarativevideooutput_p.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
tst_qdeclarativevideooutput.cpp
|
tst_qdeclarativevideooutput.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
#include <QtQml/qqmlengine.h>
|
#include <QtQml/qqmlengine.h>
|
||||||
#include <QtQml/qqmlcomponent.h>
|
#include <QtQml/qqmlcomponent.h>
|
||||||
|
|
||||||
#include "qdeclarativevideooutput_p.h"
|
#include "private/qdeclarativevideooutput_p.h"
|
||||||
|
|
||||||
#include <qabstractvideosurface.h>
|
#include <qabstractvideosurface.h>
|
||||||
#include <qvideorenderercontrol.h>
|
#include <qvideorenderercontrol.h>
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ TARGET = tst_qdeclarativevideooutput_window
|
|||||||
QT += multimedia-private qml testlib quick
|
QT += multimedia-private qml testlib quick
|
||||||
CONFIG += testcase
|
CONFIG += testcase
|
||||||
|
|
||||||
OTHER_FILES += \
|
|
||||||
../../../../src/imports/multimedia/qdeclarativevideooutput_p.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
tst_qdeclarativevideooutput_window.cpp
|
tst_qdeclarativevideooutput_window.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
//TESTED_COMPONENT=plugins/declarative/multimedia
|
//TESTED_COMPONENT=plugins/declarative/multimedia
|
||||||
|
|
||||||
#include "qdeclarativevideooutput_p.h"
|
#include "private/qdeclarativevideooutput_p.h"
|
||||||
#include <QtCore/qobject.h>
|
#include <QtCore/qobject.h>
|
||||||
#include <QtTest/qtest.h>
|
#include <QtTest/qtest.h>
|
||||||
#include <QtQml/qqmlengine.h>
|
#include <QtQml/qqmlengine.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user