pub struct BroadcastProducer { /* private fields */ }Expand description
Manages tracks within a broadcast.
Insert tracks statically with Self::insert_track / Self::create_track, or handle on-demand requests via Self::dynamic.
Implementations§
Source§impl BroadcastProducer
impl BroadcastProducer
Sourcepub fn new(info: Broadcast) -> Self
pub fn new(info: Broadcast) -> Self
Create a producer for the given broadcast metadata. Prefer Broadcast::produce.
Sourcepub fn insert_track(&mut self, track: TrackConsumer) -> Result<(), Error>
pub fn insert_track(&mut self, track: TrackConsumer) -> Result<(), Error>
Insert a track into the lookup, returning an error on duplicate.
Stores a weak handle to the track. The caller (or the owner of the
track’s TrackProducer) is responsible for keeping the track alive;
when all producers are dropped, the entry becomes closed and is
eventually evicted.
Sourcepub fn remove_track(&mut self, name: &str) -> Result<(), Error>
pub fn remove_track(&mut self, name: &str) -> Result<(), Error>
Remove a track from the lookup.
Sourcepub fn create_track(&mut self, track: Track) -> Result<TrackProducer, Error>
pub fn create_track(&mut self, track: Track) -> Result<TrackProducer, Error>
Produce a new track and insert it into the broadcast.
Sourcepub fn unique_track(&mut self, suffix: &str) -> Result<TrackProducer, Error>
pub fn unique_track(&mut self, suffix: &str) -> Result<TrackProducer, Error>
Create a track with a unique name using the given suffix.
Generates names like 0{suffix}, 1{suffix}, etc. and picks the first
one not already used in this broadcast.
Sourcepub fn dynamic(&self) -> BroadcastDynamic
pub fn dynamic(&self) -> BroadcastDynamic
Create a dynamic producer that handles on-demand track requests from consumers.
Sourcepub fn consume(&self) -> BroadcastConsumer
pub fn consume(&self) -> BroadcastConsumer
Create a consumer that can subscribe to tracks in this broadcast.
Sourcepub fn abort(&mut self, err: Error) -> Result<(), Error>
pub fn abort(&mut self, err: Error) -> Result<(), Error>
Abort the broadcast with the given error.
Externally-owned tracks are independent and must be aborted separately; inserted tracks are referenced via weak handles so that consumers can finish reading them. Pending dynamic track requests, however, are owned by the broadcast and have no other producer to fulfill them, so they are aborted here.
Trait Implementations§
Source§impl Clone for BroadcastProducer
impl Clone for BroadcastProducer
Source§fn clone(&self) -> BroadcastProducer
fn clone(&self) -> BroadcastProducer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more