GStreamer: port to 1.0.
0.10 is still used by default. To enable GStreamer 1.0, pass GST_VERSION=1.0 to qmake for qtmultimedia.pro. Contributions from: Andrew den Exter <andrew.den.exter@qinetic.com.au> Ilya Smelykh <ilya@videoexpertsgroup.com> Jim Hodapp <jim.hodapp@canonical.com> Sergio Schvezov <sergio.schvezov@canonical.com> Change-Id: I72a46d1170a8794a149bdb5e20767afcc5b7587c Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
This commit is contained in:
committed by
Andrew den Exter
parent
7e3d69668e
commit
108dda7a90
@@ -39,7 +39,10 @@
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/app/gstappsrc.h>
|
||||
|
||||
#if GST_VERSION_MAJOR < 1
|
||||
#include <gst/app/gstappbuffer.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
@@ -38,23 +38,32 @@
|
||||
#include <qmediaaudioprobecontrol.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <qaudiobuffer.h>
|
||||
#include <qshareddata.h>
|
||||
|
||||
#include <private/qgstreamerbufferprobe_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QGstreamerAudioProbeControl : public QMediaAudioProbeControl
|
||||
class QGstreamerAudioProbeControl
|
||||
: public QMediaAudioProbeControl
|
||||
, public QGstreamerBufferProbe
|
||||
, public QSharedData
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QGstreamerAudioProbeControl(QObject *parent);
|
||||
virtual ~QGstreamerAudioProbeControl();
|
||||
|
||||
void bufferProbed(GstBuffer* buffer);
|
||||
protected:
|
||||
void probeCaps(GstCaps *caps);
|
||||
bool probeBuffer(GstBuffer *buffer);
|
||||
|
||||
private slots:
|
||||
void bufferProbed();
|
||||
|
||||
private:
|
||||
QAudioBuffer m_pendingBuffer;
|
||||
QAudioFormat m_format;
|
||||
QMutex m_bufferMutex;
|
||||
};
|
||||
|
||||
|
||||
86
src/multimedia/gsttools_headers/qgstreamerbufferprobe_p.h
Normal file
86
src/multimedia/gsttools_headers/qgstreamerbufferprobe_p.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 Jolla Ltd.
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia 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.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QGSTREAMERBUFFERPROBE_H
|
||||
#define QGSTREAMERBUFFERPROBE_H
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QGstreamerBufferProbe
|
||||
{
|
||||
public:
|
||||
enum Flags
|
||||
{
|
||||
ProbeCaps = 0x01,
|
||||
ProbeBuffers = 0x02,
|
||||
ProbeAll = ProbeCaps | ProbeBuffers
|
||||
};
|
||||
|
||||
explicit QGstreamerBufferProbe(Flags flags = ProbeAll);
|
||||
virtual ~QGstreamerBufferProbe();
|
||||
|
||||
void addProbeToPad(GstPad *pad, bool downstream = true);
|
||||
void removeProbeFromPad(GstPad *pad);
|
||||
|
||||
protected:
|
||||
virtual void probeCaps(GstCaps *caps);
|
||||
virtual bool probeBuffer(GstBuffer *buffer);
|
||||
|
||||
private:
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
static GstPadProbeReturn capsProbe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data);
|
||||
static GstPadProbeReturn bufferProbe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data);
|
||||
int m_capsProbeId;
|
||||
#else
|
||||
static gboolean bufferProbe(GstElement *element, GstBuffer *buffer, gpointer user_data);
|
||||
GstCaps *m_caps;
|
||||
#endif
|
||||
int m_bufferProbeId;
|
||||
const Flags m_flags;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QGSTREAMERAUDIOPROBECONTROL_H
|
||||
102
src/multimedia/gsttools_headers/qgstreamermirtexturerenderer_p.h
Normal file
102
src/multimedia/gsttools_headers/qgstreamermirtexturerenderer_p.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 Canonical Ltd.
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QGSTREAMERMIRTEXTURERENDERER_H
|
||||
#define QGSTREAMERMIRTEXTURERENDERER_H
|
||||
|
||||
#include <qmediaplayer.h>
|
||||
#include <qvideorenderercontrol.h>
|
||||
#include <private/qvideosurfacegstsink_p.h>
|
||||
#include <qabstractvideosurface.h>
|
||||
|
||||
#include "qgstreamervideorendererinterface_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QGstreamerMirTextureBuffer;
|
||||
class QGstreamerPlayerSession;
|
||||
class QGLContext;
|
||||
class QOpenGLContext;
|
||||
class QSurfaceFormat;
|
||||
|
||||
class QGstreamerMirTextureRenderer : public QVideoRendererControl, public QGstreamerVideoRendererInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGstreamerVideoRendererInterface)
|
||||
public:
|
||||
QGstreamerMirTextureRenderer(QObject *parent = 0, const QGstreamerPlayerSession *playerSession = 0);
|
||||
virtual ~QGstreamerMirTextureRenderer();
|
||||
|
||||
QAbstractVideoSurface *surface() const;
|
||||
void setSurface(QAbstractVideoSurface *surface);
|
||||
|
||||
void setPlayerSession(const QGstreamerPlayerSession *playerSession);
|
||||
|
||||
GstElement *videoSink();
|
||||
|
||||
void stopRenderer();
|
||||
bool isReady() const { return m_surface != 0; }
|
||||
|
||||
signals:
|
||||
void sinkChanged();
|
||||
void readyChanged(bool);
|
||||
void nativeSizeChanged();
|
||||
|
||||
private slots:
|
||||
void handleFormatChange();
|
||||
void updateNativeVideoSize();
|
||||
void handleFocusWindowChanged(QWindow *window);
|
||||
void renderFrame();
|
||||
|
||||
private:
|
||||
QWindow *createOffscreenWindow(const QSurfaceFormat &format);
|
||||
static void handleFrameReady(gpointer userData);
|
||||
static GstPadProbeReturn padBufferProbe(GstPad *pad, GstPadProbeInfo *info, gpointer userData);
|
||||
|
||||
GstElement *m_videoSink;
|
||||
QPointer<QAbstractVideoSurface> m_surface;
|
||||
QPointer<QAbstractVideoSurface> m_glSurface;
|
||||
QGLContext *m_context;
|
||||
QOpenGLContext *m_glContext;
|
||||
unsigned int m_textureId;
|
||||
QWindow *m_offscreenSurface;
|
||||
QGstreamerPlayerSession *m_playerSession;
|
||||
QGstreamerMirTextureBuffer *m_textureBuffer;
|
||||
QSize m_nativeSize;
|
||||
|
||||
QMutex m_mutex;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QGSTREAMERMIRTEXTURERENDRER_H
|
||||
@@ -35,20 +35,29 @@
|
||||
#define QGSTREAMERVIDEOPROBECONTROL_H
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <qmediavideoprobecontrol.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <qvideoframe.h>
|
||||
#include <qvideosurfaceformat.h>
|
||||
|
||||
#include <private/qgstreamerbufferprobe_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QGstreamerVideoProbeControl : public QMediaVideoProbeControl
|
||||
class QGstreamerVideoProbeControl
|
||||
: public QMediaVideoProbeControl
|
||||
, public QGstreamerBufferProbe
|
||||
, public QSharedData
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QGstreamerVideoProbeControl(QObject *parent);
|
||||
virtual ~QGstreamerVideoProbeControl();
|
||||
|
||||
void bufferProbed(GstBuffer* buffer);
|
||||
void probeCaps(GstCaps *caps);
|
||||
bool probeBuffer(GstBuffer *buffer);
|
||||
|
||||
void startFlushing();
|
||||
void stopFlushing();
|
||||
|
||||
@@ -56,10 +65,16 @@ private slots:
|
||||
void frameProbed();
|
||||
|
||||
private:
|
||||
bool m_flushing;
|
||||
bool m_frameProbed; // true if at least one frame was probed
|
||||
QVideoSurfaceFormat m_format;
|
||||
QVideoFrame m_pendingFrame;
|
||||
QMutex m_frameMutex;
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
GstVideoInfo m_videoInfo;
|
||||
#else
|
||||
int m_bytesPerLine;
|
||||
#endif
|
||||
bool m_flushing;
|
||||
bool m_frameProbed; // true if at least one frame was probed
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include "qgstreamervideorendererinterface_p.h"
|
||||
#include <private/qgstreamerbushelper_p.h>
|
||||
#include <private/qgstreamerbufferprobe_p.h>
|
||||
#include <QtGui/qcolor.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -45,7 +46,8 @@ class QAbstractVideoSurface;
|
||||
|
||||
class QGstreamerVideoWindow : public QVideoWindowControl,
|
||||
public QGstreamerVideoRendererInterface,
|
||||
public QGstreamerSyncMessageFilter
|
||||
public QGstreamerSyncMessageFilter,
|
||||
private QGstreamerBufferProbe
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGstreamerVideoRendererInterface QGstreamerSyncMessageFilter)
|
||||
@@ -101,10 +103,10 @@ signals:
|
||||
void readyChanged(bool);
|
||||
|
||||
private slots:
|
||||
void updateNativeVideoSize();
|
||||
void updateNativeVideoSize(const QSize &size);
|
||||
|
||||
private:
|
||||
static void padBufferProbe(GstPad *pad, GstBuffer *buffer, gpointer user_data);
|
||||
void probeCaps(GstCaps *caps);
|
||||
|
||||
GstElement *m_videoSink;
|
||||
WId m_windowId;
|
||||
@@ -113,7 +115,6 @@ private:
|
||||
bool m_fullScreen;
|
||||
QSize m_nativeSize;
|
||||
mutable QColor m_colorKey;
|
||||
int m_bufferProbeId;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -49,14 +49,32 @@
|
||||
#include <QtCore/qset.h>
|
||||
#include <QtCore/qvector.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <qaudioformat.h>
|
||||
#include <qcamera.h>
|
||||
#include <qabstractvideobuffer.h>
|
||||
#include <qvideoframe.h>
|
||||
#include <QDebug>
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
# define QT_GSTREAMER_PLAYBIN_ELEMENT_NAME "playbin"
|
||||
# define QT_GSTREAMER_CAMERABIN_ELEMENT_NAME "camerabin"
|
||||
# define QT_GSTREAMER_COLORCONVERSION_ELEMENT_NAME "videoconvert"
|
||||
# define QT_GSTREAMER_RAW_AUDIO_MIME "audio/x-raw"
|
||||
#else
|
||||
# define QT_GSTREAMER_PLAYBIN_ELEMENT_NAME "playbin2"
|
||||
# define QT_GSTREAMER_CAMERABIN_ELEMENT_NAME "camerabin2"
|
||||
# define QT_GSTREAMER_COLORCONVERSION_ELEMENT_NAME "ffmpegcolorspace"
|
||||
# define QT_GSTREAMER_RAW_AUDIO_MIME "audio/x-raw-int"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QSize;
|
||||
class QVariant;
|
||||
class QByteArray;
|
||||
class QImage;
|
||||
class QVideoSurfaceFormat;
|
||||
|
||||
namespace QGstUtils {
|
||||
struct CameraInfo
|
||||
@@ -73,8 +91,12 @@ namespace QGstUtils {
|
||||
QSize capsResolution(const GstCaps *caps);
|
||||
QSize capsCorrectedResolution(const GstCaps *caps);
|
||||
QAudioFormat audioFormatForCaps(const GstCaps *caps);
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
QAudioFormat audioFormatForSample(GstSample *sample);
|
||||
#else
|
||||
QAudioFormat audioFormatForBuffer(GstBuffer *buffer);
|
||||
GstCaps *capsForAudioFormat(QAudioFormat format);
|
||||
#endif
|
||||
GstCaps *capsForAudioFormat(const QAudioFormat &format);
|
||||
void initializeGst();
|
||||
QMultimedia::SupportEstimate hasSupport(const QString &mimeType,
|
||||
const QStringList &codecs,
|
||||
@@ -86,9 +108,40 @@ namespace QGstUtils {
|
||||
QCamera::Position cameraPosition(const QString &device, GstElementFactory * factory = 0);
|
||||
int cameraOrientation(const QString &device, GstElementFactory * factory = 0);
|
||||
QByteArray cameraDriver(const QString &device, GstElementFactory * factory = 0);
|
||||
|
||||
QSet<QString> supportedMimeTypes(bool (*isValidFactory)(GstElementFactory *factory));
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
QImage bufferToImage(GstBuffer *buffer, const GstVideoInfo &info);
|
||||
QVideoSurfaceFormat formatForCaps(
|
||||
GstCaps *caps,
|
||||
GstVideoInfo *info,
|
||||
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle);
|
||||
#else
|
||||
QImage bufferToImage(GstBuffer *buffer);
|
||||
QVideoSurfaceFormat formatForCaps(
|
||||
GstCaps *caps,
|
||||
int *bytesPerLine = 0,
|
||||
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle);
|
||||
#endif
|
||||
|
||||
GstCaps *capsForFormats(const QList<QVideoFrame::PixelFormat> &formats);
|
||||
void setFrameTimeStamps(QVideoFrame *frame, GstBuffer *buffer);
|
||||
|
||||
void setMetaData(GstElement *element, const QMap<QByteArray, QVariant> &data);
|
||||
void setMetaData(GstBin *bin, const QMap<QByteArray, QVariant> &data);
|
||||
|
||||
GstCaps *videoFilterCaps();
|
||||
|
||||
}
|
||||
|
||||
void qt_gst_object_ref_sink(gpointer object);
|
||||
GstCaps *qt_gst_pad_get_current_caps(GstPad *pad);
|
||||
GstStructure *qt_gst_structure_new_empty(const char *name);
|
||||
gboolean qt_gst_element_query_position(GstElement *element, GstFormat format, gint64 *cur);
|
||||
gboolean qt_gst_element_query_duration(GstElement *element, GstFormat format, gint64 *cur);
|
||||
|
||||
QDebug operator <<(QDebug debug, GstCaps *caps);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
@@ -49,26 +49,47 @@
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
class QGstVideoBuffer : public QAbstractPlanarVideoBuffer
|
||||
{
|
||||
public:
|
||||
QGstVideoBuffer(GstBuffer *buffer, const GstVideoInfo &info);
|
||||
QGstVideoBuffer(GstBuffer *buffer, const GstVideoInfo &info,
|
||||
HandleType handleType, const QVariant &handle);
|
||||
#else
|
||||
class QGstVideoBuffer : public QAbstractVideoBuffer
|
||||
{
|
||||
public:
|
||||
QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine);
|
||||
QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine,
|
||||
HandleType handleType, const QVariant &handle);
|
||||
#endif
|
||||
|
||||
~QGstVideoBuffer();
|
||||
|
||||
MapMode mapMode() const;
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
int map(MapMode mode, int *numBytes, int bytesPerLine[4], uchar *data[4]);
|
||||
#else
|
||||
uchar *map(MapMode mode, int *numBytes, int *bytesPerLine);
|
||||
#endif
|
||||
|
||||
void unmap();
|
||||
|
||||
QVariant handle() const { return m_handle; }
|
||||
private:
|
||||
GstBuffer *m_buffer;
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
GstVideoInfo m_videoInfo;
|
||||
GstVideoFrame m_frame;
|
||||
#else
|
||||
int m_bytesPerLine;
|
||||
#endif
|
||||
GstBuffer *m_buffer;
|
||||
MapMode m_mode;
|
||||
QVariant m_handle;
|
||||
};
|
||||
|
||||
111
src/multimedia/gsttools_headers/qgstvideorendererplugin_p.h
Normal file
111
src/multimedia/gsttools_headers/qgstvideorendererplugin_p.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 Jolla Ltd.
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia 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.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QGSTVIDEORENDERERPLUGIN_P_H
|
||||
#define QGSTVIDEORENDERERPLUGIN_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/qobject.h>
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QAbstractVideoSurface;
|
||||
|
||||
const QLatin1String QGstVideoRendererPluginKey("gstvideorenderer");
|
||||
|
||||
class QGstVideoRenderer
|
||||
{
|
||||
public:
|
||||
virtual ~QGstVideoRenderer() {}
|
||||
|
||||
virtual GstCaps *getCaps(QAbstractVideoSurface *surface) = 0;
|
||||
virtual bool start(QAbstractVideoSurface *surface, GstCaps *caps) = 0;
|
||||
virtual void stop(QAbstractVideoSurface *surface) = 0; // surface may be null if unexpectedly deleted.
|
||||
virtual bool proposeAllocation(GstQuery *query) = 0; // may be called from a thread.
|
||||
|
||||
virtual bool present(QAbstractVideoSurface *surface, GstBuffer *buffer) = 0;
|
||||
virtual void flush(QAbstractVideoSurface *surface) = 0; // surface may be null if unexpectedly deleted.
|
||||
};
|
||||
|
||||
/*
|
||||
Abstract interface for video buffers allocation.
|
||||
*/
|
||||
class QGstVideoRendererInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QGstVideoRendererInterface() {}
|
||||
|
||||
virtual QGstVideoRenderer *createRenderer() = 0;
|
||||
};
|
||||
|
||||
#define QGstVideoRendererInterface_iid "org.qt-project.qt.gstvideorenderer/5.4"
|
||||
Q_DECLARE_INTERFACE(QGstVideoRendererInterface, QGstVideoRendererInterface_iid)
|
||||
|
||||
class QGstVideoRendererPlugin : public QObject, public QGstVideoRendererInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGstVideoRendererInterface)
|
||||
public:
|
||||
explicit QGstVideoRendererPlugin(QObject *parent = 0);
|
||||
virtual ~QGstVideoRendererPlugin() {}
|
||||
|
||||
virtual QGstVideoRenderer *createRenderer() = 0;
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
183
src/multimedia/gsttools_headers/qgstvideorenderersink_p.h
Normal file
183
src/multimedia/gsttools_headers/qgstvideorenderersink_p.h
Normal file
@@ -0,0 +1,183 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2014 Jolla Ltd.
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia 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.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QGSTVIDEORENDERERSINK_P_H
|
||||
#define QGSTVIDEORENDERERSINK_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 <gst/video/video.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 "qgstvideorendererplugin_p.h"
|
||||
|
||||
#include "qgstvideorendererplugin_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractVideoSurface;
|
||||
|
||||
class QGstDefaultVideoRenderer : public QGstVideoRenderer
|
||||
{
|
||||
public:
|
||||
QGstDefaultVideoRenderer();
|
||||
~QGstDefaultVideoRenderer();
|
||||
|
||||
GstCaps *getCaps(QAbstractVideoSurface *surface);
|
||||
bool start(QAbstractVideoSurface *surface, GstCaps *caps);
|
||||
void stop(QAbstractVideoSurface *surface);
|
||||
|
||||
bool proposeAllocation(GstQuery *query);
|
||||
|
||||
bool present(QAbstractVideoSurface *surface, GstBuffer *buffer);
|
||||
void flush(QAbstractVideoSurface *surface);
|
||||
|
||||
private:
|
||||
QVideoSurfaceFormat m_format;
|
||||
GstVideoInfo m_videoInfo;
|
||||
bool m_flushed;
|
||||
};
|
||||
|
||||
class QVideoSurfaceGstDelegate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QVideoSurfaceGstDelegate(QAbstractVideoSurface *surface);
|
||||
~QVideoSurfaceGstDelegate();
|
||||
|
||||
GstCaps *caps();
|
||||
|
||||
bool start(GstCaps *caps);
|
||||
void stop();
|
||||
bool proposeAllocation(GstQuery *query);
|
||||
|
||||
void flush();
|
||||
|
||||
GstFlowReturn render(GstBuffer *buffer, bool show);
|
||||
|
||||
bool event(QEvent *event);
|
||||
|
||||
static void handleShowPrerollChange(GObject *o, GParamSpec *p, gpointer d);
|
||||
|
||||
private slots:
|
||||
bool handleEvent(QMutexLocker *locker);
|
||||
void updateSupportedFormats();
|
||||
|
||||
private:
|
||||
void notify();
|
||||
bool waitForAsyncEvent(QMutexLocker *locker, QWaitCondition *condition, unsigned long time);
|
||||
|
||||
QPointer<QAbstractVideoSurface> m_surface;
|
||||
|
||||
QMutex m_mutex;
|
||||
QWaitCondition m_setupCondition;
|
||||
QWaitCondition m_renderCondition;
|
||||
GstFlowReturn m_renderReturn;
|
||||
QList<QGstVideoRenderer *> m_renderers;
|
||||
QGstVideoRenderer *m_renderer;
|
||||
QGstVideoRenderer *m_activeRenderer;
|
||||
|
||||
GstCaps *m_surfaceCaps;
|
||||
GstCaps *m_startCaps;
|
||||
GstBuffer *m_lastBuffer;
|
||||
|
||||
bool m_notified;
|
||||
bool m_stop;
|
||||
bool m_render;
|
||||
bool m_flush;
|
||||
};
|
||||
|
||||
class QGstVideoRendererSink
|
||||
{
|
||||
public:
|
||||
GstVideoSink parent;
|
||||
|
||||
static QGstVideoRendererSink *createSink(QAbstractVideoSurface *surface);
|
||||
|
||||
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, GstCaps *filter);
|
||||
static gboolean set_caps(GstBaseSink *sink, GstCaps *caps);
|
||||
|
||||
static gboolean propose_allocation(GstBaseSink *sink, GstQuery *query);
|
||||
|
||||
static GstFlowReturn preroll(GstBaseSink *sink, GstBuffer *buffer);
|
||||
static GstFlowReturn render(GstBaseSink *sink, GstBuffer *buffer);
|
||||
|
||||
private:
|
||||
QVideoSurfaceGstDelegate *delegate;
|
||||
};
|
||||
|
||||
|
||||
class QGstVideoRendererSinkClass
|
||||
{
|
||||
public:
|
||||
GstVideoSinkClass parent_class;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
@@ -45,6 +45,18 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
|
||||
#include "qgstvideorenderersink_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
typedef QGstVideoRendererSink QVideoSurfaceGstSink;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#else
|
||||
|
||||
#include <gst/video/gstvideosink.h>
|
||||
|
||||
#include <QtCore/qlist.h>
|
||||
@@ -116,10 +128,6 @@ public:
|
||||
GstVideoSink parent;
|
||||
|
||||
static QVideoSurfaceGstSink *createSink(QAbstractVideoSurface *surface);
|
||||
static QVideoSurfaceFormat formatForCaps(GstCaps *caps,
|
||||
int *bytesPerLine = 0,
|
||||
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle);
|
||||
static void setFrameTimeStamps(QVideoFrame *frame, GstBuffer *buffer);
|
||||
|
||||
private:
|
||||
static GType get_type();
|
||||
@@ -150,7 +158,6 @@ private:
|
||||
QVideoSurfaceFormat *lastSurfaceFormat;
|
||||
};
|
||||
|
||||
|
||||
class QVideoSurfaceGstSinkClass
|
||||
{
|
||||
public:
|
||||
@@ -160,3 +167,5 @@ public:
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user