Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some getters public, add various new mutable/immutable APIs and improve docs a bit #14

Merged
merged 8 commits into from
Feb 23, 2024
8 changes: 8 additions & 0 deletions src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ impl<'a> RtpPacket<'a> {
}
}

/// Returns the length of the payload in this packet without padding.
pub fn payload_len(&self) -> usize {
ystreet marked this conversation as resolved.
Show resolved Hide resolved
let offset = self.payload_offset();
let pad = self.padding().unwrap_or_default() as usize;

self.data.len() - pad - offset
}

/// Returns the payload data
pub fn payload(&self) -> &[u8] {
let offset = self.payload_offset();
Expand Down