summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieuDuponchelle <mathieu.duponchelle@epitech.eu>2013-09-15 21:48:43 +0200
committerSebastian Dröge <slomo@circular-chaos.org>2013-09-28 13:32:58 +0200
commitf330c014121590a5fad01fd06aef1273812b3315 (patch)
tree7b7d206817477f887c077b98329a387ccfddc834
parent2f0993a95d84a00b2e97f49ce180bd1996c45cb6 (diff)
adder: Don't take channel mask in consideration in mono or stereo
This could cause negotiation to fail. https://bugzilla.gnome.org/show_bug.cgi?id=708633
-rw-r--r--gst/adder/gstadder.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c
index e0e7b7694..955717538 100644
--- a/gst/adder/gstadder.c
+++ b/gst/adder/gstadder.c
@@ -223,6 +223,8 @@ gst_adder_sink_getcaps (GstPad * pad, GstCaps * filter)
{
GstAdder *adder;
GstCaps *result, *peercaps, *current_caps, *filter_caps;
+ GstStructure *s;
+ gint i, n;
adder = GST_ADDER (GST_PAD_PARENT (pad));
@@ -283,6 +285,22 @@ gst_adder_sink_getcaps (GstPad * pad, GstCaps * filter)
}
}
+ result = gst_caps_make_writable (result);
+
+ n = gst_caps_get_size (result);
+ for (i = 0; i < n; i++) {
+ GstStructure *sref;
+
+ s = gst_caps_get_structure (result, i);
+ sref = gst_structure_copy (s);
+ gst_structure_set (sref, "channels", GST_TYPE_INT_RANGE, 0, 2, NULL);
+ if (gst_structure_is_subset (s, sref)) {
+ /* This field is irrelevant when in mono or stereo */
+ gst_structure_remove_field (s, "channel-mask");
+ }
+ gst_structure_free (sref);
+ }
+
if (filter_caps)
gst_caps_unref (filter_caps);
@@ -322,9 +340,19 @@ gst_adder_sink_query (GstCollectPads * pads, GstCollectData * pad,
* the other sinkpads because we can only mix streams with the same caps.
*/
static gboolean
-gst_adder_setcaps (GstAdder * adder, GstPad * pad, GstCaps * caps)
+gst_adder_setcaps (GstAdder * adder, GstPad * pad, GstCaps * orig_caps)
{
+ GstCaps *caps;
GstAudioInfo info;
+ GstStructure *s;
+ gint channels;
+
+ caps = gst_caps_copy (orig_caps);
+
+ s = gst_caps_get_structure (caps, 0);
+ if (gst_structure_get_int (s, "channels", &channels))
+ if (channels <= 2)
+ gst_structure_remove_field (s, "channel-mask");
if (!gst_audio_info_from_caps (&info, caps))
goto invalid_format;
@@ -337,12 +365,14 @@ gst_adder_setcaps (GstAdder * adder, GstPad * pad, GstCaps * caps)
if (adder->current_caps != NULL) {
if (gst_audio_info_is_equal (&info, &adder->info)) {
GST_OBJECT_UNLOCK (adder);
+ gst_caps_unref (caps);
return TRUE;
} else {
GST_DEBUG_OBJECT (pad, "got input caps %" GST_PTR_FORMAT ", but "
"current caps are %" GST_PTR_FORMAT, caps, adder->current_caps);
GST_OBJECT_UNLOCK (adder);
gst_pad_push_event (pad, gst_event_new_reconfigure ());
+ gst_caps_unref (caps);
return FALSE;
}
}
@@ -356,11 +386,14 @@ gst_adder_setcaps (GstAdder * adder, GstPad * pad, GstCaps * caps)
GST_INFO_OBJECT (pad, "handle caps change to %" GST_PTR_FORMAT, caps);
+ gst_caps_unref (caps);
+
return TRUE;
/* ERRORS */
invalid_format:
{
+ gst_caps_unref (caps);
GST_WARNING_OBJECT (adder, "invalid format set as caps");
return FALSE;
}