Added loading of video node factories from plugins

This change will allow us to add new video node factories that
can be loaded dynamically at runtime.

The previous video node factories, I420 and RGB have been kept
as static parts of the Qt Multimedia imports, but can be moved
to plugins at a later date.

For plugins to be able to find and use QSGVideoNode, the class
has to be exported.

Change-Id: Idbead9a8ad33619cebe90fcec92eb29cf52ae9bd
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
Jonas Rabbe
2012-02-06 10:55:59 +10:00
committed by Qt by Nokia
parent a94c8a1ac2
commit 6de7c31040
12 changed files with 180 additions and 11 deletions

View File

@@ -8,12 +8,13 @@ QT += declarative quick network multimedia-private
DESTDIR = $$QT.multimedia.imports/$$TARGETPATH DESTDIR = $$QT.multimedia.imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
LIBS += -lQtMultimediaQuick_p
HEADERS += \ HEADERS += \
qdeclarativeaudio_p.h \ qdeclarativeaudio_p.h \
qdeclarativemediabase_p.h \ qdeclarativemediabase_p.h \
qdeclarativemediametadata_p.h \ qdeclarativemediametadata_p.h \
qdeclarativevideooutput_p.h \ qdeclarativevideooutput_p.h \
qsgvideonode_p.h \
qsgvideonode_i420.h \ qsgvideonode_i420.h \
qsgvideonode_rgb.h \ qsgvideonode_rgb.h \
qdeclarativeradio_p.h \ qdeclarativeradio_p.h \
@@ -36,7 +37,6 @@ SOURCES += \
qdeclarativeaudio.cpp \ qdeclarativeaudio.cpp \
qdeclarativemediabase.cpp \ qdeclarativemediabase.cpp \
qdeclarativevideooutput.cpp \ qdeclarativevideooutput.cpp \
qsgvideonode.cpp \
qsgvideonode_i420.cpp \ qsgvideonode_i420.cpp \
qsgvideonode_rgb.cpp \ qsgvideonode_rgb.cpp \
qdeclarativeradio.cpp \ qdeclarativeradio.cpp \

View File

@@ -40,7 +40,7 @@
****************************************************************************/ ****************************************************************************/
#include "qdeclarativevideooutput_p.h" #include "qdeclarativevideooutput_p.h"
#include "qsgvideonode_p.h" #include <private/qsgvideonode_p.h>
#include "qsgvideonode_i420.h" #include "qsgvideonode_i420.h"
#include "qsgvideonode_rgb.h" #include "qsgvideonode_rgb.h"
@@ -50,7 +50,7 @@
#include <QtMultimedia/qmediaservice.h> #include <QtMultimedia/qmediaservice.h>
#include <QtMultimedia/qvideorenderercontrol.h> #include <QtMultimedia/qvideorenderercontrol.h>
#include <QtMultimedia/qvideosurfaceformat.h> #include <QtMultimedia/qvideosurfaceformat.h>
#include <private/qmediapluginloader_p.h>
#include <QtCore/qmetaobject.h> #include <QtCore/qmetaobject.h>
@@ -59,6 +59,9 @@ Q_DECLARE_METATYPE(QAbstractVideoSurface*)
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, videoNodeFactoryLoader,
(QSGVideoNodeFactory_iid, QLatin1String("video"), Qt::CaseInsensitive))
class QSGVideoItemSurface : public QAbstractVideoSurface class QSGVideoItemSurface : public QAbstractVideoSurface
{ {
public: public:
@@ -172,6 +175,14 @@ QDeclarativeVideoOutput::QDeclarativeVideoOutput(QQuickItem *parent) :
connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
this, SLOT(_q_updateNativeSize(QVideoSurfaceFormat)), Qt::QueuedConnection); this, SLOT(_q_updateNativeSize(QVideoSurfaceFormat)), Qt::QueuedConnection);
foreach (QObject *instance, videoNodeFactoryLoader()->instances(QSGVideoNodeFactoryPluginKey)) {
QSGVideoNodeFactory* plugin = qobject_cast<QSGVideoNodeFactory*>(instance);
if (plugin) {
m_videoNodeFactories.append(plugin);
}
}
// Append existing node factories as fallback if we have no plugins
m_videoNodeFactories.append(new QSGVideoNodeFactory_I420); m_videoNodeFactories.append(new QSGVideoNodeFactory_I420);
m_videoNodeFactories.append(new QSGVideoNodeFactory_RGB); m_videoNodeFactories.append(new QSGVideoNodeFactory_RGB);
} }

