Index: webrtc/video/end_to_end_tests.cc |
diff --git a/webrtc/video/end_to_end_tests.cc b/webrtc/video/end_to_end_tests.cc |
index e5b12ce0b1e96027dfac849543c2965303307bca..8e3105f7411d9af37012cb7ea6635ef7edf4b79a 100644 |
--- a/webrtc/video/end_to_end_tests.cc |
+++ b/webrtc/video/end_to_end_tests.cc |
@@ -2473,7 +2473,14 @@ TEST_F(EndToEndTest, ReportsSetEncoderRates) { |
void PerformTest() override { |
ASSERT_TRUE(Wait()) |
<< "Timed out while waiting for encoder SetRates() call."; |
- // Wait for GetStats to report a corresponding bitrate. |
+ WaitForEncoderTargetBitrateMatchStats(); |
+ send_stream_->Stop(); |
+ WaitForStatsReportZeroTargetBitrate(); |
+ send_stream_->Start(); |
+ WaitForEncoderTargetBitrateMatchStats(); |
+ } |
+ |
+ void WaitForEncoderTargetBitrateMatchStats() { |
for (int i = 0; i < kDefaultTimeoutMs; ++i) { |
VideoSendStream::Stats stats = send_stream_->GetStats(); |
{ |
@@ -2489,6 +2496,16 @@ TEST_F(EndToEndTest, ReportsSetEncoderRates) { |
<< "Timed out waiting for stats reporting the currently set bitrate."; |
} |
+ void WaitForStatsReportZeroTargetBitrate() { |
+ for (int i = 0; i < kDefaultTimeoutMs; ++i) { |
+ if (send_stream_->GetStats().target_media_bitrate_bps == 0) { |
+ return; |
+ } |
+ SleepMs(1); |
+ } |
+ FAIL() << "Timed out waiting for stats reporting zero bitrate."; |
+ } |
+ |
private: |
rtc::CriticalSection crit_; |
VideoSendStream* send_stream_; |