Skip to content
Merged
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
1 change: 0 additions & 1 deletion quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ removed).
- [Poll-first async](/quest/m1/poll-first/README.md) - library crates compile no coroutines by default: async wrappers are generated from `poll_*` and gated behind an `async` feature
- [Binding announcements always carry captures](/quest/m1/ffi-required-captures.md) - moq-ffi and its generated bindings make `captures` a required list, as #7266 always sets it
- [HLS export follows a resolution change](/quest/m1/hls-reinit-same-codec.md) - a decoder-identity change under the same codec string starts a new init and segment tag
- [The last AAC segment advertises its full duration](/quest/m1/hls-final-aac-segment.md) - a TS import's final audio segment's EXTINF matches what decodes
- [A JS reader finishes after a clean close](/quest/m1/js-close-range-finish.md) - a range ending below the cache delivers what's held and then ends
- [fMP4 decode times keep increasing](/quest/m1/fmp4-bframe-decode-time.md) - fragments shorter than a GOP of B-frame video never step `tfdt` backwards
- [A JS relay floors an unresolved copy at its newest group](/quest/m1/js-early-latest.md) - lite-01..05 subscribes without a start don't replay the cache from group 0
Expand Down
1 change: 0 additions & 1 deletion quest/m1/hls-conformance.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ with both checks intact.
## Required

- [HLS export follows a resolution change](/quest/m1/hls-reinit-same-codec.md) - the conformance test's same-codec switch fails until it lands
- [The last AAC segment advertises its full duration](/quest/m1/hls-final-aac-segment.md) - the conformance test's audio check fails until it lands

## Related

Expand Down
17 changes: 0 additions & 17 deletions quest/m1/hls-final-aac-segment.md

This file was deleted.

79 changes: 53 additions & 26 deletions rs/moq-mux/src/container/ts/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3948,15 +3948,14 @@ impl<E: CatalogExt> AacStream<E> {
// Count only completed frames; input gaps and unfinished tails are not a media burst.
burst += std::time::Duration::from_nanos((1024_u64 * 1_000_000_000).div_ceil(header.sample_rate as u64));
// The importer accumulates; cut each ADTS frame into its own group (one QUIC stream)
// so the relay forwards it without waiting for the next.
import.cut(None)?;
// so the relay forwards it without waiting for the next. Its known endpoint also
// bounds the final HLS segment, since a one-frame group has no measured cadence.
pts = advance_pts(pts, 1024, header.sample_rate)?;
import.cut(pts)?;
self.resync.published(unvouched);
published += 1;
// Offsets behind the published frame are spent; carrying one would republish it.
fallback = None;

// Every ADTS frame is 1024 samples.
pts = advance_pts(pts, 1024, header.sample_rate)?;
offset = end;
}

Expand Down Expand Up @@ -4057,23 +4056,16 @@ impl OpusStream {
// 48 kHz samples elapsed since this PES's PTS, advancing each packet after the first.
let mut elapsed: u64 = 0;
for packet in packets {
let pts = match base {
Some(base) if elapsed > 0 => {
let advance = Timestamp::from_scale(elapsed, 48_000)?;
// `base` is a 90 kHz PTS; rescale the sample advance to match before
// adding (the scale-aware Timestamp rejects mixed scales).
Some(base.checked_add(advance.convert(base.scale())?)?)
}
other => other,
};
self.import.decode(packet, pts)?;
// The importer accumulates; cut each Opus packet into its own group (one QUIC stream)
// so the relay forwards it without waiting for the next.
self.import.cut(None)?;

let pts = advance_pts(base, elapsed, 48_000)?;
// Default to 20 ms (960 samples) if the TOC can't be read, so a malformed packet
// doesn't stall the timeline for the rest of the PES.
elapsed += opus::packet_samples(packet).unwrap_or(960) as u64;
let end = advance_pts(base, elapsed, 48_000)?;
self.import.decode(packet, pts)?;
// The importer accumulates; cut each Opus packet into its own group (one QUIC stream)
// so the relay forwards it without waiting for the next. Its known endpoint also
// bounds the final HLS segment, since a one-packet group has no measured cadence.
self.import.cut(end)?;
published += 1;
}
Ok(published)
Expand Down Expand Up @@ -4559,14 +4551,14 @@ impl<E: CatalogExt> LegacyStream<E> {

import.decode(&data[offset..end], pts)?;
// The importer accumulates; cut each frame into its own group (one QUIC stream)
// so the relay forwards it without waiting for the next.
import.cut(None)?;
// so the relay forwards it without waiting for the next. Its known endpoint also
// bounds the final HLS segment, since a one-frame group has no measured cadence.
pts = advance_pts(pts, header.samples, header.sample_rate)?;
import.cut(pts)?;
self.resync.published(unvouched);
published += 1;
// Offsets behind the published frame are spent; carrying one would republish it.
fallback = None;

pts = advance_pts(pts, header.samples, header.sample_rate)?;
offset = end;
}

Expand Down Expand Up @@ -6043,6 +6035,26 @@ pub(super) mod test {
);
}

