webrtcsink: emit consumer-added with webrtcbin in the Ready state

In order for applications to potentially create data channels at
the correct moment
This commit is contained in:
Mathieu Duponchelle 2022-02-23 20:24:56 +01:00
parent 9e7406cec0
commit 3a5e05f2ab

View file

@ -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(())
}