Index: webrtc/video/send_statistics_proxy_unittest.cc |
diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc |
index 593c93b8e1aa859150ceacc39408a20e5c1a64e2..577921ed0b3ec8c39682110880304ac2a81b1082 100644 |
--- a/webrtc/video/send_statistics_proxy_unittest.cc |
+++ b/webrtc/video/send_statistics_proxy_unittest.cc |
@@ -65,6 +65,8 @@ class SendStatisticsProxyTest : public ::testing::Test { |
EXPECT_EQ(one.input_frame_rate, other.input_frame_rate); |
EXPECT_EQ(one.encode_frame_rate, other.encode_frame_rate); |
EXPECT_EQ(one.media_bitrate_bps, other.media_bitrate_bps); |
+ EXPECT_EQ(one.preferred_media_bitrate_bps, |
+ other.preferred_media_bitrate_bps); |
EXPECT_EQ(one.suspended, other.suspended); |
EXPECT_EQ(one.substreams.size(), other.substreams.size()); |
@@ -288,6 +290,32 @@ TEST_F(SendStatisticsProxyTest, OnEncodedFrameTimeMeasured) { |
EXPECT_EQ(metrics.encode_usage_percent, stats.encode_usage_percent); |
} |
+TEST_F(SendStatisticsProxyTest, OnEncoderReconfiguredChangePreferredBitrate) { |
+ VideoSendStream::Stats stats = statistics_proxy_->GetStats(); |
+ EXPECT_EQ(0, stats.preferred_media_bitrate_bps); |
+ |
+ VideoEncoderConfig config; |
+ std::vector<VideoStream> streams; |
+ VideoStream stream1; |
+ stream1.target_bitrate_bps = 5; |
+ stream1.max_bitrate_bps = 6; |
+ streams.push_back(stream1); |
+ |
+ statistics_proxy_->OnEncoderReconfigured(config, streams); |
+ stats = statistics_proxy_->GetStats(); |
+ EXPECT_EQ(stream1.max_bitrate_bps, stats.preferred_media_bitrate_bps); |
+ |
+ VideoStream stream2; |
+ stream2.target_bitrate_bps = 10; |
+ stream2.max_bitrate_bps = 20; |
+ streams.push_back(stream2); |
+ |
+ statistics_proxy_->OnEncoderReconfigured(config, streams); |
+ stats = statistics_proxy_->GetStats(); |
+ EXPECT_EQ(stream2.max_bitrate_bps + stream1.target_bitrate_bps, |
+ stats.preferred_media_bitrate_bps); |
+} |
+ |
TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { |
const int kWidth = 640; |
const int kHeight = 480; |
@@ -295,13 +323,16 @@ TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { |
for (int i = 0; i < kMinRequiredSamples; ++i) |
statistics_proxy_->OnIncomingFrame(kWidth, kHeight); |
- // No switch, stats not should be updated. |
- statistics_proxy_->SetContentType( |
- VideoEncoderConfig::ContentType::kRealtimeVideo); |
+ // No switch, stats should not be updated. |
+ VideoEncoderConfig config; |
+ config.content_type = VideoEncoderConfig::ContentType::kRealtimeVideo; |
+ std::vector<VideoStream> video_streams; |
+ statistics_proxy_->OnEncoderReconfigured(config, video_streams); |
EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); |
// Switch to screenshare, real-time stats should be updated. |
- statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); |
+ config.content_type = VideoEncoderConfig::ContentType::kScreen; |
+ statistics_proxy_->OnEncoderReconfigured(config, video_streams); |
EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); |
} |
@@ -538,7 +569,10 @@ TEST_F(SendStatisticsProxyTest, ResetsRtcpCountersOnContentChange) { |
proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); |
// Changing content type causes histograms to be reported. |
- statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); |
+ VideoEncoderConfig config; |
+ config.content_type = VideoEncoderConfig::ContentType::kScreen; |
+ std::vector<VideoStream> video_streams; |
+ statistics_proxy_->OnEncoderReconfigured(config, video_streams); |
EXPECT_EQ(1, |
metrics::NumSamples("WebRTC.Video.NackPacketsReceivedPerMinute")); |
@@ -633,7 +667,10 @@ TEST_F(SendStatisticsProxyTest, ResetsRtpCountersOnContentChange) { |
proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); |
// Changing content type causes histograms to be reported. |
- statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); |
+ VideoEncoderConfig config; |
+ config.content_type = VideoEncoderConfig::ContentType::kScreen; |
+ std::vector<VideoStream> video_streams; |
+ statistics_proxy_->OnEncoderReconfigured(config, video_streams); |
EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps")); |
EXPECT_EQ(1, |