Skip to content

Commit

Permalink
Fix of rtp header size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Oto Dušek committed Jun 6, 2023
1 parent 7bf1438 commit a166fff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rtp/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct Header {
pub csrc: Vec<u32>,
pub extension_profile: u16,
pub extensions: Vec<Extension>,
pub extensions_padding: usize
}

impl Unmarshal for Header {
Expand Down Expand Up @@ -97,7 +98,7 @@ impl Unmarshal for Header {
for _ in 0..cc {
csrc.push(raw_packet.get_u32());
}

let mut extensions_padding: usize = 0;
let (extension_profile, extensions) = if extension {
let expected = curr_offset + 4;
if raw_packet_len < expected {
Expand All @@ -123,6 +124,7 @@ impl Unmarshal for Header {
if b == 0x00 {
// padding
curr_offset += 1;
extensions_padding += 1;
continue;
}

Expand All @@ -149,6 +151,7 @@ impl Unmarshal for Header {
if b == 0x00 {
// padding
curr_offset += 1;
extensions_padding += 1;
continue;
}

Expand Down Expand Up @@ -194,6 +197,7 @@ impl Unmarshal for Header {
csrc,
extension_profile,
extensions,
extensions_padding
})
}
}
Expand All @@ -203,7 +207,7 @@ impl MarshalSize for Header {
fn marshal_size(&self) -> usize {
let mut head_size = 12 + (self.csrc.len() * CSRC_LENGTH);
if self.extension {
let extension_payload_len = self.get_extension_payload_len();
let extension_payload_len = self.get_extension_payload_len() + self.extensions_padding;
let extension_payload_size = (extension_payload_len + 3) / 4;
head_size += 4 + extension_payload_size * 4;
}
Expand Down

0 comments on commit a166fff

Please sign in to comment.