Skip to main content

LivestreamSwarm

Struct LivestreamSwarm 

Source
pub struct LivestreamSwarm {
    pub stream_id: u64,
    pub config: SwarmConfig,
    pub state: SwarmState,
    pub authority: LivestreamAuthority,
    pub interest: LivestreamInterest,
    pub stats: SwarmStats,
    /* private fields */
}
Expand description

Livestream swarm - complete system for a single livestream

Fields§

§stream_id: u64

Stream ID

§config: SwarmConfig

Configuration

§state: SwarmState

Current state

§authority: LivestreamAuthority

Authority model

§interest: LivestreamInterest

Interest tracking

§stats: SwarmStats

Statistics

Implementations§

Source§

impl LivestreamSwarm

Source

pub fn new(stream_id: u64, broadcaster: NodeId, config: SwarmConfig) -> Self

Create a new livestream swarm

Source

pub fn start(&mut self)

Start the stream

Source

pub fn pause(&mut self)

Pause the stream

Source

pub fn resume(&mut self)

Resume the stream

Source

pub fn end(&mut self)

End the stream

Source

pub fn add_viewer(&mut self, viewer: NodeId)

Add a viewer

Source

pub fn remove_viewer(&mut self, viewer: NodeId)

Remove a viewer

Source

pub fn viewer_count(&self) -> usize

Get viewer count

Source

pub fn broadcaster(&self) -> NodeId

Get broadcaster

Source

pub fn can_broadcast(&self, node: NodeId) -> bool

Check if a node can broadcast

Source

pub fn create_update( &mut self, timestamp: StateTime, size: usize, is_keyframe: bool, ) -> StateUpdate

Create a state update for broadcasting

Source

pub fn needs_keyframe(&self, current_time: StateTime) -> bool

Check if we need a keyframe

Source

pub fn get_targets(&self) -> Vec<NodeId>

Get propagation targets for an update

Trait Implementations§

Source§

impl Debug for LivestreamSwarm

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.