mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 06:26:23 +00:00
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
This commit is contained in:
parent
2f0993a95d
commit
f330c01412
1 changed files with 34 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue