Gst backend: allow rendering other video buffers than allocated
Moved checking the buffer type to the buffer pool instead of comparing the buffer type in QVideoSurfaceGstSink. Some gstreamer elements may push other buffer instance than provided by sink but with the same data pointer. Change-Id: Iab3bf4da2d5eeb5d2a9375aa609a89515b067ce3 Reviewed-by: Lev Zelenskiy <lev.zelenskiy@nokia.com> Reviewed-by: Ling Hu <ling.hu@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
08d45baac2
commit
fdb5c419c4
@@ -177,6 +177,9 @@ QAbstractVideoBuffer::HandleType QGstXvImageBufferPool::handleType() const
|
|||||||
|
|
||||||
QAbstractVideoBuffer *QGstXvImageBufferPool::prepareVideoBuffer(GstBuffer *buffer, int bytesPerLine)
|
QAbstractVideoBuffer *QGstXvImageBufferPool::prepareVideoBuffer(GstBuffer *buffer, int bytesPerLine)
|
||||||
{
|
{
|
||||||
|
if (!G_TYPE_CHECK_INSTANCE_TYPE(buffer, bufferType()))
|
||||||
|
return 0;
|
||||||
|
|
||||||
QGstXvImageBuffer *xvBuffer = reinterpret_cast<QGstXvImageBuffer *>(buffer);
|
QGstXvImageBuffer *xvBuffer = reinterpret_cast<QGstXvImageBuffer *>(buffer);
|
||||||
QVariant handle = QVariant::fromValue(xvBuffer->xvImage);
|
QVariant handle = QVariant::fromValue(xvBuffer->xvImage);
|
||||||
return new QGstVideoBuffer(buffer, bytesPerLine, QAbstractVideoBuffer::XvShmImageHandle, handle);
|
return new QGstVideoBuffer(buffer, bytesPerLine, QAbstractVideoBuffer::XvShmImageHandle, handle);
|
||||||
|
|||||||
@@ -195,9 +195,10 @@ GstFlowReturn QVideoSurfaceGstDelegate::render(GstBuffer *buffer)
|
|||||||
|
|
||||||
QAbstractVideoBuffer *videoBuffer = 0;
|
QAbstractVideoBuffer *videoBuffer = 0;
|
||||||
|
|
||||||
if (m_pool && G_TYPE_CHECK_INSTANCE_TYPE(buffer, m_pool->bufferType()))
|
if (m_pool)
|
||||||
videoBuffer = m_pool->prepareVideoBuffer(buffer, m_bytesPerLine);
|
videoBuffer = m_pool->prepareVideoBuffer(buffer, m_bytesPerLine);
|
||||||
else
|
|
||||||
|
if (!videoBuffer)
|
||||||
videoBuffer = new QGstVideoBuffer(buffer, m_bytesPerLine);
|
videoBuffer = new QGstVideoBuffer(buffer, m_bytesPerLine);
|
||||||
|
|
||||||
m_frame = QVideoFrame(
|
m_frame = QVideoFrame(
|
||||||
|
|||||||
@@ -73,16 +73,14 @@ public:
|
|||||||
virtual ~QGstBufferPoolInterface() {}
|
virtual ~QGstBufferPoolInterface() {}
|
||||||
|
|
||||||
virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const = 0;
|
virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const = 0;
|
||||||
|
|
||||||
virtual GType bufferType() const = 0;
|
|
||||||
virtual GstBuffer *takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps) = 0;
|
virtual GstBuffer *takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps) = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
|
|
||||||
virtual QAbstractVideoBuffer::HandleType handleType() const = 0;
|
virtual QAbstractVideoBuffer::HandleType handleType() const = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Build an QAbstractVideoBuffer instance from compatible (mathcing gst buffer type)
|
Build an QAbstractVideoBuffer instance from GstBuffer.
|
||||||
GstBuffer.
|
Returns NULL if GstBuffer is not compatible with this buffer pool.
|
||||||
|
|
||||||
This method is called from gstreamer video sink thread.
|
This method is called from gstreamer video sink thread.
|
||||||
*/
|
*/
|
||||||
@@ -101,16 +99,14 @@ public:
|
|||||||
virtual ~QGstBufferPoolPlugin() {}
|
virtual ~QGstBufferPoolPlugin() {}
|
||||||
|
|
||||||
virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const = 0;
|
virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const = 0;
|
||||||
|
|
||||||
virtual GType bufferType() const = 0;
|
|
||||||
virtual GstBuffer *takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps) = 0;
|
virtual GstBuffer *takeBuffer(const QVideoSurfaceFormat &format, GstCaps *caps) = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
|
|
||||||
virtual QAbstractVideoBuffer::HandleType handleType() const = 0;
|
virtual QAbstractVideoBuffer::HandleType handleType() const = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Build an QAbstractVideoBuffer instance from compatible (mathcing gst buffer type)
|
Build an QAbstractVideoBuffer instance from compatible GstBuffer.
|
||||||
GstBuffer.
|
Returns NULL if GstBuffer is not compatible with this buffer pool.
|
||||||
|
|
||||||
This method is called from gstreamer video sink thread.
|
This method is called from gstreamer video sink thread.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user