pub struct SegmentWriter { /* private fields */ }std only.Expand description
The write handle for a Trunk’s segments + parts ring group.
Obtained via Trunk::segment_writer, independently of TrunkWriter
(via Trunk::writer) — see
One writer per ring group
for why this split exists, why note_segment_start/set_time_anchor are
grouped here rather than on TrunkWriter, and what is (and is not)
guaranteed about ordering relative to the sample/event rings.
Like TrunkWriter, every method here either never blocks (ordinary
eviction, exactly the sample rings’ non-blocking-producer principle) or
blocks only in the one documented ArchiveOverrun::StallIngest case —
see SegmentWriter::publish_segment.
Implementations§
Source§impl SegmentWriter
impl SegmentWriter
Sourcepub fn publish_segment(&self, entry: SegmentEntry)
pub fn publish_segment(&self, entry: SegmentEntry)
Publish one finished segment, in playlist order.
Never blocks and never rejects for every non-pinning
SegmentCursor and for every pinning cursor using
ArchiveOverrun::Gap (the default) or ArchiveOverrun::Terminate
— a full segment log evicts its oldest entry exactly like
TrunkWriter::publish’s sample rings. The one exception, by
design, is a pinning cursor using ArchiveOverrun::StallIngest
that has not yet consumed the entry about to be evicted: this call
blocks until that cursor consumes further (or is dropped) — see
The DVR contradiction.
The block is a std::sync::Condvar::wait, which releases the
shared Mutex while parked, so TrunkWriter::publish and every
cursor’s poll on other data remain free to proceed even while
this call is stalled.
Does not touch the live-part log — see
The live-part log
for why a segment closing deliberately leaves that segment’s parts
exactly as addressable as they were the instant before. Wakes any
Trunk::listen registration once this call is about to return
(bare-_HLS_msn blocking-reload’s condition), even on the
StallIngest path — a waiter is woken only after the entry has
actually landed, never merely because a pin released.
Sourcepub fn publish_part(&self, entry: PartEntry)
pub fn publish_part(&self, entry: PartEntry)
Publish one live part of the segment currently being written — see The live-part log.
Never blocks and never rejects: a full part log evicts its oldest
entry exactly like every other ring in this module — the same
non-blocking-producer principle as TrunkWriter::publish/
SegmentWriter::publish_segment’s ordinary (non-StallIngest) path.
Wakes any Trunk::listen registration once this part has actually
landed (RFC 8216bis blocking-reload’s part-availability condition).
Sourcepub fn note_segment_start(&self, segment_number: u32, start: MediaTime)
pub fn note_segment_start(&self, segment_number: u32, start: MediaTime)
Report that segment segment_number starts at start on this
trunk’s 90 kHz absolute clock — the boundary an
EventAnchor::Segment (an emsg v0’s presentation_time_delta)
needs before it can resolve. Called by whoever owns segmentation —
the entity the spec’s B1 fix names explicitly: “it cannot be
finalised until the segmenter owns a boundary.” Lives here, not on
TrunkWriter, for exactly that reason: only the segmenter can
honestly report it. This does not append to the event ring — it
resolves an already-published EventAnchor::Segment entry in
place, so grouping it with SegmentWriter::publish_segment does not
create a second appender for TrunkWriter::publish_event’s ring;
see One writer per ring group.
Sourcepub fn set_time_anchor(&self, anchor: TimeAnchor)
pub fn set_time_anchor(&self, anchor: TimeAnchor)
Give the event log a wall-clock↔media-clock mapping. Resolves every
currently-pending EventAnchor::Utc entry immediately, and every
future one at publish time, until a later call replaces it. Grouped
with SegmentWriter::note_segment_start rather than split onto
TrunkWriter — see
One writer per ring group
for why, and the same in-place-resolution reasoning: this is not an
append to the event ring either.