Skip to main content

Router

Struct Router 

Source
pub struct Router {
    primary: RouterId,
    placements: Option<RouterPlacements>,
    capabilities: MediaCapabilities,
    routers: BTreeMap<RouterId, LocalRouter>,
    sessions: BTreeMap<UserId, CommittedSession>,
    users: BTreeMap<ConnectionId, UserId>,
}
Expand description

pure room router for placement and routed media lifetimes

Fields§

§primary: RouterId§placements: Option<RouterPlacements>§capabilities: MediaCapabilities§routers: BTreeMap<RouterId, LocalRouter>§sessions: BTreeMap<UserId, CommittedSession>§users: BTreeMap<ConnectionId, UserId>

Implementations§

Source§

impl Router

Source

pub fn new(primary: RouterId, capabilities: MediaCapabilities) -> Self

Source

pub fn with_placements( placements: RouterPlacements, capabilities: MediaCapabilities, ) -> Self

Source

pub const fn rtp_capabilities(&self) -> &MediaCapabilities

Source

pub fn committed_media_worker_id( &self, user: &UserId, connection: ConnectionId, ) -> Option<MediaWorkerId>

Source

pub fn commit_session_placement( &mut self, user: &UserId, connection: ConnectionId, placement: RouterPlacement, ) -> Result<MediaWorkerId, RouterError>

commit one user connection to a router placement

§Errors

returns an error when the connection is occupied or when the placement contradicts an existing router-to-worker assignment

Source

pub fn retire_committed_placement( &mut self, user: &UserId, connection: ConnectionId, ) -> Option<MediaWorkerId>

Source

pub fn media_worker_id_for_connection( &self, connection: ConnectionId, ) -> MediaWorkerId

§Panics

panics when connection has no committed placement

Source

pub fn primary_worker(&self) -> Option<MediaWorkerId>

Source

pub fn placement_snapshot(&self) -> PlacementSnapshot

Source

pub fn add_producer( &mut self, user: &UserId, producer: ProducerId, ) -> Result<RoutedProducerId, RouterError>

create a producer on the user’s home router

§Errors

returns a missing session or duplicate producer error

Source

pub fn add_consumer( &mut self, user: &UserId, consumer: ConsumerId, producer: RoutedProducerId, ) -> Result<RoutedConsumerId, RouterError>

create a consumer on its producer’s source router

§Errors

returns a missing session, router, producer or duplicate consumer error

Source

pub fn remove_consumer( &mut self, consumer: RoutedConsumerId, ) -> Result<(), RouterError>

remove one consumer and its empty foreign receiver session

§Errors

returns a missing router or consumer error

Source

pub fn remove_producer( &mut self, producer: RoutedProducerId, ) -> Result<(), RouterError>

remove one producer and every dependent consumer

§Errors

returns a missing router or producer error

Source

pub fn remove_session(&mut self, user: &UserId) -> Result<(), RouterError>

remove a user’s home session, foreign sessions and routed media

§Errors

returns a missing session or router error

Source

fn remove_dependents( &mut self, router: RouterId, consumers: BTreeSet<RoutedConsumerId>, )

Source

fn attach_placement(&mut self, placement: RouterPlacement)

Source

fn validate_placement( &self, placement: RouterPlacement, ) -> Result<(), RouterError>

Source

fn require_session( &self, user: &UserId, ) -> Result<&CommittedSession, RouterError>

Source

fn prune_foreign_session(&mut self, router: RouterId, connection: ConnectionId)

Trait Implementations§

Source§

impl Debug for Router

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
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.