Overview
TrackLocal is an interface that controls how the user can send media. The user can provide their own TrackLocal implementations, or use the implementations provided in the library.Interface Definition
Methods
Bind
Implements the way media data flows from the Track to the PeerConnection. This is called internally after signaling is complete and the list of available codecs has been determined.TrackLocalContext
required
The context containing negotiated parameters, SSRCs, and write stream
RTPCodecParameters
The selected codec parameters to use for this track
error
Returns error if binding fails
Unbind
Implements the teardown logic when the track is no longer needed. This happens because a track has been stopped.TrackLocalContext
required
The context that was previously bound
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
Returns the RTP Stream ID for this track. Used for simulcast scenarios where multiple tracks share the same ID but have different RIDs.string
The RTP stream identifier, or empty string if not set
StreamID
Returns the group this track belongs to. This must be unique.string
The stream identifier
Kind
Returns whether this TrackLocal is audio or video.RTPCodecType
Either RTPCodecTypeAudio or RTPCodecTypeVideo
TrackLocalContext
The context passed when a TrackLocal has been bound/unbound from a PeerConnection.TrackLocalWriter
The Writer interface for outbound RTP Packets.Built-in Implementations
Pion WebRTC provides several built-in TrackLocal implementations:Usage Examples
Creating a Video Track
Creating an Audio Track
Writing Media Samples
Simulcast with RIDs
Using TrackLocalStaticRTP
Custom TrackLocal Implementation
See Also
- RTPSender - Manages outbound RTP streams
- TrackRemote - Remote media track
- MediaEngine - Codec configuration