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.TrackLocal
required
The local track to send
*DTLSTransport
required
The DTLS transport to use for sending
*RTPSender
The newly created RTPSender
error
Returns error if track or 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 sender’s track.RTPSendParameters
The current send parameters including codecs and encodings
Track
Returns the RTPSender’s track, or nil.TrackLocal
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.TrackLocal
The new track to send. Pass nil to stop sending.
error
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.TrackLocal
required
The additional track encoding to add. Must have a RID set.
error
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.RTPSendParameters
required
The send parameters to configure
error
Returns error if Send has already been called or track was removed
Stop
Irreversibly stops the RTPSender.error
Returns error if stopping fails
Read
Reads incoming RTCP for this RTPSender.[]byte
required
Buffer to read RTCP data into
int
Number of bytes read
interceptor.Attributes
Interceptor attributes associated with the RTCP packet
error
Returns error if read fails or sender is stopped
ReadRTCP
A convenience method that wraps Read and unmarshals for you.[]rtcp.Packet
The unmarshaled RTCP packets
interceptor.Attributes
Interceptor attributes
error
Returns error if read or unmarshal fails
ReadSimulcast
Reads incoming RTCP for this RTPSender for given RID.[]byte
required
Buffer to read RTCP data into
string
required
The RTP stream identifier to read RTCP for
ReadSimulcastRTCP
A convenience method that wraps ReadSimulcast and unmarshal for you.string
required
The RTP stream identifier
SetReadDeadline
Sets the deadline for the Read operation. Setting to zero means no deadline.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
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