When creating an offer or an answer, also take into account
the caps on the pads as well as the codec preferences when both are set.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2183>
{
WebRTCTransceiver *trans = (WebRTCTransceiver *) rtp_trans;
GstCaps *ret = NULL;
{
WebRTCTransceiver *trans = (WebRTCTransceiver *) rtp_trans;
GstCaps *ret = NULL;
+ GstCaps *codec_preferences = NULL;
GstWebRTCBinPad *pad = NULL;
GST_LOG_OBJECT (webrtc, "retrieving codec preferences from %" GST_PTR_FORMAT,
trans);
GstWebRTCBinPad *pad = NULL;
GST_LOG_OBJECT (webrtc, "retrieving codec preferences from %" GST_PTR_FORMAT,
trans);
if (rtp_trans->codec_preferences) {
GST_LOG_OBJECT (webrtc, "Using codec preferences: %" GST_PTR_FORMAT,
rtp_trans->codec_preferences);
if (rtp_trans->codec_preferences) {
GST_LOG_OBJECT (webrtc, "Using codec preferences: %" GST_PTR_FORMAT,
rtp_trans->codec_preferences);
- ret = gst_caps_ref (rtp_trans->codec_preferences);
+ codec_preferences = gst_caps_ref (rtp_trans->codec_preferences);
}
GST_OBJECT_UNLOCK (rtp_trans);
}
GST_OBJECT_UNLOCK (rtp_trans);
+ pad = _find_pad_for_transceiver (webrtc, direction, rtp_trans);
}
/* try to find a pad */
}
/* try to find a pad */
- if (!trans
- || !(pad = _find_pad_for_transceiver (webrtc, direction, rtp_trans)))
pad = _find_pad_for_mline (webrtc, direction, media_idx);
pad = _find_pad_for_mline (webrtc, direction, media_idx);
- if (!pad) {
- if (trans && trans->last_configured_caps)
- ret = gst_caps_ref (trans->last_configured_caps);
- } else {
GstCaps *caps = NULL;
if (pad->received_caps) {
GstCaps *caps = NULL;
if (pad->received_caps) {
}
gst_caps_unref (filter);
}
}
gst_caps_unref (filter);
}
+
+ if (caps && codec_preferences) {
+ GstCaps *intersection;
+
+ intersection = gst_caps_intersect_full (codec_preferences, caps,
+ GST_CAPS_INTERSECT_FIRST);
+ gst_caps_unref (caps);
+
+ if (gst_caps_is_empty (intersection)) {
+ caps = NULL;
+ gst_caps_unref (intersection);
+ } else {
+ caps = intersection;
+ }
+ }
+
if (caps) {
if (trans)
gst_caps_replace (&trans->last_configured_caps, caps);
if (caps) {
if (trans)
gst_caps_replace (&trans->last_configured_caps, caps);
}
gst_object_unref (pad);
}
gst_object_unref (pad);
+ } else {
+ if (codec_preferences)
+ ret = gst_caps_ref (codec_preferences);
+ else if (trans && trans->last_configured_caps)
+ ret = gst_caps_ref (trans->last_configured_caps);
+ if (codec_preferences)
+ gst_caps_unref (codec_preferences);
+
if (!ret)
GST_DEBUG_OBJECT (trans, "Could not find caps for mline %u", media_idx);
if (!ret)
GST_DEBUG_OBJECT (trans, "Could not find caps for mline %u", media_idx);