gst video surface sink: start surface with correct handle type
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
Wed, 14 Mar 2012 01:52:43 +0000 (11:52 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 14 Mar 2012 03:47:51 +0000 (04:47 +0100)
The handle type should match one from the currently used buffer pool.

Change-Id: I33f7856a742299ce0640f331898c3cbe5cfbdf97
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
src/gsttools/qvideosurfacegstsink.cpp
src/multimedia/gsttools_headers/qvideosurfacegstsink_p.h

index 65aca1f..c1f2792 100644 (file)
@@ -581,7 +581,11 @@ gboolean QVideoSurfaceGstSink::set_caps(GstBaseSink *base, GstCaps *caps)
         return TRUE;
     } else {
         int bytesPerLine = 0;
-        QVideoSurfaceFormat format = formatForCaps(caps, &bytesPerLine);
+        QGstBufferPoolInterface *pool = sink->delegate->pool();
+        QAbstractVideoBuffer::HandleType handleType =
+                pool ? pool->handleType() : QAbstractVideoBuffer::NoHandle;
+
+        QVideoSurfaceFormat format = formatForCaps(caps, &bytesPerLine, handleType);
 
         if (sink->delegate->isActive()) {
             QVideoSurfaceFormat surfaceFormst = sink->delegate->surfaceFormat();
@@ -612,7 +616,7 @@ gboolean QVideoSurfaceGstSink::set_caps(GstBaseSink *base, GstCaps *caps)
     return FALSE;
 }
 
-QVideoSurfaceFormat QVideoSurfaceGstSink::formatForCaps(GstCaps *caps, int *bytesPerLine)
+QVideoSurfaceFormat QVideoSurfaceGstSink::formatForCaps(GstCaps *caps, int *bytesPerLine, QAbstractVideoBuffer::HandleType handleType)
 {
     const GstStructure *structure = gst_caps_get_structure(caps, 0);
 
@@ -655,7 +659,7 @@ QVideoSurfaceFormat QVideoSurfaceGstSink::formatForCaps(GstCaps *caps, int *byte
     }
 
     if (pixelFormat != QVideoFrame::Format_Invalid) {
-        QVideoSurfaceFormat format(size, pixelFormat);
+        QVideoSurfaceFormat format(size, pixelFormat, handleType);
 
         QPair<int, int> rate;
         gst_structure_get_fraction(structure, "framerate", &rate.first, &rate.second);
@@ -771,7 +775,11 @@ GstFlowReturn QVideoSurfaceGstSink::buffer_alloc(
 
     if (!sink->delegate->isActive()) {
         int bytesPerLine = 0;
-        QVideoSurfaceFormat format = formatForCaps(intersection, &bytesPerLine);
+        QGstBufferPoolInterface *pool = sink->delegate->pool();
+        QAbstractVideoBuffer::HandleType handleType =
+                pool ? pool->handleType() : QAbstractVideoBuffer::NoHandle;
+
+        QVideoSurfaceFormat format = formatForCaps(intersection, &bytesPerLine, handleType);
 
         if (!sink->delegate->start(format, bytesPerLine)) {
             qWarning() << "failed to start video surface";
index 143f65d..6ee6907 100644 (file)
@@ -134,7 +134,9 @@ public:
     GstVideoSink parent;
 
     static QVideoSurfaceGstSink *createSink(QAbstractVideoSurface *surface);
-    static QVideoSurfaceFormat formatForCaps(GstCaps *caps, int *bytesPerLine = 0);
+    static QVideoSurfaceFormat formatForCaps(GstCaps *caps,
+                                             int *bytesPerLine = 0,
+                                             QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle);
     static void setFrameTimeStamps(QVideoFrame *frame, GstBuffer *buffer);
 
     static void handleShowPrerollChange(GObject *o, GParamSpec *p, gpointer d);