Skip to main content

Overview

The JitsiRemoteTrack class represents a single remote media track (either audio or video) received from another participant in the conference.

Constructor

constructor(
  rtc: RTC,
  conference: JitsiConference,
  ownerEndpointId: string,
  stream: MediaStream,
  track: MediaStreamTrack,
  mediaType: MediaType,
  videoType: VideoType,
  ssrc: number,
  muted: boolean,
  isP2P: boolean,
  sourceName: string
)
rtc
RTC
required
The RTC service instance
conference
JitsiConference
required
The conference to which this track belongs
ownerEndpointId
string
required
The endpoint ID of the track owner
stream
MediaStream
required
WebRTC MediaStream, parent of the track
track
MediaStreamTrack
required
Underlying WebRTC MediaStreamTrack
mediaType
MediaType
required
The type of the media (‘audio’ or ‘video’)
videoType
VideoType
required
The type of the video (‘camera’ or ‘desktop’)
ssrc
number
required
The SSRC number of the Media Stream
muted
boolean
required
The initial muted state
isP2P
boolean
required
Indicates whether this track belongs to a P2P session
sourceName
string
required
The source name signaled for the track

Methods

dispose()

Removes attached event listeners and disposes the track streaming status.
dispose(): Promise<void>
Promise<void>
Promise
Resolves when disposal is complete

setMute()

Sets the current muted status and fires events for the change.
setMute(value: boolean): void
value
boolean
required
The muted status to set

isMuted()

Returns the current muted status of the track.
isMuted(): boolean
muted
boolean
True if the track is muted, false otherwise

getParticipantId()

Returns the participant ID which owns the track.
getParticipantId(): string
participantId
string
The ID of the participant (corresponds to Colibri endpoint ID/MUC nickname)

getSsrc()

Returns the synchronization source identifier (SSRC) of this remote track.
getSsrc(): number
ssrc
number
The SSRC of this remote track

getSourceName()

Returns the track’s source name.
getSourceName(): string
sourceName
string
The source name identifier

setOwner()

Updates the properties when the track is remapped to another source.
setOwner(owner: string): void
owner
string
required
The endpoint ID of the new owner

setSourceName()

Sets the name of the source associated with the remote track.
setSourceName(name: string): void
name
string
required
The source name to be associated with the track

getTrackStreamingStatus()

Returns the track’s streaming status.
getTrackStreamingStatus(): TrackStreamingStatus | null
status
TrackStreamingStatus | null
The streaming status of the track, or null if not initialized. Possible values:
  • ACTIVE - Track is actively receiving media
  • INACTIVE - Track is not receiving media
  • RESTORING - Track is in the process of restoring
  • INTERRUPTED - Track streaming was interrupted

toString()

Creates a text representation of this remote track instance.
toString(): string
string
string
String representation including user ID, type, SSRC, P2P status, source name, and track status

Internal Methods

The following methods are marked as internal and are primarily used by the library itself.

_setVideoType()

Changes the video type of the track.
_setVideoType(type: VideoType): void
type
VideoType
required
The new video type (‘camera’ or ‘desktop’)

_setTrackStreamingStatus()

Updates the track’s streaming status.
_setTrackStreamingStatus(status: TrackStreamingStatus): void
status
TrackStreamingStatus
required
The current track streaming state

_setEnteredForwardedSourcesTimestamp()

Updates the timestamp of when the track entered forwarded sources.
_setEnteredForwardedSourcesTimestamp(timestamp: number): void
timestamp
number
required
The time in milliseconds

_getEnteredForwardedSourcesTimestamp()

Returns the timestamp of when the track entered forwarded sources.
_getEnteredForwardedSourcesTimestamp(): number | null
timestamp
number | null
The time in milliseconds or null

_clearEnteredForwardedSourcesTimestamp()

Clears the timestamp of when the track entered forwarded sources.
_clearEnteredForwardedSourcesTimestamp(): void

Properties

ownerEndpointId
string
The endpoint ID of the participant who owns this track
isP2P
boolean
Indicates whether this track belongs to a peer-to-peer session
rtcId
string | null
The RTC identifier for this track

Events

JitsiRemoteTrack extends JitsiTrack and emits additional events:
  • TRACK_MUTE_CHANGED - Fired when the mute status changes
  • TRACK_VIDEOTYPE_CHANGED - Fired when the video type changes
  • TRACK_STREAMING_STATUS_CHANGED - Fired when the streaming status changes
  • REMOTE_TRACK_MUTE - Fired when the remote track is muted
  • REMOTE_TRACK_UNMUTE - Fired when the remote track is unmuted

Track Streaming Status

The TrackStreamingStatus indicates the current state of media reception:
  • ACTIVE - Track is actively receiving media data
  • INACTIVE - Track is not receiving media data
  • RESTORING - Track entered forwarded sources and is attempting to restore
  • INTERRUPTED - Track streaming was interrupted (no data received within timeout)

Example Usage

// Listen for streaming status changes
remoteTrack.addEventListener(
  JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED,
  (track, status) => {
    console.log(`Track ${track.getParticipantId()} status: ${status}`);
  }
);

// Check if track is muted
if (remoteTrack.isMuted()) {
  console.log('Remote track is muted');
}

// Get track information
const participantId = remoteTrack.getParticipantId();
const ssrc = remoteTrack.getSsrc();
const sourceName = remoteTrack.getSourceName();

// Attach to video element
const videoElement = document.getElementById('remote-video');
await remoteTrack.attach(videoElement);

Build docs developers (and LLMs) love