update for new fixate_caps function
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 22 Feb 2012 11:27:49 +0000 (12:27 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 22 Feb 2012 11:32:44 +0000 (12:32 +0100)
gst/audioconvert/gstaudioconvert.c
gst/audioresample/gstaudioresample.c
gst/videoconvert/gstvideoconvert.c
gst/videorate/gstvideorate.c
gst/videoscale/gstvideoscale.c

index 76b868c..044b5b9 100644 (file)
@@ -79,7 +79,7 @@ static gboolean gst_audio_convert_get_unit_size (GstBaseTransform * base,
     GstCaps * caps, gsize * size);
 static GstCaps *gst_audio_convert_transform_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps, GstCaps * filter);
-static void gst_audio_convert_fixate_caps (GstBaseTransform * base,
+static GstCaps *gst_audio_convert_fixate_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
 static gboolean gst_audio_convert_set_caps (GstBaseTransform * base,
     GstCaps * incaps, GstCaps * outcaps);
@@ -585,7 +585,7 @@ gst_audio_convert_fixate_channels (GstBaseTransform * base, GstStructure * ins,
 /* try to keep as many of the structure members the same by fixating the
  * possible ranges; this way we convert the least amount of things as possible
  */
-static void
+static GstCaps *
 gst_audio_convert_fixate_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
 {
@@ -593,7 +593,7 @@ gst_audio_convert_fixate_caps (GstBaseTransform * base,
   gint rate;
   const gchar *fmt;
 
-  g_return_if_fail (gst_caps_is_fixed (caps));
+  othercaps = gst_caps_make_writable (othercaps);
 
   GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT
       " based on caps %" GST_PTR_FORMAT, othercaps, caps);
@@ -616,6 +616,8 @@ gst_audio_convert_fixate_caps (GstBaseTransform * base,
 
   gst_caps_truncate (othercaps);
   GST_DEBUG_OBJECT (base, "fixated othercaps to %" GST_PTR_FORMAT, othercaps);
+
+  return othercaps;
 }
 
 static gboolean
index dc653f4..ebd5895 100644 (file)
@@ -106,7 +106,7 @@ static gboolean gst_audio_resample_get_unit_size (GstBaseTransform * base,
     GstCaps * caps, gsize * size);
 static GstCaps *gst_audio_resample_transform_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps, GstCaps * filter);
-static void gst_audio_resample_fixate_caps (GstBaseTransform * base,
+static GstCaps *gst_audio_resample_fixate_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
 static gboolean gst_audio_resample_transform_size (GstBaseTransform * trans,
     GstPadDirection direction, GstCaps * incaps, gsize insize,
@@ -307,7 +307,7 @@ gst_audio_resample_transform_caps (GstBaseTransform * base,
 }
 
 /* Fixate rate to the allowed rate that has the smallest difference */
-static void
+static GstCaps *
 gst_audio_resample_fixate_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
 {
@@ -316,11 +316,13 @@ gst_audio_resample_fixate_caps (GstBaseTransform * base,
 
   s = gst_caps_get_structure (caps, 0);
   if (G_UNLIKELY (!gst_structure_get_int (s, "rate", &rate)))
-    return;
+    return othercaps;
 
+  othercaps = gst_caps_make_writable (othercaps);
   gst_caps_truncate (othercaps);
   s = gst_caps_get_structure (othercaps, 0);
   gst_structure_fixate_field_nearest_int (s, "rate", rate);
+  return othercaps;
 }
 
 static const SpeexResampleFuncs *
index 5b0033a..5c4ca4b 100644 (file)
@@ -132,13 +132,15 @@ gst_video_convert_caps_remove_format_info (GstCaps * caps)
   return res;
 }
 
-static void
+static GstCaps *
 gst_video_convert_fixate_caps (GstBaseTransform * trans,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
 {
   GstStructure *ss, *ds;
   const gchar *val;
 
+  othercaps = gst_caps_make_writable (othercaps);
+
   GST_DEBUG_OBJECT (trans, "fixating caps %" GST_PTR_FORMAT, othercaps);
 
   ss = gst_caps_get_structure (caps, 0);
@@ -161,6 +163,8 @@ gst_video_convert_fixate_caps (GstBaseTransform * trans,
 
   /* fixate remaining fields */
   gst_caps_fixate (othercaps);
+
+  return othercaps;
 }
 
 /* The caps can be transformed into any other caps with format info removed.
index 1e07387..483397f 100644 (file)
@@ -132,7 +132,7 @@ static gboolean gst_video_rate_setcaps (GstBaseTransform * trans,
 static GstCaps *gst_video_rate_transform_caps (GstBaseTransform * trans,
     GstPadDirection direction, GstCaps * caps, GstCaps * filter);
 
-static void gst_video_rate_fixate_caps (GstBaseTransform * trans,
+static GstCaps *gst_video_rate_fixate_caps (GstBaseTransform * trans,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
 
 static GstFlowReturn gst_video_rate_transform_ip (GstBaseTransform * trans,
@@ -454,7 +454,7 @@ gst_video_rate_transform_caps (GstBaseTransform * trans,
   return ret;
 }
 
-static void
+static GstCaps *
 gst_video_rate_fixate_caps (GstBaseTransform * trans,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
 {
@@ -463,11 +463,14 @@ gst_video_rate_fixate_caps (GstBaseTransform * trans,
 
   s = gst_caps_get_structure (caps, 0);
   if (G_UNLIKELY (!gst_structure_get_fraction (s, "framerate", &num, &denom)))
-    return;
+    return othercaps;
 
+  othercaps = gst_caps_make_writable (othercaps);
   gst_caps_truncate (othercaps);
   s = gst_caps_get_structure (othercaps, 0);
   gst_structure_fixate_field_nearest_fraction (s, "framerate", num, denom);
+
+  return othercaps;
 }
 
 static gboolean
index 86721b0..1882d8c 100644 (file)
@@ -187,7 +187,7 @@ static gboolean gst_video_scale_src_event (GstBaseTransform * trans,
 /* base transform vmethods */
 static GstCaps *gst_video_scale_transform_caps (GstBaseTransform * trans,
     GstPadDirection direction, GstCaps * caps, GstCaps * filter);
-static void gst_video_scale_fixate_caps (GstBaseTransform * base,
+static GstCaps *gst_video_scale_fixate_caps (GstBaseTransform * base,
     GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
 
 static gboolean gst_video_scale_set_info (GstVideoFilter * filter,
@@ -511,7 +511,7 @@ gst_video_scale_set_info (GstVideoFilter * filter, GstCaps * in,
   return TRUE;
 }
 
-static void
+static GstCaps *
 gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
     GstCaps * caps, GstCaps * othercaps)
 {
@@ -520,8 +520,7 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
   GValue fpar = { 0, }, tpar = {
   0,};
 
-  g_return_if_fail (gst_caps_is_fixed (caps));
-
+  othercaps = gst_caps_make_writable (othercaps);
   gst_caps_truncate (othercaps);
 
   GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT
@@ -572,7 +571,7 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
     gint num, den;
 
     /* from_par should be fixed */
-    g_return_if_fail (gst_value_is_fixed (from_par));
+    g_return_val_if_fail (gst_value_is_fixed (from_par), othercaps);
 
     from_par_n = gst_value_get_fraction_numerator (from_par);
     from_par_d = gst_value_get_fraction_denominator (from_par);
@@ -945,6 +944,8 @@ done:
     g_value_unset (&fpar);
   if (to_par == &tpar)
     g_value_unset (&tpar);
+
+  return othercaps;
 }
 
 static void