Skip to content

Commit

Permalink
fix: add a way to reset Media object
Browse files Browse the repository at this point in the history
  • Loading branch information
therishidesai committed Oct 1, 2024
1 parent ab0f36f commit c52d35b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions moq-pub/src/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ impl Media {
})
}

pub fn reset(&mut self) {
for track in self.tracks.values_mut() {
track.end_group();
}
}

// Parse the input buffer, reading any full atoms we can find.
// Keep appending more data and calling parse.
pub fn parse<B: Buf>(&mut self, buf: &mut B) -> anyhow::Result<()> {
Expand All @@ -61,15 +67,17 @@ impl Media {
match header.name {
mp4::BoxType::FtypBox => {
if self.ftyp.is_some() {
anyhow::bail!("multiple ftyp atoms");
tracing::debug!("multiple ftyp atoms");
return Ok(true);
}

// Save the ftyp atom for later.
self.ftyp = Some(atom)
}
mp4::BoxType::MoovBox => {
if self.moov.is_some() {
anyhow::bail!("multiple moov atoms");
tracing::debug!("multiple moov atoms");
return Ok(true);
}

// Parse the moov box so we can detect the timescales for each track.
Expand Down

0 comments on commit c52d35b

Please sign in to comment.