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;

}
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to