Commit e495d5a4 authored by Lambros Lambrou's avatar Lambros Lambrou Committed by Commit Bot

[remoting WebRTC] Add quantizer to per-frame statistics.

This adds the VP8/9 frame quantizer to the stats for each frame.
This will enable the website to show a graph of these values over time.

This also adds new FrameStats unittests, and fixes a capturer_id
initialization bug discovered by the unittest.

Bug: 888833
Change-Id: I2c48f9c024a0e64a6a5756a3371717d3491a8474
Reviewed-on: https://chromium-review.googlesource.com/1242398
Commit-Queue: Lambros Lambrou <lambroslambrou@chromium.org>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594934}
parent 5f769f77
......@@ -11,7 +11,7 @@ option optimize_for = LITE_RUNTIME;
package remoting;
// Next Id: 13
// Next Id: 14
message FrameStatsMessage {
// Frame ID.
optional uint32 frame_id = 1;
......@@ -49,5 +49,9 @@ message FrameStatsMessage {
// The capturer Id to indicate the implementation of ScreenCapturer that
// generates this frame.
optional uint32 capturer_id = 12;
}
// The last quantizer chosen by the encoder for this frame. Higher numbers
// represent lower-quality images. Values are between 0 and 63, as used by
// the rc_*_quantizer config parameters.
optional uint32 frame_quantizer = 13;
}
......@@ -340,6 +340,7 @@ source_set("unit_tests") {
"connection_tester.h",
"content_description_unittest.cc",
"data_channel_manager_unittest.cc",
"frame_stats_unittest.cc",
"http_ice_config_request_unittest.cc",
"ice_config_unittest.cc",
"ice_transport_unittest.cc",
......
......@@ -95,6 +95,12 @@ HostFrameStats HostFrameStats::FromFrameStatsMessage(
if (message.has_bandwidth_estimate_kbps()) {
result.bandwidth_estimate_kbps = message.bandwidth_estimate_kbps();
}
if (message.has_capturer_id()) {
result.capturer_id = message.capturer_id();
}
if (message.has_frame_quantizer()) {
result.frame_quantizer = message.frame_quantizer();
}
return result;
}
......@@ -136,6 +142,9 @@ void HostFrameStats::ToFrameStatsMessage(FrameStatsMessage* message_out) const {
if (capturer_id != webrtc::DesktopCapturerId::kUnknown) {
message_out->set_capturer_id(capturer_id);
}
if (frame_quantizer != -1) {
message_out->set_frame_quantizer(frame_quantizer);
}
}
FrameStats::FrameStats() = default;
......
......@@ -43,6 +43,7 @@ struct HostFrameStats {
base::TimeDelta rtt_estimate = base::TimeDelta::Max();
int bandwidth_estimate_kbps = -1;
uint32_t capturer_id = webrtc::DesktopCapturerId::kUnknown;
int frame_quantizer = -1;
};
struct ClientFrameStats {
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/protocol/frame_stats.h"
#include "remoting/proto/video_stats.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
namespace protocol {
class FrameStatsTest : public testing::Test {};
TEST_F(FrameStatsTest, ToStatsMessageAndBack_RestoresFrameStats) {
HostFrameStats stats;
stats.frame_size = 10;
stats.capture_delay = base::TimeDelta::FromSeconds(11);
stats.encode_delay = base::TimeDelta::FromSeconds(12);
stats.capture_pending_delay = base::TimeDelta::FromSeconds(13);
stats.capture_overhead_delay = base::TimeDelta::FromSeconds(14);
stats.encode_pending_delay = base::TimeDelta::FromSeconds(15);
stats.send_pending_delay = base::TimeDelta::FromSeconds(16);
stats.rtt_estimate = base::TimeDelta::FromSeconds(17);
stats.bandwidth_estimate_kbps = 18;
stats.capturer_id = 19;
stats.frame_quantizer = 20;
FrameStatsMessage message;
stats.ToFrameStatsMessage(&message);
HostFrameStats newStats = HostFrameStats::FromFrameStatsMessage(message);
EXPECT_EQ(stats.frame_size, newStats.frame_size);
EXPECT_EQ(stats.capture_delay, newStats.capture_delay);
EXPECT_EQ(stats.encode_delay, newStats.encode_delay);
EXPECT_EQ(stats.capture_pending_delay, newStats.capture_pending_delay);
EXPECT_EQ(stats.capture_overhead_delay, newStats.capture_overhead_delay);
EXPECT_EQ(stats.encode_pending_delay, newStats.encode_pending_delay);
EXPECT_EQ(stats.send_pending_delay, newStats.send_pending_delay);
EXPECT_EQ(stats.rtt_estimate, newStats.rtt_estimate);
EXPECT_EQ(stats.bandwidth_estimate_kbps, newStats.bandwidth_estimate_kbps);
EXPECT_EQ(stats.capturer_id, newStats.capturer_id);
EXPECT_EQ(stats.frame_quantizer, newStats.frame_quantizer);
}
} // namespace protocol
} // namespace remoting
......@@ -64,6 +64,7 @@ struct WebrtcVideoStream::FrameStats {
base::TimeTicks encode_ended_time;
uint32_t capturer_id = 0;
int frame_quantizer = -1;
};
WebrtcVideoStream::WebrtcVideoStream(const SessionOptions& session_options)
......@@ -242,6 +243,7 @@ void WebrtcVideoStream::OnFrameEncoded(
DCHECK(thread_checker_.CalledOnValidThread());
current_frame_stats_->encode_ended_time = base::TimeTicks::Now();
current_frame_stats_->frame_quantizer = frame->quantizer;
HostFrameStats stats;
scheduler_->OnFrameEncoded(frame.get(), &stats);
......@@ -297,6 +299,8 @@ void WebrtcVideoStream::OnFrameEncoded(
stats.capturer_id = current_frame_stats_->capturer_id;
stats.frame_quantizer = current_frame_stats_->frame_quantizer;
video_stats_dispatcher_.OnVideoFrameStats(result.frame_id, stats);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment