pub struct Broadcaster { /* private fields */ }Expand description
All renditions of one broadcast, kept in sync with its catalog.
Implementations§
Source§impl Broadcaster
impl Broadcaster
Sourcepub async fn new(source: Source, config: Config) -> Result<Arc<Self>>
pub async fn new(source: Source, config: Config) -> Result<Arc<Self>>
Resolve source’s catalog broadcast and start tracking its renditions.
Sourcepub async fn closed(&self)
pub async fn closed(&self)
Resolve once the source broadcast closes, so a pool can evict a dead broadcaster.
Sourcepub fn rendition(&self, kind: Kind, name: &str) -> Option<Arc<Rendition>>
pub fn rendition(&self, kind: Kind, name: &str) -> Option<Arc<Rendition>>
Look up a rendition by kind and name. Video and audio are separate axes, so a video and an audio rendition may share a name without colliding.
Sourcepub fn renditions(&self) -> Consumer
pub fn renditions(&self) -> Consumer
A cursor over rendition add/remove events, for a consumer that mirrors or records the
whole broadcast. It replays the current renditions, then yields changes, and returns
None once the source closes.
Sourcepub async fn ready(&self)
pub async fn ready(&self)
Resolve once at least one rendition has a playable media playlist. How long to wait is the caller’s policy: wrap this in a timeout (or select against it) as needed.
Sourcepub fn set_generation(&self, generation: Option<&str>) -> Result<()>
pub fn set_generation(&self, generation: Option<&str>) -> Result<()>
Version every segment URL with generation, a label for the publisher run the
broadcast carries now, or stop versioning with None (the default).
A restarted publisher is spliced into the same broadcast and restarts its segment
numbers, so seg/0.m4s would name different bytes on each run. Supply a new generation
before the new run’s media flows. Replacing one drops every listed segment and every
init built from the old run’s media, while the first only labels the run already flowing. A segment URL carrying any other generation
is refused. Init URLs need none: they carry a hash of their bytes.
Fails unless generation is non-empty ASCII letters, digits, -, and _.
Sourcepub fn master_playlist(&self, query: Option<&str>) -> String
pub fn master_playlist(&self, query: Option<&str>) -> String
Render the multivariant (master) playlist from the current renditions.
query is an optional query string (without the leading ?, e.g. jwt=<token>)
appended to every child media-playlist URL, so a credential the master was fetched
with propagates to the rendition playlists a stock player loads next. It is an
argument rather than a Config field because one broadcaster fans out to viewers
holding different tokens; a credential in Config would embed one viewer’s in
another’s playlist.
Sourcepub fn manifest(&self, query: Option<&str>) -> Option<String>
pub fn manifest(&self, query: Option<&str>) -> Option<String>
Render the DASH manifest (MPD) from the current renditions and their views of the
broadcast timeline, or None while nothing is listable yet (every SegmentTimeline
would be empty, which players reject).
Live broadcasts render a dynamic presentation anchored at the catalog’s declared
wall clock (or, absent one, at an anchor estimated from the first record’s arrival); a
finished broadcast renders static. query propagates to every child URL exactly as
in master_playlist.
Each representation names its init by a hash of the bytes, so a rendition is left out
until its init is known. An inline-parameter-set codec only learns it from media: await
each rendition’s init first.