{
GstAdder *adder;
GstCaps *result, *peercaps, *current_caps, *filter_caps;
+ GstStructure *s;
+ gint i, n;
adder = GST_ADDER (GST_PAD_PARENT (pad));
}
}
+ 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);
* 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;
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;
}
}
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;
}