diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2022-12-05 13:15:55 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2022-12-05 13:15:55 +0300 |
commit | 9b964db4c915bc91a7b2fb113bc8b68f8073bee4 (patch) | |
tree | b82d03fa6e15ecd301bb311cf1deda6568b0b071 | |
parent | 8452cd9efa92a73f237b7d02f6805eb48ffe4a3e (diff) |
whipsink: Handle offer creation errors more gracefully
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/949>
-rw-r--r-- | net/webrtchttp/src/whepsrc/imp.rs | 2 | ||||
-rw-r--r-- | net/webrtchttp/src/whipsink/imp.rs | 25 |
2 files changed, 21 insertions, 6 deletions
diff --git a/net/webrtchttp/src/whepsrc/imp.rs b/net/webrtchttp/src/whepsrc/imp.rs index 5b38ef1f..74e8ee75 100644 --- a/net/webrtchttp/src/whepsrc/imp.rs +++ b/net/webrtchttp/src/whepsrc/imp.rs @@ -845,7 +845,7 @@ impl WhepSrc { gst::element_imp_error!( self_, gst::LibraryError::Failed, - ["generate offer::Promise returned with no reply: {}", error] + ["generate offer::Promise returned with error: {}", error] ); } }); diff --git a/net/webrtchttp/src/whipsink/imp.rs b/net/webrtchttp/src/whipsink/imp.rs index 12ef0dee..9739e92c 100644 --- a/net/webrtchttp/src/whipsink/imp.rs +++ b/net/webrtchttp/src/whipsink/imp.rs @@ -427,11 +427,26 @@ impl ObjectImpl for WhipSink { let whipsink = ele.imp(); let offer_sdp = match reply { - Ok(Some(sdp)) => sdp - .value("offer") - .expect("structure must have an offer key") - .get::<gst_webrtc::WebRTCSessionDescription>() - .expect("offer must be an SDP"), + Ok(Some(reply)) => { + if let Ok(sdp) = reply.value("offer").map(|offer| { + offer.get::<gst_webrtc::WebRTCSessionDescription>().unwrap() + }) { + sdp + } else { + let error = reply + .value("error") + .expect("structure must have an error value") + .get::<glib::Error>() + .expect("value must be a GLib error"); + + gst::element_imp_error!( + whipsink, + gst::LibraryError::Failed, + ["generate offer::Promise returned with error: {}", error] + ); + return; + } + } Ok(None) => { gst::element_error!( ele, |