Skip to content

Commit

Permalink
Add timestamp to exp timeSyncUpdate (#1126)
Browse files Browse the repository at this point in the history
* Add timestamp to exp timeSyncUpdate

* Create loud-fireants-hammer.md
  • Loading branch information
lukasIO authored May 6, 2024
1 parent 3bcfee8 commit fdfb7b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-fireants-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Add timestamp to exp timeSyncUpdate
11 changes: 7 additions & 4 deletions src/room/track/RemoteTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/room/track/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,5 +525,5 @@ export type TrackEventCallbacks = {
upstreamResumed: (track: any) => void;
trackProcessorUpdate: (processor?: TrackProcessor<Track.Kind, any>) => void;
audioTrackFeatureUpdate: (track: any, feature: AudioTrackFeature, enabled: boolean) => void;
timeSyncUpdate: (timestamp: number) => void;
timeSyncUpdate: (update: { timestamp: number; rtpTimestamp: number }) => void;
};

0 comments on commit fdfb7b3

Please sign in to comment.