2
Copyright (C) 2012 Collabora Ltd. <info@collabora.com>
3
@author George Kiagiadakis <george.kiagiadakis@collabora.com>
5
This library is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published
7
by the Free Software Foundation; either version 2.1 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU Lesser General Public License for more details.
15
You should have received a copy of the GNU Lesser General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
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);
44
ElementPtr GraphicsVideoSurface::videoSink() const
46
if (d->videoSink.isNull()) {
47
#ifndef QTGSTREAMER_UI_NO_OPENGL
48
//if the viewport is a QGLWidget, profit from it
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");
74
QGlib::connect(d->videoSink, "update",
75
const_cast<GraphicsVideoSurface*>(this),
76
&GraphicsVideoSurface::onUpdate);
82
void GraphicsVideoSurface::onUpdate()
84
Q_FOREACH(GraphicsVideoWidget *item, d->items) {
85
item->update(item->rect());