diff --git a/src/gsttools/qvideosurfacegstsink.cpp b/src/gsttools/qvideosurfacegstsink.cpp index 1d6a1057..6347582a 100644 --- a/src/gsttools/qvideosurfacegstsink.cpp +++ b/src/gsttools/qvideosurfacegstsink.cpp @@ -523,7 +523,24 @@ GstCaps *QVideoSurfaceGstSink::get_caps(GstBaseSink *base) GstCaps *caps = gst_caps_new_empty(); + // Find the supported pixel formats + // with buffer pool specific formats listed first + QList supportedFormats; + + QList poolHandleFormats; + sink->delegate->poolMutex()->lock(); + QGstBufferPoolInterface *pool = sink->delegate->pool(); + if (pool) + poolHandleFormats = sink->delegate->supportedPixelFormats(pool->handleType()); + sink->delegate->poolMutex()->unlock(); + + supportedFormats = poolHandleFormats; foreach (QVideoFrame::PixelFormat format, sink->delegate->supportedPixelFormats()) { + if (!poolHandleFormats.contains(format)) + supportedFormats.append(format); + } + + foreach (QVideoFrame::PixelFormat format, supportedFormats) { int index = indexOfYuvColor(format); if (index != -1) { @@ -750,6 +767,8 @@ GstFlowReturn QVideoSurfaceGstSink::buffer_alloc( return GST_FLOW_OK; } + poolLock.unlock(); + GstCaps *intersection = gst_caps_intersect(get_caps(GST_BASE_SINK(sink)), caps); if (gst_caps_is_empty (intersection)) { @@ -757,8 +776,6 @@ GstFlowReturn QVideoSurfaceGstSink::buffer_alloc( return GST_FLOW_NOT_NEGOTIATED; } - poolLock.unlock(); - if (sink->delegate->isActive()) { //if format was changed, restart the surface QVideoSurfaceFormat format = formatForCaps(intersection);