From 3a5e05f2ab9fb14dfecbf9554c55c2fadbbadba9 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 23 Feb 2022 20:24:56 +0100 Subject: [PATCH] webrtcsink: emit consumer-added with webrtcbin in the Ready state In order for applications to potentially create data channels at the correct moment --- plugins/src/webrtcsink/imp.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/src/webrtcsink/imp.rs b/plugins/src/webrtcsink/imp.rs index 7b83fedd..1855b874 100644 --- a/plugins/src/webrtcsink/imp.rs +++ b/plugins/src/webrtcsink/imp.rs @@ -1728,6 +1728,15 @@ impl WebRTCSink { state.navigation_handler = Some(NavigationEventHandler::new(&element, &webrtcbin)); } + state.consumers.insert(peer_id.to_string(), consumer); + + drop(state); + + // This is intentionally emitted with the pipeline in the Ready state, + // so that application code can create data channels at the correct + // moment. + element.emit_by_name::<()>("consumer-added", &[&peer_id, &webrtcbin]); + pipeline.set_state(gst::State::Playing).map_err(|err| { WebRTCSinkError::ConsumerPipelineError { peer_id: peer_id.to_string(), @@ -1735,11 +1744,6 @@ impl WebRTCSink { } })?; - state.consumers.insert(peer_id.to_string(), consumer); - - drop(state); - element.emit_by_name::<()>("consumer-added", &[&peer_id, &webrtcbin]); - Ok(()) }