From c2acb000b114213e4e3d8cad4597c65b80d9f859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 27 May 2020 12:21:14 +0300 Subject: [PATCH] gstreamer/promise: Convert None promise replies to an empty structure in the change_func webrtcbin likes to put a NULL structure into the reply under some circumstances when the promise successfully resolved. See https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1300 for details. --- gstreamer/src/promise.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gstreamer/src/promise.rs b/gstreamer/src/promise.rs index 45ddd6cfe..a942fa14d 100644 --- a/gstreamer/src/promise.rs +++ b/gstreamer/src/promise.rs @@ -52,15 +52,19 @@ impl Promise { promise: *mut gst_sys::GstPromise, user_data: glib_sys::gpointer, ) { + lazy_static! { + static ref EMPTY: Structure = Structure::new_empty("EMPTY"); + } + let user_data: &mut Option = &mut *(user_data as *mut _); let callback = user_data.take().unwrap(); let promise: Promise = from_glib_borrow(promise); let res = match promise.wait() { - PromiseResult::Replied => { - Ok(promise.get_reply().expect("Promise resolved but no reply")) - } + // Return an empty structure if it's None as workaround for + // https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1300 + PromiseResult::Replied => Ok(promise.get_reply().unwrap_or(&EMPTY)), PromiseResult::Interrupted => Err(PromiseError::Interrupted), PromiseResult::Expired => Err(PromiseError::Expired), PromiseResult::Pending => {