Crate rvoip_rtp_core

Source
Expand description

RTP Core library for the RVOIP project

This crate provides RTP packet encoding/decoding, RTCP support, and other utilities for handling real-time media transport.

The library is organized into several modules:

  • packet: RTP and RTCP packet definitions and processing
  • session: RTP session management including SSRC demultiplexing
  • transport: Network transport for RTP/RTCP
  • srtp: Secure RTP implementation
  • stats: RTP statistics collection
  • time: Timing and clock utilities
  • sync: Media synchronization for multiple streams
  • traits: Public traits for integration with other crates
  • payload: RTP payload format handlers
  • buffer: High-performance buffer management for receiving and transmitting packets
  • csrc: CSRC management
  • error: Error handling
  • rtcp: RTCP packet definitions and processing
  • dtls: DTLS support
  • api: New API module with client/server separation
  • feedback: Advanced RTCP feedback mechanisms for real-time adaptation

§New API Structure

The api module provides a higher-level interface with clear client/server separation:

  • api::client: Client-side media transport for sending/receiving media frames
  • api::server: Server-side media transport for handling multiple clients
  • api::common: Shared types and utilities used by both client and server

This structure makes the library easier to use for higher-level components like media-core.

§Advanced RTCP Feedback

The feedback module provides intelligent RTCP feedback generation for optimal media quality:

  • Picture Loss Indication (PLI) and Full Intra Request (FIR) for video recovery
  • Receiver Estimated Max Bitrate (REMB) for bandwidth adaptation
  • Transport-wide Congestion Control feedback for network optimization
  • Google Congestion Control (GCC) algorithm implementation
  • Quality-based feedback decisions using multiple network metrics
  • Configurable feedback generation with rate limiting and priority handling

This enables WebRTC-compatible adaptive streaming with automatic quality optimization.

§Buffer Management

The buffer module provides optimized memory and packet management for high-scale deployments:

  • Memory pooling to reduce allocations
  • Adaptive jitter buffer for handling network variation
  • Priority-based transmit buffering
  • Congestion control for network adaptation
  • Global memory limits to prevent OOM conditions
  • Efficient packet ordering and scheduling

This is ideal for deployments handling tens of thousands of concurrent streams.

Re-exports§

