Expand description
RTP Media API
This module provides the RTCRtpTransceiver, which represents a permanent pairing
of an RTCRtpSender and an RTCRtpReceiver,
along with shared state.
§Overview
A transceiver manages bidirectional media exchange for a single media type (audio or video). It combines:
- An RTP sender for outgoing media
- An RTP receiver for incoming media
- Shared state including direction, mid, and codec preferences
§Examples
§Adding a transceiver from a track
let mut peer_connection = RTCPeerConnectionBuilder::new().build()?;
// Add a transceiver for sending audio
let init = RTCRtpTransceiverInit {
direction: RTCRtpTransceiverDirection::Sendrecv,
..Default::default()
};
let sender_id = peer_connection
.add_transceiver_from_track(audio_track, Some(init))?;
println!("Added sender with ID: {:?}", sender_id);§Adding a transceiver by media kind
let mut peer_connection = RTCPeerConnectionBuilder::new().build()?;
// Add a video transceiver for receiving only
let init = RTCRtpTransceiverInit {
direction: RTCRtpTransceiverDirection::Recvonly,
..Default::default()
};
let receiver_id = peer_connection
.add_transceiver_from_kind(RtpCodecKind::Video, Some(init))?;
println!("Added receiver with ID: {:?}", receiver_id);§Controlling transceiver direction
let mut peer_connection = RTCPeerConnectionBuilder::new().build()?;
// Iterate through transceivers and change direction
for transceiver_id in peer_connection.get_transceivers() {
// Access the transceiver through peer_connection's internal methods
// Note: Direct transceiver access may be internal API
// This demonstrates the concept - actual usage depends on your API design
}§Setting codec preferences
let mut peer_connection = RTCPeerConnectionBuilder::new().build()?;
// Codec preferences would be set through peer connection methods
// The exact API depends on your implementation§Specification
See RTCRtpTransceiver in the W3C WebRTC specification.
Modules§
- rtp_
receiver - RTP Receiver implementation following the W3C WebRTC specification.
- rtp_
sender - RTP sender module providing WebRTC RTPSender functionality.
Structs§
- RTCRtp
Receiver Id - Identifier for an
RTCRtpReceiverwithin a peer connection. - RTCRtp
Sender Id - Identifier for an
RTCRtpSenderwithin a peer connection. - RTCRtp
Transceiver Init - Initialization parameters for creating an
RTCRtpTransceiver.
Enums§
- RTCRtp
Transceiver Direction - Direction of media flow for an RTP transceiver.
Type Aliases§
- Payload
Type - RTP payload type identifier.
- RTCRtp
Transceiver Id - Internal identifier for an RTP transceiver.
- Repaired
Stream Id - Repaired RTP stream identifier.
- RtpStream
Id - RTP stream identifier.
- SSRC
- SSRC (Synchronization Source) identifier.