flv: Add `skip_back` method for reverse tag parsing

This commit is contained in:
David Wendt 2023-04-10 20:37:55 -04:00 committed by kmeisthax
parent 7bf28074c0
commit 20d33df458
1 changed files with 14 additions and 0 deletions

View File

@ -83,6 +83,20 @@ impl<'a> Tag<'a> {
None None
} }
} }
/// Skip back to the prior tag in the FLV.
///
/// FLV files are constructed as a list of tags. Back pointers to prior
/// tags are provided to allow reverse seeking. This function ignores the
/// tag at the current location and skips back to prior data in the file.
pub fn skip_back(reader: &mut FlvReader<'a>) -> Option<()> {
let previous_tag_size = reader.read_u32()?;
reader
.seek(SeekFrom::Current(-(previous_tag_size as i64)))
.ok()?;
Some(())
}
} }
#[cfg(test)] #[cfg(test)]