Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ unknown-registry = "deny"
unknown-git = "deny"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
# uniffi-bindgen's generator-only UniFFI fork. Unpublished, so it never ships in a crate.
allow-git = ["https://github.com/kixelated/uniffi-rs"]
# mp4-atom's counted trun samples and dOps mapping (kixelated/mp4-atom#254, #246), until 0.17.0 is published.
allow-git = ["https://github.com/kixelated/uniffi-rs", "https://github.com/kixelated/mp4-atom"]
1 change: 0 additions & 1 deletion quest/m1/cut-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ leaving JS-only redesigns of `js/net` to [rs2ts](/quest/m2/rs2ts/README.md).

## Required

- [Counted field-less `trun` entries](/quest/m1/cut-audit/fmp4-sample-resolver.md) - a moof of field-less runs cannot materialize millions of sample entries
- [A reserved group survives a route returning](/quest/m1/cut-audit/reserved-route-return.md) - a route flip A to B to A no longer panics a peeked reader
- [JS tracks end clean only on a deliberate finish](/quest/m1/cut-audit/js-close-cause.md) - local close, violations, and unanswered requests end with errors
- [A description-less AAC rendition means one thing](/quest/m1/cut-audit/aac-description-less.md) - every player and exporter agrees on the frame format
Expand Down
43 changes: 0 additions & 43 deletions quest/m1/cut-audit/fmp4-sample-resolver.md

This file was deleted.

