| 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 |
| 11 #include <memory> |
| 12 #include <utility> |
| 13 |
| 14 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller
.h" |
| 11 #include "webrtc/modules/pacing/packet_router.h" | 15 #include "webrtc/modules/pacing/packet_router.h" |
| 12 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" | 16 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" |
| 13 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| 14 #include "webrtc/system_wrappers/include/clock.h" | 18 #include "webrtc/system_wrappers/include/clock.h" |
| 15 #include "webrtc/test/gmock.h" | 19 #include "webrtc/test/gmock.h" |
| 16 #include "webrtc/test/gtest.h" | 20 #include "webrtc/test/gtest.h" |
| 17 | 21 |
| 18 using ::testing::_; | 22 using ::testing::_; |
| 19 using ::testing::InSequence; | 23 using ::testing::InSequence; |
| 20 using ::testing::Invoke; | 24 using ::testing::Invoke; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 void IncomingPacket(uint16_t seq, int64_t time_ms) { | 39 void IncomingPacket(uint16_t seq, int64_t time_ms) { |
| 36 RTPHeader header; | 40 RTPHeader header; |
| 37 header.extension.hasTransportSequenceNumber = true; | 41 header.extension.hasTransportSequenceNumber = true; |
| 38 header.extension.transportSequenceNumber = seq; | 42 header.extension.transportSequenceNumber = seq; |
| 39 header.ssrc = kMediaSsrc; | 43 header.ssrc = kMediaSsrc; |
| 40 proxy_.IncomingPacket(time_ms, kDefaultPacketSize, header); | 44 proxy_.IncomingPacket(time_ms, kDefaultPacketSize, header); |
| 41 } | 45 } |
| 42 | 46 |
| 43 void Process() { | 47 void Process() { |
| 44 clock_.AdvanceTimeMilliseconds( | 48 clock_.AdvanceTimeMilliseconds( |
| 45 RemoteEstimatorProxy::kDefaultProcessIntervalMs); | 49 RemoteEstimatorProxy::kDefaultSendIntervalMs); |
| 46 proxy_.Process(); | 50 proxy_.Process(); |
| 47 } | 51 } |
| 48 | 52 |
| 49 SimulatedClock clock_; | 53 SimulatedClock clock_; |
| 50 testing::StrictMock<MockPacketRouter> router_; | 54 testing::StrictMock<MockPacketRouter> router_; |
| 51 RemoteEstimatorProxy proxy_; | 55 RemoteEstimatorProxy proxy_; |
| 52 | 56 |
| 53 const size_t kDefaultPacketSize = 100; | 57 const size_t kDefaultPacketSize = 100; |
| 54 const uint32_t kMediaSsrc = 456; | 58 const uint32_t kMediaSsrc = 456; |
| 55 const uint16_t kBaseSeq = 10; | 59 const uint16_t kBaseSeq = 10; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 EXPECT_EQ(kBaseTimeMs - 1, | 347 EXPECT_EQ(kBaseTimeMs - 1, |
| 344 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); | 348 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); |
| 345 EXPECT_EQ(kTimeoutTimeMs - kBaseTimeMs, delta_vec[1] / 1000); | 349 EXPECT_EQ(kTimeoutTimeMs - kBaseTimeMs, delta_vec[1] / 1000); |
| 346 EXPECT_EQ(1, delta_vec[2] / 1000); | 350 EXPECT_EQ(1, delta_vec[2] / 1000); |
| 347 return true; | 351 return true; |
| 348 })); | 352 })); |
| 349 | 353 |
| 350 Process(); | 354 Process(); |
| 351 } | 355 } |
| 352 | 356 |
| 357 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsZeroBeforeFirstProcess) { |
| 358 EXPECT_EQ(0, proxy_.TimeUntilNextProcess()); |
| 359 } |
| 360 |
| 361 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsDefaultOnUnkownBitrate) { |
| 362 Process(); |
| 363 EXPECT_EQ(RemoteEstimatorProxy::kDefaultSendIntervalMs, |
| 364 proxy_.TimeUntilNextProcess()); |
| 365 } |
| 366 |
| 367 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsMinIntervalOn300kbps) { |
| 368 Process(); |
| 369 proxy_.OnBitrateChanged(300000); |
| 370 EXPECT_EQ(RemoteEstimatorProxy::kMinSendIntervalMs, |
| 371 proxy_.TimeUntilNextProcess()); |
| 372 } |
| 373 |
| 374 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsMaxIntervalOn20kbps) { |
| 375 Process(); |
| 376 proxy_.OnBitrateChanged(20000); |
| 377 EXPECT_EQ(RemoteEstimatorProxy::kMaxSendIntervalMs, |
| 378 proxy_.TimeUntilNextProcess()); |
| 379 } |
| 380 |
| 381 TEST_F(RemoteEstimatorProxyTest, TwccReportsUse5PercentOfAvailableBandwidth) { |
| 382 Process(); |
| 383 proxy_.OnBitrateChanged(80000); |
| 384 // 80kbps * 0.05 = TwccReportSize(68B * 8b/B) * 1000ms / SendInterval(136ms) |
| 385 EXPECT_EQ(136, proxy_.TimeUntilNextProcess()); |
| 386 } |
| 387 |
| 353 } // namespace webrtc | 388 } // namespace webrtc |
| OLD | NEW |