1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! 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:
//!
//! ```rust
//! 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_insert`] with [`BreakEdge::Return`],
//! `examples/rebase_and_return.rs`.
//!
//! # Modules
//!
//! - [`schedule`]: the schedule model and the playhead.
//! - [`transition`]: join planning and PTS rebasing.
//! - [`scte35`]: the `splice_insert()` a break edge implies.
//! - [`error`]: [`Error`] and [`Result`].
//!
//! # 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/`.
extern crate alloc;
;
pub use ;
pub use ;
pub use ;
pub use ;