mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-24 09:58:13 +00:00
rtpav1depay: Set DISCONT flag on buffers following a corrupted packet
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1086>
This commit is contained in:
parent
3520fc67de
commit
dc47b35536
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
|
// TODO: handle internal size fields in RTP OBUs
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug)]
|
||||||
struct State {
|
struct State {
|
||||||
last_timestamp: Option<u32>,
|
last_timestamp: Option<u32>,
|
||||||
/// if true, the last packet of a temporal unit has been received
|
/// if true, the last packet of a temporal unit has been received
|
||||||
marked_packet: bool,
|
marked_packet: bool,
|
||||||
|
/// if the next output buffer needs the DISCONT flag set
|
||||||
|
needs_discont: bool,
|
||||||
/// holds data for a fragment
|
/// holds data for a fragment
|
||||||
obu_fragment: Option<(UnsizedObu, Vec<u8>)>,
|
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)]
|
#[derive(Debug, Default)]
|
||||||
pub struct RTPAv1Depay {
|
pub struct RTPAv1Depay {
|
||||||
state: Mutex<State>,
|
state: Mutex<State>,
|
||||||
|
@ -314,9 +327,10 @@ impl RTPBaseDepayloadImpl for RTPAv1Depay {
|
||||||
gst::log!(
|
gst::log!(
|
||||||
CAT,
|
CAT,
|
||||||
imp: self,
|
imp: self,
|
||||||
"creating buffer containing {} bytes of data (marker {})...",
|
"creating buffer containing {} bytes of data (marker {}, discont {})...",
|
||||||
ready_obus.len(),
|
ready_obus.len(),
|
||||||
state.marked_packet,
|
state.marked_packet,
|
||||||
|
state.needs_discont,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut buffer = gst::Buffer::from_mut_slice(ready_obus);
|
let mut buffer = gst::Buffer::from_mut_slice(ready_obus);
|
||||||
|
@ -325,6 +339,10 @@ impl RTPBaseDepayloadImpl for RTPAv1Depay {
|
||||||
if state.marked_packet {
|
if state.marked_packet {
|
||||||
buffer.set_flags(gst::BufferFlags::MARKER);
|
buffer.set_flags(gst::BufferFlags::MARKER);
|
||||||
}
|
}
|
||||||
|
if state.needs_discont {
|
||||||
|
buffer.set_flags(gst::BufferFlags::DISCONT);
|
||||||
|
state.needs_discont = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(buffer)
|
Some(buffer)
|
||||||
|
@ -332,6 +350,8 @@ impl RTPBaseDepayloadImpl for RTPAv1Depay {
|
||||||
None
|
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() {
|
if state.marked_packet && state.obu_fragment.is_some() {
|
||||||
gst::error!(
|
gst::error!(
|
||||||
CAT,
|
CAT,
|
||||||
|
|
Loading…
Reference in a new issue