[Interest] QVideoProbe Woes

Jason H scorp1us at yahoo.com
Thu Feb 6 22:07:35 CET 2014


So I made a basic wrapper class (included below) for QVideoProbe to expose it to QML. I can set the source property, but when I do it reports it gets a QDeclaritiveAudio class instance, ans the setSource() call fails. How can I get the video part of it?

Output:
qobject_cast<QMediaObject*>(sourceObj) QObject(0x0) // attempting to take the sourceObj pointer and cast it fails,
QDeclarativeAudio // so I print sourceObj->metaObject()->className();



--------------QML

MediaPlayer{
id:video
autoLoad:true
autoPlay:true
source:"vvvv.mp4"
}
VideoProbe{
source:video
onFrame:{
console.log("frame\n")
scanner.decode(videoFrame)
}
}

------------------------------- VideoProbe.h
classVideoProbe:publicQVideoProbe
{
Q_OBJECT

QObject*m_source;Q_PROPERTY(QObject*sourceREADsourceWRITEsetSource)

public:
explicitVideoProbe(QObject*parent=0);
QObject*source();boolsetSource(QObject*);

signals:
voidframe(QVideoFramevideoFrame);

publicslots:
voidemitFrame(QVideoFramevideoFrame);

};

-----------------VideoProbe.cpp:: setSource()
boolVideoProbe::setSource(QObject*sourceObj)
{
m_source=sourceObj; // not actually used anywhere other than to keep track if non NULL
qDebug()<<"qobject_cast<QMediaObject*>(sourceObj)"<<qobject_cast<QMediaObject*>(sourceObj);
if(qobject_cast<QMediaObject*>(sourceObj))
{
boolret=QVideoProbe::setSource((QMediaObject*)sourceObj);
qDebug()<<"VideoProbe::setSource()"<<sourceObj<<ret;
returnret;
}else{
qDebug()<<sourceObj->metaObject()->className();
}
returnfalse;

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140206/b1044499/attachment.html>


More information about the Interest mailing list