Commit 96407d8d authored by Laszlo Agocs's avatar Laszlo Agocs Committed by Jani Heikkinen
Browse files

Fix bogus videonode plugin handling


Each plugin must provide its own unique key. Otherwise we will only ever
see one single plugin.

Right now running on i.MX6 is often broken because the imx6 videonode plugin is
not picked up since only the egl one is seen by the system. With the fix both plugins
provide their own unique key so both become visible.

Additionally, introduce a QT_VIDEONODE environment variable. This is useful to specify
which plugin to use. This is necessary in case multiple custom videonode plugins support
the same formats.

Change-Id: Iaa1988f8436dcb938cb9a95e2e0d68a4e92e113c
Reviewed-by: default avatarYoann Lopes <yoann.lopes@theqtcompany.com>
Showing with 22 additions and 9 deletions
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
const QLatin1String QSGVideoNodeFactoryPluginKey("sgvideonodes");
class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNode : public QSGGeometryNode class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNode : public QSGGeometryNode
{ {
public: public:
......
{ {
"Keys": ["sgvideonodes"] "Keys": ["android"]
} }
{ {
"Keys": ["sgvideonodes"] "Keys": ["egl"]
} }
{ {
"Keys": ["sgvideonodes"] "Keys": ["imx6"]
} }
...@@ -55,10 +55,21 @@ QDeclarativeVideoRendererBackend::QDeclarativeVideoRendererBackend(QDeclarativeV ...@@ -55,10 +55,21 @@ QDeclarativeVideoRendererBackend::QDeclarativeVideoRendererBackend(QDeclarativeV
QObject::connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), QObject::connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
q, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); q, SLOT(_q_updateNativeSize()), Qt::QueuedConnection);
foreach (QObject *instance, videoNodeFactoryLoader()->instances(QSGVideoNodeFactoryPluginKey)) { // Prioritize the plugin requested by the environment
QString requestedVideoNode = QString::fromLatin1(qgetenv("QT_VIDEONODE"));
foreach (const QString &key, videoNodeFactoryLoader()->keys()) {
QObject *instance = videoNodeFactoryLoader()->instance(key);
QSGVideoNodeFactoryInterface* plugin = qobject_cast<QSGVideoNodeFactoryInterface*>(instance); QSGVideoNodeFactoryInterface* plugin = qobject_cast<QSGVideoNodeFactoryInterface*>(instance);
if (plugin) if (plugin) {
m_videoNodeFactories.append(plugin); if (key == requestedVideoNode)
m_videoNodeFactories.prepend(plugin);
else
m_videoNodeFactories.append(plugin);
#ifdef DEBUG_VIDEOITEM
qDebug() << "found videonode plugin" << key << plugin;
#endif
}
} }
// Append existing node factories as fallback if we have no plugins // Append existing node factories as fallback if we have no plugins
...@@ -224,8 +235,12 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, ...@@ -224,8 +235,12 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode,
if (!videoNode) { if (!videoNode) {
foreach (QSGVideoNodeFactoryInterface* factory, m_videoNodeFactories) { foreach (QSGVideoNodeFactoryInterface* factory, m_videoNodeFactories) {
videoNode = factory->createNode(m_surface->surfaceFormat()); videoNode = factory->createNode(m_surface->surfaceFormat());
if (videoNode) if (videoNode) {
#ifdef DEBUG_VIDEOITEM
qDebug() << "using video node from factory" << factory;
#endif
break; break;
}
} }
} }
} }
......
Supports Markdown
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