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: u64Stream ID
config: SwarmConfigConfiguration
state: SwarmStateCurrent state
Authority model
interest: LivestreamInterestInterest tracking
stats: SwarmStatsStatistics
Implementations§
Source§impl LivestreamSwarm
impl LivestreamSwarm
Sourcepub fn new(stream_id: u64, broadcaster: NodeId, config: SwarmConfig) -> Self
pub fn new(stream_id: u64, broadcaster: NodeId, config: SwarmConfig) -> Self
Create a new livestream swarm
Sourcepub fn add_viewer(&mut self, viewer: NodeId)
pub fn add_viewer(&mut self, viewer: NodeId)
Add a viewer
Sourcepub fn remove_viewer(&mut self, viewer: NodeId)
pub fn remove_viewer(&mut self, viewer: NodeId)
Remove a viewer
Sourcepub fn viewer_count(&self) -> usize
pub fn viewer_count(&self) -> usize
Get viewer count
Sourcepub fn broadcaster(&self) -> NodeId
pub fn broadcaster(&self) -> NodeId
Get broadcaster
Sourcepub fn can_broadcast(&self, node: NodeId) -> bool
pub fn can_broadcast(&self, node: NodeId) -> bool
Check if a node can broadcast
Sourcepub fn create_update(
&mut self,
timestamp: StateTime,
size: usize,
is_keyframe: bool,
) -> StateUpdate
pub fn create_update( &mut self, timestamp: StateTime, size: usize, is_keyframe: bool, ) -> StateUpdate
Create a state update for broadcasting
Sourcepub fn needs_keyframe(&self, current_time: StateTime) -> bool
pub fn needs_keyframe(&self, current_time: StateTime) -> bool
Check if we need a keyframe
Sourcepub fn get_targets(&self) -> Vec<NodeId>
pub fn get_targets(&self) -> Vec<NodeId>
Get propagation targets for an update
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LivestreamSwarm
impl RefUnwindSafe for LivestreamSwarm
impl Send for LivestreamSwarm
impl Sync for LivestreamSwarm
impl Unpin for LivestreamSwarm
impl UnsafeUnpin for LivestreamSwarm
impl UnwindSafe for LivestreamSwarm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more