Title: [214348] trunk
Revision
214348
Author
[email protected]
Date
2017-03-24 09:25:09 -0700 (Fri, 24 Mar 2017)

Log Message

Fix framesEncoded/framesDecoded RTC stats
https://bugs.webkit.org/show_bug.cgi?id=170024

Patch by Youenn Fablet <[email protected]> on 2017-03-24
Reviewed by Eric Carlson.

Source/WebCore:

Test: webrtc/video-stats.html

Adding access to these fields now that they are available.

* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::fillInboundRTPStreamStats):
(WebCore::fillOutboundRTPStreamStats):

LayoutTests:

* webrtc/video-stats-expected.txt: Added.
* webrtc/video-stats.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (214347 => 214348)


--- trunk/LayoutTests/ChangeLog	2017-03-24 14:55:59 UTC (rev 214347)
+++ trunk/LayoutTests/ChangeLog	2017-03-24 16:25:09 UTC (rev 214348)
@@ -1,3 +1,13 @@
+2017-03-24  Youenn Fablet  <[email protected]>
+
+        Fix framesEncoded/framesDecoded RTC stats
+        https://bugs.webkit.org/show_bug.cgi?id=170024
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/video-stats-expected.txt: Added.
+        * webrtc/video-stats.html: Added.
+
 2017-03-24  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed GTK+ gardening. Mark media/video-load-require-user-gesture.html as failing after r214338.

Added: trunk/LayoutTests/webrtc/video-stats-expected.txt (0 => 214348)


--- trunk/LayoutTests/webrtc/video-stats-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/video-stats-expected.txt	2017-03-24 16:25:09 UTC (rev 214348)
@@ -0,0 +1,3 @@
+
+PASS Basic video stats 
+

Added: trunk/LayoutTests/webrtc/video-stats.html (0 => 214348)


--- trunk/LayoutTests/webrtc/video-stats.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/video-stats.html	2017-03-24 16:25:09 UTC (rev 214348)
@@ -0,0 +1,100 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing basic video exchange from offerer to receiver</title>
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <script src =""
+        <script>
+
+function getInboundRTPStats(connection)
+{
+    return connection.getStats().then((report) => {
+        var stats;
+        report.forEach((statItem) => {
+            if (statItem.type === "inbound-rtp") {
+                stats = statItem;
+            }
+        });
+        return stats;
+    });
+}
+
+function getOutboundRTPStats(connection)
+{
+    return connection.getStats().then((report) => {
+        var stats;
+        report.forEach((statItem) => {
+            if (statItem.type === "outbound-rtp") {
+                stats = statItem;
+            }
+        });
+        return stats;
+    });
+}
+
+function testStatsTwice(firstConnection, secondConnection)
+{
+    return Promise.all([
+        firstConnection.getStats().then((report) => {
+            firstReportB = report;
+        }),
+        secondConnection.getStats().then((report) => {
+            secondReportB = report;
+        })
+    ]);
+}
+
+var firstConnection, secondConnection;
+promise_test((test) => {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    var localStream, remoteStream;
+    return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
+        localStream = stream;
+        return new Promise((resolve, reject) => {
+            if (window.internals)
+                internals.useMockRTCPeerConnectionFactory("TwoRealPeerConnections");
+
+            createConnections((connection) => {
+                firstConnection = connection;
+                firstConnection.addTrack(stream.getVideoTracks()[0], stream);
+            }, (connection) => {
+                secondConnection = connection;
+                secondConnection._ontrack_ = (trackEvent) => {
+                    remoteStream = trackEvent.streams[0];
+                    resolve();
+                };
+            });
+            setTimeout(() => reject("Test timed out"), 5000);
+        });
+    }).then(() => {
+        return getOutboundRTPStats(firstConnection);
+    }).then((stats) => {
+        assert_true(!!stats, "outbound-rtp stats should not be null");
+        assert_true(Number.isInteger(stats.framesEncoded), "framesEncoded should be an integer");
+        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");
+        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");
+    });
+}, "Basic video stats");
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (214347 => 214348)


--- trunk/Source/WebCore/ChangeLog	2017-03-24 14:55:59 UTC (rev 214347)
+++ trunk/Source/WebCore/ChangeLog	2017-03-24 16:25:09 UTC (rev 214348)
@@ -1,3 +1,18 @@
+2017-03-24  Youenn Fablet  <[email protected]>
+
+        Fix framesEncoded/framesDecoded RTC stats
+        https://bugs.webkit.org/show_bug.cgi?id=170024
+
+        Reviewed by Eric Carlson.
+
+        Test: webrtc/video-stats.html
+
+        Adding access to these fields now that they are available.
+
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::fillInboundRTPStreamStats):
+        (WebCore::fillOutboundRTPStreamStats):
+
 2017-03-24  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix GTK+ test /webkit2/WebKitWebView/default-menu after r214244.

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (214347 => 214348)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-03-24 14:55:59 UTC (rev 214347)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-03-24 16:25:09 UTC (rev 214348)
@@ -305,8 +305,8 @@
         stats.gapLossRate = *rtcStats.gap_loss_rate;
     if (rtcStats.gap_discard_rate.is_defined())
         stats.gapDiscardRate = *rtcStats.gap_discard_rate;
-    // FIXME: Set framesDecoded
-    stats.framesDecoded = 0;
+    if (rtcStats.frames_decoded.is_defined())
+        stats.framesDecoded = *rtcStats.frames_decoded;
 }
 
 static inline void fillOutboundRTPStreamStats(RTCStatsReport::OutboundRTPStreamStats& stats, const webrtc::RTCOutboundRTPStreamStats& rtcStats)
@@ -319,8 +319,8 @@
         stats.bytesSent = *rtcStats.bytes_sent;
     if (rtcStats.target_bitrate.is_defined())
         stats.targetBitrate = *rtcStats.target_bitrate;
-    // FIXME: Set framesEncoded
-    stats.framesEncoded = 0;
+    if (rtcStats.frames_encoded.is_defined())
+        stats.framesEncoded = *rtcStats.frames_encoded;
 }
 
 void LibWebRTCMediaEndpoint::StatsCollector::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& rtcReport)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to