summaryrefslogtreecommitdiff
path: root/elements/gstqtvideosink/gstqtvideosinksurface.h
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2011-11-01 14:42:43 +0200
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2012-01-06 17:51:15 +0200
commit50ba34fd0aa175e11c819994a64d38358bffc02c (patch)
treedca284105ea3d531108c4ba755b3e8c5ec9ee6ba /elements/gstqtvideosink/gstqtvideosinksurface.h
parentfdcd7ff4302af28de7f8d04b76ca944a01156f33 (diff)
qtvideosink: Initial refactoring.
* Eliminated QtMultimedia dependencies. * Eliminated the need to link to the internal classes of the sink by adding a standard properties/signals interface to the gst element. * Simplified some parts of the initial code, which were there only to support plugging the components individually to different parts of QtMultimedia.
Diffstat (limited to 'elements/gstqtvideosink/gstqtvideosinksurface.h')
-rw-r--r--elements/gstqtvideosink/gstqtvideosinksurface.h215
1 files changed, 110 insertions, 105 deletions
diff --git a/elements/gstqtvideosink/gstqtvideosinksurface.h b/elements/gstqtvideosink/gstqtvideosinksurface.h
index 2f0879c..6176444 100644
--- a/elements/gstqtvideosink/gstqtvideosinksurface.h
+++ b/elements/gstqtvideosink/gstqtvideosinksurface.h
@@ -1,93 +1,84 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Collabora Ltd
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file was originally part of the Qt Mobility Components.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-****************************************************************************/
-
-#ifndef QPAINTERVIDEOSURFACE_P_H
-#define QPAINTERVIDEOSURFACE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qmobilityglobal.h>
-#include <QtCore/qsize.h>
-#include <QtGui/qimage.h>
-#include <QtGui/qmatrix4x4.h>
-#include <QtGui/qpaintengine.h>
-#include <qabstractvideosurface.h>
-#include <qvideoframe.h>
-
-QT_BEGIN_NAMESPACE
-class QGLContext;
-QT_END_NAMESPACE
-
-QT_USE_NAMESPACE
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). <qt-info@nokia.com>
+ Copyright (C) 2011 Collabora Ltd. <info@collabora.com>
-QT_BEGIN_NAMESPACE
-
-class QmlVideoSurfacePainter
-{
-public:
- virtual ~QmlVideoSurfacePainter();
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License version 2.1
+ as published by the Free Software Foundation.
- virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType) const = 0;
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- virtual bool isFormatSupported(
- const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const = 0;
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
- virtual QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format) = 0;
- virtual void stop() = 0;
+#ifndef GST_QT_VIDEO_SINK_SURFACE_H
+#define GST_QT_VIDEO_SINK_SURFACE_H
- virtual QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame) = 0;
+#include "gstqtvideosink.h"
+#include "bufferformat.h"
+#include "abstractsurfacepainter.h"
- virtual QAbstractVideoSurface::Error paint(
- const QRectF &target, QPainter *painter, const QRectF &source) = 0;
+#include <QtCore/QObject>
+#include <QtCore/QEvent>
+#include <QtCore/QSet>
+#include <QtCore/QReadWriteLock>
- virtual void updateColors(int brightness, int contrast, int hue, int saturation) = 0;
- virtual void viewportDestroyed() {}
-};
+class QGLContext;
-class QM_AUTOTEST_EXPORT QmlPainterVideoSurface : public QAbstractVideoSurface
+class GstQtVideoSinkSurface : public QObject
{
Q_OBJECT
public:
- explicit QmlPainterVideoSurface(QObject *parent = 0);
- ~QmlPainterVideoSurface();
+ enum EventType {
+ BufferEventType = QEvent::User,
+ DeactivateEventType
+ };
+
+ //-------------------------------------
+
+ class BufferEvent : public QEvent
+ {
+ public:
+ inline BufferEvent(GstBuffer *buf, bool formatDirty)
+ : QEvent(static_cast<QEvent::Type>(BufferEventType)),
+ buffer(gst_buffer_ref(buf)),
+ formatDirty(formatDirty)
+ {
+ }
+
+ GstBuffer *buffer;
+ bool formatDirty;
+ };
+
+ //-------------------------------------
+
+ class DeactivateEvent : public QEvent
+ {
+ public:
+ inline DeactivateEvent()
+ : QEvent(static_cast<QEvent::Type>(DeactivateEventType))
+ {
+ }
+ };
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
+ //-------------------------------------
- bool isFormatSupported(
- const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar = 0) const;
+ explicit GstQtVideoSinkSurface(GstQtVideoSink *sink, QObject *parent = 0);
+ ~GstQtVideoSinkSurface();
- bool start(const QVideoSurfaceFormat &format);
- void stop();
+ // API for GstQtVideoSink
- bool present(const QVideoFrame &frame);
+ QSet<BufferFormat::PixelFormat> supportedPixelFormats() const;
+
+ bool isActive() const;
+ void setActive(bool playing);
+
+ // GstColorBalance interface
int brightness() const;
void setBrightness(int brightness);
@@ -101,16 +92,15 @@ public:
int saturation() const;
void setSaturation(int saturation);
- bool isReady() const;
- void setReady(bool ready);
+ // force-aspect-ratio property
- bool isPlaying() const;
- void setPlaying(bool playing);
+ bool forceAspectRatio() const;
+ void setForceAspectRatio(bool force);
- void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1));
+ // glcontext property
-#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
- const QGLContext *glContext() const;
+#ifndef GST_QT_VIDEO_SINK_NO_OPENGL
+ QGLContext *glContext() const;
void setGLContext(QGLContext *context);
enum ShaderType
@@ -121,45 +111,60 @@ public:
};
Q_DECLARE_FLAGS(ShaderTypes, ShaderType)
-
- ShaderTypes supportedShaderTypes() const;
-
- ShaderType shaderType() const;
- void setShaderType(ShaderType type);
#endif
-public Q_SLOTS:
- void viewportDestroyed();
+ // paint action signal
-Q_SIGNALS:
- void frameChanged();
+ void paint(QPainter *painter, int x, int y, int width, int height);
+
+protected:
+ bool event(QEvent *event);
private:
- void createPainter();
+ void changePainter(const BufferFormat & format);
+ void destroyPainter();
+
- QmlVideoSurfacePainter *m_painter;
-#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
+ AbstractSurfacePainter *m_painter;
+
+#ifndef GST_QT_VIDEO_SINK_NO_OPENGL
QGLContext *m_glContext;
- ShaderTypes m_shaderTypes;
+ ShaderTypes m_supportedShaderTypes;
ShaderType m_shaderType;
#endif
+
+ // colorbalance interface properties
+ mutable QReadWriteLock m_colorsLock;
+ bool m_colorsDirty;
int m_brightness;
int m_contrast;
int m_hue;
int m_saturation;
- QVideoFrame::PixelFormat m_pixelFormat;
- QSize m_frameSize;
- QRect m_sourceRect;
- bool m_colorsDirty;
- bool m_ready;
- bool m_playing;
-};
+ // force-aspect-ratio property
+ mutable QReadWriteLock m_forceAspectRatioLock;
+ bool m_forceAspectRatioDirty;
+ bool m_forceAspectRatio;
-#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QmlPainterVideoSurface::ShaderTypes)
-#endif
+ // format caching
+ bool m_formatDirty;
+ BufferFormat m_bufferFormat;
+ QRect m_targetArea;
+ QRect m_videoArea;
+ QRect m_clipRect;
-QT_END_NAMESPACE
+ // whether the sink is active (PAUSED or PLAYING)
+ mutable QReadWriteLock m_isActiveLock;
+ bool m_isActive;
+ // the buffer to be drawn next
+ GstBuffer *m_buffer;
+
+ GstQtVideoSink *m_sink;
+};
+
+#ifndef GST_QT_VIDEO_SINK_NO_OPENGL
+Q_DECLARE_OPERATORS_FOR_FLAGS(GstQtVideoSinkSurface::ShaderTypes)
#endif
+
+#endif // GST_QT_VIDEO_SINK_SURFACE_H