[884/906] filter: return the pad template caps in transform_caps
authorMatthew Waters <ystreet00@gmail.com>
Fri, 21 Feb 2014 02:28:16 +0000 (13:28 +1100)
committerMatthew Waters <ystreet00@gmail.com>
Sat, 15 Mar 2014 17:37:06 +0000 (18:37 +0100)
We can transform from any input in our caps to any output.
With the following pipeline snippet:

  ... ! vaapidecode ! glcolorscale ! xvimagesink

GstVideoGLTextureUploadMeta was being used on both src and sink
pads causing linking to fail.  This allows the usage of the meta
on either pad without affecting whether the meta is chosen on the
other pad.

gst-libs/gst/gl/gstglfilter.c

index d6a0b9d..f91d0ec 100644 (file)
@@ -638,42 +638,16 @@ static GstCaps *
 gst_gl_filter_transform_caps (GstBaseTransform * bt,
     GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
-  //GstGLFilter* filter = GST_GL_FILTER (bt);
-  GstStructure *structure;
-  GstCapsFeatures *features;
   GstCaps *newcaps, *result;
-  const GValue *par;
-  guint i, n;
 
-  par = NULL;
-  newcaps = gst_caps_new_empty ();
-  n = gst_caps_get_size (caps);
-
-  for (i = 0; i < n; i++) {
-    structure = gst_caps_get_structure (caps, i);
-    features = gst_caps_get_features (caps, i);
-
-    if (i > 0
-        && gst_caps_is_subset_structure_full (newcaps, structure, features))
-      continue;
-
-    structure = gst_structure_copy (structure);
-    features = gst_caps_features_copy (features);
-
-    gst_structure_set (structure,
-        "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
-        "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
-
-    gst_structure_remove_field (structure, "format");
-
-    if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
-      gst_structure_set (structure,
-          "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
-          NULL);
-    }
-
-    gst_caps_append_structure_full (newcaps, structure, features);
-  }
+  if (direction == GST_PAD_SINK)
+    newcaps =
+        gst_static_pad_template_get_caps (&gst_gl_filter_src_pad_template);
+  else if (direction == GST_PAD_SRC)
+    newcaps =
+        gst_static_pad_template_get_caps (&gst_gl_filter_sink_pad_template);
+  else
+    newcaps = gst_caps_new_any ();
 
   if (filter) {
     result =