pub struct WebRtcHandle { /* private fields */ }webrtc only.Expand description
Cheaply-cloneable handle for requesting new tracks, completing
renegotiation, and picking up newly-attached tracks — same spirit as
crate::elements::AppSourceHandle. Cloning shares one queue of
pending WebRtcHandle::next_track results, same as any other
multi-consumer channel — only one clone’s call actually receives a
given track, so in practice only one place in the app should be
draining it.
Implementations§
Source§impl WebRtcHandle
impl WebRtcHandle
Sourcepub fn add_track(
&self,
kind: MediaKind,
direction: Direction,
codec: Codec,
) -> Result<TrackId>
pub fn add_track( &self, kind: MediaKind, direction: Direction, codec: Codec, ) -> Result<TrackId>
Requests a new track of kind/direction. Blocks only while the
peer’s bounded command queue is full; once the command is accepted,
returns the locally assigned TrackId. This does not mean SDP
negotiation has completed — receive the attached track through
WebRtcHandle::next_track. Returns WebRtcError::Closed without
yielding a TrackId if the peer loop has already stopped.
codec is what WebRtcTrackSink::consume on the resulting track
will actually be fed (an encoder’s output, or a packet relayed
verbatim from another track) — used to pick the matching payload
type out of whatever this connection negotiates for the track,
instead of guessing. If this connection never negotiates codec for
it, pushed buffers are silently dropped, same as an unopened track.
Sourcepub fn next_track(
&self,
) -> Result<(TrackId, Mid, MediaKind, WebRtcTrackSink, WebRtcTrackSource)>
pub fn next_track( &self, ) -> Result<(TrackId, Mid, MediaKind, WebRtcTrackSink, WebRtcTrackSource)>
Blocks until the next track attaches — either one requested via
WebRtcHandle::add_track (on either side) once its Mid exists,
or one the remote peer added on its own. Returns the TrackId (so
the caller can match it against what add_track returned — a Mid
alone doesn’t exist yet at add_track time, see TrackId’s own
docs) alongside the Mid/MediaKind str0m assigned it and the
WebRtcTrackSink/WebRtcTrackSource pair to send/receive on it.
Err once WebRtcPeer (and its run) is gone and every
already-attached track has been drained.
Sourcepub fn set_answer(&self, answer: SdpAnswer)
pub fn set_answer(&self, answer: SdpAnswer)
Feeds a remote answer back in, completing a renegotiation started by
WebRtcHandle::add_track. A no-op if WebRtcPeer (and its run)
is already gone.
Sourcepub fn accept_remote_offer(&self, offer: SdpOffer) -> Result<SdpAnswer>
pub fn accept_remote_offer(&self, offer: SdpOffer) -> Result<SdpAnswer>
Accepts a fresh offer from the remote peer (their own
renegotiation) and returns the resulting answer for the caller to
ship back over its own signaling transport. Blocks until
WebRtcPeer::run has actually applied it.
Trait Implementations§
Source§impl Clone for WebRtcHandle
impl Clone for WebRtcHandle
Source§fn clone(&self) -> WebRtcHandle
fn clone(&self) -> WebRtcHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more