From c068f662b133c99a9f9ad66acdc12e267be12608 Mon Sep 17 00:00:00 2001 From: r4v3n6101 Date: Fri, 8 Aug 2025 13:20:59 +0300 Subject: [PATCH] rtmp4gdepay2: fix condition while creating parser Part-of: --- net/rtp/src/mp4g/mode.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/net/rtp/src/mp4g/mode.rs b/net/rtp/src/mp4g/mode.rs index 663518d20..c7aa9d64b 100644 --- a/net/rtp/src/mp4g/mode.rs +++ b/net/rtp/src/mp4g/mode.rs @@ -9,8 +9,8 @@ pub enum ModeError { #[error("sizelength & constantsize can't be both defined")] BothAuSizeLenAndConstantSize, - #[error("Neither sizelength nor constantsize are defined, need at least one of them")] - NeitherAuSizeLenNorConstantSize, + #[error("no AU length parameters defined: need sizelength, constantsize, or constantduration")] + MissingAuLengthParameters, #[error("indexlength > 0 but indexdeltalength not defined")] MandatoryIndexDeltaLength, @@ -83,13 +83,14 @@ impl ModeConfig { let size_len = Self::parse_int::(s, "sizelength")?; let constant_size = Self::parse_int::(s, "constantsize")?; + let constant_duration = Self::parse_int::(s, "constantduration")?; if size_len != 0 && constant_size != 0 { Err(BothAuSizeLenAndConstantSize)?; } - if size_len == 0 && constant_size == 0 { - Err(NeitherAuSizeLenNorConstantSize)?; + if size_len == 0 && constant_size == 0 && constant_duration == 0 { + Err(MissingAuLengthParameters)?; } // ยง 3.2.1 @@ -116,7 +117,7 @@ impl ModeConfig { stream_state_indication: Self::parse_int::(s, "streamstateindication")?, auxiliary_data_size_len: Self::parse_int::(s, "auxiliarydatasizelength")?, constant_size, - constant_duration: Self::parse_int::(s, "constantduration")?, + constant_duration, max_displacement: Self::parse_int::(s, "maxdisplacement")?, }) } @@ -161,8 +162,8 @@ impl ModeConfig { Err(BothAuSizeLenAndConstantSize)?; } - if self.size_len == 0 && self.constant_size == 0 { - Err(NeitherAuSizeLenNorConstantSize)?; + if self.size_len == 0 && self.constant_size == 0 && self.constant_duration == 0 { + Err(MissingAuLengthParameters)?; } if self.index_len > 0 && self.index_delta_len == 0 {