pub struct RTCPeerConnection { /* private fields */ }
Expand description

PeerConnection represents a WebRTC connection that establishes a peer-to-peer communications with another PeerConnection instance in a browser, or to another endpoint implementing the required protocols.

Implementations§

source§

impl RTCPeerConnection

source

pub fn on_signaling_state_change(&self, f: OnSignalingStateChangeHdlrFn)

on_signaling_state_change sets an event handler which is invoked when the peer connection’s signaling state changes

source

pub fn on_data_channel(&self, f: OnDataChannelHdlrFn)

on_data_channel sets an event handler which is invoked when a data channel message arrives from a remote peer.

source

pub fn on_negotiation_needed(&self, f: OnNegotiationNeededHdlrFn)

on_negotiation_needed sets an event handler which is invoked when a change has occurred which requires session negotiation

source

pub fn on_ice_candidate(&self, f: OnLocalCandidateHdlrFn)

on_ice_candidate sets an event handler which is invoked when a new ICE candidate is found. Take note that the handler is gonna be called with a nil pointer when gathering is finished.

source

pub fn on_ice_gathering_state_change(&self, f: OnICEGathererStateChangeHdlrFn)

on_ice_gathering_state_change sets an event handler which is invoked when the ICE candidate gathering state has changed.

source

pub fn on_track(&self, f: OnTrackHdlrFn)

on_track sets an event handler which is called when remote track arrives from a remote peer.

source

pub fn on_ice_connection_state_change( &self, f: OnICEConnectionStateChangeHdlrFn )

on_ice_connection_state_change sets an event handler which is called when an ICE connection state is changed.

source

pub fn on_peer_connection_state_change( &self, f: OnPeerConnectionStateChangeHdlrFn )

on_peer_connection_state_change sets an event handler which is called when the PeerConnectionState has changed

source

pub fn get_configuration(&self) -> &RTCConfiguration

get_configuration returns a Configuration object representing the current configuration of this PeerConnection object. The returned object is a copy and direct mutation on it will not take affect until set_configuration has been called with Configuration passed as its only argument. https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-getconfiguration

source

pub fn get_stats_id(&self) -> &str

source

pub async fn create_offer( &self, options: Option<RTCOfferOptions> ) -> Result<RTCSessionDescription>

create_offer starts the PeerConnection and generates the localDescription https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createoffer

source

pub async fn create_answer( &self, _options: Option<RTCAnswerOptions> ) -> Result<RTCSessionDescription>

create_answer starts the PeerConnection and generates the localDescription

source

pub async fn set_local_description( &self, desc: RTCSessionDescription ) -> Result<()>

set_local_description sets the SessionDescription of the local peer

source

pub async fn local_description(&self) -> Option<RTCSessionDescription>

local_description returns PendingLocalDescription if it is not null and otherwise it returns CurrentLocalDescription. This property is used to determine if set_local_description has already been called. https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-localdescription

source

pub fn is_lite_set(desc: &SessionDescription) -> bool

source

pub async fn set_remote_description( &self, desc: RTCSessionDescription ) -> Result<()>

set_remote_description sets the SessionDescription of the remote peer

source

pub async fn remote_description(&self) -> Option<RTCSessionDescription>

remote_description returns pending_remote_description if it is not null and otherwise it returns current_remote_description. This property is used to determine if setRemoteDescription has already been called. https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-remotedescription

source

pub async fn add_ice_candidate( &self, candidate: RTCIceCandidateInit ) -> Result<()>

add_ice_candidate accepts an ICE candidate string and adds it to the existing set of candidates.

source

pub fn ice_connection_state(&self) -> RTCIceConnectionState

ice_connection_state returns the ICE connection state of the PeerConnection instance.

source

pub async fn get_senders(&self) -> Vec<Arc<RTCRtpSender>>

get_senders returns the RTPSender that are currently attached to this PeerConnection

source

pub async fn get_receivers(&self) -> Vec<Arc<RTCRtpReceiver>>

get_receivers returns the RTPReceivers that are currently attached to this PeerConnection

source

pub async fn get_transceivers(&self) -> Vec<Arc<RTCRtpTransceiver>>

get_transceivers returns the RtpTransceiver that are currently attached to this PeerConnection

source

pub async fn add_track( &self, track: Arc<dyn TrackLocal + Send + Sync> ) -> Result<Arc<RTCRtpSender>>

