Expand description
Package rtcp implements encoding and decoding of RTCP packets according to RFCs 3550 and 5506.
RTCP is a sister protocol of the Real-time Transport Protocol (RTP). Its basic functionality and packet structure is defined in RFC 3550. RTCP provides out-of-band statistics and control information for an RTP session. It partners with RTP in the delivery and packaging of multimedia data, but does not transport any media data itself.
The primary function of RTCP is to provide feedback on the quality of service (QoS) in media distribution by periodically sending statistics information such as transmitted octet and packet counts, packet loss, packet delay variation, and round-trip delay time to participants in a streaming multimedia session. An application may use this information to control quality of service parameters, perhaps by limiting flow, or using a different codec.
§Decoding RTCP packets
One datagram may hold several packets — RTCP is compound — so packet::unmarshal
consumes the buffer and returns them all. Recover each concrete type by downcasting:
use bytes::Bytes;
use rtc_rtcp::goodbye::Goodbye;
use rtc_rtcp::packet::unmarshal;
use rtc_rtcp::payload_feedbacks::picture_loss_indication::PictureLossIndication;
let mut buf = rtcp_data;
for packet in unmarshal(&mut buf)? {
if let Some(pli) = packet.as_any().downcast_ref::<PictureLossIndication>() {
println!("keyframe requested for ssrc {}", pli.media_ssrc);
} else if let Some(bye) = packet.as_any().downcast_ref::<Goodbye>() {
println!("{:?} left the session", bye.sources);
}
}§Encoding RTCP packets
Every packet type implements Marshal, so that trait must be
in scope:
use rtc_rtcp::payload_feedbacks::picture_loss_indication::PictureLossIndication;
use shared::marshal::Marshal;
let pli = PictureLossIndication {
sender_ssrc,
media_ssrc,
};
let pli_data = pli.marshal()?;Re-exports§
Modules§
- compound_
packet - Compound RTCP packets — the several reports that share one datagram.
- extended_
report - Extended reports (XR, RFC 3611): loss/discard run lengths, receipt times and per-block statistics.
- goodbye
- The BYE packet, by which a source announces it is leaving.
- header
- The four-byte header common to every RTCP packet. The RTCP header.
- packet
- The
Packettrait every RTCP packet type implements. - payload_
feedbacks - Payload-specific feedback (PT 206): PLI, FIR, SLI and REMB.
- raw_
packet - An unparsed packet, used for types this crate does not model.
- receiver_
report - The Receiver Report (RR), which reports reception quality back to a sender.
- reception_
report - The reception report block carried inside SR and RR packets.
- sender_
report - The Sender Report (SR), which carries a sender’s timing and packet counts.
- source_
description - The SDES packet, which carries CNAME and other source metadata.
- transport_
feedbacks - Transport-specific feedback (PT 205): NACK and transport-wide congestion control.