diff --git a/Cargo.lock b/Cargo.lock index cd0f4afc72..be516cd9cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5146,8 +5146,7 @@ dependencies = [ [[package]] name = "mp4-atom" version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6f6638ef4f165c7eb423d7ab9666fff423c8ab53f0dc67ec523aa49530729a7" +source = "git+https://github.com/kixelated/mp4-atom?branch=dops-channel-mapping#6cb4683d98372b0bb8c209d32bdb11332b33c7fd" dependencies = [ "bytes", "derive_more 2.1.1", diff --git a/Cargo.toml b/Cargo.toml index 5ede5997b9..d2cc64572c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -254,6 +254,8 @@ zeroize = { version = "1", features = ["derive"] } # this, the lock carries a second kio whose pin drifts behind the member, and the # next publish that reaches both fails to resolve a single version (#3551). kio = { path = "rs/kio" } +# TEMP: carries the dOps channel mapping until kixelated/mp4-atom#246 releases. +mp4-atom = { git = "https://github.com/kixelated/mp4-atom", branch = "dops-channel-mapping" } [profile.dev] # Full DWARF is what makes a debug build enormous: the debug `libmoq_ffi.a` diff --git a/quest/m2/README.md b/quest/m2/README.md index 813b339b87..802d378e44 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -54,7 +54,6 @@ ranked just below deterministic TS legs, which it requires. - [MoQ in obs-studio](/quest/m2/obs-studio/README.md) - a native MoQ output and service merged into obs-studio, once its maintainers agree; the plugin carries it until then - [AudioToolbox decode](/quest/m2/audio-decode-audiotoolbox.md) - macOS and iOS decode HE-AAC, multichannel AAC, and what else the framework offers - [AudioToolbox encode](/quest/m2/audio-encode-audiotoolbox.md) - macOS and iOS encode AAC-LC -- [mp4-atom dOps mapping](/quest/m2/mp4-atom-dops-mapping.md) - a released mp4-atom reads and writes any `dOps` channel mapping family and table - [CMAF surround Opus](/quest/m2/cmaf-opus-surround.md) - fMP4 import and export carry an Opus channel mapping table - [GPU CI](/quest/m2/gpu-ci.md) - NVIDIA tests run nightly on real hardware, and `just rs nvidia` runs them locally instead of skipping - [Simulcast rung disable](/quest/m2/simulcast-rung-disable.md) - JS, Rust/FFI, and OBS publishers stop encoding the top renditions their grant cannot fund, advertise `enabled: false`, and re-enable with hysteresis diff --git a/quest/m2/cmaf-opus-surround.md b/quest/m2/cmaf-opus-surround.md index 233e7c8f02..352f203951 100644 --- a/quest/m2/cmaf-opus-surround.md +++ b/quest/m2/cmaf-opus-surround.md @@ -9,13 +9,9 @@ exports to a `dOps` that keeps the table. Today both directions refuse it. ## Plan Build the head from the `dOps` family and table with `opus::Mapping` on import, -and write the table from the parsed head on export in place of the -`UnsupportedMappingFamily` refusal in `synthesize_audio_trak`. Keep refusing -families the head cannot describe. +and write the table from the parsed head on export, in place of the +`UnsupportedMappingFamily` refusals in the fMP4 importer and +`synthesize_audio_trak`. Keep refusing families the head cannot describe. Regression: a family 1 5.1 `dOps` round-trips through import and export with its table intact. - -## Required - -- [mp4-atom dOps mapping](/quest/m2/mp4-atom-dops-mapping.md) - `Dops` carries the mapping family and table diff --git a/quest/m2/mp4-atom-dops-mapping.md b/quest/m2/mp4-atom-dops-mapping.md deleted file mode 100644 index 3d1f4d818d..0000000000 --- a/quest/m2/mp4-atom-dops-mapping.md +++ /dev/null @@ -1,15 +0,0 @@ -# [S] mp4-atom dOps channel mapping - -## Goal - -A released `mp4-atom` decodes and encodes a `dOps` box with any channel mapping -family, exposing the family and its table (stream count, coupled count, and the -per-channel mapping) instead of refusing a nonzero family. This repository -bumps to that release. - -## Plan - -The work lands in kixelated/mp4-atom. Validate the table against the output -channel count on decode rather than trusting it, and keep family 0 encoding -byte-identical. The bump here is a separate, small step once the release -ships. diff --git a/rs/moq-mux/src/container/fmp4/import.rs b/rs/moq-mux/src/container/fmp4/import.rs index 6f63d9383e..e8641935ba 100644 --- a/rs/moq-mux/src/container/fmp4/import.rs +++ b/rs/moq-mux/src/container/fmp4/import.rs @@ -590,9 +590,12 @@ impl Import { } mp4_atom::Codec::Opus(opus) => { // dOps carries the OpusHead fields in ISOBMFF byte order; republish them as the - // OpusHead description so decoders apply its pre-skip and gain. mp4-atom already - // refuses a nonzero channel mapping family, so the table is never dropped here. + // OpusHead description so decoders apply its pre-skip and gain. A mapping table + // is refused rather than dropped, since the head built here is family 0. let dops = &opus.dops; + if let Some(mapping) = &dops.channel_mapping { + return Err(crate::codec::opus::Error::UnsupportedMappingFamily(mapping.family).into()); + } let mut head = crate::codec::opus::Config::new(dops.input_sample_rate, dops.output_channel_count as u32) .with_pre_skip(dops.pre_skip); diff --git a/rs/moq-mux/src/container/fmp4/import_test.rs b/rs/moq-mux/src/container/fmp4/import_test.rs index 6abecc99a9..36f90f9ef6 100644 --- a/rs/moq-mux/src/container/fmp4/import_test.rs +++ b/rs/moq-mux/src/container/fmp4/import_test.rs @@ -688,19 +688,23 @@ fn opus_init(entry_rate: u16) -> (mp4_atom::Dops, Vec) { pre_skip: 312, input_sample_rate: 44_100, output_gain: -1536, + channel_mapping: None, }; + (dops.clone(), opus_init_with(entry_rate, dops)) +} + +fn opus_init_with(entry_rate: u16, dops: mp4_atom::Dops) -> Vec { let opus = mp4_atom::Opus { audio: mp4_atom::Audio { data_reference_index: 1, - channel_count: 2, + channel_count: dops.output_channel_count as u16, sample_size: 16, sample_rate: mp4_atom::FixedPoint::from(entry_rate), }, - dops: dops.clone(), + dops, btrt: None, }; - let data = audio_init(super::build_audio_trak(1, 48_000, mp4_atom::Codec::from(opus))); - (dops, data) + audio_init(super::build_audio_trak(1, 48_000, mp4_atom::Codec::from(opus))) } /// dOps becomes the OpusHead description, and a track re-exported from that description @@ -743,17 +747,33 @@ fn opus_catalog_uses_the_decode_rate() { /// A dOps with a channel mapping table is refused rather than imported without it. #[test] fn opus_dops_mapping_family_is_refused() { - let (_, mut data) = opus_init(48_000); - - // The mapping family byte follows version, channels, pre-skip, rate, and gain. - let at = data.windows(4).position(|w| w == b"dOps").unwrap() + 4 + 10; - assert_eq!(data[at], 0); - data[at] = 1; + let data = opus_init_with( + 48_000, + mp4_atom::Dops { + output_channel_count: 2, + pre_skip: 312, + input_sample_rate: 48_000, + output_gain: 0, + channel_mapping: Some(mp4_atom::OpusChannelMapping { + family: 1, + stream_count: 1, + coupled_count: 1, + channel_mapping: vec![0, 1], + }), + }, + ); 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 = crate::container::fmp4::Import::new(broadcast, catalog.reserve()); - assert!(fmp4.decode(&bytes::BytesMut::from(data.as_slice())).is_err()); + let err = fmp4.decode(&bytes::BytesMut::from(data.as_slice())).unwrap_err(); + assert!( + matches!( + err, + crate::Error::Opus(crate::codec::opus::Error::UnsupportedMappingFamily(1)) + ), + "{err:?}" + ); assert!(catalog.snapshot().audio.renditions.is_empty()); } diff --git a/rs/moq-mux/src/container/fmp4/mod.rs b/rs/moq-mux/src/container/fmp4/mod.rs index e28e27ced9..150287faee 100644 --- a/rs/moq-mux/src/container/fmp4/mod.rs +++ b/rs/moq-mux/src/container/fmp4/mod.rs @@ -884,6 +884,7 @@ pub(crate) fn synthesize_audio_trak(track_id: u32, timescale: u64, config: &Audi pre_skip: head.pre_skip, input_sample_rate: head.sample_rate, output_gain: head.output_gain, + channel_mapping: None, }, btrt: None, })