extensions/loc-carriage.md maps an envelope whose payload is one WebCodecs chunk (an Opus packet, an AVC or HEVC access unit in Annex B, an ADTS frame) onto one object of a track of packaging loc (draft-ietf-moq-loc-04): the payload as the LOC Payload, the manifest as the Immutable Property WAI_MANIFEST (0x3A61), the receipt commitment as WAI_RECEIPT. A reader rebuilds the envelope byte for byte and checks the receipt against it, refusing with the extension's codes. joule-moq's loc module writes and reads; its example writes the corpus and tests/loc_vectors.rs checks it; loc_verify.py is the second implementation. WAI_MANIFEST is registered as a wire identifier; moq-streaming-format §6 points to the carriage. Co-Authored-By: Claude Opus 5.5 <[email protected]>
37 lines
1.8 KiB
Rust
37 lines
1.8 KiB
Rust
//! LOC carriage (WAI `extensions/loc-carriage.md`): the committed corpus
|
|
//! `wai/live-conformance/loc/vectors.json` regenerates byte for byte from the H.265 stream it
|
|
//! takes its access units from, every object and refusal in it holds, and the extension's §6
|
|
//! lists exactly the codes [`LocRefusal::all`] gives. The corpus lives beside this crate in
|
|
//! the monorepo; if it cannot be read the test fails, it never passes on nothing.
|
|
|
|
use joule_moq::loc::{corpus, LocRefusal};
|
|
|
|
const WAI: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../../wai/");
|
|
|
|
fn committed() -> String {
|
|
std::fs::read_to_string(format!("{WAI}live-conformance/loc/vectors.json")).expect("the LOC corpus")
|
|
}
|
|
|
|
#[test]
|
|
fn the_corpus_regenerates() {
|
|
let hevc = std::fs::read(format!("{WAI}format-probe-conformance/ext/hevc/base_64x64.265")).expect("the H.265 vector");
|
|
assert_eq!(corpus::generate(&hevc).expect("generates"), committed(), "run `cargo run -p joule-moq --example loc_vectors -- gen`");
|
|
}
|
|
|
|
#[test]
|
|
fn every_vector_holds() {
|
|
let doc: serde_json::Value = serde_json::from_str(&committed()).expect("JSON");
|
|
assert!(doc["objects"].as_array().is_some_and(|a| a.len() >= 6));
|
|
let fails = corpus::verify(&doc);
|
|
assert!(fails.is_empty(), "{}", fails.join("\n"));
|
|
}
|
|
|
|
#[test]
|
|
fn the_extension_lists_the_codes() {
|
|
let text = std::fs::read_to_string(format!("{WAI}extensions/loc-carriage.md")).expect("the extension");
|
|
let at = text.find("\n## 6. Refusals").expect("a §6");
|
|
let end = text[at + 1..].find("\n## ").map_or(text.len(), |e| at + 1 + e);
|
|
let listed: Vec<&str> = text[at..end].lines().filter(|l| l.starts_with("| `")).filter_map(|l| l.split('`').nth(1)).collect();
|
|
let want: Vec<&str> = LocRefusal::all().iter().map(|r| r.code()).collect();
|
|
assert_eq!(listed, want);
|
|
}
|