13 changes: 8 additions & 5 deletions quest/m2/cmaf-opus-surround.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ family 0), the shape drafted in kixelated/mp4-atom#246. That is a breaking
Decided 2026-10-17: the `mp4-atom` change is not worth landing on its own.
Alone it only swaps `mp4-atom`'s generic decode error for
`UnsupportedMappingFamily`; the payoff is surround Opus. So the former
`mp4-atom-dops-mapping` quest (draft moq-dev/moq#5819) folded in here, and
the breaking `mp4-atom` release lands only when this quest does.

Order: land kixelated/mp4-atom#246, release `mp4-atom` 0.17, then one moq PR
that bumps `rs/moq-mux` to `mp4-atom = "0.17"` and does the import and export.
`mp4-atom-dops-mapping` quest (draft moq-dev/moq#5819) folded in here.

Decided 2026-10-28 (maintainer): kixelated/mp4-atom#246 ships in 0.17.0
beside kixelated/mp4-atom#254, so downstream takes one breaking bump.
moq-dev/moq#7043 takes 0.17 for the
[counted trun](/quest/m1/cut-audit/fmp4-sample-resolver.md) and keeps
refusing a nonzero family explicitly, since `mp4-atom` no longer does.
This quest then only does the import and export.
A git patch to the branch cannot stand in for the release, since `cargo deny`
refuses unknown git sources.

Expand Down
6 changes: 3 additions & 3 deletions quest/m2/mux-vr-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ landed the fields.
stays out of scope. `webm-iterable` already names the Matroska elements.
- Ambisonic fMP4 needs the `dOps` mapping table, so it moved to
[fMP4 ambisonic layout](/quest/m2/mux-vr-ambisonic-fmp4.md) (2026-10-22,
maintainer); Matroska and raw Opus land here. Before taking 0.17.0,
settle with [CMAF surround Opus](/quest/m2/cmaf-opus-surround.md) whether
the release also carries kixelated/mp4-atom#246.
maintainer); Matroska and raw Opus land here. 0.17.0 also carries
kixelated/mp4-atom#246 (2026-10-28, maintainer), which
[CMAF surround Opus](/quest/m2/cmaf-opus-surround.md) consumes.
- Exporters writing the fields back are out of scope.

Tests: a fixture per source (MP4 360, a 180-degree equirectangular MP4 with
Expand Down
1 change: 1 addition & 0 deletions rs/moq-mux/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- [**breaking**] Declare per-track archive durations from GOP hints or the first completed record.
- [**breaking**] Update the re-exported `mp4_atom` to 0.17, whose `Trun.entries` is now `Trun.samples`: a run without per-sample fields decodes as a count, so a moof of field-less runs no longer materializes an entry per sample before import refuses it. Read entries with `trun.samples.iter()` and build them with `samples: entries.into()`. `Dops` gains `channel_mapping: Option<OpusChannelMapping>` (`None` for family 0); the fMP4 importer still refuses a nonzero family.

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion rs/moq-mux/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ moq-json = { workspace = true }
moq-loc = { workspace = true }
moq-msf = { workspace = true }
moq-net = { workspace = true }
mp4-atom = { version = "0.16.2", features = ["tokio", "bytes", "serde"] }
mp4-atom = { version = "0.16.2", git = "https://github.com/kixelated/mp4-atom", rev = "3e150f9683ac652ac26cd79ccb34322dfd2d1a64", features = ["tokio", "bytes", "serde"] }
mpeg2ts = "0.6.0"
num_enum = { workspace = true }
roxmltree = "0.21.1"
Expand Down
5 changes: 3 additions & 2 deletions rs/moq-mux/benches/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,13 @@ fn interleaved(init: &[u8], tracks: usize, runs: usize, fragments: usize, payloa
trun: (0..runs)
.map(|run| mp4_atom::Trun {
data_offset: Some(0),
entries: vec![mp4_atom::TrunEntry {
samples: vec![mp4_atom::TrunEntry {
duration: Some(trak.mdia.mdhd.timescale / 50),
size: Some(payload.len() as u32),
flags: Some(if run == 0 { 0 } else { 0x0001_0000 }),
cts: None,
}],
}]
.into(),
})
.collect(),
..Default::default()
Expand Down
1 change: 1 addition & 0 deletions rs/moq-mux/src/container/fmp4/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ mod tests {
pre_skip: 312,
input_sample_rate: 48_000,
output_gain: 0,
channel_mapping: None,
},
btrt: None,
}
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-mux/src/container/fmp4/export_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ fn traf_samples(fragment: &Bytes) -> Vec<(u32, usize)> {
continue;
};
for traf in moof.traf {
let samples = traf.trun.iter().map(|trun| trun.entries.len()).sum();
let samples = traf.trun.iter().map(|trun| trun.samples.len()).sum();
trafs.push((traf.tfhd.track_id, samples));
}
}
Expand Down
36 changes: 24 additions & 12 deletions rs/moq-mux/src/container/fmp4/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,9 +833,14 @@ impl<E: crate::catalog::hang::CatalogExt> Import<E> {
}
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. The head built here
// is family 0, so refuse a mapping table rather than drop it.
let dops = &opus.dops;
if let Some(mapping) = &dops.channel_mapping {
return Err(
Error::Opus(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);
Expand Down Expand Up @@ -901,7 +906,10 @@ impl<E: crate::catalog::hang::CatalogExt> Import<E> {
/// A segment is the unit a group carries, which is what lets audio (whose samples are all
/// independently decodable, so it has no boundary of its own) follow the same segmentation as
/// video instead of opening a group per fragment.
fn starts_segment(&self, moof: &Moof, has_video: bool) -> bool {
///
/// `mdat_len` bounds the scan: each sample takes at least one byte of the mdat, and the resolver
/// refuses any past it, so a forged field-less run of billions of samples isn't walked here.
fn starts_segment(&self, moof: &Moof, has_video: bool, mdat_len: usize) -> bool {
if self.pending_cut {
return true;
}
Expand All @@ -928,8 +936,9 @@ impl<E: crate::catalog::hang::CatalogExt> Import<E> {
&& traf
.trun
.iter()
.flat_map(|trun| trun.entries.iter())
.any(|entry| track.defaults.resolve(&traf.tfhd, entry).is_sync())
.flat_map(|trun| trun.samples.iter())
.take(mdat_len)
.any(|entry| track.defaults.resolve(&traf.tfhd, &entry).is_sync())
})
}

Expand All @@ -952,7 +961,7 @@ impl<E: crate::catalog::hang::CatalogExt> Import<E> {
// Resolve the segment boundary BEFORE the per-track loop. A moof can carry both an audio
// and a video traf, and whichever comes first must see the same answer, or the other rolls
// a fragment late and the two tracks stop agreeing on where segments fall.
if self.starts_segment(&moof, has_video) {
if self.starts_segment(&moof, has_video, payload.len()) {
self.segment += 1;
// A boundary the source declared is also an HLS segment boundary; one merely inferred
// from a keyframe is not, since the default pacing already sees that group open.
Expand Down Expand Up @@ -1172,9 +1181,12 @@ fn fragment(
for trun_mut in &mut traf_mut.trun {
// Reserve the data_offset field; the real value is filled in below.
trun_mut.data_offset = Some(0);
for entry in &mut trun_mut.entries {
if entry.duration == Some(0) {
entry.duration = None;
// Only explicit entries carry a duration; an inherited run takes the tfhd's, cleared above.
if let mp4_atom::TrunSamples::Explicit(entries) = &mut trun_mut.samples {
for entry in entries {
if entry.duration == Some(0) {
entry.duration = None;
}
}
}
}
Expand All @@ -1194,9 +1206,9 @@ fn fragment(

// Advance past this trun's sample data
let trun_data_size: u64 = trun_mut
.entries
.samples
.iter()
.map(|entry| u64::from(defaults.resolve(&traf_mut.tfhd, entry).size))
.map(|entry| u64::from(defaults.resolve(&traf_mut.tfhd, &entry).size))
.sum();
cumulative_offset += trun_data_size;
}
Expand Down Expand Up @@ -1255,7 +1267,7 @@ fn kept(traf: &mp4_atom::Traf, run: &Run) -> Result<mp4_atom::Traf> {
}),
trun: vec![mp4_atom::Trun {
data_offset: None,
entries,
samples: entries.into(),
}],
..Default::default()
})
Expand Down
Loading
Loading