Skip to main content

write_segment

Function write_segment 

Source
pub fn write_segment(cues: &[Cue], segment_start: MediaTime) -> String
Expand description

Render one HLS segment of WebVTT (RFC 8216 §3.5): the WEBVTT signature, an X-TIMESTAMP-MAP=MPEGTS:<n>,LOCAL:00:00:00.000 header mapping this segment’s local WebVTT clock to the shared MPEG-2 TS (PES) timeline, then each cue rendered with times relative to segment_start (so cue timestamps stay small and segment-local, per the RFC 8216 convention of LOCAL:00:00:00.000).

segment_start is the carrying media segment’s first PES PTS (already wrap-unrolled, e.g. via crate::timeline::Timeline); it is reduced modulo 2^33 for the MPEGTS: field, matching the 33-bit PTS the value represents on the wire. Cues with start/end before segment_start saturate to zero (should not occur for cues that genuinely belong to this segment).