mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-08 18:25:30 +00:00
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/1387>
This commit is contained in:
parent
beb524e950
commit
7bb6f0265c
1 changed files with 20 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue