diff options
Diffstat (limited to 'rtp/src/rtcp.rs')
-rw-r--r-- | rtp/src/rtcp.rs | 86 |
1 files changed, 56 insertions, 30 deletions
diff --git a/rtp/src/rtcp.rs b/rtp/src/rtcp.rs index da0a683..371aa85 100644 --- a/rtp/src/rtcp.rs +++ b/rtp/src/rtcp.rs @@ -9,46 +9,63 @@ pub enum Error { } pub struct RtcpPacket<'a> { - parts: Vec<RtcpPart<'a>>, + pub parts: Vec<RtcpPart<'a>>, } pub enum RtcpPart<'a> { SenderReport(SenderReport<'a>), ReceiverReport(ReceiverReport), SourceDescription(SourceDescription), - Bye(Bye), + Bye(Bye<'a>), Application(Application<'a>), } -struct SenderReport<'a> { - ssrc: SSRC, - sender_info: SenderInfo, - reports: Vec<ReportBlock>, - extension: &'a [u8], +pub struct SenderReport<'a> { + pub ssrc: SSRC, + pub sender_info: SenderInfo, + pub reports: Vec<ReportBlock>, + pub extension: &'a [u8], } -struct ReceiverReport { - sender_ssrc: SSRC, - reports: Vec<ReportBlock>, +pub struct ReceiverReport { + pub sender_ssrc: SSRC, + pub reports: Vec<ReportBlock>, } -struct SourceDescription {} -struct Bye {} -struct Application<'a> { - data: &'a [u8], +pub struct SourceDescription { + sources: Vec<(SSRC, Vec<SourceDescriptionItem>)>, } -struct SenderInfo { - ntp_ts: u64, - rtp_ts: u32, - packet_count: u32, - octet_count: u32, +pub enum SourceDescriptionItem { + CanonicalName(String), + Name(String), + Email(String), + Phone(String), + Location(String), + Tool(String), + Notice(String), + PrivateExtension(String), } -struct ReportBlock { - ssrc: SSRC, - fraction_lost: u8, - cumulative_packets_lost: u32, - ext_max_seq_num_recv: u32, - interarrical_jitter: u32, - lsr: u32, - dlsr: u32, +pub struct Bye<'a> { + pub ssrcs: Vec<SSRC>, + pub reason: &'a [u8], +} +pub struct Application<'a> { + pub subtype: u8, + pub name: [u8; 4], + pub data: &'a [u8], +} +pub struct SenderInfo { + pub ntp_ts: u64, + pub rtp_ts: u32, + pub packet_count: u32, + pub octet_count: u32, +} +pub struct ReportBlock { + pub ssrc: SSRC, + pub fraction_lost: u8, + pub cumulative_packets_lost: u32, + pub ext_max_seq_num_recv: u32, + pub interarrical_jitter: u32, + pub lsr: u32, + pub dlsr: u32, } impl<'a> RtcpPacket<'a> { @@ -69,7 +86,7 @@ impl<'a> RtcpPacket<'a> { match packet_type { 200 => { - // Sender Report + // sender seport if packet.len() < 28 + 24 * num_reports as usize { return Err(Error::Truncated); } @@ -89,7 +106,17 @@ impl<'a> RtcpPacket<'a> { extension, })) } - 201 => { // Receiver Report + 201 => { + // receiver report + } + 202 => { + // source description + } + 203 => { + // bye + } + 204 => { + // application defined } _ => {} } @@ -107,7 +134,6 @@ impl<'a> RtcpPacket<'a> { version << 6 | (padding as u8) << 5 | sender_report.reports.len() as u8, ); out.push(200); - } RtcpPart::ReceiverReport(receiver_report) => todo!(), RtcpPart::SourceDescription(source_description) => todo!(), |