OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 24 matching lines...) Expand all Loading... |
35 void IncomingPacket(uint16_t seq, int64_t time_ms) { | 35 void IncomingPacket(uint16_t seq, int64_t time_ms) { |
36 RTPHeader header; | 36 RTPHeader header; |
37 header.extension.hasTransportSequenceNumber = true; | 37 header.extension.hasTransportSequenceNumber = true; |
38 header.extension.transportSequenceNumber = seq; | 38 header.extension.transportSequenceNumber = seq; |
39 header.ssrc = kMediaSsrc; | 39 header.ssrc = kMediaSsrc; |
40 proxy_.IncomingPacket(time_ms, kDefaultPacketSize, header); | 40 proxy_.IncomingPacket(time_ms, kDefaultPacketSize, header); |
41 } | 41 } |
42 | 42 |
43 void Process() { | 43 void Process() { |
44 clock_.AdvanceTimeMilliseconds( | 44 clock_.AdvanceTimeMilliseconds( |
45 RemoteEstimatorProxy::kDefaultProcessIntervalMs); | 45 RemoteEstimatorProxy::kDefaultSendIntervalMs); |
46 proxy_.Process(); | 46 proxy_.Process(); |
47 } | 47 } |
48 | 48 |
49 SimulatedClock clock_; | 49 SimulatedClock clock_; |
50 testing::StrictMock<MockPacketRouter> router_; | 50 testing::StrictMock<MockPacketRouter> router_; |
51 RemoteEstimatorProxy proxy_; | 51 RemoteEstimatorProxy proxy_; |
52 | 52 |
53 const size_t kDefaultPacketSize = 100; | 53 const size_t kDefaultPacketSize = 100; |
54 const uint32_t kMediaSsrc = 456; | 54 const uint32_t kMediaSsrc = 456; |
55 const uint16_t kBaseSeq = 10; | 55 const uint16_t kBaseSeq = 10; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 EXPECT_EQ(kBaseTimeMs - 1, | 343 EXPECT_EQ(kBaseTimeMs - 1, |
344 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | 344 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); |
345 EXPECT_EQ(kTimeoutTimeMs - kBaseTimeMs, delta_vec[1] / 1000); | 345 EXPECT_EQ(kTimeoutTimeMs - kBaseTimeMs, delta_vec[1] / 1000); |
346 EXPECT_EQ(1, delta_vec[2] / 1000); | 346 EXPECT_EQ(1, delta_vec[2] / 1000); |
347 return true; | 347 return true; |
348 })); | 348 })); |
349 | 349 |
350 Process(); | 350 Process(); |
351 } | 351 } |
352 | 352 |
| 353 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsZeroBeforeFirstProcess) { |
| 354 EXPECT_EQ(0, proxy_.TimeUntilNextProcess()); |
| 355 } |
| 356 |
| 357 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsDefaultOnUnkownBitrate) { |
| 358 Process(); |
| 359 EXPECT_EQ(RemoteEstimatorProxy::kDefaultSendIntervalMs, |
| 360 proxy_.TimeUntilNextProcess()); |
| 361 } |
| 362 |
| 363 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsMinIntervalOn300kbps) { |
| 364 Process(); |
| 365 proxy_.OnBitrateChanged(300000); |
| 366 EXPECT_EQ(RemoteEstimatorProxy::kMinSendIntervalMs, |
| 367 proxy_.TimeUntilNextProcess()); |
| 368 } |
| 369 |
| 370 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsMaxIntervalOn0kbps) { |
| 371 Process(); |
| 372 // TimeUntilNextProcess should be limited by |kMaxSendIntervalMs| when |
| 373 // bitrate is small. We choose 0 bps as a special case, which also tests |
| 374 // erroneous behaviors like division-by-zero. |
| 375 proxy_.OnBitrateChanged(0); |
| 376 EXPECT_EQ(RemoteEstimatorProxy::kMaxSendIntervalMs, |
| 377 proxy_.TimeUntilNextProcess()); |
| 378 } |
| 379 |
| 380 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsMaxIntervalOn20kbps) { |
| 381 Process(); |
| 382 proxy_.OnBitrateChanged(20000); |
| 383 EXPECT_EQ(RemoteEstimatorProxy::kMaxSendIntervalMs, |
| 384 proxy_.TimeUntilNextProcess()); |
| 385 } |
| 386 |
| 387 TEST_F(RemoteEstimatorProxyTest, TwccReportsUse5PercentOfAvailableBandwidth) { |
| 388 Process(); |
| 389 proxy_.OnBitrateChanged(80000); |
| 390 // 80kbps * 0.05 = TwccReportSize(68B * 8b/B) * 1000ms / SendInterval(136ms) |
| 391 EXPECT_EQ(136, proxy_.TimeUntilNextProcess()); |
| 392 } |
| 393 |
353 } // namespace webrtc | 394 } // namespace webrtc |
OLD | NEW |