pub struct GStreamerWebRtcController {Show 15 fields
webrtc: Element,
pipeline: Pipeline,
delayed_negotiation: bool,
thread: WebRtcController,
signaller: Box<dyn WebRtcSignaller>,
streams: Vec<MediaStreamId>,
pending_streams: Vec<MediaStreamId>,
pt_counter: i32,
request_pad_counter: usize,
remote_mline_info: Vec<MLineInfo>,
pending_remote_mline_info: Vec<MLineInfo>,
remote_offer_generation: u32,
_main_loop: MainLoop,
data_channels: Arc<Mutex<HashMap<DataChannelId, DataChannelEventTarget>>>,
next_data_channel_id: Arc<AtomicUsize>,
}
Fields§
§webrtc: Element
§pipeline: Pipeline
§delayed_negotiation: bool
We can’t trigger a negotiation-needed event until we have streams, or otherwise a createOffer() call will lead to bad SDP. Instead, we delay negotiation.
thread: WebRtcController
A handle to the event loop abstraction surrounding the webrtc implementations, which lets gstreamer callbacks send events back to the event loop to run on this object
signaller: Box<dyn WebRtcSignaller>
§streams: Vec<MediaStreamId>
All the streams that are actually connected to the webrtcbin (i.e., their presence has already been negotiated)
pending_streams: Vec<MediaStreamId>
Disconnected streams that are waiting to be linked. Streams are only linked when:
- An offer is made (all pending streams are flushed)
- An offer is received (all matching pending streams are flushed)
- A stream is added when there is a so-far-disconnected remote-m-line
In other words, these are all yet to be negotiated
See link_stream
pt_counter: i32
Each new webrtc stream should have a new payload/pt value, starting at 96
This is maintained as a known yet-unused payload number, being incremented whenever we use it, and set to (remote_pt + 1) if the remote sends us a stream with a higher pt
request_pad_counter: usize
We keep track of how many request pads have been created on webrtcbin so that we can request more to fill in the gaps and acquire a specific pad if necessary
remote_mline_info: Vec<MLineInfo>
Streams need to be connected to the relevant sink pad, and we figure this out by keeping track of the caps of each m-line in the SDP.
pending_remote_mline_info: Vec<MLineInfo>
Temporary storage for remote_mline_info until the remote description is applied
Without this, a unluckily timed call to link_stream() may happen before the webrtcbin knows the remote description, but while we think it does
remote_offer_generation: u32
In case we get multiple remote offers, this lets us keep track of which is the newest
_main_loop: MainLoop
§data_channels: Arc<Mutex<HashMap<DataChannelId, DataChannelEventTarget>>>
§next_data_channel_id: Arc<AtomicUsize>
Implementations§
source§impl GStreamerWebRtcController
impl GStreamerWebRtcController
fn set_description( &mut self, desc: SessionDescription, description_type: DescriptionType, cb: Box<dyn FnOnce() + Send + 'static>, ) -> WebRtcResult
fn store_remote_mline_info(&mut self, sdp: &SDPMessage)
sourcefn link_stream(
&mut self,
stream_id: &MediaStreamId,
stream: &mut GStreamerMediaStream,
request_new_pads: bool,
) -> WebRtcResult
fn link_stream( &mut self, stream_id: &MediaStreamId, stream: &mut GStreamerMediaStream, request_new_pads: bool, ) -> WebRtcResult
Streams need to be linked to the correct pads, so we buffer them up until we know enough to do this.
When we get a remote offer, we store the relevant m-line information so that we can pick the correct sink pad and payload. Shortly after we look for any pending streams and connect them to available compatible m-lines using link_stream.
When we create an offer, we’re controlling the pad order, so we set request_new_pads to true and forcefully link all pending streams before generating the offer.
When request_new_pads is false, we may still request new pads, however we only do this for streams that have already been negotiated by the remote.
sourcefn flush_pending_streams(&mut self, request_new_pads: bool) -> WebRtcResult
fn flush_pending_streams(&mut self, request_new_pads: bool) -> WebRtcResult
link_stream, but for all pending streams
fn start_pipeline(&mut self) -> WebRtcResult
Trait Implementations§
source§impl WebRtcControllerBackend for GStreamerWebRtcController
impl WebRtcControllerBackend for GStreamerWebRtcController
fn add_ice_candidate(&mut self, candidate: IceCandidate) -> WebRtcResult
fn set_remote_description( &mut self, desc: SessionDescription, cb: Box<dyn FnOnce() + Send + 'static>, ) -> WebRtcResult
fn set_local_description( &mut self, desc: SessionDescription, cb: Box<dyn FnOnce() + Send + 'static>, ) -> WebRtcResult
fn create_offer( &mut self, cb: Box<dyn FnOnce(SessionDescription) + Send + 'static>, ) -> WebRtcResult
fn create_answer( &mut self, cb: Box<dyn FnOnce(SessionDescription) + Send + 'static>, ) -> WebRtcResult
fn add_stream(&mut self, stream_id: &MediaStreamId) -> WebRtcResult
fn create_data_channel( &mut self, init: &DataChannelInit, ) -> WebRtcDataChannelResult
fn close_data_channel(&mut self, id: &DataChannelId) -> WebRtcResult
fn send_data_channel_message( &mut self, id: &DataChannelId, message: &DataChannelMessage, ) -> WebRtcResult
fn configure(&mut self, stun_server: &str, policy: BundlePolicy) -> WebRtcResult
fn internal_event(&mut self, e: InternalEvent) -> WebRtcResult
fn quit(&mut self)
Auto Trait Implementations§
impl Freeze for GStreamerWebRtcController
impl !RefUnwindSafe for GStreamerWebRtcController
impl Send for GStreamerWebRtcController
impl !Sync for GStreamerWebRtcController
impl Unpin for GStreamerWebRtcController
impl !UnwindSafe for GStreamerWebRtcController
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more