From 824ae39848e7ce68e49c305805727b12e93d26c6 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 24 Nov 2023 19:53:38 +0100 Subject: [PATCH] webrtcsink: don't panic on failure to request pad from webrtcbin webrtcbin will refuse pad requests for all sorts of reasons, and should be logging an error when doing so, simply post an error message and let the application deal with it, the reason for the refusal should hopefully be available in the logs to the user. Part-of: --- net/webrtc/src/webrtcsink/imp.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/net/webrtc/src/webrtcsink/imp.rs b/net/webrtc/src/webrtcsink/imp.rs index e8846cf7..8d88b413 100644 --- a/net/webrtc/src/webrtcsink/imp.rs +++ b/net/webrtc/src/webrtcsink/imp.rs @@ -1479,9 +1479,15 @@ impl BaseWebRTCSink { let ssrc = BaseWebRTCSink::generate_ssrc(element, webrtc_pads); let media_idx = webrtc_pads.len() as i32; - let pad = webrtcbin - .request_pad_simple(&format!("sink_{}", media_idx)) - .unwrap(); + let Some(pad) = webrtcbin.request_pad_simple(&format!("sink_{}", media_idx)) else { + gst::error!(CAT, obj: element, "Failed to request pad from webrtcbin"); + gst::element_error!( + element, + gst::StreamError::Failed, + ["Failed to request pad from webrtcbin"] + ); + return; + }; let transceiver = pad.property::("transceiver"); @@ -1574,9 +1580,15 @@ impl BaseWebRTCSink { payloader_caps ); - let pad = webrtcbin - .request_pad_simple(&format!("sink_{}", media_idx)) - .unwrap(); + let Some(pad) = webrtcbin.request_pad_simple(&format!("sink_{}", media_idx)) else { + gst::error!(CAT, obj: element, "Failed to request pad from webrtcbin"); + gst::element_error!( + element, + gst::StreamError::Failed, + ["Failed to request pad from webrtcbin"] + ); + return; + }; let transceiver = pad.property::("transceiver");