webrtcsrc: make updated transceiver retrieval backward compatible

In 1.24 and before transceivers for remote sendonly medias are only
created at answer time. If that is the case, we can add the transceiver
ourself, it will get associated when creating the answer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1853>
This commit is contained in:
Mathieu Duponchelle 2024-10-16 14:05:13 +02:00 committed by GStreamer Marge Bot
parent 82d0eaf438
commit ef06421a25

View file

@ -844,10 +844,15 @@ impl Session {
obj = element,
"Getting transceiver for {stream_id} and index {i} with caps: {caps:#?}"
);
let transceiver = webrtcbin.emit_by_name::<gst_webrtc::WebRTCRTPTransceiver>(
let transceiver = webrtcbin.emit_by_name::<Option<gst_webrtc::WebRTCRTPTransceiver>>(
"get-transceiver",
&[&(i as i32)],
);
).unwrap_or_else(|| {
gst::warning!(CAT, "Transceiver for idx {i} does not exist, GStreamer <= 1.24, adding it ourself");
webrtcbin.emit_by_name::<gst_webrtc::WebRTCRTPTransceiver>(
"add-transceiver",
&[&gst_webrtc::WebRTCRTPTransceiverDirection::Recvonly, &caps])
});
transceiver.set_property("do_nack", do_retransmission);
transceiver.set_property("fec-type", gst_webrtc::WebRTCFECType::UlpRed);