Skip to main content

Module rtp_transceiver

Module rtp_transceiver 

Source
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§

RTCRtpReceiverId
Identifier for an RTCRtpReceiver within a peer connection.
RTCRtpSenderId
Identifier for an RTCRtpSender within a peer connection.
RTCRtpTransceiverInit
Initialization parameters for creating an RTCRtpTransceiver.

Enums§

RTCRtpTransceiverDirection
Direction of media flow for an RTP transceiver.

Type Aliases§

PayloadType
RTP payload type identifier.
RTCRtpTransceiverId
Internal identifier for an RTP transceiver.
RepairedStreamId
Repaired RTP stream identifier.
RtpStreamId
RTP stream identifier.
SSRC
SSRC (Synchronization Source) identifier.