[domistream] RTP and FEC API: RTP header parser, Reed-Solomon over GF(2^8)

This commit is contained in:
2026-11-25 11:47:42 +01:00
parent c01f980292
commit e7c69ac956
3 changed files with 130 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
//! The 12-byte RTP header shared by video and audio ([RFC 3550] §5.1, `docs/PROTOCOL.md` 5.2, 6.2).
//!
//! [RFC 3550]: https://www.rfc-editor.org/rfc/rfc3550
/// Length of the fixed RTP header.
pub const RTP_HEADER_LEN: usize = 12;
/// The fixed RTP header. Fields are big-endian on the wire. The first byte is kept raw (version 2 plus flags:
/// `0x90` for video, `0x80` for audio).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct RtpHeader {
/// Byte 0: version, padding, extension, CSRC count.
pub flags: u8,
/// Byte 1: payload type (video 0, audio 97, audio parity 127).
pub payload_type: u8,
/// Sequence number.
pub sequence: u16,
/// Timestamp.
pub timestamp: u32,
/// SSRC.
pub ssrc: u32,
}
/// Parses the first [`RTP_HEADER_LEN`] bytes of `packet` (the rest is ignored here). Refuses a version other
/// than 2.
///
/// # Errors
/// [`crate::Error::Truncated`] for fewer than 12 bytes, [`crate::Error::UnexpectedValue`] for another RTP version.
/// Phase A: always [`crate::Error::Unimplemented`].
pub fn parse_rtp_header(packet: &[u8]) -> crate::Result<RtpHeader> {
let _ = packet;
Err(crate::Error::Unimplemented)
}