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.
type TrackLocal interface { // Bind implements the way media data flows from Track to PeerConnection Bind(TrackLocalContext) (RTPCodecParameters, error) // Unbind implements teardown logic when track is no longer needed Unbind(TrackLocalContext) error // ID is the unique identifier for this Track ID() string // RID is the RTP Stream ID for this track RID() string // StreamID is the group this track belongs to StreamID() string // Kind controls if this TrackLocal is audio or video Kind() RTPCodecType}
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.
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’.
The context passed when a TrackLocal has been bound/unbound from a PeerConnection.
type TrackLocalContext interface { // CodecParameters returns negotiated RTPCodecParameters CodecParameters() []RTPCodecParameters // HeaderExtensions returns negotiated RTPHeaderExtensionParameters HeaderExtensions() []RTPHeaderExtensionParameter // SSRC returns the negotiated SSRC SSRC() SSRC // SSRCRetransmission returns the negotiated retransmission SSRC SSRCRetransmission() SSRC // SSRCForwardErrorCorrection returns the negotiated FEC SSRC SSRCForwardErrorCorrection() SSRC // WriteStream returns the WriteStream for this TrackLocal WriteStream() TrackLocalWriter // ID is a unique identifier used for both Bind/Unbind ID() string // RTCPReader returns the RTCP interceptor for this TrackLocal RTCPReader() interceptor.RTCPReader}
type TrackLocalWriter interface { // WriteRTP encrypts an RTP packet and writes to the connection WriteRTP(header *rtp.Header, payload []byte) (int, error) // Write encrypts and writes a full RTP packet Write(b []byte) (int, error)}