QtGStreamer 1.2.0
Loading...
Searching...
No Matches
graphicsvideowidget.cpp
1/*
2 Copyright (C) 2012 Collabora Ltd. <info@collabora.com>
3 @author George Kiagiadakis <george.kiagiadakis@collabora.com>
4
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.
9
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.
14
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/>.
17*/
18#include "graphicsvideowidget.h"
19#include "graphicsvideosurface_p.h"
20#include "../../QGlib/Signal"
21
22namespace QGst {
23namespace Ui {
24
25GraphicsVideoWidget::GraphicsVideoWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
26 : QGraphicsWidget(parent, wFlags)
27{
28 setFlag(QGraphicsItem::ItemHasNoContents, false);
29}
30
31GraphicsVideoWidget::~GraphicsVideoWidget()
32{
33 setSurface(0);
34}
35
36GraphicsVideoSurface *GraphicsVideoWidget::surface() const
37{
38 return m_surface.data();
39}
40
41void GraphicsVideoWidget::setSurface(GraphicsVideoSurface *surface)
42{
43 if (m_surface) {
44 m_surface.data()->d->items.remove(this);
45 }
46
47 m_surface = surface;
48
49 if (m_surface) {
50 m_surface.data()->d->items.insert(this);
51 }
52}
53
54void GraphicsVideoWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
55{
56 Q_UNUSED(option);
57
58 QRectF r = rect();
59
60 if (!m_surface || m_surface.data()->d->videoSink.isNull() ||
61 widget != m_surface.data()->d->view->viewport()
62 ) {
63 painter->fillRect(r, Qt::black);
64 } else {
65 QGlib::emit<void>(m_surface.data()->d->videoSink, "paint",
66 (void*)painter, r.x(), r.y(), r.width(), r.height());
67 }
68}
69
70} // namespace Ui
71} // namespace QGst
Wrappers for GStreamer classes.