Changed QVideoSurfaceGstSink to take pools from plugins

Change-Id: Iec743efc52513e2000276b9a18d1d9639c270699
Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
Jonas Rabbe
2011-11-08 12:38:02 +10:00
committed by Qt by Nokia
parent 34cdc41a93
commit 956526a9fb
6 changed files with 118 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef QGSTBUFFERPOOL_P_H
#define QGSTBUFFERPOOL_P_H
#ifndef QGSTBUFFERPOOLINTERFACE_P_H
#define QGSTBUFFERPOOLINTERFACE_P_H
//
// W A R N I N G
@@ -55,16 +55,21 @@
#include <qabstractvideobuffer.h>
#include <qvideosurfaceformat.h>
#include <QtCore/qobject.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
#include <gst/gst.h>
const QLatin1String QGstBufferPoolPluginKey("bufferpool");
/*!
Abstract interface for video buffers allocation.
*/
class QAbstractGstBufferPool
class QGstBufferPoolInterface : public QFactoryInterface
{
public:
virtual ~QAbstractGstBufferPool() {}
virtual ~QGstBufferPoolInterface() {}
virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const = 0;
@@ -83,4 +88,34 @@ public:
virtual QAbstractVideoBuffer *prepareVideoBuffer(GstBuffer *buffer, int bytesPerLine) = 0;
};
#define QGstBufferPoolInterface_iid "com.nokia.Qt.QGstBufferPoolInterface"
Q_DECLARE_INTERFACE(QGstBufferPoolInterface, QGstBufferPoolInterface_iid)
class QGstBufferPoolPlugin : public QObject, public QGstBufferPoolInterface
{
Q_OBJECT
Q_INTERFACES(QGstBufferPoolInterface:QFactoryInterface)
public:
explicit QGstBufferPoolPlugin(QObject *parent = 0);
virtual ~QGstBufferPoolPlugin() {}
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;
virtual QStringList keys() const = 0;
};
#endif

View File

@@ -71,7 +71,7 @@
#include <gst/gst.h>
#include "qabstractgstbufferpool_p.h"
#include "qgstbufferpoolinterface_p.h"
class QGstXvImageBufferPool;
@@ -91,7 +91,7 @@ struct QGstXvImageBuffer {
Q_DECLARE_METATYPE(XvImage*)
class QGstXvImageBufferPool : public QObject, public QAbstractGstBufferPool {
class QGstXvImageBufferPool : public QObject, public QGstBufferPoolInterface {
Q_OBJECT
friend class QGstXvImageBuffer;
public:

View File

@@ -64,7 +64,7 @@
#include <qvideoframe.h>
#include <qabstractvideobuffer.h>
#include "qabstractgstbufferpool_p.h"
#include "qgstbufferpoolinterface_p.h"
QT_BEGIN_NAMESPACE
class QAbstractVideoSurface;
@@ -92,7 +92,7 @@ public:
bool isActive();
QAbstractGstBufferPool *pool() { return m_pool; }
QGstBufferPoolInterface *pool() { return m_pool; }
QMutex *poolMutex() { return &m_poolMutex; }
GstFlowReturn render(GstBuffer *buffer);
@@ -109,8 +109,8 @@ private:
QList<QVideoFrame::PixelFormat> m_supportedPixelFormats;
//pixel formats of buffers pool native type
QList<QVideoFrame::PixelFormat> m_supportedPoolPixelFormats;
QAbstractGstBufferPool *m_pool;
QList<QAbstractGstBufferPool *> m_pools;
QGstBufferPoolInterface *m_pool;
QList<QGstBufferPoolInterface *> m_pools;
QMutex m_poolMutex;
QMutex m_mutex;
QWaitCondition m_setupCondition;