stats: convert qualitylimitationdurations to seconds

the internal value is defined milliseconds
  https://webrtc.googlesource.com/src/+/refs/heads/main/video/g3doc/stats.md
while the specification defines it in seconds
  https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationdurations

BUG=webrtc:13548,webrtc:10686

Change-Id: I901c84214c77dd5a6e59f6556a029c8e20cb7672
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/245482
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com>
Cr-Commit-Position: refs/heads/main@{#35657}
This commit is contained in:
Philipp Hancke
2022-01-10 17:41:43 +01:00
committed by WebRTC LUCI CQ
parent cf00059db6
commit 3fd9cbc7a0
3 changed files with 7 additions and 2 deletions

View File

@ -269,9 +269,12 @@ std::map<std::string, double>
QualityLimitationDurationToRTCQualityLimitationDuration(
std::map<webrtc::QualityLimitationReason, int64_t> durations_ms) {
std::map<std::string, double> result;
// The internal duration is defined in milliseconds while the spec defines
// the value in seconds:
// https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationdurations
for (const auto& elem : durations_ms) {
result[QualityLimitationReasonToRTCQualityLimitationReason(elem.first)] =
elem.second;
elem.second / static_cast<double>(rtc::kNumMillisecsPerSec);
}
return result;
}

View File

@ -2329,7 +2329,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) {
expected_video.total_packet_send_delay = 10.0;
expected_video.quality_limitation_reason = "bandwidth";
expected_video.quality_limitation_durations = std::map<std::string, double>{
std::pair<std::string, double>{"bandwidth", 300.0},
std::pair<std::string, double>{"bandwidth", 0.3},
};
expected_video.quality_limitation_resolution_changes = 56u;
expected_video.frame_width = 200u;

View File

@ -24,6 +24,8 @@ namespace webrtc {
// duration of time spent in each reason. See qualityLimitationReason[1],
// qualityLimitationDurations[2], and qualityLimitationResolutionChanges[3] in
// the webrtc-stats spec.
// Note that the specification defines the durations in seconds while the
// internal data structures defines it in milliseconds.
// [1]
// https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationreason
// [2]