Struct medea_jason::peer::PeerConnection[][src]

pub struct PeerConnection { /* fields omitted */ }

High-level wrapper around RtcPeerConnection.

Implementations

impl PeerConnection[src]

pub fn new(
    state: &State,
    peer_events_sender: UnboundedSender<PeerEvent>,
    media_manager: Rc<MediaManager>,
    send_constraints: LocalTracksConstraints,
    connections: Rc<Connections>,
    recv_constraints: Rc<RecvConstraints>
) -> Result<Rc<Self>, Traced<PeerError>>
[src]

Creates new PeerConnection.

Provided peer_events_sender will be used to emit PeerEvents from this peer.

Provided ice_servers will be used by created RtcPeerConnection.

Errors

Errors with PeerError::RtcPeerConnection if RtcPeerConnection creating fails.

Errors with PeerError::RtcPeerConnection if some callback of RtcPeerConnection can’t be set.

#[must_use]pub fn get_senders_without_tracks_ids(
    &self,
    kinds: LocalStreamUpdateCriteria
) -> Vec<TrackId>
[src]

Returns all TrackIds of Senders that match the provided LocalStreamUpdateCriteria and don’t have local::Track.

pub async fn drop_send_tracks(&self, kinds: LocalStreamUpdateCriteria)[src]

Drops local::Tracks of all Senders which are matches provided LocalStreamUpdateCriteria.

pub fn send_peer_stats(&self, stats: RtcStats)[src]

Filters out already sent stats, and send new statss from provided RtcStats.

pub async fn scrape_and_send_peer_stats(&self)[src]

Sends RtcStats update of this PeerConnection to the server.

#[must_use]pub fn is_all_transceiver_sides_in_media_state(
    &self,
    kind: MediaKind,
    direction: TrackDirection,
    source_kind: Option<MediaSourceKind>,
    state: MediaState
) -> bool
[src]

Indicates whether all TransceiverSides with the provided MediaKind, TrackDirection and MediaSourceKind are in the provided MediaState.

pub fn id(&self) -> PeerId[src]

Returns PeerId of this PeerConnection.

pub fn get_transceivers_sides(
    &self,
    kind: MediaKind,
    direction: TrackDirection,
    source_kind: Option<MediaSourceKind>
) -> Vec<Rc<dyn TransceiverSide>>
[src]

Returns all TransceiverSides from this PeerConnection with provided MediaKind, TrackDirection and MediaSourceKind.

pub async fn update_local_stream(
    &self,
    criteria: LocalStreamUpdateCriteria
) -> Result<HashMap<TrackId, Stable>, Traced<PeerError>>
[src]

Updates local::Tracks being used in PeerConnections Senders. Senders are chosen based on provided LocalStreamUpdateCriteria.

First of all make sure that PeerConnection Senders are up to date (you set those with State::senders) and State::senders are synchronized with a real object state. If there are no senders configured in this PeerConnection, then this method is no-op.

Secondly, make sure that configured LocalTracksConstraints are up to date.

This function requests local stream from MediaManager. If stream returned from MediaManager is considered new, then this function will emit PeerEvent::NewLocalTrack events.

Constraints being used when requesting stream from MediaManager are a result of merging constraints received from this PeerConnection Senders, which are configured by server during signalling, and LocalTracksConstraints, that are optionally configured by JS-side.

Returns HashMap with media_exchange_state::Stables updates for the Senders.

Errors

With TracksRequestError if current state of peer’s Senders cannot be represented as SimpleTracksRequest (max 1 audio Sender and max 1 video Sender), or local::Tracks requested from MediaManager does not satisfy Senders constraints.

With TracksRequestError::ExpectedAudioTracks or TracksRequestError::ExpectedDeviceVideoTracks / TracksRequestError::ExpectedDisplayVideoTracks if provided MediaStreamSettings are incompatible with this peer Senders constraints.

With MediaManagerError::GetUserMediaFailed or MediaManagerError::GetDisplayMediaFailed if corresponding request to UA failed.

With MediaConnectionsError::InvalidMediaTracks, MediaConnectionsError::InvalidMediaTrack or MediaConnectionsError::CouldNotInsertLocalTrack if local::Track couldn’t inserted into PeerConnections Senders.

pub fn get_media_settings(
    &self,
    kind: MediaKind,
    source_kind: Option<MediaSourceKind>
) -> Result<Option<MediaStreamSettings>, Traced<PeerError>>
[src]

Returns MediaStreamSettings for the provided MediaKind and MediaSourceKind.

If MediaSourceKind is None then MediaStreamSettings for all MediaSourceKinds will be provided.

Errors

Errors with PeerError::TracksRequest if failed to create or merge SimpleTracksRequest.

pub fn get_transceiver_side_by_id(
    &self,
    track_id: TrackId
) -> Option<Rc<dyn TransceiverSide>>
[src]

Returns Rc to TransceiverSide with a provided TrackId.

Returns None if TransceiverSide with a provided TrackId doesn’t exist in this PeerConnection.

pub async fn add_ice_candidate(
    &self,
    candidate: String,
    sdp_m_line_index: Option<u16>,
    sdp_mid: Option<String>
) -> Result<(), Traced<PeerError>>
[src]

pub fn remove_track(&self, track_id: TrackId)[src]

Removes a sender::Component and a receiver::Component with the provided TrackId from this PeerConnection.

Trait Implementations

impl Drop for PeerConnection[src]

fn drop(&mut self)[src]

Drops on_track and on_ice_candidate callbacks to prevent possible leaks.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<E> WrapTraced<E> for E[src]