diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-02-27 12:52:07 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-02-27 12:52:07 +0100 |
commit | ef980bc09b4ddb705dee74df8266359dd2f37fe0 (patch) | |
tree | f1e89f49fe9731d6788f1bbdb01478bec487d0d6 /gst/audioconvert | |
parent | 55076379b2983ddb2dff3058c161d4dd0fb479df (diff) | |
download | gstreamer-plugins-base-ef980bc09b4ddb705dee74df8266359dd2f37fe0.tar.gz |
audioconvert: improve fixation
Diffstat (limited to 'gst/audioconvert')
-rw-r--r-- | gst/audioconvert/gstaudioconvert.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c index 044b5b9ae..8d93013f8 100644 --- a/gst/audioconvert/gstaudioconvert.c +++ b/gst/audioconvert/gstaudioconvert.c @@ -590,34 +590,30 @@ gst_audio_convert_fixate_caps (GstBaseTransform * base, GstPadDirection direction, GstCaps * caps, GstCaps * othercaps) { GstStructure *ins, *outs; - gint rate; - const gchar *fmt; - - othercaps = gst_caps_make_writable (othercaps); + GstCaps *result; GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT " based on caps %" GST_PTR_FORMAT, othercaps, caps); - ins = gst_caps_get_structure (caps, 0); - outs = gst_caps_get_structure (othercaps, 0); + result = gst_caps_intersect (othercaps, caps); + if (gst_caps_is_empty (result)) { + result = othercaps; + } else { + gst_caps_unref (othercaps); + } - gst_audio_convert_fixate_channels (base, ins, outs); + /* fixate remaining fields */ + result = gst_caps_make_writable (result); - if ((fmt = gst_structure_get_string (ins, "format"))) { - /* FIXME, find the best format */ - gst_structure_fixate_field_string (outs, "format", fmt); - } + ins = gst_caps_get_structure (caps, 0); + outs = gst_caps_get_structure (result, 0); - if (gst_structure_get_int (ins, "rate", &rate)) { - if (gst_structure_has_field (outs, "rate")) { - gst_structure_fixate_field_nearest_int (outs, "rate", rate); - } - } + gst_audio_convert_fixate_channels (base, ins, outs); + gst_caps_fixate (result); - gst_caps_truncate (othercaps); - GST_DEBUG_OBJECT (base, "fixated othercaps to %" GST_PTR_FORMAT, othercaps); + GST_DEBUG_OBJECT (base, "fixated othercaps to %" GST_PTR_FORMAT, result); - return othercaps; + return result; } static gboolean |