rtpav1depay: Skip unexpected leading fragments

If a packet is starting with a leading fragment but we do not expect to
receive one, then skip over it to the next OBU.

Not doing so would cause parsing of the middle of an OBU, which would
most likely fail and cause unnecessary warning messages about a
corrupted stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1367>
This commit is contained in:
Sebastian Dröge 2023-10-23 21:46:45 +03:00 committed by GStreamer Marge Bot
parent b1894a0acb
commit 1f5e9a9335

View file

@ -33,6 +33,8 @@ struct State {
marked_packet: bool,
/// if the next output buffer needs the DISCONT flag set
needs_discont: bool,
/// if we saw a valid OBU since the last reset
found_valid_obu: bool,
/// holds data for a fragment
obu_fragment: Option<(UnsizedObu, Vec<u8>)>,
}
@ -43,6 +45,7 @@ impl Default for State {
last_timestamp: None,
marked_packet: false,
needs_discont: true,
found_valid_obu: false,
obu_fragment: None,
}
}
@ -291,6 +294,21 @@ impl RTPAv1Depay {
let (element_size, is_last_obu) =
self.find_element_info(rtp, &mut reader, &aggr_header, idx)?;
if idx == 0 && aggr_header.leading_fragment {
if state.found_valid_obu {
gst::error!(
CAT,
imp: self,
"invalid packet: unexpected leading OBU fragment"
);
}
reader
.seek(SeekFrom::Current(element_size as i64))
.map_err(err_flow!(self, buf_read))?;
idx += 1;
continue;
}
let header_pos = reader.position();
let mut bitreader = BitReader::endian(&mut reader, ENDIANNESS);
let obu = UnsizedObu::parse(&mut bitreader).map_err(err_flow!(self, obu_read))?;
@ -299,6 +317,8 @@ impl RTPAv1Depay {
.seek(SeekFrom::Start(header_pos))
.map_err(err_flow!(self, buf_read))?;
state.found_valid_obu = true;
// ignore these OBU types
if matches!(obu.obu_type, ObuType::TemporalDelimiter | ObuType::TileList) {
reader