Bug 1430255 - P3 - update RTPSources timebase, js PeerConnection, mochitests;r?jib,r?mjf
MozReview-Commit-ID: ClIEk4Yy4Uu
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -1269,17 +1269,17 @@ class RTCPeerConnection {
Promise.resolve().then(() => {
this._rtpSourceCache = new RTCRtpSourceCache();
});
}
// Fetch the RTP source local time, store it for reuse, calculate
// the local offset, likewise store it for reuse.
if (cache.tsNowInRtpSourceTime !== undefined) {
cache.tsNowInRtpSourceTime = this._impl.getNowInRtpSourceReferenceTime();
- cache.jsTimestamp = new Date().getTime();
+ cache.jsTimestamp = this._win.performance.now() + this._win.performance.timeOrigin;
cache.timestampOffset = cache.jsTimestamp - cache.tsNowInRtpSourceTime;
}
let id = receiver.track.id;
if (cache.rtpSourcesByTrackId[id] === undefined) {
cache.rtpSourcesByTrackId[id] =
this._impl.getRtpSources(receiver.track, cache.tsNowInRtpSourceTime);
}
return {
--- a/dom/media/tests/mochitest/test_peerConnection_audioSynchronizationSources.html
+++ b/dom/media/tests/mochitest/test_peerConnection_audioSynchronizationSources.html
@@ -36,18 +36,20 @@
is(syncSources.length, 1, "Each receiver has only a single sync source");
let source = recv.getSynchronizationSources()[0];
ok(source.audioLevel,
`Synchronization source has audio level. (${source.audioLevel})`);
ok(source.audioLevel < 128,
`Synchronization source audio level < 128. (${source.audioLevel})`);
ok(source.timestamp,
`Synchronization source has timestamp (${source.timestamp})`);
- ok(Number.isInteger(source.timestamp),
- `Synchronization source timestamp is int (${source.timestamp})`);
+ ok(window.performance.now() + window.performance.timeOrigin -
+ source.timestamp < 250, // This large value is used because sometimes
+ // the testing hardware is very slow
+ `Synchronization source timestamp is close to now`);
is(source.voiceActivityFlag, undefined,
"Synchronization source unsupported voiceActivity is undefined");
}
};
var testSynchronizationSourceCached = async (test) => {
await waitForSyncSources(test);
let receivers = [...test.pcRemote.getReceivers(),