Overview
TheJitsiLocalTrack class represents a single local media track (either audio or video). One JitsiLocalTrack corresponds to one WebRTC MediaStreamTrack captured from the user’s device.
Constructor
ITrackInfo
required
Object containing track configuration:
constraints: The constraints used for creating the trackrtcId: The ID assigned by the RTC modulestream: The WebRTC MediaStream (parent of the track)track: The underlying WebRTC MediaStreamTrackmediaType: The MediaType (‘audio’ or ‘video’)videoType: The VideoType (‘camera’ or ‘desktop’)effects: Array of effects to be applieddeviceId: The ID of the local devicefacingMode: The camera facing mode (mobile only)sourceId: The Chrome media source ID for desktop sharingsourceType: The type of source the track originates from
Methods
mute()
Asynchronously mutes this track.Promise
Resolves when the track is successfully muted
unmute()
Asynchronously unmutes this track.Promise
Resolves when the track is successfully unmuted
dispose()
Stops sending the media track and removes it from the HTML.Promise
Resolves when disposal is complete
isLocal()
Returns true for local tracks.boolean
Always returns true
isMuted()
Checks if the stream is muted.boolean
True if the stream is muted, false otherwise
isEnded()
Returns if the associated MediaStreamTrack is in the ‘ended’ state.boolean
True if the track has ended
isReceivingData()
Checks whether the attached MediaStream is receiving data from source.boolean
True if the stream is receiving data, false otherwise
getCameraFacingMode()
Returns the camera facing mode for video tracks from camera.CameraFacingMode | undefined
‘user’ or ‘environment’ for camera tracks, undefined for other types
getCaptureResolution()
Returns the capture resolution of the video track.number
The capture resolution in pixels
getDeviceId()
Returns the device ID associated with the track.string
The device identifier
getDuration()
Returns the duration of the track.number
The duration of the track in seconds
getParticipantId()
Returns the participant ID which owns the track.string
The ID of the participant (corresponds to Colibri endpoint ID/MUC nickname)
getSourceName()
Returns the source name associated with the track.string | null
The source name identifier
getSsrc()
Returns the primary SSRC associated with the track.number | null
The synchronization source identifier
setConference()
Sets the JitsiConference object associated with the track.JitsiConference
required
The JitsiConference object to associate with the track
setEffect()
Sets the effect and switches between the modified stream and original one.IStreamEffect
The effect instance to be used. Pass undefined to remove the current effect
Promise
Resolves when the effect is successfully applied
setSourceName()
Sets the source name to be used for signaling the track.string
required
The source name to assign
setSsrc()
Sets the primary SSRC for the track.number
required
The SSRC to assign to the track
stopStream()
Stops the associated MediaStream.toString()
Creates a text representation of this local track instance.string
String representation in format: LocalTrack[rtcId,mediaType]
applyConstraints()
Applies media constraints to the current MediaStreamTrack.IAudioConstraints
required
Media constraints to apply:
autoGainControl: Enable/disable automatic gain controlechoCancellation: Enable/disable echo cancellationnoiseSuppression: Enable/disable noise suppressionchannelCount: Number of audio channels
Promise
Resolves when constraints are successfully applied
onByteSentStatsReceived()
Handles bytes sent statistics (used only for audio tracks to detect audio issues).TraceablePeerConnection
required
The peer connection reporting the bytes sent stat
number
required
The new bytes sent value
Properties
number
The ID assigned by the RTC module on instance creation
string
The ID of the local device for this track
string | undefined
The Chrome media source ID for desktop sharing tracks
string | undefined
The type of source the track originates from
number | undefined
The capture resolution for video tracks
number | undefined
The maximum enabled resolution for video tracks
ITrackMetadata
Track metadata including timestamp and display surface information
Events
JitsiLocalTrack extends JitsiTrack and emits additional events:LOCAL_TRACK_STOPPED- Fired when the track stopsTRACK_MUTE_CHANGED- Fired when the mute status changesNO_DATA_FROM_SOURCE- Fired when no data is received from the sourceNO_AUDIO_INPUT- Fired when no audio input is detected