void MmRendererPlayerVideoRendererControl::updateScene(const QSize &size)
{
    if (m_surface) {
        if (!m_surface->isActive()) {
            if (m_windowGrabber->eglImageSupported()) {
                m_surface->start(QVideoSurfaceFormat(size, QVideoFrame::Format_BGR32,
                                                     QAbstractVideoBuffer::GLTextureHandle));
            } else {
                m_surface->start(QVideoSurfaceFormat(size, QVideoFrame::Format_ARGB32));
            }
        } else {
            if (m_surface->surfaceFormat().frameSize() != size) {
                m_surface->stop();
                if (m_windowGrabber->eglImageSupported()) {
                    m_surface->start(QVideoSurfaceFormat(size, QVideoFrame::Format_BGR32,
                                                         QAbstractVideoBuffer::GLTextureHandle));
                } else {
                    m_surface->start(QVideoSurfaceFormat(size, QVideoFrame::Format_ARGB32));
                }
            }
        }

        // Depending on the support of EGL images on the current platform we either pass a texture
        // handle or a copy of the image data
        if (m_windowGrabber->eglImageSupported()) {
            QnxTextureBuffer *textBuffer = new QnxTextureBuffer(m_windowGrabber);
            QVideoFrame actualFrame(textBuffer, size, QVideoFrame::Format_BGR32);
            m_surface->present(actualFrame);
        } else {
            m_surface->present(m_windowGrabber->getNextImage().copy());
        }
    }
}
void MmRendererPlayerVideoRendererControl::frameGrabbed(const QImage &frame, int handle)
{
    if (m_surface) {
        if (!m_surface->isActive()) {
            if (m_windowGrabber->eglImageSupported()) {
                if (QOpenGLContext::currentContext())
                    m_windowGrabber->createEglImages();
                else
                    m_surface->setProperty("_q_GLThreadCallback", QVariant::fromValue<QObject*>(this));

                m_surface->start(QVideoSurfaceFormat(frame.size(), QVideoFrame::Format_BGR32,
                                                 QAbstractVideoBuffer::GLTextureHandle));
            } else {
                m_surface->start(QVideoSurfaceFormat(frame.size(), QVideoFrame::Format_ARGB32));
            }
        } else {
            if (m_surface->surfaceFormat().frameSize() != frame.size()) {
                QAbstractVideoBuffer::HandleType type = m_surface->surfaceFormat().handleType();
                m_surface->stop();
                if (type != QAbstractVideoBuffer::NoHandle) {
                    m_surface->setProperty("_q_GLThreadCallback", QVariant::fromValue<QObject*>(this));
                    m_surface->start(QVideoSurfaceFormat(frame.size(), QVideoFrame::Format_BGR32,
                                                     QAbstractVideoBuffer::GLTextureHandle));
                } else {
                    m_surface->start(QVideoSurfaceFormat(frame.size(), QVideoFrame::Format_ARGB32));
                }
            }
        }

        // Depending on the support of EGL images on the current platform we either pass a texture
        // handle or a copy of the image data
        if (m_surface->surfaceFormat().handleType() != QAbstractVideoBuffer::NoHandle) {
            if (m_windowGrabber->eglImagesInitialized() &&
                    m_surface->property("_q_GLThreadCallback") != 0)
                m_surface->setProperty("_q_GLThreadCallback", 0);


            BBTextureBuffer *textBuffer = new BBTextureBuffer(handle);
            QVideoFrame actualFrame(textBuffer, frame.size(), QVideoFrame::Format_BGR32);
            m_surface->present(actualFrame);
        } else {
            m_surface->present(frame.copy());
        }
    }
}