WebRTC stats should be in milliseconds
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 May 2017 03:27:51 +0000 (03:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 May 2017 03:27:51 +0000 (03:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172644

Patch by Youenn Fablet <youenn@apple.com> on 2017-05-26
Reviewed by Eric Carlson.

Source/WebCore:

Covered by updated tests.

* Modules/mediastream/RTCStatsReport.h:
* Modules/mediastream/RTCStatsReport.idl:
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::fillRTCStats):

LayoutTests:

* TestExpectations:
* webrtc/video-stats.html: Making it less flaky prone.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217519 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/webrtc/video-stats.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCStatsReport.h
Source/WebCore/Modules/mediastream/RTCStatsReport.idl
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp

index 2c9f349..0654eac 100644 (file)
@@ -1,3 +1,13 @@
+2017-05-26  Youenn Fablet  <youenn@apple.com>
+
+        WebRTC stats should be in milliseconds
+        https://bugs.webkit.org/show_bug.cgi?id=172644
+
+        Reviewed by Eric Carlson.
+
+        * TestExpectations:
+        * webrtc/video-stats.html: Making it less flaky prone.
+
 2017-05-26  Sam Weinig  <sam@webkit.org>
 
         [WebIDL] Overloaded functions should throw this object check exception before argument check exception
index 5a333bd..78bf623 100644 (file)
@@ -735,7 +735,6 @@ media/session [ Skip ]
 
 webrtc/negotiatedneeded-event-addStream.html [ Pass Crash ]
 webrtc/video-replace-track.html [ Pass Failure ]
-webrtc/video-stats.html [ Pass Failure ]
 webrtc/video-getParameters.html [ Failure ]
 webrtc/peer-connection-audio-mute2.html [ Pass Failure ]
 webrtc/peer-connection-remote-audio-mute2.html [ Pass Failure ]
index 5bd4e20..6e9d9a9 100644 (file)
@@ -46,6 +46,32 @@ function getOutboundRTPStats(connection)
     });
 }
 
+function checkInboundFramesNumberIncreased(secondConnection, statsSecondConnection, count)
+{
+    return getInboundRTPStats(secondConnection).then((stats) => {
+        if (stats.timestamp > statsSecondConnection.timestamp && stats.framesDecoded > statsSecondConnection.framesDecoded)
+            return;
+        if (++count === 20)
+            return Promise.reject("checking inbound stats frame number increasing timed out");
+        return waitFor(50).then(() => {
+            return checkInboundFramesNumberIncreased(secondConnection, statsSecondConnection, count)
+        });
+    });
+}
+
+function checkOutboundFramesNumberIncreased(firstConnection, statsFirstConnection, count)
+{
+    return getOutboundRTPStats(firstConnection).then((stats) => {
+        if (stats.timestamp > statsFirstConnection.timestamp && stats.framesEncoded > statsFirstConnection.framesEncoded)
+            return;
+        if (++count === 20)
+            return Promise.reject("checking outbound stats frame number increasing timed out");
+        return waitFor(50).then(() => {
+            return checkOutboundFramesNumberIncreased(firstConnection, statsFirstConnection, count)
+        });
+    });
+}
+
 var firstConnection, secondConnection;
 promise_test((test) => {
     if (window.testRunner)
@@ -73,24 +99,21 @@ promise_test((test) => {
         assert_true(!!stats, "outbound-rtp stats should not be null");
         assert_true(Number.isInteger(stats.framesEncoded), "framesEncoded should be an integer");
         assert_true(Number.isInteger(stats.qpSum), "outbound qpSum should be an integer");
+        assert_false(Number.isInteger(stats.timestamp), "timestamp should be a double");
+        assert_true(typeof stats.timestamp === "number", "timestamp should be a double");
         statsFirstConnection = stats;
         return getInboundRTPStats(secondConnection);
     }).then((stats) => {
         assert_true(!!stats, "inbound-rtp stats should not be null");
         assert_true(Number.isInteger(stats.framesDecoded), "framesDecoded should be an integer");
         assert_true(Number.isInteger(stats.qpSum), "inbound qpSum should be an integer");
+        assert_false(Number.isInteger(stats.timestamp), "timestamp should be a double");
+        assert_true(typeof stats.timestamp === "number", "timestamp should be a double");
         statsSecondConnection = stats;
-        return waitFor(300);
     }).then(() => {
-        return getOutboundRTPStats(firstConnection);
-    }).then((stats) => {
-        assert_true(stats.timestamp > statsFirstConnection.timestamp, "Timestamp for first connection should have increased");
-        assert_true(stats.framesEncoded > statsFirstConnection.framesEncoded, "Number of encoded frames should have increased");
-
-        return getInboundRTPStats(secondConnection);
-    }).then((stats) => {
-        assert_true(stats.timestamp > statsSecondConnection.timestamp, "Timestamp for second connection should have increased");
-        assert_true(stats.framesDecoded > statsSecondConnection.framesDecoded, "Number of decoded frames should have increased");
+        return checkInboundFramesNumberIncreased(secondConnection, statsSecondConnection, 0);
+    }).then(() => {
+        return checkOutboundFramesNumberIncreased(firstConnection, statsFirstConnection, 0);
     });
 }, "Basic video stats");
         </script>
index 02226e5..31a4cd5 100644 (file)
@@ -1,3 +1,17 @@
+2017-05-26  Youenn Fablet  <youenn@apple.com>
+
+        WebRTC stats should be in milliseconds
+        https://bugs.webkit.org/show_bug.cgi?id=172644
+
+        Reviewed by Eric Carlson.
+
+        Covered by updated tests.
+
+        * Modules/mediastream/RTCStatsReport.h:
+        * Modules/mediastream/RTCStatsReport.idl:
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::fillRTCStats):
+
 2017-05-26  Sam Weinig  <sam@webkit.org>
 
         [WebIDL] Overloaded functions should throw this object check exception before argument check exception
index 0b31217..ff84f1e 100644 (file)
@@ -53,7 +53,7 @@ public:
         Certificate
     };
     struct Stats {
-        unsigned long long timestamp;
+        double timestamp;
         Type type;
         String id;
     };
index 5ce6258..144fbfb 100644 (file)
@@ -45,9 +45,10 @@ enum RTCStatsType {
     "certificate"
 };
 
+typedef double DOMHighResTimeStamp;
+
 dictionary RTCStats {
-    // FIXME 169662: change type to DOMHighResTimeStamp
-    unsigned long long timestamp;
+    DOMHighResTimeStamp timestamp;
     RTCStatsType type;
     DOMString id;
 
index 285cae0..d2923d3 100644 (file)
@@ -239,7 +239,7 @@ static inline String fromStdString(const std::string& value)
 
 static inline void fillRTCStats(RTCStatsReport::Stats& stats, const webrtc::RTCStats& rtcStats)
 {
-    stats.timestamp = rtcStats.timestamp_us();
+    stats.timestamp = rtcStats.timestamp_us() / 1000.0;
     stats.id = fromStdString(rtcStats.id());
 }