diff --git a/.changeset/loud-fireants-hammer.md b/.changeset/loud-fireants-hammer.md new file mode 100644 index 0000000000..f5bebb59f3 --- /dev/null +++ b/.changeset/loud-fireants-hammer.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Add timestamp to exp timeSyncUpdate diff --git a/src/room/track/RemoteTrack.ts b/src/room/track/RemoteTrack.ts index c5720148f2..d307e68503 100644 --- a/src/room/track/RemoteTrack.ts +++ b/src/room/track/RemoteTrack.ts @@ -85,10 +85,13 @@ export default abstract class RemoteTrack< registerTimeSyncUpdate() { const loop = () => { this.timeSyncHandle = requestAnimationFrame(() => loop()); - const newTime = this.receiver?.getSynchronizationSources()[0]?.rtpTimestamp; - if (newTime && this.rtpTimestamp !== newTime) { - this.emit(TrackEvent.TimeSyncUpdate, newTime); - this.rtpTimestamp = newTime; + const sources = this.receiver?.getSynchronizationSources()[0]; + if (sources) { + const { timestamp, rtpTimestamp } = sources; + if (rtpTimestamp && this.rtpTimestamp !== rtpTimestamp) { + this.emit(TrackEvent.TimeSyncUpdate, { timestamp, rtpTimestamp }); + this.rtpTimestamp = rtpTimestamp; + } } }; loop(); diff --git a/src/room/track/Track.ts b/src/room/track/Track.ts index 62ff9782b5..881ac9faf1 100644 --- a/src/room/track/Track.ts +++ b/src/room/track/Track.ts @@ -525,5 +525,5 @@ export type TrackEventCallbacks = { upstreamResumed: (track: any) => void; trackProcessorUpdate: (processor?: TrackProcessor) => void; audioTrackFeatureUpdate: (track: any, feature: AudioTrackFeature, enabled: boolean) => void; - timeSyncUpdate: (timestamp: number) => void; + timeSyncUpdate: (update: { timestamp: number; rtpTimestamp: number }) => void; };