mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-09 10:45:27 +00:00
rtpav1depay: Set DISCONT flag on buffers following a corrupted packet
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1072>
This commit is contained in:
parent
d6cb9d72d8
commit
ed4e9a50d5
1 changed files with 22 additions and 2 deletions
|
@ -26,15 +26,28 @@ use crate::av1::common::{
|
|||
|
||||
// TODO: handle internal size fields in RTP OBUs
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
struct State {
|
||||
last_timestamp: Option<u32>,
|
||||
/// if true, the last packet of a temporal unit has been received
|
||||
marked_packet: bool,
|
||||
/// if the next output buffer needs the DISCONT flag set
|
||||
needs_discont: bool,
|
||||
/// holds data for a fragment
|
||||
obu_fragment: Option<(UnsizedObu, Vec<u8>)>,
|
||||
}
|
||||
|
||||
impl Default for State {
|
||||
fn default() -> Self {
|
||||
State {
|
||||
last_timestamp: None,
|
||||
marked_packet: false,
|
||||
needs_discont: true,
|
||||
obu_fragment: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct RTPAv1Depay {
|
||||
state: Mutex<State>,
|
||||
|
@ -314,9 +327,10 @@ impl RTPBaseDepayloadImpl for RTPAv1Depay {
|
|||
gst::log!(
|
||||
CAT,
|
||||
imp: self,
|
||||
"creating buffer containing {} bytes of data (marker {})...",
|
||||
"creating buffer containing {} bytes of data (marker {}, discont {})...",
|
||||
ready_obus.len(),
|
||||
state.marked_packet,
|
||||
state.needs_discont,
|
||||
);
|
||||
|
||||
let mut buffer = gst::Buffer::from_mut_slice(ready_obus);
|
||||
|
@ -325,6 +339,10 @@ impl RTPBaseDepayloadImpl for RTPAv1Depay {
|
|||
if state.marked_packet {
|
||||
buffer.set_flags(gst::BufferFlags::MARKER);
|
||||
}
|
||||
if state.needs_discont {
|
||||
buffer.set_flags(gst::BufferFlags::DISCONT);
|
||||
state.needs_discont = false;
|
||||
}
|
||||
}
|
||||
|
||||
Some(buffer)
|
||||
|
@ -332,6 +350,8 @@ impl RTPBaseDepayloadImpl for RTPAv1Depay {
|
|||
None
|
||||
};
|
||||
|
||||
// It's important to check this after the packet was created as otherwise
|
||||
// the discont flag is already before the missing data.
|
||||
if state.marked_packet && state.obu_fragment.is_some() {
|
||||
gst::error!(
|
||||
CAT,
|
||||
|
|
Loading…
Reference in a new issue