diff options
author | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2012-02-08 22:25:03 +0200 |
---|---|---|
committer | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2012-02-08 22:25:03 +0200 |
commit | a61c819d5360234c6250e54375f6176870cb0447 (patch) | |
tree | 99b71b582d8f3fc3640ce9098523b00dd080c207 /src/QGst/Ui | |
parent | 13d0c462985eb8970dfb50a97da679ae35556ab0 (diff) |
GraphicsVideoSurface: Update the code to use qtglvideosink for QGLWidget viewports
Diffstat (limited to 'src/QGst/Ui')
-rw-r--r-- | src/QGst/Ui/graphicsvideosurface.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/QGst/Ui/graphicsvideosurface.cpp b/src/QGst/Ui/graphicsvideosurface.cpp index b7c2904..22f2e69 100644 --- a/src/QGst/Ui/graphicsvideosurface.cpp +++ b/src/QGst/Ui/graphicsvideosurface.cpp @@ -40,26 +40,36 @@ GraphicsVideoSurface::~GraphicsVideoSurface() ElementPtr GraphicsVideoSurface::videoSink() const { if (d->videoSink.isNull()) { - d->videoSink = QGst::ElementFactory::make("qtvideosink"); +#ifndef QTGSTREAMER_UI_NO_OPENGL + //if the viewport is a QGLWidget, profit from it + QGLWidget *glw = qobject_cast<QGLWidget*>(d->view->viewport()); + if (glw) { + d->videoSink = QGst::ElementFactory::make("qtglvideosink"); + + if (!d->videoSink.isNull()) { + glw->makeCurrent(); + d->videoSink->setProperty("glcontext", (void*) QGLContext::currentContext()); + glw->doneCurrent(); + + if (d->videoSink->setState(QGst::StateReady) != QGst::StateChangeSuccess) { + d->videoSink.clear(); + } + } + } +#endif if (d->videoSink.isNull()) { - qCritical("Failed to create qtvideosink. Make sure it is installed correctly"); - return ElementPtr(); + d->videoSink = QGst::ElementFactory::make("qtvideosink"); + + if (d->videoSink.isNull()) { + qCritical("Failed to create qtvideosink. Make sure it is installed correctly"); + return ElementPtr(); + } } QGlib::connect(d->videoSink, "update", const_cast<GraphicsVideoSurface*>(this), &GraphicsVideoSurface::onUpdate); - -#ifndef QTGSTREAMER_UI_NO_OPENGL - //if the viewport is a QGLWidget, profit from it - QGLWidget *glw = qobject_cast<QGLWidget*>(d->view->viewport()); - if (glw) { - glw->makeCurrent(); - d->videoSink->setProperty("glcontext", (void*) QGLContext::currentContext()); - glw->doneCurrent(); - } -#endif } return d->videoSink; |