pub struct RtcPeerConnection { /* private fields */ }Expand description
Representation of RTCPeerConnection.
Implementations§
Source§impl RtcPeerConnection
impl RtcPeerConnection
Sourcepub async fn new<I>(
ice_servers: I,
is_force_relayed: bool,
) -> Result<Self, Traced<RtcPeerConnectionError>>where
I: IntoIterator<Item = IceServer>,
pub async fn new<I>(
ice_servers: I,
is_force_relayed: bool,
) -> Result<Self, Traced<RtcPeerConnectionError>>where
I: IntoIterator<Item = IceServer>,
Instantiates a new RtcPeerConnection.
§Errors
Errors with RtcPeerConnectionError::PeerCreationError if
RtcPeerConnection creation fails.
Sourcepub async fn get_stats(
&self,
) -> Result<RtcStats, Traced<RtcPeerConnectionError>>
pub async fn get_stats( &self, ) -> Result<RtcStats, Traced<RtcPeerConnectionError>>
Returns RtcStats of this RtcPeerConnection.
Sourcepub fn on_track<F>(&self, handler: Option<F>)
pub fn on_track<F>(&self, handler: Option<F>)
Sets handler for a RTCTrackEvent (see ontrack callback).
Sourcepub fn on_ice_candidate<F>(&self, handler: Option<F>)where
F: 'static + FnMut(IceCandidate),
pub fn on_ice_candidate<F>(&self, handler: Option<F>)where
F: 'static + FnMut(IceCandidate),
Sets handler for a RTCPeerConnectionIceEvent (see
onicecandidate callback).
Sourcepub fn on_ice_candidate_error<F>(&self, handler: Option<F>)where
F: 'static + FnMut(IceCandidateError),
pub fn on_ice_candidate_error<F>(&self, handler: Option<F>)where
F: 'static + FnMut(IceCandidateError),
Sets handler for an RTCPeerConnectionIceEvent (see the
onicecandidateerror callback).
Sourcepub fn ice_connection_state(&self) -> IceConnectionState
pub fn ice_connection_state(&self) -> IceConnectionState
Returns IceConnectionState of this RtcPeerConnection.
Sourcepub fn connection_state(&self) -> PeerConnectionState
pub fn connection_state(&self) -> PeerConnectionState
Returns PeerConnectionState of this RtcPeerConnection.
Sourcepub fn on_ice_connection_state_change<F>(&self, handler: Option<F>)where
F: 'static + FnMut(IceConnectionState),
pub fn on_ice_connection_state_change<F>(&self, handler: Option<F>)where
F: 'static + FnMut(IceConnectionState),
Sets handler for an iceconnectionstatechange event.
Sourcepub fn on_connection_state_change<F>(&self, handler: Option<F>)where
F: 'static + FnMut(PeerConnectionState),
pub fn on_connection_state_change<F>(&self, handler: Option<F>)where
F: 'static + FnMut(PeerConnectionState),
Sets handler for a connectionstatechange event.
Sourcepub async fn add_ice_candidate(
&self,
candidate: &str,
sdp_m_line_index: Option<u16>,
sdp_mid: &Option<String>,
) -> Result<(), Traced<RtcPeerConnectionError>>
pub async fn add_ice_candidate( &self, candidate: &str, sdp_m_line_index: Option<u16>, sdp_mid: &Option<String>, ) -> Result<(), Traced<RtcPeerConnectionError>>
Adds remote RTCPeerConnection’s ICE candidate to this
RtcPeerConnection.
§Errors
With RtcPeerConnectionError::AddIceCandidateFailed if
RtcPeerConnection.addIceCandidate() fails.
Sourcepub fn restart_ice(&self)
pub fn restart_ice(&self)
Marks RtcPeerConnection to trigger ICE restart.
After this function returns, the offer returned by the next call to
RtcPeerConnection::create_offer is automatically configured
to trigger ICE restart.
Sourcepub async fn set_offer(
&self,
offer: &str,
) -> Result<(), Traced<RtcPeerConnectionError>>
pub async fn set_offer( &self, offer: &str, ) -> Result<(), Traced<RtcPeerConnectionError>>
Sets provided SDP offer as local description.
§Errors
With RtcPeerConnectionError::SetLocalDescriptionFailed if
RtcPeerConnection.setLocalDescription() fails.
Sourcepub async fn set_answer(
&self,
answer: &str,
) -> Result<(), Traced<RtcPeerConnectionError>>
pub async fn set_answer( &self, answer: &str, ) -> Result<(), Traced<RtcPeerConnectionError>>
Sets the provided SDP answer as local description.
§Errors
With RtcPeerConnectionError::SetLocalDescriptionFailed if
RtcPeerConnection.setLocalDescription() fails.
Sourcepub async fn create_answer(
&self,
) -> Result<String, Traced<RtcPeerConnectionError>>
pub async fn create_answer( &self, ) -> Result<String, Traced<RtcPeerConnectionError>>
Obtains SDP answer from the RtcPeerConnection.
Should be called whenever remote description has been changed.
§Errors
With RtcPeerConnectionError::CreateAnswerFailed if
RtcPeerConnection.createAnswer() fails.
Sourcepub async fn rollback(&self) -> Result<(), Traced<RtcPeerConnectionError>>
pub async fn rollback(&self) -> Result<(), Traced<RtcPeerConnectionError>>
Rollbacks the RtcPeerConnection to the previous stable state.
§Errors
With RtcPeerConnectionError::SetLocalDescriptionFailed if
RtcPeerConnection.setLocalDescription() fails.
Sourcepub async fn create_offer(
&self,
) -> Result<String, Traced<RtcPeerConnectionError>>
pub async fn create_offer( &self, ) -> Result<String, Traced<RtcPeerConnectionError>>
Obtains SDP offer from the RtcPeerConnection.
Should be called after local tracks changes, which require (re)negotiation.
§Errors
With RtcPeerConnectionError::CreateOfferFailed if
RtcPeerConnection.createOffer() fails.
Sourcepub async fn set_remote_description(
&self,
sdp: SdpType,
) -> Result<(), Traced<RtcPeerConnectionError>>
pub async fn set_remote_description( &self, sdp: SdpType, ) -> Result<(), Traced<RtcPeerConnectionError>>
Instructs the RtcPeerConnection to apply the supplied
SDP as the remote offer or
answer.
Changes the local media state.
§Errors
With RtcPeerConnectionError::SetRemoteDescriptionFailed if
RTCPeerConnection.setRemoteDescription() fails.
Sourcepub async fn add_transceiver(
&self,
kind: MediaKind,
init: TransceiverInit,
) -> Transceiver
pub async fn add_transceiver( &self, kind: MediaKind, init: TransceiverInit, ) -> Transceiver
Creates a new Transceiver (see RTCRtpTransceiver) and adds it
to the set of this RTCPeerConnection’s transceivers.
Sourcepub fn get_transceiver_by_mid(
&self,
mid: String,
) -> impl Future<Output = Option<Transceiver>> + 'static + use<>
pub fn get_transceiver_by_mid( &self, mid: String, ) -> impl Future<Output = Option<Transceiver>> + 'static + use<>
Returns Transceiver (see RTCRtpTransceiver) from a
set of this RTCPeerConnection’s transceivers by provided mid.
Trait Implementations§
Source§impl Clone for RtcPeerConnection
impl Clone for RtcPeerConnection
Source§fn clone(&self) -> RtcPeerConnection
fn clone(&self) -> RtcPeerConnection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more