open-standards/joule-code/joule-code-rs/crates/joule-moq/examples/loc_vectors.rs
Transaction Science cbf58297e2 LOC carriage: WAI envelopes on LOC objects, a writer and reader in joule-moq, the corpus live-conformance/loc
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]>
2026-10-22 10:43:34 -04:00

42 lines
1.8 KiB
Rust

//! The LOC carriage corpus (WAI `live-conformance/loc/`, loc-carriage §8):
//!
//! cargo run -p joule-moq --example loc_vectors -- gen writes vectors.json (never in CI)
//! cargo run -p joule-moq --example loc_vectors -- verify checks it
//!
//! Its HEVC objects carry access units of WAI's `format-probe-conformance/ext/hevc/base_64x64.265`.
use joule_moq::loc::corpus;
const WAI: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../../wai/");
fn main() -> std::process::ExitCode {
let hevc = std::fs::read(format!("{WAI}format-probe-conformance/ext/hevc/base_64x64.265")).expect("the H.265 vector");
let path = format!("{WAI}live-conformance/loc/vectors.json");
match std::env::args().nth(1).as_deref() {
Some("gen") => match corpus::generate(&hevc) {
Ok(s) => {
std::fs::create_dir_all(format!("{WAI}live-conformance/loc")).expect("the corpus directory");
std::fs::write(&path, s).expect("write vectors.json");
println!("wrote {path}");
std::process::ExitCode::SUCCESS
}
Err(e) => {
eprintln!("{e}");
std::process::ExitCode::FAILURE
}
},
Some("verify") => {
let doc: serde_json::Value = serde_json::from_str(&std::fs::read_to_string(&path).expect("vectors.json")).expect("JSON");
let fails = corpus::verify(&doc);
for f in &fails {
eprintln!("FAIL {f}");
}
println!("{} failures", fails.len());
if fails.is_empty() { std::process::ExitCode::SUCCESS } else { std::process::ExitCode::FAILURE }
}
_ => {
eprintln!("usage: loc_vectors gen | verify");
std::process::ExitCode::from(2)
}
}
}