Added support for non QMediaObject based VideoOutput sources.
VideoOutput element checks first for mediaObject property of source object and if it's not available it checks for videoSurface property. It allows to implement video frames generator and connect it to optimized VideoOutput QML element. Change-Id: I8ee618cf61b9d9100f25e742c631ea8724c188dc Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
d6c5d9faa6
commit
434075645a
@@ -55,6 +55,7 @@
|
||||
#include <QtCore/qmetaobject.h>
|
||||
|
||||
//#define DEBUG_VIDEOITEM
|
||||
Q_DECLARE_METATYPE(QAbstractVideoSurface*)
|
||||
|
||||
class QSGVideoItemSurface : public QAbstractVideoSurface
|
||||
{
|
||||
@@ -153,6 +154,7 @@ private:
|
||||
|
||||
QDeclarativeVideoOutput::QDeclarativeVideoOutput(QQuickItem *parent) :
|
||||
QQuickItem(parent),
|
||||
m_sourceType(NoSource),
|
||||
m_fillMode(PreserveAspectFit)
|
||||
{
|
||||
setFlag(ItemHasContents, true);
|
||||
@@ -187,23 +189,39 @@ void QDeclarativeVideoOutput::setSource(QObject *source)
|
||||
if (source == m_source.data())
|
||||
return;
|
||||
|
||||
if (m_source)
|
||||
if (m_source && m_sourceType == MediaObjectSource)
|
||||
disconnect(0, m_source.data(), SLOT(_q_updateMediaObject()));
|
||||
|
||||
if (m_source && m_sourceType == VideoSurfaceSource)
|
||||
m_source.data()->setProperty("videoSurface", QVariant::fromValue<QAbstractVideoSurface*>(0));
|
||||
|
||||
m_surface->stop();
|
||||
|
||||
m_source = source;
|
||||
|
||||
if (m_source) {
|
||||
const QMetaObject *metaObject = m_source.data()->metaObject();
|
||||
const QMetaProperty mediaObjectProperty = metaObject->property(
|
||||
metaObject->indexOfProperty("mediaObject"));
|
||||
|
||||
if (mediaObjectProperty.hasNotifySignal()) {
|
||||
QMetaMethod method = mediaObjectProperty.notifySignal();
|
||||
QMetaObject::connect(m_source.data(), method.methodIndex(),
|
||||
this, this->metaObject()->indexOfSlot("updateMediaObject()"),
|
||||
Qt::DirectConnection, 0);
|
||||
int mediaObjectPropertyIndex = metaObject->indexOfProperty("mediaObject");
|
||||
if (mediaObjectPropertyIndex != -1) {
|
||||
const QMetaProperty mediaObjectProperty = metaObject->property(mediaObjectPropertyIndex);
|
||||
|
||||
if (mediaObjectProperty.hasNotifySignal()) {
|
||||
QMetaMethod method = mediaObjectProperty.notifySignal();
|
||||
QMetaObject::connect(m_source.data(), method.methodIndex(),
|
||||
this, this->metaObject()->indexOfSlot("updateMediaObject()"),
|
||||
Qt::DirectConnection, 0);
|
||||
|
||||
}
|
||||
m_sourceType = MediaObjectSource;
|
||||
} else if (metaObject->indexOfProperty("videoSurface") != -1) {
|
||||
m_source.data()->setProperty("videoSurface", QVariant::fromValue<QAbstractVideoSurface*>(m_surface));
|
||||
m_sourceType = VideoSurfaceSource;
|
||||
} else {
|
||||
m_sourceType = NoSource;
|
||||
}
|
||||
} else {
|
||||
m_sourceType = NoSource;
|
||||
}
|
||||
|
||||
_q_updateMediaObject();
|
||||
|
||||
@@ -94,10 +94,18 @@ private Q_SLOTS:
|
||||
void _q_updateGeometry();
|
||||
|
||||
private:
|
||||
enum SourceType {
|
||||
NoSource,
|
||||
MediaObjectSource,
|
||||
VideoSurfaceSource
|
||||
};
|
||||
|
||||
void present(const QVideoFrame &frame);
|
||||
|
||||
friend class QSGVideoItemSurface;
|
||||
|
||||
SourceType m_sourceType;
|
||||
|
||||
QWeakPointer<QObject> m_source;
|
||||
QWeakPointer<QMediaObject> m_mediaObject;
|
||||
QWeakPointer<QMediaService> m_service;
|
||||
|
||||
Reference in New Issue
Block a user