summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorJonas Rabbe <jonas.rabbe@nokia.com>2011-10-11 15:25:36 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-12 08:58:30 +0200
commit48d95f0baac39fc5eb38a137a8e84eda2cdb2b79 (patch)
tree038a66510f91527c70a5fc416238484842a514c1 /src/multimedia
parent126addddb5e5a1928a8decf84e9e20655ac24f8d (diff)
Moved general gstreamer helper classes into separate library.
Cleaned up configuration of gstreamer with a separate config test. Change-Id: I1ec9ee466233687fbcfdc544a12d9fce578e4379 Reviewed-on: http://codereview.qt-project.org/6459 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/gsttools_headers/qabstractgstbufferpool_p.h86
-rw-r--r--src/multimedia/gsttools_headers/qgstreamerbushelper_p.h100
-rw-r--r--src/multimedia/gsttools_headers/qgstreamermessage_p.h79
-rw-r--r--src/multimedia/gsttools_headers/qgstutils_p.h70
-rw-r--r--src/multimedia/gsttools_headers/qgstvideobuffer_p.h83
-rw-r--r--src/multimedia/gsttools_headers/qgstxvimagebuffer_p.h141
-rw-r--r--src/multimedia/gsttools_headers/qvideosurfacegstsink_p.h174
7 files changed, 733 insertions, 0 deletions
diff --git a/src/multimedia/gsttools_headers/qabstractgstbufferpool_p.h b/src/multimedia/gsttools_headers/qabstractgstbufferpool_p.h
new file mode 100644
index 000000000..40c75ad32
--- /dev/null
+++ b/src/multimedia/gsttools_headers/qabstractgstbufferpool_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGSTBUFFERPOOL_P_H
+#define QGSTBUFFERPOOL_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 <qabstractvideobuffer.h>
+#include <qvideosurfaceformat.h>
+
+#include <gst/gst.h>
+
+/*!
+ Abstract interface for video buffers allocation.
+*/
+class QAbstractGstBufferPool
+{
+public:
+ virtual ~QAbstractGstBufferPool() {}
+
+ virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const = 0;
+
+ virtual GType bufferType() const = 0;
+ virtual GstBuffer *takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps) = 0;
+ virtual void clear() = 0;
+
+ virtual QAbstractVideoBuffer::HandleType handleType() const = 0;
+
+ /*!
+ Build an QAbstractVideoBuffer instance from compatible (mathcing gst buffer type)
+ GstBuffer.
+
+ This method is called from gstreamer video sink thread.
+ */
+ virtual QAbstractVideoBuffer *prepareVideoBuffer(GstBuffer *buffer, int bytesPerLine) = 0;
+};
+
+#endif
diff --git a/src/multimedia/gsttools_headers/qgstreamerbushelper_p.h b/src/multimedia/gsttools_headers/qgstreamerbushelper_p.h
new file mode 100644
index 000000000..0ae5b8978
--- /dev/null
+++ b/src/multimedia/gsttools_headers/qgstreamerbushelper_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGSTREAMERBUSHELPER_P_H
+#define QGSTREAMERBUSHELPER_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 <QObject>
+
+#include "qgstreamermessage_p.h"
+#include <gst/gst.h>
+
+class QGstreamerSyncMessageFilter {
+public:
+ //returns true if message was processed and should be dropped, false otherwise
+ virtual bool processSyncMessage(const QGstreamerMessage &message) = 0;
+};
+#define QGstreamerSyncMessageFilter_iid "com.nokia.Qt.QGstreamerSyncMessageFilter/1.0"
+Q_DECLARE_INTERFACE(QGstreamerSyncMessageFilter, QGstreamerSyncMessageFilter_iid)
+
+
+class QGstreamerBusMessageFilter {
+public:
+ //returns true if message was processed and should be dropped, false otherwise
+ virtual bool processBusMessage(const QGstreamerMessage &message) = 0;
+};
+#define QGstreamerBusMessageFilter_iid "com.nokia.Qt.QGstreamerBusMessageFilter/1.0"
+Q_DECLARE_INTERFACE(QGstreamerBusMessageFilter, QGstreamerBusMessageFilter_iid)
+
+
+class QGstreamerBusHelperPrivate;
+
+class QGstreamerBusHelper : public QObject
+{
+ Q_OBJECT
+ friend class QGstreamerBusHelperPrivate;
+
+public:
+ QGstreamerBusHelper(GstBus* bus, QObject* parent = 0);
+ ~QGstreamerBusHelper();
+
+ void installMessageFilter(QObject *filter);
+ void removeMessageFilter(QObject *filter);
+
+signals:
+ void message(QGstreamerMessage const& message);
+
+private:
+ QGstreamerBusHelperPrivate* d;
+};
+
+#endif
diff --git a/src/multimedia/gsttools_headers/qgstreamermessage_p.h b/src/multimedia/gsttools_headers/qgstreamermessage_p.h
new file mode 100644
index 000000000..b0a568de2
--- /dev/null
+++ b/src/multimedia/gsttools_headers/qgstreamermessage_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGSTREAMERMESSAGE_P_H
+#define QGSTREAMERMESSAGE_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 <QMetaType>
+
+#include <gst/gst.h>
+
+
+class QGstreamerMessage
+{
+public:
+ QGstreamerMessage();
+ QGstreamerMessage(GstMessage* message);
+ QGstreamerMessage(QGstreamerMessage const& m);
+ ~QGstreamerMessage();
+
+ GstMessage* rawMessage() const;
+
+ QGstreamerMessage& operator=(QGstreamerMessage const& rhs);
+
+private:
+ GstMessage* m_message;
+};
+
+Q_DECLARE_METATYPE(QGstreamerMessage);
+
+#endif
diff --git a/src/multimedia/gsttools_headers/qgstutils_p.h b/src/multimedia/gsttools_headers/qgstutils_p.h
new file mode 100644
index 000000000..ea99e560f
--- /dev/null
+++ b/src/multimedia/gsttools_headers/qgstutils_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGSTUTILS_P_H
+#define QGSTUTILS_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 <QtCore/qmap.h>
+#include <gst/gst.h>
+
+class QSize;
+class QVariant;
+class QByteArray;
+
+namespace QGstUtils {
+ QMap<QByteArray, QVariant> gstTagListToMap(const GstTagList *list);
+
+ QSize capsResolution(const GstCaps *caps);
+ QSize capsCorrectedResolution(const GstCaps *caps);
+}
+
+#endif
diff --git a/src/multimedia/gsttools_headers/qgstvideobuffer_p.h b/src/multimedia/gsttools_headers/qgstvideobuffer_p.h
new file mode 100644
index 000000000..0f14a8fec
--- /dev/null
+++ b/src/multimedia/gsttools_headers/qgstvideobuffer_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGSTVIDEOBUFFER_P_H
+#define QGSTVIDEOBUFFER_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 <qabstractvideobuffer.h>
+#include <QtCore/qvariant.h>
+
+#include <gst/gst.h>
+
+class QGstVideoBuffer : public QAbstractVideoBuffer
+{
+public:
+ QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine);
+ QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine,
+ HandleType handleType, const QVariant &handle);
+ ~QGstVideoBuffer();
+
+ MapMode mapMode() const;
+
+ uchar *map(MapMode mode, int *numBytes, int *bytesPerLine);
+ void unmap();
+
+ QVariant handle() const { return m_handle; }
+private:
+ GstBuffer *m_buffer;
+ int m_bytesPerLine;
+ MapMode m_mode;
+ QVariant m_handle;
+};
+
+
+#endif
diff --git a/src/multimedia/gsttools_headers/qgstxvimagebuffer_p.h b/src/multimedia/gsttools_headers/qgstxvimagebuffer_p.h
new file mode 100644
index 000000000..c6f74373e
--- /dev/null
+++ b/src/multimedia/gsttools_headers/qgstxvimagebuffer_p.h
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGSTXVIMAGEBUFFER_P_H
+#define QGSTXVIMAGEBUFFER_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 <qabstractvideobuffer.h>
+#include <qvideosurfaceformat.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qwaitcondition.h>
+#include <QtCore/qqueue.h>
+
+#ifndef QT_NO_XVIDEO
+
+#include <X11/Xlib.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvlib.h>
+
+
+#include <gst/gst.h>
+#include "qabstractgstbufferpool_p.h"
+
+class QGstXvImageBufferPool;
+
+struct QGstXvImageBuffer {
+ GstBuffer buffer;
+ QGstXvImageBufferPool *pool;
+ XvImage *xvImage;
+ XShmSegmentInfo shmInfo;
+ bool markedForDeletion;
+
+ static GType get_type(void);
+ static void class_init(gpointer g_class, gpointer class_data);
+ static void buffer_init(QGstXvImageBuffer *xvimage, gpointer g_class);
+ static void buffer_finalize(QGstXvImageBuffer * xvimage);
+ static GstBufferClass *parent_class;
+};
+
+Q_DECLARE_METATYPE(XvImage*)
+
+class QGstXvImageBufferPool : public QObject, public QAbstractGstBufferPool {
+Q_OBJECT
+friend class QGstXvImageBuffer;
+public:
+ QGstXvImageBufferPool(QObject *parent = 0);
+ virtual ~QGstXvImageBufferPool();
+
+ bool isFormatSupported(const QVideoSurfaceFormat &format) const;
+
+ GType bufferType() const;
+ GstBuffer *takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps);
+ void clear();
+
+ QAbstractVideoBuffer::HandleType handleType() const;
+ QAbstractVideoBuffer *prepareVideoBuffer(GstBuffer *buffer, int bytesPerLine);
+
+private slots:
+ void queuedAlloc();
+ void queuedDestroy();
+
+ void doClear();
+
+ void recycleBuffer(QGstXvImageBuffer *);
+ void destroyBuffer(QGstXvImageBuffer *);
+
+private:
+ void doAlloc();
+
+ struct XvShmImage {
+ XvImage *xvImage;
+ XShmSegmentInfo shmInfo;
+ };
+
+ QMutex m_poolMutex;
+ QMutex m_allocMutex;
+ QWaitCondition m_allocWaitCondition;
+ QMutex m_destroyMutex;
+ QVideoSurfaceFormat m_format;
+ GstCaps *m_caps;
+ QList<QGstXvImageBuffer*> m_pool;
+ QList<QGstXvImageBuffer*> m_allBuffers;
+ QList<XvShmImage> m_imagesToDestroy;
+ Qt::HANDLE m_threadId;
+};
+
+#endif //QT_NO_XVIDEO
+
+#endif
diff --git a/src/multimedia/gsttools_headers/qvideosurfacegstsink_p.h b/src/multimedia/gsttools_headers/qvideosurfacegstsink_p.h
new file mode 100644
index 000000000..438b796cf
--- /dev/null
+++ b/src/multimedia/gsttools_headers/qvideosurfacegstsink_p.h
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VIDEOSURFACEGSTSINK_P_H
+#define VIDEOSURFACEGSTSINK_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 <gst/video/gstvideosink.h>
+
+#include <QtCore/qlist.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qqueue.h>
+#include <QtCore/qpointer.h>
+#include <QtCore/qwaitcondition.h>
+#include <qvideosurfaceformat.h>
+#include <qvideoframe.h>
+#include <qabstractvideobuffer.h>
+
+#include "qabstractgstbufferpool_p.h"
+
+QT_BEGIN_NAMESPACE
+class QAbstractVideoSurface;
+QT_END_NAMESPACE
+
+#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
+class QGstXvImageBuffer;
+class QGstXvImageBufferPool;
+#endif
+
+class QVideoSurfaceGstDelegate : public QObject
+{
+ Q_OBJECT
+public:
+ QVideoSurfaceGstDelegate(QAbstractVideoSurface *surface);
+ ~QVideoSurfaceGstDelegate();
+
+ QList<QVideoFrame::PixelFormat> supportedPixelFormats(
+ QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
+
+ QVideoSurfaceFormat surfaceFormat() const;
+
+ bool start(const QVideoSurfaceFormat &format, int bytesPerLine);
+ void stop();
+
+ bool isActive();
+
+ QAbstractGstBufferPool *pool() { return m_pool; }
+ QMutex *poolMutex() { return &m_poolMutex; }
+
+ GstFlowReturn render(GstBuffer *buffer);
+
+private slots:
+ void queuedStart();
+ void queuedStop();
+ void queuedRender();
+
+ void updateSupportedFormats();
+
+private:
+ QPointer<QAbstractVideoSurface> m_surface;
+ QList<QVideoFrame::PixelFormat> m_supportedPixelFormats;
+ //pixel formats of buffers pool native type
+ QList<QVideoFrame::PixelFormat> m_supportedPoolPixelFormats;
+ QAbstractGstBufferPool *m_pool;
+ QList<QAbstractGstBufferPool *> m_pools;
+ QMutex m_poolMutex;
+ QMutex m_mutex;
+ QWaitCondition m_setupCondition;
+ QWaitCondition m_renderCondition;
+ QVideoSurfaceFormat m_format;
+ QVideoFrame m_frame;
+ GstFlowReturn m_renderReturn;
+ int m_bytesPerLine;
+ bool m_started;
+ bool m_startCanceled;
+};
+
+class QVideoSurfaceGstSink
+{
+public:
+ GstVideoSink parent;
+
+ static QVideoSurfaceGstSink *createSink(QAbstractVideoSurface *surface);
+ static QVideoSurfaceFormat formatForCaps(GstCaps *caps, int *bytesPerLine = 0);
+
+private:
+ static GType get_type();
+ static void class_init(gpointer g_class, gpointer class_data);
+ static void base_init(gpointer g_class);
+ static void instance_init(GTypeInstance *instance, gpointer g_class);
+
+ static void finalize(GObject *object);
+
+ static GstStateChangeReturn change_state(GstElement *element, GstStateChange transition);
+
+ static GstCaps *get_caps(GstBaseSink *sink);
+ static gboolean set_caps(GstBaseSink *sink, GstCaps *caps);
+
+ static GstFlowReturn buffer_alloc(
+ GstBaseSink *sink, guint64 offset, guint size, GstCaps *caps, GstBuffer **buffer);
+
+ static gboolean start(GstBaseSink *sink);
+ static gboolean stop(GstBaseSink *sink);
+
+ static gboolean unlock(GstBaseSink *sink);
+
+ static gboolean event(GstBaseSink *sink, GstEvent *event);
+ static GstFlowReturn preroll(GstBaseSink *sink, GstBuffer *buffer);
+ static GstFlowReturn render(GstBaseSink *sink, GstBuffer *buffer);
+
+private:
+ QVideoSurfaceGstDelegate *delegate;
+
+ GstCaps *lastRequestedCaps;
+ GstCaps *lastBufferCaps;
+ QVideoSurfaceFormat *lastSurfaceFormat;
+};
+
+
+class QVideoSurfaceGstSinkClass
+{
+public:
+ GstVideoSinkClass parent_class;
+};
+
+#endif