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
15 changes: 13 additions & 2 deletions doc/bin/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,20 @@ keyframe when it re-enables. The muxed exports declare only enabled renditions
in their header; one disabled afterwards keeps its track, idle until it
re-enables.

A rendition whose track fails ends alone while the export still reads another, with
a warning: the muxed exports keep the other media, and the export fails only when
nothing else is left reading. A rendition of the same medium that the catalog
lists afterwards takes its place, as `import capture` publishes a reopened
microphone. `ts` adds it as a new stream; `fmp4`, `mkv`, and `flv` continue the
failed track with it, from its first sync frame past what was written, as long as
it has the same codec configuration.

fMP4 writes one fragment per publisher group; `--fragment-duration` caps it.
The init segment declares every enabled rendition, so it is written only once each can
be described, and the track set is then fixed: a new rendition or a changed
codec configuration ends the export. Restart it to pick up the change.
codec configuration ends the export. Restart it to pick up the change. A new
rendition waits instead while a track of its medium could still fail, to take
that track's place.
Annex-B H.264 and H.265 whose catalog codec string and dimensions fix the sample
entry are described at once as `avc3` or `hev1`, with SPS, PPS, and VPS kept in
the samples, so an encoder restarting with a new SPS does not end the export.
Expand Down Expand Up @@ -249,7 +259,8 @@ fallback when built with `openh264`, and audio is Opus; [moq-video](/lib/rs/moq-
backends. An audio device that fails mid-session, such as a USB microphone
re-enumerating, is reopened every 0.5 to 4 seconds as a new audio track. One
still failing after 10 seconds ends only the audio track: video keeps
publishing, and the import exits with the audio error once it stops. A device
publishing, and the import exits with the audio error once it stops. A muxed
export of the broadcast follows each reopened track. A device
that fails to open at startup ends the import at once. Audio appears
in the catalog once its device opens; a microphone permission prompt leaves
other media available. The camera and
Expand Down
30 changes: 0 additions & 30 deletions quest/m2/export-replaced-rendition.md

This file was deleted.

25 changes: 17 additions & 8 deletions rs/moq-mux/src/container/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ enum Reader<E> {
/// An error ended the reader, which reads as finished from then on. The subscription is
/// released, and the publisher's demand with it.
Ended,
/// The track's own failure ended the reader once its groups drained, as [`Self::Ended`] does.
Lost,
}

/// How a [`Consumer`]'s cursor chooses its first group.
Expand Down Expand Up @@ -576,18 +578,25 @@ impl<F: Container> Consumer<F> {
Poll::Ready(Ok(Some(item)))
}

/// Whether the error that ended the reader was its track's own failure, rather than its media.
pub(crate) fn lost(&self) -> bool {
matches!(self.reader, Reader::Lost)
}

/// Read media or a clean group boundary without waiting for a successor group.
pub(crate) fn poll_event(&mut self, waiter: &kio::Waiter) -> Poll<Result<Option<Event>, F::Error>> {
// An error ended the reader, which reads as finished from then on: a decode error has
// already consumed the frame it came from, so reading on would skip it.
if let Reader::Ended = self.reader {
if let Reader::Ended | Reader::Lost = self.reader {
return Poll::Ready(Ok(None));
}
let event = ready!(self.poll_event_inner(waiter));
if event.is_err() {
// Nothing more is read, so release the subscription and the groups it holds rather
// than pin the publisher's demand and cache for as long as the caller keeps this.
self.reader = Reader::Ended;
if !matches!(self.reader, Reader::Lost) {
self.reader = Reader::Ended;
}
self.pending.clear();
}
Poll::Ready(event)
Expand Down Expand Up @@ -877,7 +886,7 @@ impl<F: Container> Consumer<F> {
Reader::Reading(track) | Reader::Failed(track, _) => {
track.next_in_range(self.current).is_none_or(|next| next >= sequence)
}
Reader::Ended => false,
Reader::Ended | Reader::Lost => false,
};
// The groups past the hole already fill the max buffer, so it can hold none of what
// would arrive into it.
Expand Down Expand Up @@ -968,7 +977,7 @@ impl<F: Container> Consumer<F> {

if finished && self.pending.is_empty() {
if let Reader::Failed(..) = self.reader
&& let Reader::Failed(_, err) = std::mem::replace(&mut self.reader, Reader::Ended)
&& let Reader::Failed(_, err) = std::mem::replace(&mut self.reader, Reader::Lost)
{
// The caller only gets the bare error, with nothing to say which track died.
tracing::warn!(track = &*self.name, error = ?err, "track failed; ending the reader");
Expand Down Expand Up @@ -1177,7 +1186,7 @@ impl<F: Container> Consumer<F> {
fn subscriber(&mut self) -> &mut moq_net::track::Subscriber {
match &mut self.reader {
Reader::Reading(track) | Reader::Failed(track, _) => track,
Reader::Ended => unreachable!("read only until an error ends the reader"),
Reader::Ended | Reader::Lost => unreachable!("read only until an error ends the reader"),
}
}

Expand Down Expand Up @@ -1216,7 +1225,7 @@ impl<F: Container> Consumer<F> {

/// Receive group handles and wait for the track and every received group to finish.
pub(crate) fn poll_received(&mut self, waiter: &kio::Waiter) -> Poll<()> {
if let Reader::Ended = self.reader {
if let Reader::Ended | Reader::Lost = self.reader {
return Poll::Ready(());
}
ready!(self.poll_read_finish(waiter));
Expand Down Expand Up @@ -1402,7 +1411,7 @@ impl<F: Container> Consumer<F> {
pub fn is_skipped(&self, groups: std::ops::Range<u64>) -> bool {
match &self.reader {
Reader::Reading(track) | Reader::Failed(track, _) => track.is_skipped(groups),
Reader::Ended => false,
Reader::Ended | Reader::Lost => false,
}
}

Expand Down Expand Up @@ -1825,7 +1834,7 @@ mod tests {
fn subscribed<F: ContainerTrait>(consumer: &Consumer<F>) -> &moq_net::track::Subscriber {
match &consumer.reader {
Reader::Reading(track) | Reader::Failed(track, _) => track,
Reader::Ended => panic!("the reader ended"),
Reader::Ended | Reader::Lost => panic!("the reader ended"),
}
}
use std::time::Duration;
Expand Down
Loading