View File

@@ -52,7 +52,7 @@
#include <QtCore/qsharedpointer.h> #include <QtCore/qsharedpointer.h>
#include <QtCore/qmutex.h> #include <QtCore/qmutex.h>
#include "qsgvideonode_p.h" #include <private/qsgvideonode_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@@ -65,6 +65,11 @@ QSGVideoNode *QSGVideoNodeFactory_I420::createNode(const QVideoSurfaceFormat &fo
return 0; return 0;
} }
QStringList QSGVideoNodeFactory_I420::keys() const
{
return QStringList() << QSGVideoNodeFactoryPluginKey;
}
class QSGVideoMaterialShader_YUV420 : public QSGMaterialShader class QSGVideoMaterialShader_YUV420 : public QSGMaterialShader
{ {

View File

@@ -42,7 +42,7 @@
#ifndef QSGVIDEONODE_I420_H #ifndef QSGVIDEONODE_I420_H
#define QSGVIDEONODE_I420_H #define QSGVIDEONODE_I420_H
#include "qsgvideonode_p.h" #include <private/qsgvideonode_p.h>
#include <QtMultimedia/qvideosurfaceformat.h> #include <QtMultimedia/qvideosurfaceformat.h>
class QSGVideoMaterial_YUV420; class QSGVideoMaterial_YUV420;
@@ -68,6 +68,7 @@ class QSGVideoNodeFactory_I420 : public QSGVideoNodeFactory {
public: public:
QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const; QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const;
QSGVideoNode *createNode(const QVideoSurfaceFormat &format); QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
QStringList keys() const;
}; };

View File

@@ -70,6 +70,11 @@ QSGVideoNode *QSGVideoNodeFactory_RGB::createNode(const QVideoSurfaceFormat &for
return 0; return 0;
} }
QStringList QSGVideoNodeFactory_RGB::keys() const
{
return QStringList() << QSGVideoNodeFactoryPluginKey;
}
class QSGVideoMaterialShader_RGB : public QSGMaterialShader class QSGVideoMaterialShader_RGB : public QSGMaterialShader
{ {

View File

@@ -42,7 +42,7 @@
#ifndef QSGVIDEONODE_RGB_H #ifndef QSGVIDEONODE_RGB_H
#define QSGVIDEONODE_RGB_H #define QSGVIDEONODE_RGB_H
#include "qsgvideonode_p.h" #include <private/qsgvideonode_p.h>
#include <QtMultimedia/qvideosurfaceformat.h> #include <QtMultimedia/qvideosurfaceformat.h>
class QSGVideoMaterial_RGB; class QSGVideoMaterial_RGB;
@@ -68,6 +68,7 @@ class QSGVideoNodeFactory_RGB : public QSGVideoNodeFactory {
public: public:
QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const; QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const;
QSGVideoNode *createNode(const QVideoSurfaceFormat &format); QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
QStringList keys() const;
}; };

View File

@@ -43,12 +43,22 @@
#define QSGVIDEONODE_P_H #define QSGVIDEONODE_P_H
#include <QtQuick/qsgnode.h> #include <QtQuick/qsgnode.h>
#include <private/qtmultimediaquickdefs_p.h>
#include <QtMultimedia/qvideoframe.h> #include <QtMultimedia/qvideoframe.h>
#include <QtMultimedia/qvideosurfaceformat.h> #include <QtMultimedia/qvideosurfaceformat.h>
#include <QtGui/qopenglfunctions.h> #include <QtGui/qopenglfunctions.h>
#include <QtCore/qfactoryinterface.h>
class QSGVideoNode : public QSGGeometryNode QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Multimedia)
const QLatin1String QSGVideoNodeFactoryPluginKey("sgvideonodes");
class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNode : public QSGGeometryNode
{ {
public: public:
QSGVideoNode(); QSGVideoNode();
@@ -64,10 +74,17 @@ private:
int m_orientation; int m_orientation;
}; };
class QSGVideoNodeFactory { class QSGVideoNodeFactory : public QFactoryInterface {
public: public:
virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const = 0; virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const = 0;
virtual QSGVideoNode *createNode(const QVideoSurfaceFormat &format) = 0; virtual QSGVideoNode *createNode(const QVideoSurfaceFormat &format) = 0;
}; };
#define QSGVideoNodeFactory_iid "com.nokia.Qt.QSGVideoNodeFactory"
Q_DECLARE_INTERFACE(QSGVideoNodeFactory, QSGVideoNodeFactory_iid)
QT_END_NAMESPACE
QT_END_HEADER
#endif // QSGVIDEONODE_H #endif // QSGVIDEONODE_H

