Recap: I am setting up a QML element to intercept frames from a VideoSource 
going to a VideoOutput. It looks like:
{VideoSource}-frames-> {MySurfaceImplementation}-frames->{VideoOutput}

Thanks to all the people here, I got the first part of it working. Now I'm 
confused on the last half. 

MySurfaceImplementation (called VideoSurface):

1. takes a source (MediaPlayer or Camera}
2. takes various settings related to the frame/image grabbing and processing
3. takes the frame from source and relays them to a dest (VideoOutput)

Currently 1 & 2 work 3 is proving problematic.

When VideoSurface::present is called, I attempt to present frames to dest, 
immediately and always, but these never appear. And present() does not indicate 
an error. In fact, I don't get any errors. 

I am wondering what is needed to get this working. I investigated 
QMediaService, which reads: "In general, implementing a QMediaService is 
outside of the scope of this documentation and support on the relevant mailing 
lists or IRC channels should be sought."

So now I am here. I just want to provide frames to QVideoOutput, the same ones 
from the MediaPlayer. I don't care about sound.

One thing that might be very useful and gereral is a MediaTee element and 
class, where you take one source, and have two dests, so that I can get a frame 
and process it and the VideoOutput can continue unrestricted. Without it, I'm 
trying to patch my VideoSurface class the media graph. 

What do I need to do to send the frame I have to the VideoOutput?

Many, many thanks in advance!

------

void VideoSurface::setSource(QObject *source)
{
m_source = source;
if (m_source)
{
QMediaPlayer *player = 
qvariant_cast<QMediaPlayer*>(m_source->property("mediaObject"));
qDebug() << "videoSurface::setDest() player" << player;

if (player)
{
QVideoRendererControl* rendererControl = 
player->service()->requestControl<QVideoRendererControl*>();
if (rendererControl)
{
rendererControl->setSurface(this);
} else {
qDebug() << "VideoSurface::setSource()" << source <<  " Unable to get 
QVideoRenderControl for video integration.";
}
} else {
qDebug() << "VideoSurface::setSource()" << source <<  " Unable to get player " 
<< player;
}
}
}
------
bool VideoSurface::start ( const QVideoSurfaceFormat & format )
{
qDebug() << "videoSurface::start()";
if (m_dest)
{
bool ret = ((QAbstractVideoSurface*)m_dest)->start(format);
if (!ret)
{
qDebug() << "VideoSurface::start() dest: " << m_dest <<  " start() failed";
}
return ret && QAbstractVideoSurface::start(format);
}
return QAbstractVideoSurface::start(format);
}

------

bool VideoSurface::present ( const QVideoFrame & videoFrame )
{
// qDebug() << "videoSurface::present()" << m_frameCount << m_emitRate;
// present the frame to the destiantion first, some don't block, so this might 
be quick. At least on those
if (m_dest) // cases we won't slow it down.
{
bool ret = ((QAbstractVideoSurface*)m_dest)->present(videoFrame);
if (!ret)
{
qDebug() << "VideoSurface::present() dest: " << m_dest <<  " present() failed, 
reason:" << ((QAbstractVideoSurface*)m_dest)->error();
}
} 
/* conversion code follows */
}
------


-QML--
Rectangle{
width:360
height:360

MediaPlayer{ id:player; source:"vin4.mp4"; autoPlay:true }
VideoSurface{ id:surface; source:player; dest:viewer ;emitRate:10  
emitImages:true}
VideoOutput{ id:viewer; source:surface; anchors.fill:parent}
}

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

Reply via email to