add_track adds a Track to the PeerConnection

source

pub async fn remove_track(&self, sender: &Arc<RTCRtpSender>) -> Result<()>

remove_track removes a Track from the PeerConnection

source

pub async fn add_transceiver_from_kind( &self, kind: RTPCodecType, init: Option<RTCRtpTransceiverInit> ) -> Result<Arc<RTCRtpTransceiver>>

add_transceiver_from_kind Create a new RtpTransceiver and adds it to the set of transceivers.

source

pub async fn add_transceiver_from_track( &self, track: Arc<dyn TrackLocal + Send + Sync>, init: Option<RTCRtpTransceiverInit> ) -> Result<Arc<RTCRtpTransceiver>>

add_transceiver_from_track Create a new RtpTransceiver(SendRecv or SendOnly) and add it to the set of transceivers.

source

pub async fn create_data_channel( &self, label: &str, options: Option<RTCDataChannelInit> ) -> Result<Arc<RTCDataChannel>>

create_data_channel creates a new DataChannel object with the given label and optional DataChannelInit used to configure properties of the underlying channel such as data reliability.

source

pub fn set_identity_provider(&self, _provider: &str) -> Result<()>

set_identity_provider is used to configure an identity provider to generate identity assertions

source

pub async fn write_rtcp( &self, pkts: &[Box<dyn Packet + Send + Sync>] ) -> Result<usize>

write_rtcp sends a user provided RTCP packet to the connected peer. If no peer is connected the packet is discarded. It also runs any configured interceptors.

source

pub async fn close(&self) -> Result<()>

close ends the PeerConnection

source

pub async fn current_local_description(&self) -> Option<RTCSessionDescription>

CurrentLocalDescription represents the local description that was successfully negotiated the last time the PeerConnection transitioned into the stable state plus any local candidates that have been generated by the ICEAgent since the offer or answer was created.

source

pub async fn pending_local_description(&self) -> Option<RTCSessionDescription>

PendingLocalDescription represents a local description that is in the process of being negotiated plus any local candidates that have been generated by the ICEAgent since the offer or answer was created. If the PeerConnection is in the stable state, the value is null.

source

pub async fn current_remote_description(&self) -> Option<RTCSessionDescription>

current_remote_description represents the last remote description that was successfully negotiated the last time the PeerConnection transitioned into the stable state plus any remote candidates that have been supplied via add_icecandidate() since the offer or answer was created.

source

pub async fn pending_remote_description(&self) -> Option<RTCSessionDescription>

pending_remote_description represents a remote description that is in the process of being negotiated, complete with any remote candidates that have been supplied via add_icecandidate() since the offer or answer was created. If the PeerConnection is in the stable state, the value is null.

source

pub fn signaling_state(&self) -> RTCSignalingState

signaling_state attribute returns the signaling state of the PeerConnection instance.

source

pub fn ice_gathering_state(&self) -> RTCIceGatheringState

icegathering_state attribute returns the ICE gathering state of the PeerConnection instance.

source

pub fn connection_state(&self) -> RTCPeerConnectionState

connection_state attribute returns the connection state of the PeerConnection instance.

source

pub async fn get_stats(&self) -> StatsReport

source

pub fn sctp(&self) -> Arc<RTCSctpTransport>

sctp returns the SCTPTransport for this PeerConnection

The SCTP transport over which SCTP data is sent and received. If SCTP has not been negotiated, the value is nil. https://www.w3.org/TR/webrtc/#attributes-15

source

pub async fn gathering_complete_promise(&self) -> Receiver<()>

gathering_complete_promise is a Pion specific helper function that returns a channel that is closed when gathering is complete. This function may be helpful in cases where you are unable to trickle your ICE Candidates.

It is better to not use this function, and instead trickle candidates. If you use this function you will see longer connection startup times. When the call is connected you will see no impact however.

source

pub fn dtls_transport(&self) -> Arc<RTCDtlsTransport>

Returns the internal RTCDtlsTransport.

source

pub async fn add_transceiver(&self, t: Arc<RTCRtpTransceiver>)

Adds the specified RTCRtpTransceiver to this RTCPeerConnection.

Trait Implementations§

source§

impl Debug for RTCPeerConnection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for RTCPeerConnection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V