rtpmux: Keep caps order from the peer or the filter

This commit is contained in:
Olivier Crête 2013-07-09 17:42:59 -04:00
parent 3d0988f46f
commit 1997acc8b2

View file

@ -638,34 +638,30 @@ gst_rtp_mux_getcaps (GstPad * pad, GstRTPMux * mux, GstCaps * filter)
GValue v = { 0 }; GValue v = { 0 };
GstIteratorResult res; GstIteratorResult res;
GstCaps *peercaps; GstCaps *peercaps;
GstCaps *othercaps = NULL; GstCaps *othercaps;
GstCaps *filtered_caps;
peercaps = gst_pad_peer_query_caps (mux->srcpad, filter); peercaps = gst_pad_peer_query_caps (mux->srcpad, filter);
if (peercaps) { if (peercaps) {
othercaps = gst_caps_intersect (peercaps, othercaps = gst_caps_intersect_full (peercaps,
gst_pad_get_pad_template_caps (pad)); gst_pad_get_pad_template_caps (pad), GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (peercaps); gst_caps_unref (peercaps);
} else { } else {
othercaps = gst_caps_copy (gst_pad_get_pad_template_caps (mux->srcpad)); if (filter)
othercaps = gst_caps_intersect_full (filter,
gst_pad_get_pad_template_caps (mux->srcpad),
GST_CAPS_INTERSECT_FIRST);
else
othercaps = gst_caps_copy (gst_pad_get_pad_template_caps (mux->srcpad));
} }
if (filter) { clear_caps (othercaps, FALSE);
filtered_caps = gst_caps_intersect (othercaps, filter);
gst_caps_unref (othercaps);
} else {
filtered_caps = othercaps;
}
filtered_caps = gst_caps_make_writable (filtered_caps);
clear_caps (filtered_caps, FALSE);
g_value_init (&v, GST_TYPE_CAPS); g_value_init (&v, GST_TYPE_CAPS);
iter = gst_element_iterate_sink_pads (GST_ELEMENT (mux)); iter = gst_element_iterate_sink_pads (GST_ELEMENT (mux));
do { do {
gst_value_set_caps (&v, filtered_caps); gst_value_set_caps (&v, othercaps);
res = gst_iterator_fold (iter, same_clock_rate_fold, &v, pad); res = gst_iterator_fold (iter, same_clock_rate_fold, &v, pad);
gst_iterator_resync (iter); gst_iterator_resync (iter);
} while (res == GST_ITERATOR_RESYNC); } while (res == GST_ITERATOR_RESYNC);
@ -678,7 +674,7 @@ gst_rtp_mux_getcaps (GstPad * pad, GstRTPMux * mux, GstCaps * filter)
caps = gst_caps_new_empty (); caps = gst_caps_new_empty ();
} }
gst_caps_unref (filtered_caps); gst_caps_unref (othercaps);
return caps; return caps;
} }