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…
- Build a channel schedule of programmes, ads and slates:
Schedule,ScheduleEntry,EntryKind,examples/schedule_and_transition.rs. - Walk every join the schedule implies, with its rebase offset and
discontinuity:
next_transition,Playhead,examples/schedule_and_transition.rs. - Plan the join between two given entries:
TransitionPlan::plan,examples/rebase_and_return.rs. - Put an incoming source’s timestamps on the channel timeline, including a
33-bit PTS that wraps:
TransitionPlan::rebase,TransitionPlan::rebase_wrapped,examples/rebase_and_return.rs. - Ask which entry is on air at an instant:
Schedule::active_at,examples/rebase_and_return.rs. - Emit the
splice_insert()that enters a break, snapped to a real keyframe, and serialise it:build_splice_insert,BreakEdge,to_section,examples/emit_splice_from_real_cue.rs. - Emit the
splice_insert()that returns to the network:build_splice_insertwithBreakEdge::Return,examples/rebase_and_return.rs.
§Modules
schedule: the schedule model and the playhead.transition: join planning and PTS rebasing.scte35: thesplice_insert()a break edge implies.error:ErrorandResult.
§Feature flags
std(default): link the standard library; without it the crate isno_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 withscte35-splice’s ownSerialize, not hand-assembled bytes. - transition
- Transition planning: given a
Scheduleand the current channel-timeline position, what transition happens next, at what instant, and what timeline-continuity actions it implies.