audioparsers: Fix GstBaseParse::get_sink_caps() implementations
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 5 Jun 2012 07:18:12 +0000 (09:18 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 5 Jun 2012 07:21:08 +0000 (09:21 +0200)
They should take the filter caps into account and always return
the template caps appended to the actual caps. Otherwise the
parsers stop to accept unparsed streams where upstream does not
know about channels, rate, etc.

Fixes bug #677401.

gst/audioparsers/gstaacparse.c
gst/audioparsers/gstac3parse.c
gst/audioparsers/gstamrparse.c
gst/audioparsers/gstdcaparse.c
gst/audioparsers/gstflacparse.c
gst/audioparsers/gstmpegaudioparse.c
gst/audioparsers/gstwavpackparse.c

index b082076..f56b3e8 100644 (file)
@@ -1093,10 +1093,8 @@ gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
   GstCaps *peercaps, *templ;
   GstCaps *res;
 
-  /* FIXME: handle filter caps */
-
-  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)),
-      peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
+  peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
   if (peercaps) {
     guint i, n;
 
@@ -1111,10 +1109,24 @@ gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
 
     res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
-    gst_caps_unref (templ);
+
+    /* Append the template caps because we still want to accept
+     * caps without any fields in the case upstream does not
+     * know anything.
+     */
+    gst_caps_append (res, templ);
   } else {
     res = templ;
   }
 
+  if (filter) {
+    GstCaps *intersection;
+
+    intersection =
+        gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (res);
+    res = intersection;
+  }
+
   return res;
 }
index 26ee0d8..e6ac16b 100644 (file)
@@ -696,9 +696,9 @@ gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
   GstCaps *peercaps, *templ;
   GstCaps *res;
 
-  /* FIXME: handle filter */
-  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)),
-      peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
+  peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+
   if (peercaps) {
     guint i, n;
 
@@ -715,10 +715,24 @@ gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 
     res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
-    gst_caps_unref (templ);
+
+    /* Append the template caps because we still want to accept
+     * caps without any fields in the case upstream does not
+     * know anything.
+     */
+    gst_caps_append (res, templ);
   } else {
     res = templ;
   }
 
+  if (filter) {
+    GstCaps *intersection;
+
+    intersection =
+        gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (res);
+    res = intersection;
+  }
+
   return res;
 }
index 530f025..2bcb085 100644 (file)
@@ -368,11 +368,10 @@ gst_amr_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
   GstCaps *peercaps, *templ;
   GstCaps *res;
 
-  /* FIXME: handle filter caps */
 
   templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
-
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+
   if (peercaps) {
     guint i, n;
 
@@ -390,10 +389,23 @@ gst_amr_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
 
     res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
-    gst_caps_unref (templ);
+    /* Append the template caps because we still want to accept
+     * caps without any fields in the case upstream does not
+     * know anything.
+     */
+    gst_caps_append (res, templ);
   } else {
     res = templ;
   }
 
+  if (filter) {
+    GstCaps *intersection;
+
+    intersection =
+        gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (res);
+    res = intersection;
+  }
+
   return res;
 }
index 2b6aafb..3d44b65 100644 (file)
@@ -446,10 +446,9 @@ gst_dca_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
   GstCaps *peercaps, *templ;
   GstCaps *res;
 
-  /* FIXME: handle filter caps */
   templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
-
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+
   if (peercaps) {
     guint i, n;
 
@@ -464,10 +463,24 @@ gst_dca_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 
     res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
-    gst_caps_unref (templ);
+
+    /* Append the template caps because we still want to accept
+     * caps without any fields in the case upstream does not
+     * know anything.
+     */
+    gst_caps_append (res, templ);
   } else {
     res = templ;
   }
 
+  if (filter) {
+    GstCaps *intersection;
+
+    intersection =
+        gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (res);
+    res = intersection;
+  }
+
   return res;
 }
index 5ca2ca1..bc0beaa 100644 (file)
@@ -1550,10 +1550,9 @@ gst_flac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
   GstCaps *peercaps, *templ;
   GstCaps *res;
 
-  /* FIXME: handle filter caps */
   templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
-
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+
   if (peercaps) {
     guint i, n;
 
@@ -1568,10 +1567,24 @@ gst_flac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 
     res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
-    gst_caps_unref (templ);
+
+    /* Append the template caps because we still want to accept
+     * caps without any fields in the case upstream does not
+     * know anything.
+     */
+    gst_caps_append (res, templ);
   } else {
     res = templ;
   }
 
+  if (filter) {
+    GstCaps *intersection;
+
+    intersection =
+        gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (res);
+    res = intersection;
+  }
+
   return res;
 }
index b028be1..03be438 100644 (file)
@@ -1404,10 +1404,9 @@ gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
   GstCaps *peercaps, *templ;
   GstCaps *res;
 
-  /* FIXME: handle filter caps */
   templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
-
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+
   if (peercaps) {
     guint i, n;
 
@@ -1422,10 +1421,24 @@ gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 
     res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
-    gst_caps_unref (templ);
+
+    /* Append the template caps because we still want to accept
+     * caps without any fields in the case upstream does not
+     * know anything.
+     */
+    gst_caps_append (res, templ);
   } else {
     res = templ;
   }
 
+  if (filter) {
+    GstCaps *intersection;
+
+    intersection =
+        gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (res);
+    res = intersection;
+  }
+
   return res;
 }
index c3bcb68..e11f82a 100644 (file)
@@ -614,10 +614,9 @@ gst_wavpack_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
   GstCaps *peercaps, *templ;
   GstCaps *res;
 
-  /* FIXME: handle filter caps */
   templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
-
   peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
+
   if (peercaps) {
     guint i, n;
 
@@ -632,10 +631,24 @@ gst_wavpack_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
 
     res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref (peercaps);
-    gst_caps_unref (templ);
+
+    /* Append the template caps because we still want to accept
+     * caps without any fields in the case upstream does not
+     * know anything.
+     */
+    gst_caps_append (res, templ);
   } else {
     res = templ;
   }
 
+  if (filter) {
+    GstCaps *intersection;
+
+    intersection =
+        gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (res);
+    res = intersection;
+  }
+
   return res;
 }