pub struct RtpSession { /* private fields */ }Expand description
RTP session that manages send/receive streams
Implementations§
Source§impl RtpSession
impl RtpSession
Sourcepub async fn new(config: SessionConfig) -> Result<Self, SessionError>
pub async fn new(config: SessionConfig) -> Result<Self, SessionError>
Create and bind a new RTP session
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Get the local address this session is bound to
Sourcepub fn set_remote_addr(&mut self, addr: SocketAddr)
pub fn set_remote_addr(&mut self, addr: SocketAddr)
Update the remote address (e.g. after receiving SDP answer)
Sourcepub async fn send_audio(
&mut self,
pcm_samples: &[i16],
) -> Result<usize, SessionError>
pub async fn send_audio( &mut self, pcm_samples: &[i16], ) -> Result<usize, SessionError>
Send PCM audio samples as an RTP packet
Sourcepub async fn send_rfc2833_digit(
&mut self,
digit: char,
payload_type: u8,
) -> Result<(), SessionError>
pub async fn send_rfc2833_digit( &mut self, digit: char, payload_type: u8, ) -> Result<(), SessionError>
Send one RFC2833 telephone-event digit.
payload_type is typically negotiated via SDP a=rtpmap:<pt> telephone-event/8000.
Sourcepub fn queue_rfc2833_digits(
&mut self,
digits: &str,
) -> Result<usize, SessionError>
pub fn queue_rfc2833_digits( &mut self, digits: &str, ) -> Result<usize, SessionError>
Queue DTMF digits for RFC2833 transmission.
Returns the number of queued digits.
pub fn queued_rfc2833_digits(&self) -> usize
Sourcepub async fn send_next_queued_rfc2833(
&mut self,
payload_type: u8,
) -> Result<Option<char>, SessionError>
pub async fn send_next_queued_rfc2833( &mut self, payload_type: u8, ) -> Result<Option<char>, SessionError>
Send the next queued RFC2833 DTMF digit.
Sourcepub async fn flush_queued_rfc2833(
&mut self,
payload_type: u8,
inter_digit_gap_ms: u64,
) -> Result<usize, SessionError>
pub async fn flush_queued_rfc2833( &mut self, payload_type: u8, inter_digit_gap_ms: u64, ) -> Result<usize, SessionError>
Flush the queued RFC2833 digits with an inter-digit gap.
Sourcepub async fn send_packet(
&self,
packet: &RtpPacket,
) -> Result<usize, SessionError>
pub async fn send_packet( &self, packet: &RtpPacket, ) -> Result<usize, SessionError>
Send a raw RTP packet
Sourcepub async fn recv_packet(&self) -> Result<(RtpPacket, SocketAddr), SessionError>
pub async fn recv_packet(&self) -> Result<(RtpPacket, SocketAddr), SessionError>
Receive a single RTP packet
Sourcepub fn decode_packet(
&mut self,
packet: &RtpPacket,
) -> Result<Vec<i16>, SessionError>
pub fn decode_packet( &mut self, packet: &RtpPacket, ) -> Result<Vec<i16>, SessionError>
Decode an RTP packet’s payload to PCM samples
Sourcepub fn silence_frame(&self) -> Vec<u8> ⓘ
pub fn silence_frame(&self) -> Vec<u8> ⓘ
Get a silence frame for this session’s codec
Sourcepub fn start_receiving(
&self,
buffer_size: usize,
) -> (Receiver<Vec<i16>>, Sender<()>)
pub fn start_receiving( &self, buffer_size: usize, ) -> (Receiver<Vec<i16>>, Sender<()>)
Start a receive loop that feeds packets into a jitter buffer and outputs decoded audio
Sourcepub fn start_receiving_events(
&self,
buffer_size: usize,
dtmf_payload_type: Option<u8>,
) -> (Receiver<ReceiveEvent>, Sender<()>)
pub fn start_receiving_events( &self, buffer_size: usize, dtmf_payload_type: Option<u8>, ) -> (Receiver<ReceiveEvent>, Sender<()>)
Start a receive loop that emits both decoded audio and RFC2833 DTMF events.
Sourcepub fn stats(&self) -> SessionStats
pub fn stats(&self) -> SessionStats
Get session statistics
Sourcepub fn codec(&self) -> &CodecPipeline
pub fn codec(&self) -> &CodecPipeline
Get the codec pipeline reference