From a5fb61c09807c9664cca1d74e3b67325cc9543f6 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 17:12:41 +0100 Subject: [PATCH 01/23] build(mux): build against mp4-atom's Common Encryption boxes Patch mp4-atom to kixelated/mp4-atom#268 until a release ships its encv/enca, sinf and pssh atoms, and absorb what else changed there: colr is a list per sample entry, and moov and moof carry their pssh boxes. The color comes from the first colr with code points, so an ICC profile beside them no longer hides them. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 2 - Cargo.toml | 2 + rs/moq-mux/benches/containers.rs | 1 + rs/moq-mux/src/container/fmp4/import.rs | 41 ++++++++++++++++---- rs/moq-mux/src/container/fmp4/import_test.rs | 14 ++++++- rs/moq-mux/src/container/fmp4/mod.rs | 5 ++- rs/moq-mux/src/container/fmp4/sample.rs | 1 + 7 files changed, 54 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83555451d05..027ddb08579 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5381,8 +5381,6 @@ dependencies = [ [[package]] name = "mp4-atom" version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718b5227fa90c52ed2e72d4d553560130d9e128acb6217d9fe0ea57312ee7063" dependencies = [ "bytes", "derive_more 2.1.1", diff --git a/Cargo.toml b/Cargo.toml index f6ffa1c4660..b509097d357 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -250,6 +250,8 @@ zeroize = { version = "1", features = ["derive"] } # the member, and the next publish that reaches both fails to resolve a single # version (#3551). kio = { path = "rs/kio" } +# Common Encryption boxes (kixelated/mp4-atom#268), until a release ships them. +mp4-atom = { path = "/Users/michael/Projects/mp4-atom" } [profile.dev] # Full DWARF is what makes a debug build enormous: the debug `libmoq_ffi.a` diff --git a/rs/moq-mux/benches/containers.rs b/rs/moq-mux/benches/containers.rs index b45d80f4b2f..738a9883a59 100644 --- a/rs/moq-mux/benches/containers.rs +++ b/rs/moq-mux/benches/containers.rs @@ -201,6 +201,7 @@ fn interleaved(init: &[u8], tracks: usize, runs: usize, fragments: usize, payloa let mut out = BytesMut::from(&init[..cursor.position() as usize]); for fragment in 0..fragments { let mut moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: fragment as u32 + 1, }, diff --git a/rs/moq-mux/src/container/fmp4/import.rs b/rs/moq-mux/src/container/fmp4/import.rs index b02300c9d37..ffa6fa2722d 100644 --- a/rs/moq-mux/src/container/fmp4/import.rs +++ b/rs/moq-mux/src/container/fmp4/import.rs @@ -741,6 +741,7 @@ impl Import { trak.edts = None; let single_moov = Moov { + pssh: Vec::new(), mvhd: moov.mvhd.clone(), trak: vec![trak], mvex: Some(mp4_atom::Mvex { @@ -773,25 +774,25 @@ impl Import { let (mut config, colr, pasp, spatial) = match codec { mp4_atom::Codec::Avc1(avc1) => ( self.init_h264(false, &avc1.avcc, &avc1.visual, container)?, - avc1.colr.as_ref(), + avc1.colr.as_slice(), avc1.pasp.as_ref(), avc1.spatial.as_deref(), ), mp4_atom::Codec::Avc3(avc3) => ( self.init_h264(true, &avc3.avcc, &avc3.visual, container)?, - avc3.colr.as_ref(), + avc3.colr.as_slice(), avc3.pasp.as_ref(), avc3.spatial.as_deref(), ), mp4_atom::Codec::Hev1(hev1) => ( self.init_h265(true, &hev1.hvcc, &hev1.visual, container)?, - hev1.colr.as_ref(), + hev1.colr.as_slice(), hev1.pasp.as_ref(), hev1.spatial.as_deref(), ), mp4_atom::Codec::Hvc1(hvc1) => ( self.init_h265(false, &hvc1.hvcc, &hvc1.visual, container)?, - hvc1.colr.as_ref(), + hvc1.colr.as_slice(), hvc1.pasp.as_ref(), hvc1.spatial.as_deref(), ), @@ -808,7 +809,12 @@ impl Import { config.coded_width = Some(vp08.visual.width as _); config.coded_height = Some(vp08.visual.height as _); config.container = container; - (config, vp08.colr.as_ref(), vp08.pasp.as_ref(), vp08.spatial.as_deref()) + ( + config, + vp08.colr.as_slice(), + vp08.pasp.as_ref(), + vp08.spatial.as_deref(), + ) } mp4_atom::Codec::Vp09(vp09) => { // https://github.com/gpac/mp4box.js/blob/325741b592d910297bf609bc7c400fc76101077b/src/box-codecs.js#L238 @@ -829,7 +835,12 @@ impl Import { config.coded_width = Some(vp09.visual.width as _); config.coded_height = Some(vp09.visual.height as _); config.container = container; - (config, vp09.colr.as_ref(), vp09.pasp.as_ref(), vp09.spatial.as_deref()) + ( + config, + vp09.colr.as_slice(), + vp09.pasp.as_ref(), + vp09.spatial.as_deref(), + ) } mp4_atom::Codec::Av01(av01) => { let mut config = VideoConfig::new(crate::codec::av1::av1_from_av1c(&av01.av1c)); @@ -837,13 +848,24 @@ impl Import { config.coded_width = Some(av01.visual.width as _); config.coded_height = Some(av01.visual.height as _); config.container = container; - (config, av01.colr.as_ref(), av01.pasp.as_ref(), av01.spatial.as_deref()) + ( + config, + av01.colr.as_slice(), + av01.pasp.as_ref(), + av01.spatial.as_deref(), + ) } mp4_atom::Codec::Unknown(unknown, _) => return Err(Error::UnknownCodec(*unknown).into()), unsupported => return Err(Error::UnsupportedCodec(Box::new(unsupported.clone())).into()), }; // The codec config outranks the colr box a muxer added, which only fills its gaps. - let colr = colr.map(super::colr_color).transpose()?.flatten(); + // An entry may carry an ICC profile beside its code points; only the code points say anything. + let colr = colr + .iter() + .find(|colr| matches!(colr, mp4_atom::Colr::Nclx { .. } | mp4_atom::Colr::Nclc { .. })) + .map(super::colr_color) + .transpose()? + .flatten(); crate::codec::color::fill(&mut config.color, colr.as_ref(), "colr"); (config.projection, config.stereo) = super::spatial(spatial)?; if let Some(pasp) = pasp { @@ -1451,6 +1473,7 @@ fn fragment(traf: &mp4_atom::Traf, moof: &Moof, run: &Run, defaults: &sample::De // Build a per-track moof containing only this traf, and a per-track mdat // with only the samples belonging to this track. let mut adjusted_moof = Moof { + pssh: Vec::new(), mfhd: moof.mfhd.clone(), traf: vec![match run.dropped { true => kept(traf, run)?, @@ -1896,6 +1919,7 @@ mod tests { // Only the headers are supplied. The declared mdat may never finish. fn media_header(id: u32, decode_time: u64, offsets: &[usize], size: u32, len: Option) -> Vec { let mut moof = Moof { + pssh: Vec::new(), mfhd: Default::default(), traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -2030,6 +2054,7 @@ mod tests { // A moof of one traf on track `id` carrying `trun`, whose samples are a byte and 1024 ticks each. fn runs_moof(id: u32, trun: Vec) -> Vec { let moof = Moof { + pssh: Vec::new(), mfhd: Default::default(), traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { diff --git a/rs/moq-mux/src/container/fmp4/import_test.rs b/rs/moq-mux/src/container/fmp4/import_test.rs index 8c6b64913ad..7c2f348bdd9 100644 --- a/rs/moq-mux/src/container/fmp4/import_test.rs +++ b/rs/moq-mux/src/container/fmp4/import_test.rs @@ -765,6 +765,7 @@ async fn separated_runs_keep_their_samples() { ..Default::default() }; let mut moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 1 }, traf: vec![ mp4_atom::Traf { @@ -868,6 +869,7 @@ fn empty_samples_are_refused() { let (init, (video_id, timescale), _) = bbb_init(); for explicit in [false, true] { let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 1 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -922,6 +924,7 @@ fn absolute_sample_bases_are_refused() { let (init, (video_id, timescale), _) = bbb_init(); for base in [0, 1024, u64::MAX] { let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 1 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -995,6 +998,7 @@ async fn shared_sample_bytes_are_refused() { ]; for trafs in cases { let mut moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 1 }, traf: trafs.iter().map(|(traf, _)| traf.clone()).collect(), }; @@ -1050,6 +1054,7 @@ async fn unwrapped_samples_present_at_their_composition_time() { let non_sync = 0x0001_0000; let entries = [(tick, 0, 0xA), (2 * tick, non_sync, 0xB), (0, non_sync, 0xC)]; let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 1 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -1142,6 +1147,7 @@ fn fieldless_runs_do_not_stall_the_segment_scan() { // repeating the traf can't multiply it. for (trafs, runs, mdat) in [(1, 1000, 6), (1000, 1, 1 << 16)] { let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 2 }, traf: vec![traf(runs); trafs], }; @@ -1246,6 +1252,7 @@ async fn audio_presents_from_its_edit() { /// One video fragment decoding from `dts`, a sample per `(cts, flags, byte)` lasting `tick`. fn video_fragment(track_id: u32, dts: u64, tick: u64, entries: &[(u64, u32, u8)]) -> Vec { let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 1 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -2323,6 +2330,7 @@ async fn a_mid_gop_join_keeps_tracks_on_the_same_groups_in(passthrough: bool) { /// the importer needs to slice them back out. fn audio_fragment(base_media_decode_time: u64, duration: u32, size: u32) -> Vec { let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 0 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -2411,6 +2419,7 @@ fn rejected_fragment_keeps_the_first_error() { /// Like [`audio_fragment`] but carrying `samples` samples, the shape a real segmenter emits. fn audio_fragment_samples(base_media_decode_time: u64, duration: u32, size: u32, samples: usize) -> Vec { let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 0 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -2516,6 +2525,7 @@ fn fragment_jitter_uses_sample_endpoints() { let mut import = crate::container::fmp4::Import::new(broadcast, catalog.reserve()); import.decode(&init).unwrap(); let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 0 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -3069,6 +3079,7 @@ fn webvtt_init(header: &str) -> Vec { /// One fragment carrying `samples` back to back, each lasting `duration` ms from `decode_time`. fn webvtt_fragment(decode_time: u64, samples: &[Vec], duration: u32) -> Vec { let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 1 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -3199,6 +3210,7 @@ fn empty_and_multiple_webvtt_cues_are_supported() { fn oversized_text_sample_is_refused_before_staging() { let size = super::MAX_HELD_BYTES + 1; let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 1 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -3667,7 +3679,7 @@ fn unsignalled_color_stays_absent() { let mp4_atom::Codec::Avc1(avc1) = &moov.trak[0].mdia.minf.stbl.stsd.codecs[0] else { panic!("expected avc1"); }; - assert_eq!(avc1.colr, None); + assert!(avc1.colr.is_empty()); let catalog = run_fmp4(&init); let video = catalog.video.renditions.values().next().unwrap(); diff --git a/rs/moq-mux/src/container/fmp4/mod.rs b/rs/moq-mux/src/container/fmp4/mod.rs index f2a19c68de4..0fa2b81f04c 100644 --- a/rs/moq-mux/src/container/fmp4/mod.rs +++ b/rs/moq-mux/src/container/fmp4/mod.rs @@ -782,6 +782,7 @@ pub(super) fn encode_at(info: FragmentInfo, base_dts: u64, frames: &[Frame]) -> let mdat_data: Vec = frames.iter().flat_map(|f| f.payload.iter().copied()).collect(); let build_moof = |data_offset| mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -997,7 +998,7 @@ pub(crate) fn synthesize_video_trak( // Codecs that carry an out-of-band config record require `description`. let require_description = || description.ok_or_else(|| Error::MissingVideoDescription(config.codec.to_string())); - let colr = color_colr(config.color.as_ref()); + let colr: Vec<_> = color_colr(config.color.as_ref()).into_iter().collect(); let sample_entry = match &config.codec { VideoCodec::H264(h264) => { let mut cursor = std::io::Cursor::new(require_description()?); @@ -1806,6 +1807,7 @@ mod tests { // hand-built moof+mdat with explicit per-sample durations is enough. let timescale = moq_net::Timescale::MICRO; let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 0 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { @@ -2229,6 +2231,7 @@ mod tests { let timescale = moq_net::Timescale::new(24_000).unwrap(); let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 0 }, traf: vec![mp4_atom::Traf { tfhd: mp4_atom::Tfhd { diff --git a/rs/moq-mux/src/container/fmp4/sample.rs b/rs/moq-mux/src/container/fmp4/sample.rs index 5f18533c995..0927513a2b4 100644 --- a/rs/moq-mux/src/container/fmp4/sample.rs +++ b/rs/moq-mux/src/container/fmp4/sample.rs @@ -378,6 +378,7 @@ mod tests { run.samples = samples.clone(); } let moof = mp4_atom::Moof { + pssh: Vec::new(), mfhd: mp4_atom::Mfhd { sequence_number: 1 }, traf: vec![traf], }; From a73e8231317aa33e4d91e1e6c06226bab2f893b0 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 17:20:06 +0100 Subject: [PATCH 02/23] feat(hang): a root drm section for protected CMAF renditions The catalog gains a root `drm` section keyed by entry ID. Each entry names one DRM system, one Common Encryption scheme (cenc or cbcs) and one default key, plus the system's pssh box and its license and certificate servers, so it maps 1:1 onto a CMSF contentProtections entry. A protected video or audio rendition lists its entries' IDs in its own `drm` field, and check_renditions refuses one that names an entry the root lacks, in Rust and in js/hang alike. The shared parity corpus covers both. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 1 + js/hang/src/catalog/audio.ts | 5 + js/hang/src/catalog/drm.ts | 69 +++++ js/hang/src/catalog/index.ts | 5 +- js/hang/src/catalog/root.ts | 21 +- js/hang/src/catalog/video.ts | 5 + rs/hang/Cargo.toml | 1 + rs/hang/fixtures/catalog-parity.json | 362 +++++++++++++++++++++++++++ rs/hang/src/catalog/audio/mod.rs | 10 + rs/hang/src/catalog/drm.rs | 232 +++++++++++++++++ rs/hang/src/catalog/mod.rs | 1 + rs/hang/src/catalog/root.rs | 76 +++++- rs/hang/src/catalog/video/mod.rs | 10 + rs/hang/src/error.rs | 13 + rs/workspace-hack/Cargo.toml | 8 +- 15 files changed, 806 insertions(+), 13 deletions(-) create mode 100644 js/hang/src/catalog/drm.ts create mode 100644 rs/hang/src/catalog/drm.rs diff --git a/Cargo.lock b/Cargo.lock index 027ddb08579..3b2b3b7b5cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2958,6 +2958,7 @@ dependencies = [ "tokio", "tracing", "url", + "uuid", "workspace-hack", ] diff --git a/js/hang/src/catalog/audio.ts b/js/hang/src/catalog/audio.ts index c84397adf74..246882b38bd 100644 --- a/js/hang/src/catalog/audio.ts +++ b/js/hang/src/catalog/audio.ts @@ -39,6 +39,11 @@ const AudioConfigFields = z.object({ // The container format, used to decode the timestamp and more. container: ContainerSchema, + // The IDs of the root `drm` entries protecting this rendition, one per DRM system that can + // decrypt it. Absent or empty means clear. Only a CMAF rendition can be protected; `codec` names + // the codec its encrypted sample entry wraps. A consumer that can't decrypt skips it. + drm: z.optional(z.array(z.string())), + // The description is used for some codecs. // If provided, we can initialize the decoder based on the catalog alone. // Otherwise, the initialization information is in-band. diff --git a/js/hang/src/catalog/drm.ts b/js/hang/src/catalog/drm.ts new file mode 100644 index 00000000000..2e442976769 --- /dev/null +++ b/js/hang/src/catalog/drm.ts @@ -0,0 +1,69 @@ +import * as z from "zod/mini"; + +/** + * Well-known DRM system IDs, as draft-ietf-moq-cmsf lists them. + */ +export const SYSTEM = { + widevine: "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed", + playready: "9a04f079-9840-4286-ab92-e65be0885f95", + fairplay: "94ce86fb-07ff-4f43-adb8-93d2fa968ca2", + // The W3C Common System ID: for testing, since the key travels in the clear. + clearkey: "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", +} as const; + +/** A license or certificate server. */ +export const DrmServerSchema = z.object({ + url: z.url(), + // The protocol a license server speaks (e.g. `EME-1.0`), or the MIME type of a certificate. + type: z.optional(z.string()), +}); + +/** A license or certificate server. */ +export type DrmServer = z.infer; + +/** + * One DRM system protecting renditions under one Common Encryption scheme and one default key. + * + * Each protected video or audio rendition lists the IDs of its entries in its own `drm` field; + * the entries map 1:1 onto draft-ietf-moq-cmsf's `contentProtections`. + */ +export const DrmSchema = z.object({ + // The DRM system ID, as a UUID string (see `SYSTEM`). + system: z.guid(), + // How the samples are encrypted; draft-ietf-moq-cmsf allows only these two. + scheme: z.enum(["cenc", "cbcs"]), + // The default key ID (`tenc`'s `default_KID`), as a UUID string. + kid: z.guid(), + // The system's whole `pssh` box from the init segment, base64. + pssh: z.optional(z.base64()), + // Where to request a license. + license: z.optional(DrmServerSchema), + // Where to fetch the server certificate, which systems such as FairPlay need first. + certificate: z.optional(DrmServerSchema), +}); + +/** One DRM system protecting renditions. */ +export type Drm = z.infer; + +/** A protected rendition lists a `drm` entry the root `drm` section lacks. */ +export class MissingDrm extends Error { + /** The rendition listing the entry. */ + readonly rendition: string; + /** The entry ID the root lacks. */ + readonly id: string; + + constructor(rendition: string, id: string) { + super(`rendition ${rendition} references missing drm entry ${id}`); + this.name = "MissingDrm"; + this.rendition = rendition; + this.id = id; + } +} + +/** + * Whether a rendition is protected: it lists `drm` entries, so its samples are encrypted and only a + * consumer that can decrypt them may select it. + */ +export function isProtected(config: { drm?: string[] }): boolean { + return (config.drm?.length ?? 0) > 0; +} diff --git a/js/hang/src/catalog/index.ts b/js/hang/src/catalog/index.ts index e99954e9dbf..6a798ed4fa1 100644 --- a/js/hang/src/catalog/index.ts +++ b/js/hang/src/catalog/index.ts @@ -2,8 +2,8 @@ * JSON catalog schema and types describing a broadcast's tracks: audio/video decoder configs for * WebCodecs, container format, rendition layout, the `media` section (the broadcast's `clock` and * `join` interval), - * plus the `json` and `binary` data sections, optional `stats` and `echo` discovery, and whole - * `contributions` listed without opening them. + * plus the `json` and `binary` data sections, optional `stats` and `echo` discovery, whole + * `contributions` listed without opening them, and the `drm` systems protecting CMAF renditions. * * @module */ @@ -26,6 +26,7 @@ export * from "./binary"; export * from "./clock"; export * from "./container"; export * from "./contribution"; +export * from "./drm"; export * from "./echo"; export * from "./format"; export * from "./hex"; diff --git a/js/hang/src/catalog/root.ts b/js/hang/src/catalog/root.ts index 7827f1ab84a..7d129d303a1 100644 --- a/js/hang/src/catalog/root.ts +++ b/js/hang/src/catalog/root.ts @@ -5,6 +5,7 @@ import * as z from "zod/mini"; import { AudioSchema } from "./audio"; import { BinarySchema } from "./binary"; import { ContributionSchema } from "./contribution"; +import { DrmSchema, MissingDrm } from "./drm"; import { EchoSchema } from "./echo"; import { TRACK } from "./format"; import { JsonSchema } from "./json"; @@ -86,6 +87,9 @@ export const RootSchema = z.looseObject({ binary: section(BinarySchema, "tracks"), // A new key, so a malformed entry fails the catalog, the same as Rust. contributions: z.optional(renditions(ContributionSchema, "contribution")), + // The DRM systems protecting the CMAF renditions, keyed by entry ID; each protected rendition + // lists its entries' IDs in its own `drm`. A new key, so a malformed entry fails the catalog. + drm: z.optional(renditions(DrmSchema, "drm entry")), }); /** The root catalog object: the media sections, `media`, the data track sections, plus any app extensions. */ @@ -125,11 +129,26 @@ export class DuplicateRendition extends Error { } } -/** Refuse an update with an ID naming both a video and an audio rendition. */ +/** + * Refuse an update with an ID naming both a video and an audio rendition, or with a rendition + * listing a `drm` entry the root lacks. + * + * Throws {@link DuplicateRendition} or {@link MissingDrm}. + */ export function checkRenditions(root: Root): Root { const audio = root.audio?.renditions ?? {}; const duplicate = Object.keys(root.video?.renditions ?? {}).find((id) => Object.hasOwn(audio, id)); if (duplicate !== undefined) throw new DuplicateRendition(duplicate); + + // A protected rendition whose entry is missing would read as clear, or name no system. + const drm = root.drm ?? {}; + const sections: (Record | undefined)[] = [root.video?.renditions, audio]; + for (const section of sections) { + for (const [rendition, config] of Object.entries(section ?? {})) { + const missing = config.drm?.find((id) => !Object.hasOwn(drm, id)); + if (missing !== undefined) throw new MissingDrm(rendition, missing); + } + } return root; } diff --git a/js/hang/src/catalog/video.ts b/js/hang/src/catalog/video.ts index adbb69f3bbc..016259b4c66 100644 --- a/js/hang/src/catalog/video.ts +++ b/js/hang/src/catalog/video.ts @@ -135,6 +135,11 @@ export const VideoConfigSchema = z.object({ // The container format, used to decode the timestamp and more. container: ContainerSchema, + // The IDs of the root `drm` entries protecting this rendition, one per DRM system that can + // decrypt it. Absent or empty means clear. Only a CMAF rendition can be protected; `codec` names + // the codec its encrypted sample entry wraps. A consumer that can't decrypt skips it. + drm: z.optional(z.array(z.string())), + // The description is used for some codecs. // If provided, we can initialize the decoder based on the catalog alone. // Otherwise, the initialization information is (repeated) before each key-frame. diff --git a/rs/hang/Cargo.toml b/rs/hang/Cargo.toml index 73d2d00f5d2..d4796054201 100644 --- a/rs/hang/Cargo.toml +++ b/rs/hang/Cargo.toml @@ -23,6 +23,7 @@ serde_json = { workspace = true } serde_with = { workspace = true, features = ["base64"] } thiserror = { workspace = true } url = { workspace = true, features = ["serde"] } +uuid = { workspace = true, features = ["serde"] } [dependencies.derive_more] version = "2" diff --git a/rs/hang/fixtures/catalog-parity.json b/rs/hang/fixtures/catalog-parity.json index f39ae0ae8dc..07f37caa649 100644 --- a/rs/hang/fixtures/catalog-parity.json +++ b/rs/hang/fixtures/catalog-parity.json @@ -3723,5 +3723,367 @@ } }, "refused": true + }, + { + "name": "drm entries protect video and audio", + "catalog": { + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + "pssh": "AAAA", + "license": { + "url": "https://license.example.com/", + "type": "EME-1.0" + } + }, + "2": { + "system": "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + "certificate": { + "url": "https://cert.example.com/" + } + } + }, + "video": { + "renditions": { + "v": { + "codec": "avc1.64001f", + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1", "2"] + } + } + }, + "audio": { + "renditions": { + "a": { + "codec": "mp4a.40.2", + "sampleRate": 48000, + "numberOfChannels": 2, + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + } + }, + "video": ["v"], + "audio": ["a"] + }, + { + "name": "drm unknown entry members are ignored", + "catalog": { + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + "future": true + } + }, + "video": { + "renditions": { + "v": { + "codec": "avc1.64001f", + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + }, + "audio": { + "renditions": { + "a": { + "codec": "mp4a.40.2", + "sampleRate": 48000, + "numberOfChannels": 2, + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + } + }, + "video": ["v"], + "audio": ["a"] + }, + { + "name": "drm unreferenced entry is accepted", + "catalog": { + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90" + } + } + } + }, + { + "name": "drm dangling video reference refuses the catalog", + "catalog": { + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90" + } + }, + "video": { + "renditions": { + "v": { + "codec": "avc1.64001f", + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["2"] + } + } + }, + "audio": { + "renditions": { + "a": { + "codec": "mp4a.40.2", + "sampleRate": 48000, + "numberOfChannels": 2, + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + } + }, + "refused": true + }, + { + "name": "drm dangling audio reference refuses the catalog", + "catalog": { + "drm": {}, + "video": { + "renditions": { + "v": { + "codec": "avc1.64001f", + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": [] + } + } + }, + "audio": { + "renditions": { + "a": { + "codec": "mp4a.40.2", + "sampleRate": 48000, + "numberOfChannels": 2, + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + } + }, + "refused": true + }, + { + "name": "drm scheme cens refuses the catalog", + "catalog": { + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cens", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90" + } + }, + "video": { + "renditions": { + "v": { + "codec": "avc1.64001f", + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + }, + "audio": { + "renditions": { + "a": { + "codec": "mp4a.40.2", + "sampleRate": 48000, + "numberOfChannels": 2, + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + } + }, + "refused": true + }, + { + "name": "drm malformed system refuses the catalog", + "catalog": { + "drm": { + "1": { + "system": "widevine", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90" + } + }, + "video": { + "renditions": { + "v": { + "codec": "avc1.64001f", + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + }, + "audio": { + "renditions": { + "a": { + "codec": "mp4a.40.2", + "sampleRate": 48000, + "numberOfChannels": 2, + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + } + }, + "refused": true + }, + { + "name": "drm entry without kid refuses the catalog", + "catalog": { + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cenc" + } + } + }, + "refused": true + }, + { + "name": "drm license without url refuses the catalog", + "catalog": { + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + "license": { + "type": "EME-1.0" + } + } + }, + "video": { + "renditions": { + "v": { + "codec": "avc1.64001f", + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + }, + "audio": { + "renditions": { + "a": { + "codec": "mp4a.40.2", + "sampleRate": 48000, + "numberOfChannels": 2, + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + } + }, + "refused": true + }, + { + "name": "drm references must be a list", + "catalog": { + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90" + } + }, + "video": { + "renditions": { + "v": { + "codec": "avc1.64001f", + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": "1" + } + } + }, + "audio": { + "renditions": { + "a": { + "codec": "mp4a.40.2", + "sampleRate": 48000, + "numberOfChannels": 2, + "container": { + "kind": "cmaf", + "init": "AAAA" + }, + "drm": ["1"] + } + } + } + }, + "refused": true + }, + { + "name": "drm unhyphenated kid refuses the catalog", + "catalog": { + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cenc", + "kid": "a1b2c3d4e5f60718293a4b5c6d7e8f90" + } + } + }, + "refused": true } ] diff --git a/rs/hang/src/catalog/audio/mod.rs b/rs/hang/src/catalog/audio/mod.rs index 177afe90eea..db7b1962387 100644 --- a/rs/hang/src/catalog/audio/mod.rs +++ b/rs/hang/src/catalog/audio/mod.rs @@ -175,6 +175,15 @@ pub struct AudioConfig { #[serde(default)] pub container: Container, + /// The IDs of the root `drm` entries protecting this rendition, one per DRM system that can + /// decrypt it. Empty means the rendition is clear, and is left off the wire. + /// + /// Only a [`Cmaf`](Container::Cmaf) rendition can be protected: its init segment carries the + /// encrypted sample entry (`encv`/`enca`), while `codec` names the codec it wraps. A consumer + /// that cannot decrypt treats a protected rendition as undecodable. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub drm: Vec, + /// The maximum delay between a frame being ready and the publisher flushing it. /// The player's jitter buffer should be larger than this value. /// If not provided, the player should assume each frame is flushed immediately. @@ -240,6 +249,7 @@ impl AudioConfig { enabled: true, description: None, container: Container::default(), + drm: Vec::new(), jitter: None, warmup: None, delay: None, diff --git a/rs/hang/src/catalog/drm.rs b/rs/hang/src/catalog/drm.rs new file mode 100644 index 00000000000..785e9668778 --- /dev/null +++ b/rs/hang/src/catalog/drm.rs @@ -0,0 +1,232 @@ +//! Content protection: the DRM systems that encrypt a broadcast's CMAF renditions. +//! +//! The catalog's root `drm` section maps an entry ID to an [`Entry`], and each protected video or +//! audio rendition lists the IDs of the entries that protect it in its `drm` field. A rendition +//! that lists none is clear. Every entry names one DRM system, one Common Encryption +//! [`Scheme`], and one default key, so the entries map 1:1 onto draft-ietf-moq-cmsf's +//! `contentProtections` and a rendition's IDs onto its `contentProtectionRefIDs`. +//! +//! ```json +//! { +//! "drm": { +//! "1": { +//! "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", +//! "scheme": "cbcs", +//! "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", +//! "pssh": "AAAANHBzc2gB...", +//! "license": { "url": "https://license.example.com/clearkey" } +//! } +//! }, +//! "video": { "renditions": { "hd": { "codec": "avc1.64001f", "drm": ["1"], "...": "..." } } } +//! } +//! ``` + +use bytes::Bytes; +use serde::{Deserialize, Serialize}; +use serde_with::{base64::Base64, serde_as}; + +/// Well-known DRM system IDs, as draft-ietf-moq-cmsf lists them. +pub mod system { + /// Google Widevine. + pub const WIDEVINE: uuid::Uuid = uuid::uuid!("edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"); + /// Microsoft PlayReady. + pub const PLAYREADY: uuid::Uuid = uuid::uuid!("9a04f079-9840-4286-ab92-e65be0885f95"); + /// Apple FairPlay Streaming. + pub const FAIRPLAY: uuid::Uuid = uuid::uuid!("94ce86fb-07ff-4f43-adb8-93d2fa968ca2"); + /// W3C ClearKey, the Common System ID: for testing, since the key travels in the clear. + pub const CLEARKEY: uuid::Uuid = uuid::uuid!("1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"); + + /// The system ID a short name (`widevine`, `playready`, `fairplay`, `clearkey`) stands for. + pub fn named(name: &str) -> Option { + Some(match name.to_ascii_lowercase().as_str() { + "widevine" => WIDEVINE, + "playready" => PLAYREADY, + "fairplay" => FAIRPLAY, + "clearkey" => CLEARKEY, + _ => return None, + }) + } +} + +/// One DRM system protecting renditions under one scheme and one default key. +/// +/// The scheme, key, system, and `pssh` are the media's own (the init segment's `schm`, `tenc`, +/// and `pssh` boxes); the license and certificate servers are the publisher's, which the media +/// does not carry. +/// +/// Marked `#[non_exhaustive]` so optional fields can be added later. External callers build one +/// with [`Entry::new`]. +#[serde_as] +#[serde_with::skip_serializing_none] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub struct Entry { + /// The DRM system ID, as a UUID string (see [`system`]). + #[serde_as(as = "Hyphenated")] + pub system: uuid::Uuid, + + /// How the samples are encrypted. + pub scheme: Scheme, + + /// The default key ID (`tenc`'s `default_KID`), as a UUID string. + #[serde_as(as = "Hyphenated")] + pub kid: uuid::Uuid, + + /// The system's whole `pssh` box from the init segment, base64: what the player hands its + /// DRM system to request a license. + #[serde(default)] + #[serde_as(as = "Option")] + pub pssh: Option, + + /// Where to request a license. + #[serde(default)] + pub license: Option, + + /// Where to fetch the server certificate, which systems such as FairPlay need first. + #[serde(default)] + pub certificate: Option, +} + +impl Entry { + /// An entry with no `pssh` and no servers. + pub fn new(system: uuid::Uuid, scheme: Scheme, kid: uuid::Uuid) -> Self { + Self { + system, + scheme, + kid, + pssh: None, + license: None, + certificate: None, + } + } + + /// Whether `other` describes the same system, scheme, and key, which renditions share. + pub fn same_key(&self, other: &Self) -> bool { + self.system == other.system && self.scheme == other.scheme && self.kid == other.kid + } +} + +/// A UUID in its hyphenated form only, as draft-ietf-moq-cmsf writes one, refusing the simple, +/// braced, and URN forms [`uuid::Uuid`]'s own decoder also takes. +struct Hyphenated; + +impl serde_with::SerializeAs for Hyphenated { + fn serialize_as(source: &uuid::Uuid, serializer: S) -> Result { + source.hyphenated().serialize(serializer) + } +} + +impl<'de> serde_with::DeserializeAs<'de, uuid::Uuid> for Hyphenated { + fn deserialize_as>(deserializer: D) -> Result { + let text = String::deserialize(deserializer)?; + match text.len() { + 36 => uuid::Uuid::try_parse(&text).map_err(serde::de::Error::custom), + _ => Err(serde::de::Error::custom(format_args!( + "expected a hyphenated UUID: {text:?}" + ))), + } + } +} + +/// The Common Encryption scheme (ISO/IEC 23001-7) of a protected rendition. +/// +/// draft-ietf-moq-cmsf allows only these two; a catalog naming another is refused. +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[serde(rename_all = "lowercase")] +pub enum Scheme { + /// AES-CTR, full sample or subsample. + Cenc, + /// AES-CBC pattern encryption with a constant IV, which FairPlay and most hardware decode. + Cbcs, +} + +impl Scheme { + /// The scheme's four-character code, as `schm` carries it. + pub fn as_str(&self) -> &'static str { + match self { + Self::Cenc => "cenc", + Self::Cbcs => "cbcs", + } + } +} + +impl std::fmt::Display for Scheme { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::str::FromStr for Scheme { + type Err = crate::Error; + + fn from_str(s: &str) -> crate::Result { + match s { + "cenc" => Ok(Self::Cenc), + "cbcs" => Ok(Self::Cbcs), + other => Err(crate::Error::UnsupportedScheme(other.to_string())), + } + } +} + +/// A license or certificate server. +/// +/// Marked `#[non_exhaustive]` so optional fields can be added later. External callers build one +/// with [`Server::new`]. +#[serde_with::skip_serializing_none] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] +pub struct Server { + /// The server's URL. + pub url: url::Url, + + /// The protocol a license server speaks (e.g. `EME-1.0`), or the MIME type of a certificate + /// (e.g. `application/pkcs7-mime`). + #[serde(default, rename = "type")] + pub kind: Option, +} + +impl Server { + /// A server at `url`, of no declared type. + pub fn new(url: url::Url) -> Self { + Self { url, kind: None } + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn an_entry_round_trips_with_hang_member_names() { + let json = serde_json::json!({ + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + "pssh": "AAAA", + "license": { "url": "https://license.example.com/", "type": "EME-1.0" }, + }); + let entry: Entry = serde_json::from_value(json.clone()).unwrap(); + assert_eq!(entry.system, system::CLEARKEY); + assert_eq!(entry.scheme, Scheme::Cbcs); + assert_eq!(entry.pssh.as_deref(), Some(&[0u8, 0, 0][..])); + assert_eq!(entry.license.as_ref().unwrap().kind.as_deref(), Some("EME-1.0")); + assert_eq!(serde_json::to_value(&entry).unwrap(), json); + } + + #[test] + fn another_scheme_is_refused() { + let json = serde_json::json!({ + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cens", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + }); + assert!(serde_json::from_value::(json).is_err()); + } + + #[test] + fn short_system_names_resolve() { + assert_eq!(system::named("Widevine"), Some(system::WIDEVINE)); + assert_eq!(system::named("primetime"), None); + } +} diff --git a/rs/hang/src/catalog/mod.rs b/rs/hang/src/catalog/mod.rs index 8d792d033dc..e3a6c2b78cb 100644 --- a/rs/hang/src/catalog/mod.rs +++ b/rs/hang/src/catalog/mod.rs @@ -11,6 +11,7 @@ mod clock; mod consumer; mod container; mod contribution; +pub mod drm; mod echo; mod hex; mod json; diff --git a/rs/hang/src/catalog/root.rs b/rs/hang/src/catalog/root.rs index adcc3e90d8b..f04706c6464 100644 --- a/rs/hang/src/catalog/root.rs +++ b/rs/hang/src/catalog/root.rs @@ -91,6 +91,14 @@ pub struct Catalog { /// Omitted from the wire when empty. A malformed entry refuses the catalog. pub contributions: std::collections::BTreeMap, + /// The DRM systems protecting the broadcast's CMAF renditions, keyed by entry ID. + /// + /// A protected video or audio rendition lists the IDs of its entries in its own `drm` field, + /// and one listing an ID missing here is refused by [`check_renditions`](Self::check_renditions). + /// Omitted from the wire when empty. A malformed entry refuses the catalog. See + /// [`drm`](crate::catalog::drm). + pub drm: std::collections::BTreeMap, + /// Application-defined root sections, flattened alongside the base catalog sections. /// /// The root `version` is reserved: serializing computes it from the base sections, and fails if @@ -168,6 +176,9 @@ struct Wire { #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")] contributions: std::collections::BTreeMap, + #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")] + drm: std::collections::BTreeMap, + #[serde(flatten, serialize_with = "serialize_ext")] ext: E, } @@ -203,6 +214,7 @@ impl From> for Catalog { stats, echo, contributions, + drm, ext, } = wire; Self { @@ -216,6 +228,7 @@ impl From> for Catalog { stats, echo, contributions, + drm, ext, } } @@ -270,10 +283,11 @@ impl Catalog<()> { } impl Catalog { - /// Refuse a catalog with an ID naming both a video and an audio rendition, or with a - /// rendition field out of range, such as a zero sample rate or a projection out of bounds. + /// Refuse a catalog with an ID naming both a video and an audio rendition, with a rendition + /// field out of range, such as a zero sample rate or a projection out of bounds, or with a + /// rendition listing a `drm` entry the root lacks. /// - /// Decoding already refuses an out-of-range rendition, so this catches a catalog built by hand. + /// Decoding already refuses an out-of-range rendition, so that catches a catalog built by hand. pub fn check_renditions(&self) -> Result<()> { use crate::catalog::Rendition; @@ -291,6 +305,18 @@ impl Catalog { for config in self.audio.renditions.values() { config.check()?; } + + // A protected rendition whose entry is missing would read as clear, or name no system. + let drm = (self.video.renditions.iter().map(|(id, config)| (id, &config.drm))) + .chain(self.audio.renditions.iter().map(|(id, config)| (id, &config.drm))); + for (rendition, ids) in drm { + if let Some(id) = ids.iter().find(|id| !self.drm.contains_key(*id)) { + return Err(crate::Error::MissingDrm { + rendition: rendition.clone(), + id: id.clone(), + }); + } + } Ok(()) } @@ -318,13 +344,15 @@ impl Catalog { (renamed || warmup).then_some(4) } - /// Copy the media sections into a catalog with no application extension. + /// Copy the media sections, and the `drm` entries they reference, into a catalog with no + /// application extension. pub fn media(&self) -> Catalog<()> { Catalog { video: self.video.clone(), audio: self.audio.clone(), media: self.media, text: self.text.clone(), + drm: self.drm.clone(), ..Default::default() } } @@ -489,6 +517,44 @@ mod test { assert!(failures.is_empty(), "{}", failures.join("\n")); } + /// A protected rendition references a root `drm` entry, which survives a round trip and the + /// media copy; a clear catalog writes no `drm` at all, and a dangling reference is refused. + #[test] + fn drm_entries_round_trip_and_dangling_references_are_refused() { + use crate::catalog::drm; + + let mut catalog = Catalog::<()>::default(); + assert!(!catalog.to_json().unwrap().contains("drm")); + + let kid = uuid::uuid!("a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90"); + catalog.drm.insert( + "1".into(), + drm::Entry::new(drm::system::CLEARKEY, drm::Scheme::Cbcs, kid), + ); + let mut video = VideoConfig::new(H264 { + profile: 0x64, + constraints: 0, + level: 0x1f, + inline: false, + }); + video.container = Container::Cmaf { + init: bytes::Bytes::from_static(b"init"), + }; + video.drm = vec!["1".into()]; + catalog.video.renditions.insert("hd".into(), video); + catalog.check_renditions().unwrap(); + + let decoded = Catalog::<()>::from_str(&catalog.to_json().unwrap()).unwrap(); + assert_eq!(decoded, catalog); + assert_eq!(catalog.media().drm, catalog.drm); + + catalog.drm.clear(); + assert!(matches!( + catalog.check_renditions(), + Err(crate::Error::MissingDrm { rendition, id }) if rendition == "hd" && id == "1" + )); + } + /// The rendition count is the publisher's to choose: a catalog listing many is accepted. #[test] fn many_renditions_are_accepted() { @@ -789,6 +855,7 @@ mod test { reorder: None, optimize_for_latency: None, container: Container::Legacy, + drm: Vec::new(), warmup: None, jitter: Some(std::time::Duration::from_millis(100)), delay: Some(std::time::Duration::from_millis(200)), @@ -811,6 +878,7 @@ mod test { enabled: true, description: None, container: Container::Legacy, + drm: Vec::new(), warmup: None, jitter: Some(std::time::Duration::from_millis(40)), delay: None, diff --git a/rs/hang/src/catalog/video/mod.rs b/rs/hang/src/catalog/video/mod.rs index db21279c4d2..ace83a0e5e2 100644 --- a/rs/hang/src/catalog/video/mod.rs +++ b/rs/hang/src/catalog/video/mod.rs @@ -317,6 +317,15 @@ pub struct VideoConfig { #[serde(default)] pub container: Container, + /// The IDs of the root `drm` entries protecting this rendition, one per DRM system that can + /// decrypt it. Empty means the rendition is clear, and is left off the wire. + /// + /// Only a [`Cmaf`](Container::Cmaf) rendition can be protected: its init segment carries the + /// encrypted sample entry (`encv`/`enca`), while `codec` names the codec it wraps. A consumer + /// that cannot decrypt treats a protected rendition as undecodable. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub drm: Vec, + /// The maximum delay between a frame being ready and the publisher flushing it. /// The player's jitter buffer should be larger than this value. /// If not provided, the player should assume each frame is flushed immediately. @@ -394,6 +403,7 @@ impl VideoConfig { reorder: None, optimize_for_latency: None, container: Container::default(), + drm: Vec::new(), jitter: None, warmup: None, delay: None, diff --git a/rs/hang/src/error.rs b/rs/hang/src/error.rs index ce4a66b5a2e..a811eee2517 100644 --- a/rs/hang/src/error.rs +++ b/rs/hang/src/error.rs @@ -17,6 +17,19 @@ pub enum Error { #[error("catalog rendition ID is both video and audio: {0}")] DuplicateRendition(String), + /// A protected rendition lists a `drm` entry the catalog's root `drm` section lacks. + #[error("rendition {rendition} references missing drm entry {id}")] + MissingDrm { + /// The rendition listing the entry. + rendition: String, + /// The entry ID the root lacks. + id: String, + }, + + /// A Common Encryption scheme other than `cenc` and `cbcs`. + #[error("unsupported encryption scheme: {0}")] + UnsupportedScheme(String), + /// A catalog needs a newer moq-hang draft than this reader implements. #[error("unsupported catalog version {0}: upgrade to read it")] UnsupportedVersion(u64), diff --git a/rs/workspace-hack/Cargo.toml b/rs/workspace-hack/Cargo.toml index 7eed8186016..3ee59cfc7c7 100644 --- a/rs/workspace-hack/Cargo.toml +++ b/rs/workspace-hack/Cargo.toml @@ -129,7 +129,7 @@ typenum = { version = "1", default-features = false, features = ["const-generics url = { version = "2", features = ["serde"] } usage-argv = { version = "7", default-features = false, features = ["complete", "diagnostics", "help-advanced"] } usage-rs = { version = "7", features = ["completions", "config"] } -uuid = { version = "1", features = ["v4", "v7"] } +uuid = { version = "1", features = ["serde", "v4", "v7"] } winnow-dff4ba8e3ae991db = { package = "winnow", version = "1", features = ["simd"] } zeroize = { version = "1", features = ["derive"] } @@ -246,7 +246,7 @@ typenum = { version = "1", default-features = false, features = ["const-generics url = { version = "2", features = ["serde"] } usage-argv = { version = "7", default-features = false, features = ["complete", "diagnostics", "help-advanced"] } usage-rs = { version = "7", features = ["completions", "config"] } -uuid = { version = "1", features = ["v4", "v7"] } +uuid = { version = "1", features = ["serde", "v4", "v7"] } winnow-ca01ad9e24f5d932 = { package = "winnow", version = "0.7" } winnow-dff4ba8e3ae991db = { package = "winnow", version = "1", features = ["simd"] } zeroize = { version = "1", features = ["derive"] } @@ -343,7 +343,6 @@ tokio = { version = "1", default-features = false, features = ["tracing"] } tokio-rustls = { version = "0.26", default-features = false, features = ["aws-lc-rs", "tls12"] } tower = { version = "0.5", default-features = false, features = ["retry", "timeout"] } tower-http = { version = "0.6", default-features = false, features = ["decompression-gzip", "follow-redirect"] } -uuid = { version = "1", default-features = false, features = ["serde"] } zerocopy = { version = "0.8", default-features = false, features = ["derive", "simd"] } [target.aarch64-unknown-linux-gnu.build-dependencies] @@ -376,7 +375,6 @@ tokio = { version = "1", default-features = false, features = ["tracing"] } tokio-rustls = { version = "0.26", default-features = false, features = ["aws-lc-rs", "tls12"] } tower = { version = "0.5", default-features = false, features = ["retry", "timeout"] } tower-http = { version = "0.6", default-features = false, features = ["decompression-gzip", "follow-redirect"] } -uuid = { version = "1", default-features = false, features = ["serde"] } zerocopy = { version = "0.8", default-features = false, features = ["derive", "simd"] } [target.x86_64-pc-windows-msvc.dependencies] @@ -447,7 +445,6 @@ tokio = { version = "1", default-features = false, features = ["tracing"] } tokio-rustls = { version = "0.26", default-features = false, features = ["aws-lc-rs", "tls12"] } tower = { version = "0.5", default-features = false, features = ["retry", "timeout"] } tower-http = { version = "0.6", default-features = false, features = ["decompression-gzip", "follow-redirect"] } -uuid = { version = "1", default-features = false, features = ["serde"] } zerocopy = { version = "0.8", default-features = false, features = ["derive", "simd"] } [target.x86_64-unknown-linux-gnu.build-dependencies] @@ -480,7 +477,6 @@ tokio = { version = "1", default-features = false, features = ["tracing"] } tokio-rustls = { version = "0.26", default-features = false, features = ["aws-lc-rs", "tls12"] } tower = { version = "0.5", default-features = false, features = ["retry", "timeout"] } tower-http = { version = "0.6", default-features = false, features = ["decompression-gzip", "follow-redirect"] } -uuid = { version = "1", default-features = false, features = ["serde"] } zerocopy = { version = "0.8", default-features = false, features = ["derive", "simd"] } ### END HAKARI SECTION From ce4cc8668c4187d728774b60ffe0020968c1fb6a Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 17:21:19 +0100 Subject: [PATCH 03/23] feat(msf): read and write CMSF content protection moq-msf reads and writes draft-ietf-moq-cmsf section 4: the root contentProtections array and each track's contentProtectionRefIDs, refusing a track that references an entry the root lacks, like a missing initRef. The draft names no member for the authorization URL or robustness, so neither is carried. Co-Authored-By: Claude Opus 5.5 --- rs/moq-msf/src/lib.rs | 213 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 211 insertions(+), 2 deletions(-) diff --git a/rs/moq-msf/src/lib.rs b/rs/moq-msf/src/lib.rs index 1d577a6d7f6..74d5801d24f 100644 --- a/rs/moq-msf/src/lib.rs +++ b/rs/moq-msf/src/lib.rs @@ -56,6 +56,12 @@ pub struct Catalog { /// The tracks in this catalog snapshot. pub tracks: Vec, + /// The DRM systems protecting this broadcast's tracks (CMSF 4.1.1). + /// + /// Tracks point at these entries by [`ContentProtection::ref_id`] through + /// [`Track::content_protection_ref_ids`]; an entry is never repeated on a track. + pub content_protections: Vec, + /// The application extension: root members beyond the ones MSF defines. pub ext: E, } @@ -89,7 +95,8 @@ pub struct Catalog { /// `serde_json::Map`, which keeps them verbatim. /// /// An extension MUST NOT name a member after one MSF defines (`version`, `generatedAt`, -/// `isComplete`, `tracks`, `initDataList`); the wire JSON would carry a duplicate key. +/// `isComplete`, `tracks`, `initDataList`, `contentProtections`); the wire JSON would carry a +/// duplicate key. pub trait CatalogExt: Serialize + serde::de::DeserializeOwned + Default + Clone + Send + Unpin + 'static {} // Blanket, so a caller writes no impl: naming the trait is only about readable bounds. @@ -185,6 +192,11 @@ pub struct Track { #[serde(rename = "maxObjSapStartingType")] pub max_obj_sap_starting_type: Option, + /// The [`ContentProtection::ref_id`]s of the catalog's entries that protect this track + /// (CMSF 4.1.2). Empty means the track is not encrypted with Common Encryption. + #[serde(default, rename = "contentProtectionRefIDs", skip_serializing_if = "Vec::is_empty")] + pub content_protection_ref_ids: Vec, + /// Jitter (non-standard extension; not in the MSF/CMSF drafts). /// /// Serialized as a JSON number of milliseconds, matching the hang catalog. @@ -217,6 +229,7 @@ impl Catalog { generated_at: None, is_complete: false, tracks, + content_protections: Vec::new(), ext, } } @@ -261,7 +274,7 @@ fn colliding_member(ext: &E) -> Option { pub fn reserved_root(name: &str) -> bool { matches!( name, - "version" | "generatedAt" | "isComplete" | "tracks" | "initDataList" + "version" | "generatedAt" | "isComplete" | "tracks" | "initDataList" | "contentProtections" ) } @@ -312,6 +325,7 @@ impl Serialize for Catalog { is_complete: self.is_complete, tracks, init_data_list: (!init_data_list.is_empty()).then_some(init_data_list), + content_protections: self.content_protections.clone(), ext: self.ext.clone(), } .serialize(serializer) @@ -338,6 +352,21 @@ impl<'de, E: CatalogExt> Deserialize<'de> for Catalog { } } + // A track's protection refers to a root entry by refID; one that names none would claim + // encryption the catalog cannot describe, so it is refused like a missing initRef. + for track in &wire.tracks { + if let Some(missing) = track + .content_protection_ref_ids + .iter() + .find(|id| !wire.content_protections.iter().any(|cp| &cp.ref_id == *id)) + { + return Err(serde::de::Error::custom(format!( + "MSF track {:?} references missing content protection {:?}", + track.name, missing + ))); + } + } + let tracks = wire .tracks .into_iter() @@ -380,6 +409,7 @@ impl<'de, E: CatalogExt> Deserialize<'de> for Catalog { generated_at: wire.generated_at, is_complete: wire.is_complete, tracks, + content_protections: wire.content_protections, ext: wire.ext, }) } @@ -402,6 +432,8 @@ struct Wire { #[serde(default)] tracks: Vec, init_data_list: Option>, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + content_protections: Vec, /// The extension's own root members, written flat alongside the ones above. #[serde(flatten)] @@ -508,12 +540,111 @@ impl Track { alt_group: None, max_grp_sap_starting_type: None, max_obj_sap_starting_type: None, + content_protection_ref_ids: Vec::new(), jitter: None, delay: None, } } } +/// One DRM system configuration protecting tracks of the broadcast (CMSF 4.1.1). +/// +/// The samples are encrypted with ISO Common Encryption; the track's initialization data +/// carries the matching `sinf`/`tenc` (CMSF 4.2). draft-ietf-moq-cmsf-01 names no member for +/// its authorization URL (4.1.1.4.4) or robustness (4.1.1.4.6), so neither is carried. +#[serde_with::skip_serializing_none] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] +pub struct ContentProtection { + /// The identifier tracks use to reference this entry. + #[serde(rename = "refID")] + pub ref_id: String, + + /// The default key IDs (`default_KID`) as UUID strings. + #[serde(rename = "defaultKID")] + pub default_kid: Vec, + + /// The Common Encryption scheme, `cenc` or `cbcs`. + pub scheme: String, + + /// The DRM system and where to obtain its license. + #[serde(rename = "drmSystem")] + pub drm_system: DrmSystem, +} + +impl ContentProtection { + /// An entry with the required fields; the DRM system's optional fields start empty. + pub fn new( + ref_id: impl Into, + default_kid: Vec, + scheme: impl Into, + system_id: impl Into, + ) -> Self { + Self { + ref_id: ref_id.into(), + default_kid, + scheme: scheme.into(), + drm_system: DrmSystem::new(system_id), + } + } +} + +/// A DRM system description within a [`ContentProtection`] (CMSF 4.1.1.4). +#[serde_with::skip_serializing_none] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] +pub struct DrmSystem { + /// The DRM system ID as a UUID string, e.g. Widevine's `edef8ba9-79d6-4ace-a3c8-27dcd51d21ed`. + #[serde(rename = "systemID")] + pub system_id: String, + + /// The license acquisition service. + #[serde(rename = "laURL")] + pub la_url: Option, + + /// The certificate service, required by systems such as FairPlay Streaming. + #[serde(rename = "certURL")] + pub cert_url: Option, + + /// A base64 `pssh` box with the system's initialization data. + pub pssh: Option, +} + +impl DrmSystem { + /// A DRM system with only its ID set. + pub fn new(system_id: impl Into) -> Self { + Self { + system_id: system_id.into(), + la_url: None, + cert_url: None, + pssh: None, + } + } +} + +/// A service URL in a [`DrmSystem`], with an optional protocol or MIME type. +#[serde_with::skip_serializing_none] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] +pub struct ProtectionUrl { + /// The service URL. + pub url: String, + + /// The protocol or MIME type, e.g. `EME-1.0`. + #[serde(rename = "type")] + pub kind: Option, +} + +impl ProtectionUrl { + /// A URL without a type. + pub fn new(url: impl Into) -> Self { + Self { + url: url.into(), + kind: None, + } + } +} + /// Packaging mode for an MSF track. #[derive(Debug, Clone, PartialEq, Eq)] pub enum Packaging { @@ -638,6 +769,81 @@ impl<'de> Deserialize<'de> for Role { #[cfg(test)] mod test { + /// The protected-video example of draft-ietf-moq-cmsf-01 section 5.2, trimmed to two DRM + /// systems, survives a parse and a serialize unchanged. + #[test] + fn content_protection_round_trips() { + let json = r#"{ + "version": "draft-01", + "contentProtections": [ + { + "refID": "1", + "defaultKID": ["01234567-89ab-cdef-0123-456789abcdef"], + "scheme": "cbcs", + "drmSystem": { + "systemID": "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed", + "laURL": { "url": "https://widevine-license.example.com/proxy" }, + "pssh": "AAAAP3Bzc2gAAAAA7e+LqXnWSs6jy" + } + }, + { + "refID": "3", + "defaultKID": ["01234567-89ab-cdef-0123-456789abcdef"], + "scheme": "cbcs", + "drmSystem": { + "systemID": "94ce86fb-07ff-4f43-adb8-93d2fa968ca2", + "laURL": { "url": "https://fps-license.example.com/api/licenses" }, + "certURL": { "url": "https://fps-license.example.com/cert", "type": "application/pkcs7-mime" } + } + } + ], + "tracks": [ + { "name": "video_protected", "packaging": "cmaf", "isLive": true, "codec": "avc3.4D401F", "contentProtectionRefIDs": ["1", "3"] }, + { "name": "audio", "packaging": "cmaf", "isLive": true, "codec": "mp4a.40.2" } + ] + }"#; + let catalog: super::Catalog = json.parse().unwrap(); + assert_eq!(catalog.content_protections.len(), 2); + let fairplay = &catalog.content_protections[1].drm_system; + assert_eq!( + fairplay.cert_url.as_ref().unwrap().kind.as_deref(), + Some("application/pkcs7-mime") + ); + assert_eq!(catalog.tracks[0].content_protection_ref_ids, ["1", "3"]); + assert!(catalog.tracks[1].content_protection_ref_ids.is_empty()); + + let again: super::Catalog = catalog.to_json().unwrap().parse().unwrap(); + assert_eq!(again, catalog); + let wire: serde_json::Value = serde_json::from_str(&catalog.to_json().unwrap()).unwrap(); + assert!( + wire["tracks"][1].get("contentProtectionRefIDs").is_none(), + "an unprotected track carries no refs" + ); + assert_eq!( + wire["contentProtections"][0]["drmSystem"]["systemID"], + "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" + ); + } + + /// A catalog without protection writes no `contentProtections` member at all. + #[test] + fn no_protection_writes_nothing() { + let catalog = super::Catalog::new(vec![super::Track::new("video", super::Packaging::Cmaf)]); + let wire: serde_json::Value = serde_json::from_str(&catalog.to_json().unwrap()).unwrap(); + assert!(wire.get("contentProtections").is_none()); + assert!(wire["tracks"][0].get("contentProtectionRefIDs").is_none()); + } + + /// A track that references an entry the root lacks is refused, like a missing initRef. + #[test] + fn a_dangling_protection_ref_is_refused() { + let json = r#"{ "version": "draft-01", "tracks": [ + { "name": "video", "packaging": "cmaf", "isLive": true, "contentProtectionRefIDs": ["9"] } + ] }"#; + let err = json.parse::().unwrap_err().to_string(); + assert!(err.contains("missing content protection"), "{err}"); + } + #[test] fn track_namespace_round_trips() { for version in ["1", "\"draft-01\""] { @@ -674,6 +880,7 @@ mod test { alt_group: None, max_grp_sap_starting_type: None, max_obj_sap_starting_type: None, + content_protection_ref_ids: Vec::new(), jitter: None, delay: None, } @@ -701,6 +908,7 @@ mod test { alt_group: None, max_grp_sap_starting_type: None, max_obj_sap_starting_type: None, + content_protection_ref_ids: Vec::new(), jitter: None, delay: None, } @@ -728,6 +936,7 @@ mod test { alt_group: None, max_grp_sap_starting_type: Some(1), max_obj_sap_starting_type: Some(2), + content_protection_ref_ids: Vec::new(), jitter: Some(Duration::from_millis(15)), delay: None, } From 4ff8916d593675abe1dfb1fa6b29082b870a3fdf Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 17:35:10 +0100 Subject: [PATCH 04/23] feat(mux): import Common Encryption fMP4 in passthrough fmp4::Import with passthrough publishes cenc and cbcs media unchanged. Each protected track's init keeps its encv/enca entry and the moov's pssh boxes that apply to its key, the rendition's codec is the one frma names, and the catalog's drm section gets one entry per DRM system, scheme and key, shared by tracks under the same key. Import::with_drm sets a system's license and certificate servers, and a system no encrypted track carries is refused. Re-encoding a fragment moves its senc, so saio is pointed at the rebuilt one. An edit list that drops samples, such as Shaka's AAC priming edit, restates senc and saiz for the kept samples. Refused rather than published undecryptable: encrypted input without passthrough, an encrypted track without a pssh, encryption information outside senc or over several saio, key rotation (pssh in a moof, or a seig sample group; roll groups pass), a clear lead, and schemes other than cenc and cbcs. The MSF catalog renders the drm section as CMSF contentProtections and contentProtectionRefIDs, and parsing one maps them back; an entry with several default keys becomes one hang entry per key. Fixtures: the ClearKey cenc file (ffmpeg plus a ClearKey pssh) and Shaka Packager 3.9.3 cbcs video and audio, trimmed to their first fragments. Co-Authored-By: Claude Opus 5.5 --- rs/hang/src/catalog/drm.rs | 25 ++ rs/moq-mux/MIGRATE.md | 8 + rs/moq-mux/src/catalog/msf/consumer.rs | 158 ++++++- rs/moq-mux/src/catalog/msf/mod.rs | 11 + rs/moq-mux/src/catalog/producer.rs | 30 +- rs/moq-mux/src/container/fmp4/cenc.rs | 331 ++++++++++++++ rs/moq-mux/src/container/fmp4/import.rs | 184 +++++++- rs/moq-mux/src/container/fmp4/import_test.rs | 423 ++++++++++++++++++ rs/moq-mux/src/container/fmp4/mod.rs | 32 ++ .../container/fmp4/test_data/cbcs-audio.mp4 | Bin 0 -> 17948 bytes .../container/fmp4/test_data/cbcs-video.mp4 | Bin 0 -> 35053 bytes .../fmp4/test_data/cenc-clearkey.mp4 | Bin 0 -> 40861 bytes 12 files changed, 1179 insertions(+), 23 deletions(-) create mode 100644 rs/moq-mux/src/container/fmp4/cenc.rs create mode 100644 rs/moq-mux/src/container/fmp4/test_data/cbcs-audio.mp4 create mode 100644 rs/moq-mux/src/container/fmp4/test_data/cbcs-video.mp4 create mode 100644 rs/moq-mux/src/container/fmp4/test_data/cenc-clearkey.mp4 diff --git a/rs/hang/src/catalog/drm.rs b/rs/hang/src/catalog/drm.rs index 785e9668778..c805db52400 100644 --- a/rs/hang/src/catalog/drm.rs +++ b/rs/hang/src/catalog/drm.rs @@ -25,6 +25,9 @@ use bytes::Bytes; use serde::{Deserialize, Serialize}; use serde_with::{base64::Base64, serde_as}; +/// Re-export of the [`uuid`] crate's UUID, which system and key IDs are. +pub use uuid::Uuid; + /// Well-known DRM system IDs, as draft-ietf-moq-cmsf lists them. pub mod system { /// Google Widevine. @@ -169,6 +172,28 @@ impl std::str::FromStr for Scheme { } } +/// The servers a publisher supplies for one DRM system, which the media does not carry. +/// +/// An importer copies them into each [`Entry`] of that system. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +#[non_exhaustive] +pub struct Servers { + /// Where to request a license. + pub license: Option, + /// Where to fetch the server certificate. + pub certificate: Option, +} + +impl Servers { + /// A license server and no certificate server. + pub fn license(url: url::Url) -> Self { + Self { + license: Some(Server::new(url)), + certificate: None, + } + } +} + /// A license or certificate server. /// /// Marked `#[non_exhaustive]` so optional fields can be added later. External callers build one diff --git a/rs/moq-mux/MIGRATE.md b/rs/moq-mux/MIGRATE.md index fa580fcf187..55f94969378 100644 --- a/rs/moq-mux/MIGRATE.md +++ b/rs/moq-mux/MIGRATE.md @@ -4,6 +4,14 @@ How to adopt new APIs and update for breaking changes, newest first. ## Unreleased +### Protected CMAF import and the mp4-atom bump + +`fmp4::Import` with passthrough publishes Common Encryption (`cenc` and `cbcs`) fMP4 instead of refusing its `encv`/`enca` entries, filling the catalog's `drm` section; set license and certificate servers with `Import::with_drm`. +Without passthrough, an encrypted file now fails with `fmp4::Error::ProtectedNeedsPassthrough` rather than `UnsupportedCodec`. + +The re-exported `fmp4::mp4_atom` moves to the release with Common Encryption's boxes: a sample entry's `colr` is a `Vec`, `Moov` and `Moof` gain `pssh: Vec`, and `Codec` gains `Encv` and `Enca`. +Build a `Moov` or `Moof` literal with `pssh: Vec::new()`, and match the new `Codec` variants. + ### Shared playout timing Native players can use `timeline::Producer` and its read-only `Consumer` instead diff --git a/rs/moq-mux/src/catalog/msf/consumer.rs b/rs/moq-mux/src/catalog/msf/consumer.rs index bb9ffb3a9da..8939b0b5fb0 100644 --- a/rs/moq-mux/src/catalog/msf/consumer.rs +++ b/rs/moq-mux/src/catalog/msf/consumer.rs @@ -111,9 +111,16 @@ impl From for Consumer { /// Fields with no representation in `hang::Catalog` (`generated_at`, `is_complete`, `is_live`, /// `render_group`, `alt_group`, `max_grp_sap_starting_type`, `max_obj_sap_starting_type`) are /// dropped. +/// +/// `contentProtections` become the `drm` section, each `refID` an entry ID, and a track's +/// `contentProtectionRefIDs` its rendition's `drm`. An entry naming several default keys becomes +/// one hang entry per key, `{refID}:{kid}`, and a track lists the one its init's `tenc` uses (all +/// of them when the init names none). pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net::Path) -> Result> { let mut catalog = Catalog::default(); catalog.ext = msf.ext.clone(); + let protections = Protections::from_msf(msf)?; + catalog.drm = protections.entries.clone(); for track in &msf.tracks { // The track name is the rendition ID, so a later track with the name replaces the earlier @@ -146,6 +153,7 @@ pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net: moq_msf::Role::Video => match video_config_from_msf(track)? { Some(mut config) => { config.broadcast = broadcast; + config.drm = protections.track(track, &config.container); catalog.video.renditions.insert(track.name.clone(), config); } None => { @@ -159,6 +167,7 @@ pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net: moq_msf::Role::Audio => match audio_config_from_msf(track)? { Some(mut config) => { config.broadcast = broadcast; + config.drm = protections.track(track, &config.container); catalog.audio.renditions.insert(track.name.clone(), config); } None => { @@ -188,6 +197,101 @@ pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net: Ok(catalog) } +/// An MSF catalog's `contentProtections` as hang `drm` entries. +struct Protections { + /// The hang entries, by ID. + entries: std::collections::BTreeMap, + /// Each `refID`'s hang entries, with the default key each one is for. + by_ref: std::collections::HashMap>, +} + +impl Protections { + fn from_msf(msf: &moq_msf::Catalog) -> Result { + use hang::catalog::drm; + + let mut entries = std::collections::BTreeMap::new(); + let mut by_ref = std::collections::HashMap::>::new(); + for cp in &msf.content_protections { + let invalid = |reason| Error::InvalidContentProtection { + ref_id: cp.ref_id.clone(), + reason, + }; + let system = drm::Uuid::try_parse(&cp.drm_system.system_id).map_err(|_| invalid("malformed systemID"))?; + let scheme: drm::Scheme = cp.scheme.parse().map_err(|_| invalid("unsupported scheme"))?; + let server = |url: &moq_msf::ProtectionUrl| -> Result { + let mut server = drm::Server::new(url.url.parse().map_err(|_| invalid("malformed URL"))?); + server.kind = url.kind.clone(); + Ok(server) + }; + let license = cp.drm_system.la_url.as_ref().map(server).transpose()?; + let certificate = cp.drm_system.cert_url.as_ref().map(server).transpose()?; + let pssh = (cp.drm_system.pssh.as_ref()) + .map(|pssh| base64::engine::general_purpose::STANDARD.decode(pssh)) + .transpose() + .map_err(|_| invalid("malformed pssh"))?; + if cp.default_kid.is_empty() { + return Err(invalid("no defaultKID").into()); + } + + let split = by_ref.entry(cp.ref_id.clone()).or_default(); + for kid in &cp.default_kid { + let kid = drm::Uuid::try_parse(kid).map_err(|_| invalid("malformed defaultKID"))?; + let id = match cp.default_kid.len() { + 1 => cp.ref_id.clone(), + _ => format!("{}:{}", cp.ref_id, kid.hyphenated()), + }; + let mut entry = drm::Entry::new(system, scheme, kid); + entry.license = license.clone(); + entry.certificate = certificate.clone(); + entry.pssh = pssh.clone().map(Into::into); + entries.insert(id.clone(), entry); + split.push((id, kid)); + } + } + Ok(Self { entries, by_ref }) + } + + /// The hang entry IDs protecting `track`, whose CMAF init is in `container`. + fn track(&self, track: &moq_msf::Track, container: &Container) -> Vec { + let kid = match container { + Container::Cmaf { init } => init_kid(init), + _ => None, + }; + let mut ids = Vec::new(); + // moq-msf refuses a refID the root lacks. + for split in track + .content_protection_ref_ids + .iter() + .filter_map(|id| self.by_ref.get(id)) + { + let matching: Vec<_> = split.iter().filter(|(_, other)| Some(*other) == kid).collect(); + let chosen = match (split.len(), matching.is_empty()) { + (1, _) | (_, true) => split.iter().collect(), + _ => matching, + }; + ids.extend(chosen.into_iter().map(|(id, _)| id.clone())); + } + ids + } +} + +/// The default key ID an encrypted CMAF init's `tenc` names, if any. +fn init_kid(init: &[u8]) -> Option { + use mp4_atom::{Any, DecodeMaybe}; + + let mut cursor = std::io::Cursor::new(init); + while let Ok(Some(atom)) = Any::decode_maybe(&mut cursor) { + if let Any::Moov(moov) = atom { + let sinf = (moov.trak.iter()) + .flat_map(|trak| &trak.mdia.minf.stbl.stsd.codecs) + .find_map(crate::container::fmp4::cenc::sinf)?; + let tenc = sinf.schi.as_ref()?.tenc.as_ref()?; + return Some(hang::catalog::drm::Uuid::from_bytes(tenc.default_kid)); + } + } + None +} + /// Decode the [`Container`] for a track based on its packaging and `init_data`. /// /// Returns `Ok(None)` when the packaging is unsupported (e.g. `MediaTimeline`, @@ -432,7 +536,9 @@ fn cmaf_moov(track: &moq_msf::Track, init: &[u8]) -> Result { fn cmaf_video_description(track: &moq_msf::Track, init: &[u8], codec: &VideoCodec) -> Result> { use mp4_atom::{Atom, Codec}; let moov = cmaf_moov(track, init)?; - for sample in moov.trak.iter().flat_map(|trak| &trak.mdia.minf.stbl.stsd.codecs) { + let samples = moov.trak.iter().flat_map(|trak| &trak.mdia.minf.stbl.stsd.codecs); + // A protected entry wraps the codec the catalog names. + for sample in samples.map(crate::container::fmp4::cenc::clear) { let mut description = bytes::BytesMut::new(); match (codec, sample) { ( @@ -462,7 +568,7 @@ fn derive_from_cmaf_moov(track: &moq_msf::Track, init: bytes::Bytes) -> Result { return Ok(DerivedAudio { @@ -485,6 +591,54 @@ fn derive_from_cmaf_moov(track: &moq_msf::Track, init: bytes::Bytes) -> Result(catalog: &hang::Catalog, base: &moq_net::Path) -> track.alt_group = if has_multiple_video { Some(1) } else { None }; track.max_grp_sap_starting_type = sap_type; track.max_obj_sap_starting_type = sap_type; + track.content_protection_ref_ids = config.drm.clone(); track.jitter = config.jitter; track.delay = config.delay.filter(|delay| !delay.is_zero()); tracks.push(track); @@ -1405,6 +1406,7 @@ fn to_msf_media(catalog: &hang::Catalog, base: &moq_net::Path) -> track.alt_group = if has_multiple_audio { Some(1) } else { None }; track.max_grp_sap_starting_type = Some(1); track.max_obj_sap_starting_type = Some(1); + track.content_protection_ref_ids = config.drm.clone(); track.jitter = config.jitter; track.delay = config.delay.filter(|delay| !delay.is_zero()); tracks.push(track); @@ -1442,7 +1444,33 @@ fn to_msf_media(catalog: &hang::Catalog, base: &moq_net::Path) -> } } } - moq_msf::Catalog::with_ext(unique, E::default()) + let mut msf = moq_msf::Catalog::with_ext(unique, E::default()); + msf.content_protections = catalog + .drm + .iter() + .map(|(id, entry)| content_protection(id, entry)) + .collect(); + msf +} + +/// A hang `drm` entry as the CMSF `contentProtections` entry it mirrors (draft-ietf-moq-cmsf +/// section 4.1.1), its ID becoming the `refID` tracks reference. +fn content_protection(id: &str, entry: &hang::catalog::drm::Entry) -> moq_msf::ContentProtection { + let server = |server: &hang::catalog::drm::Server| { + let mut url = moq_msf::ProtectionUrl::new(server.url.as_str()); + url.kind = server.kind.clone(); + url + }; + let mut msf = moq_msf::ContentProtection::new( + id, + vec![entry.kid.hyphenated().to_string()], + entry.scheme.as_str(), + entry.system.hyphenated().to_string(), + ); + msf.drm_system.la_url = entry.license.as_ref().map(server); + msf.drm_system.cert_url = entry.certificate.as_ref().map(server); + msf.drm_system.pssh = (entry.pssh.as_ref()).map(|pssh| base64::engine::general_purpose::STANDARD.encode(pssh)); + msf } #[cfg(test)] diff --git a/rs/moq-mux/src/container/fmp4/cenc.rs b/rs/moq-mux/src/container/fmp4/cenc.rs new file mode 100644 index 00000000000..95893efdafa --- /dev/null +++ b/rs/moq-mux/src/container/fmp4/cenc.rs @@ -0,0 +1,331 @@ +//! Common Encryption (ISO/IEC 23001-7) passthrough: what an encrypted track's init declares, and +//! the checks that keep a republished fragment decryptable. + +use hang::catalog::drm; +use mp4_atom::{Atom, Encode, FourCC}; + +use super::Error; +use crate::Result; + +/// The `seig` sample group: per-sample key IDs, which is key rotation. +const SEIG: FourCC = FourCC::new(b"seig"); + +/// What an encrypted track's sample entry and its moov declare. +#[derive(Debug, Clone)] +pub(crate) struct Protection { + /// The scheme `schm` names. + pub scheme: drm::Scheme, + /// `tenc`'s default key ID. + pub kid: [u8; 16], + /// The moov's `pssh` boxes that apply to this track, in their order there. + pub pssh: Vec, + /// How each fragment's encryption information is laid out. + pub aux: Aux, +} + +/// How an encrypted track's `senc` lays out each sample's encryption information. +#[derive(Debug, Clone, Copy)] +pub(crate) struct Aux { + /// The size of each sample's IV, 0 under a constant IV. + iv_size: u8, +} + +impl Protection { + /// The protection of `trak`'s sample entry, or `None` when it is clear. + /// + /// Refuses a clear lead (an encrypted entry beside another), a scheme other than `cenc` or + /// `cbcs`, key rotation declared in the sample table, and an encrypted track that no `pssh` + /// applies to, since the catalog could name no DRM system for it. + pub fn of(trak: &mp4_atom::Trak, moov: &mp4_atom::Moov) -> Result> { + let stbl = &trak.mdia.minf.stbl; + let codecs = &stbl.stsd.codecs; + let Some(sinf) = codecs.iter().find_map(sinf) else { + return Ok(None); + }; + // A clear lead: an encrypted entry beside a clear one, refused as several codecs are. + if codecs.len() > 1 { + return Err(Error::MultipleCodecs.into()); + } + + let schm = sinf + .schm + .as_ref() + .ok_or(Error::InvalidProtection("protected sample entry without schm"))?; + let scheme = match &<[u8; 4]>::from(schm.scheme_type) { + b"cenc" => drm::Scheme::Cenc, + b"cbcs" => drm::Scheme::Cbcs, + _ => return Err(Error::UnsupportedScheme(schm.scheme_type).into()), + }; + // mp4-atom refuses a cenc or cbcs sinf without a tenc. + let tenc = sinf + .schi + .as_ref() + .and_then(|schi| schi.tenc.as_ref()) + .ok_or(Error::InvalidProtection("protected sample entry without tenc"))?; + + if rotates(&stbl.sgpd, &stbl.sbgp) { + return Err(Error::KeyRotation.into()); + } + + let kid = tenc.default_kid; + // A version 0 pssh applies to every key; a version 1 one names the keys it covers. + let pssh: Vec<_> = (moov.pssh.iter()) + .filter(|pssh| { + pssh.kid + .as_ref() + .is_none_or(|kids| kids.is_empty() || kids.contains(&kid)) + }) + .cloned() + .collect(); + if pssh.is_empty() { + return Err(Error::MissingPssh.into()); + } + + let aux = Aux { + iv_size: tenc.default_per_sample_iv_size, + }; + Ok(Some(Self { scheme, kid, pssh, aux })) + } + + /// How the track's fragments lay out their encryption information. + pub fn aux(&self) -> Aux { + self.aux + } + + /// One catalog entry per DRM system, with that system's first `pssh` box. + pub fn entries(&self) -> Result> { + let mut entries: Vec = Vec::new(); + for pssh in &self.pssh { + let system = drm::Uuid::from_bytes(pssh.system_id); + if entries.iter().any(|entry| entry.system == system) { + continue; + } + let mut entry = drm::Entry::new(system, self.scheme, drm::Uuid::from_bytes(self.kid)); + let mut buf = Vec::new(); + pssh.encode(&mut buf).map_err(Error::from)?; + entry.pssh = Some(buf.into()); + entries.push(entry); + } + Ok(entries) + } +} + +impl Aux { + /// Restate `source`'s encryption information in `kept`, the same fragment holding only the + /// samples at `indices`, ascending positions among `source`'s samples. + /// + /// The edit list drops samples a packager kept for decoding, such as AAC's priming frame, + /// and the samples that remain still need their IVs and subsample maps. + pub fn restate(&self, source: &mp4_atom::Traf, kept: &mut mp4_atom::Traf, indices: &[usize]) -> Result<()> { + let Some(senc) = &source.senc else { + // Nothing per sample to keep: a constant IV over whole samples. Information elsewhere + // is refused, as it is for any fragment. + if source.saio.iter().any(|saio| is_cenc(saio.aux_info.as_ref())) { + return Err(Error::InvalidProtection("encryption auxiliary information outside senc").into()); + } + return Ok(()); + }; + if senc.version != mp4_atom::SencBoxVersion::V0 { + return Err(Error::InvalidProtection("unsupported senc version").into()); + } + + let entries = self.entries(senc)?; + if entries.len() as u64 != super::sample::count(source) { + return Err(Error::InvalidProtection("senc and trun disagree on the sample count").into()); + } + let mut data = Vec::with_capacity(senc.data.len()); + data.extend_from_slice(&(indices.len() as u32).to_be_bytes()); + for &index in indices { + let entry = entries + .get(index) + .ok_or(Error::InvalidProtection("senc lacks a sample"))?; + data.extend_from_slice(entry); + } + kept.senc = Some(mp4_atom::Senc { + version: senc.version.clone(), + use_subsamples: senc.use_subsamples, + data, + }); + + let mut saiz = source.saiz.iter().filter(|saiz| is_cenc(saiz.aux_info.as_ref())); + if let Some(saiz) = saiz.next() { + if saiz.default_sample_info_size == 0 { + let sizes = (indices.iter()) + .map(|&index| saiz.sample_info_size.get(index).copied()) + .collect::>>() + .ok_or(Error::InvalidProtection("saiz lacks a sample"))?; + kept.saiz.push(mp4_atom::Saiz { + aux_info: saiz.aux_info.clone(), + default_sample_info_size: 0, + sample_count: indices.len() as u32, + sample_info_size: sizes, + }); + } else { + kept.saiz.push(mp4_atom::Saiz { + aux_info: saiz.aux_info.clone(), + default_sample_info_size: saiz.default_sample_info_size, + sample_count: indices.len() as u32, + sample_info_size: Vec::new(), + }); + } + } + // Several would be refused by `reserve_saio` on the source's own fragments too. + if saiz.next().is_some() { + return Err(Error::InvalidProtection("encryption auxiliary information split over several saiz").into()); + } + kept.saio = (source.saio.iter()) + .filter(|saio| is_cenc(saio.aux_info.as_ref())) + .cloned() + .collect(); + Ok(()) + } + + /// Each sample's encryption information in `senc`: its IV, then its subsample map when + /// `senc` carries them. + fn entries<'a>(&self, senc: &'a mp4_atom::Senc) -> Result> { + let malformed = || Error::InvalidProtection("malformed senc"); + let data = senc.data.as_slice(); + let count = data.get(..4).ok_or_else(malformed)?; + let count = u32::from_be_bytes(count.try_into().expect("four bytes")) as usize; + // A constant IV over whole samples leaves every entry empty, so the count is bounded by + // what a fragment may hold rather than by the box's size. + if count as u64 > super::MAX_FRAGMENT_SAMPLES { + return Err(malformed().into()); + } + let mut entries = Vec::with_capacity(count); + let mut position = 4; + for _ in 0..count { + let start = position; + position += self.iv_size as usize; + if senc.use_subsamples { + let subsamples = data.get(position..position + 2).ok_or_else(malformed)?; + let subsamples = u16::from_be_bytes(subsamples.try_into().expect("two bytes")) as usize; + // Each subsample is a 16-bit clear and a 32-bit protected byte count. + position += 2 + subsamples * 6; + } + entries.push(data.get(start..position).ok_or_else(malformed)?); + } + if position != data.len() { + return Err(malformed().into()); + } + Ok(entries) + } +} + +/// The `sinf` of an encrypted sample entry, `None` for a clear one. +pub(crate) fn sinf(codec: &mp4_atom::Codec) -> Option<&mp4_atom::Sinf> { + match codec { + mp4_atom::Codec::Encv(encv) => Some(&encv.sinf), + mp4_atom::Codec::Enca(enca) => Some(&enca.sinf), + _ => None, + } +} + +/// The sample entry an encrypted one wraps, or `codec` itself when it is clear. +/// +/// The catalog names a protected rendition by this codec, as MSE and EME expect. +pub(crate) fn clear(codec: &mp4_atom::Codec) -> &mp4_atom::Codec { + match codec { + mp4_atom::Codec::Encv(encv) => &encv.codec, + mp4_atom::Codec::Enca(enca) => &enca.codec, + codec => codec, + } +} + +/// Whether sample groups assign keys per sample (`seig`), which is key rotation. +/// +/// Other groups, such as AAC's `roll`, say nothing about keys and pass through. +fn rotates(sgpd: &[mp4_atom::Sgpd], sbgp: &[mp4_atom::Sbgp]) -> bool { + sgpd.iter().any(|sgpd| sgpd.grouping_type == SEIG) || sbgp.iter().any(|sbgp| sbgp.grouping_type == SEIG) +} + +/// Refuse a fragment of an encrypted track whose keys rotate: a `pssh` in its `moof`, or a `seig` +/// sample group in its `traf`. +pub(crate) fn check_moof(moof: &mp4_atom::Moof, traf: &mp4_atom::Traf) -> Result<()> { + if !moof.pssh.is_empty() || rotates(&traf.sgpd, &traf.sbgp) { + return Err(Error::KeyRotation.into()); + } + Ok(()) +} + +/// Whether `saio` addresses Common Encryption's auxiliary information: an untyped one (which an +/// encrypted track's scheme types) or one typed by a Common Encryption scheme. +fn is_cenc(aux: Option<&mp4_atom::AuxInfo>) -> bool { + aux.is_none_or(|aux| { + matches!( + &<[u8; 4]>::from(aux.aux_info_type), + b"cenc" | b"cbc1" | b"cens" | b"cbcs" + ) + }) +} + +/// Prepare an encrypted track's fragment for re-encoding: refuse auxiliary information the +/// rebuilt fragment would lose, and reserve the one `saio` offset [`point_saio`] fills in. +/// +/// The per-sample IVs and subsample maps must sit in the fragment's `senc`, which the rebuilt +/// fragment carries; ones only in the source's `mdat`, or split over several `saio` boxes, would be +/// lost or misaddressed. +pub(crate) fn reserve_saio(traf: &mut mp4_atom::Traf) -> Result<()> { + let count = traf.saio.iter().filter(|saio| is_cenc(saio.aux_info.as_ref())).count(); + match (traf.senc.is_some(), count) { + (_, 0) => Ok(()), + (false, _) => Err(Error::InvalidProtection("encryption auxiliary information outside senc").into()), + (true, 1) => { + for saio in traf.saio.iter_mut().filter(|saio| is_cenc(saio.aux_info.as_ref())) { + // The rebuilt senc holds every sample's information back to back, so one offset + // addresses all of it, however many runs the source split it over. + saio.offsets = vec![0]; + } + Ok(()) + } + (true, _) => Err(Error::InvalidProtection("encryption auxiliary information split over several saio").into()), + } +} + +/// Point the Common Encryption `saio` of the encoded per-track fragment `moof` at its `senc`'s +/// first sample, relative to the `moof` as `default-base-is-moof` addresses it. +/// +/// `moof` must be the encoding of `traf`'s fragment with the offset [`reserve_saio`] reserved, so +/// the offset this fills in keeps its size. +pub(crate) fn point_saio(traf: &mut mp4_atom::Traf, moof: &[u8]) -> Result<()> { + if !traf.saio.iter().any(|saio| is_cenc(saio.aux_info.as_ref())) { + return Ok(()); + } + let senc = find( + moof, + &[mp4_atom::Moof::KIND, mp4_atom::Traf::KIND, mp4_atom::Senc::KIND], + ) + .ok_or(Error::InvalidProtection("rebuilt fragment has no senc"))?; + // senc's version and flags, then its sample count, precede the first sample's information. + let offset = senc + 4 + 4; + for saio in traf.saio.iter_mut().filter(|saio| is_cenc(saio.aux_info.as_ref())) { + saio.offsets = vec![offset as u64]; + } + Ok(()) +} + +/// The offset of the body of the box at `path`, walking from the start of `buf`. +fn find(buf: &[u8], path: &[FourCC]) -> Option { + let (first, rest) = path.split_first()?; + let mut position = 0; + while position < buf.len() { + let mut cursor = &buf[position..]; + let header = ::decode(&mut cursor).ok()?; + let header_size = buf.len() - position - cursor.len(); + let size = header + .size + .map(|size| size + header_size) + .unwrap_or(buf.len() - position); + let body = position + header_size; + if header.kind == *first { + if rest.is_empty() { + return Some(body); + } + // A box's children start right after its header; moof and traf carry no fields. + let end = (position + size).min(buf.len()); + return find(&buf[body..end], rest).map(|offset| body + offset); + } + position = position.checked_add(size)?; + } + None +} diff --git a/rs/moq-mux/src/container/fmp4/import.rs b/rs/moq-mux/src/container/fmp4/import.rs index ffa6fa2722d..d68c51a93d0 100644 --- a/rs/moq-mux/src/container/fmp4/import.rs +++ b/rs/moq-mux/src/container/fmp4/import.rs @@ -57,6 +57,9 @@ pub struct Import { // Republish each fragment whole as CMAF instead of unwrapping its samples. passthrough: bool, + // The license and certificate servers of each DRM system the media is encrypted for. + drm: std::collections::BTreeMap, + // A lookup to tracks in the broadcast tracks: HashMap>, text: HashMap, @@ -138,6 +141,9 @@ struct Fmp4Track { // group, which is what keeps audio on the same boundaries as video. segment: Option, + // The samples are encrypted, so each fragment's encryption information must survive. + protected: Option, + output: Output, } @@ -248,6 +254,8 @@ struct Sample { sync: bool, /// The sample's bytes within the `mdat` payload. range: std::ops::Range, + /// The sample's position among its `traf`'s, which its encryption information follows. + index: usize, } /// The samples one `traf` places in its `mdat`. @@ -272,6 +280,7 @@ impl Import { initial_reservation: Some(reserved), select: None, passthrough: false, + drm: Default::default(), tracks: HashMap::default(), text: HashMap::default(), skipped: HashSet::default(), @@ -336,6 +345,18 @@ impl Import { self } + /// Set the license and certificate servers of a DRM system the media is encrypted for. + /// + /// Common Encryption media names its DRM systems (each `pssh` box's system ID) but not where a + /// player gets a license, so the publisher supplies that here; the catalog's `drm` entries for + /// `system` carry it. A later call for the same system replaces the earlier one. Once the + /// `moov` arrives, a system no imported encrypted track carries a `pssh` for is refused with + /// [`Error::UnusedDrmSystem`]. + pub fn with_drm(mut self, system: hang::catalog::drm::Uuid, servers: hang::catalog::drm::Servers) -> Self { + self.drm.insert(system, servers); + self + } + /// Whether `kind` is selected for import (every role when unset). fn selects(&self, kind: &Kind) -> bool { match (&self.select, kind) { @@ -534,6 +555,9 @@ impl Import { // Only `finish()` releases the reservation before a moov, since a fragment needs one. let reserved = self.initial_reservation.clone().ok_or(Error::MoovAfterFinish)?; + // Refuse undecryptable or unsignalled protection before any track is published. + let protections = self.protections(&moov)?; + for trak in &moov.trak { let track_id = trak.tkhd.track_id; let handler = &trak.mdia.hdlr.handler; @@ -558,9 +582,10 @@ impl Import { let timescale = moq_net::Timescale::new(trak.mdia.mdhd.timescale as u64)?; let edit = Edit::new(trak, moov.mvhd.timescale)?; + let protection = protections.get(&track_id); let output = match self.passthrough { true => Output::Passthrough(Box::new( - self.init_passthrough(trak, &moov, &reserved, kind, timescale)?, + self.init_passthrough(trak, &moov, &reserved, kind, timescale, protection)?, )), false => self.init_unwrap(trak, &moov, &reserved, kind)?, }; @@ -577,6 +602,7 @@ impl Import { last_decode_time: None, sample_duration: None, segment: None, + protected: protection.map(super::cenc::Protection::aux), output, }, ); @@ -593,6 +619,73 @@ impl Import { Ok(()) } + /// The protection of every imported track that is encrypted, keyed by track ID. + /// + /// Refuses encrypted media without passthrough, whose unwrapped samples would lose their + /// per-sample IVs, every protection [`Protection::of`](super::cenc::Protection::of) refuses, and a + /// DRM system [`with_drm`](Self::with_drm) configured that no encrypted track carries. + fn protections(&self, moov: &Moov) -> Result> { + let mut protections = HashMap::new(); + for trak in &moov.trak { + let imported = Kind::from_handler(trak.mdia.hdlr.handler).is_ok_and(|kind| self.selects(&kind)); + if !imported { + continue; + } + let Some(protection) = super::cenc::Protection::of(trak, moov)? else { + continue; + }; + if !self.passthrough { + return Err(Error::ProtectedNeedsPassthrough.into()); + } + protections.insert(trak.tkhd.track_id, protection); + } + + let carried = |system: &hang::catalog::drm::Uuid| { + (protections.values()) + .flat_map(|protection| &protection.pssh) + .any(|pssh| pssh.system_id == *system.as_bytes()) + }; + if let Some(system) = self.drm.keys().find(|system| !carried(system)) { + return Err(Error::UnusedDrmSystem(*system).into()); + } + Ok(protections) + } + + /// Add the catalog's `drm` entries for `protection`, one per DRM system with the servers + /// [`with_drm`](Self::with_drm) set for it, returning their IDs for the rendition to list. + /// + /// A system, scheme, and key another rendition already uses shares its entry, so video and + /// audio under one key list the same IDs. A new entry takes the lowest free numeric ID. + fn register_drm(&mut self, protection: &super::cenc::Protection) -> Result> { + let mut entries = protection.entries()?; + for entry in &mut entries { + if let Some(servers) = self.drm.get(&entry.system) { + entry.license = servers.license.clone(); + entry.certificate = servers.certificate.clone(); + } + } + + let mut ids = Vec::with_capacity(entries.len()); + self.catalog.mutate(|catalog| { + for entry in entries { + let existing = catalog.drm.iter().find(|(_, other)| other.same_key(&entry)); + let id = match existing { + Some((id, _)) => id.clone(), + None => { + let id = (1..) + .map(|n: u64| n.to_string()) + .find(|id| !catalog.drm.contains_key(id)) + .expect("a free entry ID"); + catalog.drm.insert(id.clone(), entry); + id + } + }; + ids.push(id); + } + })?; + Ok(ids) + } + fn init_passthrough( &mut self, trak: &Trak, @@ -600,6 +693,7 @@ impl Import { reserved: &crate::catalog::Reserved, kind: Kind, timescale: moq_net::Timescale, + protection: Option<&super::cenc::Protection>, ) -> Result> { // Declare the track at the fMP4's native timescale, which the moq-hang draft requires // of a CMAF track: frame timestamps are emitted at this same scale (see `extract`), so @@ -614,15 +708,19 @@ impl Import { // Whatever the descriptor declared (a bitrate) is authoritative; the rest is filled by // `estimate` as fragments arrive. + // The entries go in before the rendition listing them, so no catalog has a dangling one. + let drm = protection.map(|protection| self.register_drm(protection)).transpose()?; let rendition = match kind { Kind::Video => { - let config = self.init_video(trak, moov)?; + let mut config = self.init_video(trak, moov, protection)?; + config.drm = drm.unwrap_or_default(); let mut rendition = reserved.init(track.name())?; rendition.set(config)?; Rendition::Video(rendition) } Kind::Audio => { - let config = self.init_audio(trak, moov)?; + let mut config = self.init_audio(trak, moov, protection)?; + config.drm = drm.unwrap_or_default(); let mut rendition = reserved.init(track.name())?; rendition.set(config)?; Rendition::Audio(rendition) @@ -660,8 +758,8 @@ impl Import { )?; let wire = crate::catalog::hang::Container::new(&Container::Legacy, wire_kind)?; Ok(match kind { - Kind::Video => Output::Video(reserved.video(track, wire, self.init_video(trak, moov)?)?), - Kind::Audio => Output::Audio(reserved.audio(track, wire, self.init_audio(trak, moov)?)?), + Kind::Video => Output::Video(reserved.video(track, wire, self.init_video(trak, moov, None)?)?), + Kind::Audio => Output::Audio(reserved.audio(track, wire, self.init_audio(trak, moov, None)?)?), }) } @@ -709,7 +807,10 @@ impl Import { /// The container a rendition advertises: unwrapped samples are Legacy frames, while a /// passthrough track carries its own single-track init segment. - fn container(&self, trak: &Trak, moov: &Moov) -> Result { + /// + /// An encrypted track's init keeps its `encv`/`enca` entry and the `pssh` boxes that apply to + /// it, which a decrypting player needs (CMSF section 4.2). + fn container(&self, trak: &Trak, moov: &Moov, protection: Option<&super::cenc::Protection>) -> Result { if !self.passthrough { return Ok(Container::Legacy); } @@ -741,7 +842,7 @@ impl Import { trak.edts = None; let single_moov = Moov { - pssh: Vec::new(), + pssh: protection.map(|protection| protection.pssh.clone()).unwrap_or_default(), mvhd: moov.mvhd.clone(), trak: vec![trak], mvex: Some(mp4_atom::Mvex { @@ -761,8 +862,13 @@ impl Import { } } - fn init_video(&mut self, trak: &Trak, moov: &Moov) -> Result { - let container = self.container(trak, moov)?; + fn init_video( + &mut self, + trak: &Trak, + moov: &Moov, + protection: Option<&super::cenc::Protection>, + ) -> Result { + let container = self.container(trak, moov, protection)?; let stsd = &trak.mdia.minf.stbl.stsd; let codec = match stsd.codecs.len() { @@ -770,6 +876,8 @@ impl Import { 1 => &stsd.codecs[0], _ => return Err(Error::MultipleCodecs.into()), }; + // A protected rendition is described by the codec its encrypted entry wraps. + let codec = super::cenc::clear(codec); let (mut config, colr, pasp, spatial) = match codec { mp4_atom::Codec::Avc1(avc1) => ( @@ -941,8 +1049,13 @@ impl Import { Ok(config) } - fn init_audio(&mut self, trak: &Trak, moov: &Moov) -> Result { - let container = self.container(trak, moov)?; + fn init_audio( + &mut self, + trak: &Trak, + moov: &Moov, + protection: Option<&super::cenc::Protection>, + ) -> Result { + let container = self.container(trak, moov, protection)?; let stsd = &trak.mdia.minf.stbl.stsd; let codec = match stsd.codecs.len() { @@ -950,6 +1063,8 @@ impl Import { 1 => &stsd.codecs[0], _ => return Err(Error::MultipleCodecs.into()), }; + // A protected rendition is described by the codec its encrypted entry wraps. + let codec = super::cenc::clear(codec); let config = match codec { mp4_atom::Codec::Mp4a(mp4a) => { @@ -1162,7 +1277,7 @@ impl Import { new_segment: track.segment != Some(self.segment), }; let prefix = match track.output { - Output::Passthrough(_) => Some(fragment(traf, &moof, &run, &track.defaults)?), + Output::Passthrough(_) => Some(fragment(traf, &moof, &run, &track.defaults, track.protected)?), _ => None, }; let index = mdat.tracks.len(); @@ -1406,7 +1521,7 @@ impl Fmp4Track { let mut end = None; let mut samples = Vec::with_capacity(sample::count(traf) as usize); let mut dropped = false; - for resolved in resolver.resolve(traf, self.defaults)? { + for (index, resolved) in resolver.resolve(traf, self.defaults)?.enumerate() { let sample::Resolved { sample, cts, range } = resolved?; let duration = sample.duration; @@ -1440,6 +1555,7 @@ impl Fmp4Track { flags: sample.flags, sync: sample.is_sync(), range, + index, }); } else { dropped = true; @@ -1469,17 +1585,35 @@ impl Fmp4Track { /// /// The mdat holds `run`'s samples back to back in decode order, whatever separated them in the /// source (padding, another track's runs), so each rewritten `data_offset` is the sizes before it. -fn fragment(traf: &mp4_atom::Traf, moof: &Moof, run: &Run, defaults: &sample::Defaults) -> Result { +/// +/// An encrypted track's fragment keeps its `senc`, `saiz`, and `saio`, with `saio` pointed at the +/// rebuilt `senc`. One whose keys rotate, whose encryption information is outside `senc`, or whose +/// edit list drops samples is refused. +fn fragment( + traf: &mp4_atom::Traf, + moof: &Moof, + run: &Run, + defaults: &sample::Defaults, + protected: Option, +) -> Result { + if protected.is_some() { + super::cenc::check_moof(moof, traf)?; + } + // Build a per-track moof containing only this traf, and a per-track mdat // with only the samples belonging to this track. let mut adjusted_moof = Moof { pssh: Vec::new(), mfhd: moof.mfhd.clone(), traf: vec![match run.dropped { - true => kept(traf, run)?, + true => kept(traf, run, protected)?, false => traf.clone(), }], }; + let protected = protected.is_some(); + if protected { + super::cenc::reserve_saio(&mut adjusted_moof.traf[0])?; + } // Apply structural (flag-presence) changes BEFORE measuring the encoded // size, otherwise the rewritten data_offset values are computed from a @@ -1508,6 +1642,10 @@ fn fragment(traf: &mp4_atom::Traf, moof: &Moof, run: &Run, defaults: &sample::De let mut moof_buf = Vec::new(); adjusted_moof.encode(&mut moof_buf)?; let new_moof_size = moof_buf.len(); + // Rewriting the reserved offsets below keeps every box's size, so senc stays where it is now. + if protected { + super::cenc::point_saio(&mut adjusted_moof.traf[0], &moof_buf)?; + } // A payload past 4 GiB takes the 16-byte largesize header. let mut mdat = Vec::new(); @@ -1547,9 +1685,10 @@ fn fragment(traf: &mp4_atom::Traf, moof: &Moof, run: &Run, defaults: &sample::De /// /// Each sample keeps its decode and composition time: `tfdt` starts at the first kept sample, and /// each kept sample lasts until the next one decodes. The per-sample tables (`sbgp`, -/// `subs`, sample auxiliary information) would index the wrong samples, and no consumer reads -/// them, so they go. -fn kept(traf: &mp4_atom::Traf, run: &Run) -> Result { +/// `subs`, sample auxiliary information) would index the wrong samples, and no consumer of a clear +/// track reads them, so they go. An encrypted track's encryption information is restated for the +/// kept samples instead, since a player cannot decrypt without it. +fn kept(traf: &mp4_atom::Traf, run: &Run, protected: Option) -> Result { let mut entries = Vec::with_capacity(run.samples.len()); for (index, sample) in run.samples.iter().enumerate() { let duration = match run.samples.get(index + 1) { @@ -1565,7 +1704,7 @@ fn kept(traf: &mp4_atom::Traf, run: &Run) -> Result { }); } let first = run.samples.first().ok_or(Error::MissingTrun)?; - Ok(mp4_atom::Traf { + let mut kept = mp4_atom::Traf { tfhd: traf.tfhd.clone(), tfdt: Some(mp4_atom::Tfdt { base_media_decode_time: first.dts, @@ -1575,7 +1714,12 @@ fn kept(traf: &mp4_atom::Traf, run: &Run) -> Result { samples: entries.into(), }], ..Default::default() - }) + }; + if let Some(aux) = protected { + let indices: Vec = run.samples.iter().map(|sample| sample.index).collect(); + aux.restate(traf, &mut kept, &indices)?; + } + Ok(kept) } impl Passthrough { diff --git a/rs/moq-mux/src/container/fmp4/import_test.rs b/rs/moq-mux/src/container/fmp4/import_test.rs index 7c2f348bdd9..d1b971192b1 100644 --- a/rs/moq-mux/src/container/fmp4/import_test.rs +++ b/rs/moq-mux/src/container/fmp4/import_test.rs @@ -3883,3 +3883,426 @@ async fn declared_boundaries_do_not_split_passthrough_fragments() { ); } } + +const CENC: &[u8] = include_bytes!("test_data/cenc-clearkey.mp4"); +const CBCS_VIDEO: &[u8] = include_bytes!("test_data/cbcs-video.mp4"); +const CBCS_AUDIO: &[u8] = include_bytes!("test_data/cbcs-audio.mp4"); +const CLEARKEY_KID: hang::catalog::drm::Uuid = + hang::catalog::drm::Uuid::from_u128(0xa1b2c3d4_e5f6_0718_293a_4b5c6d7e8f90); + +/// Import each of `files` in passthrough into one broadcast and catalog, configuring each importer +/// with `configure`, and return the first error alongside what was published. +/// +/// The importers come back too: dropping one retires its renditions. +#[allow(clippy::type_complexity, reason = "a test helper returning what each test reads")] +fn import_protected( + files: &[&[u8]], + configure: impl Fn(super::Import) -> super::Import, +) -> ( + crate::Result<()>, + crate::catalog::Producer, + moq_net::broadcast::Consumer, + Vec, +) { + let mut broadcast = moq_net::broadcast::Info::new().produce(); + let consumer = broadcast.consume(); + let catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap(); + let mut importers: Vec<_> = (files.iter()) + .map(|_| configure(super::Import::new(broadcast.clone(), catalog.reserve()).with_passthrough(true))) + .collect(); + let mut result = Ok(()); + for (fmp4, data) in importers.iter_mut().zip(files) { + result = result.and(fmp4.decode(data)); + } + for fmp4 in &mut importers { + result = result.and(fmp4.finish()); + } + (result, catalog, consumer, importers) +} + +fn protected_error(files: &[&[u8]], configure: impl Fn(super::Import) -> super::Import) -> super::Error { + match import_protected(files, configure).0 { + Err(crate::Error::Cmaf(err)) => err, + other => panic!("expected a refusal, got {other:?}"), + } +} + +/// The file's top-level boxes with `edit` applied, re-encoded. A changed `moof` keeps addressing +/// its samples: every run's `data_offset` shifts by how much the `moof` grew. +fn rewrite(data: &[u8], mut edit: impl FnMut(&mut mp4_atom::Any)) -> Vec { + use mp4_atom::DecodeMaybe; + + let mut cursor = std::io::Cursor::new(data); + let mut out = Vec::new(); + loop { + let start = cursor.position(); + let Some(mut atom) = mp4_atom::Any::decode_maybe(&mut cursor).unwrap() else { + break; + }; + let before = cursor.position() - start; + edit(&mut atom); + if let mp4_atom::Any::Moof(moof) = &mut atom { + let mut after = Vec::new(); + moof.encode(&mut after).unwrap(); + let grew = after.len() as i32 - before as i32; + for trun in moof.traf.iter_mut().flat_map(|traf| &mut traf.trun) { + trun.data_offset = trun.data_offset.map(|offset| offset + grew); + } + } + atom.encode(&mut out).unwrap(); + } + out +} + +/// The first `moof` of `data`. +fn first_moof(data: &[u8]) -> mp4_atom::Moof { + use mp4_atom::DecodeMaybe; + + let mut cursor = std::io::Cursor::new(data); + while let Some(atom) = mp4_atom::Any::decode_maybe(&mut cursor).unwrap() { + if let mp4_atom::Any::Moof(moof) = atom { + return moof; + } + } + panic!("no moof"); +} + +/// Every fragment the broadcast published on `name`, in order. +async fn fragments(consumer: &moq_net::broadcast::Consumer, name: &str) -> Vec { + let mut track = consumer.track(name).unwrap().subscribe(replay()).await.unwrap(); + let mut out = Vec::new(); + while let Some(mut group) = track.recv_group().now_or_never().and_then(|r| r.ok().flatten()) { + while let Some(frame) = group.read_frame().now_or_never().and_then(|r| r.ok().flatten()) { + out.push(frame.payload); + } + } + out +} + +/// The `senc` of a published fragment, checking its `saio` (if any) points at its first sample's +/// information, relative to the `moof`. +fn checked_senc(fragment: &[u8]) -> mp4_atom::Senc { + let moof = mp4_atom::Moof::decode(&mut &fragment[..]).unwrap(); + let traf = &moof.traf[0]; + let senc = traf.senc.clone().expect("the fragment keeps its senc"); + if let Some(saio) = traf.saio.first() { + let [offset] = saio.offsets[..] else { + panic!("one saio offset, got {:?}", saio.offsets); + }; + let offset = offset as usize; + // The senc header's type, its version and flags, then the sample count the data starts with. + assert_eq!( + &fragment[offset - 12..offset - 8], + b"senc", + "saio points past a senc header" + ); + assert_eq!(&fragment[offset - 4..offset - 4 + senc.data.len()], &senc.data[..]); + } + senc +} + +/// The ClearKey `cenc` file's two tracks share one key and system, so one `drm` entry protects +/// both; each init keeps its encrypted entry and the `pssh`, and the codec is the one it wraps. +#[test] +fn cenc_passthrough_signals_drm() { + use hang::catalog::drm; + + let (result, catalog, _, _importers) = import_protected(&[CENC], |fmp4| fmp4); + result.unwrap(); + let catalog = catalog.snapshot(); + + let entry = &catalog.drm["1"]; + assert_eq!(catalog.drm.len(), 1, "{:?}", catalog.drm); + assert_eq!(entry.system, drm::system::CLEARKEY); + assert_eq!(entry.scheme, drm::Scheme::Cenc); + assert_eq!(entry.kid, CLEARKEY_KID); + let pssh = mp4_atom::Pssh::decode(&mut entry.pssh.as_deref().unwrap()).unwrap(); + assert_eq!(pssh.kid.as_deref(), Some(&[*CLEARKEY_KID.as_bytes()][..])); + + let video = catalog.video.renditions.values().next().unwrap(); + let audio = catalog.audio.renditions.values().next().unwrap(); + assert!(video.codec.to_string().starts_with("avc1"), "{}", video.codec); + assert_eq!(audio.codec.to_string(), "mp4a.40.2"); + assert_eq!( + (&video.drm[..], &audio.drm[..]), + (&["1".to_string()][..], &["1".to_string()][..]) + ); + + for container in [&video.container, &audio.container] { + let Container::Cmaf { init } = container else { + panic!("passthrough publishes CMAF"); + }; + let (_, moov) = decode_init(init); + assert!( + matches!( + moov.trak[0].mdia.minf.stbl.stsd.codecs[..], + [mp4_atom::Codec::Encv(_) | mp4_atom::Codec::Enca(_)] + ), + "the init keeps the encrypted entry" + ); + assert_eq!(moov.pssh, std::slice::from_ref(&pssh), "the init keeps the pssh"); + } +} + +/// Shaka's `cbcs` video and audio, imported side by side, share the entry for their one key; the +/// audio's `roll` sample groups are not key rotation. +#[test] +fn cbcs_video_and_audio_share_an_entry() { + let (result, catalog, _, _importers) = import_protected(&[CBCS_VIDEO, CBCS_AUDIO], |fmp4| fmp4); + result.unwrap(); + let catalog = catalog.snapshot(); + assert_eq!(catalog.drm.len(), 1, "{:?}", catalog.drm); + assert_eq!(catalog.drm["1"].scheme, hang::catalog::drm::Scheme::Cbcs); + assert_eq!(catalog.drm["1"].kid, CLEARKEY_KID); + let video = catalog.video.renditions.values().next().unwrap(); + let audio = catalog.audio.renditions.values().next().unwrap(); + assert_eq!(video.drm, ["1"]); + assert_eq!(audio.drm, ["1"]); + assert!(video.codec.to_string().starts_with("avc1"), "{}", video.codec); + assert_eq!(audio.codec.to_string(), "mp4a.40.2"); +} + +/// The MSF catalog renders the entries as CMSF `contentProtections`, with the publisher's servers, +/// and parsing it maps them back to the same `drm` section. +#[test] +fn drm_renders_as_cmsf_content_protection_and_back() { + use hang::catalog::drm; + + let mut certificate = drm::Server::new("https://cert.example.com/".parse().unwrap()); + certificate.kind = Some("application/pkcs7-mime".into()); + let mut servers = drm::Servers::license("https://license.example.com/clearkey".parse().unwrap()); + servers.certificate = Some(certificate); + let (result, catalog, _, _importers) = import_protected(&[CBCS_VIDEO, CBCS_AUDIO], |fmp4| { + fmp4.with_drm(drm::system::CLEARKEY, servers.clone()) + }); + result.unwrap(); + let catalog = catalog.snapshot(); + assert_eq!(catalog.drm["1"].license, servers.license); + assert_eq!(catalog.drm["1"].certificate, servers.certificate); + + let msf = crate::catalog::to_msf(&catalog, &moq_net::Path::empty()); + let [entry] = &msf.content_protections[..] else { + panic!("one entry, got {:?}", msf.content_protections); + }; + assert_eq!(entry.ref_id, "1"); + assert_eq!(entry.scheme, "cbcs"); + assert_eq!(entry.default_kid, ["a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90"]); + assert_eq!(entry.drm_system.system_id, "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"); + assert_eq!( + entry.drm_system.la_url.as_ref().unwrap().url, + "https://license.example.com/clearkey" + ); + assert_eq!( + entry.drm_system.cert_url.as_ref().unwrap().kind.as_deref(), + Some("application/pkcs7-mime") + ); + assert!(entry.drm_system.pssh.is_some()); + for track in &msf.tracks { + assert_eq!(track.content_protection_ref_ids, ["1"], "{}", track.name); + } + + let wire: moq_msf::Catalog = msf.to_json().unwrap().parse().unwrap(); + let back = crate::catalog::msf::from_msf(&wire, &moq_net::Path::empty()).unwrap(); + assert_eq!(back.drm, catalog.drm); + assert_eq!(back.video.renditions.values().next().unwrap().drm, ["1"]); + assert_eq!(back.audio.renditions.values().next().unwrap().drm, ["1"]); +} + +/// A license server for a DRM system the media carries no `pssh` for is a configuration mistake. +#[test] +fn a_drm_system_the_media_lacks_is_refused() { + use hang::catalog::drm; + + let servers = drm::Servers::license("https://license.example.com/".parse().unwrap()); + let err = protected_error(&[CENC], |fmp4| fmp4.with_drm(drm::system::WIDEVINE, servers.clone())); + assert!( + matches!(err, super::Error::UnusedDrmSystem(system) if system == drm::system::WIDEVINE), + "{err:?}" + ); +} + +/// Without passthrough the importer would unwrap samples and lose their per-sample IVs, so an +/// encrypted file is refused rather than published undecryptable. +#[test] +fn encrypted_unwrapped_import_is_refused() { + let mut broadcast = moq_net::broadcast::Info::new().produce(); + let catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap(); + let mut fmp4 = super::Import::new(broadcast, catalog.reserve()); + let err = fmp4.decode(CBCS_VIDEO).unwrap_err(); + assert!( + matches!(err, crate::Error::Cmaf(super::Error::ProtectedNeedsPassthrough)), + "{err:?}" + ); +} + +/// Passthrough re-encodes each fragment, which moves `senc`; every published fragment's `saio` +/// still points at its IVs, which are the source's. +#[tokio::test] +async fn encrypted_fragments_keep_saio_on_their_ivs() { + for data in [CENC, CBCS_VIDEO] { + let (result, catalog, consumer, _importers) = import_protected(&[data], |fmp4| fmp4); + result.unwrap(); + let snapshot = catalog.snapshot(); + let source = first_moof(data); + for (name, config) in &snapshot.video.renditions { + let Container::Cmaf { init } = &config.container else { + unreachable!() + }; + let (_, moov) = decode_init(init); + let track_id = moov.trak[0].tkhd.track_id; + let published = fragments(&consumer, name).await; + assert!(!published.is_empty(), "{name}"); + let senc = checked_senc(&published[0]); + let traf = source.traf.iter().find(|traf| traf.tfhd.track_id == track_id).unwrap(); + assert_eq!(Some(senc), traf.senc, "the IVs are the source's"); + for fragment in &published[1..] { + checked_senc(fragment); + } + } + } +} + +/// Shaka starts AAC on an edit that skips its priming frame. The edit list drops that sample, so +/// the first fragment's `senc` is restated for the kept samples rather than refused. +#[tokio::test] +async fn an_edit_restates_the_kept_samples_encryption() { + let (result, catalog, consumer, _importers) = import_protected(&[CBCS_AUDIO], |fmp4| fmp4); + result.unwrap(); + let name = catalog.snapshot().audio.renditions.keys().next().unwrap().clone(); + let published = fragments(&consumer, &name).await; + let first = mp4_atom::Moof::decode(&mut &published[0][..]).unwrap(); + let samples = super::sample::count(&first.traf[0]); + assert_eq!(samples, super::sample::count(&first_moof(CBCS_AUDIO).traf[0]) - 1); + let senc = checked_senc(&published[0]); + assert_eq!( + senc.data, + (samples as u32).to_be_bytes(), + "one empty entry per kept sample" + ); +} + +/// The same with per-sample IVs and subsamples: an edit dropping the `cenc` file's first audio +/// frame drops that frame's IV and size, and keeps the rest byte for byte. +#[tokio::test] +async fn an_edit_drops_the_skipped_samples_ivs() { + let data = rewrite(CENC, |atom| { + if let mp4_atom::Any::Moov(moov) = atom { + let audio = moov + .trak + .iter_mut() + .find(|trak| trak.mdia.hdlr.handler == b"soun".into()) + .unwrap(); + let frame = 1024; + audio.edts = Some(mp4_atom::Edts { + elst: Some(mp4_atom::Elst { + entries: vec![mp4_atom::ElstEntry { + segment_duration: 0, + media_time: Some(frame), + media_rate: mp4_atom::FixedPoint::from(1), + }], + }), + }); + } + }); + let (result, catalog, consumer, _importers) = import_protected(&[&data], |fmp4| fmp4); + result.unwrap(); + let (name, config) = catalog.snapshot().audio.renditions.into_iter().next().unwrap(); + let Container::Cmaf { init } = &config.container else { + unreachable!() + }; + let track_id = decode_init(init).1.trak[0].tkhd.track_id; + let source = first_moof(&data); + let source = source.traf.iter().find(|traf| traf.tfhd.track_id == track_id).unwrap(); + + let published = fragments(&consumer, &name).await; + let senc = checked_senc(&published[0]); + let kept = super::sample::count(source) as u32 - 1; + // 8-byte IVs and no subsamples in ffmpeg's audio: the first IV goes. + let source_senc = source.senc.as_ref().unwrap(); + assert!(!source_senc.use_subsamples); + let mut expected = kept.to_be_bytes().to_vec(); + expected.extend_from_slice(&source_senc.data[4 + 8..]); + assert_eq!(senc.data, expected); + let moof = mp4_atom::Moof::decode(&mut &published[0][..]).unwrap(); + assert_eq!(moof.traf[0].saiz[0].sample_count, kept); +} + +/// Keys that rotate are refused: a `pssh` in a `moof`, or a `seig` sample group. +#[test] +fn key_rotation_is_refused() { + let pssh = rewrite(CBCS_VIDEO, |atom| { + if let mp4_atom::Any::Moof(moof) = atom { + moof.pssh.push(mp4_atom::Pssh { + system_id: *hang::catalog::drm::system::CLEARKEY.as_bytes(), + kid: Some(vec![*CLEARKEY_KID.as_bytes()]), + data: Vec::new(), + }); + } + }); + let seig = rewrite(CBCS_VIDEO, |atom| { + if let mp4_atom::Any::Moof(moof) = atom { + moof.traf[0].sbgp.push(mp4_atom::Sbgp { + grouping_type: b"seig".into(), + grouping_type_parameter: None, + entries: vec![mp4_atom::SbgpEntry { + sample_count: 1, + group_description_index: 1, + }], + }); + } + }); + for data in [pssh, seig] { + let err = protected_error(&[&data], |fmp4| fmp4); + assert!(matches!(err, super::Error::KeyRotation), "{err:?}"); + } +} + +/// Without a `pssh` the catalog could name no DRM system, and the track would read as clear. +#[test] +fn an_encrypted_track_without_pssh_is_refused() { + let data = rewrite(CBCS_VIDEO, |atom| { + if let mp4_atom::Any::Moov(moov) = atom { + moov.pssh.clear(); + } + }); + let err = protected_error(&[&data], |fmp4| fmp4); + assert!(matches!(err, super::Error::MissingPssh), "{err:?}"); +} + +/// IVs the rebuilt fragment would not carry are refused: ones outside `senc`, or split over +/// several `saio`. +#[test] +fn encryption_information_outside_senc_is_refused() { + let outside = rewrite(CBCS_VIDEO, |atom| { + if let mp4_atom::Any::Moof(moof) = atom { + moof.traf[0].senc = None; + } + }); + let split = rewrite(CBCS_VIDEO, |atom| { + if let mp4_atom::Any::Moof(moof) = atom { + let saio = moof.traf[0].saio[0].clone(); + moof.traf[0].saio.push(saio); + } + }); + for data in [outside, split] { + let err = protected_error(&[&data], |fmp4| fmp4); + assert!(matches!(err, super::Error::InvalidProtection(_)), "{err:?}"); + } +} + +/// A clear lead (an encrypted entry beside a clear one) stays refused as several codecs. +#[test] +fn a_clear_lead_is_refused() { + let data = rewrite(CBCS_VIDEO, |atom| { + if let mp4_atom::Any::Moov(moov) = atom { + let codecs = &mut moov.trak[0].mdia.minf.stbl.stsd.codecs; + let mp4_atom::Codec::Encv(encv) = &codecs[0] else { + unreachable!() + }; + let clear = (*encv.codec).clone(); + codecs.push(clear); + } + }); + let err = protected_error(&[&data], |fmp4| fmp4); + assert!(matches!(err, super::Error::MultipleCodecs), "{err:?}"); +} diff --git a/rs/moq-mux/src/container/fmp4/mod.rs b/rs/moq-mux/src/container/fmp4/mod.rs index 0fa2b81f04c..062e5686c90 100644 --- a/rs/moq-mux/src/container/fmp4/mod.rs +++ b/rs/moq-mux/src/container/fmp4/mod.rs @@ -6,6 +6,7 @@ //! container; [`Import`] parses external fMP4 streams and [`Export`] //! produces them. +pub(crate) mod cenc; mod edit; mod export; pub mod fragment; @@ -173,6 +174,37 @@ pub enum Error { #[error("unknown codec: {0:?}")] UnknownCodec(mp4_atom::FourCC), + /// An encrypted (`encv`/`enca`) track whose protection boxes, or whose fragments' encryption + /// information, the republished media could not carry intact. + #[error("invalid protected track: {0}")] + InvalidProtection(&'static str), + + /// An encrypted track under a Common Encryption scheme other than `cenc` and `cbcs`. + #[error("unsupported encryption scheme: {0:?}")] + UnsupportedScheme(mp4_atom::FourCC), + + /// Encrypted samples carry their per-sample IVs in the fragment's `senc`, which only + /// passthrough keeps; unwrapped samples would be undecryptable. + #[error("encrypted fMP4 needs passthrough (CMAF) import")] + ProtectedNeedsPassthrough, + + /// An encrypted track without a `pssh` box, so the catalog could name no DRM system for it. + #[error("encrypted track without a pssh box")] + MissingPssh, + + /// Keys that rotate within the track: a `pssh` box in a `moof`, or a `seig` sample group. + #[error("key rotation is not supported")] + KeyRotation, + + /// An edit list drops samples of an encrypted track, whose kept samples' encryption + /// information would not be restated. + #[error("an edit list drops samples from an encrypted track")] + ProtectedEdit, + + /// A license or certificate server for a DRM system no encrypted track carries a `pssh` for. + #[error("DRM system {0} protects no track")] + UnusedDrmSystem(hang::catalog::drm::Uuid), + /// A `colr` box code point past H.273's 255. #[error("invalid colr code point: {0}")] InvalidColr(u16), diff --git a/rs/moq-mux/src/container/fmp4/test_data/cbcs-audio.mp4 b/rs/moq-mux/src/container/fmp4/test_data/cbcs-audio.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..afa0e008be88599f1874e1e59950167316c01dfc GIT binary patch literal 17948 zcmZsC19&D)({60r8{1AcwzI*;wr$%sHnweSjE#0ieFNBO^N{+BH9e{}&X&ufF3yp1_$nSnC6}+lOT|M?*7f00%NOFm(KP3@(7q9H3%y0u2Apu)sih_5HKE zcaT_A+|pXsKCy8~quGL#skaQ8N91R0SGoE_fDTBGPELPZ`7j6|fb0m^%l{!Xfb8)f z>7N3ijiK#->2MrP?TkJKb+EPi2+4=z!0+#XE0Ux2KdS>Me-Np$(Vx-qjIA7<{!#r6 z5@0+2<2R?Zi?JJ^4$0d1-@d?}A596J9RBD(${#HO_-6}$C;-H2=jdqmQGw)oe$rDf z3sSkmL!h|*EDcZr|L;(IbO5Mj0C()i0wYhmYL_^3jeF&|De70|3|r;Nz*_4#3B}0s)8sAOV0J0FnWy2A~3f zYyb)XXa%4gfII*?02lU2_+X;ohuZd6j*I}1m$Q=5rMNs(Dr2Z4#Q-YqZ%puso3XR&J3US9uLwaqUbaB zl*4H2K=v(i18P=)j;M1N%ypylysb$?8osLPZ{AWnDD#k9E1ZH7$pozDi7IzC{n;mU zG$j~67nRSFgkuMo;t_=&dGExq?R#>m$?c*0xk=4r zpIuf8K2a`o)XEf!1Ota6b91V_HY(?%h^O^tg))sX@uF6K4Jv3i<=kOXS5H1{6bV|{ zwj~cn^Qy?x7<$C19)RARX0&FAJ0ftXf-&>LPIx@BiiYhelf>{K#?SPU3&*l<&YBS( zj1IX<9plZqJ$kkSPPtfk!vdvwI@*jM^y*Ee_L)N$QMqk!2`a-jf-7V;1{!}Ns%pq~ zE7B;q|FgcF`hDp_L&79UYEp{&i{>&t0rlulYd@Tmu)K8mjzYvXABKEH1>0u^F-(8O zz(d{mv{8*1HYWcFrXK4{E{4V;YH!2NV|_V;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H@Foa+0ik;TdX2)z=vJhx2 zb6QCkn^lf^*RQ{G8+QW_i_4cc47wPWIkBA5{T~ zLK?*)&BBe}iBmi6zD}JTX+64t7zUhSr)|F za8`==d}1s$?yU6h@`L)dJ!G@UM)CdeI~If+ZYHjWjYoIQHBc+d;Qhr4IDrV`?X!5|MujI zLM?FwLh6pxfYKF|2(e1d!i6)=t3)GntKiaaegg7b*Im+?YhNmpo1`18H*@vfHhm`= zkwz~E>bn*gKHlVBi0ryX`S?Y?e;xf`2EONMa}h#Pr1?}Dm*X3IR%(FU zG0B0<;9;JWVvL`opDaDs5RX)kg08lHXDr6PG=C{*fP7YA1%*qTYm2ghxEJM%)r_4I z8Iq`S;epbNEz!*QTrz|UFXcP_JzhcJyV38CG&LSupvx(=_rXVlJG!(Ggcb`DX}Pt5s^${Gc!xM}5%#kez8NK57FN;rnumghdk?@;_lj!N)K?#Q|} zC-5bo_Inl`3ggS`qy3_Yr~S@9P4A}~LVb^W9;%`3D)!~{WDOPiKLaie0QRc^Kn!;t literal 0 HcmV?d00001 diff --git a/rs/moq-mux/src/container/fmp4/test_data/cbcs-video.mp4 b/rs/moq-mux/src/container/fmp4/test_data/cbcs-video.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f87c54e3f82d6ff355c385c8aac5b9990994399a GIT binary patch literal 35053 zcmZ^~1yo#3vjsX3B)9~Z;O=fgg9Z%*2+lCLy9IX*?oM!b3-0a?!QI{E4d0jl-hbWq zUN27Xs@>Jq)zvb?VF3UDs15C1tSzkBSpeW-VrRt-ek|T}eW0B&&=JG}vM>Yz0Pm_T ztgIZtCgv87#`42RESeRHEf(3H@f001n*5FNlD{tW-I@p>M|0_d? z+u7@xgXIT1d%J%Y`(GY#U|3BZv_HgSmiVEXDjf4M*lMZ zx5jyW1ygL`ZT1;LAAtC}4!|)2V@VA>;?v!GFYvYlfGb?s5KILK0F?15%Fy%O-J27j z-M^DSG_m<>4EJ2hQ|ZuOu!V2Jvj1zBF2RPWL0%dZ{N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z8q0znzj?16h>I<>(Q1V-D;blr+_wz>KjKN}6aF3Nb#7S7kkrcZ&X`a z^X?e`7jzMzmG(HooX3Sn6w}=SzyK#(U~`i4OQz8GnC8?Wkt`X`h3OuJk*L)Udf)pT zyI?fK%aidzz<)7t!T2S438>wK?uGe z+WC;3^V?0b`AdTL;wp%N!bRy15>K=b%ByPMyEB?NVZWPQ+Cl;jjWpxpfu7j;ljdcC DV#EgX literal 0 HcmV?d00001 diff --git a/rs/moq-mux/src/container/fmp4/test_data/cenc-clearkey.mp4 b/rs/moq-mux/src/container/fmp4/test_data/cenc-clearkey.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..edb6e9c1eee1d651864cf99c6a9b90fca3636f37 GIT binary patch literal 40861 zcmb@tb9iP=vo{*swmq>qv7L!++s4FpCgvm)+nHcu+nU(6bMDMD``hn+&wIY>{IUB= z)vvp%yVmMj)qO8ifPjGTOr1UKEu8GwfPg@NJ`h0cHukJcKtSNNHgHz z0Q{HI=KrSw3H!18VF0KQ*%<%(yqG^a0IBr;0XlPIYsWt|0CTl4Hur1<*?v*cb@zeG>@F41neJFmNvqQ2szbpg;hIEgpfc01O0Xe$HF{ z`ta~E6v^Je$sT|oC-FfFPX9~_&eYMy0ALOfF+gZeM&>pE1Tq4g_21K_0>~@?A|mGx z*`ERol~>y{yL$(TMa?a(ZQ~mo2N0tfIy*Z5QG>z@0DTbPm`={lPJd+oFhJYsuZ=$f zG(g+)U-TbUKp!K!|CWIu{$C;r5OM#n0{q9z|L*F4YYY63VZdeo-x2lCO8HL_$rc0NTd?5>cvuBMQmspNRUezW;xs3Fn_^0vi9fXzBo51B1VY{(DLwKu905zl)mP z#L4)N(?R|H{mB8_0vG@>1b!2e^|Jr+?P`hXP#dR|?-v%a$$>*dJRi9~|P~gM)tiBkB0tLl3YA0i?kA9~|iU z4{!Xd)Bmdz{Uh!9!_WTe4F2jWKcv9Se>nGFo#9_y`5&p~9}W$$j^<=w@n5^e$K-PX zgaMHKpIrr<1P@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U z`C8q~F-Y=w_6}=^bm@&K4`fJBpw7r(dSQh%)X;CxzDp%Z>{dLwQ_dptK35^lQDTYo zs22%&)?dEe?FUu(=@p`f@v@m6!X24p0`H)L?OI#{xM@hp;?TWQC=P&7zwV42zOQR} zt@CbhB}J2xQ9+_0oxp6=s$TijMK(&pC<^Ap5&b;_sHba{`v6c7J5oT_y9egGd+A4u z@|LMG-#yCx)tD*2CMcOgm<0Hm}QriCRxv90)`7{O@doovTnjZU5$Dh>OGWUSGU}9e{X#~gyh2RL23)^~5Od&su+Y1Tb_}0yn6!Y`QMZ%K;nq(U@BJEg6e4r3*P8nxXi2@V4oJK>VZZ-H=_$sxp;HB$hSM_s%3LPf z*e%7_%Y%L~i&vx$l>==7!2UIVk%jWWZR4MOdnNRep}~#9LO1s^D82Pm`3&BiB(l{f zdQ?$Dj5Gcj;F}cgEZ%eAfc3sQ#oGMJT-UUCM3v{FYJa!Ikg59sPgx9`pc@(_4<7Jj zgG5aE_$`oA`J3lZYn)`Rxm7Hu$H<(n5#<0{SPO&vg)<-5h~edE3S*9~oapy_AB3&q z5)+S~d2B|iQAlOGCq%49y;@yx??;`vCBT6bN(g>)!J|~iZH@=^9UJ@us?%e7&wDk7 zmga*MW_4qZ|kbTsD)5m7o7!5si=ff#ay~&+c z-YVe>vc~yeLBqz4J&hz^4wb5iL9%Jw#FyshkCTw}AUm3lj*n9<+-6IytGs!=*it0_ z7UbCKadAhM8~*TJ**Ju%g+}<2Z&c433g;+WzL1?d^nOFi%6TYu`eEKz8%B~nfH1&X zmNJmU>Mx1sZhA@UW{0IHXt|cIi;{TvOD;^2R;r~bdaSaJ5!rP$~cb literal 0 HcmV?d00001 From 6250f7b77f652f3209042a18bced259e4ca7d7a7 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 17:37:59 +0100 Subject: [PATCH 05/23] feat(cli): license and certificate servers for import fmp4 `moq import fmp4 --cmaf` takes --drm-license and --drm-certificate, each SYSTEM=URL with SYSTEM a well-known name (widevine, playready, fairplay, clearkey) or a system ID, and repeatable per system. They reach the catalog's drm entries through fmp4::Import::with_drm, which refuses a system the media carries no pssh for. Co-Authored-By: Claude Opus 5.5 --- rs/moq-cli/src/args.rs | 100 +++++++++++++++++++++++++++++++++++++- rs/moq-cli/src/publish.rs | 33 ++++++++++--- 2 files changed, 125 insertions(+), 8 deletions(-) diff --git a/rs/moq-cli/src/args.rs b/rs/moq-cli/src/args.rs index cacc8f64c5a..4f71204da5c 100644 --- a/rs/moq-cli/src/args.rs +++ b/rs/moq-cli/src/args.rs @@ -887,6 +887,7 @@ impl ImportSource { Self::Avc3 => PublishFormat::Avc3, Self::Fmp4(args) => PublishFormat::Fmp4 { passthrough: args.passthrough, + drm: args.drm(), }, Self::Ts(args) if args.passthrough => PublishFormat::TsPassthrough { pcr_pid: args.pcr_pid.map(|pid| pid.0), @@ -939,14 +940,69 @@ impl ImportSource { } } -/// The fMP4 stdin container: whether to unwrap its fragments. +/// The fMP4 stdin container: whether to unwrap its fragments, and where a player gets the +/// licenses for encrypted ones. #[derive(usage_rs::Args, Clone)] #[usage(unknown_flags = "error", args_override_self = false)] pub struct Fmp4Import { /// Publish each fragment whole as CMAF instead of splitting it into one frame per sample. /// Keeps the source's exact sample timing, but every player has to parse ISO BMFF. + /// Encrypted (Common Encryption) media needs it. #[usage(long = "cmaf")] pub passthrough: bool, + + /// The license server of a DRM system the media is encrypted for, as `SYSTEM=URL`. SYSTEM is + /// `widevine`, `playready`, `fairplay`, `clearkey`, or a system ID. Repeat for each system; + /// a system the media carries no `pssh` for is refused. + #[usage(long = "drm-license", value_name = "SYSTEM=URL", requires = "--cmaf")] + pub drm_license: Vec, + + /// The certificate server of a DRM system, such as FairPlay's, as `SYSTEM=URL`. + #[usage(long = "drm-certificate", value_name = "SYSTEM=URL", requires = "--cmaf")] + pub drm_certificate: Vec, +} + +impl Fmp4Import { + /// The servers of each DRM system the flags name. + fn drm(&self) -> std::collections::BTreeMap { + let mut drm = std::collections::BTreeMap::<_, hang::catalog::drm::Servers>::new(); + for server in &self.drm_license { + drm.entry(server.system).or_default().license = Some(hang::catalog::drm::Server::new(server.url.clone())); + } + for server in &self.drm_certificate { + drm.entry(server.system).or_default().certificate = + Some(hang::catalog::drm::Server::new(server.url.clone())); + } + drm + } +} + +/// An `import fmp4 --drm-license` or `--drm-certificate` value: a DRM system and a server URL. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct DrmServer { + /// The DRM system ID. + pub system: hang::catalog::drm::Uuid, + /// The server's URL. + pub url: url::Url, +} + +impl std::str::FromStr for DrmServer { + type Err = String; + + fn from_str(arg: &str) -> Result { + let (system, url) = arg + .split_once('=') + .ok_or_else(|| format!("expected SYSTEM=URL, got `{arg}`"))?; + let system = hang::catalog::drm::system::named(system) + .or_else(|| hang::catalog::drm::Uuid::try_parse(system).ok()) + .ok_or_else(|| { + format!( + "unknown DRM system `{system}`: expected widevine, playready, fairplay, clearkey, or a system ID" + ) + })?; + let url = url.parse().map_err(|err| format!("invalid URL `{url}`: {err}"))?; + Ok(Self { system, url }) + } } /// The MPEG-TS stdin container: which programs of a multiplex to publish. @@ -1988,6 +2044,48 @@ mod tests { assert!(matches!(format(&[]), Some(PublishFormat::Ts { program: None }))); } + /// `import fmp4 --drm-license` and `--drm-certificate` name a system and need `--cmaf`. + #[test] + fn import_fmp4_takes_drm_servers() { + use hang::catalog::drm; + + let format = |args: &[&str]| { + let argv = ["moq", "import", "fmp4"].into_iter().chain(args.iter().copied()); + let cli = Invocation::try_parse_from(argv).ok()?; + let Command::Import(import) = &cli.stages[0] else { + panic!("an import stage"); + }; + import.source.stdin_format() + }; + let Some(PublishFormat::Fmp4 { passthrough: true, drm }) = format(&[ + "--cmaf", + "--drm-license", + "clearkey=https://license.example.com/clearkey", + "--drm-license", + "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed=https://wv.example.com/", + "--drm-certificate", + "FairPlay=https://fps.example.com/cert", + ]) else { + panic!("an fmp4 import"); + }; + assert_eq!(drm.len(), 3); + assert_eq!( + drm[&drm::system::CLEARKEY].license.as_ref().unwrap().url.as_str(), + "https://license.example.com/clearkey" + ); + assert!(drm[&drm::system::WIDEVINE].certificate.is_none()); + assert!(drm[&drm::system::FAIRPLAY].license.is_none()); + assert!(drm[&drm::system::FAIRPLAY].certificate.is_some()); + + assert!( + format(&["--drm-license", "clearkey=https://a.example/"]).is_none(), + "needs --cmaf" + ); + assert!(format(&["--cmaf", "--drm-license", "primetime=https://a.example/"]).is_none()); + assert!(format(&["--cmaf", "--drm-license", "clearkey"]).is_none()); + assert!(format(&["--cmaf", "--drm-license", "clearkey=not a url"]).is_none()); + } + /// `import srt` takes the same `--program` as `import ts`; `export srt` has no program to pick. #[test] fn import_srt_takes_a_program() { diff --git a/rs/moq-cli/src/publish.rs b/rs/moq-cli/src/publish.rs index a2e10ff1581..d4ba0bb1df0 100644 --- a/rs/moq-cli/src/publish.rs +++ b/rs/moq-cli/src/publish.rs @@ -3,12 +3,16 @@ use hang::moq_net; use moq_mux::container::{flv, fmp4, ts}; /// Container format read from stdin on the import (source) side. -#[derive(Clone, Copy)] +#[derive(Clone)] pub enum PublishFormat { /// Raw AVC (H.264) Annex B elementary stream. Avc3, - /// Fragmented MP4 (CMAF), republished whole as CMAF when `passthrough`. - Fmp4 { passthrough: bool }, + /// Fragmented MP4 (CMAF), republished whole as CMAF when `passthrough`, with the license and + /// certificate servers of each DRM system encrypted media is for. + Fmp4 { + passthrough: bool, + drm: std::collections::BTreeMap, + }, /// MPEG-TS (transport stream), limited to one `program` of a multiplex when given. Ts { program: Option }, /// MPEG-TS published whole, paced on `pcr_pid` when given rather than the PMT's clock. @@ -432,9 +436,12 @@ impl Publish { import: Box::new(import), } } - PublishFormat::Fmp4 { passthrough } => { + PublishFormat::Fmp4 { passthrough, drm } => { let timebase = catalog.timebase(); - let fmp4 = fmp4::Import::new(broadcast.clone(), timebase.reserve()).with_passthrough(*passthrough); + let mut fmp4 = fmp4::Import::new(broadcast.clone(), timebase.reserve()).with_passthrough(*passthrough); + for (system, servers) in drm { + fmp4 = fmp4.with_drm(*system, servers.clone()); + } PublishDecoder::Fmp4(Box::new(fmp4)) } PublishFormat::Ts { .. } => unreachable!("TS is handled above with the mpegts catalog extension"), @@ -2135,8 +2142,20 @@ pub(crate) mod tests { for (format, input) in [ (PublishFormat::Ts { program: None }, TS), (PublishFormat::TsPassthrough { pcr_pid: None }, TS), - (PublishFormat::Fmp4 { passthrough: false }, FMP4), - (PublishFormat::Fmp4 { passthrough: true }, FMP4), + ( + PublishFormat::Fmp4 { + passthrough: false, + drm: Default::default(), + }, + FMP4, + ), + ( + PublishFormat::Fmp4 { + passthrough: true, + drm: Default::default(), + }, + FMP4, + ), ] { let origin = moq_tokio::origin::spawn(); let consumer = origin.consume(); From 70468658350e5a1a7d6dfbfa91b00a8e645826c3 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 17:41:06 +0100 Subject: [PATCH 06/23] feat(msf): CMSF content protection in JavaScript @moq/msf reads and writes the root contentProtections array and each track's contentProtectionRefIDs, refusing a track that references an entry the root lacks, as moq-msf does. Co-Authored-By: Claude Opus 5.5 --- js/msf/src/catalog.test.ts | 31 +++++++++++++++++++++ js/msf/src/catalog.ts | 55 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/js/msf/src/catalog.test.ts b/js/msf/src/catalog.test.ts index b5d4b91e2ec..97ac52f1bb6 100644 --- a/js/msf/src/catalog.test.ts +++ b/js/msf/src/catalog.test.ts @@ -322,3 +322,34 @@ test("refuses malformed Unicode in catalogs", () => { const prefix = new TextEncoder().encode('{"version":1,"extension":"'); expect(() => decode(new Uint8Array([...prefix, 0xff, 0x22, 0x7d]))).toThrow(); }); + +// Mirrors moq-msf: CMSF content protection round-trips, and a dangling refID is refused. +test("content protection round-trips and a dangling refID is refused", () => { + const contentProtections = [ + { + refID: "1", + defaultKID: ["a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90"], + scheme: "cbcs", + drmSystem: { + systemID: "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + laURL: { url: "https://license.example.com/", type: "EME-1.0" }, + pssh: "AAAA", + }, + }, + ]; + const track = { name: "video", packaging: "cmaf", isLive: true, role: "video", codec: "avc1.64001f" }; + const catalog = decode( + encodeJson({ + version: "draft-01", + contentProtections, + tracks: [{ ...track, contentProtectionRefIDs: ["1"] }], + }), + ); + expect(catalog.contentProtections).toEqual(contentProtections); + expect(catalog.tracks[0].contentProtectionRefIDs).toEqual(["1"]); + expect(catalog.ext).toBeUndefined(); + expect(decode(encode(catalog))).toEqual(catalog); + + const dangling = encodeJson({ version: "draft-01", tracks: [{ ...track, contentProtectionRefIDs: ["2"] }] }); + expect(() => decode(dangling)).toThrow("missing content protection"); +}); diff --git a/js/msf/src/catalog.ts b/js/msf/src/catalog.ts index 78438c20a79..b876b484fb7 100644 --- a/js/msf/src/catalog.ts +++ b/js/msf/src/catalog.ts @@ -48,6 +48,8 @@ const trackShape = { altGroup: z.optional(z.number()), maxGrpSapStartingType: z.optional(z.number()), maxObjSapStartingType: z.optional(z.number()), + /** The `refID`s of the root `contentProtections` entries protecting this track (CMSF 4.1.2). */ + contentProtectionRefIDs: z.optional(z.array(z.string())), // Non-standard: maximum delay (ms) between consecutive frames on this track. // The player's buffer must be at least this large to avoid underruns. @@ -59,6 +61,40 @@ const trackShape = { delay: z.optional(z.number()), }; +/** A service URL in a {@link DrmSystem}, with an optional protocol or MIME type. */ +export const ProtectionUrlSchema = z.object({ + url: z.string(), + type: z.optional(z.string()), +}); + +/** + * A DRM system description (CMSF 4.1.1.4). draft-ietf-moq-cmsf-01 names no member for its + * authorization URL or robustness, so neither is carried. + */ +export const DrmSystemSchema = z.object({ + systemID: z.string(), + laURL: z.optional(ProtectionUrlSchema), + certURL: z.optional(ProtectionUrlSchema), + /** A base64 `pssh` box with the system's initialization data. */ + pssh: z.optional(z.string()), +}); + +/** A DRM system description within a {@link ContentProtection}. */ +export type DrmSystem = z.infer; + +/** One DRM system configuration protecting tracks of the broadcast (CMSF 4.1.1). */ +export const ContentProtectionSchema = z.object({ + refID: z.string(), + /** The default key IDs (`default_KID`) as UUID strings. */ + defaultKID: z.array(z.string()), + /** The Common Encryption scheme, `cenc` or `cbcs`. */ + scheme: z.string(), + drmSystem: DrmSystemSchema, +}); + +/** One DRM system configuration protecting tracks of the broadcast. */ +export type ContentProtection = z.infer; + /** Zod schema describing a single track entry in an MSF catalog. */ export const TrackSchema = z.object(trackShape); @@ -68,6 +104,8 @@ export type Track = z.infer; /** Zod schema for the top-level MSF catalog: a version-agnostic snapshot of tracks. */ export const CatalogSchema = z.object({ tracks: z.array(TrackSchema), + /** The DRM systems protecting the tracks, which reference them by `refID` (CMSF 4.1.1). */ + contentProtections: z.optional(z.array(ContentProtectionSchema)), // The application extension: root members beyond the ones MSF defines, kept // verbatim. An extension adds a section here, e.g. the `mpegts` section of // draft-lcurley-moq-mpegts. Mirrors `Catalog::ext` in `moq-msf`, which is typed; @@ -80,7 +118,7 @@ export const CatalogSchema = z.object({ export type Catalog = z.infer; /** Root member names MSF itself defines, which an extension section must not reuse. */ -const RESERVED_ROOT = ["version", "generatedAt", "isComplete", "tracks", "initDataList"]; +const RESERVED_ROOT = ["version", "generatedAt", "isComplete", "tracks", "initDataList", "contentProtections"]; /** The newest MSF draft version string this package emits on the wire. */ export const VERSION = "draft-01"; @@ -107,6 +145,7 @@ const WireCatalogSchema = z.object({ version: z.union([z.literal(1), z.string()]), tracks: z.optional(z.array(WireTrackSchema)), initDataList: z.optional(z.array(InitDataSchema)), + contentProtections: z.optional(z.array(ContentProtectionSchema)), }); /** Serialize a catalog to its JSON wire representation (draft-01). */ @@ -135,6 +174,7 @@ export function encode(catalog: Catalog): Uint8Array { // the member from the encoded catalog. const wire: Record = Object.assign(Object.create(null), { version: VERSION, tracks }); if (initDataList.length > 0) wire.initDataList = initDataList; + if (catalog.contentProtections?.length) wire.contentProtections = catalog.contentProtections; // Extension members are written flat, so one named after a field MSF defines would // emit a duplicate key and lose one of the two on re-parse. Refuse instead. The Rust @@ -171,8 +211,16 @@ export function decode(raw: Uint8Array): Catalog { byId.set(entry.id, entry); } + // A track's protection refers to a root entry by refID; one that names none would claim + // encryption the catalog cannot describe, so it is refused like a missing initRef. + const refIDs = new Set((wire.contentProtections ?? []).map((cp) => cp.refID)); + const tracks = (wire.tracks ?? []).map(({ initRef, ...track }) => { track.isLive ??= false; + const missing = track.contentProtectionRefIDs?.find((id) => !refIDs.has(id)); + if (missing !== undefined) { + throw new Error(`MSF track "${track.name}" references missing content protection "${missing}"`); + } // Resolve draft-01 initRef into inline initData so callers never see the // indirection. Inline initData (draft-00) is kept as-is, but a catalog that @@ -196,7 +244,10 @@ export function decode(raw: Uint8Array): Catalog { return track; }); - return Object.keys(ext).length > 0 ? { tracks, ext } : { tracks }; + const catalog: Catalog = { tracks }; + if (wire.contentProtections?.length) catalog.contentProtections = wire.contentProtections; + if (Object.keys(ext).length > 0) catalog.ext = ext; + return catalog; } /** Read and decode the next catalog frame from a track, or undefined if the track ended. */ From d09f284ecbc9507debf45ebeffc7e9a71309e91f Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 17:41:08 +0100 Subject: [PATCH 07/23] feat(watch): hide protected renditions as unplayable WebCodecs cannot decrypt, so the video and audio decoders' support probes refuse a rendition that lists drm entries, and never selects it; a protected rendition joins the decoder identity. An MSF catalog's content protection maps onto the hang drm section, so a protected MSF track is hidden the same way. Co-Authored-By: Claude Opus 5.5 --- js/watch/src/audio/config.ts | 3 ++- js/watch/src/audio/decoder.ts | 6 +++++ js/watch/src/msf.test.ts | 40 +++++++++++++++++++++++++++++ js/watch/src/msf.ts | 46 ++++++++++++++++++++++++++++++++-- js/watch/src/protected.test.ts | 23 +++++++++++++++++ js/watch/src/video/config.ts | 3 ++- js/watch/src/video/decoder.ts | 6 +++++ 7 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 js/watch/src/protected.test.ts diff --git a/js/watch/src/audio/config.ts b/js/watch/src/audio/config.ts index 4452effc5a4..51d2c186a7d 100644 --- a/js/watch/src/audio/config.ts +++ b/js/watch/src/audio/config.ts @@ -13,7 +13,7 @@ const MP3_MPEG1_MIN_SAMPLE_RATE = 32000; /** The catalog fields that determine the demuxer and WebCodecs decoder instance. */ export type DecoderConfig = Pick< Catalog.AudioConfig, - "codec" | "container" | "description" | "sampleRate" | "numberOfChannels" | "warmup" + "codec" | "container" | "description" | "sampleRate" | "numberOfChannels" | "warmup" | "drm" >; /** The routing and decoder state whose changes require a replacement subscription. */ @@ -33,6 +33,7 @@ export function decoderConfig(config: Catalog.AudioConfig): DecoderConfig { sampleRate: config.sampleRate, numberOfChannels: config.numberOfChannels, warmup: config.warmup, + drm: config.drm, }; } diff --git a/js/watch/src/audio/decoder.ts b/js/watch/src/audio/decoder.ts index 4dad4c81cb9..18195723bae 100644 --- a/js/watch/src/audio/decoder.ts +++ b/js/watch/src/audio/decoder.ts @@ -1020,6 +1020,12 @@ async function supported(config: Catalog.AudioConfig): Promise { return false; } + // WebCodecs cannot decrypt, so an encrypted rendition is unplayable here. + if (Catalog.isProtected(config)) { + console.warn(`audio: ignoring protected rendition ${config.codec}: playback cannot decrypt it`); + return false; + } + // Opus only runs at its native rates, so a catalog advertising anything else is wrong and Safari // refuses to decode it. Warn rather than reject: Chrome and Firefox ignore the configured rate and // play these streams fine, so rejecting would silence them for a publisher they handle today. diff --git a/js/watch/src/msf.test.ts b/js/watch/src/msf.test.ts index 3303c7564d1..21ae0279f81 100644 --- a/js/watch/src/msf.test.ts +++ b/js/watch/src/msf.test.ts @@ -1,4 +1,5 @@ import { expect, test } from "bun:test"; +import * as Catalog from "@moq/hang/catalog"; import { u53 } from "@moq/hang/catalog"; import * as Msf from "@moq/msf"; import { Path } from "@moq/net"; @@ -317,3 +318,42 @@ test("a later MSF track with a name replaces the earlier one, whatever its role" "vp09.00.10.08", ); }); + +// A protected MSF track lands as a hang rendition listing its `drm` entries, so `` +// knows it cannot play it; an entry with two keys splits into one hang entry per key. +test("maps CMSF content protection onto hang drm entries", () => { + const catalog: Msf.Catalog = { + contentProtections: [ + { + refID: "ck", + defaultKID: ["a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90"], + scheme: "cbcs", + drmSystem: { systemID: "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", laURL: { url: "https://l.example/" } }, + }, + { + refID: "wv", + defaultKID: ["01234567-89ab-cdef-0123-456789abcdef", "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90"], + scheme: "cbcs", + drmSystem: { systemID: "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" }, + }, + ], + tracks: [ + { name: "video", packaging: "loc", role: "video", codec: "vp8", contentProtectionRefIDs: ["ck", "wv"] }, + { name: "audio", packaging: "loc", role: "audio", codec: "opus" }, + ], + }; + const root = Catalog.checkRenditions(toHang(catalog)); + expect(Object.keys(root.drm ?? {}).sort()).toEqual([ + "ck", + "wv:01234567-89ab-cdef-0123-456789abcdef", + "wv:a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + ]); + expect(root.drm?.ck?.license?.url).toBe("https://l.example/"); + expect(root.video?.renditions.video?.drm).toHaveLength(3); + expect(Catalog.isProtected(root.video?.renditions.video ?? { drm: [] })).toBe(true); + expect(root.audio?.renditions.audio?.drm).toBeUndefined(); + + const cens = structuredClone(catalog); + if (cens.contentProtections?.[0]) cens.contentProtections[0].scheme = "cens"; + expect(() => toHang(cens)).toThrow("unsupported scheme"); +}); diff --git a/js/watch/src/msf.ts b/js/watch/src/msf.ts index 9d7219cdc4c..e9cfb68d4da 100644 --- a/js/watch/src/msf.ts +++ b/js/watch/src/msf.ts @@ -119,8 +119,48 @@ function namesCatalog(namespace: Path.Valid, base: Path.Valid): boolean { return endsWith(a, b) || endsWith(b, a); } +/** + * The hang `drm` entries an MSF catalog's `contentProtections` describe, and each `refID`'s entry IDs. + * + * Mirrors moq-mux: an entry naming several default keys becomes one hang entry per key, + * `{refID}:{kid}`. A track referencing it lists all of them here, which is enough to know it is + * protected; moq-mux picks the one its init's `tenc` names. + */ +function toDrm(msf: Msf.Catalog): { drm: Record; byRef: Map } { + const drm: Record = Object.create(null); + const byRef = new Map(); + for (const cp of msf.contentProtections ?? []) { + if (cp.scheme !== "cenc" && cp.scheme !== "cbcs") { + throw new Error(`MSF content protection ${cp.refID} has unsupported scheme ${cp.scheme}`); + } + if (cp.defaultKID.length === 0) throw new Error(`MSF content protection ${cp.refID} has no defaultKID`); + const ids: string[] = []; + for (const kid of cp.defaultKID) { + const id = cp.defaultKID.length === 1 ? cp.refID : `${cp.refID}:${kid.toLowerCase()}`; + drm[id] = { + system: cp.drmSystem.systemID, + scheme: cp.scheme, + kid, + pssh: cp.drmSystem.pssh, + license: cp.drmSystem.laURL, + certificate: cp.drmSystem.certURL, + }; + ids.push(id); + } + byRef.set(cp.refID, ids); + } + return { drm, byRef }; +} + /** Convert an MSF catalog to a hang catalog Root. */ export function toHang(msf: Msf.Catalog, base?: Path.Valid): Catalog.Root { + const { drm, byRef } = toDrm(msf); + // The hang entry IDs a track's refIDs name; @moq/msf refuses a refID the root lacks. + const protection = (track: Msf.Track) => { + const ids = (track.contentProtectionRefIDs ?? []).flatMap((id) => byRef.get(id) ?? []); + return ids.length > 0 ? { drm: ids } : {}; + }; + // Track names are untrusted keys; a null prototype keeps `__proto__` an ordinary rendition. const videoRenditions: Record = Object.create(null); const audioRenditions: Record = Object.create(null); @@ -151,10 +191,10 @@ export function toHang(msf: Msf.Catalog, base?: Path.Valid): Catalog.Root { } if (track.role === "video") { const config = toVideoConfig(track); - if (config) videoRenditions[track.name] = { ...config, broadcast }; + if (config) videoRenditions[track.name] = { ...config, broadcast, ...protection(track) }; } else if (track.role === "audio") { const config = toAudioConfig(track); - if (config) audioRenditions[track.name] = { ...config, broadcast }; + if (config) audioRenditions[track.name] = { ...config, broadcast, ...protection(track) }; } else if ( track.role === "caption" || track.role === "subtitle" || @@ -192,5 +232,7 @@ export function toHang(msf: Msf.Catalog, base?: Path.Valid): Catalog.Root { if (Object.keys(textRenditions).length > 0) root.text = { renditions: textRenditions }; + if (Object.keys(drm).length > 0) root.drm = drm; + return root; } diff --git a/js/watch/src/protected.test.ts b/js/watch/src/protected.test.ts new file mode 100644 index 00000000000..bc7c29fb14b --- /dev/null +++ b/js/watch/src/protected.test.ts @@ -0,0 +1,23 @@ +import { expect, mock, test } from "bun:test"; +import * as Catalog from "@moq/hang/catalog"; + +// Bun cannot load the blob-URL worklet import, so mock it before the decoder imports it. +mock.module("./audio/render-worklet.ts?worklet", () => ({ default: async () => "blob:fake-render" })); +const Audio = await import("./audio/decoder"); +const Video = await import("./video/decoder"); + +// WebCodecs cannot decrypt, so `` treats a protected rendition as unplayable before it +// asks the decoder, whatever the codec. +test("protected renditions are unplayable", async () => { + const cmaf = { kind: "cmaf", init: "AAAA" }; + const video = Catalog.VideoConfigSchema.parse({ codec: "avc1.64001f", container: cmaf, drm: ["1"] }); + const audio = Catalog.AudioConfigSchema.parse({ + codec: "mp4a.40.2", + container: cmaf, + sampleRate: 48000, + numberOfChannels: 2, + drm: ["1"], + }); + expect(await Video.Decoder.supported(video)).toBe(false); + expect(await Audio.Decoder.supported(audio)).toBe(false); +}); diff --git a/js/watch/src/video/config.ts b/js/watch/src/video/config.ts index fd5cd257781..0faade426c7 100644 --- a/js/watch/src/video/config.ts +++ b/js/watch/src/video/config.ts @@ -3,7 +3,7 @@ import type * as Catalog from "@moq/hang/catalog"; /** The catalog fields that determine the demuxer and WebCodecs decoder instance. */ export type DecoderConfig = Pick< Catalog.VideoConfig, - "codec" | "container" | "description" | "displayAspectWidth" | "displayAspectHeight" + "codec" | "container" | "description" | "displayAspectWidth" | "displayAspectHeight" | "drm" > & { optimizeForLatency: boolean; interlaced: boolean; @@ -29,6 +29,7 @@ export function playbackIdentity(config: Catalog.VideoConfig): PlaybackIdentity description: config.description, displayAspectWidth: config.displayAspectWidth, displayAspectHeight: config.displayAspectHeight, + drm: config.drm, optimizeForLatency: config.optimizeForLatency ?? true, interlaced: config.interlaced ?? false, }, diff --git a/js/watch/src/video/decoder.ts b/js/watch/src/video/decoder.ts index 38503bb77bc..7f4de364ed0 100644 --- a/js/watch/src/video/decoder.ts +++ b/js/watch/src/video/decoder.ts @@ -1272,6 +1272,12 @@ async function supported(config: Catalog.VideoConfig): Promise { return false; } + // WebCodecs cannot decrypt, so an encrypted rendition is unplayable here. + if (Catalog.isProtected(config)) { + console.warn(`video: ignoring protected rendition ${config.codec}: playback cannot decrypt it`); + return false; + } + let description: Uint8Array | undefined; if (config.description) { description = Util.Hex.toBytes(config.description); From 0f17c1f810abf98041a5a13a8b0139b5c8d70eab Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 17:43:19 +0100 Subject: [PATCH 08/23] docs(hang): the drm catalog section and protected CMAF import The moq-hang draft defines the root drm map and the rendition drm field and their mapping onto CMSF contentProtections; the catalog concept page and the CLI page cover importing Common Encryption fMP4 with license servers, and why does not play it yet. Co-Authored-By: Claude Opus 5.5 --- doc/bin/cli.md | 14 +++++++++++ doc/concept/hang.md | 31 ++++++++++++++++++++++++ drafts/draft-lcurley-moq-hang.md | 41 ++++++++++++++++++++++++++++++-- 3 files changed, 84 insertions(+), 2 deletions(-) diff --git a/doc/bin/cli.md b/doc/bin/cli.md index 80f1dcf0b85..26d06e7df79 100644 --- a/doc/bin/cli.md +++ b/doc/bin/cli.md @@ -157,6 +157,20 @@ MP4 parser. `import fmp4 --cmaf` publishes each fragment whole as [`cmaf`](/concept/hang#container) instead, keeping the source's exact sample timing. +`import fmp4 --cmaf` also publishes Common Encryption (`cenc` and `cbcs`) media, +such as Shaka Packager's output, unchanged, and signals it in the catalog's +[`drm`](/concept/hang#content-protection) section. Name each DRM system's +license server with `--drm-license SYSTEM=URL`, and FairPlay's certificate with +`--drm-certificate SYSTEM=URL`; SYSTEM is `widevine`, `playready`, `fairplay`, +`clearkey`, or a system ID, and one the media carries no `pssh` for is +refused. Encrypted media without `--cmaf`, key rotation, and a clear lead are +refused too. + +```bash +moq --connect https://relay.example.com/anon --broadcast movie.hang \ + import fmp4 --cmaf --drm-license clearkey=https://license.example.com/clearkey < cbcs.mp4 +``` + `import rtsp` pulls an IP camera's H.264 or H.265 video and AAC audio without re-encoding. RTP rides the RTSP connection, so run it on the camera's network and the camera needs no inbound port. Credentials go in the URL diff --git a/doc/concept/hang.md b/doc/concept/hang.md index a7b9e77fbd4..2a7ba72bcc0 100644 --- a/doc/concept/hang.md +++ b/doc/concept/hang.md @@ -64,6 +64,7 @@ A few things the catalog can express beyond decoder config: - **Labels.** Any rendition may carry a human-readable `label` for a track picker. The map key stays the rendition's ID, so labels need not be unique and renaming one doesn't rename the track. - **Renditions in another broadcast.** A rendition may point at a relative broadcast path, so a transcoder can publish a ladder that adds low rungs and references the source's original rendition without re-publishing its bytes. The path resolves against where the consumer found the catalog, so a reference that escapes above the root names nothing and the catalog is rejected. `@moq/watch` and `moqsrc` follow a referenced path's announcements like their own, restarting the rendition on each instance that serves it; every other reader, such as `moq play`, the exporters, and the bindings, waits for the first one announced and keeps it, and an exporter ends the rendition with it. An optional `instance` beside the path names the [stream](/concept/moq-lite#publisher-instances) it expects: a route of another instance ends the rendition instead of falling back to it, while a route whose instance a session minted (one that crossed an older version) cannot prove one, so there it is best effort. Omit `instance` for a broadcast produced on demand, which has none until a worker answers; see [identity and recovery](/concept/identity). - **Whole contributions.** A root `contributions` map names whole broadcasts, such as each guest feed in a composed room, by the same relative path and optional `instance` as a rendition's reference. Listing one opens nothing, so a contribution produced on demand starts only once a viewer selects it, which `@moq/watch` does with `broadcast.contribution(effect, id)`. Its rendition IDs stay its own. +- **DRM.** A root `drm` map describes the DRM systems protecting Common Encryption (`cenc` or `cbcs`) CMAF renditions, one entry per system, scheme, and key: its `system` and `kid` UUIDs, the `pssh` box, and the `license` and `certificate` servers. A protected rendition lists its entries' IDs in its own `drm` field, keeps the encrypted sample entry in its `init`, and names the codec that entry wraps; a rendition listing an ID the root lacks refuses the catalog. Renditions under one key share an entry. The MSF catalog carries the same entries as CMSF `contentProtections`. See [Content protection](#content-protection). - **Track names.** The map key is a rendition's ID and, by default, its track name. A rendition sets `track` only when the two must differ, such as two renditions of same-named tracks in different broadcasts, or a rendition whose media changed and so needs a new name; readers subscribe to `track` when present. An ID can't name both a video and an audio rendition. - **Jitter.** A rendition can say how much media it writes behind a frame's timestamp, in whole milliseconds rounded up: the reorder delay of B-frames and the span of a fragment or batch written together. It is measured from media timestamps alone, never the time a frame was written, so neither a constant encoder delay nor a capture clock counts. It describes the publisher, never the network, only grows over the life of a stream, and a player sizes its buffer to at least this much. A `0` is read as absent. - **Delay.** A rendition can also say how far its frames' timestamps trail those another rendition already wrote, so a video encoder running 200 ms behind audio advertises `delay: 200` on video. A rendition alone measures none. It follows the same rules as jitter. A player holds the largest `delay + jitter` among the renditions it subscribes to, and never subtracts one rendition's `delay` from another's. @@ -240,6 +241,36 @@ derived from the credential and a semantic name such as `foo.hang`; it carries no format marker. `moq-crypto` is the Rust implementation. Relays need no configuration to carry it. +## Content protection + +DRM is separate from moq-e2ee: the media itself is Common Encryption CMAF, +encrypted before it reaches MoQ by a packager such as Shaka Packager, and a +relay carries it like any other CMAF. `moq import fmp4 --cmaf` publishes such a +file unchanged and fills the catalog's `drm` section from each track's `schm`, +`tenc`, and `pssh` boxes. The license and certificate servers are not in the +media, so the publisher supplies them per DRM system, with `--drm-license` and +`--drm-certificate` or `fmp4::Import::with_drm`. + +```json +{ + "drm": { + "1": { + "system": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b", + "scheme": "cbcs", + "kid": "a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + "pssh": "AAAANHBzc2gB...", + "license": { "url": "https://license.example.com/clearkey" } + } + }, + "video": { "renditions": { "0.m4s": { "codec": "avc1.64000c", "drm": ["1"], "container": { "kind": "cmaf", "init": "..." } } } } +} +``` + +WebCodecs cannot decrypt, so `@moq/watch` treats a protected rendition as +unplayable and never selects it. Playback through MSE and EME is not built yet. +Key rotation and a clear lead are refused on import, as is anything else the +republished media could not decrypt. + ## Your own format hang is a convention, not a requirement. If you control both ends, publish diff --git a/drafts/draft-lcurley-moq-hang.md b/drafts/draft-lcurley-moq-hang.md index 52aae272f54..064de57ca2f 100644 --- a/drafts/draft-lcurley-moq-hang.md +++ b/drafts/draft-lcurley-moq-hang.md @@ -18,6 +18,14 @@ author: normative: moqmsf: I-D.ietf-moq-msf + moqcmsf: I-D.ietf-moq-cmsf + cenc: + title: "Information technology - MPEG systems technologies - Part 7: Common encryption in ISO base media file format files" + author: + - org: ISO/IEC + seriesinfo: + ISO/IEC: 23001-7 + date: false moql: I-D.lcurley-moq-lite moqflate: title: "DEFLATE Compressed Tracks for MoQ" @@ -160,6 +168,7 @@ type Catalog = { "broadcast": string, "instance": string | undefined, }> | undefined, + "drm": Record | undefined, // ... any custom fields ... } ~~~ @@ -172,7 +181,7 @@ For example, a chat entry should name a chat track, not carry individual chat me This way catalog updates are rare and a client MAY choose to not subscribe. The `json` and `binary` sections ({{data}}) are how a track like that is listed. -This specification defines audio, video, and text media tracks, an optional `media` section ({{media}}) holding the clock that maps content time to wall time and the interval a viewer can join on, the root `version` ({{catalog-version}}), the application data tracks in {{data}}, optional publisher statistics and solicited viewer feedback ({{media-stats}}), and whole broadcasts listed as `contributions` ({{contributions}}). +This specification defines audio, video, and text media tracks, an optional `media` section ({{media}}) holding the clock that maps content time to wall time and the interval a viewer can join on, the root `version` ({{catalog-version}}), the application data tracks in {{data}}, optional publisher statistics and solicited viewer feedback ({{media-stats}}), whole broadcasts listed as `contributions` ({{contributions}}), and the DRM systems protecting encrypted renditions ({{drm}}). ## Version {#catalog-version} The root `version` field is the oldest draft of this specification that reads the catalog correctly, by draft number: `4` needs a consumer of moq-hang-04 or later. @@ -188,7 +197,7 @@ This draft needs `version` 4 for: - a `track` ({{field-track}}) other than the entry's ID, which an older consumer subscribes to instead; - a video `warmup` ({{field-warmup}}) above zero, since an older consumer starts decoding a group at a picture that is not a keyframe. -Every other catalog change in this draft is safe to ignore: `enabled` ({{field-enabled}}) leaves an older consumer selecting a disabled rendition, which plays nothing; `media` ({{media}}) only offers the clock and join interval, which an older consumer goes without; `stats` and `echo` ({{media-stats}}) only offer optional tracks; `contributions` ({{contributions}}) only offer broadcasts to open on selection; video `reorder` leaves an older consumer inferring decode times from timestamps; `jitter`, `delay`, audio `warmup`, and the data track estimates are hints. +Every other catalog change in this draft is safe to ignore: `enabled` ({{field-enabled}}) leaves an older consumer selecting a disabled rendition, which plays nothing; `media` ({{media}}) only offers the clock and join interval, which an older consumer goes without; `stats` and `echo` ({{media-stats}}) only offer optional tracks; `contributions` ({{contributions}}) only offer broadcasts to open on selection; `drm` ({{drm}}) leaves an older consumer reading a rendition its init segment already marks as encrypted; video `reorder` leaves an older consumer inferring decode times from timestamps; `jitter`, `delay`, audio `warmup`, and the data track estimates are hints. ## Media {#media} The catalog's root `media` field holds what applies to every audio and video track: @@ -252,6 +261,33 @@ A contribution's rendition IDs belong to its own catalog and MUST NOT replace ID An unavailable contribution does not invalidate the listing catalog. A consumer does not expand a contribution's own `contributions`: each needs a selection of its own. +## DRM {#drm} +The optional root `drm` map describes the DRM systems protecting encrypted renditions. +Each key is an entry ID, and each entry is one DRM system for one Common Encryption scheme and one key: + +~~~ +type DrmSchema = { + "system": string, + "scheme": "cenc" | "cbcs", + "kid": string, + "pssh": string | undefined, + "license": { "url": string, "type": string | undefined } | undefined, + "certificate": { "url": string, "type": string | undefined } | undefined, +} +~~~ + +The `system` field is the DRM system ID and `kid` the default key ID, each a hyphenated UUID string, and `scheme` is the Common Encryption scheme {{cenc}}. +The `pssh` field is the system's whole `pssh` box, base64-encoded ({{!RFC4648, Section 4}}). +The `license` field names the server a consumer requests a license from, and `certificate` the server certificate a system such as FairPlay needs first; each `type` is the license protocol or the certificate's MIME type. +Renditions encrypted under the same system, scheme, and key share an entry. + +A protected audio or video rendition lists the IDs of the entries that can decrypt it in its `drm` field, an array of strings; absent or empty means the rendition is clear. +Only a `cmaf` rendition ({{cmaf}}) can be protected: its `init` keeps the encrypted sample entry with its `sinf`, and the `pssh` boxes, while its `codec` names the codec the encrypted entry wraps. +A consumer MUST reject a catalog with a malformed entry, or with a rendition listing an ID the root `drm` lacks. +A consumer that cannot decrypt a rendition MUST treat it as one it cannot decode. + +Each entry maps 1:1 onto a CMSF `contentProtections` entry {{moqcmsf}}: the ID is its `refID`, `kid` its single `defaultKID`, `system`, `license`, `certificate`, and `pssh` its `drmSystem`'s `systemID`, `laURL`, `certURL`, and `pssh`, and a rendition's `drm` its `contentProtectionRefIDs`. + ## Track Identity {#identity} A track name always means the same content, so a catalog update never redefines an audio or video track. A track's identity is the fields a consumer cannot change without reinitializing its decoder or demuxer: `codec`, `description`, and `container`, plus `displayAspectWidth`, `displayAspectHeight`, and `interlaced` for video and `sampleRate` and `numberOfChannels` for audio. @@ -1124,6 +1160,7 @@ This document has no IANA actions. - Added the optional video `preference` field: a consumer selects automatically among the highest preference it can decode. - Added the optional video `reorder` field: the most frames that can precede one in decode order and follow it in presentation, fixed for the track once declared. A consumer that authors decode times derives them from it and the current group alone, refusing deeper reordering; without it, a consumer infers them from timestamps. - Added an optional `instance` beside every rendition and data track `broadcast` reference ({{field-instance}}). A consumer reads each referenced path from the first broadcast it resolves for a catalog instance; a present `instance` fails a rendition that resolves another stream, and is best effort against an Instance a receiver minted. +- Added the optional root `drm` map ({{drm}}) and the audio and video `drm` field: the DRM systems, scheme, and key protecting a Common Encryption `cmaf` rendition, mapping onto CMSF `contentProtections`. A dangling entry ID refuses the catalog. - Added the optional root `contributions` map ({{contributions}}): whole broadcasts named by a relative `broadcast` and an optional `instance`, opened only on selection, whose rendition IDs stay their own. - Added optional `stats` and `echo` catalog sections, publisher/viewer snapshots keyed by rendition ID, and the `.echo` feedback broadcast convention. - An Opus frame timestamp counts the OpusHead pre-skip: a consumer presents each decoded sample the pre-skip earlier than its frame timestamp places it. From 56914d024fa30ee4ea3c5f320cd56cbdcc8e1902 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 20:14:08 +0100 Subject: [PATCH 09/23] fix(mux): refuse an encrypted fragment without senc A fragment whose samples need a senc (per-sample IVs, or encrypted video's subsample maps) and carries none, or only PIFF's uuid box, was republished undecryptable. Refuse it as InvalidProtection. Also drop the never-built Error::ProtectedEdit, name the sample in a senc/saiz that lacks one (ProtectionLacksSample), check saiz's sample count when restating, and test restating a mid-GOP start and the scheme whitelist. Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/container/fmp4/cenc.rs | 47 +++++-- rs/moq-mux/src/container/fmp4/import.rs | 8 +- rs/moq-mux/src/container/fmp4/import_test.rs | 141 +++++++++++++++++++ rs/moq-mux/src/container/fmp4/mod.rs | 12 +- 4 files changed, 191 insertions(+), 17 deletions(-) diff --git a/rs/moq-mux/src/container/fmp4/cenc.rs b/rs/moq-mux/src/container/fmp4/cenc.rs index 95893efdafa..e3a2b5d000c 100644 --- a/rs/moq-mux/src/container/fmp4/cenc.rs +++ b/rs/moq-mux/src/container/fmp4/cenc.rs @@ -20,7 +20,7 @@ pub(crate) struct Protection { /// The moov's `pssh` boxes that apply to this track, in their order there. pub pssh: Vec, /// How each fragment's encryption information is laid out. - pub aux: Aux, + aux: Aux, } /// How an encrypted track's `senc` lays out each sample's encryption information. @@ -28,6 +28,9 @@ pub(crate) struct Protection { pub(crate) struct Aux { /// The size of each sample's IV, 0 under a constant IV. iv_size: u8, + /// Every fragment must carry a `senc`: the samples have per-sample IVs, or they are video, + /// which Common Encryption only protects with subsample maps. + senc: bool, } impl Protection { @@ -81,8 +84,12 @@ impl Protection { return Err(Error::MissingPssh.into()); } + let iv_size = tenc.default_per_sample_iv_size; + let video = matches!(codecs[..], [mp4_atom::Codec::Encv(_)]); let aux = Aux { - iv_size: tenc.default_per_sample_iv_size, + iv_size, + // A clear-by-default track (no seig, refused above) has no encryption information. + senc: tenc.default_is_protected && (iv_size > 0 || video), }; Ok(Some(Self { scheme, kid, pssh, aux })) } @@ -111,11 +118,23 @@ impl Protection { } impl Aux { + /// Refuse a fragment that lacks the `senc` its samples need to be decrypted. + /// + /// mp4-atom reads only the ISO `senc`, so this also refuses one that carries its information + /// only in PIFF's `uuid` box, which the rebuilt fragment would drop. + pub fn check(&self, traf: &mp4_atom::Traf) -> Result<()> { + if self.senc && traf.senc.is_none() { + return Err(Error::InvalidProtection("encrypted fragment without senc").into()); + } + Ok(()) + } + /// Restate `source`'s encryption information in `kept`, the same fragment holding only the /// samples at `indices`, ascending positions among `source`'s samples. /// - /// The edit list drops samples a packager kept for decoding, such as AAC's priming frame, - /// and the samples that remain still need their IVs and subsample maps. + /// The importer drops samples an edit list skips, such as AAC's priming frame, and those before + /// the first sync sample of a stream joined mid-GOP; the samples that remain still need their + /// IVs and subsample maps. pub fn restate(&self, source: &mp4_atom::Traf, kept: &mut mp4_atom::Traf, indices: &[usize]) -> Result<()> { let Some(senc) = &source.senc else { // Nothing per sample to keep: a constant IV over whole samples. Information elsewhere @@ -136,9 +155,10 @@ impl Aux { let mut data = Vec::with_capacity(senc.data.len()); data.extend_from_slice(&(indices.len() as u32).to_be_bytes()); for &index in indices { - let entry = entries - .get(index) - .ok_or(Error::InvalidProtection("senc lacks a sample"))?; + let entry = entries.get(index).ok_or(Error::ProtectionLacksSample { + aux: "senc", + sample: index, + })?; data.extend_from_slice(entry); } kept.senc = Some(mp4_atom::Senc { @@ -149,11 +169,18 @@ impl Aux { let mut saiz = source.saiz.iter().filter(|saiz| is_cenc(saiz.aux_info.as_ref())); if let Some(saiz) = saiz.next() { + if saiz.sample_count as u64 != super::sample::count(source) { + return Err(Error::InvalidProtection("saiz and trun disagree on the sample count").into()); + } if saiz.default_sample_info_size == 0 { let sizes = (indices.iter()) - .map(|&index| saiz.sample_info_size.get(index).copied()) - .collect::>>() - .ok_or(Error::InvalidProtection("saiz lacks a sample"))?; + .map(|&index| { + (saiz.sample_info_size.get(index).copied()).ok_or(Error::ProtectionLacksSample { + aux: "saiz", + sample: index, + }) + }) + .collect::, _>>()?; kept.saiz.push(mp4_atom::Saiz { aux_info: saiz.aux_info.clone(), default_sample_info_size: 0, diff --git a/rs/moq-mux/src/container/fmp4/import.rs b/rs/moq-mux/src/container/fmp4/import.rs index d68c51a93d0..e3ff510104b 100644 --- a/rs/moq-mux/src/container/fmp4/import.rs +++ b/rs/moq-mux/src/container/fmp4/import.rs @@ -1587,8 +1587,9 @@ impl Fmp4Track { /// source (padding, another track's runs), so each rewritten `data_offset` is the sizes before it. /// /// An encrypted track's fragment keeps its `senc`, `saiz`, and `saio`, with `saio` pointed at the -/// rebuilt `senc`. One whose keys rotate, whose encryption information is outside `senc`, or whose -/// edit list drops samples is refused. +/// rebuilt `senc`, and samples dropped by an edit list or a mid-GOP start have their entries +/// restated for the kept ones. One whose keys rotate, that lacks a `senc` its samples need, or +/// whose encryption information is outside `senc` is refused. fn fragment( traf: &mp4_atom::Traf, moof: &Moof, @@ -1596,8 +1597,9 @@ fn fragment( defaults: &sample::Defaults, protected: Option, ) -> Result { - if protected.is_some() { + if let Some(aux) = protected { super::cenc::check_moof(moof, traf)?; + aux.check(traf)?; } // Build a per-track moof containing only this traf, and a per-track mdat diff --git a/rs/moq-mux/src/container/fmp4/import_test.rs b/rs/moq-mux/src/container/fmp4/import_test.rs index d1b971192b1..c9c738c4e51 100644 --- a/rs/moq-mux/src/container/fmp4/import_test.rs +++ b/rs/moq-mux/src/container/fmp4/import_test.rs @@ -4306,3 +4306,144 @@ fn a_clear_lead_is_refused() { let err = protected_error(&[&data], |fmp4| fmp4); assert!(matches!(err, super::Error::MultipleCodecs), "{err:?}"); } + +/// A fragment of an encrypted track without the `senc` its per-sample IVs (or, for video, its +/// subsample maps) need is refused, rather than republished undecryptable. +#[test] +fn an_encrypted_fragment_without_senc_is_refused() { + for data in [CENC, CBCS_VIDEO] { + let data = rewrite(data, |atom| { + if let mp4_atom::Any::Moof(moof) = atom { + for traf in &mut moof.traf { + traf.senc = None; + traf.saio.clear(); + traf.saiz.clear(); + } + } + }); + let err = protected_error(&[&data], |fmp4| fmp4); + assert!( + matches!(err, super::Error::InvalidProtection("encrypted fragment without senc")), + "{err:?}" + ); + } +} + +/// Only `cenc` and `cbcs` are carried, the two schemes CMSF allows. +#[test] +fn another_scheme_is_refused() { + let data = rewrite(CBCS_VIDEO, |atom| { + if let mp4_atom::Any::Moov(moov) = atom { + let mp4_atom::Codec::Encv(encv) = &mut moov.trak[0].mdia.minf.stbl.stsd.codecs[0] else { + unreachable!() + }; + encv.sinf.schm.as_mut().unwrap().scheme_type = b"cens".into(); + } + }); + let err = protected_error(&[&data], |fmp4| fmp4); + assert!( + matches!(err, super::Error::UnsupportedScheme(scheme) if scheme == b"cens".into()), + "{err:?}" + ); +} + +/// The video track's ID and its `tenc`'s per-sample IV size. +fn protected_video(data: &[u8]) -> (u32, u8) { + use mp4_atom::DecodeMaybe; + + let mut cursor = std::io::Cursor::new(data); + while let Some(atom) = mp4_atom::Any::decode_maybe(&mut cursor).unwrap() { + if let mp4_atom::Any::Moov(moov) = atom { + let trak = (moov.trak.iter()) + .find(|trak| trak.mdia.hdlr.handler == b"vide".into()) + .unwrap(); + let mp4_atom::Codec::Encv(encv) = &trak.mdia.minf.stbl.stsd.codecs[0] else { + panic!("expected encv"); + }; + let tenc = encv.sinf.schi.as_ref().unwrap().tenc.as_ref().unwrap(); + return (trak.tkhd.track_id, tenc.default_per_sample_iv_size); + } + } + panic!("no moov"); +} + +/// Each sample's entry in `senc`: its IV, then its subsample map. +fn senc_entries(senc: &mp4_atom::Senc, iv_size: usize) -> Vec> { + let data = &senc.data[..]; + let count = u32::from_be_bytes(data[..4].try_into().unwrap()); + let mut position = 4; + let mut entries = Vec::new(); + for _ in 0..count { + let start = position; + position += iv_size; + if senc.use_subsamples { + let subsamples = u16::from_be_bytes(data[position..position + 2].try_into().unwrap()) as usize; + position += 2 + 6 * subsamples; + } + entries.push(data[start..position].to_vec()); + } + assert_eq!(position, data.len()); + entries +} + +/// A stream joined mid-GOP drops the samples before its first sync sample, the same as an edit +/// list does: the kept samples' IVs, subsample maps, and `saiz` sizes are restated, with the +/// per-sample IVs of the `cenc` file and the constant IV of Shaka's `cbcs` video alike. +#[tokio::test] +async fn a_mid_gop_start_restates_the_kept_samples_encryption() { + const NON_SYNC: u32 = 0x0101_0000; + const SYNC: u32 = 0x0200_0000; + const SKIPPED: usize = 2; + + for source in [CENC, CBCS_VIDEO] { + let (video, iv_size) = protected_video(source); + // The first fragment's first two video samples become non-sync and its third a sync sample. + let mut first = true; + let data = rewrite(source, |atom| { + let mp4_atom::Any::Moof(moof) = atom else { + return; + }; + if !std::mem::take(&mut first) { + return; + } + let traf = moof.traf.iter_mut().find(|traf| traf.tfhd.track_id == video).unwrap(); + let mut index = 0; + for trun in &mut traf.trun { + let mut entries: Vec<_> = trun.samples.iter().collect(); + for entry in &mut entries { + entry.flags = Some(if index == SKIPPED { SYNC } else { NON_SYNC }); + index += 1; + } + trun.samples = mp4_atom::TrunSamples::Explicit(entries); + } + }); + + let (result, catalog, consumer, _importers) = import_protected(&[&data], |fmp4| fmp4); + result.unwrap(); + let name = catalog.snapshot().video.renditions.keys().next().unwrap().clone(); + let published = fragments(&consumer, &name).await; + + let source = first_moof(&data); + let source = source.traf.iter().find(|traf| traf.tfhd.track_id == video).unwrap(); + let total = super::sample::count(source) as usize; + let moof = mp4_atom::Moof::decode(&mut &published[0][..]).unwrap(); + assert_eq!(super::sample::count(&moof.traf[0]) as usize, total - SKIPPED); + + let senc = checked_senc(&published[0]); + let source_senc = source.senc.as_ref().unwrap(); + assert!(source_senc.use_subsamples, "encrypted video carries subsample maps"); + let kept = senc_entries(&senc, iv_size as usize); + assert_eq!(kept, senc_entries(source_senc, iv_size as usize)[SKIPPED..]); + + let saiz = &moof.traf[0].saiz[0]; + assert_eq!(saiz.sample_count as usize, total - SKIPPED); + let sizes: Vec<_> = kept.iter().map(|entry| entry.len()).collect(); + match saiz.default_sample_info_size { + 0 => assert_eq!( + saiz.sample_info_size.iter().map(|&size| size as usize).collect::>(), + sizes + ), + size => assert!(sizes.iter().all(|&entry| entry == size as usize)), + } + } +} diff --git a/rs/moq-mux/src/container/fmp4/mod.rs b/rs/moq-mux/src/container/fmp4/mod.rs index 062e5686c90..5f950970f87 100644 --- a/rs/moq-mux/src/container/fmp4/mod.rs +++ b/rs/moq-mux/src/container/fmp4/mod.rs @@ -196,10 +196,14 @@ pub enum Error { #[error("key rotation is not supported")] KeyRotation, - /// An edit list drops samples of an encrypted track, whose kept samples' encryption - /// information would not be restated. - #[error("an edit list drops samples from an encrypted track")] - ProtectedEdit, + /// An encrypted track's `senc` or `saiz` has no entry for a sample its fragment holds. + #[error("{aux} lacks the encryption information of sample {sample}")] + ProtectionLacksSample { + /// The box lacking the entry, `senc` or `saiz`. + aux: &'static str, + /// The sample's position among its fragment's. + sample: usize, + }, /// A license or certificate server for a DRM system no encrypted track carries a `pssh` for. #[error("DRM system {0} protects no track")] From 18fb32b283bb25848875ac2ad9d1f5c5281d38db Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 20:15:35 +0100 Subject: [PATCH 10/23] fix(mux): share a drm entry only when it is identical, and release it with its last rendition register_drm shared an entry by system, scheme and key alone, so a second importer under the same key but with other servers or another pssh was signalled with the first one's. It now shares only an identical entry and gives any other its own ID. Removing a video or audio rendition removes the drm entries no rendition lists any more. hang's Entry::same_key, now unused, goes. Co-Authored-By: Claude Opus 5.5 --- rs/hang/src/catalog/drm.rs | 5 --- rs/moq-mux/src/catalog/tracks.rs | 21 +++++++++- rs/moq-mux/src/container/fmp4/import.rs | 8 ++-- rs/moq-mux/src/container/fmp4/import_test.rs | 41 ++++++++++++++++++++ 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/rs/hang/src/catalog/drm.rs b/rs/hang/src/catalog/drm.rs index c805db52400..39c46805ab8 100644 --- a/rs/hang/src/catalog/drm.rs +++ b/rs/hang/src/catalog/drm.rs @@ -103,11 +103,6 @@ impl Entry { certificate: None, } } - - /// Whether `other` describes the same system, scheme, and key, which renditions share. - pub fn same_key(&self, other: &Self) -> bool { - self.system == other.system && self.scheme == other.scheme && self.kid == other.kid - } } /// A UUID in its hyphenated form only, as draft-ietf-moq-cmsf writes one, refusing the simple, diff --git a/rs/moq-mux/src/catalog/tracks.rs b/rs/moq-mux/src/catalog/tracks.rs index b0fbf73ae8b..f4101f0ce62 100644 --- a/rs/moq-mux/src/catalog/tracks.rs +++ b/rs/moq-mux/src/catalog/tracks.rs @@ -294,6 +294,19 @@ impl VideoHint { } } +/// Remove the `drm` entries among `ids` that no video or audio rendition lists any more, so an +/// entry leaves the catalog with the last rendition it protects. +fn release_drm(catalog: &mut Catalog, ids: &[String]) { + for id in ids { + let listed = (catalog.video.renditions.values().map(|config| &config.drm)) + .chain(catalog.audio.renditions.values().map(|config| &config.drm)) + .any(|drm| drm.contains(id)); + if !listed { + catalog.drm.remove(id); + } + } +} + impl RenditionConfig for hang::catalog::VideoConfig { fn detects() -> bool { true @@ -306,7 +319,9 @@ impl RenditionConfig for hang::catalog::VideoConfig { catalog.video.renditions.get_mut(name) } fn remove(catalog: &mut Catalog, name: &str) { - catalog.video.renditions.remove(name); + if let Some(config) = catalog.video.renditions.remove(name) { + release_drm(catalog, &config.drm); + } } fn estimate(&self) -> Estimate { @@ -336,7 +351,9 @@ impl RenditionConfig for hang::catalog::AudioConfig { catalog.audio.renditions.get_mut(name) } fn remove(catalog: &mut Catalog, name: &str) { - catalog.audio.renditions.remove(name); + if let Some(config) = catalog.audio.renditions.remove(name) { + release_drm(catalog, &config.drm); + } } fn estimate(&self) -> Estimate { diff --git a/rs/moq-mux/src/container/fmp4/import.rs b/rs/moq-mux/src/container/fmp4/import.rs index e3ff510104b..ae1fed210ed 100644 --- a/rs/moq-mux/src/container/fmp4/import.rs +++ b/rs/moq-mux/src/container/fmp4/import.rs @@ -654,8 +654,10 @@ impl Import { /// Add the catalog's `drm` entries for `protection`, one per DRM system with the servers /// [`with_drm`](Self::with_drm) set for it, returning their IDs for the rendition to list. /// - /// A system, scheme, and key another rendition already uses shares its entry, so video and - /// audio under one key list the same IDs. A new entry takes the lowest free numeric ID. + /// An entry identical to one another rendition already lists (the same system, scheme, key, + /// `pssh`, and servers) is shared, so video and audio under one key list the same IDs. Any + /// difference, such as another importer's servers for the same key, takes a new entry with the + /// lowest free numeric ID, so no importer's rendition is signalled with another's servers. fn register_drm(&mut self, protection: &super::cenc::Protection) -> Result> { let mut entries = protection.entries()?; for entry in &mut entries { @@ -668,7 +670,7 @@ impl Import { let mut ids = Vec::with_capacity(entries.len()); self.catalog.mutate(|catalog| { for entry in entries { - let existing = catalog.drm.iter().find(|(_, other)| other.same_key(&entry)); + let existing = catalog.drm.iter().find(|(_, other)| **other == entry); let id = match existing { Some((id, _)) => id.clone(), None => { diff --git a/rs/moq-mux/src/container/fmp4/import_test.rs b/rs/moq-mux/src/container/fmp4/import_test.rs index c9c738c4e51..e99507774d9 100644 --- a/rs/moq-mux/src/container/fmp4/import_test.rs +++ b/rs/moq-mux/src/container/fmp4/import_test.rs @@ -4447,3 +4447,44 @@ async fn a_mid_gop_start_restates_the_kept_samples_encryption() { } } } + +/// Importers sharing a key but not their servers get an entry each, so neither rendition is +/// signalled with the other's license server. +#[test] +fn different_servers_for_one_key_take_their_own_entries() { + use hang::catalog::drm; + + let servers = [ + drm::Servers::license("https://a.example.com/".parse().unwrap()), + drm::Servers::license("https://b.example.com/".parse().unwrap()), + ]; + let index = std::cell::Cell::new(0); + let (result, catalog, _, _importers) = import_protected(&[CBCS_VIDEO, CBCS_AUDIO], |fmp4| { + let servers = servers[index.replace(index.get() + 1)].clone(); + fmp4.with_drm(drm::system::CLEARKEY, servers) + }); + result.unwrap(); + let catalog = catalog.snapshot(); + assert_eq!(catalog.drm.len(), 2, "{:?}", catalog.drm); + let video = &catalog.video.renditions.values().next().unwrap().drm; + let audio = &catalog.audio.renditions.values().next().unwrap().drm; + assert_ne!(video, audio); + assert_eq!(catalog.drm[&video[0]].license, servers[0].license); + assert_eq!(catalog.drm[&audio[0]].license, servers[1].license); +} + +/// A shared entry stays while any rendition lists it and leaves with the last one. +#[test] +fn a_drm_entry_leaves_with_its_last_rendition() { + let (result, catalog, _, mut importers) = import_protected(&[CBCS_VIDEO, CBCS_AUDIO], |fmp4| fmp4); + result.unwrap(); + assert_eq!(catalog.snapshot().drm.len(), 1); + + drop(importers.remove(0)); + let snapshot = catalog.snapshot(); + assert!(snapshot.video.renditions.is_empty()); + assert_eq!(snapshot.drm.len(), 1, "the audio still lists it"); + + drop(importers); + assert!(catalog.snapshot().drm.is_empty()); +} From 04c44dad1e7613cd88d7cf673e6e1fd6f0e299e1 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 20:19:56 +0100 Subject: [PATCH 11/23] fix: treat a protected rendition as undecodable in every Rust consumer The exports kept a protected rendition's encv/enca entry but dropped its pssh, senc, saiz and saio, and the players fed its ciphertext to decoders. Nothing in the workspace decrypts, so each consumer now treats a rendition listing drm entries as one it cannot decode, as the hang draft requires: - moq-mux: Source::retain_selectable drops it, as it does a disabled one, for every export (moq export, recordings). catalog::hang::retain_clear does it for other consumers. - moq-hls: neither listed nor held. - moq-video and moq-audio: Decoder::new refuses it as unsupported, which moq play, the FFI decoders and transcode report like an unknown codec. - moq-transcode: never the source; the derivative carries the drm entries of the source renditions it references. - moq-gst source and moq-rtc egress: left out of what they forward. Co-Authored-By: Claude Opus 5.5 --- rs/moq-audio/src/decode/decoder.rs | 19 +++++++++ rs/moq-gst/src/source/imp.rs | 2 + rs/moq-hls/src/export/mod.rs | 29 ++++++++++++++ rs/moq-hls/src/export/renditions.rs | 5 +++ rs/moq-mux/MIGRATE.md | 3 ++ rs/moq-mux/src/catalog/hang/container.rs | 25 ++++++++++++ rs/moq-mux/src/catalog/hang/mod.rs | 2 +- rs/moq-mux/src/container/fmp4/export_test.rs | 40 +++++++++++++++++++ rs/moq-mux/src/source.rs | 32 ++++++++++++++- rs/moq-rtc/src/egress.rs | 4 +- rs/moq-transcode/src/catalog.rs | 41 ++++++++++++++++++++ rs/moq-video/src/decode/decoder.rs | 25 +++++++++++- 12 files changed, 223 insertions(+), 4 deletions(-) diff --git a/rs/moq-audio/src/decode/decoder.rs b/rs/moq-audio/src/decode/decoder.rs index 462981480fa..c2c954868dd 100644 --- a/rs/moq-audio/src/decode/decoder.rs +++ b/rs/moq-audio/src/decode/decoder.rs @@ -54,7 +54,15 @@ impl Decoder { /// catalog fields directly and requires an absent `description`. AAC reads /// its AudioSpecificConfig; without one, legacy and LOC packets carry ADTS headers, /// while demuxed CMAF samples remain raw. + /// + /// A protected rendition (one listing `drm` entries) is refused, since its samples are + /// encrypted and nothing here decrypts them. pub fn new(catalog: &hang::catalog::AudioConfig, config: &Config) -> Result { + if !catalog.drm.is_empty() { + return Err(Error::Unsupported( + "the rendition is encrypted, and decryption is not supported".into(), + )); + } let backend = backend::open(catalog, config)?; let delay = backend.delay(); Ok(Self { @@ -406,6 +414,17 @@ pub(crate) mod tests { } } + /// A protected rendition's samples are encrypted, so it is refused before any backend opens. + #[test] + fn a_protected_rendition_is_unsupported() { + let mut catalog = hang::catalog::AudioConfig::new(hang::catalog::AudioCodec::Opus, 48_000, 2); + catalog.drm = vec!["1".into()]; + assert!(matches!( + Decoder::new(&catalog, &Config::default()), + Err(Error::Unsupported(_)) + )); + } + /// Without a description the catalog shapes the stream, which has no pre-skip. #[test] fn opus_decodes_without_a_description() { diff --git a/rs/moq-gst/src/source/imp.rs b/rs/moq-gst/src/source/imp.rs index a05d8a9676f..f0cfe8a58ff 100644 --- a/rs/moq-gst/src/source/imp.rs +++ b/rs/moq-gst/src/source/imp.rs @@ -1049,6 +1049,8 @@ fn reconcile( .video(Default::default()) .audio(Default::default()) .retain(&mut playable, &selected); + // Encrypted samples would reach the decoders as ciphertext; this source does not decrypt. + moq_mux::catalog::hang::retain_clear(&mut playable); // Build the desired shape for each rendition. This is deliberately cheap: caps come from the // catalog config and the container is just the hang descriptor. The reader parses the wire diff --git a/rs/moq-hls/src/export/mod.rs b/rs/moq-hls/src/export/mod.rs index e517d855c70..286860f2f78 100644 --- a/rs/moq-hls/src/export/mod.rs +++ b/rs/moq-hls/src/export/mod.rs @@ -709,6 +709,35 @@ mod tests { assert!(renditions.get(Kind::Video, "video").is_none()); } + /// A protected rendition is not served: its segments would lose the `pssh`, `senc`, `saiz`, + /// and `saio` a decrypting player needs. Its clear sibling is. + #[tokio::test(start_paused = true)] + async fn protected_rendition_is_not_advertised() { + let broadcast = moq_net::broadcast::Info::new().produce(); + let source = moq_mux::Source::new(produce_origin().consume(), broadcast.consume()); + let mut catalog = joined(); + let mut protected = hang::catalog::VideoConfig::new(hang::catalog::VideoCodec::VP8); + protected.drm = vec!["1".into()]; + catalog.drm.insert( + "1".into(), + hang::catalog::drm::Entry::new( + hang::catalog::drm::system::CLEARKEY, + hang::catalog::drm::Scheme::Cenc, + hang::catalog::drm::Uuid::nil(), + ), + ); + catalog.video.renditions.insert("protected".to_string(), protected); + catalog.video.renditions.insert( + "clear".to_string(), + hang::catalog::VideoConfig::new(hang::catalog::VideoCodec::VP8), + ); + + let renditions = renditions::Producer::spawned(Config::default().window); + renditions.sync(&source, &catalog); + assert!(renditions.get(Kind::Video, "protected").is_none()); + assert!(renditions.get(Kind::Video, "clear").is_some()); + } + #[tokio::test(start_paused = true)] async fn audio_renditions_follow_catalog_quality_order() { let broadcast = moq_net::broadcast::Info::new().produce(); diff --git a/rs/moq-hls/src/export/renditions.rs b/rs/moq-hls/src/export/renditions.rs index 04f493a729a..2524c6ac95d 100644 --- a/rs/moq-hls/src/export/renditions.rs +++ b/rs/moq-hls/src/export/renditions.rs @@ -612,6 +612,11 @@ impl Producer { } pub fn sync(&self, source: &moq_mux::Source, catalog: &Catalog) { + // A protected rendition is neither listed nor held: the segments would lose the `pssh`, + // `senc`, `saiz`, and `saio` a decrypting player needs. + let mut catalog = catalog.clone(); + moq_mux::catalog::hang::retain_clear(&mut catalog); + let catalog = &catalog; let clock = catalog.media.clock; let interval = catalog.media.interval(); diff --git a/rs/moq-mux/MIGRATE.md b/rs/moq-mux/MIGRATE.md index 55f94969378..e7da2f47db5 100644 --- a/rs/moq-mux/MIGRATE.md +++ b/rs/moq-mux/MIGRATE.md @@ -9,6 +9,9 @@ How to adopt new APIs and update for breaking changes, newest first. `fmp4::Import` with passthrough publishes Common Encryption (`cenc` and `cbcs`) fMP4 instead of refusing its `encv`/`enca` entries, filling the catalog's `drm` section; set license and certificate servers with `Import::with_drm`. Without passthrough, an encrypted file now fails with `fmp4::Error::ProtectedNeedsPassthrough` rather than `UnsupportedCodec`. +Every export (fMP4, MP4, MKV, MPEG-TS, FLV, Annex-B) leaves out a protected rendition, one whose `drm` lists entries, as it does a disabled one: nothing here decrypts, and a re-encoded file would lose its IVs. +A consumer of your own can do the same with `catalog::hang::retain_clear`. + The re-exported `fmp4::mp4_atom` moves to the release with Common Encryption's boxes: a sample entry's `colr` is a `Vec`, `Moov` and `Moof` gain `pssh: Vec`, and `Codec` gains `Encv` and `Enca`. Build a `Moov` or `Moof` literal with `pssh: Vec::new()`, and match the new `Codec` variants. diff --git a/rs/moq-mux/src/catalog/hang/container.rs b/rs/moq-mux/src/catalog/hang/container.rs index 0186bd8e140..df4fdc73a02 100644 --- a/rs/moq-mux/src/catalog/hang/container.rs +++ b/rs/moq-mux/src/catalog/hang/container.rs @@ -73,6 +73,31 @@ pub(crate) fn supported(rendition: &str, container: &hang::catalog::Container) - } } +/// Drop the protected video and audio renditions, those listing `drm` entries, logging each one. +/// +/// Their samples are encrypted, and the hang spec has a consumer that cannot decrypt a rendition +/// treat it as one it cannot decode. Nothing here decrypts, and a re-encoded file would also lose +/// the `pssh`, `senc`, `saiz`, and `saio` a decrypting player needs, so every export and player in +/// this workspace runs this on each catalog snapshot instead of writing undecryptable media. +pub fn retain_clear(catalog: &mut hang::Catalog) { + catalog + .video + .renditions + .retain(|name, config| clear("video", name, &config.drm)); + catalog + .audio + .renditions + .retain(|name, config| clear("audio", name, &config.drm)); +} + +fn clear(kind: &'static str, rendition: &str, drm: &[String]) -> bool { + if drm.is_empty() { + return true; + } + tracing::warn!(rendition, kind, "ignoring encrypted rendition: decryption is not supported"); + false +} + impl ContainerTrait for Container { type Error = crate::Error; diff --git a/rs/moq-mux/src/catalog/hang/mod.rs b/rs/moq-mux/src/catalog/hang/mod.rs index ac0c170d728..484861400e7 100644 --- a/rs/moq-mux/src/catalog/hang/mod.rs +++ b/rs/moq-mux/src/catalog/hang/mod.rs @@ -11,7 +11,7 @@ mod container; mod ext; pub use consumer::Consumer; -pub use container::Container; +pub use container::{Container, retain_clear}; pub(crate) use container::supported; pub use ext::{CatalogExt, Extra}; pub use hang::Catalog; diff --git a/rs/moq-mux/src/container/fmp4/export_test.rs b/rs/moq-mux/src/container/fmp4/export_test.rs index 9c4d26571f6..50dc5735d08 100644 --- a/rs/moq-mux/src/container/fmp4/export_test.rs +++ b/rs/moq-mux/src/container/fmp4/export_test.rs @@ -457,6 +457,46 @@ async fn cmaf_source_to_cmaf_export_passthrough() { moov.encode(&mut buf).expect("encode merged moov"); } +/// A protected rendition is left out of the export: re-encoded fragments would lose its IVs, and +/// nothing here decrypts it. The clear renditions beside it are exported as usual. +#[tokio::test(start_paused = true)] +async fn a_protected_rendition_is_left_out() { + let broadcast = moq_net::broadcast::Info::new(); + let mut producer = broadcast.produce(); + let consumer = producer.consume(); + + let catalog = crate::catalog::Producer::new(&mut producer, crate::catalog::Config::default()).unwrap(); + let mut clear = crate::container::fmp4::Import::new(producer.clone(), catalog.reserve()); + let _ = clear.decode(&BytesMut::from(include_bytes!("test_data/bbb.mp4").as_slice())); + let mut protected = crate::container::fmp4::Import::new(producer, catalog.reserve()).with_passthrough(true); + protected + .decode(include_bytes!("test_data/cbcs-video.mp4")) + .expect("protected import"); + assert_eq!(catalog.snapshot().video.renditions.len(), 2); + + let catalog_stream = crate::catalog::Consumer::<()>::new(&consumer, crate::catalog::CatalogFormat::Hang) + .await + .expect("catalog consumer"); + let mut exporter = crate::container::fmp4::Export::new(crate::source::announced(&consumer).await, catalog_stream); + let init = kio::clock::timeout(std::time::Duration::from_secs(1), exporter.next()) + .await + .expect("exporter timed out") + .expect("exporter result") + .expect("expected init bytes"); + + let mut cursor = Cursor::new(init.as_ref()); + let mut moov = None; + while let Some(atom) = mp4_atom::Any::decode_maybe(&mut cursor).expect("decode init") { + if let mp4_atom::Any::Moov(m) = atom { + moov = Some(m); + } + } + let moov = moov.expect("moov"); + assert_eq!(moov.trak.len(), 2, "only bbb's clear video and audio"); + let codecs = moov.trak.iter().flat_map(|trak| &trak.mdia.minf.stbl.stsd.codecs); + assert!(!codecs.into_iter().any(|codec| matches!(codec, mp4_atom::Codec::Encv(_)))); +} + /// Per-rendition export (a single non-first source track, e.g. moq-hls exporting /// the audio rendition alone) must give the init moov the SAME track id its /// re-encoded fragments carry. diff --git a/rs/moq-mux/src/source.rs b/rs/moq-mux/src/source.rs index f7673a46ee6..fde8a59dff2 100644 --- a/rs/moq-mux/src/source.rs +++ b/rs/moq-mux/src/source.rs @@ -264,7 +264,8 @@ impl Source { /// /// Every export runs this on each catalog snapshot, so a disabled rendition reads as /// absent: one that is disabled later leaves the snapshot, and one that re-enables - /// returns to it. Every section carrying renditions must be listed here; one left out + /// returns to it. A protected one (listing `drm` entries) reads as absent as well, since no + /// export decrypts it (see [`retain_clear`](crate::catalog::hang::retain_clear)). Every section carrying renditions must be listed here; one left out /// silently exempts its renditions from the containment check, exactly as on the /// consumer side. pub(crate) fn retain_selectable( @@ -273,6 +274,8 @@ impl Source { ) { catalog.video.renditions.retain(|_, config| config.enabled); catalog.audio.renditions.retain(|_, config| config.enabled); + // Nothing exported is decrypted, so a protected rendition reads as absent too. + crate::catalog::hang::retain_clear(catalog); self.retain_valid_references("video", &mut catalog.video.renditions); self.retain_valid_references("audio", &mut catalog.audio.renditions); self.retain_valid_references("text", &mut catalog.text.renditions); @@ -1046,6 +1049,33 @@ mod tests { assert!(catalog.audio.renditions.is_empty()); } + /// A protected rendition is never exported, since nothing exported is decrypted, while its + /// clear sibling is. + #[test] + fn protected_rendition_is_removed_while_clear_sibling_remains() { + let origin = produce_origin(); + let source = created(&origin); + let clear = VideoConfig::new(H264 { + profile: 0x42, + constraints: 0, + level: 0x1e, + inline: false, + }); + let mut protected = clear.clone(); + protected.drm = vec!["1".into()]; + let mut audio = hang::catalog::AudioConfig::new(hang::catalog::AudioCodec::Opus, 48_000, 2); + audio.drm = vec!["1".into()]; + + let mut catalog = hang::Catalog::<()>::default(); + catalog.video.renditions.insert("protected".to_string(), protected); + catalog.video.renditions.insert("clear".to_string(), clear); + catalog.audio.renditions.insert("audio".to_string(), audio); + source.retain_selectable(&mut catalog); + + assert_eq!(catalog.video.renditions.keys().collect::>(), vec!["clear"]); + assert!(catalog.audio.renditions.is_empty()); + } + /// The filter covers every section carrying renditions, not just the media ones. Text /// is the section that only exists on one side of the containment check by default, so /// it is the one that silently goes unchecked when the two sides drift. diff --git a/rs/moq-rtc/src/egress.rs b/rs/moq-rtc/src/egress.rs index 25327f5dacf..4011f3932c7 100644 --- a/rs/moq-rtc/src/egress.rs +++ b/rs/moq-rtc/src/egress.rs @@ -199,7 +199,9 @@ async fn follow_catalog(mut consumer: moq_mux::catalog::Consumer<()>, tx: watch: loop { tokio::select! { next = consumer.next() => match next { - Ok(Some(catalog)) => { + Ok(Some(mut catalog)) => { + // WebRTC egress would forward ciphertext as media; it does not decrypt. + moq_mux::catalog::hang::retain_clear(&mut catalog); tx.send_replace(catalog); } Ok(None) => return Ok(()), diff --git a/rs/moq-transcode/src/catalog.rs b/rs/moq-transcode/src/catalog.rs index a1f77512202..1be66d9a510 100644 --- a/rs/moq-transcode/src/catalog.rs +++ b/rs/moq-transcode/src/catalog.rs @@ -148,6 +148,7 @@ impl Decoders { let mut config = rendition.clone(); config.description = None; config.container = Container::Legacy; + config.drm.clear(); match &mut config.codec { VideoCodec::H264(h264) => h264.inline = true, VideoCodec::H265(h265) => h265.in_band = true, @@ -172,6 +173,8 @@ pub(crate) async fn choose_source(video: &Video, decoders: &mut Decoders) -> Res // A rendition that itself lives in another broadcast can't be subscribed // through this one; composing relative references is a follow-up. .filter(|(_, config)| config.broadcast.is_none()) + // A protected rendition's samples are encrypted, and nothing here decrypts them. + .filter(|(_, config)| config.drm.is_empty()) .filter_map(|(name, config)| Some((name, config, codec(config)?))); let mut refused = None; @@ -220,6 +223,7 @@ pub(crate) async fn follow_source( let mut kept = None; if let Some(config) = video.renditions.get(current) && config.broadcast.is_none() + && config.drm.is_empty() && dimensions(config).is_some() && let Some(codec) = codec(config) // The name can stay while the codec changes under it. @@ -359,6 +363,8 @@ pub(crate) fn populate( ) -> Result<(), Error> { out.video = Video::default(); out.audio = hang::catalog::Audio::default(); + // The rungs are clear; only the source renditions listed below may reference an entry. + out.drm.clear(); // The derivative republishes the child's timeline, so its timestamps only mean something under // the child's wall mapping. out.media.clock = source.media.clock; @@ -381,6 +387,8 @@ pub(crate) fn populate( if out.media.join.is_none() { out.media.join = source.media.join; } + // A protected source rendition keeps its `drm` IDs, so the entries come along. + out.drm = source.drm.clone(); for (name, config) in &source.video.renditions { if config.broadcast.is_some() { @@ -1076,4 +1084,37 @@ mod tests { }; assert_eq!(frame.timestamp.unwrap().as_millis(), adopted.now().as_millis()); } + + /// A protected rendition's samples are encrypted, so it is never the source, however well it + /// ranks; the derivative still lists it, with the `drm` entries it references. + #[tokio::test] + async fn a_protected_rendition_is_not_transcoded() { + use hang::catalog::drm; + + let mut child = moq_mux::catalog::hang::Catalog::<()>::default(); + child.drm.insert( + "1".into(), + drm::Entry::new(drm::system::CLEARKEY, drm::Scheme::Cbcs, drm::Uuid::nil()), + ); + let mut protected = source(1920, 1080, None); + protected.drm = vec!["1".into()]; + child.video.insert("protected", protected).unwrap(); + child.video.insert("clear", source(640, 360, None)).unwrap(); + + let (name, _) = choose_source(&child.video, &mut decodes_all()).await.unwrap(); + assert_eq!(name, "clear"); + let (name, _) = follow_source(&child.video, "protected", &mut decodes_all()) + .await + .unwrap(); + assert_eq!(name, "clear"); + + let rel = Relative::new(".").unwrap(); + let mut out = moq_mux::catalog::hang::Catalog::<()>::default(); + populate(&mut out, &child, &[], Some(&rel)).unwrap(); + assert_eq!(out.drm, child.drm); + out.check_renditions().unwrap(); + + populate(&mut out, &child, &[], None).unwrap(); + assert!(out.drm.is_empty(), "only the rungs, which are clear"); + } } diff --git a/rs/moq-video/src/decode/decoder.rs b/rs/moq-video/src/decode/decoder.rs index b82346c0265..1b68a8f8f4c 100644 --- a/rs/moq-video/src/decode/decoder.rs +++ b/rs/moq-video/src/decode/decoder.rs @@ -166,9 +166,15 @@ impl Decoder { /// Build a decoder for the catalog's video config. /// /// A codec or description this build cannot decode is - /// [`Error::UnsupportedCodec`]. A backend that exists for the codec but fails to + /// [`Error::UnsupportedCodec`], as is a protected rendition (one listing `drm` entries), whose + /// samples are encrypted. A backend that exists for the codec but fails to /// open is [`Error::NoDecoder`], a fault rather than a property of the track. pub fn new(catalog: &VideoConfig, config: &Config) -> Result { + if !catalog.drm.is_empty() { + return Err(Error::UnsupportedCodec( + "the rendition is encrypted, and decryption is not supported".into(), + )); + } // CMAF samples are length-prefixed whatever the sample entry; Legacy and LOC // carry Annex-B exactly when the parameter sets are in band. let cmaf = matches!(catalog.container, Container::Cmaf { .. }); @@ -481,6 +487,23 @@ mod tests { crate::Size::new(320, 240) } + /// A protected rendition's samples are encrypted, so it is refused like a codec this build + /// cannot decode, before any backend opens. + #[test] + fn a_protected_rendition_is_unsupported() { + let mut catalog = hang::catalog::VideoConfig::new(hang::catalog::H264 { + inline: true, + profile: 0x42, + constraints: 0, + level: 0x1e, + }); + catalog.drm = vec!["1".into()]; + assert!(matches!( + super::Decoder::new(&catalog, &super::Config::new()), + Err(crate::Error::UnsupportedCodec(_)) + )); + } + #[test] #[cfg(feature = "openh264")] fn openh264_round_trip() { From bbcc107402cda52756319cd791a29c451c3f5dff Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 20:23:36 +0100 Subject: [PATCH 12/23] style(mux): rustfmt the protected rendition changes Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/catalog/hang/container.rs | 6 +++++- rs/moq-mux/src/catalog/hang/mod.rs | 2 +- rs/moq-mux/src/container/fmp4/export_test.rs | 6 +++++- rs/moq-mux/src/container/fmp4/import_test.rs | 5 ++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/rs/moq-mux/src/catalog/hang/container.rs b/rs/moq-mux/src/catalog/hang/container.rs index df4fdc73a02..ce97020253d 100644 --- a/rs/moq-mux/src/catalog/hang/container.rs +++ b/rs/moq-mux/src/catalog/hang/container.rs @@ -94,7 +94,11 @@ fn clear(kind: &'static str, rendition: &str, drm: &[String]) -> bool { if drm.is_empty() { return true; } - tracing::warn!(rendition, kind, "ignoring encrypted rendition: decryption is not supported"); + tracing::warn!( + rendition, + kind, + "ignoring encrypted rendition: decryption is not supported" + ); false } diff --git a/rs/moq-mux/src/catalog/hang/mod.rs b/rs/moq-mux/src/catalog/hang/mod.rs index 484861400e7..c4ee2218f20 100644 --- a/rs/moq-mux/src/catalog/hang/mod.rs +++ b/rs/moq-mux/src/catalog/hang/mod.rs @@ -11,7 +11,7 @@ mod container; mod ext; pub use consumer::Consumer; -pub use container::{Container, retain_clear}; pub(crate) use container::supported; +pub use container::{Container, retain_clear}; pub use ext::{CatalogExt, Extra}; pub use hang::Catalog; diff --git a/rs/moq-mux/src/container/fmp4/export_test.rs b/rs/moq-mux/src/container/fmp4/export_test.rs index 50dc5735d08..eac7dd547ed 100644 --- a/rs/moq-mux/src/container/fmp4/export_test.rs +++ b/rs/moq-mux/src/container/fmp4/export_test.rs @@ -494,7 +494,11 @@ async fn a_protected_rendition_is_left_out() { let moov = moov.expect("moov"); assert_eq!(moov.trak.len(), 2, "only bbb's clear video and audio"); let codecs = moov.trak.iter().flat_map(|trak| &trak.mdia.minf.stbl.stsd.codecs); - assert!(!codecs.into_iter().any(|codec| matches!(codec, mp4_atom::Codec::Encv(_)))); + assert!( + !codecs + .into_iter() + .any(|codec| matches!(codec, mp4_atom::Codec::Encv(_))) + ); } /// Per-rendition export (a single non-first source track, e.g. moq-hls exporting diff --git a/rs/moq-mux/src/container/fmp4/import_test.rs b/rs/moq-mux/src/container/fmp4/import_test.rs index e99507774d9..566a3249e7a 100644 --- a/rs/moq-mux/src/container/fmp4/import_test.rs +++ b/rs/moq-mux/src/container/fmp4/import_test.rs @@ -4440,7 +4440,10 @@ async fn a_mid_gop_start_restates_the_kept_samples_encryption() { let sizes: Vec<_> = kept.iter().map(|entry| entry.len()).collect(); match saiz.default_sample_info_size { 0 => assert_eq!( - saiz.sample_info_size.iter().map(|&size| size as usize).collect::>(), + saiz.sample_info_size + .iter() + .map(|&size| size as usize) + .collect::>(), sizes ), size => assert!(sizes.iter().all(|&entry| entry == size as usize)), From ed39b959018a54e6bd1417a5e40e5d692675e5e6 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 20:23:37 +0100 Subject: [PATCH 13/23] fix(msf): drop only a bad content protection, and match its split IDs across Rust and JS One CMSF entry the hang catalog cannot carry (a cens scheme, no defaultKID, a malformed ID, URL or pssh) failed MSF to hang for the whole catalog, so its clear renditions vanished too. moq-mux and @moq/watch now drop just that entry and the video and audio tracks it protects, with a warning in Rust. moq-mux's InvalidContentProtection, no longer returned, goes. A split entry's {refID}:{kid} could also overwrite a real refID. moq-msf and @moq/msf refuse a repeated refID, and a split ID that is another entry's refID drops the split entry. @moq/watch now parses system and key IDs in every form moq-mux's uuid parse takes and writes them lowercase hyphenated, so both sides produce the same IDs and keys. Co-Authored-By: Claude Opus 5.5 --- js/msf/src/catalog.test.ts | 7 + js/msf/src/catalog.ts | 8 +- js/watch/src/msf.test.ts | 50 +++++- js/watch/src/msf.ts | 117 ++++++++++---- rs/moq-msf/src/lib.rs | 19 +++ rs/moq-mux/src/catalog/msf/consumer.rs | 211 +++++++++++++++++++------ rs/moq-mux/src/catalog/msf/mod.rs | 11 -- 7 files changed, 331 insertions(+), 92 deletions(-) diff --git a/js/msf/src/catalog.test.ts b/js/msf/src/catalog.test.ts index 97ac52f1bb6..cd76c8f7d99 100644 --- a/js/msf/src/catalog.test.ts +++ b/js/msf/src/catalog.test.ts @@ -352,4 +352,11 @@ test("content protection round-trips and a dangling refID is refused", () => { const dangling = encodeJson({ version: "draft-01", tracks: [{ ...track, contentProtectionRefIDs: ["2"] }] }); expect(() => decode(dangling)).toThrow("missing content protection"); + + const repeated = encodeJson({ + version: "draft-01", + contentProtections: [...contentProtections, ...contentProtections], + tracks: [], + }); + expect(() => decode(repeated)).toThrow("is repeated"); }); diff --git a/js/msf/src/catalog.ts b/js/msf/src/catalog.ts index b876b484fb7..fbc0274d220 100644 --- a/js/msf/src/catalog.ts +++ b/js/msf/src/catalog.ts @@ -211,9 +211,15 @@ export function decode(raw: Uint8Array): Catalog { byId.set(entry.id, entry); } + // A refID names one entry, so a repeated one leaves its tracks' protection ambiguous. + const refIDs = new Set(); + for (const cp of wire.contentProtections ?? []) { + if (refIDs.has(cp.refID)) throw new Error(`MSF content protection refID "${cp.refID}" is repeated`); + refIDs.add(cp.refID); + } + // A track's protection refers to a root entry by refID; one that names none would claim // encryption the catalog cannot describe, so it is refused like a missing initRef. - const refIDs = new Set((wire.contentProtections ?? []).map((cp) => cp.refID)); const tracks = (wire.tracks ?? []).map(({ initRef, ...track }) => { track.isLive ??= false; diff --git a/js/watch/src/msf.test.ts b/js/watch/src/msf.test.ts index 21ae0279f81..74057018fea 100644 --- a/js/watch/src/msf.test.ts +++ b/js/watch/src/msf.test.ts @@ -353,7 +353,55 @@ test("maps CMSF content protection onto hang drm entries", () => { expect(Catalog.isProtected(root.video?.renditions.video ?? { drm: [] })).toBe(true); expect(root.audio?.renditions.audio?.drm).toBeUndefined(); + // An entry the hang catalog cannot carry is dropped, and with it the tracks it protects; the + // clear audio stays. const cens = structuredClone(catalog); if (cens.contentProtections?.[0]) cens.contentProtections[0].scheme = "cens"; - expect(() => toHang(cens)).toThrow("unsupported scheme"); + const noKid = structuredClone(catalog); + if (noKid.contentProtections?.[0]) noKid.contentProtections[0].defaultKID = []; + for (const malformed of [cens, noKid]) { + const root = Catalog.checkRenditions(toHang(malformed)); + expect(Object.keys(root.drm ?? {}).sort()).toEqual([ + "wv:01234567-89ab-cdef-0123-456789abcdef", + "wv:a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + ]); + expect(root.video).toBeUndefined(); + expect(root.audio?.renditions.audio).toBeDefined(); + } +}); + +// Mirrors moq-mux: a split entry's ID and key are lowercase hyphenated whatever form MSF used, and +// one that would take another entry's refID drops that entry rather than overwriting the other. +test("split CMSF entry IDs are normalised and never collide", () => { + const split: Msf.ContentProtection = { + refID: "ck", + defaultKID: ["0123456789ABCDEF0123456789ABCDEF", "{A1B2C3D4-E5F6-0718-293A-4B5C6D7E8F90}"], + scheme: "cenc", + drmSystem: { systemID: "1077EFEC-C0B2-4D02-ACE3-3C1E52E2FB4B" }, + }; + const track: Msf.Track = { + name: "video", + packaging: "loc", + role: "video", + codec: "vp8", + contentProtectionRefIDs: ["ck"], + }; + const root = Catalog.checkRenditions(toHang({ contentProtections: [split], tracks: [track] })); + expect(Object.keys(root.drm ?? {}).sort()).toEqual([ + "ck:01234567-89ab-cdef-0123-456789abcdef", + "ck:a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90", + ]); + expect(root.drm?.["ck:01234567-89ab-cdef-0123-456789abcdef"]?.kid).toBe("01234567-89ab-cdef-0123-456789abcdef"); + expect(root.drm?.["ck:01234567-89ab-cdef-0123-456789abcdef"]?.system).toBe(Catalog.SYSTEM.clearkey); + + const colliding: Msf.ContentProtection = { + refID: "ck:01234567-89ab-cdef-0123-456789abcdef", + defaultKID: ["01234567-89ab-cdef-0123-456789abcdef"], + scheme: "cbcs", + drmSystem: { systemID: Catalog.SYSTEM.widevine }, + }; + const collided = Catalog.checkRenditions(toHang({ contentProtections: [split, colliding], tracks: [track] })); + expect(Object.keys(collided.drm ?? {})).toEqual(["ck:01234567-89ab-cdef-0123-456789abcdef"]); + expect(collided.drm?.["ck:01234567-89ab-cdef-0123-456789abcdef"]?.scheme).toBe("cbcs"); + expect(collided.video).toBeUndefined(); }); diff --git a/js/watch/src/msf.ts b/js/watch/src/msf.ts index e9cfb68d4da..cd78ff7d048 100644 --- a/js/watch/src/msf.ts +++ b/js/watch/src/msf.ts @@ -1,5 +1,5 @@ import type * as Catalog from "@moq/hang/catalog"; -import { u53 } from "@moq/hang/catalog"; +import { DrmSchema, u53 } from "@moq/hang/catalog"; import * as Util from "@moq/hang/util"; import type * as Msf from "@moq/msf"; import { Path } from "@moq/net"; @@ -119,35 +119,86 @@ function namesCatalog(namespace: Path.Valid, base: Path.Valid): boolean { return endsWith(a, b) || endsWith(b, a); } +const HYPHENATED = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; +const SIMPLE = /^[0-9a-f]{32}$/i; + /** - * The hang `drm` entries an MSF catalog's `contentProtections` describe, and each `refID`'s entry IDs. + * A UUID in lowercase hyphenated form, from any form moq-mux's `uuid` parse accepts: simple, + * hyphenated, braced, or URN. `undefined` for anything else. + */ +function normalizeUuid(text: string): string | undefined { + let hyphenated: string; + if (text.length === 32) { + if (!SIMPLE.test(text)) return undefined; + const at = [0, 8, 12, 16, 20, 32]; + hyphenated = at + .slice(1) + .map((end, i) => text.slice(at[i], end)) + .join("-"); + } else if (text.length === 36) { + hyphenated = text; + } else if (text.length === 38 && text.startsWith("{") && text.endsWith("}")) { + hyphenated = text.slice(1, -1); + } else if (text.length === 45 && text.slice(0, 9).toLowerCase() === "urn:uuid:") { + hyphenated = text.slice(9); + } else { + return undefined; + } + return HYPHENATED.test(hyphenated) ? hyphenated.toLowerCase() : undefined; +} + +/** + * The hang `drm` entries one MSF content protection describes, by ID, or `undefined` when the hang + * catalog cannot carry it. * * Mirrors moq-mux: an entry naming several default keys becomes one hang entry per key, - * `{refID}:{kid}`. A track referencing it lists all of them here, which is enough to know it is + * `{refID}:{kid}` with the key in lowercase hyphenated form, and a split ID that is another + * entry's refID drops the entry rather than overwriting the other. + */ +function splitEntry(cp: Msf.ContentProtection, refIDs: Set): [string, Catalog.Drm][] | undefined { + if (cp.defaultKID.length === 0) return undefined; + const system = normalizeUuid(cp.drmSystem.systemID); + if (system === undefined) return undefined; + const entries: [string, Catalog.Drm][] = []; + for (const raw of cp.defaultKID) { + const kid = normalizeUuid(raw); + if (kid === undefined) return undefined; + const id = cp.defaultKID.length === 1 ? cp.refID : `${cp.refID}:${kid}`; + if (entries.some(([other]) => other === id)) return undefined; + if (cp.defaultKID.length > 1 && refIDs.has(id)) return undefined; + // The scheme, the servers' URLs, and the pssh are checked the way the hang catalog reads them. + const entry = DrmSchema.safeParse({ + system, + scheme: cp.scheme, + kid, + pssh: cp.drmSystem.pssh, + license: cp.drmSystem.laURL, + certificate: cp.drmSystem.certURL, + }); + if (!entry.success) return undefined; + entries.push([id, entry.data]); + } + return entries; +} + +/** + * The hang `drm` entries an MSF catalog's `contentProtections` describe, and each `refID`'s entry + * IDs, `undefined` for an entry the hang catalog cannot carry. + * + * A track referencing it lists all of a split entry's IDs here, which is enough to know it is * protected; moq-mux picks the one its init's `tenc` names. */ -function toDrm(msf: Msf.Catalog): { drm: Record; byRef: Map } { +function toDrm(msf: Msf.Catalog): { drm: Record; byRef: Map } { const drm: Record = Object.create(null); - const byRef = new Map(); + const byRef = new Map(); + const refIDs = new Set((msf.contentProtections ?? []).map((cp) => cp.refID)); for (const cp of msf.contentProtections ?? []) { - if (cp.scheme !== "cenc" && cp.scheme !== "cbcs") { - throw new Error(`MSF content protection ${cp.refID} has unsupported scheme ${cp.scheme}`); - } - if (cp.defaultKID.length === 0) throw new Error(`MSF content protection ${cp.refID} has no defaultKID`); - const ids: string[] = []; - for (const kid of cp.defaultKID) { - const id = cp.defaultKID.length === 1 ? cp.refID : `${cp.refID}:${kid.toLowerCase()}`; - drm[id] = { - system: cp.drmSystem.systemID, - scheme: cp.scheme, - kid, - pssh: cp.drmSystem.pssh, - license: cp.drmSystem.laURL, - certificate: cp.drmSystem.certURL, - }; - ids.push(id); - } - byRef.set(cp.refID, ids); + const entries = splitEntry(cp, refIDs); + byRef.set( + cp.refID, + entries?.map(([id]) => id), + ); + for (const [id, entry] of entries ?? []) drm[id] = entry; } return { drm, byRef }; } @@ -155,9 +206,17 @@ function toDrm(msf: Msf.Catalog): { drm: Record; byRef: Map /** Convert an MSF catalog to a hang catalog Root. */ export function toHang(msf: Msf.Catalog, base?: Path.Valid): Catalog.Root { const { drm, byRef } = toDrm(msf); - // The hang entry IDs a track's refIDs name; @moq/msf refuses a refID the root lacks. - const protection = (track: Msf.Track) => { - const ids = (track.contentProtectionRefIDs ?? []).flatMap((id) => byRef.get(id) ?? []); + // The hang entry IDs a track's refIDs name; @moq/msf refuses a refID the root lacks. A track + // protected by an entry that was dropped is encrypted in a way the catalog cannot describe, so + // it is dropped too (`undefined`) rather than signalled as clear; the other tracks remain. + const protection = (track: Msf.Track): { drm?: string[] } | undefined => { + const ids: string[] = []; + for (const ref of track.contentProtectionRefIDs ?? []) { + if (!byRef.has(ref)) continue; + const split = byRef.get(ref); + if (split === undefined) return undefined; + ids.push(...split); + } return ids.length > 0 ? { drm: ids } : {}; }; @@ -191,10 +250,12 @@ export function toHang(msf: Msf.Catalog, base?: Path.Valid): Catalog.Root { } if (track.role === "video") { const config = toVideoConfig(track); - if (config) videoRenditions[track.name] = { ...config, broadcast, ...protection(track) }; + const drm = protection(track); + if (config && drm) videoRenditions[track.name] = { ...config, broadcast, ...drm }; } else if (track.role === "audio") { const config = toAudioConfig(track); - if (config) audioRenditions[track.name] = { ...config, broadcast, ...protection(track) }; + const drm = protection(track); + if (config && drm) audioRenditions[track.name] = { ...config, broadcast, ...drm }; } else if ( track.role === "caption" || track.role === "subtitle" || diff --git a/rs/moq-msf/src/lib.rs b/rs/moq-msf/src/lib.rs index 74d5801d24f..6e35b9f1dd3 100644 --- a/rs/moq-msf/src/lib.rs +++ b/rs/moq-msf/src/lib.rs @@ -352,6 +352,15 @@ impl<'de, E: CatalogExt> Deserialize<'de> for Catalog { } } + // A refID names one entry, so a repeated one leaves its tracks' protection ambiguous. + let mut ref_ids = std::collections::HashSet::new(); + if let Some(repeated) = (wire.content_protections.iter()).find(|cp| !ref_ids.insert(cp.ref_id.as_str())) { + return Err(serde::de::Error::custom(format!( + "MSF content protection refID {:?} is repeated", + repeated.ref_id + ))); + } + // A track's protection refers to a root entry by refID; one that names none would claim // encryption the catalog cannot describe, so it is refused like a missing initRef. for track in &wire.tracks { @@ -844,6 +853,16 @@ mod test { assert!(err.contains("missing content protection"), "{err}"); } + /// A refID names one entry, so a catalog repeating one is refused. + #[test] + fn a_repeated_protection_ref_id_is_refused() { + let entry = r#"{ "refID": "1", "defaultKID": ["01234567-89ab-cdef-0123-456789abcdef"], "scheme": "cbcs", + "drmSystem": { "systemID": "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" } }"#; + let json = format!(r#"{{ "version": "draft-01", "contentProtections": [{entry}, {entry}], "tracks": [] }}"#); + let err = json.parse::().unwrap_err().to_string(); + assert!(err.contains("is repeated"), "{err}"); + } + #[test] fn track_namespace_round_trips() { for version in ["1", "\"draft-01\""] { diff --git a/rs/moq-mux/src/catalog/msf/consumer.rs b/rs/moq-mux/src/catalog/msf/consumer.rs index 8939b0b5fb0..b80696b3656 100644 --- a/rs/moq-mux/src/catalog/msf/consumer.rs +++ b/rs/moq-mux/src/catalog/msf/consumer.rs @@ -114,12 +114,15 @@ impl From for Consumer { /// /// `contentProtections` become the `drm` section, each `refID` an entry ID, and a track's /// `contentProtectionRefIDs` its rendition's `drm`. An entry naming several default keys becomes -/// one hang entry per key, `{refID}:{kid}`, and a track lists the one its init's `tenc` uses (all -/// of them when the init names none). +/// one hang entry per key, `{refID}:{kid}` with the key in lowercase hyphenated form, and a track +/// lists the one its init's `tenc` uses (all of them when the init names none). An entry the hang +/// catalog cannot carry (a malformed ID, URL, or `pssh`, a scheme other than `cenc` and `cbcs`, no +/// default key, or a split ID that is another entry's `refID`) is dropped with a warning, and so is +/// every video and audio track it protects; the other tracks remain. pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net::Path) -> Result> { let mut catalog = Catalog::default(); catalog.ext = msf.ext.clone(); - let protections = Protections::from_msf(msf)?; + let protections = Protections::from_msf(msf); catalog.drm = protections.entries.clone(); for track in &msf.tracks { @@ -152,8 +155,12 @@ pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net: match role { moq_msf::Role::Video => match video_config_from_msf(track)? { Some(mut config) => { + let Some(drm) = protections.track(track, &config.container) else { + tracing::warn!(track = %track.name, "skipping MSF video track protected by an ignored content protection"); + continue; + }; config.broadcast = broadcast; - config.drm = protections.track(track, &config.container); + config.drm = drm; catalog.video.renditions.insert(track.name.clone(), config); } None => { @@ -166,8 +173,12 @@ pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net: }, moq_msf::Role::Audio => match audio_config_from_msf(track)? { Some(mut config) => { + let Some(drm) = protections.track(track, &config.container) else { + tracing::warn!(track = %track.name, "skipping MSF audio track protected by an ignored content protection"); + continue; + }; config.broadcast = broadcast; - config.drm = protections.track(track, &config.container); + config.drm = drm; catalog.audio.renditions.insert(track.name.clone(), config); } None => { @@ -201,58 +212,90 @@ pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net: struct Protections { /// The hang entries, by ID. entries: std::collections::BTreeMap, - /// Each `refID`'s hang entries, with the default key each one is for. - by_ref: std::collections::HashMap>, + /// Each usable `refID`'s hang entries, with the default key each one is for, or `None` for one + /// the hang catalog cannot carry. + by_ref: std::collections::HashMap>>, } impl Protections { - fn from_msf(msf: &moq_msf::Catalog) -> Result { - use hang::catalog::drm; - - let mut entries = std::collections::BTreeMap::new(); - let mut by_ref = std::collections::HashMap::>::new(); + /// Map each entry, dropping with a warning one the hang catalog cannot carry, so a bad entry + /// costs only the renditions it protects (see [`track`](Self::track)), not the whole catalog. + fn from_msf(msf: &moq_msf::Catalog) -> Self { + // moq-msf refuses a repeated refID. A split entry's `{refID}:{kid}` must not take another + // entry's refID, whichever comes first. + let ref_ids: std::collections::HashSet<&str> = + msf.content_protections.iter().map(|cp| cp.ref_id.as_str()).collect(); + let mut protections = Self { + entries: Default::default(), + by_ref: Default::default(), + }; for cp in &msf.content_protections { - let invalid = |reason| Error::InvalidContentProtection { - ref_id: cp.ref_id.clone(), - reason, + let split = match protections.split(cp, &ref_ids) { + Ok(split) => Some(split), + Err(reason) => { + tracing::warn!(ref_id = %cp.ref_id, reason, "ignoring MSF content protection the hang catalog cannot carry"); + None + } }; - let system = drm::Uuid::try_parse(&cp.drm_system.system_id).map_err(|_| invalid("malformed systemID"))?; - let scheme: drm::Scheme = cp.scheme.parse().map_err(|_| invalid("unsupported scheme"))?; - let server = |url: &moq_msf::ProtectionUrl| -> Result { - let mut server = drm::Server::new(url.url.parse().map_err(|_| invalid("malformed URL"))?); - server.kind = url.kind.clone(); - Ok(server) + protections.by_ref.insert(cp.ref_id.clone(), split); + } + protections + } + + /// Add `cp`'s hang entries, one per default key, returning their IDs. + fn split( + &mut self, + cp: &moq_msf::ContentProtection, + ref_ids: &std::collections::HashSet<&str>, + ) -> std::result::Result, &'static str> { + use hang::catalog::drm; + + let system = drm::Uuid::try_parse(&cp.drm_system.system_id).map_err(|_| "malformed systemID")?; + let scheme: drm::Scheme = cp.scheme.parse().map_err(|_| "unsupported scheme")?; + let server = |url: &moq_msf::ProtectionUrl| -> std::result::Result { + let mut server = drm::Server::new(url.url.parse().map_err(|_| "malformed URL")?); + server.kind = url.kind.clone(); + Ok(server) + }; + let license = cp.drm_system.la_url.as_ref().map(server).transpose()?; + let certificate = cp.drm_system.cert_url.as_ref().map(server).transpose()?; + let pssh = (cp.drm_system.pssh.as_ref()) + .map(|pssh| base64::engine::general_purpose::STANDARD.decode(pssh)) + .transpose() + .map_err(|_| "malformed pssh")?; + if cp.default_kid.is_empty() { + return Err("no defaultKID"); + } + + let mut split = Vec::with_capacity(cp.default_kid.len()); + for kid in &cp.default_kid { + let kid = drm::Uuid::try_parse(kid).map_err(|_| "malformed defaultKID")?; + let id = match cp.default_kid.len() { + 1 => cp.ref_id.clone(), + _ => format!("{}:{}", cp.ref_id, kid.hyphenated()), }; - let license = cp.drm_system.la_url.as_ref().map(server).transpose()?; - let certificate = cp.drm_system.cert_url.as_ref().map(server).transpose()?; - let pssh = (cp.drm_system.pssh.as_ref()) - .map(|pssh| base64::engine::general_purpose::STANDARD.decode(pssh)) - .transpose() - .map_err(|_| invalid("malformed pssh"))?; - if cp.default_kid.is_empty() { - return Err(invalid("no defaultKID").into()); + if split.iter().any(|(other, _)| *other == id) { + return Err("repeated defaultKID"); } - - let split = by_ref.entry(cp.ref_id.clone()).or_default(); - for kid in &cp.default_kid { - let kid = drm::Uuid::try_parse(kid).map_err(|_| invalid("malformed defaultKID"))?; - let id = match cp.default_kid.len() { - 1 => cp.ref_id.clone(), - _ => format!("{}:{}", cp.ref_id, kid.hyphenated()), - }; - let mut entry = drm::Entry::new(system, scheme, kid); - entry.license = license.clone(); - entry.certificate = certificate.clone(); - entry.pssh = pssh.clone().map(Into::into); - entries.insert(id.clone(), entry); - split.push((id, kid)); + if cp.default_kid.len() > 1 && ref_ids.contains(id.as_str()) { + return Err("a split entry ID is another entry's refID"); } + split.push((id, kid)); } - Ok(Self { entries, by_ref }) + for (id, kid) in &split { + let mut entry = drm::Entry::new(system, scheme, *kid); + entry.license = license.clone(); + entry.certificate = certificate.clone(); + entry.pssh = pssh.clone().map(Into::into); + self.entries.insert(id.clone(), entry); + } + Ok(split) } - /// The hang entry IDs protecting `track`, whose CMAF init is in `container`. - fn track(&self, track: &moq_msf::Track, container: &Container) -> Vec { + /// The hang entry IDs protecting `track`, whose CMAF init is in `container`, or `None` when it + /// references an entry that was dropped: its samples are encrypted in a way the catalog cannot + /// describe, so the rendition is left out rather than signalled as clear. + fn track(&self, track: &moq_msf::Track, container: &Container) -> Option> { let kid = match container { Container::Cmaf { init } => init_kid(init), _ => None, @@ -264,6 +307,7 @@ impl Protections { .iter() .filter_map(|id| self.by_ref.get(id)) { + let split = split.as_ref()?; let matching: Vec<_> = split.iter().filter(|(_, other)| Some(*other) == kid).collect(); let chosen = match (split.len(), matching.is_empty()) { (1, _) | (_, true) => split.iter().collect(), @@ -271,7 +315,7 @@ impl Protections { }; ids.extend(chosen.into_iter().map(|(id, _)| id.clone())); } - ids + Some(ids) } } @@ -593,7 +637,7 @@ fn derive_from_cmaf_moov(track: &moq_msf::Track, init: bytes::Bytes) -> Result>(), ["wv"]); + assert!(catalog.video.renditions.is_empty()); + assert!(catalog.audio.renditions.contains_key("audio")); + } + } + + /// A split entry's ID writes its key in lowercase hyphenated form, whatever form the MSF + /// catalog used, as `@moq/watch` does; one that would take another entry's `refID` drops that + /// entry rather than overwriting the other. + #[test] + fn split_entry_ids_are_normalised_and_never_collide() { + let json = r#"{ + "version": "draft-01", + "contentProtections": [ + { "refID": "ck", "defaultKID": ["0123456789ABCDEF0123456789ABCDEF", "{A1B2C3D4-E5F6-0718-293A-4B5C6D7E8F90}"], + "scheme": "cenc", "drmSystem": { "systemID": "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b" } } + ], + "tracks": [ + { "name": "video", "packaging": "legacy", "isLive": true, "role": "video", "codec": "vp8", + "contentProtectionRefIDs": ["ck"] } + ] + }"#; + let msf: moq_msf::Catalog = json.parse().unwrap(); + let catalog = from_msf(&msf, &moq_net::Path::empty()).unwrap(); + assert_eq!( + catalog.drm.keys().collect::>(), + [ + "ck:01234567-89ab-cdef-0123-456789abcdef", + "ck:a1b2c3d4-e5f6-0718-293a-4b5c6d7e8f90" + ] + ); + assert_eq!( + catalog.drm["ck:01234567-89ab-cdef-0123-456789abcdef"].kid, + hang::catalog::drm::Uuid::from_u128(0x01234567_89ab_cdef_0123_456789abcdef) + ); + + // Another entry whose refID is one of the split IDs keeps it; the split entry is dropped. + let colliding = json.replace( + "\"contentProtections\": [", + r#""contentProtections": [ + { "refID": "ck:01234567-89ab-cdef-0123-456789abcdef", "defaultKID": ["01234567-89ab-cdef-0123-456789abcdef"], + "scheme": "cbcs", "drmSystem": { "systemID": "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" } },"#, + ); + let msf: moq_msf::Catalog = colliding.parse().unwrap(); + let catalog = from_msf(&msf, &moq_net::Path::empty()).unwrap(); + assert_eq!( + catalog.drm.keys().collect::>(), + ["ck:01234567-89ab-cdef-0123-456789abcdef"] + ); + assert_eq!( + catalog.drm["ck:01234567-89ab-cdef-0123-456789abcdef"].scheme, + hang::catalog::drm::Scheme::Cbcs + ); + assert!(catalog.video.renditions.is_empty()); } /// A later track with a name replaces the earlier one, even under another role, so the diff --git a/rs/moq-mux/src/catalog/msf/mod.rs b/rs/moq-mux/src/catalog/msf/mod.rs index fb1bd3220a4..03d75a80d94 100644 --- a/rs/moq-mux/src/catalog/msf/mod.rs +++ b/rs/moq-mux/src/catalog/msf/mod.rs @@ -40,17 +40,6 @@ pub enum Error { namespace: String, }, - /// A `contentProtections` entry the hang catalog's `drm` section cannot carry: a malformed - /// system or key ID, a scheme other than `cenc` and `cbcs`, no default key, or a malformed URL - /// or `pssh`. - #[error("MSF content protection {ref_id:?} is invalid: {reason}")] - InvalidContentProtection { - /// The entry's `refID`. - ref_id: String, - /// What is wrong with it. - reason: &'static str, - }, - /// The catalog frame is not valid UTF-8. #[error("MSF catalog frame is not valid UTF-8")] InvalidUtf8, From bbec20e781d7aa991773fbb9353eef3f04b868cd Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 20:26:10 +0100 Subject: [PATCH 14/23] fix(cli): refuse a repeated --drm-license or --drm-certificate system, and take a server type A second --drm-license (or --drm-certificate) for the same system silently replaced the first. It is now refused. SYSTEM:TYPE=URL gives the server's protocol or the certificate's MIME type, which the catalog carries as the server's type. Co-Authored-By: Claude Opus 5.5 --- rs/moq-cli/src/args.rs | 90 +++++++++++++++++++++++++++++++----------- 1 file changed, 68 insertions(+), 22 deletions(-) diff --git a/rs/moq-cli/src/args.rs b/rs/moq-cli/src/args.rs index 4f71204da5c..a2c7989b8f2 100644 --- a/rs/moq-cli/src/args.rs +++ b/rs/moq-cli/src/args.rs @@ -327,6 +327,11 @@ impl Invocation { { capture.validate()?; } + if let Command::Import(import) = command + && let ImportSource::Fmp4(fmp4) = &import.source + { + fmp4.drm()?; + } if let Command::Import(import) = command && import.report && let Some(reason) = import.source.catalog_refusal() @@ -887,7 +892,8 @@ impl ImportSource { Self::Avc3 => PublishFormat::Avc3, Self::Fmp4(args) => PublishFormat::Fmp4 { passthrough: args.passthrough, - drm: args.drm(), + // `Invocation::validate` refuses a system named twice. + drm: args.drm().unwrap_or_default(), }, Self::Ts(args) if args.passthrough => PublishFormat::TsPassthrough { pcr_pid: args.pcr_pid.map(|pid| pid.0), @@ -951,37 +957,51 @@ pub struct Fmp4Import { #[usage(long = "cmaf")] pub passthrough: bool, - /// The license server of a DRM system the media is encrypted for, as `SYSTEM=URL`. SYSTEM is - /// `widevine`, `playready`, `fairplay`, `clearkey`, or a system ID. Repeat for each system; - /// a system the media carries no `pssh` for is refused. - #[usage(long = "drm-license", value_name = "SYSTEM=URL", requires = "--cmaf")] + /// The license server of a DRM system the media is encrypted for, as `SYSTEM[:TYPE]=URL`. + /// SYSTEM is `widevine`, `playready`, `fairplay`, `clearkey`, or a system ID; TYPE is the + /// protocol the server speaks, such as `EME-1.0`. Once per system; a system the media carries + /// no `pssh` for is refused. + #[usage(long = "drm-license", value_name = "SYSTEM[:TYPE]=URL", requires = "--cmaf")] pub drm_license: Vec, - /// The certificate server of a DRM system, such as FairPlay's, as `SYSTEM=URL`. - #[usage(long = "drm-certificate", value_name = "SYSTEM=URL", requires = "--cmaf")] + /// The certificate server of a DRM system, such as FairPlay's, as `SYSTEM[:TYPE]=URL`, where + /// TYPE is the certificate's MIME type. Once per system. + #[usage(long = "drm-certificate", value_name = "SYSTEM[:TYPE]=URL", requires = "--cmaf")] pub drm_certificate: Vec, } impl Fmp4Import { - /// The servers of each DRM system the flags name. - fn drm(&self) -> std::collections::BTreeMap { + /// The servers of each DRM system the flags name, refusing a system named twice by one flag. + fn drm(&self) -> anyhow::Result> { let mut drm = std::collections::BTreeMap::<_, hang::catalog::drm::Servers>::new(); - for server in &self.drm_license { - drm.entry(server.system).or_default().license = Some(hang::catalog::drm::Server::new(server.url.clone())); - } - for server in &self.drm_certificate { - drm.entry(server.system).or_default().certificate = - Some(hang::catalog::drm::Server::new(server.url.clone())); + for (flag, servers) in [ + ("--drm-license", &self.drm_license), + ("--drm-certificate", &self.drm_certificate), + ] { + for server in servers { + let entry = drm.entry(server.system).or_default(); + let slot = match flag { + "--drm-license" => &mut entry.license, + _ => &mut entry.certificate, + }; + anyhow::ensure!(slot.is_none(), "{flag} names DRM system {} twice", server.system); + let mut value = hang::catalog::drm::Server::new(server.url.clone()); + value.kind = server.kind.clone(); + *slot = Some(value); + } } - drm + Ok(drm) } } -/// An `import fmp4 --drm-license` or `--drm-certificate` value: a DRM system and a server URL. +/// An `import fmp4 --drm-license` or `--drm-certificate` value: a DRM system, optionally the +/// server's type, and its URL. #[derive(Clone, Debug, PartialEq, Eq)] pub struct DrmServer { /// The DRM system ID. pub system: hang::catalog::drm::Uuid, + /// The server's protocol, or the certificate's MIME type. + pub kind: Option, /// The server's URL. pub url: url::Url, } @@ -992,7 +1012,13 @@ impl std::str::FromStr for DrmServer { fn from_str(arg: &str) -> Result { let (system, url) = arg .split_once('=') - .ok_or_else(|| format!("expected SYSTEM=URL, got `{arg}`"))?; + .ok_or_else(|| format!("expected SYSTEM[:TYPE]=URL, got `{arg}`"))?; + // No system ID or name holds a colon, so the first one starts the type. + let (system, kind) = match system.split_once(':') { + Some((_, "")) => return Err(format!("empty TYPE in `{arg}`")), + Some((system, kind)) => (system, Some(kind.to_string())), + None => (system, None), + }; let system = hang::catalog::drm::system::named(system) .or_else(|| hang::catalog::drm::Uuid::try_parse(system).ok()) .ok_or_else(|| { @@ -1001,7 +1027,7 @@ impl std::str::FromStr for DrmServer { ) })?; let url = url.parse().map_err(|err| format!("invalid URL `{url}`: {err}"))?; - Ok(Self { system, url }) + Ok(Self { system, kind, url }) } } @@ -2052,6 +2078,7 @@ mod tests { let format = |args: &[&str]| { let argv = ["moq", "import", "fmp4"].into_iter().chain(args.iter().copied()); let cli = Invocation::try_parse_from(argv).ok()?; + cli.validate().ok()?; let Command::Import(import) = &cli.stages[0] else { panic!("an import stage"); }; @@ -2064,7 +2091,9 @@ mod tests { "--drm-license", "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed=https://wv.example.com/", "--drm-certificate", - "FairPlay=https://fps.example.com/cert", + "FairPlay:application/pkcs7-mime=https://fps.example.com/cert", + "--drm-license", + "fairplay=https://fps.example.com/license", ]) else { panic!("an fmp4 import"); }; @@ -2074,8 +2103,25 @@ mod tests { "https://license.example.com/clearkey" ); assert!(drm[&drm::system::WIDEVINE].certificate.is_none()); - assert!(drm[&drm::system::FAIRPLAY].license.is_none()); - assert!(drm[&drm::system::FAIRPLAY].certificate.is_some()); + assert!(drm[&drm::system::FAIRPLAY].license.is_some()); + let certificate = drm[&drm::system::FAIRPLAY].certificate.as_ref().unwrap(); + assert_eq!(certificate.kind.as_deref(), Some("application/pkcs7-mime")); + assert_eq!(certificate.url.as_str(), "https://fps.example.com/cert"); + assert!(drm[&drm::system::CLEARKEY].license.as_ref().unwrap().kind.is_none()); + + // One server per system and role: a repeat is refused rather than replacing the first. + assert!( + format(&[ + "--cmaf", + "--drm-license", + "clearkey=https://a.example/", + "--drm-license", + "ClearKey:EME-1.0=https://b.example/", + ]) + .is_none(), + "a repeated system" + ); + assert!(format(&["--cmaf", "--drm-license", "clearkey:=https://a.example/"]).is_none()); assert!( format(&["--drm-license", "clearkey=https://a.example/"]).is_none(), From 109905bb1d87f6cf0be58b8fc0c0784bdded89ca Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 20:26:11 +0100 Subject: [PATCH 15/23] docs(hang): protected renditions in the Rust tools, and soften the CMAF-only wording The concept doc names the Rust consumers that leave a protected rendition out and uses "video" as the example rendition ID; the CLI doc gives the SYSTEM:TYPE form. The hang draft, hang, and js/hang no longer say only a CMAF rendition can be protected, which nothing enforces, and note that a multi-key CMSF entry splits on parse. Renditions under one key MAY share an entry, since different servers now take their own. Co-Authored-By: Claude Opus 5.5 --- doc/bin/cli.md | 7 ++++--- doc/concept/hang.md | 7 +++++-- drafts/draft-lcurley-moq-hang.md | 7 ++++--- js/hang/src/catalog/audio.ts | 5 +++-- js/hang/src/catalog/drm.ts | 3 ++- js/hang/src/catalog/video.ts | 5 +++-- rs/hang/src/catalog/audio/mod.rs | 7 ++++--- rs/hang/src/catalog/drm.rs | 5 +++-- rs/hang/src/catalog/video/mod.rs | 7 ++++--- 9 files changed, 32 insertions(+), 21 deletions(-) diff --git a/doc/bin/cli.md b/doc/bin/cli.md index 26d06e7df79..001e03be588 100644 --- a/doc/bin/cli.md +++ b/doc/bin/cli.md @@ -161,9 +161,10 @@ timing. such as Shaka Packager's output, unchanged, and signals it in the catalog's [`drm`](/concept/hang#content-protection) section. Name each DRM system's license server with `--drm-license SYSTEM=URL`, and FairPlay's certificate with -`--drm-certificate SYSTEM=URL`; SYSTEM is `widevine`, `playready`, `fairplay`, -`clearkey`, or a system ID, and one the media carries no `pssh` for is -refused. Encrypted media without `--cmaf`, key rotation, and a clear lead are +`--drm-certificate SYSTEM=URL`, once per system; SYSTEM is `widevine`, +`playready`, `fairplay`, `clearkey`, or a system ID, and one the media carries +no `pssh` for is refused. `SYSTEM:TYPE=URL` also gives the server's type, such +as `widevine:EME-1.0=…` or `fairplay:application/pkcs7-mime=…`. Encrypted media without `--cmaf`, key rotation, and a clear lead are refused too. ```bash diff --git a/doc/concept/hang.md b/doc/concept/hang.md index 2a7ba72bcc0..42338bcb286 100644 --- a/doc/concept/hang.md +++ b/doc/concept/hang.md @@ -64,7 +64,7 @@ A few things the catalog can express beyond decoder config: - **Labels.** Any rendition may carry a human-readable `label` for a track picker. The map key stays the rendition's ID, so labels need not be unique and renaming one doesn't rename the track. - **Renditions in another broadcast.** A rendition may point at a relative broadcast path, so a transcoder can publish a ladder that adds low rungs and references the source's original rendition without re-publishing its bytes. The path resolves against where the consumer found the catalog, so a reference that escapes above the root names nothing and the catalog is rejected. `@moq/watch` and `moqsrc` follow a referenced path's announcements like their own, restarting the rendition on each instance that serves it; every other reader, such as `moq play`, the exporters, and the bindings, waits for the first one announced and keeps it, and an exporter ends the rendition with it. An optional `instance` beside the path names the [stream](/concept/moq-lite#publisher-instances) it expects: a route of another instance ends the rendition instead of falling back to it, while a route whose instance a session minted (one that crossed an older version) cannot prove one, so there it is best effort. Omit `instance` for a broadcast produced on demand, which has none until a worker answers; see [identity and recovery](/concept/identity). - **Whole contributions.** A root `contributions` map names whole broadcasts, such as each guest feed in a composed room, by the same relative path and optional `instance` as a rendition's reference. Listing one opens nothing, so a contribution produced on demand starts only once a viewer selects it, which `@moq/watch` does with `broadcast.contribution(effect, id)`. Its rendition IDs stay its own. -- **DRM.** A root `drm` map describes the DRM systems protecting Common Encryption (`cenc` or `cbcs`) CMAF renditions, one entry per system, scheme, and key: its `system` and `kid` UUIDs, the `pssh` box, and the `license` and `certificate` servers. A protected rendition lists its entries' IDs in its own `drm` field, keeps the encrypted sample entry in its `init`, and names the codec that entry wraps; a rendition listing an ID the root lacks refuses the catalog. Renditions under one key share an entry. The MSF catalog carries the same entries as CMSF `contentProtections`. See [Content protection](#content-protection). +- **DRM.** A root `drm` map describes the DRM systems protecting Common Encryption (`cenc` or `cbcs`) CMAF renditions, one entry per system, scheme, and key: its `system` and `kid` UUIDs, the `pssh` box, and the `license` and `certificate` servers. A protected rendition lists its entries' IDs in its own `drm` field, keeps the encrypted sample entry in its `init`, and names the codec that entry wraps; a rendition listing an ID the root lacks refuses the catalog. Renditions under one key, with the same servers, share an entry. The MSF catalog carries the same entries as CMSF `contentProtections`. See [Content protection](#content-protection). - **Track names.** The map key is a rendition's ID and, by default, its track name. A rendition sets `track` only when the two must differ, such as two renditions of same-named tracks in different broadcasts, or a rendition whose media changed and so needs a new name; readers subscribe to `track` when present. An ID can't name both a video and an audio rendition. - **Jitter.** A rendition can say how much media it writes behind a frame's timestamp, in whole milliseconds rounded up: the reorder delay of B-frames and the span of a fragment or batch written together. It is measured from media timestamps alone, never the time a frame was written, so neither a constant encoder delay nor a capture clock counts. It describes the publisher, never the network, only grows over the life of a stream, and a player sizes its buffer to at least this much. A `0` is read as absent. - **Delay.** A rendition can also say how far its frames' timestamps trail those another rendition already wrote, so a video encoder running 200 ms behind audio advertises `delay: 200` on video. A rendition alone measures none. It follows the same rules as jitter. A player holds the largest `delay + jitter` among the renditions it subscribes to, and never subtracts one rendition's `delay` from another's. @@ -262,12 +262,15 @@ media, so the publisher supplies them per DRM system, with `--drm-license` and "license": { "url": "https://license.example.com/clearkey" } } }, - "video": { "renditions": { "0.m4s": { "codec": "avc1.64000c", "drm": ["1"], "container": { "kind": "cmaf", "init": "..." } } } } + "video": { "renditions": { "video": { "codec": "avc1.64000c", "drm": ["1"], "container": { "kind": "cmaf", "init": "..." } } } } } ``` WebCodecs cannot decrypt, so `@moq/watch` treats a protected rendition as unplayable and never selects it. Playback through MSE and EME is not built yet. +Nothing in the Rust tools decrypts either: `moq play`, `moq export`, the HLS +gateway, recordings, and transcoding leave a protected rendition out, as they +would a codec they cannot decode. Key rotation and a clear lead are refused on import, as is anything else the republished media could not decrypt. diff --git a/drafts/draft-lcurley-moq-hang.md b/drafts/draft-lcurley-moq-hang.md index 064de57ca2f..ad914f98978 100644 --- a/drafts/draft-lcurley-moq-hang.md +++ b/drafts/draft-lcurley-moq-hang.md @@ -279,14 +279,15 @@ type DrmSchema = { The `system` field is the DRM system ID and `kid` the default key ID, each a hyphenated UUID string, and `scheme` is the Common Encryption scheme {{cenc}}. The `pssh` field is the system's whole `pssh` box, base64-encoded ({{!RFC4648, Section 4}}). The `license` field names the server a consumer requests a license from, and `certificate` the server certificate a system such as FairPlay needs first; each `type` is the license protocol or the certificate's MIME type. -Renditions encrypted under the same system, scheme, and key share an entry. +Renditions encrypted under the same system, scheme, and key MAY share an entry. A protected audio or video rendition lists the IDs of the entries that can decrypt it in its `drm` field, an array of strings; absent or empty means the rendition is clear. -Only a `cmaf` rendition ({{cmaf}}) can be protected: its `init` keeps the encrypted sample entry with its `sinf`, and the `pssh` boxes, while its `codec` names the codec the encrypted entry wraps. +Common Encryption is defined for CMAF, so a protected rendition is in practice a `cmaf` one ({{cmaf}}): its `init` keeps the encrypted sample entry with its `sinf`, and the `pssh` boxes, while its `codec` names the codec the encrypted entry wraps. A consumer MUST reject a catalog with a malformed entry, or with a rendition listing an ID the root `drm` lacks. A consumer that cannot decrypt a rendition MUST treat it as one it cannot decode. -Each entry maps 1:1 onto a CMSF `contentProtections` entry {{moqcmsf}}: the ID is its `refID`, `kid` its single `defaultKID`, `system`, `license`, `certificate`, and `pssh` its `drmSystem`'s `systemID`, `laURL`, `certURL`, and `pssh`, and a rendition's `drm` its `contentProtectionRefIDs`. +Each entry maps onto a CMSF `contentProtections` entry {{moqcmsf}}: the ID is its `refID`, `kid` its single `defaultKID`, `system`, `license`, `certificate`, and `pssh` its `drmSystem`'s `systemID`, `laURL`, `certURL`, and `pssh`, and a rendition's `drm` its `contentProtectionRefIDs`. +A CMSF entry naming several `defaultKID`s has no single hang entry, so a consumer converting it splits it into one entry per key. ## Track Identity {#identity} A track name always means the same content, so a catalog update never redefines an audio or video track. diff --git a/js/hang/src/catalog/audio.ts b/js/hang/src/catalog/audio.ts index 246882b38bd..0e9891d79a3 100644 --- a/js/hang/src/catalog/audio.ts +++ b/js/hang/src/catalog/audio.ts @@ -40,8 +40,9 @@ const AudioConfigFields = z.object({ container: ContainerSchema, // The IDs of the root `drm` entries protecting this rendition, one per DRM system that can - // decrypt it. Absent or empty means clear. Only a CMAF rendition can be protected; `codec` names - // the codec its encrypted sample entry wraps. A consumer that can't decrypt skips it. + // decrypt it. Absent or empty means clear. Common Encryption is defined for CMAF, so in practice + // it is a CMAF rendition, and `codec` names the codec its encrypted sample entry wraps. A consumer + // that can't decrypt skips it. drm: z.optional(z.array(z.string())), // The description is used for some codecs. diff --git a/js/hang/src/catalog/drm.ts b/js/hang/src/catalog/drm.ts index 2e442976769..91b4bba38b0 100644 --- a/js/hang/src/catalog/drm.ts +++ b/js/hang/src/catalog/drm.ts @@ -25,7 +25,8 @@ export type DrmServer = z.infer; * One DRM system protecting renditions under one Common Encryption scheme and one default key. * * Each protected video or audio rendition lists the IDs of its entries in its own `drm` field; - * the entries map 1:1 onto draft-ietf-moq-cmsf's `contentProtections`. + * each entry maps onto one of draft-ietf-moq-cmsf's `contentProtections`, and a CMSF entry naming + * several default keys splits into one entry per key on parse. */ export const DrmSchema = z.object({ // The DRM system ID, as a UUID string (see `SYSTEM`). diff --git a/js/hang/src/catalog/video.ts b/js/hang/src/catalog/video.ts index 016259b4c66..e17a5ef5318 100644 --- a/js/hang/src/catalog/video.ts +++ b/js/hang/src/catalog/video.ts @@ -136,8 +136,9 @@ export const VideoConfigSchema = z.object({ container: ContainerSchema, // The IDs of the root `drm` entries protecting this rendition, one per DRM system that can - // decrypt it. Absent or empty means clear. Only a CMAF rendition can be protected; `codec` names - // the codec its encrypted sample entry wraps. A consumer that can't decrypt skips it. + // decrypt it. Absent or empty means clear. Common Encryption is defined for CMAF, so in practice + // it is a CMAF rendition, and `codec` names the codec its encrypted sample entry wraps. A consumer + // that can't decrypt skips it. drm: z.optional(z.array(z.string())), // The description is used for some codecs. diff --git a/rs/hang/src/catalog/audio/mod.rs b/rs/hang/src/catalog/audio/mod.rs index db7b1962387..5bacf93f4c7 100644 --- a/rs/hang/src/catalog/audio/mod.rs +++ b/rs/hang/src/catalog/audio/mod.rs @@ -178,9 +178,10 @@ pub struct AudioConfig { /// The IDs of the root `drm` entries protecting this rendition, one per DRM system that can /// decrypt it. Empty means the rendition is clear, and is left off the wire. /// - /// Only a [`Cmaf`](Container::Cmaf) rendition can be protected: its init segment carries the - /// encrypted sample entry (`encv`/`enca`), while `codec` names the codec it wraps. A consumer - /// that cannot decrypt treats a protected rendition as undecodable. + /// Common Encryption is defined for CMAF, so a protected rendition is a [`Cmaf`](Container::Cmaf) + /// one in practice: its init segment carries the encrypted sample entry (`encv`/`enca`), while + /// `codec` names the codec it wraps. A consumer that cannot decrypt treats a protected + /// rendition as undecodable. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub drm: Vec, diff --git a/rs/hang/src/catalog/drm.rs b/rs/hang/src/catalog/drm.rs index 39c46805ab8..1d60c6ff736 100644 --- a/rs/hang/src/catalog/drm.rs +++ b/rs/hang/src/catalog/drm.rs @@ -3,8 +3,9 @@ //! The catalog's root `drm` section maps an entry ID to an [`Entry`], and each protected video or //! audio rendition lists the IDs of the entries that protect it in its `drm` field. A rendition //! that lists none is clear. Every entry names one DRM system, one Common Encryption -//! [`Scheme`], and one default key, so the entries map 1:1 onto draft-ietf-moq-cmsf's -//! `contentProtections` and a rendition's IDs onto its `contentProtectionRefIDs`. +//! [`Scheme`], and one default key, so each maps onto one of draft-ietf-moq-cmsf's +//! `contentProtections` and a rendition's IDs onto its `contentProtectionRefIDs`; a CMSF entry +//! naming several default keys splits into one entry per key on parse. //! //! ```json //! { diff --git a/rs/hang/src/catalog/video/mod.rs b/rs/hang/src/catalog/video/mod.rs index ace83a0e5e2..3bef6a49ac3 100644 --- a/rs/hang/src/catalog/video/mod.rs +++ b/rs/hang/src/catalog/video/mod.rs @@ -320,9 +320,10 @@ pub struct VideoConfig { /// The IDs of the root `drm` entries protecting this rendition, one per DRM system that can /// decrypt it. Empty means the rendition is clear, and is left off the wire. /// - /// Only a [`Cmaf`](Container::Cmaf) rendition can be protected: its init segment carries the - /// encrypted sample entry (`encv`/`enca`), while `codec` names the codec it wraps. A consumer - /// that cannot decrypt treats a protected rendition as undecodable. + /// Common Encryption is defined for CMAF, so a protected rendition is a [`Cmaf`](Container::Cmaf) + /// one in practice: its init segment carries the encrypted sample entry (`encv`/`enca`), while + /// `codec` names the codec it wraps. A consumer that cannot decrypt treats a protected + /// rendition as undecodable. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub drm: Vec, From 889404a3616181564394e6492ace4b4ba954b590 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 22:55:08 +0100 Subject: [PATCH 16/23] fix(mux): add a rendition's drm entries in the same catalog edit The fMP4 importer added a protected rendition's drm entries in one catalog edit and the rendition listing them in a later one. Another importer's rendition leaving in between released the new entries, so the rendition then listed missing ones: every later emit failed check_renditions and closed the catalog for every importer. An init failing after the entries went in left them behind. Rendition::set_protected now adds the entries, shared when identical, and the rendition in one guard, and releases them again if the rendition fails to write. RenditionConfig gains drm_mut, None by default. Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/catalog/tracks.rs | 64 ++++++++++++++++++++++++- rs/moq-mux/src/container/fmp4/import.rs | 49 +++++-------------- 2 files changed, 75 insertions(+), 38 deletions(-) diff --git a/rs/moq-mux/src/catalog/tracks.rs b/rs/moq-mux/src/catalog/tracks.rs index f4101f0ce62..1b6ba6ef7cd 100644 --- a/rs/moq-mux/src/catalog/tracks.rs +++ b/rs/moq-mux/src/catalog/tracks.rs @@ -111,6 +111,12 @@ pub trait RenditionConfig: Clone + Send + 'static { /// Replace the config's [`Estimate`] fields. Defaults to discarding them. fn set_estimate(&mut self, _estimate: Estimate) {} + + /// The IDs of the root `drm` entries the config lists, for a config that can be protected. + /// Defaults to `None`: only video and audio renditions carry protected media. + fn drm_mut(&mut self) -> Option<&mut Vec> { + None + } } impl RenditionConfig for hang::catalog::JsonConfig { @@ -294,6 +300,32 @@ impl VideoHint { } } +/// Add `entries` to the catalog's `drm` section, returning their IDs for a rendition to list. +/// +/// An entry identical to one already present (the same system, scheme, key, `pssh`, and servers) +/// is shared, so video and audio under one key list the same IDs. Any difference, such as another +/// importer's servers for the same key, takes a new entry with the lowest free numeric ID, so no +/// rendition is signalled with another's servers. +fn register_drm(catalog: &mut Catalog, entries: Vec) -> Vec { + let mut ids = Vec::with_capacity(entries.len()); + for entry in entries { + let existing = catalog.drm.iter().find(|(_, other)| **other == entry); + let id = match existing { + Some((id, _)) => id.clone(), + None => { + let id = (1..) + .map(|n: u64| n.to_string()) + .find(|id| !catalog.drm.contains_key(id)) + .expect("a free entry ID"); + catalog.drm.insert(id.clone(), entry); + id + } + }; + ids.push(id); + } + ids +} + /// Remove the `drm` entries among `ids` that no video or audio rendition lists any more, so an /// entry leaves the catalog with the last rendition it protects. fn release_drm(catalog: &mut Catalog, ids: &[String]) { @@ -337,6 +369,9 @@ impl RenditionConfig for hang::catalog::VideoConfig { self.delay = estimate.delay; self.framerate = estimate.framerate; } + fn drm_mut(&mut self) -> Option<&mut Vec> { + Some(&mut self.drm) + } } impl RenditionConfig for hang::catalog::AudioConfig { @@ -367,6 +402,9 @@ impl RenditionConfig for hang::catalog::AudioConfig { self.bitrate = estimate.bitrate; self.delay = estimate.delay; } + fn drm_mut(&mut self) -> Option<&mut Vec> { + Some(&mut self.drm) + } } impl RenditionConfig for hang::catalog::TextConfig { @@ -685,7 +723,21 @@ impl> Rendition { /// the MSF catalog. A caller who wants to pre-empt detection sets the field on the config, or (for /// a config an importer builds out of the bitstream) hands the importer a hint like [`VideoHint`]. /// Unset jitter and delay keep the published floor across reconfiguration. - pub(crate) fn set(&mut self, mut config: C) -> crate::Result<()> { + pub(crate) fn set(&mut self, config: C) -> crate::Result<()> { + self.set_protected(config, Vec::new()) + } + + /// [`set`](Self::set) a protected rendition, adding the `drm` entries protecting it in the same + /// catalog edit and listing their IDs in its config. + /// + /// One edit adds the entries and the rendition listing them, so no catalog holds one without the + /// other: an entry another rendition's removal released in between would dangle and fail every + /// later catalog publish, and one added for a rendition that then failed would be left behind. + pub(crate) fn set_protected( + &mut self, + mut config: C, + entries: Vec, + ) -> crate::Result<()> { let supplied = config.estimate(); let mut resolved = Self::resolved(&supplied, &self.detected); if self.present { @@ -701,7 +753,15 @@ impl> Rendition { config.set_estimate(resolved.clone()); { let mut guard = self.catalog.modify()?; - write(&mut guard, &self.name, config)?; + let ids = register_drm(&mut guard, entries); + if !ids.is_empty() { + let drm = config.drm_mut().expect("only video and audio renditions are protected"); + drm.clone_from(&ids); + } + if let Err(err) = write(&mut guard, &self.name, config) { + release_drm(&mut guard, &ids); + return Err(err); + } self.present = true; guard.list::(&self.name); if C::detects() { diff --git a/rs/moq-mux/src/container/fmp4/import.rs b/rs/moq-mux/src/container/fmp4/import.rs index ae1fed210ed..a0d7fde35b0 100644 --- a/rs/moq-mux/src/container/fmp4/import.rs +++ b/rs/moq-mux/src/container/fmp4/import.rs @@ -651,14 +651,9 @@ impl Import { Ok(protections) } - /// Add the catalog's `drm` entries for `protection`, one per DRM system with the servers - /// [`with_drm`](Self::with_drm) set for it, returning their IDs for the rendition to list. - /// - /// An entry identical to one another rendition already lists (the same system, scheme, key, - /// `pssh`, and servers) is shared, so video and audio under one key list the same IDs. Any - /// difference, such as another importer's servers for the same key, takes a new entry with the - /// lowest free numeric ID, so no importer's rendition is signalled with another's servers. - fn register_drm(&mut self, protection: &super::cenc::Protection) -> Result> { + /// The catalog's `drm` entries for `protection`, one per DRM system, each with the servers + /// [`with_drm`](Self::with_drm) set for it. + fn drm_entries(&self, protection: &super::cenc::Protection) -> Result> { let mut entries = protection.entries()?; for entry in &mut entries { if let Some(servers) = self.drm.get(&entry.system) { @@ -666,26 +661,7 @@ impl Import { entry.certificate = servers.certificate.clone(); } } - - let mut ids = Vec::with_capacity(entries.len()); - self.catalog.mutate(|catalog| { - for entry in entries { - let existing = catalog.drm.iter().find(|(_, other)| **other == entry); - let id = match existing { - Some((id, _)) => id.clone(), - None => { - let id = (1..) - .map(|n: u64| n.to_string()) - .find(|id| !catalog.drm.contains_key(id)) - .expect("a free entry ID"); - catalog.drm.insert(id.clone(), entry); - id - } - }; - ids.push(id); - } - })?; - Ok(ids) + Ok(entries) } fn init_passthrough( @@ -710,21 +686,22 @@ impl Import { // Whatever the descriptor declared (a bitrate) is authoritative; the rest is filled by // `estimate` as fragments arrive. - // The entries go in before the rendition listing them, so no catalog has a dangling one. - let drm = protection.map(|protection| self.register_drm(protection)).transpose()?; + // The entries go in with the rendition listing them, in one catalog edit. + let drm = match protection { + Some(protection) => self.drm_entries(protection)?, + None => Vec::new(), + }; let rendition = match kind { Kind::Video => { - let mut config = self.init_video(trak, moov, protection)?; - config.drm = drm.unwrap_or_default(); + let config = self.init_video(trak, moov, protection)?; let mut rendition = reserved.init(track.name())?; - rendition.set(config)?; + rendition.set_protected(config, drm)?; Rendition::Video(rendition) } Kind::Audio => { - let mut config = self.init_audio(trak, moov, protection)?; - config.drm = drm.unwrap_or_default(); + let config = self.init_audio(trak, moov, protection)?; let mut rendition = reserved.init(track.name())?; - rendition.set(config)?; + rendition.set_protected(config, drm)?; Rendition::Audio(rendition) } }; From b32d344943956aa35e27a5c0e0e3fa7990a06912 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 22:55:11 +0100 Subject: [PATCH 17/23] fix(mux): drop the unreachable ProtectionLacksSample Restating a fragment's encryption information checks the senc and saiz sample counts against the trun first, and mp4-atom decodes a saiz with one size per counted sample, so a kept sample always has its entry and ProtectionLacksSample could never be returned. It goes; the defensive lookups report InvalidProtection. A fragment kept whole still passes its senc and saiz through unchecked: ffmpeg's cenc audio (Lavf 63) carries every earlier fragment's entries in each senc and saiz, and holding the counts to the trun there would refuse ffmpeg's own output. Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/container/fmp4/cenc.rs | 22 +++++++++++----------- rs/moq-mux/src/container/fmp4/mod.rs | 9 --------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/rs/moq-mux/src/container/fmp4/cenc.rs b/rs/moq-mux/src/container/fmp4/cenc.rs index e3a2b5d000c..9384c15ac69 100644 --- a/rs/moq-mux/src/container/fmp4/cenc.rs +++ b/rs/moq-mux/src/container/fmp4/cenc.rs @@ -122,6 +122,11 @@ impl Aux { /// /// mp4-atom reads only the ISO `senc`, so this also refuses one that carries its information /// only in PIFF's `uuid` box, which the rebuilt fragment would drop. + /// + /// A fragment kept whole passes through as the source wrote it, so its `senc` and `saiz` sample + /// counts are not held to its `trun`: ffmpeg's `cenc` audio (as of Lavf 63) carries every earlier + /// fragment's entries too, and refusing that would refuse ffmpeg's own output. Only a fragment + /// the importer drops samples from is held to it, by [`restate`](Self::restate). pub fn check(&self, traf: &mp4_atom::Traf) -> Result<()> { if self.senc && traf.senc.is_none() { return Err(Error::InvalidProtection("encrypted fragment without senc").into()); @@ -155,10 +160,9 @@ impl Aux { let mut data = Vec::with_capacity(senc.data.len()); data.extend_from_slice(&(indices.len() as u32).to_be_bytes()); for &index in indices { - let entry = entries.get(index).ok_or(Error::ProtectionLacksSample { - aux: "senc", - sample: index, - })?; + let entry = entries + .get(index) + .ok_or(Error::InvalidProtection("a kept sample past senc"))?; data.extend_from_slice(entry); } kept.senc = Some(mp4_atom::Senc { @@ -174,13 +178,9 @@ impl Aux { } if saiz.default_sample_info_size == 0 { let sizes = (indices.iter()) - .map(|&index| { - (saiz.sample_info_size.get(index).copied()).ok_or(Error::ProtectionLacksSample { - aux: "saiz", - sample: index, - }) - }) - .collect::, _>>()?; + .map(|&index| saiz.sample_info_size.get(index).copied()) + .collect::>>() + .ok_or(Error::InvalidProtection("a kept sample past saiz"))?; kept.saiz.push(mp4_atom::Saiz { aux_info: saiz.aux_info.clone(), default_sample_info_size: 0, diff --git a/rs/moq-mux/src/container/fmp4/mod.rs b/rs/moq-mux/src/container/fmp4/mod.rs index 5f950970f87..257e892c33f 100644 --- a/rs/moq-mux/src/container/fmp4/mod.rs +++ b/rs/moq-mux/src/container/fmp4/mod.rs @@ -196,15 +196,6 @@ pub enum Error { #[error("key rotation is not supported")] KeyRotation, - /// An encrypted track's `senc` or `saiz` has no entry for a sample its fragment holds. - #[error("{aux} lacks the encryption information of sample {sample}")] - ProtectionLacksSample { - /// The box lacking the entry, `senc` or `saiz`. - aux: &'static str, - /// The sample's position among its fragment's. - sample: usize, - }, - /// A license or certificate server for a DRM system no encrypted track carries a `pssh` for. #[error("DRM system {0} protects no track")] UnusedDrmSystem(hang::catalog::drm::Uuid), From 7bd851036cd51d197323a86b9828ae2ecfe9fb44 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 22:55:29 +0100 Subject: [PATCH 18/23] fix(mux): never read an encrypted CMAF init as clear An MSF CMAF track whose initData is encrypted (encv/enca) but that lists no contentProtectionRefIDs became a clear rendition, so exports wrote an encv init without pssh or senc and decoders got ciphertext. from_msf now drops such a track, as it does one whose content protection it cannot carry. catalog::hang::protected counts a CMAF rendition whose init holds an encrypted sample entry as protected even when its drm is empty, and retain_clear uses it, so a third-party hang catalog that encrypts without signalling it is left out as well. retain_clear warns once per rendition and logs repeats at debug level, rather than warning on every snapshot. Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/catalog/hang/container.rs | 58 ++++++++++++++++---- rs/moq-mux/src/catalog/hang/mod.rs | 2 +- rs/moq-mux/src/catalog/msf/consumer.rs | 44 ++++++++------- rs/moq-mux/src/container/fmp4/cenc.rs | 17 ++++++ rs/moq-mux/src/container/fmp4/import_test.rs | 33 +++++++++++ rs/moq-mux/src/source.rs | 8 +-- 6 files changed, 124 insertions(+), 38 deletions(-) diff --git a/rs/moq-mux/src/catalog/hang/container.rs b/rs/moq-mux/src/catalog/hang/container.rs index ce97020253d..d7b8481b90c 100644 --- a/rs/moq-mux/src/catalog/hang/container.rs +++ b/rs/moq-mux/src/catalog/hang/container.rs @@ -73,32 +73,66 @@ pub(crate) fn supported(rendition: &str, container: &hang::catalog::Container) - } } -/// Drop the protected video and audio renditions, those listing `drm` entries, logging each one. +/// Drop the protected video and audio renditions, logging each one (see [`protected`]). /// /// Their samples are encrypted, and the hang spec has a consumer that cannot decrypt a rendition /// treat it as one it cannot decode. Nothing here decrypts, and a re-encoded file would also lose -/// the `pssh`, `senc`, `saiz`, and `saio` a decrypting player needs, so every export and player in -/// this workspace runs this on each catalog snapshot instead of writing undecryptable media. +/// the `pssh`, `senc`, `saiz`, and `saio` a decrypting player needs, so every export, player, and +/// binding in this workspace runs this on each catalog snapshot instead of handing out +/// undecryptable media. A rendition is logged as a warning the first time and at debug level after. pub fn retain_clear(catalog: &mut hang::Catalog) { catalog .video .renditions - .retain(|name, config| clear("video", name, &config.drm)); + .retain(|name, config| clear("video", name, &config.drm, &config.container)); catalog .audio .renditions - .retain(|name, config| clear("audio", name, &config.drm)); + .retain(|name, config| clear("audio", name, &config.drm, &config.container)); } -fn clear(kind: &'static str, rendition: &str, drm: &[String]) -> bool { - if drm.is_empty() { +/// Whether a rendition's samples are encrypted: it lists `drm` entries, or its CMAF init holds an +/// encrypted (`encv`/`enca`) sample entry. +/// +/// The init check catches a publisher that encrypts without signalling it, so a consumer never +/// reads such a rendition as clear and decodes ciphertext. +pub fn protected(drm: &[String], container: &hang::catalog::Container) -> bool { + if !drm.is_empty() { return true; } - tracing::warn!( - rendition, - kind, - "ignoring encrypted rendition: decryption is not supported" - ); + match container { + hang::catalog::Container::Cmaf { init, .. } => fmp4::cenc::init_sinf(init).is_some(), + _ => false, + } +} + +fn clear(kind: &'static str, rendition: &str, drm: &[String], container: &hang::catalog::Container) -> bool { + if !protected(drm, container) { + return true; + } + // Every catalog snapshot runs this, so warn only the first time a rendition is dropped. + static WARNED: std::sync::Mutex> = + std::sync::Mutex::new(std::collections::BTreeSet::new()); + let first = { + let mut warned = WARNED.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + // Bounded, so a publisher minting fresh names cannot grow it without limit. + if warned.len() >= 1024 { + warned.clear(); + } + warned.insert((kind, rendition.to_string())) + }; + match first { + true => tracing::warn!( + rendition, + kind, + "ignoring encrypted rendition: decryption is not supported" + ), + false => tracing::debug!( + rendition, + kind, + "ignoring encrypted rendition: decryption is not supported" + ), + } false } diff --git a/rs/moq-mux/src/catalog/hang/mod.rs b/rs/moq-mux/src/catalog/hang/mod.rs index c4ee2218f20..24e952e983c 100644 --- a/rs/moq-mux/src/catalog/hang/mod.rs +++ b/rs/moq-mux/src/catalog/hang/mod.rs @@ -12,6 +12,6 @@ mod ext; pub use consumer::Consumer; pub(crate) use container::supported; -pub use container::{Container, retain_clear}; +pub use container::{Container, protected, retain_clear}; pub use ext::{CatalogExt, Extra}; pub use hang::Catalog; diff --git a/rs/moq-mux/src/catalog/msf/consumer.rs b/rs/moq-mux/src/catalog/msf/consumer.rs index b80696b3656..1214815544a 100644 --- a/rs/moq-mux/src/catalog/msf/consumer.rs +++ b/rs/moq-mux/src/catalog/msf/consumer.rs @@ -118,7 +118,9 @@ impl From for Consumer { /// lists the one its init's `tenc` uses (all of them when the init names none). An entry the hang /// catalog cannot carry (a malformed ID, URL, or `pssh`, a scheme other than `cenc` and `cbcs`, no /// default key, or a split ID that is another entry's `refID`) is dropped with a warning, and so is -/// every video and audio track it protects; the other tracks remain. +/// every video and audio track it protects; the other tracks remain. A CMAF track whose init is +/// encrypted (`encv`/`enca`) but that lists no `contentProtectionRefIDs` is dropped the same way, +/// rather than read as clear. pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net::Path) -> Result> { let mut catalog = Catalog::default(); catalog.ext = msf.ext.clone(); @@ -156,7 +158,7 @@ pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net: moq_msf::Role::Video => match video_config_from_msf(track)? { Some(mut config) => { let Some(drm) = protections.track(track, &config.container) else { - tracing::warn!(track = %track.name, "skipping MSF video track protected by an ignored content protection"); + tracing::warn!(track = %track.name, "skipping MSF video track whose protection the catalog cannot signal"); continue; }; config.broadcast = broadcast; @@ -174,7 +176,7 @@ pub(crate) fn from_msf(msf: &moq_msf::Catalog, base: &moq_net: moq_msf::Role::Audio => match audio_config_from_msf(track)? { Some(mut config) => { let Some(drm) = protections.track(track, &config.container) else { - tracing::warn!(track = %track.name, "skipping MSF audio track protected by an ignored content protection"); + tracing::warn!(track = %track.name, "skipping MSF audio track whose protection the catalog cannot signal"); continue; }; config.broadcast = broadcast; @@ -293,13 +295,23 @@ impl Protections { } /// The hang entry IDs protecting `track`, whose CMAF init is in `container`, or `None` when it - /// references an entry that was dropped: its samples are encrypted in a way the catalog cannot - /// describe, so the rendition is left out rather than signalled as clear. + /// references an entry that was dropped, or its init is encrypted (`encv`/`enca`) and it + /// references none: its samples are encrypted in a way the catalog cannot describe, so the + /// rendition is left out rather than signalled as clear. fn track(&self, track: &moq_msf::Track, container: &Container) -> Option> { - let kid = match container { - Container::Cmaf { init } => init_kid(init), - _ => None, + let (encrypted, kid) = match container { + Container::Cmaf { init } => match crate::container::fmp4::cenc::init_sinf(init) { + Some(_) => (true, init_kid(init)), + None => (false, None), + }, + _ => (false, None), }; + // An encrypted init no content protection signals would read as clear, and every consumer + // would then decode ciphertext. + if encrypted && track.content_protection_ref_ids.is_empty() { + tracing::warn!(track = %track.name, "MSF track has an encrypted init but no contentProtectionRefIDs"); + return None; + } let mut ids = Vec::new(); // moq-msf refuses a refID the root lacks. for split in track @@ -321,19 +333,9 @@ impl Protections { /// The default key ID an encrypted CMAF init's `tenc` names, if any. fn init_kid(init: &[u8]) -> Option { - use mp4_atom::{Any, DecodeMaybe}; - - let mut cursor = std::io::Cursor::new(init); - while let Ok(Some(atom)) = Any::decode_maybe(&mut cursor) { - if let Any::Moov(moov) = atom { - let sinf = (moov.trak.iter()) - .flat_map(|trak| &trak.mdia.minf.stbl.stsd.codecs) - .find_map(crate::container::fmp4::cenc::sinf)?; - let tenc = sinf.schi.as_ref()?.tenc.as_ref()?; - return Some(hang::catalog::drm::Uuid::from_bytes(tenc.default_kid)); - } - } - None + let sinf = crate::container::fmp4::cenc::init_sinf(init)?; + let tenc = sinf.schi.as_ref()?.tenc.as_ref()?; + Some(hang::catalog::drm::Uuid::from_bytes(tenc.default_kid)) } /// Decode the [`Container`] for a track based on its packaging and `init_data`. diff --git a/rs/moq-mux/src/container/fmp4/cenc.rs b/rs/moq-mux/src/container/fmp4/cenc.rs index 9384c15ac69..456327f193a 100644 --- a/rs/moq-mux/src/container/fmp4/cenc.rs +++ b/rs/moq-mux/src/container/fmp4/cenc.rs @@ -239,6 +239,23 @@ impl Aux { } } +/// The first `sinf` of an encrypted sample entry in a CMAF init's `moov`, `None` for a clear init +/// or one that does not decode. +pub(crate) fn init_sinf(init: &[u8]) -> Option { + use mp4_atom::{Any, DecodeMaybe}; + + let mut cursor = std::io::Cursor::new(init); + while let Ok(Some(atom)) = Any::decode_maybe(&mut cursor) { + if let Any::Moov(moov) = atom { + return (moov.trak.iter()) + .flat_map(|trak| &trak.mdia.minf.stbl.stsd.codecs) + .find_map(sinf) + .cloned(); + } + } + None +} + /// The `sinf` of an encrypted sample entry, `None` for a clear one. pub(crate) fn sinf(codec: &mp4_atom::Codec) -> Option<&mp4_atom::Sinf> { match codec { diff --git a/rs/moq-mux/src/container/fmp4/import_test.rs b/rs/moq-mux/src/container/fmp4/import_test.rs index 566a3249e7a..d1d046aee72 100644 --- a/rs/moq-mux/src/container/fmp4/import_test.rs +++ b/rs/moq-mux/src/container/fmp4/import_test.rs @@ -4108,6 +4108,39 @@ fn drm_renders_as_cmsf_content_protection_and_back() { assert_eq!(back.audio.renditions.values().next().unwrap().drm, ["1"]); } +/// An MSF CMAF track whose init is encrypted but that no `contentProtections` entry signals must not +/// read as clear: parsing drops it, and a hang catalog listing such a rendition without `drm` has +/// it removed by `retain_clear` all the same. +#[test] +fn an_encrypted_init_without_protection_is_never_clear() { + let (result, catalog, _, _importers) = import_protected(&[CENC], |fmp4| fmp4); + result.unwrap(); + let catalog = catalog.snapshot(); + + let mut msf = crate::catalog::to_msf(&catalog, &moq_net::Path::empty()); + msf.content_protections.clear(); + for track in &mut msf.tracks { + track.content_protection_ref_ids.clear(); + } + let wire: moq_msf::Catalog = msf.to_json().unwrap().parse().unwrap(); + let back = crate::catalog::msf::from_msf(&wire, &moq_net::Path::empty()).unwrap(); + assert!(back.video.renditions.is_empty(), "{:?}", back.video.renditions.keys()); + assert!(back.audio.renditions.is_empty(), "{:?}", back.audio.renditions.keys()); + + let mut unsignalled = catalog.clone(); + unsignalled.drm.clear(); + for config in unsignalled.video.renditions.values_mut() { + config.drm.clear(); + } + for config in unsignalled.audio.renditions.values_mut() { + config.drm.clear(); + } + assert!(!unsignalled.video.renditions.is_empty()); + crate::catalog::hang::retain_clear(&mut unsignalled); + assert!(unsignalled.video.renditions.is_empty()); + assert!(unsignalled.audio.renditions.is_empty()); +} + /// A license server for a DRM system the media carries no `pssh` for is a configuration mistake. #[test] fn a_drm_system_the_media_lacks_is_refused() { diff --git a/rs/moq-mux/src/source.rs b/rs/moq-mux/src/source.rs index fde8a59dff2..cd1e12baef8 100644 --- a/rs/moq-mux/src/source.rs +++ b/rs/moq-mux/src/source.rs @@ -264,10 +264,10 @@ impl Source { /// /// Every export runs this on each catalog snapshot, so a disabled rendition reads as /// absent: one that is disabled later leaves the snapshot, and one that re-enables - /// returns to it. A protected one (listing `drm` entries) reads as absent as well, since no - /// export decrypts it (see [`retain_clear`](crate::catalog::hang::retain_clear)). Every section carrying renditions must be listed here; one left out - /// silently exempts its renditions from the containment check, exactly as on the - /// consumer side. + /// returns to it. A protected one reads as absent as well, since no export decrypts it + /// (see [`retain_clear`](crate::catalog::hang::retain_clear)). Every section carrying + /// renditions must be listed here; one left out silently exempts its renditions from the + /// containment check, exactly as on the consumer side. pub(crate) fn retain_selectable( &self, catalog: &mut crate::catalog::hang::Catalog, From f4414cb313a55e8de0211f1454013e930792f91b Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 22:55:30 +0100 Subject: [PATCH 19/23] fix(mux): drop protected renditions before selecting, and fail when none is clear catalog::Select and moq-gst's source applied the selection before retain_clear, so a held clear rendition could be passed over for an enabled protected one, which retain_clear then removed, leaving nothing. Both now drop the protected renditions first. A snapshot whose video and audio are all protected fails the selection with the new Error::Protected. moq export of such a broadcast exited 0 having written nothing; it now fails with "no rendition can be exported: every one is protected". Co-Authored-By: Claude Opus 5.5 --- rs/moq-gst/src/source/imp.rs | 5 +- rs/moq-mux/MIGRATE.md | 8 ++- rs/moq-mux/src/catalog/select.rs | 68 ++++++++++++++++++-- rs/moq-mux/src/container/fmp4/export_test.rs | 27 ++++++++ rs/moq-mux/src/error.rs | 5 ++ 5 files changed, 103 insertions(+), 10 deletions(-) diff --git a/rs/moq-gst/src/source/imp.rs b/rs/moq-gst/src/source/imp.rs index f0cfe8a58ff..55154b4ef71 100644 --- a/rs/moq-gst/src/source/imp.rs +++ b/rs/moq-gst/src/source/imp.rs @@ -1045,12 +1045,13 @@ fn reconcile( } } let mut playable = catalog.clone(); + // Encrypted samples would reach the decoders as ciphertext; this source does not decrypt. Drop + // them before selecting, so a clear rendition is never passed over for a protected one. + moq_mux::catalog::hang::retain_clear(&mut playable); moq_mux::select::Broadcast::default() .video(Default::default()) .audio(Default::default()) .retain(&mut playable, &selected); - // Encrypted samples would reach the decoders as ciphertext; this source does not decrypt. - moq_mux::catalog::hang::retain_clear(&mut playable); // Build the desired shape for each rendition. This is deliberately cheap: caps come from the // catalog config and the container is just the hang descriptor. The reader parses the wire diff --git a/rs/moq-mux/MIGRATE.md b/rs/moq-mux/MIGRATE.md index e7da2f47db5..3e2cca92382 100644 --- a/rs/moq-mux/MIGRATE.md +++ b/rs/moq-mux/MIGRATE.md @@ -9,8 +9,12 @@ How to adopt new APIs and update for breaking changes, newest first. `fmp4::Import` with passthrough publishes Common Encryption (`cenc` and `cbcs`) fMP4 instead of refusing its `encv`/`enca` entries, filling the catalog's `drm` section; set license and certificate servers with `Import::with_drm`. Without passthrough, an encrypted file now fails with `fmp4::Error::ProtectedNeedsPassthrough` rather than `UnsupportedCodec`. -Every export (fMP4, MP4, MKV, MPEG-TS, FLV, Annex-B) leaves out a protected rendition, one whose `drm` lists entries, as it does a disabled one: nothing here decrypts, and a re-encoded file would lose its IVs. -A consumer of your own can do the same with `catalog::hang::retain_clear`. +Every export (fMP4, MP4, MKV, MPEG-TS, FLV, Annex-B) leaves out a protected rendition as it does a disabled one: nothing here decrypts, and a re-encoded file would lose its IVs. +A rendition is protected when its `drm` lists entries, or when it is CMAF and its init holds an encrypted (`encv`/`enca`) sample entry, so a publisher that encrypts without signalling it is never read as clear. +A consumer of your own can do the same with `catalog::hang::retain_clear`, or test one rendition with `catalog::hang::protected`. +`catalog::Select` drops protected renditions before it selects, and fails a snapshot whose video and audio are all protected with the new `Error::Protected`, so an export of such a broadcast fails instead of writing nothing. +An MSF CMAF track whose init is encrypted but that lists no `contentProtectionRefIDs` is dropped on parse rather than read as clear. +`RenditionConfig` gains `drm_mut`, defaulting to `None`; an implementation of your own needs no change. The re-exported `fmp4::mp4_atom` moves to the release with Common Encryption's boxes: a sample entry's `colr` is a `Vec`, `Moov` and `Moof` gain `pssh: Vec`, and `Codec` gains `Encv` and `Enca`. Build a `Moov` or `Moof` literal with `pssh: Vec::new()`, and match the new `Codec` variants. diff --git a/rs/moq-mux/src/catalog/select.rs b/rs/moq-mux/src/catalog/select.rs index 5193d0b9b1a..adf2ab2efe7 100644 --- a/rs/moq-mux/src/catalog/select.rs +++ b/rs/moq-mux/src/catalog/select.rs @@ -4,6 +4,10 @@ //! to each snapshot, dropping renditions that aren't selected before handing the //! catalog on. Each snapshot holds what the previous one selected, so a rendition its //! publisher disables stays while nothing else of its role is enabled. +//! +//! Protected renditions (see [`retain_clear`](super::hang::retain_clear)) are dropped before +//! selecting, since nothing that consumes a selection decrypts, and a snapshot whose video and +//! audio are all protected fails with [`Error::Protected`](crate::Error::Protected). use std::task::{Poll, ready}; @@ -39,12 +43,22 @@ impl Stream for Select { type Ext = S::Ext; fn poll_next(&mut self, waiter: &kio::Waiter) -> Poll>>> { - let next = ready!(self.inner.poll_next(waiter))?; - Poll::Ready(Ok(next.map(|mut catalog| { - self.selection.retain(&mut catalog, &self.selected); - self.selected = select::Selected::of(&catalog); - catalog - }))) + let Some(mut catalog) = ready!(self.inner.poll_next(waiter))? else { + return Poll::Ready(Ok(None)); + }; + // Nothing downstream of a selection decrypts, so a protected rendition is absent before it + // is chosen from: otherwise one could displace a clear rendition, then be dropped. + let media = |catalog: &Catalog| catalog.video.renditions.len() + catalog.audio.renditions.len(); + let listed = media(&catalog); + super::hang::retain_clear(&mut catalog); + // A broadcast whose media is all protected can never export anything; say so rather than + // export nothing and succeed. + if listed > 0 && media(&catalog) == 0 { + return Poll::Ready(Err(crate::Error::Protected)); + } + self.selection.retain(&mut catalog, &self.selected); + self.selected = select::Selected::of(&catalog); + Poll::Ready(Ok(Some(catalog))) } } @@ -92,6 +106,48 @@ mod tests { (name.to_string(), config) } + /// A protected rendition is dropped before selecting, so a held clear rendition the publisher + /// disabled is not passed over for an enabled protected one that is then removed too. + #[test] + fn protected_renditions_never_displace_a_clear_one() { + let snapshot = |enabled: bool| { + let mut catalog = Catalog::default(); + let (name, mut clear) = h264("clear"); + clear.enabled = enabled; + catalog.video.renditions.insert(name, clear); + let (name, mut protected) = h264("protected"); + protected.drm = vec!["1".to_string()]; + catalog.video.renditions.insert(name, protected); + catalog + }; + let selection = select::Broadcast::default().video(select::Video::default()); + let mut stream = Snapshots::new([snapshot(true), snapshot(false)]).select(selection); + assert_eq!(next(&mut stream).video.renditions.keys().collect::>(), ["clear"]); + assert_eq!( + next(&mut stream).video.renditions.keys().collect::>(), + ["clear"], + "held while disabled" + ); + } + + /// A broadcast whose media is all protected fails rather than exporting nothing; one with no + /// media yet just waits for it. + #[test] + fn only_protected_media_is_an_error() { + let (name, mut protected) = h264("protected"); + protected.drm = vec!["1".to_string()]; + let mut catalog = Catalog::default(); + catalog.video.renditions.insert(name, protected); + + let selection = select::Broadcast::default().video(select::Video::default()); + let mut stream = Snapshots::new([Catalog::default(), catalog]).select(selection); + assert!(next(&mut stream).video.renditions.is_empty()); + assert!(matches!( + stream.poll_next(&kio::Waiter::noop()), + Poll::Ready(Err(crate::Error::Protected)) + )); + } + #[test] fn narrows_each_snapshot() { let mut catalog = Catalog::default(); diff --git a/rs/moq-mux/src/container/fmp4/export_test.rs b/rs/moq-mux/src/container/fmp4/export_test.rs index eac7dd547ed..94e3f332bad 100644 --- a/rs/moq-mux/src/container/fmp4/export_test.rs +++ b/rs/moq-mux/src/container/fmp4/export_test.rs @@ -501,6 +501,33 @@ async fn a_protected_rendition_is_left_out() { ); } +/// A selected export of a broadcast whose media is all protected fails, rather than writing +/// nothing and ending as if it succeeded. +#[tokio::test(start_paused = true)] +async fn an_export_of_only_protected_media_fails() { + use crate::catalog::Stream as _; + + let broadcast = moq_net::broadcast::Info::new(); + let mut producer = broadcast.produce(); + let consumer = producer.consume(); + + let catalog = crate::catalog::Producer::new(&mut producer, crate::catalog::Config::default()).unwrap(); + let mut protected = crate::container::fmp4::Import::new(producer, catalog.reserve()).with_passthrough(true); + protected + .decode(include_bytes!("test_data/cenc-clearkey.mp4")) + .expect("protected import"); + + let catalog_stream = crate::catalog::Consumer::<()>::new(&consumer, crate::catalog::CatalogFormat::Hang) + .await + .expect("catalog consumer"); + let selected = catalog_stream.select(crate::select::Broadcast::default()); + let mut exporter = crate::container::fmp4::Export::new(crate::source::announced(&consumer).await, selected); + let result = kio::clock::timeout(std::time::Duration::from_secs(1), exporter.next()) + .await + .expect("exporter timed out"); + assert!(matches!(result, Err(crate::Error::Protected)), "{result:?}"); +} + /// Per-rendition export (a single non-first source track, e.g. moq-hls exporting /// the audio rendition alone) must give the init moov the SAME track id its /// re-encoded fragments carry. diff --git a/rs/moq-mux/src/error.rs b/rs/moq-mux/src/error.rs index f4f916e2e23..19c1482d91c 100644 --- a/rs/moq-mux/src/error.rs +++ b/rs/moq-mux/src/error.rs @@ -282,6 +282,11 @@ pub enum Error { #[error("rendition `{0}` changed identity; publish it under a new track name")] IdentityChanged(String), + /// Every video and audio rendition of a catalog is protected, so a selection has nothing it can + /// export: nothing here decrypts (see [`retain_clear`](crate::catalog::hang::retain_clear)). + #[error("no rendition can be exported: every one is protected")] + Protected, + /// A rendition moved to a track whose media goes back before what the export already read for it. #[error( "rendition {rendition} moved to a track that goes back in time: a group starts at {start:?}, not past {read:?}" From ff665d9d1fd463831c636dfcee631340271d9bb7 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 22:55:32 +0100 Subject: [PATCH 20/23] fix(c,ffi): hide protected renditions from the bindings The C and UniFFI media consumers listed a protected rendition under the codec it wraps, with nothing marking it protected, and their readers then handed out encrypted samples that had lost their IVs. Each catalog snapshot they see now goes through retain_clear (moq-c) or the same protected test (moq-ffi's convert_catalog), so a protected rendition is absent, as the hang draft requires of a consumer that cannot decrypt. Exposing the drm section to the bindings is left to a follow-up. Co-Authored-By: Claude Opus 5.5 --- doc/concept/hang.md | 6 ++-- rs/moq-c/MIGRATE.md | 4 +++ rs/moq-c/src/consume.rs | 5 +++- rs/moq-c/src/test.rs | 64 +++++++++++++++++++++++++++++++++++++++++ rs/moq-ffi/MIGRATE.md | 4 +++ rs/moq-ffi/src/media.rs | 28 ++++++++++++++++++ 6 files changed, 108 insertions(+), 3 deletions(-) diff --git a/doc/concept/hang.md b/doc/concept/hang.md index 42338bcb286..8114c46e42c 100644 --- a/doc/concept/hang.md +++ b/doc/concept/hang.md @@ -269,8 +269,10 @@ media, so the publisher supplies them per DRM system, with `--drm-license` and WebCodecs cannot decrypt, so `@moq/watch` treats a protected rendition as unplayable and never selects it. Playback through MSE and EME is not built yet. Nothing in the Rust tools decrypts either: `moq play`, `moq export`, the HLS -gateway, recordings, and transcoding leave a protected rendition out, as they -would a codec they cannot decode. +gateway, recordings, transcoding, and the C and UniFFI bindings leave a +protected rendition out, as they would a codec they cannot decode, and `moq +export` fails when nothing else is left. They also count a CMAF rendition whose +`init` holds an encrypted sample entry as protected when it lists no `drm`. Key rotation and a clear lead are refused on import, as is anything else the republished media could not decrypt. diff --git a/rs/moq-c/MIGRATE.md b/rs/moq-c/MIGRATE.md index b75c742e14a..b6e7e6016f4 100644 --- a/rs/moq-c/MIGRATE.md +++ b/rs/moq-c/MIGRATE.md @@ -4,6 +4,10 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Protected renditions are hidden + +A catalog snapshot leaves out every protected video and audio rendition: one listing `drm` entries, or a CMAF one whose init holds an encrypted (`encv`/`enca`) sample entry. Its samples are encrypted and nothing here decrypts them, so `moq_consume_video_config`, `moq_consume_audio_config`, and the media readers no longer reach it, rather than handing out ciphertext that has lost its IVs. The C ABI is unchanged; renditions after a hidden one move down an index. + ### Datagrams are a track of their own A raw track's datagrams travel on a separate datagram track of the same name, so the C ABI is unchanged but some results differ: diff --git a/rs/moq-c/src/consume.rs b/rs/moq-c/src/consume.rs index 649b8e988cc..64df1008ea0 100644 --- a/rs/moq-c/src/consume.rs +++ b/rs/moq-c/src/consume.rs @@ -309,7 +309,7 @@ impl Consume { // `biased` so a pending close always wins over a ready update: a hot // stream must not be able to starve the close signal, and we must not // deliver another update once close has been requested. - let update = tokio::select! { + let mut update = tokio::select! { biased; _ = &mut close => return Ok(()), next = catalog.next() => match next? { @@ -317,6 +317,9 @@ impl Consume { None => return Ok(()), }, }; + // A protected rendition's samples are encrypted, and nothing here decrypts them or + // exposes the `drm` section, so the bindings treat it as one they cannot decode. + moq_mux::catalog::hang::retain_clear(&mut update); // Unfortunately we need to store the codec information on the heap. let audio_codec = update diff --git a/rs/moq-c/src/test.rs b/rs/moq-c/src/test.rs index 788cd996a4d..952c8c9d0c2 100644 --- a/rs/moq-c/src/test.rs +++ b/rs/moq-c/src/test.rs @@ -853,6 +853,70 @@ fn publish_video_config_replaces_its_own_rendition() { assert_eq!(moq_origin_close(origin), 0); } +/// The `ftyp` and `moov` of an encrypted (ClearKey `cenc`) fMP4 file, ahead of its first fragment. +fn encrypted_init() -> &'static [u8] { + const FILE: &[u8] = include_bytes!("../../moq-mux/src/container/fmp4/test_data/cenc-clearkey.mp4"); + let mut end = 0; + while &FILE[end + 4..end + 8] != b"moof" { + end += u32::from_be_bytes(FILE[end..end + 4].try_into().unwrap()) as usize; + } + &FILE[..end] +} + +/// A protected rendition (here a CMAF one whose init is encrypted) is absent from the catalog the +/// bindings see: they cannot decrypt it, so they treat it as one they cannot decode. +#[test] +fn consume_catalog_hides_protected_renditions() { + let origin = id(moq_origin_create()); + let path = b"catalog-protected"; + let broadcast = publish_broadcast(origin, path); + + let video = |name: &'static str, codec: &'static str, container: moq_container| moq_video_config { + preference: 0, + name: name.as_ptr().cast(), + name_len: name.len(), + label: std::ptr::null(), + label_len: 0, + codec: codec.as_ptr().cast(), + codec_len: codec.len(), + description: std::ptr::null(), + description_len: 0, + coded_width: 640, + coded_height: 360, + container, + }; + let init = encrypted_init(); + let protected = video( + "protected", + "avc1.64001f", + moq_container { + kind: moq_container_kind::MOQ_CONTAINER_KIND_CMAF as u32, + init: init.as_ptr(), + init_len: init.len(), + }, + ); + assert_eq!(unsafe { moq_publish_video_config(broadcast, &protected) }, 0); + let clear = video("clear", "vp8", moq_container::default()); + assert_eq!(unsafe { moq_publish_video_config(broadcast, &clear) }, 0); + + let consume = request_broadcast(origin, path); + let catalog_cb = Callback::new(); + let catalog_task = id(unsafe { moq_consume_catalog(consume, Some(channel_callback), catalog_cb.ptr) }); + let catalog = id(catalog_cb.recv()); + + let mut config = video("", "", moq_container::default()); + assert_eq!(unsafe { moq_consume_video_config(catalog, 0, &mut config) }, 0); + assert_eq!(borrowed_string(config.name, config.name_len).as_deref(), Some("clear")); + assert!(unsafe { moq_consume_video_config(catalog, 1, &mut config) } < 0); + + assert_eq!(moq_consume_catalog_free(catalog), 0); + assert_eq!(moq_consume_catalog_cancel(catalog_task), 0); + assert_eq!(catalog_cb.recv_terminal(), 0); + assert_eq!(moq_consume_close(consume), 0); + assert_eq!(moq_publish_close(broadcast), 0); + assert_eq!(moq_origin_close(origin), 0); +} + /// Manual catalog metadata cannot redefine the decoder identity of an existing raw track. #[test] fn manual_video_identity_change_is_refused() { diff --git a/rs/moq-ffi/MIGRATE.md b/rs/moq-ffi/MIGRATE.md index 5260084c9d4..b7cb7f38728 100644 --- a/rs/moq-ffi/MIGRATE.md +++ b/rs/moq-ffi/MIGRATE.md @@ -5,6 +5,10 @@ These are the UniFFI names; each language wrapper has its own `MIGRATE.md` in it ## Unreleased +### Protected renditions are hidden + +`MoqMediaCatalogConsumer::next` leaves out every protected video and audio rendition: one listing `drm` entries, or a CMAF one whose init holds an encrypted (`encv`/`enca`) sample entry. Its samples are encrypted and nothing here decrypts them, so a binding no longer subscribes to it and reads ciphertext that has lost its IVs. The API is unchanged. + ### Viewer targets are bounded ([#7090](https://github.com/moq-dev/moq/pull/7090)) Viewer ceilings and PROBE target overrides are refused with the new `MoqError::OutOfRange` once they would sum above 2^53 - 1 bps, the most a PROBE target carries; nothing changes on a refusal. `MoqViewers::watch` and `set_target` and `MoqViewer::update` return a `Result`. Handle the new variant wherever you match the error exhaustively. Regenerate bindings and rebuild the matching native library together. diff --git a/rs/moq-ffi/src/media.rs b/rs/moq-ffi/src/media.rs index 5f74160b019..c7e4bfce3fe 100644 --- a/rs/moq-ffi/src/media.rs +++ b/rs/moq-ffi/src/media.rs @@ -596,11 +596,17 @@ impl MoqVideoInit { } } +/// Convert a catalog snapshot for the bindings, leaving out the protected renditions. +/// +/// A protected rendition (see [`moq_mux::catalog::hang::protected`]) carries encrypted samples, and +/// nothing here decrypts them or exposes the `drm` section, so the bindings treat it as one they +/// cannot decode. pub(crate) fn convert_catalog(catalog: &moq_mux::catalog::hang::Catalog) -> MoqCatalog { let video = catalog .video .renditions .iter() + .filter(|(_, config)| !moq_mux::catalog::hang::protected(&config.drm, &config.container)) .filter_map(|(name, config)| { Some(( name.clone(), @@ -633,6 +639,7 @@ pub(crate) fn convert_catalog(catalog: &moq_mux::catalog::hang::Catalog>(), ["clear"]); + assert!(converted.audio.is_empty()); + } + #[test] fn catalog_exposes_rendition_labels() { let mut catalog = moq_mux::catalog::hang::Catalog::default(); From 279ef2d2c7f61ceb5c5a56ad55e7999fd88763c0 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 22:55:33 +0100 Subject: [PATCH 21/23] fix(cli): take urn:uuid DRM system IDs in --drm-license and --drm-certificate SYSTEM was split at its first colon to find the TYPE, so urn:uuid:edef8ba9-...=URL parsed as a system named urn and was refused. A urn:uuid: prefix is now part of SYSTEM, with or without :TYPE after it. The validated servers are taken with expect rather than silently defaulting to none. Co-Authored-By: Claude Opus 5.5 --- doc/bin/cli.md | 9 ++++++--- rs/moq-cli/src/args.rs | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/doc/bin/cli.md b/doc/bin/cli.md index 001e03be588..14ba7b47541 100644 --- a/doc/bin/cli.md +++ b/doc/bin/cli.md @@ -163,9 +163,12 @@ such as Shaka Packager's output, unchanged, and signals it in the catalog's license server with `--drm-license SYSTEM=URL`, and FairPlay's certificate with `--drm-certificate SYSTEM=URL`, once per system; SYSTEM is `widevine`, `playready`, `fairplay`, `clearkey`, or a system ID, and one the media carries -no `pssh` for is refused. `SYSTEM:TYPE=URL` also gives the server's type, such -as `widevine:EME-1.0=…` or `fairplay:application/pkcs7-mime=…`. Encrypted media without `--cmaf`, key rotation, and a clear lead are -refused too. +no `pssh` for is refused. A system ID may also be written as a +`urn:uuid:` URN. `SYSTEM:TYPE=URL` also gives the server's type, such as +`widevine:EME-1.0=…` or `fairplay:application/pkcs7-mime=…`. Encrypted media +without `--cmaf`, key rotation, and a clear lead are refused too. An export +leaves the protected renditions out, since nothing in `moq` decrypts them, and +fails when every rendition is protected. ```bash moq --connect https://relay.example.com/anon --broadcast movie.hang \ diff --git a/rs/moq-cli/src/args.rs b/rs/moq-cli/src/args.rs index a2c7989b8f2..08f7fc5ac41 100644 --- a/rs/moq-cli/src/args.rs +++ b/rs/moq-cli/src/args.rs @@ -887,13 +887,15 @@ pub enum ImportSource { impl ImportSource { /// The stdin container format, when this source is one of the container formats. + /// + /// Call it only on an [`Invocation::validate`]d invocation, which refuses the flags it cannot + /// turn into a format. pub fn stdin_format(&self) -> Option { Some(match self { Self::Avc3 => PublishFormat::Avc3, Self::Fmp4(args) => PublishFormat::Fmp4 { passthrough: args.passthrough, - // `Invocation::validate` refuses a system named twice. - drm: args.drm().unwrap_or_default(), + drm: (args.drm()).expect("Invocation::validate refuses a system named twice"), }, Self::Ts(args) if args.passthrough => PublishFormat::TsPassthrough { pcr_pid: args.pcr_pid.map(|pid| pid.0), @@ -1013,13 +1015,20 @@ impl std::str::FromStr for DrmServer { let (system, url) = arg .split_once('=') .ok_or_else(|| format!("expected SYSTEM[:TYPE]=URL, got `{arg}`"))?; - // No system ID or name holds a colon, so the first one starts the type. - let (system, kind) = match system.split_once(':') { + // A system ID may be a `urn:uuid:` URN, as DASH writes them. Past that prefix no system ID + // or name holds a colon, so the first one starts the type. + const URN: &str = "urn:uuid:"; + let (urn, rest) = match system.get(..URN.len()) { + Some(prefix) if prefix.eq_ignore_ascii_case(URN) => (true, &system[URN.len()..]), + _ => (false, system), + }; + let (system, kind) = match rest.split_once(':') { Some((_, "")) => return Err(format!("empty TYPE in `{arg}`")), Some((system, kind)) => (system, Some(kind.to_string())), - None => (system, None), + None => (rest, None), }; - let system = hang::catalog::drm::system::named(system) + let named = (!urn).then(|| hang::catalog::drm::system::named(system)).flatten(); + let system = named .or_else(|| hang::catalog::drm::Uuid::try_parse(system).ok()) .ok_or_else(|| { format!( @@ -2094,15 +2103,26 @@ mod tests { "FairPlay:application/pkcs7-mime=https://fps.example.com/cert", "--drm-license", "fairplay=https://fps.example.com/license", + "--drm-license", + "URN:UUID:9a04f079-9840-4286-ab92-e65be0885f95:EME-1.0=https://pr.example.com/", + "--drm-certificate", + "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed=https://wv.example.com/cert", ]) else { panic!("an fmp4 import"); }; - assert_eq!(drm.len(), 3); + assert_eq!(drm.len(), 4); + let playready = drm[&drm::system::PLAYREADY].license.as_ref().unwrap(); + assert_eq!(playready.kind.as_deref(), Some("EME-1.0")); + assert_eq!(playready.url.as_str(), "https://pr.example.com/"); + assert_eq!( + drm[&drm::system::WIDEVINE].certificate.as_ref().unwrap().url.as_str(), + "https://wv.example.com/cert" + ); + assert!(drm[&drm::system::WIDEVINE].certificate.as_ref().unwrap().kind.is_none()); assert_eq!( drm[&drm::system::CLEARKEY].license.as_ref().unwrap().url.as_str(), "https://license.example.com/clearkey" ); - assert!(drm[&drm::system::WIDEVINE].certificate.is_none()); assert!(drm[&drm::system::FAIRPLAY].license.is_some()); let certificate = drm[&drm::system::FAIRPLAY].certificate.as_ref().unwrap(); assert_eq!(certificate.kind.as_deref(), Some("application/pkcs7-mime")); @@ -2128,6 +2148,10 @@ mod tests { "needs --cmaf" ); assert!(format(&["--cmaf", "--drm-license", "primetime=https://a.example/"]).is_none()); + assert!( + format(&["--cmaf", "--drm-license", "urn:uuid:clearkey=https://a.example/"]).is_none(), + "a URN holds a system ID, not a name" + ); assert!(format(&["--cmaf", "--drm-license", "clearkey"]).is_none()); assert!(format(&["--cmaf", "--drm-license", "clearkey=not a url"]).is_none()); } From 6683c497e7e5dbd7f66228a86af8a83450fde457 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Wed, 4 Nov 2026 23:08:28 +0100 Subject: [PATCH 22/23] build: take mp4-atom#268 from its pushed commit instead of a local path Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 1 + Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 3b2b3b7b5cb..3e917296b03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5382,6 +5382,7 @@ dependencies = [ [[package]] name = "mp4-atom" version = "0.17.0" +source = "git+https://github.com/michaelstuurman/mp4-atom?rev=7ff54efdf298288c7fe55bd2744b21ebee431304#7ff54efdf298288c7fe55bd2744b21ebee431304" dependencies = [ "bytes", "derive_more 2.1.1", diff --git a/Cargo.toml b/Cargo.toml index b509097d357..359e7c23bdd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -251,7 +251,7 @@ zeroize = { version = "1", features = ["derive"] } # version (#3551). kio = { path = "rs/kio" } # Common Encryption boxes (kixelated/mp4-atom#268), until a release ships them. -mp4-atom = { path = "/Users/michael/Projects/mp4-atom" } +mp4-atom = { git = "https://github.com/michaelstuurman/mp4-atom", rev = "7ff54efdf298288c7fe55bd2744b21ebee431304" } [profile.dev] # Full DWARF is what makes a debug build enormous: the debug `libmoq_ffi.a` From de608308934aaab37586522b364936592bd608b6 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Thu, 5 Nov 2026 09:57:30 +0100 Subject: [PATCH 23/23] build: take mp4-atom#268 on 0.17.1 and restore the 0.17.1 requirement Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 4 ++-- Cargo.toml | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 379f1436bd8..b0f9e1ea84f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5346,8 +5346,8 @@ dependencies = [ [[package]] name = "mp4-atom" -version = "0.17.0" -source = "git+https://github.com/michaelstuurman/mp4-atom?rev=7ff54efdf298288c7fe55bd2744b21ebee431304#7ff54efdf298288c7fe55bd2744b21ebee431304" +version = "0.17.1" +source = "git+https://github.com/michaelstuurman/mp4-atom?rev=10490e39383294ea11e3d5827517ef1eb9d950a8#10490e39383294ea11e3d5827517ef1eb9d950a8" dependencies = [ "bytes", "derive_more 2.1.1", diff --git a/Cargo.toml b/Cargo.toml index f470f3dcaba..fbbed15c3a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -176,9 +176,7 @@ moq-vaapi = "0.1.1" # that argument, so moq-ffi and moq-c opt NVIDIA and VAAPI back in (OpenH264 # through their own `openh264` feature, which release builds enable). moq-video = { version = "0.1.10", path = "rs/moq-video", default-features = false } -# 0.17.0, not 0.17.1: the [patch.crates-io] fork below carries every 0.17.1 fix -# but still says 0.17.0. Restore 0.17.1 (or the release with #268) with it. -mp4-atom = "0.17.0" +mp4-atom = "0.17.1" nix = { version = "0.31.3", features = ["net", "socket", "uio"] } num_enum = "0.7" objc2 = "0.6.4" @@ -253,7 +251,7 @@ zeroize = { version = "1", features = ["derive"] } # version (#3551). kio = { path = "rs/kio" } # Common Encryption boxes (kixelated/mp4-atom#268), until a release ships them. -mp4-atom = { git = "https://github.com/michaelstuurman/mp4-atom", rev = "7ff54efdf298288c7fe55bd2744b21ebee431304" } +mp4-atom = { git = "https://github.com/michaelstuurman/mp4-atom", rev = "10490e39383294ea11e3d5827517ef1eb9d950a8" } [profile.dev] # Full DWARF is what makes a debug build enormous: the debug `libmoq_ffi.a`