/// Where the only audio rendition's HLS records end, once the catalog finishes.
async fn hls_audio_end<E: crate::catalog::hang::CatalogExt>(
consumer: &moq_net::broadcast::Consumer,
catalog: &mut crate::catalog::Producer<E>,
) -> Option<Timestamp> {
catalog.finish().unwrap();
let snapshot = catalog.snapshot();
let hls = snapshot.audio.renditions.values().next().unwrap().hls.as_ref().unwrap();
let mut records = crate::hls::Consumer::subscribe(consumer, hls).await.unwrap();
let mut end = None;
while let Some(event) = records.next().await.unwrap() {
if let crate::hls::Event::Push { entry, .. } = event
&& entry.is_stop()
{
end = Some(entry.pts);
}
}
end
}

/// Read every retained frame of the single audio rendition in `catalog`.
async fn read_audio_frames<E: crate::catalog::hang::CatalogExt>(
consumer: &moq_net::broadcast::Consumer,
Expand Down Expand Up @@ -6397,7 +6409,7 @@ pub(super) mod test {

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 catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap();
let mut import = super::Import::new(broadcast, catalog.reserve());

let pmt = synth_pmt(&[(StreamType::AdtsAac, AAC_PID)], false);
Expand All @@ -6422,6 +6434,11 @@ pub(super) mod test {
[0xAA, 0xBB].map(|fill| adts_frame(40, fill)[7..].to_vec()).to_vec(),
"the last frame was held for a confirmation that could never arrive"
);
// Both 1024-sample frames at 48 kHz, including the one completed by the EOF drain.
assert_eq!(
hls_audio_end(&consumer, &mut catalog).await,
Some(Timestamp::from_millis(1_042).unwrap())
);
}

/// One whole MPEG-2 Layer II frame (8 kbps, 16 kHz, mono = 72 bytes), filled with
Expand Down Expand Up @@ -6785,7 +6802,7 @@ pub(super) mod test {

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 catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap();
let mut import = super::Import::new(broadcast, catalog.reserve());

let pmt = synth_pmt(&[(StreamType::Mpeg1Audio, MP2_PID)], false);
Expand Down Expand Up @@ -6829,6 +6846,11 @@ pub(super) mod test {
)]),
"the drained frame was published without a trace"
);
// Both 1152-sample frames at 16 kHz, including the one completed by the EOF drain.
assert_eq!(
hls_audio_end(&consumer, &mut catalog).await,
Some(Timestamp::from_millis(1_144).unwrap())
);
}

// A sync word is short enough to turn up by chance in compressed payload (a valid-looking
Expand Down Expand Up @@ -9700,7 +9722,7 @@ pub(super) mod test {
async fn damaged_opus_pes_is_not_half_published() {
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 catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap();
let mut import = super::Import::new(broadcast, catalog.reserve());
import
.ensure_stream(
Expand All @@ -9726,6 +9748,11 @@ pub(super) mod test {
let name = catalog.snapshot().audio.renditions.keys().next().unwrap().clone();
let frames = read_track(&consumer, &name, crate::container::Kind::Audio).await;
assert_eq!(frames.len(), 2, "no packet from the damaged PES is published");
// The last PES starts at 1.0667 s and holds one 20 ms packet, recorded in milliseconds.
assert_eq!(
hls_audio_end(&consumer, &mut catalog).await,
Some(Timestamp::from_millis(1_086).unwrap())
);
}

/// An aborted track is a feed-wide publishing failure, never a damaged media unit.
Expand Down