Skip to main content

Rendition

Struct Rendition 

Source
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: String

Rendition name (the catalog track name; also its URL path component).

§kind: Kind

Whether 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: String

RFC 6381 codec string for the master playlist CODECS attribute.

Implementations§

Source§

impl Rendition

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more