Bug 1430255 - P3 - update RTPSources timebase, js PeerConnection, mochitests;r?jib,r?mjf draft
authorNico Grunbaum
Sun, 21 Jan 2018 15:31:58 -0800
changeset 723220 9d62220c6e8d2b33b43b020d23012c937c9114f3
parent 723219 c21865cef4276b9d504ea953fc7ee79e9b6a84d3
child 746808 572ab0b1c74ea950cc54bb9e14291a4e6095144b
push id96371
push userna-g@nostrum.com
push dateMon, 22 Jan 2018 19:22:14 +0000
reviewersjib, mjf
bugs1430255
milestone59.0a1
Bug 1430255 - P3 - update RTPSources timebase, js PeerConnection, mochitests;r?jib,r?mjf MozReview-Commit-ID: ClIEk4Yy4Uu
dom/media/PeerConnection.js
dom/media/tests/mochitest/test_peerConnection_audioSynchronizationSources.html
--- 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(),