Skip to main content

MediaStore

Struct MediaStore 

Source
pub struct MediaStore { /* private fields */ }
Available on crate feature std only.
Expand description

In-RAM rolling window for one served stream: bytes + timing, shared by every adapter serving that stream.

Implementations§

Source§

impl MediaStore

Source

pub fn resolve_playlist( &self, track_id: u32, query: BlockingQuery, ) -> PlaylistOutcome

Resolve a GET media.m3u8 request against _HLS_msn/_HLS_part blocking-reload semantics (RFC 8216bis §6.2.5.2), rendering media_playlist_m3u8 for track_id once the awaited condition is satisfied (or immediately, if query carries no blocking parameters).

_HLS_msn alone waits for segment msn to close; _HLS_msn+ _HLS_part waits only for that part of the (possibly still open) segment — these are genuinely different conditions (treating a bare _HLS_msn as _HLS_part=0 would resolve as soon as the segment merely opens with one live part, before it has an #EXTINF/URI at all). _HLS_part without _HLS_msn is meaningless (a part is only addressable relative to a segment) and a _HLS_msn unreasonably far beyond the live edge is either a broken client or abuse — both PlaylistOutcome::BadRequest immediately rather than PlaylistOutcome::WouldBlocking.

Source

pub fn resolve_resource(&self, name: &str) -> ResourceOutcome

Resolve a dynamic origin filename (init-{track}.mp4, seg-{track}- {seq}.m4s, part-{track}-{seq}.{idx}.m4s) to its bytes.

A part request is the preload-hinted Partial Segment a client fetches ahead of time (RFC 8216bis §6.2.2, §6.3.1). If the origin promised it via #EXT-X-PRELOAD-HINT but hasn’t produced it yet, ResourceOutcome::WouldBlock — the caller should hold the request open (not 404 immediately, which spams errors and defeats low latency). ResourceOutcome::NotFound is returned promptly (without the caller needing to wait out its own timeout) once the part can no longer appear: its segment has closed (now only addressable as a whole segment via seg-…), or the in-progress segment has advanced past it — a legitimate 404 the client answers by fetching the next segment/part.

Source§

impl MediaStore

Source

pub fn new( target_duration_secs: f64, part_target_ms: u32, window_segments: usize, ) -> Self

New empty store; window_segments = full segments retained.

Source

pub fn set_init(&self, bytes: Vec<u8>)

Store the fMP4 init segment.

Source

pub fn add_part(&self, part: PartInfo)

Append a completed part to the in-progress segment.

Caps live_parts at max_live_parts worth of entries, dropping the oldest live part(s) first if the cap is exceeded — this bounds RAM use even if the current segment never closes (see compute_max_live_parts).

Source

pub fn add_segment(&self, seg: SegmentInfo)

Close a full segment into the window (evicting the oldest). Its in-progress parts move out of live_parts into a bounded recent_parts buffer — still fetchable (so an in-flight preload-hint request for the segment’s final part resolves) but no longer rendered as open parts. recent_parts is capped like live_parts, oldest-first.

Source

pub fn init_bytes(&self) -> Option<Vec<u8>>

The fMP4 init segment bytes, if present — the one accessor kept public beyond add_*/set_*/health/listen, since callers (e.g. multimux’s pipeline/supervisor tests) commonly need to assert media has actually landed without going through resolve_resource.

Source

pub fn latest_progress(&self) -> (u32, u32)

(in-progress segment seq, count of live parts available for it) — used to resolve blocking _HLS_msn/_HLS_part requests.

The second value is a count, not the last part’s index: the blocking-reload resolver treats “part P ready” as count > P (0 means no parts of the in-progress segment are available yet).

pub (not pub(crate)) since issue #663 P4.2: multimux::output::ll_dash needs the in-progress segment’s identity to address its live parts (part-{track}-{seq}.{idx}.m4s) from a SegmentTemplate — the same cross-crate exception already made for Self::target_duration_secs/Self::part_target_ms/ Self::track_specs.

Source

pub fn progress_version(&self) -> u64

The current monotonic progress version — bumped by every mutation. Mostly useful for a caller wanting to detect “did anything change” without registering a listener (e.g. a cheap pre-check).

Source

pub fn listen(&self) -> EventListener

Register for the next change notification. Register before re-checking the condition you’re waiting on (see this module’s super-level doc for the wait-loop shape) — event-listener guarantees any notify call that happens after listen() returns will wake this listener, so there is no missed-wakeup race as long as the re-check happens after listen(), not before.

The returned EventListener is a plain Future<Output = ()> — any async runtime (or none, via its blocking .wait()) can drive it; this is what keeps server runtime-agnostic (unlike a tokio::sync::watch::Receiver, which only ever paired with tokio).

Source

pub fn set_health(&self, state: HealthState)

Set the route’s ingest health. Bumps the progress notification only when the state actually changes, so a caller blocked on Self::listen (e.g. an LL-HLS blocking playlist reload) wakes on a health transition too, not just new media.

Source

pub fn health(&self) -> HealthState

The current ingest health (default HealthState::Connecting until the supervisor sets it).

Source

pub fn target_duration_secs(&self) -> f64

The full-segment target duration, in seconds, this store was built with — timing configuration a manifest renderer needs (e.g. LL-HLS’s #EXT-X-TARGETDURATION, or a DASH Output’s minimumUpdatePeriod/ timeShiftBufferDepth). pub (not pub(crate)) since issue #663 P4: multimux::output::dash needs it too, not just this crate’s own engine.

Source

pub fn part_target_ms(&self) -> u32

The part target duration, in milliseconds, this store was built with. pub for the same cross-Output reason as Self::target_duration_secs.

Source

pub fn created_at(&self) -> SystemTime

Wall-clock time this store was constructed (issue #663 P4) — used as a live DASH presentation’s availabilityStartTime anchor. An approximation (the route’s start time, not the first segment’s exact cut time — the first segment typically closes target_duration_secs or so later), acceptable for a manifest attribute that only needs to establish a consistent, monotonic timeline, not wall-clock precision.

Source

pub fn set_track_specs(&self, specs: Vec<TrackSpec>)

Store the track specs the feeding pipeline built its segmenter from — called once, before the first sample is pushed. See Inner::track_specs for why this exists (DASH’s codecs string needs real codec identity; LL-HLS never reads this).

Source

pub fn track_specs(&self) -> Vec<TrackSpec>

The track specs set by Self::set_track_specs, empty if never called (e.g. in a test that only exercises playlist rendering).

Source

pub fn window_segments(&self) -> Vec<SegmentWindowEntry>

Snapshot of the closed segments currently retained in the rolling window, oldest first — enough for a manifest renderer to enumerate fetchable segments (issue #663 P4: DASH’s SegmentTemplate/ $Number$ addressing) without depending on the LL-HLS-specific playlist rendering in the playlist renderer.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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