pub struct Rendition {
pub name: String,
pub kind: Kind,
pub width: Option<u32>,
pub height: Option<u32>,
pub codec: String,
/* private fields */
}Expand description
A single HLS rendition: master-playlist metadata, its view of the broadcast timeline (which renders its media playlist), and on-demand segment fetching.
Fields§
§name: StringRendition name (the catalog track name; also its URL path component).
kind: KindWhether this rendition is video or audio.
width: Option<u32>Coded width, for the master playlist RESOLUTION (video only).
height: Option<u32>Coded height, for the master playlist RESOLUTION (video only).
codec: StringRFC 6381 codec string for the master playlist CODECS attribute.
Implementations§
Source§impl Rendition
impl Rendition
Sourcepub fn bandwidth(&self) -> u64
pub fn bandwidth(&self) -> u64
The advertised bitrate in bits per second, for the master playlist BANDWIDTH attribute
and the DASH bandwidth. Falls back to a per-kind default when the catalog carries none.
Sourcepub fn segments(self: &Arc<Self>) -> Consumer
pub fn segments(self: &Arc<Self>) -> Consumer
A cursor over this rendition’s segments, with their media, in timeline order.
For a recorder mirroring the broadcast; see segments::Consumer.
Sourcepub async fn playable(&self)
pub async fn playable(&self)
Resolve once the playlist is renderable, i.e. once media_playlist
would return Some. Bounding the wait is the caller’s policy (the serve path wraps this
in its own timeout).
Sourcepub fn media_playlist(&self, query: Option<&str>) -> Option<String>
pub fn media_playlist(&self, query: Option<&str>) -> Option<String>
Render this rendition’s media playlist from the current timeline window, or None when
there is nothing to serve yet (no segment, and the broadcast has not ended) – a
playlist with no segments confuses players, so a server should treat None as “not
ready” rather than serve it.
The playlist names its init segment by a hash of the bytes, so it is also None until
the init is known. An inline-parameter-set codec (no catalog description) only learns
it from media: await init first.
query is an optional query string (without the leading ?, e.g. jwt=<token>)
appended to every child URL (the init map and each segment), so a stock player that does
not replay request headers still carries a credential on its follow-up requests. It is an
argument rather than a Config field because one broadcaster fans out
to viewers holding different tokens.
Sourcepub async fn playlist(&self, query: Option<&str>) -> Result<Option<String>>
pub async fn playlist(&self, query: Option<&str>) -> Result<Option<String>>
Wait until the media playlist is servable, then render it: at least one segment is
listed and the EXT-X-MAP init segment it names is built, so a player never loads a
map that 404s. None when the init cannot be built yet.
Waits without bound for the first segment; bounding it is the caller’s policy. query
propagates exactly as in media_playlist.
Sourcepub async fn init(&self) -> Result<Option<Bytes>>
pub async fn init(&self) -> Result<Option<Bytes>>
The rendition’s CMAF init segment, built on first request and cached.
For inline-parameter-set codecs (no catalog description), the parameter sets are
resolved by fetching the newest keyframe group first.
Sourcepub async fn segment(&self, segment: u64) -> Result<Option<Bytes>>
pub async fn segment(&self, segment: u64) -> Result<Option<Bytes>>
Fetch and transmux the segment numbered segment.
Fetches every group the segment’s ranges cover (an audio segment packs many short
groups) and encodes them as a single CMAF fragment. None when the segment isn’t in
the playlist window, is a gap for this rendition, or its groups already left the relay
cache.