Overview
TrackRemote represents a single inbound source of media. It provides methods to read RTP packets, access track metadata, and handle retransmission (RTX) streams.Type Definition
Methods
ID
Returns the unique identifier for this Track. This should be unique for the stream, but doesn’t have to be globally unique. A common example would be ‘audio’ or ‘video’ and StreamID would be ‘desktop’ or ‘webcam’.string
The track identifier
RID
Gets the RTP Stream ID of this Track. With Simulcast you will have multiple tracks with the same ID, but different RID values. In many cases a TrackRemote will not have an RID, so it is important to assert it is non-zero.string
The RTP stream identifier, or empty string if not set
PayloadType
Gets the PayloadType of the track.PayloadType
The RTP payload type number
Kind
Gets the Kind of the track (audio or video).RTPCodecType
Either RTPCodecTypeAudio or RTPCodecTypeVideo
StreamID
Returns the group this track belongs to. This must be unique.string
The stream identifier
SSRC
Gets the SSRC of the track.SSRC
The synchronization source identifier
Msid
Gets the Msid (Media Stream ID) of the track.string
The media stream ID in format “streamID trackID”
Codec
Gets the Codec of the track.RTPCodecParameters
The codec parameters including mime type, clock rate, and format parameters
Read
Reads data from the track.[]byte
required
Buffer to read RTP packet data into
int
Number of bytes read
interceptor.Attributes
Interceptor attributes associated with the packet
error
Returns io.EOF if receiver is closed, or other errors on read failure
This method automatically handles RTX (retransmission) packets if available, transparently merging them into the main stream.
ReadRTP
A convenience method that wraps Read and unmarshals for you.*rtp.Packet
The unmarshaled RTP packet
interceptor.Attributes
Interceptor attributes
error
Returns error if read or unmarshal fails
SetReadDeadline
Sets the max amount of time the RTP stream will block before returning. 0 is forever.time.Time
required
The deadline time. Zero value means no deadline.
error
Returns error if setting the deadline fails
RtxSSRC
Returns the RTX SSRC for a track, or 0 if track does not have a separate RTX stream.SSRC
The RTX synchronization source identifier, or 0 if RTX is not enabled
HasRTX
Returns true if the track has a separate RTX stream.bool
True if RTX is enabled for this track
Usage Examples
Basic Track Handling
Saving Track to File
Handling Simulcast Tracks
Checking RTX Support
Setting Read Timeout
Forwarding Track to Another Peer
See Also
- RTPReceiver - Manages inbound RTP streams
- TrackLocal - Local media track interface
- RTPTransceiver - Combines sender and receiver