]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugin-ducati.git/commitdiff
ducatividdec: Implement src pad getcaps function
authorLuciana Fujii Pontello <luciana.fujii@collabora.co.uk>
Thu, 22 Mar 2012 01:42:30 +0000 (21:42 -0400)
committerLuciana Fujii Pontello <luciana.fujii@collabora.co.uk>
Thu, 29 Mar 2012 01:41:46 +0000 (21:41 -0400)
The caps of the src pad should not change with upstream negotiation
except between regular yuv and rowstrided.

src/gstducatividdec.c

index 43210248856d9d3d3c55e83e8df669c1549ad272..36f04a00691fa74e8873b39de2b0a978758bd559 100644 (file)
@@ -751,6 +751,42 @@ out:
   return ret;
 }
 
   return ret;
 }
 
+static GstCaps *
+gst_ducati_viddec_src_getcaps (GstPad * pad)
+{
+  GstCaps *caps = NULL;
+  GstCaps *outcaps = NULL;
+  int i;
+
+  caps = GST_PAD_CAPS (pad);
+  if (caps == NULL) {
+    outcaps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
+    return outcaps;
+  }
+
+  outcaps = gst_caps_new_empty ();
+
+  /* allow -rowstrided and regular yuv */
+  for (i = 0; i < gst_caps_get_size (caps); i++) {
+    GstStructure *structure;
+    GstStructure *modified_structure;
+
+    structure = gst_caps_get_structure (caps, i);
+    gst_caps_append_structure (outcaps, gst_structure_copy (structure));
+    modified_structure = gst_structure_copy (structure);
+
+    if (gst_structure_has_name (structure, "video/x-raw-yuv")) {
+      gst_structure_set_name (modified_structure, "video/x-raw-yuv-strided");
+      gst_caps_append_structure (outcaps, modified_structure);
+    } else {
+      gst_structure_set_name (modified_structure, "video/x-raw-yuv");
+      gst_structure_remove_field (modified_structure, "rowstride");
+      gst_caps_append_structure (outcaps, modified_structure);
+    }
+  }
+  return outcaps;
+}
+
 static gboolean
 gst_ducati_viddec_query (GstDucatiVidDec * self, GstPad * pad,
     GstQuery * query, gboolean * forward)
 static gboolean
 gst_ducati_viddec_query (GstDucatiVidDec * self, GstPad * pad,
     GstQuery * query, gboolean * forward)
@@ -1243,6 +1279,8 @@ gst_ducati_viddec_init (GstDucatiVidDec * self, GstDucatiVidDecClass * klass)
       GST_DEBUG_FUNCPTR (gst_ducati_viddec_src_event));
   gst_pad_set_query_function (self->srcpad,
       GST_DEBUG_FUNCPTR (gst_ducati_viddec_src_query));
       GST_DEBUG_FUNCPTR (gst_ducati_viddec_src_event));
   gst_pad_set_query_function (self->srcpad,
       GST_DEBUG_FUNCPTR (gst_ducati_viddec_src_query));
+  gst_pad_set_getcaps_function (self->srcpad,
+      GST_DEBUG_FUNCPTR (gst_ducati_viddec_src_getcaps));
 
   gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
   gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
 
   gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
   gst_element_add_pad (GST_ELEMENT (self), self->srcpad);