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

Side by Side Diff: webrtc/modules/video_coding/media_optimization_unittest.cc

Issue 1972083002: Move logic for calculating needed bitrate overhead used by NACK and FEC to VideoSender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Changed framerate from float to int since that is what is used in stats_,encode_frame_rate. Created 4 years, 6 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 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // above 50 + 10 kbps again. 57 // above 50 + 10 kbps again.
58 const uint32_t kThresholdBps = 50000; 58 const uint32_t kThresholdBps = 50000;
59 const uint32_t kWindowBps = 10000; 59 const uint32_t kWindowBps = 10000;
60 media_opt_.SuspendBelowMinBitrate(kThresholdBps, kWindowBps); 60 media_opt_.SuspendBelowMinBitrate(kThresholdBps, kWindowBps);
61 61
62 // The video should not be suspended from the start. 62 // The video should not be suspended from the start.
63 EXPECT_FALSE(media_opt_.IsVideoSuspended()); 63 EXPECT_FALSE(media_opt_.IsVideoSuspended());
64 64
65 uint32_t target_bitrate_kbps = 100; 65 uint32_t target_bitrate_kbps = 100;
66 media_opt_.SetTargetRates(target_bitrate_kbps * 1000, 66 media_opt_.SetTargetRates(target_bitrate_kbps * 1000,
67 0, // Lossrate. 67 0, // Lossrate.
68 100, // RTT in ms. 68 100); // RTT in ms.
69 nullptr);
70 media_opt_.EnableFrameDropper(true); 69 media_opt_.EnableFrameDropper(true);
71 for (int time = 0; time < 2000; time += frame_time_ms_) { 70 for (int time = 0; time < 2000; time += frame_time_ms_) {
72 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, false)); 71 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, false));
73 } 72 }
74 73
75 // Set the target rate below the limit for muting. 74 // Set the target rate below the limit for muting.
76 media_opt_.SetTargetRates(kThresholdBps - 1000, 75 media_opt_.SetTargetRates(kThresholdBps - 1000,
77 0, // Lossrate. 76 0, // Lossrate.
78 100, // RTT in ms. 77 100); // RTT in ms.
79 nullptr);
80 // Expect the muter to engage immediately and stay muted. 78 // Expect the muter to engage immediately and stay muted.
81 // Test during 2 seconds. 79 // Test during 2 seconds.
82 for (int time = 0; time < 2000; time += frame_time_ms_) { 80 for (int time = 0; time < 2000; time += frame_time_ms_) {
83 EXPECT_TRUE(media_opt_.IsVideoSuspended()); 81 EXPECT_TRUE(media_opt_.IsVideoSuspended());
84 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true)); 82 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true));
85 } 83 }
86 84
87 // Set the target above the limit for muting, but not above the 85 // Set the target above the limit for muting, but not above the
88 // limit + window. 86 // limit + window.
89 media_opt_.SetTargetRates(kThresholdBps + 1000, 87 media_opt_.SetTargetRates(kThresholdBps + 1000,
90 0, // Lossrate. 88 0, // Lossrate.
91 100, // RTT in ms. 89 100); // RTT in ms.
92 nullptr);
93 // Expect the muter to stay muted. 90 // Expect the muter to stay muted.
94 // Test during 2 seconds. 91 // Test during 2 seconds.
95 for (int time = 0; time < 2000; time += frame_time_ms_) { 92 for (int time = 0; time < 2000; time += frame_time_ms_) {
96 EXPECT_TRUE(media_opt_.IsVideoSuspended()); 93 EXPECT_TRUE(media_opt_.IsVideoSuspended());
97 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true)); 94 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true));
98 } 95 }
99 96
100 // Set the target above limit + window. 97 // Set the target above limit + window.
101 media_opt_.SetTargetRates(kThresholdBps + kWindowBps + 1000, 98 media_opt_.SetTargetRates(kThresholdBps + kWindowBps + 1000,
102 0, // Lossrate. 99 0, // Lossrate.
103 100, // RTT in ms. 100 100); // RTT in ms.
104 nullptr);
105 // Expect the muter to disengage immediately. 101 // Expect the muter to disengage immediately.
106 // Test during 2 seconds. 102 // Test during 2 seconds.
107 for (int time = 0; time < 2000; time += frame_time_ms_) { 103 for (int time = 0; time < 2000; time += frame_time_ms_) {
108 EXPECT_FALSE(media_opt_.IsVideoSuspended()); 104 EXPECT_FALSE(media_opt_.IsVideoSuspended());
109 ASSERT_NO_FATAL_FAILURE( 105 ASSERT_NO_FATAL_FAILURE(
110 AddFrameAndAdvanceTime((kThresholdBps + kWindowBps) / 1000, false)); 106 AddFrameAndAdvanceTime((kThresholdBps + kWindowBps) / 1000, false));
111 } 107 }
112 } 108 }
113 109
114 TEST_F(TestMediaOptimization, ProtectsUsingFecBitrateAboveCodecMax) {
115 static const int kCodecBitrateBps = 100000;
116 static const int kMaxBitrateBps = 130000;
117
118 class ProtectionCallback : public VCMProtectionCallback {
119 int ProtectionRequest(const FecProtectionParams* delta_params,
120 const FecProtectionParams* key_params,
121 uint32_t* sent_video_rate_bps,
122 uint32_t* sent_nack_rate_bps,
123 uint32_t* sent_fec_rate_bps) override {
124 *sent_video_rate_bps = kCodecBitrateBps;
125 *sent_nack_rate_bps = 0;
126 *sent_fec_rate_bps = fec_rate_bps_;
127 return 0;
128 }
129
130 public:
131 uint32_t fec_rate_bps_;
132 } protection_callback;
133
134 media_opt_.SetProtectionMethod(kFec);
135 media_opt_.SetEncodingData(kVideoCodecVP8, kCodecBitrateBps, kCodecBitrateBps,
136 640, 480, 30, 1, 1000);
137
138 // Using 10% of codec bitrate for FEC, should still be able to use all of it.
139 protection_callback.fec_rate_bps_ = kCodecBitrateBps / 10;
140 uint32_t target_bitrate = media_opt_.SetTargetRates(
141 kMaxBitrateBps, 0, 0, &protection_callback);
142
143 EXPECT_EQ(kCodecBitrateBps, static_cast<int>(target_bitrate));
144
145 // Using as much for codec bitrate as fec rate, new target rate should share
146 // both equally, but only be half of max (since that ceiling should be hit).
147 protection_callback.fec_rate_bps_ = kCodecBitrateBps;
148 target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 128, 100,
149 &protection_callback);
150 EXPECT_EQ(kMaxBitrateBps / 2, static_cast<int>(target_bitrate));
151 }
152
153 } // namespace media_optimization 110 } // namespace media_optimization
154 } // namespace webrtc 111 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698