Skip to content

Commit a7d2f8f

Browse files
authored
Allow AUD NAL units of size 2. (Used by OBS) (#670)
1 parent d355699 commit a7d2f8f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

rtp/src/codecs/h264/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,22 @@ pub struct H264Packet {
206206
impl Depacketizer for H264Packet {
207207
/// depacketize parses the passed byte slice and stores the result in the H264Packet this method is called upon
208208
fn depacketize(&mut self, packet: &Bytes) -> Result<Bytes> {
209-
if packet.len() <= 2 {
209+
if packet.len() <= 1 {
210210
return Err(Error::ErrShortPacket);
211211
}
212212

213-
let mut payload = BytesMut::new();
214-
215213
// NALU Types
216214
// https://tools.ietf.org/html/rfc6184#section-5.4
217215
let b0 = packet[0];
218216
let nalu_type = b0 & NALU_TYPE_BITMASK;
219217

218+
// The AUD NALU can be size 2 (1 byte header, 1 byte payload)
219+
if packet.len() <= 2 && nalu_type != AUD_NALU_TYPE {
220+
return Err(Error::ErrShortPacket);
221+
}
222+
223+
let mut payload = BytesMut::new();
224+
220225
match nalu_type {
221226
1..=23 => {
222227
if self.is_avc {

0 commit comments

Comments
 (0)