summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Rabbe <jonas.rabbe@nokia.com>2012-02-06 10:55:59 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-08 04:38:16 +0100
commit6de7c3104006c3aa919a697bc94ec99a3f0c4140 (patch)
tree6c3a264f2adc265d39f4c1359619e63194b90fda
parenta94c8a1ac26f4a5a79d63672d21538d016bc09f4 (diff)
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>
-rw-r--r--src/imports/multimedia/multimedia.pro4
-rw-r--r--src/imports/multimedia/qdeclarativevideooutput.cpp15
-rw-r--r--src/imports/multimedia/qdeclarativevideooutput_p.h2
-rw-r--r--src/imports/multimedia/qsgvideonode_i420.cpp5
-rw-r--r--src/imports/multimedia/qsgvideonode_i420.h3
-rw-r--r--src/imports/multimedia/qsgvideonode_rgb.cpp5
-rw-r--r--src/imports/multimedia/qsgvideonode_rgb.h3
-rw-r--r--src/multimedia/qtmultimediaquicktools_headers/qsgvideonode_p.h (renamed from src/imports/multimedia/qsgvideonode_p.h)21
-rw-r--r--src/multimedia/qtmultimediaquicktools_headers/qtmultimediaquickdefs_p.h90
-rw-r--r--src/qtmultimediaquicktools/qsgvideonode_p.cpp (renamed from src/imports/multimedia/qsgvideonode.cpp)4
-rw-r--r--src/qtmultimediaquicktools/qtmultimediaquicktools.pro30
-rw-r--r--src/src.pro9
12 files changed, 180 insertions, 11 deletions
diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro
index df01cc6b6..6bf5fbadd 100644
--- a/src/imports/multimedia/multimedia.pro
+++ b/src/imports/multimedia/multimedia.pro
@@ -8,12 +8,13 @@ QT += declarative quick network multimedia-private
DESTDIR = $$QT.multimedia.imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+LIBS += -lQtMultimediaQuick_p
+
HEADERS += \
qdeclarativeaudio_p.h \
qdeclarativemediabase_p.h \
qdeclarativemediametadata_p.h \
qdeclarativevideooutput_p.h \
- qsgvideonode_p.h \
qsgvideonode_i420.h \
qsgvideonode_rgb.h \
qdeclarativeradio_p.h \
@@ -36,7 +37,6 @@ SOURCES += \
qdeclarativeaudio.cpp \
qdeclarativemediabase.cpp \
qdeclarativevideooutput.cpp \
- qsgvideonode.cpp \
qsgvideonode_i420.cpp \
qsgvideonode_rgb.cpp \
qdeclarativeradio.cpp \
diff --git a/src/imports/multimedia/qdeclarativevideooutput.cpp b/src/imports/multimedia/qdeclarativevideooutput.cpp
index 21c09904b..58a2c8191 100644
--- a/src/imports/multimedia/qdeclarativevideooutput.cpp
+++ b/src/imports/multimedia/qdeclarativevideooutput.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include "qdeclarativevideooutput_p.h"
-#include "qsgvideonode_p.h"
+#include <private/qsgvideonode_p.h>
#include "qsgvideonode_i420.h"
#include "qsgvideonode_rgb.h"
@@ -50,7 +50,7 @@
#include <QtMultimedia/qmediaservice.h>
#include <QtMultimedia/qvideorenderercontrol.h>
#include <QtMultimedia/qvideosurfaceformat.h>
-
+#include <private/qmediapluginloader_p.h>
#include <QtCore/qmetaobject.h>
@@ -59,6 +59,9 @@ Q_DECLARE_METATYPE(QAbstractVideoSurface*)
QT_BEGIN_NAMESPACE
+Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, videoNodeFactoryLoader,
+ (QSGVideoNodeFactory_iid, QLatin1String("video"), Qt::CaseInsensitive))
+
class QSGVideoItemSurface : public QAbstractVideoSurface
{
public:
@@ -172,6 +175,14 @@ QDeclarativeVideoOutput::QDeclarativeVideoOutput(QQuickItem *parent) :
connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
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_RGB);
}
diff --git a/src/imports/multimedia/qdeclarativevideooutput_p.h b/src/imports/multimedia/qdeclarativevideooutput_p.h
index 59e2ce371..13710b1a6 100644
--- a/src/imports/multimedia/qdeclarativevideooutput_p.h
+++ b/src/imports/multimedia/qdeclarativevideooutput_p.h
@@ -52,7 +52,7 @@
#include <QtCore/qsharedpointer.h>
#include <QtCore/qmutex.h>
-#include "qsgvideonode_p.h"
+#include <private/qsgvideonode_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/imports/multimedia/qsgvideonode_i420.cpp b/src/imports/multimedia/qsgvideonode_i420.cpp
index ef075eb95..3ee9e851b 100644
--- a/src/imports/multimedia/qsgvideonode_i420.cpp
+++ b/src/imports/multimedia/qsgvideonode_i420.cpp
@@ -65,6 +65,11 @@ QSGVideoNode *QSGVideoNodeFactory_I420::createNode(const QVideoSurfaceFormat &fo
return 0;
}
+QStringList QSGVideoNodeFactory_I420::keys() const
+{
+ return QStringList() << QSGVideoNodeFactoryPluginKey;
+}
+
class QSGVideoMaterialShader_YUV420 : public QSGMaterialShader
{
diff --git a/src/imports/multimedia/qsgvideonode_i420.h b/src/imports/multimedia/qsgvideonode_i420.h
index e37abd9aa..4ab1139fe 100644
--- a/src/imports/multimedia/qsgvideonode_i420.h
+++ b/src/imports/multimedia/qsgvideonode_i420.h
@@ -42,7 +42,7 @@
#ifndef QSGVIDEONODE_I420_H
#define QSGVIDEONODE_I420_H
-#include "qsgvideonode_p.h"
+#include <private/qsgvideonode_p.h>
#include <QtMultimedia/qvideosurfaceformat.h>
class QSGVideoMaterial_YUV420;
@@ -68,6 +68,7 @@ class QSGVideoNodeFactory_I420 : public QSGVideoNodeFactory {
public:
QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const;
QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
+ QStringList keys() const;
};
diff --git a/src/imports/multimedia/qsgvideonode_rgb.cpp b/src/imports/multimedia/qsgvideonode_rgb.cpp
index b7fd9c793..30ebd54a4 100644
--- a/src/imports/multimedia/qsgvideonode_rgb.cpp
+++ b/src/imports/multimedia/qsgvideonode_rgb.cpp
@@ -70,6 +70,11 @@ QSGVideoNode *QSGVideoNodeFactory_RGB::createNode(const QVideoSurfaceFormat &for
return 0;
}
+QStringList QSGVideoNodeFactory_RGB::keys() const
+{
+ return QStringList() << QSGVideoNodeFactoryPluginKey;
+}
+
class QSGVideoMaterialShader_RGB : public QSGMaterialShader
{
diff --git a/src/imports/multimedia/qsgvideonode_rgb.h b/src/imports/multimedia/qsgvideonode_rgb.h
index dd5a852e3..d43653525 100644
--- a/src/imports/multimedia/qsgvideonode_rgb.h
+++ b/src/imports/multimedia/qsgvideonode_rgb.h
@@ -42,7 +42,7 @@
#ifndef QSGVIDEONODE_RGB_H
#define QSGVIDEONODE_RGB_H
-#include "qsgvideonode_p.h"
+#include <private/qsgvideonode_p.h>
#include <QtMultimedia/qvideosurfaceformat.h>
class QSGVideoMaterial_RGB;
@@ -68,6 +68,7 @@ class QSGVideoNodeFactory_RGB : public QSGVideoNodeFactory {
public:
QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const;
QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
+ QStringList keys() const;
};
diff --git a/src/imports/multimedia/qsgvideonode_p.h b/src/multimedia/qtmultimediaquicktools_headers/qsgvideonode_p.h
index 271eb868d..f82a337ed 100644
--- a/src/imports/multimedia/qsgvideonode_p.h
+++ b/src/multimedia/qtmultimediaquicktools_headers/qsgvideonode_p.h
@@ -43,12 +43,22 @@
#define QSGVIDEONODE_P_H
#include <QtQuick/qsgnode.h>
+#include <private/qtmultimediaquickdefs_p.h>
#include <QtMultimedia/qvideoframe.h>
#include <QtMultimedia/qvideosurfaceformat.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:
QSGVideoNode();
@@ -64,10 +74,17 @@ private:
int m_orientation;
};
-class QSGVideoNodeFactory {
+class QSGVideoNodeFactory : public QFactoryInterface {
public:
virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const = 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
diff --git a/src/multimedia/qtmultimediaquicktools_headers/qtmultimediaquickdefs_p.h b/src/multimedia/qtmultimediaquicktools_headers/qtmultimediaquickdefs_p.h
new file mode 100644
index 000000000..a204b5fec
--- /dev/null
+++ b/src/multimedia/qtmultimediaquicktools_headers/qtmultimediaquickdefs_p.h
@@ -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
+
diff --git a/src/imports/multimedia/qsgvideonode.cpp b/src/qtmultimediaquicktools/qsgvideonode_p.cpp
index b0d2ad32a..2c9f24101 100644
--- a/src/imports/multimedia/qsgvideonode.cpp
+++ b/src/qtmultimediaquicktools/qsgvideonode_p.cpp
@@ -41,6 +41,8 @@
#include "qsgvideonode_p.h"
+QT_BEGIN_NAMESPACE
+
QSGVideoNode::QSGVideoNode()
: m_orientation(-1)
{
@@ -122,3 +124,5 @@ void QSGVideoNode::setTexturedRectGeometry(const QRectF &rect, const QRectF &tex
markDirty(DirtyGeometry);
}
+
+QT_END_NAMESPACE
diff --git a/src/qtmultimediaquicktools/qtmultimediaquicktools.pro b/src/qtmultimediaquicktools/qtmultimediaquicktools.pro
new file mode 100644
index 000000000..a94ab8482
--- /dev/null
+++ b/src/qtmultimediaquicktools/qtmultimediaquicktools.pro
@@ -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
diff --git a/src/src.pro b/src/src.pro
index df94ec644..8a5537109 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -6,6 +6,9 @@ SUBDIRS += multimedia
src_qgsttools.subdir = gsttools
src_qgsttools.depends = multimedia
+src_qtmultimediaquicktools.subdir = qtmultimediaquicktools
+src_qtmultimediaquicktools.depends = multimedia
+
src_qtmmwidgets.subdir = multimediawidgets
src_qtmmwidgets.depends = multimedia
@@ -13,9 +16,11 @@ src_plugins.subdir = plugins
src_plugins.depends = multimedia
src_imports.subdir = imports
-src_imports.depends = multimedia
+src_imports.depends = multimedia src_qtmultimediaquicktools
-SUBDIRS += src_imports
+SUBDIRS += \
+ src_qtmultimediaquicktools \
+ src_imports
# Optional bits
contains(config_test_gstreamer, yes):SUBDIRS += src_qgsttools