Skip to main content

Module server

Module server 

Source
Available on crate feature std only.
Expand description

Smooth Streaming live origin engine (issue #2453): the client Manifest and fragment decision logic, driven from a shared media_plane::Trunk — the same shape as hls-runtime’s server module.

Nothing here ever .awaits or opens a socket. SmoothOrigin::manifest renders the current live Manifest and the ServedEgress implementation answers one parsed SmoothRequest with an EgressResponse (Ready, Await, BadRequest, NotFound) — never blocking the caller. The manifest is built as a broadcast-smooth model and rendered by its own to_xml; no XML is written here. Each track’s codec parameters come from transmux’s resolve_codec, the same resolver the packager uses, so the manifest advertises exactly what the fragments carry.

§The host’s bookkeeping, not the origin’s

Which segments and tracks a program presents is the host’s own bookkeeping (the set its DASH window and HLS origin already render from), so the origin asks for both through SegmentProvider and TrackProvider rather than caching the media itself. The Trunk stays the single copy.

§The caller-driven wait loop

A Manifest cannot be rendered before the trunk has an init segment, a track set and at least one published segment. The origin answers EgressResponse::Await until then; an adapter registers Trunk::listen before retrying so no publish is missed:

loop {
    let listener = trunk.listen();
    match origin.resolve(request, now, await_policy) {
        EgressResponse::Await { .. } => { /* bounded wait on `listener` */ }
        answer => return answer,
    }
}

§std-only

Like media_plane::Trunk itself, this module needs std::sync::Mutex, so it is compiled only when this crate’s std feature is enabled (the default). A --no-default-features build gets crate::client alone.

Structs§

FragmentLocation
One fragment a manifest advertises: its stream, absolute start time and duration in SMOOTH_TIMESCALE ticks.
SmoothOrigin
The live Smooth origin over one Trunk.
SmoothOriginConfig
What a SmoothOrigin is built from: every part is required, so SmoothOriginConfig::new takes all three.
StreamKey
What identifies one advertised stream: its media kind and the 1-based ordinal of that kind, (kind, ordinal), exactly the pair the manifest’s StreamIndex@Name/@Url and the request grammar name. Two tracks of one kind are therefore distinct.

Enums§

SmoothBody
The body of a SmoothOrigin answer.
SmoothOriginError
Why a SmoothOrigin cannot describe the trunk’s media.
SmoothRequest
What a caller asks a SmoothOrigin for: the client Manifest, or one fragment of it.

Traits§

SegmentProvider
The segments the origin should describe, given the Trunk it reads.
TrackProvider
The tracks the origin should describe, given the Trunk it reads.