download: only start a download transfer for sysmem caps features
authorMatthew Waters <matthew@centricular.com>
Tue, 7 Jul 2015 12:35:47 +0000 (22:35 +1000)
committerMatthew Waters <matthew@centricular.com>
Tue, 7 Jul 2015 12:38:08 +0000 (22:38 +1000)
ext/gl/gstgldownloadelement.c
gst-libs/gst/gl/egl/gstglcontext_egl.c

index 2423daf..94a6e7a 100644 (file)
@@ -32,8 +32,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_gl_download_element_debug);
 G_DEFINE_TYPE_WITH_CODE (GstGLDownloadElement, gst_gl_download_element,
     GST_TYPE_GL_BASE_FILTER,
     GST_DEBUG_CATEGORY_INIT (gst_gl_download_element_debug, "gldownloadelement",
-        0, "download element");
-    );
+        0, "download element"););
 
 static gboolean gst_gl_download_element_get_unit_size (GstBaseTransform * trans,
     GstCaps * caps, gsize * size);
@@ -161,18 +160,30 @@ static GstFlowReturn
 gst_gl_download_element_prepare_output_buffer (GstBaseTransform * bt,
     GstBuffer * inbuf, GstBuffer ** outbuf)
 {
+  GstCaps *src_caps = gst_pad_get_current_caps (bt->srcpad);
+  GstCapsFeatures *features = NULL;
   gint i, n;
 
   *outbuf = inbuf;
 
+  if (src_caps)
+    features = gst_caps_get_features (src_caps, 0);
+
   n = gst_buffer_n_memory (*outbuf);
   for (i = 0; i < n; i++) {
     GstMemory *mem = gst_buffer_peek_memory (*outbuf, i);
 
-    if (gst_is_gl_memory (mem))
-      gst_gl_memory_download_transfer ((GstGLMemory *) mem);
+    if (gst_is_gl_memory (mem)) {
+      if (!features || gst_caps_features_contains (features,
+              GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY)) {
+        gst_gl_memory_download_transfer ((GstGLMemory *) mem);
+      }
+    }
   }
 
+  if (src_caps)
+    gst_caps_unref (src_caps);
+
   return GST_FLOW_OK;
 }
 
index 697e7fd..1b130a8 100644 (file)
@@ -389,14 +389,14 @@ gst_gl_context_egl_create_context (GstGLContext * context,
         gst_gl_context_egl_get_error_string ());
     goto failure;
   }
-
-  if (other_context == NULL) {
-    /* FIXME do we want a window vfunc ? */
+  /* FIXME do we want a window vfunc ? */
 #if GST_GL_HAVE_WINDOW_X11
-    if (GST_GL_IS_WINDOW_X11 (context->window)) {
-      gst_gl_window_x11_create_window ((GstGLWindowX11 *) context->window);
-    }
+  if (GST_GL_IS_WINDOW_X11 (context->window)) {
+    gst_gl_window_x11_create_window ((GstGLWindowX11 *) context->window);
+  }
 #endif
+
+  if (other_context == NULL) {
 #if GST_GL_HAVE_WINDOW_WAYLAND
     if (GST_GL_IS_WINDOW_WAYLAND_EGL (context->window)) {
       gst_gl_window_wayland_egl_create_window ((GstGLWindowWaylandEGL *)