pub use packet::rtp::RtpPacket;
pub use packet::header::RtpHeader;
pub use packet::rtcp::RtcpPacket;
pub use packet::rtcp::RtcpSenderReport;
pub use packet::rtcp::RtcpReceiverReport;
pub use packet::rtcp::RtcpReportBlock;
pub use packet::rtcp::NtpTimestamp;
pub use packet::rtcp::RtcpSourceDescription;
pub use packet::rtcp::RtcpGoodbye;
pub use packet::rtcp::RtcpApplicationDefined;
pub use packet::rtcp::RtcpExtendedReport;
pub use packet::rtcp::RtcpCompoundPacket;
pub use packet::rtcp::RtcpXrBlock;
pub use packet::rtcp::VoipMetricsBlock;
pub use packet::extension::ExtensionElement;
pub use packet::extension::RtpHeaderExtensions;
pub use packet::extension::ids::AUDIO_LEVEL;
pub use packet::extension::ids::VIDEO_ORIENTATION;
pub use packet::extension::ids::TRANSPORT_CC;
pub use packet::extension::ids::FRAME_MARKING;
pub use packet::extension::ids::SDES;
pub use packet::extension::uris::ABS_SEND_TIME;
pub use packet::extension::uris::MID;
pub use packet::extension::uris::STREAM_ID;
pub use packet::extension::uris::REPAIR_RTP_STREAM_ID;
pub use packet::extension::uris::VIDEO_CONTENT_TYPE;
pub use session::RtpSession;
pub use session::RtpSessionConfig;
pub use session::RtpSessionEvent;
pub use session::RtpSessionStats;
pub use session::RtpStream;
pub use session::RtpStreamStats;
pub use transport::RtpTransport;
pub use transport::RtpTransportConfig;
pub use transport::UdpRtpTransport;
pub use traits::MediaTransport;
pub use traits::RtpEvent;
pub use traits::media_transport::RtpMediaTransport;
pub use payload::PayloadType;
pub use payload::PayloadFormat;
pub use payload::PayloadFormatFactory;
pub use payload::create_payload_format;
pub use payload::G711UPayloadFormat;
pub use payload::G711APayloadFormat;
pub use payload::G722PayloadFormat;
pub use payload::OpusPayloadFormat;
pub use payload::OpusBandwidth;
pub use payload::Vp8PayloadFormat;
pub use payload::Vp9PayloadFormat;
pub use csrc::CsrcMapping;
pub use csrc::CsrcManager;
pub use csrc::MAX_CSRC_COUNT;
pub use sync::MediaSync;
pub use sync::mapping::TimestampMapper;
pub use sync::clock::MediaClock;
pub use feedback::FeedbackContext;
pub use feedback::FeedbackConfig;
pub use feedback::FeedbackDecision;
pub use feedback::FeedbackPriority;
pub use feedback::QualityDegradation;
pub use feedback::CongestionState;
pub use feedback::FeedbackGenerator;
pub use feedback::FeedbackGeneratorFactory;
pub use feedback::packets::FeedbackPacket;
pub use feedback::packets::PliPacket;
pub use feedback::packets::FirPacket;
pub use feedback::packets::SliPacket;
pub use feedback::packets::TstoPacket;
pub use feedback::packets::RembPacket;
pub use feedback::packets::TransportCcPacket;
pub use feedback::packets::RTCP_HEADER_SIZE;
pub use feedback::generators::LossFeedbackGenerator;
pub use feedback::generators::CongestionFeedbackGenerator;
pub use feedback::generators::QualityFeedbackGenerator;
pub use feedback::generators::ComprehensiveFeedbackGenerator;
pub use feedback::algorithms::GoogleCongestionControl;
pub use feedback::algorithms::SimpleBandwidthEstimator;
pub use feedback::algorithms::QualityAssessment;
pub use feedback::algorithms::QualityMetrics;
pub use feedback::algorithms::PacketFeedback;
pub use api::client::MediaTransportClient;
pub use api::client::ClientFactory;
pub use api::client::ClientConfig;
pub use api::client::ClientConfigBuilder;
pub use api::server::MediaTransportServer;
pub use api::server::ServerFactory;
pub use api::server::ServerConfig;
pub use api::server::ServerConfigBuilder;
pub use api::server::ClientInfo;
pub use api::common::frame::MediaFrame;
pub use api::common::frame::MediaFrameType;
pub use api::common::events::MediaTransportEvent;
pub use api::common::events::MediaEventCallback;
pub use api::common::stats::MediaStats;
pub use api::common::stats::QualityLevel;
pub use api::common::config::SecurityMode;
pub use api::common::config::SrtpProfile;
pub use api::common::config::SecurityInfo;
pub use api::common::config::NetworkPreset;
pub use api::common::config::BaseTransportConfig;
pub use api::common::error::MediaTransportError;
pub use api::common::error::SecurityError;
pub use api::common::error::BufferError;
pub use api::common::error::StatsError;
pub use api::common::buffer::MediaBuffer;
pub use api::common::buffer::MediaBufferConfig;
pub use api::common::buffer::BufferStats;

Modules§

api
Media Transport API
buffer
High-performance buffer management for RTP packets
csrc
CSRC (Contributing Source) management for RTP
dtls
DTLS (Datagram Transport Layer Security) implementation
feedback
RTCP Feedback Mechanisms
packet
RTP Packet module
payload
Payload format handlers for RTP
prelude
Prelude module with commonly used types
rtcp
security
Security mechanisms for SIP/RTP
session
RTP Session Management
srtp
Secure RTP (SRTP) implementation
stats
RTP Statistics Module
sync
Media Synchronization module
time
Time and clock utilities for RTP
traits
Public traits for integration with other crates
transport
Network transport for RTP/RTCP

Enums§

Error
Error type for RTP operations

Constants§

DEFAULT_MAX_PACKET_SIZE
The default maximum size for RTP packets in bytes

Type Aliases§

Result
Result type for RTP operations
RtpCsrc
Typedef for RTP contributing source identifier
RtpSequenceNumber
Typedef for RTP sequence numbers
RtpSsrc
Typedef for RTP synchronization source identifier
RtpTimestamp
Typedef for RTP timestamp values