[WebRTC] Add support for freeze/pause receiver stats
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Jun 2020 16:15:08 +0000 (16:15 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Jun 2020 16:15:08 +0000 (16:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=212938
<rdar://problem/64141493>

Reviewed by Eric Carlson.

Source/WebCore:

Covered by updated tests.

Receiver stats are useful to check for freezes.
Let's introduce it in 'track' stats for now, we will later on move all
'receiver' stats to its own object once we fully align with spec.

* Modules/mediastream/RTCStatsReport.h:
* Modules/mediastream/RTCStatsReport.idl:
* Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
(WebCore::fillRTCMediaStreamTrackStats):

LayoutTests:

* webrtc/video-mediastreamtrack-stats.html:

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

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

index 138f9d5..84508de 100644 (file)
@@ -1,3 +1,13 @@
+2020-06-22  Youenn Fablet  <youenn@apple.com>
+
+        [WebRTC] Add support for freeze/pause receiver stats
+        https://bugs.webkit.org/show_bug.cgi?id=212938
+        <rdar://problem/64141493>
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/video-mediastreamtrack-stats.html:
+
 2020-06-22  Jacob Uphoff  <jacob_uphoff@apple.com>
 
         [ macOS iOS ] REGRESSION: fast/mediastream/mediastrea mtrack-video-frameRate-clon e-increasing.html is a flaky failure
index 5494784..18826d1 100644 (file)
@@ -50,7 +50,19 @@ promise_test((test) => {
         stats.id = "id";
         stats.timestamp = 1;
         stats.trackIdentifier = "trackid";
-        assert_equals(JSON.stringify(stats), '{"id":"id","timestamp":1,"type":"track","detached":false,"ended":false,"framesDecoded":0,"framesDropped":0,"framesReceived":0,"remoteSource":true,"trackIdentifier":"trackid"}');
+        assert_equals(stats.type, "track");
+        assert_false(stats.detached);
+        assert_false(stats.ended);
+        assert_equals(stats.framesDecoded, 0);
+        assert_equals(stats.framesDropped, 0);
+        assert_equals(stats.framesReceived, 0);
+        assert_true(stats.remoteSource);
+        assert_equals(stats.trackIdentifier, "trackid");
+        // non standard stats.
+        assert_equals(stats.freezeCount, 0);
+        assert_equals(stats.pauseCount, 0);
+        assert_equals(stats.totalFreezesDuration, 0);
+        assert_equals(stats.totalPausesDuration, 0);
         return waitFor(1000);
     }).then(() => {
         return getTrackStats(secondConnection);
index e3214f2..2990174 100644 (file)
@@ -1,3 +1,22 @@
+2020-06-22  Youenn Fablet  <youenn@apple.com>
+
+        [WebRTC] Add support for freeze/pause receiver stats
+        https://bugs.webkit.org/show_bug.cgi?id=212938
+        <rdar://problem/64141493>
+
+        Reviewed by Eric Carlson.
+
+        Covered by updated tests.
+
+        Receiver stats are useful to check for freezes.
+        Let's introduce it in 'track' stats for now, we will later on move all
+        'receiver' stats to its own object once we fully align with spec.
+
+        * Modules/mediastream/RTCStatsReport.h:
+        * Modules/mediastream/RTCStatsReport.idl:
+        * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
+        (WebCore::fillRTCMediaStreamTrackStats):
+
 2020-06-22  Rob Buis  <rbuis@igalia.com>
 
         Image `crossorigin` mutations should be considered "relevant mutations"
index b86f6c4..51631b7 100644 (file)
@@ -216,6 +216,15 @@ public:
         Optional<double> audioLevel;
         Optional<double> echoReturnLoss;
         Optional<double> echoReturnLossEnhancement;
+
+        Optional<uint32_t> freezeCount;
+        Optional<uint32_t> pauseCount;
+        Optional<double> totalFreezesDuration;
+        Optional<double> totalPausesDuration;
+        Optional<double> totalFramesDuration;
+        Optional<double> sumOfSquaredFramesDuration;
+
+        Optional<uint64_t> jitterBufferFlushes;
     };
 
     struct DataChannelStats : Stats {
index d2e240d..bd281cb 100644 (file)
@@ -218,6 +218,16 @@ dictionary RTCMediaStreamTrackStats : RTCStats {
     double audioLevel;
     double echoReturnLoss;
     double echoReturnLossEnhancement;
+
+    // FIXME: Introduce RTCVideoReceiverStats
+    unsigned long freezeCount;
+    unsigned long pauseCount;
+    double totalFreezesDuration;
+    double totalPausesDuration;
+    double totalFramesDuration;
+    double sumOfSquaredFramesDuration;
+    // FIXME: Introduce RTCAudioReceiverStats
+    unsigned long long jitterBufferFlushes;
 };
 
 [ JSGenerateToJSObject ]
index 59e6584..015ee14 100644 (file)
@@ -268,6 +268,22 @@ static inline void fillRTCMediaStreamTrackStats(RTCStatsReport::MediaStreamTrack
         stats.echoReturnLoss = *rtcStats.echo_return_loss;
     if (rtcStats.echo_return_loss_enhancement.is_defined())
         stats.echoReturnLossEnhancement = *rtcStats.echo_return_loss_enhancement;
+
+    // Migrate to RTCVideoReceiverStats and RTCAudioReceiverStats.
+    if (rtcStats.freeze_count.is_defined())
+        stats.freezeCount = *rtcStats.freeze_count;
+    if (rtcStats.pause_count.is_defined())
+        stats.pauseCount = *rtcStats.pause_count;
+    if (rtcStats.total_freezes_duration.is_defined())
+        stats.totalFreezesDuration = *rtcStats.total_freezes_duration;
+    if (rtcStats.total_pauses_duration.is_defined())
+        stats.totalPausesDuration = *rtcStats.total_pauses_duration;
+    if (rtcStats.total_frames_duration.is_defined())
+        stats.totalFramesDuration = *rtcStats.total_frames_duration;
+    if (rtcStats.sum_squared_frame_durations.is_defined())
+        stats.sumOfSquaredFramesDuration = *rtcStats.sum_squared_frame_durations;
+    if (rtcStats.jitter_buffer_flushes.is_defined())
+        stats.jitterBufferFlushes = *rtcStats.jitter_buffer_flushes;
 }
 
 static inline void fillRTCDataChannelStats(RTCStatsReport::DataChannelStats& stats, const webrtc::RTCDataChannelStats& rtcStats)