Skip to main content

PeerConnection

Trait PeerConnection 

Source
pub trait PeerConnection:
    Send
    + Sync
    + 'static {
Show 25 methods // Required methods fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn create_offer<'life0, 'async_trait>( &'life0 self, options: Option<RTCOfferOptions>, ) -> Pin<Box<dyn Future<Output = Result<RTCSessionDescription>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn create_answer<'life0, 'async_trait>( &'life0 self, options: Option<RTCAnswerOptions>, ) -> Pin<Box<dyn Future<Output = Result<RTCSessionDescription>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_local_description<'life0, 'async_trait>( &'life0 self, desc: RTCSessionDescription, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn local_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn current_local_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn pending_local_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn can_trickle_ice_candidates<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_remote_description<'life0, 'async_trait>( &'life0 self, desc: RTCSessionDescription, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remote_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn current_remote_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn pending_remote_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn add_ice_candidate<'life0, 'async_trait>( &'life0 self, candidate: RTCIceCandidateInit, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn restart_ice<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_configuration<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RTCConfiguration> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_configuration<'life0, 'async_trait>( &'life0 self, configuration: RTCConfiguration, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn create_data_channel<'life0, 'life1, 'async_trait>( &'life0 self, label: &'life1 str, options: Option<RTCDataChannelInit>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn DataChannel>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_senders<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<Arc<dyn RtpSender>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_receivers<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<Arc<dyn RtpReceiver>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_transceivers<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<Arc<dyn RtpTransceiver>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn add_track<'life0, 'async_trait>( &'life0 self, track: Arc<dyn TrackLocal>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn RtpSender>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remove_track<'life0, 'life1, 'async_trait>( &'life0 self, sender: &'life1 Arc<dyn RtpSender>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn add_transceiver_from_track<'life0, 'async_trait>( &'life0 self, track: Arc<dyn TrackLocal>, init: Option<RTCRtpTransceiverInit>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn RtpTransceiver>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn add_transceiver_from_kind<'life0, 'async_trait>( &'life0 self, kind: RtpCodecKind, init: Option<RTCRtpTransceiverInit>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn RtpTransceiver>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_stats<'life0, 'async_trait>( &'life0 self, now: Instant, selector: StatsSelector, ) -> Pin<Box<dyn Future<Output = RTCStatsReport> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Object-safe trait exposing all public PeerConnection operations.

PeerConnectionBuilder::build returns an opaque impl PeerConnection, hiding the generic interceptor type. Because this trait is object safe, wrap that value in Arc<dyn PeerConnection> when you need to store the connection in your own type or share it across tasks:

let pc: Arc<dyn PeerConnection> = Arc::new(builder.build().await?);

§Example

use webrtc::peer_connection::{RTCConfigurationBuilder, PeerConnection, PeerConnectionBuilder, PeerConnectionEventHandler};
use std::sync::Arc;

#[derive(Clone)]
struct MyHandler;
#[async_trait::async_trait]
impl PeerConnectionEventHandler for MyHandler {}

let pc = PeerConnectionBuilder::new()
    .with_handler(Arc::new(MyHandler))
    .with_udp_addrs(vec!["127.0.0.1:0"])
    .build()
    .await?;

let offer = pc.create_offer(None).await?;

Required Methods§

Source

fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close the peer connection

Source

fn create_offer<'life0, 'async_trait>( &'life0 self, options: Option<RTCOfferOptions>, ) -> Pin<Box<dyn Future<Output = Result<RTCSessionDescription>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create an SDP offer

Source

fn create_answer<'life0, 'async_trait>( &'life0 self, options: Option<RTCAnswerOptions>, ) -> Pin<Box<dyn Future<Output = Result<RTCSessionDescription>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create an SDP answer

Source

fn set_local_description<'life0, 'async_trait>( &'life0 self, desc: RTCSessionDescription, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the local description

Source

fn local_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the local description

Source

fn current_local_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get current local description

Source

fn pending_local_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get pending local description

Source

fn can_trickle_ice_candidates<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns whether the remote peer supports trickle ICE.

Source

fn set_remote_description<'life0, 'async_trait>( &'life0 self, desc: RTCSessionDescription, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the remote description

Source

fn remote_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the remote description

Source

fn current_remote_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get current remote description

Source

fn pending_remote_description<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<RTCSessionDescription>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get pending remote description

Source

fn add_ice_candidate<'life0, 'async_trait>( &'life0 self, candidate: RTCIceCandidateInit, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a remote ICE candidate

Source

fn restart_ice<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Trigger an ICE restart

Source

fn get_configuration<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RTCConfiguration> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the current configuration

Source

fn set_configuration<'life0, 'async_trait>( &'life0 self, configuration: RTCConfiguration, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update the configuration

Source

fn create_data_channel<'life0, 'life1, 'async_trait>( &'life0 self, label: &'life1 str, options: Option<RTCDataChannelInit>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn DataChannel>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a data channel

Source

fn get_senders<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<Arc<dyn RtpSender>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the list of rtp sender

Source

fn get_receivers<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<Arc<dyn RtpReceiver>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the list of rtp receiver

Source

fn get_transceivers<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<Arc<dyn RtpTransceiver>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the list of rtp transceiver

Source

fn add_track<'life0, 'async_trait>( &'life0 self, track: Arc<dyn TrackLocal>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn RtpSender>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a Track to the PeerConnection

Source

fn remove_track<'life0, 'life1, 'async_trait>( &'life0 self, sender: &'life1 Arc<dyn RtpSender>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a Track from the PeerConnection

Source

fn add_transceiver_from_track<'life0, 'async_trait>( &'life0 self, track: Arc<dyn TrackLocal>, init: Option<RTCRtpTransceiverInit>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn RtpTransceiver>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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

Source

fn add_transceiver_from_kind<'life0, 'async_trait>( &'life0 self, kind: RtpCodecKind, init: Option<RTCRtpTransceiverInit>, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn RtpTransceiver>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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

Source

fn get_stats<'life0, 'async_trait>( &'life0 self, now: Instant, selector: StatsSelector, ) -> Pin<Box<dyn Future<Output = RTCStatsReport> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a snapshot of accumulated statistics.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§