Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2189 test::PacketTransport* receive_transport_; | 2189 test::PacketTransport* receive_transport_; |
| 2190 rtc::Event stop_event_; | 2190 rtc::Event stop_event_; |
| 2191 rtc::PlatformThread poller_thread_; | 2191 rtc::PlatformThread poller_thread_; |
| 2192 TestState state_; | 2192 TestState state_; |
| 2193 RateLimiter retransmission_rate_limiter_; | 2193 RateLimiter retransmission_rate_limiter_; |
| 2194 } test; | 2194 } test; |
| 2195 | 2195 |
| 2196 RunBaseTest(&test); | 2196 RunBaseTest(&test); |
| 2197 } | 2197 } |
| 2198 | 2198 |
| 2199 class ProbingTest : public test::EndToEndTest { | |
| 2200 public: | |
| 2201 explicit ProbingTest(int start_bitrate_bps) | |
| 2202 : clock_(Clock::GetRealTimeClock()), | |
| 2203 start_bitrate_bps_(start_bitrate_bps), | |
| 2204 sender_call_(nullptr) {} | |
| 2205 | |
| 2206 ~ProbingTest() {} | |
| 2207 | |
| 2208 Call::Config GetSenderCallConfig() override { | |
| 2209 Call::Config config(&event_log_); | |
| 2210 config.bitrate_config.start_bitrate_bps = start_bitrate_bps_; | |
| 2211 return config; | |
| 2212 } | |
| 2213 | |
| 2214 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { | |
| 2215 sender_call_ = sender_call; | |
| 2216 } | |
| 2217 | |
| 2218 protected: | |
| 2219 Clock* const clock_; | |
| 2220 int start_bitrate_bps_; | |
|
stefan-webrtc
2017/03/17 13:14:26
const
philipel
2017/03/17 13:33:23
Done.
| |
| 2221 Call* sender_call_; | |
| 2222 int state_ = 0; | |
|
stefan-webrtc
2017/03/17 13:14:26
Use an enum for readability. It also seems like th
philipel
2017/03/17 13:33:23
I don't really think an enum adds anything in term
| |
| 2223 }; | |
| 2224 | |
| 2225 TEST_F(EndToEndTest, InitialProbing) { | |
| 2226 class InitialProbingTest : public ProbingTest { | |
| 2227 public: | |
| 2228 InitialProbingTest() : ProbingTest(300000) {} | |
| 2229 | |
| 2230 void PerformTest() override { | |
| 2231 int64_t test_end_ms = clock_->TimeInMilliseconds() + kTimeoutMs; | |
| 2232 do { | |
| 2233 if (test_end_ms - clock_->TimeInMilliseconds() <= 0) { | |
|
stefan-webrtc
2017/03/17 13:14:26
I would have written this:
if (clock_->TimeInMilli
philipel
2017/03/17 13:33:23
Agree, fixed.
| |
| 2234 ADD_FAILURE() << "Timed out while waiting for initial probing."; | |
| 2235 break; | |
| 2236 } | |
| 2237 | |
| 2238 Call::Stats stats = sender_call_->GetStats(); | |
| 2239 // Initial probing is done with a x3 and x6 multiplier of the start | |
| 2240 // bitrate, so a x5 multiplier is a high enough threshold. | |
| 2241 if (stats.send_bandwidth_bps > 5 * 300000) | |
| 2242 break; | |
| 2243 } while (!observation_complete_.Wait(20)); | |
| 2244 } | |
| 2245 | |
| 2246 private: | |
| 2247 const int kTimeoutMs = 1000; | |
| 2248 } test; | |
| 2249 | |
| 2250 RunBaseTest(&test); | |
| 2251 } | |
| 2252 | |
| 2253 TEST_F(EndToEndTest, TriggerMidCallProbing) { | |
| 2254 class TriggerMidCallProbingTest : public ProbingTest { | |
| 2255 public: | |
| 2256 TriggerMidCallProbingTest() : ProbingTest(300000) {} | |
| 2257 | |
| 2258 void PerformTest() override { | |
| 2259 int64_t test_end_ms = clock_->TimeInMilliseconds() + kTimeoutMs; | |
| 2260 do { | |
| 2261 if (test_end_ms - clock_->TimeInMilliseconds() <= 0) { | |
| 2262 ADD_FAILURE() << "Timed out while waiting for mid-call probing."; | |
| 2263 break; | |
| 2264 } | |
| 2265 | |
| 2266 Call::Stats stats = sender_call_->GetStats(); | |
| 2267 | |
| 2268 switch (state_) { | |
| 2269 case 0: | |
| 2270 if (stats.send_bandwidth_bps > 5 * 300000) { | |
| 2271 Call::Config::BitrateConfig bitrate_config; | |
| 2272 bitrate_config.max_bitrate_bps = 100000; | |
| 2273 sender_call_->SetBitrateConfig(bitrate_config); | |
| 2274 ++state_; | |
| 2275 } | |
| 2276 break; | |
| 2277 case 1: | |
| 2278 if (stats.send_bandwidth_bps < 110000) { | |
| 2279 Call::Config::BitrateConfig bitrate_config; | |
| 2280 bitrate_config.max_bitrate_bps = 2500000; | |
| 2281 sender_call_->SetBitrateConfig(bitrate_config); | |
| 2282 ++state_; | |
| 2283 } | |
| 2284 break; | |
| 2285 case 2: | |
| 2286 if (stats.send_bandwidth_bps > 2300000) | |
| 2287 observation_complete_.Set(); | |
| 2288 break; | |
| 2289 } | |
| 2290 } while (!observation_complete_.Wait(20)); | |
| 2291 } | |
| 2292 | |
| 2293 private: | |
| 2294 const int kTimeoutMs = 5000; | |
| 2295 } test; | |
| 2296 | |
| 2297 RunBaseTest(&test); | |
| 2298 } | |
| 2299 | |
| 2199 TEST_F(EndToEndTest, VerifyNackStats) { | 2300 TEST_F(EndToEndTest, VerifyNackStats) { |
| 2200 static const int kPacketNumberToDrop = 200; | 2301 static const int kPacketNumberToDrop = 200; |
| 2201 class NackObserver : public test::EndToEndTest { | 2302 class NackObserver : public test::EndToEndTest { |
| 2202 public: | 2303 public: |
| 2203 NackObserver() | 2304 NackObserver() |
| 2204 : EndToEndTest(kLongTimeoutMs), | 2305 : EndToEndTest(kLongTimeoutMs), |
| 2205 sent_rtp_packets_(0), | 2306 sent_rtp_packets_(0), |
| 2206 dropped_rtp_packet_(0), | 2307 dropped_rtp_packet_(0), |
| 2207 dropped_rtp_packet_requested_(false), | 2308 dropped_rtp_packet_requested_(false), |
| 2208 send_stream_(nullptr), | 2309 send_stream_(nullptr), |
| (...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4180 std::unique_ptr<VideoEncoder> encoder_; | 4281 std::unique_ptr<VideoEncoder> encoder_; |
| 4181 std::unique_ptr<VideoDecoder> decoder_; | 4282 std::unique_ptr<VideoDecoder> decoder_; |
| 4182 rtc::CriticalSection crit_; | 4283 rtc::CriticalSection crit_; |
| 4183 int recorded_frames_ GUARDED_BY(crit_); | 4284 int recorded_frames_ GUARDED_BY(crit_); |
| 4184 } test(this); | 4285 } test(this); |
| 4185 | 4286 |
| 4186 RunBaseTest(&test); | 4287 RunBaseTest(&test); |
| 4187 } | 4288 } |
| 4188 | 4289 |
| 4189 } // namespace webrtc | 4290 } // namespace webrtc |
| OLD | NEW |