Skip to main content

Crate playout_runtime

Crate playout_runtime 

Source
Expand description

Sans-IO linear channel playout: a schedule of programmes, ads and slates, the plan for each join between two sources, and the SCTE 35 splice_insert() each break edge implies.

A channel is an ordered Schedule; next_transition finds the next join and plans it: the channel-timeline instant, the PTS-rebase offset that lands the incoming source’s clock continuously on the channel timeline (unwrapping a 33-bit source PTS when asked), and whether a codec configuration change must be signalled as a discontinuity. build_splice_insert turns a break edge into an ANSI/SCTE 35 2023r1 splice_insert() (§9.7.3, Table 10) whose splice time is conditioned against real boundaries by ssai-runtime, and to_section wraps it in a clear splice_info_section built by scte35-splice.

The schedule is an in-memory model of this crate (no wire format, and SCTE 224 is deliberately not adopted). The crate computes numbers and cues only: transmux applies a rebase to samples, a playlist writer acts on a discontinuity, and the caller owns the clock and the media. No HTTP, no async runtime, no transcoding; no_std + alloc without std.

§Quickstart

Schedule a programme and a 30 s ad, plan the join, and build the cue that enters the break:

use broadcast_common::clock33::Clock33;
use broadcast_core::timescale::Timescale;
use playout_runtime::{
    BreakEdge, CodecConfigId, EntryKind, Playhead, Schedule, ScheduleEntry,
    build_splice_insert, next_transition,
};
use std::time::Duration;

let mut schedule = Schedule::new();
schedule
    .push(ScheduleEntry {
        id: "news".into(),
        kind: EntryKind::Programme,
        planned_start: 0,
        source_start_pts: 0,
        codec_config: CodecConfigId(1),
    })
    .unwrap();
schedule
    .push(ScheduleEntry {
        id: "ad".into(),
        kind: EntryKind::Ad,
        planned_start: 54_000_000,
        source_start_pts: 5_000,
        codec_config: CodecConfigId(2),
    })
    .unwrap();

let t = next_transition(&schedule, Playhead::new(0, Timescale::MICROS)).unwrap();
assert_eq!(t.plan.at_pts, 54_000_000);
assert!(t.plan.discontinuity);
assert_eq!(t.plan.rebase(5_000), Some(54_000_000));

let clock = |ticks| Clock33::try_new(ticks).unwrap();
let (point, insert) = build_splice_insert(
    BreakEdge::Enter,
    1,
    clock(t.plan.at_pts),
    &[clock(53_998_000), clock(54_003_000)],
    Duration::from_millis(60),
    Some(Duration::from_secs(30)),
)
.unwrap();
assert_eq!(point.snapped_pts, clock(53_998_000));
assert!(insert.out_of_network_indicator);

§How do I…

§Modules

§Feature flags

  • std (default): link the standard library; without it the crate is no_std + alloc.
  • serde: serde derives on the schedule, transition and decision types.

§Spec citations

ANSI/SCTE 35 2023r1 §9.7.3 Table 10 (splice_insert()) and §9.8 (splice_time(), break_duration()), transcribed in private/specs-verified/scte/scte35-splice/.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use schedule::CodecConfigId;
pub use schedule::EntryKind;
pub use schedule::Playhead;
pub use schedule::Schedule;
pub use schedule::ScheduleEntry;
pub use scte35::BreakEdge;
pub use scte35::build_splice_insert;
pub use scte35::to_section;
pub use transition::PlannedTransition;
pub use transition::TransitionPlan;
pub use transition::next_transition;

Modules§

error
Crate error type.
schedule
The channel schedule: an ordered list of entries (programme / ad / slate).
scte35
SCTE-35 emission points a transition implies (issue #748): splice_insert() — ANSI/SCTE 35 2023r1 §9.7.3, Table 10 — built and serialized with scte35-splice’s own Serialize, not hand-assembled bytes.
transition
Transition planning: given a Schedule and the current channel-timeline position, what transition happens next, at what instant, and what timeline-continuity actions it implies.