| 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 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 protected: | 2229 protected: |
| 2230 Clock* const clock_; | 2230 Clock* const clock_; |
| 2231 const int start_bitrate_bps_; | 2231 const int start_bitrate_bps_; |
| 2232 int state_; | 2232 int state_; |
| 2233 Call* sender_call_; | 2233 Call* sender_call_; |
| 2234 }; | 2234 }; |
| 2235 | 2235 |
| 2236 TEST_F(EndToEndTest, MAYBE_InitialProbing) { | 2236 TEST_F(EndToEndTest, MAYBE_InitialProbing) { |
| 2237 class InitialProbingTest : public ProbingTest { | 2237 class InitialProbingTest : public ProbingTest { |
| 2238 public: | 2238 public: |
| 2239 InitialProbingTest() : ProbingTest(300000) {} | 2239 explicit InitialProbingTest(bool* success) |
| 2240 : ProbingTest(300000), success_(success) {} |
| 2240 | 2241 |
| 2241 void PerformTest() override { | 2242 void PerformTest() override { |
| 2242 int64_t start_time_ms = clock_->TimeInMilliseconds(); | 2243 int64_t start_time_ms = clock_->TimeInMilliseconds(); |
| 2243 do { | 2244 do { |
| 2244 if (clock_->TimeInMilliseconds() - start_time_ms > kTimeoutMs) { | 2245 if (clock_->TimeInMilliseconds() - start_time_ms > kTimeoutMs) |
| 2245 ADD_FAILURE() << "Timed out while waiting for initial probing."; | |
| 2246 break; | 2246 break; |
| 2247 } | |
| 2248 | 2247 |
| 2249 Call::Stats stats = sender_call_->GetStats(); | 2248 Call::Stats stats = sender_call_->GetStats(); |
| 2250 // Initial probing is done with a x3 and x6 multiplier of the start | 2249 // Initial probing is done with a x3 and x6 multiplier of the start |
| 2251 // bitrate, so a x4 multiplier is a high enough threshold. | 2250 // bitrate, so a x4 multiplier is a high enough threshold. |
| 2252 if (stats.send_bandwidth_bps > 4 * 300000) | 2251 if (stats.send_bandwidth_bps > 4 * 300000) { |
| 2252 *success_ = true; |
| 2253 break; | 2253 break; |
| 2254 } |
| 2254 } while (!observation_complete_.Wait(20)); | 2255 } while (!observation_complete_.Wait(20)); |
| 2255 } | 2256 } |
| 2256 | 2257 |
| 2257 private: | 2258 private: |
| 2258 const int kTimeoutMs = 1000; | 2259 const int kTimeoutMs = 1000; |
| 2259 } test; | 2260 bool* const success_; |
| 2261 }; |
| 2260 | 2262 |
| 2261 RunBaseTest(&test); | 2263 bool success; |
| 2264 const int kMaxAttempts = 3; |
| 2265 for (int i = 0; i < kMaxAttempts; ++i) { |
| 2266 InitialProbingTest test(&success); |
| 2267 RunBaseTest(&test); |
| 2268 if (success) |
| 2269 return; |
| 2270 } |
| 2271 RTC_DCHECK(success) << "Failed to perform mid initial probing (" |
| 2272 << kMaxAttempts << " attempts)."; |
| 2262 } | 2273 } |
| 2263 | 2274 |
| 2264 TEST_F(EndToEndTest, TriggerMidCallProbing) { | 2275 TEST_F(EndToEndTest, TriggerMidCallProbing) { |
| 2265 class TriggerMidCallProbingTest : public ProbingTest { | 2276 class TriggerMidCallProbingTest : public ProbingTest { |
| 2266 public: | 2277 public: |
| 2267 TriggerMidCallProbingTest() : ProbingTest(300000) {} | 2278 explicit TriggerMidCallProbingTest(bool* success) |
| 2279 : ProbingTest(300000), success_(success) {} |
| 2268 | 2280 |
| 2269 void PerformTest() override { | 2281 void PerformTest() override { |
| 2282 *success_ = false; |
| 2270 int64_t start_time_ms = clock_->TimeInMilliseconds(); | 2283 int64_t start_time_ms = clock_->TimeInMilliseconds(); |
| 2271 do { | 2284 do { |
| 2272 if (clock_->TimeInMilliseconds() - start_time_ms > kTimeoutMs) { | 2285 if (clock_->TimeInMilliseconds() - start_time_ms > kTimeoutMs) |
| 2273 ADD_FAILURE() << "Timed out while waiting for mid-call probing."; | |
| 2274 break; | 2286 break; |
| 2275 } | |
| 2276 | 2287 |
| 2277 Call::Stats stats = sender_call_->GetStats(); | 2288 Call::Stats stats = sender_call_->GetStats(); |
| 2278 | 2289 |
| 2279 switch (state_) { | 2290 switch (state_) { |
| 2280 case 0: | 2291 case 0: |
| 2281 if (stats.send_bandwidth_bps > 5 * 300000) { | 2292 if (stats.send_bandwidth_bps > 5 * 300000) { |
| 2282 Call::Config::BitrateConfig bitrate_config; | 2293 Call::Config::BitrateConfig bitrate_config; |
| 2283 bitrate_config.max_bitrate_bps = 100000; | 2294 bitrate_config.max_bitrate_bps = 100000; |
| 2284 sender_call_->SetBitrateConfig(bitrate_config); | 2295 sender_call_->SetBitrateConfig(bitrate_config); |
| 2285 ++state_; | 2296 ++state_; |
| 2286 } | 2297 } |
| 2287 break; | 2298 break; |
| 2288 case 1: | 2299 case 1: |
| 2289 if (stats.send_bandwidth_bps < 110000) { | 2300 if (stats.send_bandwidth_bps < 110000) { |
| 2290 Call::Config::BitrateConfig bitrate_config; | 2301 Call::Config::BitrateConfig bitrate_config; |
| 2291 bitrate_config.max_bitrate_bps = 2500000; | 2302 bitrate_config.max_bitrate_bps = 2500000; |
| 2292 sender_call_->SetBitrateConfig(bitrate_config); | 2303 sender_call_->SetBitrateConfig(bitrate_config); |
| 2293 ++state_; | 2304 ++state_; |
| 2294 } | 2305 } |
| 2295 break; | 2306 break; |
| 2296 case 2: | 2307 case 2: |
| 2297 // During high cpu load the pacer will not be able to pace packets | 2308 // During high cpu load the pacer will not be able to pace packets |
| 2298 // at the correct speed, but if we go from 110 to 1250 kbps | 2309 // at the correct speed, but if we go from 110 to 1250 kbps |
| 2299 // in 5 seconds then it is due to probing. | 2310 // in 5 seconds then it is due to probing. |
| 2300 if (stats.send_bandwidth_bps > 1250000) | 2311 if (stats.send_bandwidth_bps > 1250000) { |
| 2312 *success_ = true; |
| 2301 observation_complete_.Set(); | 2313 observation_complete_.Set(); |
| 2314 } |
| 2302 break; | 2315 break; |
| 2303 } | 2316 } |
| 2304 } while (!observation_complete_.Wait(20)); | 2317 } while (!observation_complete_.Wait(20)); |
| 2305 } | 2318 } |
| 2306 | 2319 |
| 2307 private: | 2320 private: |
| 2308 const int kTimeoutMs = 5000; | 2321 const int kTimeoutMs = 5000; |
| 2309 } test; | 2322 bool* const success_; |
| 2323 }; |
| 2310 | 2324 |
| 2311 RunBaseTest(&test); | 2325 bool success; |
| 2326 const int kMaxAttempts = 3; |
| 2327 for (int i = 0; i < kMaxAttempts; ++i) { |
| 2328 TriggerMidCallProbingTest test(&success); |
| 2329 RunBaseTest(&test); |
| 2330 if (success) |
| 2331 return; |
| 2332 } |
| 2333 RTC_DCHECK(success) << "Failed to perform mid call probing (" << kMaxAttempts |
| 2334 << " attempts)."; |
| 2312 } | 2335 } |
| 2313 | 2336 |
| 2314 TEST_F(EndToEndTest, VerifyNackStats) { | 2337 TEST_F(EndToEndTest, VerifyNackStats) { |
| 2315 static const int kPacketNumberToDrop = 200; | 2338 static const int kPacketNumberToDrop = 200; |
| 2316 class NackObserver : public test::EndToEndTest { | 2339 class NackObserver : public test::EndToEndTest { |
| 2317 public: | 2340 public: |
| 2318 NackObserver() | 2341 NackObserver() |
| 2319 : EndToEndTest(kLongTimeoutMs), | 2342 : EndToEndTest(kLongTimeoutMs), |
| 2320 sent_rtp_packets_(0), | 2343 sent_rtp_packets_(0), |
| 2321 dropped_rtp_packet_(0), | 2344 dropped_rtp_packet_(0), |
| (...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4295 std::unique_ptr<VideoEncoder> encoder_; | 4318 std::unique_ptr<VideoEncoder> encoder_; |
| 4296 std::unique_ptr<VideoDecoder> decoder_; | 4319 std::unique_ptr<VideoDecoder> decoder_; |
| 4297 rtc::CriticalSection crit_; | 4320 rtc::CriticalSection crit_; |
| 4298 int recorded_frames_ GUARDED_BY(crit_); | 4321 int recorded_frames_ GUARDED_BY(crit_); |
| 4299 } test(this); | 4322 } test(this); |
| 4300 | 4323 |
| 4301 RunBaseTest(&test); | 4324 RunBaseTest(&test); |
| 4302 } | 4325 } |
| 4303 | 4326 |
| 4304 } // namespace webrtc | 4327 } // namespace webrtc |
| OLD | NEW |