summaryrefslogtreecommitdiff
path: root/src/QGst/Ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/QGst/Ui')
-rw-r--r--src/QGst/Ui/graphicsvideosurface.cpp36
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;