Struct medea_jason::peer::PeerConnection [−][src]
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]
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>>
Creates new PeerConnection
.
Provided peer_events_sender
will be used to emit PeerEvent
s 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]
&self,
kinds: LocalStreamUpdateCriteria
) -> Vec<TrackId>
Returns all TrackId
s of Sender
s that match the provided
LocalStreamUpdateCriteria
and don’t have local::Track
.
pub async fn drop_send_tracks(&self, kinds: LocalStreamUpdateCriteria)
[src]
Drops local::Track
s of all Sender
s 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]
&self,
kind: MediaKind,
direction: TrackDirection,
source_kind: Option<MediaSourceKind>,
state: MediaState
) -> bool
Indicates whether all TransceiverSide
s 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]
&self,
kind: MediaKind,
direction: TrackDirection,
source_kind: Option<MediaSourceKind>
) -> Vec<Rc<dyn TransceiverSide>>
Returns all TransceiverSide
s 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]
&self,
criteria: LocalStreamUpdateCriteria
) -> Result<HashMap<TrackId, Stable>, Traced<PeerError>>
Updates local::Track
s being used in PeerConnection
s Sender
s.
Sender
s are chosen based on provided LocalStreamUpdateCriteria
.
First of all make sure that PeerConnection
Sender
s 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
Sender
s, which are configured by server during signalling, and
LocalTracksConstraints
, that are optionally configured by JS-side.
Returns HashMap
with media_exchange_state::Stable
s updates for
the Sender
s.
Errors
With TracksRequestError
if current state of peer’s Sender
s
cannot be represented as SimpleTracksRequest
(max 1 audio Sender
and max 1 video Sender
), or local::Track
s requested from
MediaManager
does not satisfy Sender
s constraints.
With TracksRequestError::ExpectedAudioTracks
or
TracksRequestError::ExpectedDeviceVideoTracks
/
TracksRequestError::ExpectedDisplayVideoTracks
if provided
MediaStreamSettings
are incompatible with this peer Sender
s
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 PeerConnection
s Sender
s.
pub fn get_media_settings(
&self,
kind: MediaKind,
source_kind: Option<MediaSourceKind>
) -> Result<Option<MediaStreamSettings>, Traced<PeerError>>
[src]
&self,
kind: MediaKind,
source_kind: Option<MediaSourceKind>
) -> Result<Option<MediaStreamSettings>, Traced<PeerError>>
Returns MediaStreamSettings
for the provided MediaKind
and
MediaSourceKind
.
If MediaSourceKind
is None
then MediaStreamSettings
for all
MediaSourceKind
s 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]
&self,
track_id: TrackId
) -> Option<Rc<dyn TransceiverSide>>
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]
&self,
candidate: String,
sdp_m_line_index: Option<u16>,
sdp_mid: Option<String>
) -> Result<(), Traced<PeerError>>
Adds remote peers ICE Candidate to this peer.
Errors
With RtcPeerConnectionError::AddIceCandidateFailed
if
RtcPeerConnection.addIceCandidate() fails to add buffered
ICE candidates.
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]
Auto Trait Implementations
impl !RefUnwindSafe for PeerConnection
impl !Send for PeerConnection
impl !Sync for PeerConnection
impl Unpin for PeerConnection
impl !UnwindSafe for PeerConnection
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.