rtp: av1: Drop padding OBUs too like Chrome does

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1628>
This commit is contained in:
Sebastian Dröge 2024-06-17 13:10:52 +03:00 committed by GStreamer Marge Bot
parent 998b4734bf
commit 8840861861
3 changed files with 30 additions and 16 deletions

View file

@ -532,7 +532,10 @@ impl RTPAv1Depay {
first = false;
// ignore these OBU types
if matches!(obu.obu_type, ObuType::TemporalDelimiter | ObuType::TileList) {
if matches!(
obu.obu_type,
ObuType::TemporalDelimiter | ObuType::TileList | ObuType::Padding
) {
gst::trace!(CAT, imp: self, "Dropping {:?} of size {element_size}", obu.obu_type);
reader
.seek(SeekFrom::Current(element_size as i64))

View file

@ -139,9 +139,9 @@ impl RTPAv1Pay {
// tile lists and temporal delimiters should not be transmitted,
// see section 5 of the RTP AV1 spec
match obu.obu_type {
// completely ignore tile lists
ObuType::TileList => {
gst::log!(CAT, imp: self, "ignoring tile list OBU");
// completely ignore tile lists and padding
ObuType::TileList | ObuType::Padding => {
gst::log!(CAT, imp: self, "ignoring {:?} OBU", obu.obu_type);
reader
.seek(SeekFrom::Current(
(obu.header_len + obu.leb_size + obu.size) as i64,
@ -751,7 +751,7 @@ mod tests {
obus: VecDeque::from(vec![
ObuData {
info: SizedObu {
obu_type: ObuType::Padding,
obu_type: ObuType::Frame,
size: 3,
..base_obu
},
@ -810,6 +810,14 @@ mod tests {
},
..ObuData::default()
},
ObuData {
info: SizedObu {
obu_type: ObuType::SequenceHeader,
size: 0,
..base_obu
},
..ObuData::default()
},
ObuData {
info: SizedObu {
obu_type: ObuType::Frame,
@ -821,7 +829,7 @@ mod tests {
},
ObuData {
info: SizedObu {
obu_type: ObuType::Padding,
obu_type: ObuType::Frame,
size: 6,
..base_obu
},
@ -898,8 +906,8 @@ mod tests {
),
(
Some(PacketOBUData {
obu_count: 4,
payload_size: 34,
obu_count: 5,
payload_size: 36,
last_obu_fragment_size: None,
omit_last_size_field: false,
ends_temporal_unit: true,
@ -942,7 +950,8 @@ mod tests {
state
.obus
.iter()
.filter(|o| o.info.obu_type != ObuType::TemporalDelimiter)
.filter(|o| o.info.obu_type != ObuType::TemporalDelimiter
&& o.info.obu_type != ObuType::Padding)
.cloned()
.collect::<Vec<_>>(),
results[idx].1.obus.iter().cloned().collect::<Vec<_>>()

View file

@ -35,7 +35,7 @@ fn test_depayloader() {
), ( // 2 OBUs, last is fragmented
vec![
0b0110_0000,
0b0000_0110, 0b0111_1000, 1, 2, 3, 4, 5,
0b0000_0110, 0b0011_0000, 1, 2, 3, 4, 5,
0b0011_0000, 1, 2, 3,
],
false,
@ -64,7 +64,7 @@ fn test_depayloader() {
],
vec![
0b0001_0010, 0,
0b0111_1010, 0b0000_0101, 1, 2, 3, 4, 5,
0b0011_0010, 0b0000_0101, 1, 2, 3, 4, 5,
],
vec![
0b0011_0010, 0b0000_1010, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
@ -115,15 +115,16 @@ fn test_payloader() {
let test_buffers: [(u64, Vec<u8>); 3] = [
(
0,
vec![ // this should result in exactly 25 bytes for the RTP payload
vec![ // this should result in exactly 27 bytes for the RTP payload
0b0001_0010, 0,
0b0000_1010, 0,
0b0011_0010, 0b0000_1100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
0b0011_0010, 0b0000_1001, 1, 2, 3, 4, 5, 6, 7, 8, 9,
],
), (
0,
vec![ // these all have to go in separate packets since their IDs mismatch
0b0111_1010, 0b0000_0100, 1, 2, 3, 4,
0b0011_0010, 0b0000_0100, 1, 2, 3, 4,
0b0011_0110, 0b0010_1000, 0b0000_0101, 1, 2, 3, 4, 5,
0b0011_0110, 0b0100_1000, 0b0000_0001, 1,
],
@ -141,7 +142,8 @@ fn test_payloader() {
false, // marker bit
0, // relative RTP timestamp
vec![ // payload bytes
0b0010_1000,
0b0011_1000,
0b0000_0001, 0b0000_1000,
0b0000_1101, 0b0011_0000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
0b0011_0000, 1, 2, 3, 4, 5, 6, 7, 8, 9,
],
@ -150,7 +152,7 @@ fn test_payloader() {
0,
vec![
0b0001_0000,
0b0111_1000, 1, 2, 3, 4,
0b0011_0000, 1, 2, 3, 4,
]
), (
false,
@ -183,7 +185,7 @@ fn test_payloader() {
let pay = h.element().unwrap();
pay.set_property(
"mtu",
gst_rtp::calc_packet_len(25, 0, 0)
gst_rtp::calc_packet_len(27, 0, 0)
);
}
h.play();