View File

@@ -0,0 +1,90 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
//
// 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.
//
#ifndef QMULTIMEDIAQUICKDEFS_P_H
#define QMULTIMEDIAQUICKDEFS_P_H
#include <QtCore/qglobal.h>
QT_BEGIN_HEADER
#if defined(Q_OS_WIN)
# if defined(QT_NODLL)
# undef QT_MAKEDLL
# undef QT_DLL
# elif defined(QT_MAKEDLL)
# if defined(QT_DLL)
# undef QT_DLL
# endif
# if defined(QT_BUILD_QTMM_QUICK_LIB)
# define Q_MULTIMEDIAQUICK_EXPORT Q_DECL_EXPORT
# else
# define Q_MULTIMEDIAQUICK_EXPORT Q_DECL_IMPORT
# endif
# elif defined(QT_DLL) /* use a Qt DLL library */
# define Q_MULTIMEDIAQUICK_EXPORT Q_DECL_IMPORT
# endif
#endif
#if !defined(Q_MULTIMEDIAQUICK_EXPORT)
# if defined(QT_SHARED)
# define Q_MULTIMEDIAQUICK_EXPORT Q_DECL_EXPORT
# else
# define Q_MULTIMEDIAQUICK_EXPORT
# endif
#endif
QT_END_HEADER
#endif // QMULTIMEDIAQUICKDEFS_P_H

View File

@@ -41,6 +41,8 @@
#include "qsgvideonode_p.h" #include "qsgvideonode_p.h"
QT_BEGIN_NAMESPACE
QSGVideoNode::QSGVideoNode() QSGVideoNode::QSGVideoNode()
: m_orientation(-1) : m_orientation(-1)
{ {
@@ -122,3 +124,5 @@ void QSGVideoNode::setTexturedRectGeometry(const QRectF &rect, const QRectF &tex
markDirty(DirtyGeometry); markDirty(DirtyGeometry);
} }
QT_END_NAMESPACE

View File

@@ -0,0 +1,30 @@
load(qt_module)
TEMPLATE = lib
TARGET = QtMultimediaQuick_p
QPRO_PWD = $$PWD
QT = core quick multimedia-private
!static:DEFINES += QT_MAKEDLL
DEFINES += QT_BUILD_QTMM_QUICK_LIB
# Header files must go inside source directory of a module
# to be installed by syncqt.
INCLUDEPATH += ../multimedia/qtmultimediaquicktools_headers/
DEPENDPATH += ../multimedia/qtmultimediaquicktools_headers/
PRIVATE_HEADERS += \
qsgvideonode_p.h \
qtmultimediaquickdefs_p.h
SOURCES += \
qsgvideonode_p.cpp
HEADERS += $$PRIVATE_HEADERS
DESTDIR = $$QT.multimedia.libs
target.path = $$[QT_INSTALL_LIBS]
INSTALLS += target

View File

@@ -6,6 +6,9 @@ SUBDIRS += multimedia
src_qgsttools.subdir = gsttools src_qgsttools.subdir = gsttools
src_qgsttools.depends = multimedia src_qgsttools.depends = multimedia
src_qtmultimediaquicktools.subdir = qtmultimediaquicktools
src_qtmultimediaquicktools.depends = multimedia
src_qtmmwidgets.subdir = multimediawidgets src_qtmmwidgets.subdir = multimediawidgets
src_qtmmwidgets.depends = multimedia src_qtmmwidgets.depends = multimedia
@@ -13,9 +16,11 @@ src_plugins.subdir = plugins
src_plugins.depends = multimedia src_plugins.depends = multimedia
src_imports.subdir = imports src_imports.subdir = imports
src_imports.depends = multimedia src_imports.depends = multimedia src_qtmultimediaquicktools
SUBDIRS += src_imports SUBDIRS += \
src_qtmultimediaquicktools \
src_imports
# Optional bits # Optional bits
contains(config_test_gstreamer, yes):SUBDIRS += src_qgsttools contains(config_test_gstreamer, yes):SUBDIRS += src_qgsttools