18 #include "graphicsvideosurface_p.h"
19 #include "../elementfactory.h"
20 #include "../../QGlib/connect.h"
22 #ifndef QTGSTREAMER_UI_NO_OPENGL
23 # include <QtOpenGL/QGLWidget>
29 GraphicsVideoSurface::GraphicsVideoSurface(QGraphicsView *parent)
30 : QObject(parent), d(new GraphicsVideoSurfacePrivate)
35 GraphicsVideoSurface::~GraphicsVideoSurface()
37 if (!d->videoSink.isNull()) {
38 d->videoSink->setState(QGst::StateNull);
46 if (d->videoSink.isNull()) {
47 #ifndef QTGSTREAMER_UI_NO_OPENGL
49 QGLWidget *glw = qobject_cast<QGLWidget*>(d->view->viewport());
51 d->videoSink = QGst::ElementFactory::make(
"qtglvideosink");
53 if (!d->videoSink.isNull()) {
55 d->videoSink->setProperty(
"glcontext", (
void*) QGLContext::currentContext());
58 if (d->videoSink->setState(QGst::StateReady) != QGst::StateChangeSuccess) {
65 if (d->videoSink.isNull()) {
66 d->videoSink = QGst::ElementFactory::make(
"qtvideosink");
68 if (d->videoSink.isNull()) {
69 qCritical(
"Failed to create qtvideosink. Make sure it is installed correctly");
75 const_cast<GraphicsVideoSurface*>(
this),
76 &GraphicsVideoSurface::onUpdate);
82 void GraphicsVideoSurface::onUpdate()
85 item->update(item->rect());