[Interest] Final QAbstractVideoSurface questions

Jason H scorp1us at yahoo.com
Fri Feb 14 23:11:35 CET 2014


In a last ditch effort, I got this to work.

I needed to change my m_dests to m_videoSurfaces, then set the source of the dest to this. I only figured this out by reviewing the VideoOutput source code.  I had seen a statement about providing a writable mediaObject or videoSurface property, which I did not fully understand. But I get it now.

I would have thought my class providing a videoSurface property was an odd way of doing it. I would have figured that the proper way was to just set the videoSurface of the VideoOutput to my VideoSurface, rather than telling VideoOutput to write it's videoSurface into my instance.  It just seems... backwards. We don't tell QObjects slots to connect themselves to our events.

Is there any insight on the rational on why this is the way it is? I'm not complaining. It works. It just feels odd.



----- Original Message -----
From: Jason H <scorp1us at yahoo.com>
To: Interests Qt <interest at qt-project.org>
Cc: 
Sent: Friday, February 14, 2014 3:53 PM
Subject: Final QAbstractVideoSurface questions

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}
}




More information about the Interest mailing list