ximagesink: Add caps with the current window geometry to the top in getcaps
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 28 Apr 2011 08:55:21 +0000 (10:55 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 5 May 2011 13:23:17 +0000 (15:23 +0200)
sys/ximage/ximagesink.c

index 8c9cdff235e6a479d0059895dfd5c8d13bf22113..80fff86f33b9c0a9fe4d76dc67450ee7f7b1d825 100644 (file)
@@ -974,8 +974,27 @@ gst_ximagesink_getcaps (GstBaseSink * bsink)
 
   ximagesink = GST_XIMAGESINK (bsink);
 
-  if (ximagesink->xcontext)
-    return gst_caps_ref (ximagesink->xcontext->caps);
+  g_mutex_lock (ximagesink->x_lock);
+  if (ximagesink->xcontext) {
+    if (ximagesink->xwindow && ximagesink->xwindow->width) {
+      GstStructure *s0, *s1;
+
+      caps = gst_caps_copy (ximagesink->xcontext->caps);
+
+      s1 = gst_structure_copy (gst_caps_get_structure (caps, 0));
+      s0 = gst_caps_get_structure (caps, 0);
+      gst_structure_set (s0, "width", G_TYPE_INT, ximagesink->xwindow->width,
+          "height", G_TYPE_INT, ximagesink->xwindow->height, NULL);
+      gst_caps_append_structure (caps, s1);
+      g_mutex_unlock (ximagesink->x_lock);
+      return caps;
+    } else {
+      caps = gst_caps_ref (ximagesink->xcontext->caps);
+      g_mutex_unlock (ximagesink->x_lock);
+      return caps;
+    }
+  }
+  g_mutex_unlock (ximagesink->x_lock);
 
   /* get a template copy and add the pixel aspect ratio */
   caps =