Skip to content

Commit

Permalink
Add check for getSynchronizationSources support (#1136)
Browse files Browse the repository at this point in the history
* Add check for getSynchronizationSources support

* Create long-trees-rule.md
  • Loading branch information
lukasIO authored May 15, 2024
1 parent 760af83 commit a5c3afb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/long-trees-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Add check for getSynchronizationSources support
5 changes: 4 additions & 1 deletion src/room/track/RemoteTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TrackEvent } from '../events';
import { monitorFrequency } from '../stats';
import type { LoggerOptions } from '../types';
import { Track } from './Track';
import { supportsSynchronizationSources } from './utils';

export default abstract class RemoteTrack<
TrackKind extends Track.Kind = Track.Kind,
Expand Down Expand Up @@ -77,7 +78,9 @@ export default abstract class RemoteTrack<
if (!this.monitorInterval) {
this.monitorInterval = setInterval(() => this.monitorReceiver(), monitorFrequency);
}
this.registerTimeSyncUpdate();
if (supportsSynchronizationSources()) {
this.registerTimeSyncUpdate();
}
}

protected abstract monitorReceiver(): void;
Expand Down
4 changes: 4 additions & 0 deletions src/room/track/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,7 @@ export function getLogContextFromTrack(track: Track | TrackPublication): Record<
};
}
}

export function supportsSynchronizationSources(): boolean {
return typeof RTCRtpReceiver !== 'undefined' && 'getSynchronizationSources' in RTCRtpReceiver;
}

0 comments on commit a5c3afb

Please sign in to comment.