Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: webrtc/video/end_to_end_tests.cc

Issue 2122743003: Fix stats for encoder target bitrate when target rate is zero. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed bad logging. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include <algorithm> 10 #include <algorithm>
(...skipping 2455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 return 0; 2466 return 0;
2467 rtc::CritScope lock(&crit_); 2467 rtc::CritScope lock(&crit_);
2468 bitrate_kbps_ = new_target_bitrate; 2468 bitrate_kbps_ = new_target_bitrate;
2469 observation_complete_.Set(); 2469 observation_complete_.Set();
2470 return 0; 2470 return 0;
2471 } 2471 }
2472 2472
2473 void PerformTest() override { 2473 void PerformTest() override {
2474 ASSERT_TRUE(Wait()) 2474 ASSERT_TRUE(Wait())
2475 << "Timed out while waiting for encoder SetRates() call."; 2475 << "Timed out while waiting for encoder SetRates() call.";
2476 // Wait for GetStats to report a corresponding bitrate. 2476 WaitForEncoderTargetBitrateMatchStats();
2477 send_stream_->Stop();
2478 WaitForStatsReportZeroTargetBitrate();
2479 send_stream_->Start();
2480 WaitForEncoderTargetBitrateMatchStats();
2481 }
2482
2483 void WaitForEncoderTargetBitrateMatchStats() {
2477 for (int i = 0; i < kDefaultTimeoutMs; ++i) { 2484 for (int i = 0; i < kDefaultTimeoutMs; ++i) {
2478 VideoSendStream::Stats stats = send_stream_->GetStats(); 2485 VideoSendStream::Stats stats = send_stream_->GetStats();
2479 { 2486 {
2480 rtc::CritScope lock(&crit_); 2487 rtc::CritScope lock(&crit_);
2481 if ((stats.target_media_bitrate_bps + 500) / 1000 == 2488 if ((stats.target_media_bitrate_bps + 500) / 1000 ==
2482 static_cast<int>(bitrate_kbps_)) { 2489 static_cast<int>(bitrate_kbps_)) {
2483 return; 2490 return;
2484 } 2491 }
2485 } 2492 }
2486 SleepMs(1); 2493 SleepMs(1);
2487 } 2494 }
2488 FAIL() 2495 FAIL()
2489 << "Timed out waiting for stats reporting the currently set bitrate."; 2496 << "Timed out waiting for stats reporting the currently set bitrate.";
2490 } 2497 }
2491 2498
2499 void WaitForStatsReportZeroTargetBitrate() {
2500 for (int i = 0; i < kDefaultTimeoutMs; ++i) {
2501 if (send_stream_->GetStats().target_media_bitrate_bps == 0) {
2502 return;
2503 }
2504 SleepMs(1);
2505 }
2506 FAIL() << "Timed out waiting for stats reporting zero bitrate.";
2507 }
2508
2492 private: 2509 private:
2493 rtc::CriticalSection crit_; 2510 rtc::CriticalSection crit_;
2494 VideoSendStream* send_stream_; 2511 VideoSendStream* send_stream_;
2495 uint32_t bitrate_kbps_ GUARDED_BY(crit_); 2512 uint32_t bitrate_kbps_ GUARDED_BY(crit_);
2496 } test; 2513 } test;
2497 2514
2498 RunBaseTest(&test); 2515 RunBaseTest(&test);
2499 } 2516 }
2500 2517
2501 TEST_F(EndToEndTest, GetStats) { 2518 TEST_F(EndToEndTest, GetStats) {
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
3558 private: 3575 private:
3559 bool video_observed_; 3576 bool video_observed_;
3560 bool audio_observed_; 3577 bool audio_observed_;
3561 SequenceNumberUnwrapper unwrapper_; 3578 SequenceNumberUnwrapper unwrapper_;
3562 std::set<int64_t> received_packet_ids_; 3579 std::set<int64_t> received_packet_ids_;
3563 } test; 3580 } test;
3564 3581
3565 RunBaseTest(&test); 3582 RunBaseTest(&test);
3566 } 3583 }
3567 } // namespace webrtc 3584 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/video_sender_unittest.cc ('k') | webrtc/video/send_statistics_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698