Skip to main content

smooth_runtime/server/
mod.rs

1//! Smooth Streaming live origin engine (issue #2453): the client Manifest and
2//! fragment *decision* logic, driven from a shared `media_plane::Trunk` — the
3//! same shape as `hls-runtime`'s `server` module.
4//!
5//! Nothing here ever `.await`s or opens a socket. [`SmoothOrigin::manifest`]
6//! renders the current live Manifest and the `ServedEgress` implementation
7//! answers one parsed [`SmoothRequest`] with an
8//! [`EgressResponse`](media_plane::egress::EgressResponse) (`Ready`, `Await`,
9//! `BadRequest`, `NotFound`) — never blocking the caller. The manifest is
10//! built as a `broadcast-smooth` model and rendered by its own `to_xml`; no
11//! XML is written here. Each track's codec parameters come from `transmux`'s
12//! [`resolve_codec`](transmux::resolve_codec), the same resolver the packager
13//! uses, so the manifest advertises exactly what the fragments carry.
14//!
15//! # The host's bookkeeping, not the origin's
16//!
17//! Which segments and tracks a program presents is the host's own
18//! bookkeeping (the set its DASH window and HLS origin already render from),
19//! so the origin asks for both through [`SegmentProvider`] and
20//! [`TrackProvider`] rather than caching the media itself. The `Trunk` stays
21//! the single copy.
22//!
23//! # The caller-driven wait loop
24//!
25//! A Manifest cannot be rendered before the trunk has an init segment, a
26//! track set and at least one published segment. The origin answers
27//! `EgressResponse::Await` until then; an adapter registers `Trunk::listen`
28//! *before* retrying so no publish is missed:
29//!
30//! ```text
31//! loop {
32//!     let listener = trunk.listen();
33//!     match origin.resolve(request, now, await_policy) {
34//!         EgressResponse::Await { .. } => { /* bounded wait on `listener` */ }
35//!         answer => return answer,
36//!     }
37//! }
38//! ```
39//!
40//! # `std`-only
41//!
42//! Like `media_plane::Trunk` itself, this module needs `std::sync::Mutex`, so
43//! it is compiled only when this crate's `std` feature is enabled (the
44//! default). A `--no-default-features` build gets [`crate::client`] alone.
45
46mod engine;
47
48pub use engine::{
49    FragmentLocation, SegmentProvider, SmoothBody, SmoothOrigin, SmoothOriginConfig,
50    SmoothOriginError, SmoothRequest, StreamKey, TrackProvider,
51};