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
impl RTCPeerConnection
Sourcepub fn on_signaling_state_change(&self, f: OnSignalingStateChangeHdlrFn)
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
Sourcepub fn on_data_channel(&self, f: OnDataChannelHdlrFn)
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.
Sourcepub fn on_negotiation_needed(&self, f: OnNegotiationNeededHdlrFn)
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
Sourcepub fn on_ice_candidate(&self, f: OnLocalCandidateHdlrFn)
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.
Sourcepub fn on_ice_gathering_state_change(&self, f: OnICEGathererStateChangeHdlrFn)
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.
Sourcepub fn on_track(&self, f: OnTrackHdlrFn)
pub fn on_track(&self, f: OnTrackHdlrFn)
on_track sets an event handler which is called when remote track arrives from a remote peer.
Sourcepub fn on_ice_connection_state_change(
&self,
f: OnICEConnectionStateChangeHdlrFn,
)
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.
Sourcepub fn on_peer_connection_state_change(
&self,
f: OnPeerConnectionStateChangeHdlrFn,
)
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
Sourcepub async fn restart_ice(&self) -> Result<()>
pub async fn restart_ice(&self) -> Result<()>
restart_ice restart ICE and triggers negotiation needed https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-restartice
pub async fn set_configuration( &self, configuration: RTCConfiguration, ) -> Result<()>
Sourcepub async fn get_configuration(&self) -> RTCConfiguration
pub async 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
pub fn get_stats_id(&self) -> &str
Sourcepub async fn create_offer(
&self,
options: Option<RTCOfferOptions>,
) -> Result<RTCSessionDescription>
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
Sourcepub async fn create_answer(
&self,
_options: Option<RTCAnswerOptions>,
) -> Result<RTCSessionDescription>
pub async fn create_answer( &self, _options: Option<RTCAnswerOptions>, ) -> Result<RTCSessionDescription>
create_answer starts the PeerConnection and generates the localDescription
Sourcepub async fn set_local_description(
&self,
desc: RTCSessionDescription,
) -> Result<()>
pub async fn set_local_description( &self, desc: RTCSessionDescription, ) -> Result<()>
set_local_description sets the SessionDescription of the local peer
Sourcepub async fn local_description(&self) -> Option<RTCSessionDescription>
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
pub fn is_lite_set(desc: &SessionDescription) -> bool
Sourcepub async fn set_remote_description(
&self,
desc: RTCSessionDescription,
) -> Result<()>
pub async fn set_remote_description( &self, desc: RTCSessionDescription, ) -> Result<()>
set_remote_description sets the SessionDescription of the remote peer
Sourcepub async fn remote_description(&self) -> Option<RTCSessionDescription>
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
Sourcepub async fn add_ice_candidate(
&self,
candidate: RTCIceCandidateInit,
) -> Result<()>
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.
Sourcepub fn ice_connection_state(&self) -> RTCIceConnectionState
pub fn ice_connection_state(&self) -> RTCIceConnectionState
ice_connection_state returns the ICE connection state of the PeerConnection instance.
Sourcepub async fn get_senders(&self) -> Vec<Arc<RTCRtpSender>>
pub async fn get_senders(&self) -> Vec<Arc<RTCRtpSender>>
get_senders returns the RTPSender that are currently attached to this PeerConnection
Sourcepub async fn get_receivers(&self) -> Vec<Arc<RTCRtpReceiver>>
pub async fn get_receivers(&self) -> Vec<Arc<RTCRtpReceiver>>
get_receivers returns the RTPReceivers that are currently attached to this PeerConnection
Sourcepub async fn get_transceivers(&self) -> Vec<Arc<RTCRtpTransceiver>>
pub async fn get_transceivers(&self) -> Vec<Arc<RTCRtpTransceiver>>
get_transceivers returns the RtpTransceiver that are currently attached to this PeerConnection
Sourcepub async fn add_track(
&self,
track: Arc<dyn TrackLocal + Send + Sync>,
) -> Result<Arc<RTCRtpSender>>
pub async fn add_track( &self, track: Arc<dyn TrackLocal + Send + Sync>, ) -> Result<Arc<RTCRtpSender>>
add_track adds a Track to the PeerConnection
Sourcepub async fn remove_track(&self, sender: &Arc<RTCRtpSender>) -> Result<()>
pub async fn remove_track(&self, sender: &Arc<RTCRtpSender>) -> Result<()>
remove_track removes a Track from the PeerConnection
Sourcepub async fn add_transceiver_from_kind(
&self,
kind: RTPCodecType,
init: Option<RTCRtpTransceiverInit>,
) -> Result<Arc<RTCRtpTransceiver>>
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.
Sourcepub async fn add_transceiver_from_track(
&self,
track: Arc<dyn TrackLocal + Send + Sync>,
init: Option<RTCRtpTransceiverInit>,
) -> Result<Arc<RTCRtpTransceiver>>
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.
Sourcepub async fn create_data_channel(
&self,
label: &str,
options: Option<RTCDataChannelInit>,
) -> Result<Arc<RTCDataChannel>>
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.
Sourcepub fn set_identity_provider(&self, _provider: &str) -> Result<()>
pub fn set_identity_provider(&self, _provider: &str) -> Result<()>
set_identity_provider is used to configure an identity provider to generate identity assertions
Sourcepub async fn write_rtcp(
&self,
pkts: &[Box<dyn Packet + Send + Sync>],
) -> Result<usize>
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.
Sourcepub async fn current_local_description(&self) -> Option<RTCSessionDescription>
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.
Sourcepub async fn pending_local_description(&self) -> Option<RTCSessionDescription>
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.
Sourcepub async fn current_remote_description(&self) -> Option<RTCSessionDescription>
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.
Sourcepub async fn pending_remote_description(&self) -> Option<RTCSessionDescription>
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.
Sourcepub fn signaling_state(&self) -> RTCSignalingState
pub fn signaling_state(&self) -> RTCSignalingState
signaling_state attribute returns the signaling state of the PeerConnection instance.
Sourcepub fn ice_gathering_state(&self) -> RTCIceGatheringState
pub fn ice_gathering_state(&self) -> RTCIceGatheringState
icegathering_state attribute returns the ICE gathering state of the PeerConnection instance.
Sourcepub fn connection_state(&self) -> RTCPeerConnectionState
pub fn connection_state(&self) -> RTCPeerConnectionState
connection_state attribute returns the connection state of the PeerConnection instance.
pub async fn get_stats(&self) -> StatsReport
Sourcepub fn sctp(&self) -> Arc<RTCSctpTransport>
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
Sourcepub async fn gathering_complete_promise(&self) -> Receiver<()>
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.
Sourcepub fn dtls_transport(&self) -> Arc<RTCDtlsTransport>
pub fn dtls_transport(&self) -> Arc<RTCDtlsTransport>
Returns the internal RTCDtlsTransport
.
Sourcepub async fn add_transceiver(&self, t: Arc<RTCRtpTransceiver>)
pub async fn add_transceiver(&self, t: Arc<RTCRtpTransceiver>)
Adds the specified RTCRtpTransceiver
to this RTCPeerConnection
.