Overview
RTPSender allows an application to control how a given Track is encoded and transmitted to a remote peer. It manages the outbound RTP stream including encoding parameters, SSRC assignment, and RTCP feedback.Type Definition
Constructor
NewRTPSender
Constructs a new RTPSender.The local track to send
The DTLS transport to use for sending
The newly created RTPSender
Returns error if track or transport is nil
Methods
Transport
Returns the currently-configured DTLSTransport or nil if one has not yet been configured.The associated DTLS transport
GetParameters
Describes the current configuration for the encoding and transmission of media on the sender’s track.The current send parameters including codecs and encodings
Track
Returns the RTPSender’s track, or nil.The local track being sent, or nil
ReplaceTrack
Replaces the track currently being used as the sender’s source with a new TrackLocal. The new track must be of the same media kind (audio, video, etc) and switching the track should not require negotiation.The new track to send. Pass nil to stop sending.
Returns error if:
- New track has incorrect kind
- New track has incorrect envelope (simulcast)
- Track binding fails
AddEncoding
Adds an encoding to RTPSender. Used by simulcast senders.The additional track encoding to add. Must have a RID set.
Returns error if:
- Track is nil
- Track RID is empty
- Sender is stopped
- Send already called
- No base encoding exists
- Track properties don’t match base encoding
- RID collision detected
AddEncoding is used for simulcast streaming where multiple encodings of the same track are sent with different quality levels.
Send
Attempts to set the parameters controlling the sending of media.The send parameters to configure
Returns error if Send has already been called or track was removed
Stop
Irreversibly stops the RTPSender.Returns error if stopping fails
Read
Reads incoming RTCP for this RTPSender.Buffer to read RTCP data into
Number of bytes read
Interceptor attributes associated with the RTCP packet
Returns error if read fails or sender is stopped
ReadRTCP
A convenience method that wraps Read and unmarshals for you.The unmarshaled RTCP packets
Interceptor attributes
Returns error if read or unmarshal fails
ReadSimulcast
Reads incoming RTCP for this RTPSender for given RID.Buffer to read RTCP data into
The RTP stream identifier to read RTCP for
ReadSimulcastRTCP
A convenience method that wraps ReadSimulcast and unmarshal for you.The RTP stream identifier
SetReadDeadline
Sets the deadline for the Read operation. Setting to zero means no deadline.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.The deadline time
The RTP stream identifier
Usage Examples
Creating and Using an RTPSender
Simulcast Sending
See Also
- RTPReceiver - Manages inbound RTP streams
- RTPTransceiver - Combines sender and receiver
- TrackLocal - Local media track interface