Skip to main content

Overview

RTPReceiver allows an application to inspect the receipt of a TrackRemote. It manages inbound RTP streams including demuxing, RTCP feedback, and support for simulcast and RTX.

Type Definition

Constructor

NewRTPReceiver

Constructs a new RTPReceiver.
RTPCodecType
required
The codec type (audio or video)
*DTLSTransport
required
The DTLS transport to use for receiving
*RTPReceiver
The newly created RTPReceiver
error
Returns error if transport is nil

Methods

Transport

Returns the currently-configured DTLSTransport or nil if one has not yet been configured.
*DTLSTransport
The associated DTLS transport

GetParameters

Describes the current configuration for the encoding and transmission of media on the receiver’s track.
RTPParameters
The current receive parameters including codecs and header extensions

Track

Returns the RTPReceiver’s TrackRemote.
*TrackRemote
The remote track, or nil if there are multiple tracks (simulcast)
For simulcast streams with multiple tracks, use the Tracks() method instead.

Tracks

Returns the RTPReceiver tracks. An RTPReceiver may have multiple tracks to support Simulcast.
[]*TrackRemote
All remote tracks associated with this receiver

RTPTransceiver

Returns the RTPTransceiver this RTPReceiver belongs to, or nil if none.
*RTPTransceiver
The associated transceiver

Receive

Initializes the track and starts all the transports.
RTPReceiveParameters
required
The receive parameters to configure
error
Returns error if:
  • Receive already called
  • Track stream not found for SSRC
  • Stream initialization fails

Read

Reads incoming RTCP for this RTPReceiver.
[]byte
required
Buffer to read RTCP data into
int
Number of bytes read
interceptor.Attributes
Interceptor attributes associated with the packet
error
Returns error if read fails or receiver is closed
If the receiver has multiple tracks (simulcast), this method will log an error recommending to use ReadSimulcast instead.

ReadRTCP

A convenience method that wraps Read and unmarshal for you. It also runs any configured interceptors.
[]rtcp.Packet
The unmarshaled RTCP packets
interceptor.Attributes
Interceptor attributes
error
Returns error if read or unmarshal fails

ReadSimulcast

Reads incoming RTCP for this RTPReceiver for given RID.
[]byte
required
Buffer to read RTCP data into
string
required
The RTP stream identifier to read RTCP for
error
Returns error if track stream not found for RID

ReadSimulcastRTCP

A convenience method that wraps ReadSimulcast and unmarshal for you.
string
required
The RTP stream identifier

Stop

Irreversibly stops the RTPReceiver.
error
Returns error if stopping fails
Stopping a receiver closes all associated RTP and RTCP streams and unbinds all interceptors.

SetReadDeadline

Sets the max amount of time the RTCP stream will block before returning. 0 is forever.
time.Time
required
The deadline time. Zero value means no deadline.

SetReadDeadlineSimulcast

Sets the max amount of time the RTCP stream for a given RID will block before returning. 0 is forever.
time.Time
required
The deadline time
string
required
The RTP stream identifier
error
Returns error if track stream not found for RID

Usage Examples

Handling Incoming Tracks

Reading RTCP Feedback

Handling Simulcast Tracks

Using RTX (Retransmission)

See Also