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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc

Issue 2381833003: Change TWCC send interval to reduce overhead on low BW situations. (Closed)
Patch Set: fix unit-test build Created 4 years, 2 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) 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/test/gmock.h"
15 #include "webrtc/test/gtest.h"
16
17 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller .h"
11 #include "webrtc/modules/pacing/packet_router.h" 18 #include "webrtc/modules/pacing/packet_router.h"
12 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" 19 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h"
13 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
14 #include "webrtc/system_wrappers/include/clock.h" 21 #include "webrtc/system_wrappers/include/clock.h"
15 #include "webrtc/test/gmock.h"
16 #include "webrtc/test/gtest.h"
17 22
18 using ::testing::_; 23 using ::testing::_;
19 using ::testing::InSequence; 24 using ::testing::InSequence;
20 using ::testing::Invoke; 25 using ::testing::Invoke;
21 using ::testing::Return; 26 using ::testing::Return;
22 27
23 namespace webrtc { 28 namespace webrtc {
24 29
25 class MockPacketRouter : public PacketRouter { 30 class MockPacketRouter : public PacketRouter {
26 public: 31 public:
27 MOCK_METHOD1(SendFeedback, bool(rtcp::TransportFeedback* packet)); 32 MOCK_METHOD1(SendFeedback, bool(rtcp::TransportFeedback* packet));
28 }; 33 };
29 34
30 class RemoteEstimatorProxyTest : public ::testing::Test { 35 class RemoteEstimatorProxyTest : public ::testing::Test {
31 public: 36 public:
32 RemoteEstimatorProxyTest() : clock_(0), proxy_(&clock_, &router_) {} 37 RemoteEstimatorProxyTest()
38 : clock_(0), proxy_(&clock_, &router_, &bitrate_controller_) {}
33 39
34 protected: 40 protected:
35 void IncomingPacket(uint16_t seq, int64_t time_ms) { 41 void IncomingPacket(uint16_t seq, int64_t time_ms) {
36 RTPHeader header; 42 RTPHeader header;
37 header.extension.hasTransportSequenceNumber = true; 43 header.extension.hasTransportSequenceNumber = true;
38 header.extension.transportSequenceNumber = seq; 44 header.extension.transportSequenceNumber = seq;
39 header.ssrc = kMediaSsrc; 45 header.ssrc = kMediaSsrc;
40 proxy_.IncomingPacket(time_ms, kDefaultPacketSize, header); 46 proxy_.IncomingPacket(time_ms, kDefaultPacketSize, header);
41 } 47 }
42 48
43 void Process() { 49 void Process() {
44 clock_.AdvanceTimeMilliseconds( 50 clock_.AdvanceTimeMilliseconds(50);
stefan-webrtc 2016/10/26 14:45:16 Why did you change this?
michaelt 2016/10/27 15:15:45 Because there is no default process interval. The
45 RemoteEstimatorProxy::kDefaultProcessIntervalMs);
46 proxy_.Process(); 51 proxy_.Process();
47 } 52 }
48 53
49 SimulatedClock clock_; 54 SimulatedClock clock_;
50 testing::StrictMock<MockPacketRouter> router_; 55 testing::StrictMock<MockPacketRouter> router_;
56 testing::StrictMock<test::MockBitrateController> bitrate_controller_;
51 RemoteEstimatorProxy proxy_; 57 RemoteEstimatorProxy proxy_;
52 58
53 const size_t kDefaultPacketSize = 100; 59 const size_t kDefaultPacketSize = 100;
54 const uint32_t kMediaSsrc = 456; 60 const uint32_t kMediaSsrc = 456;
55 const uint16_t kBaseSeq = 10; 61 const uint16_t kBaseSeq = 10;
56 const int64_t kBaseTimeMs = 123; 62 const int64_t kBaseTimeMs = 123;
57 const int64_t kMaxSmallDeltaMs = 63 const int64_t kMaxSmallDeltaMs =
58 (rtcp::TransportFeedback::kDeltaScaleFactor * 0xFF) / 1000; 64 (rtcp::TransportFeedback::kDeltaScaleFactor * 0xFF) / 1000;
59 }; 65 };
60 66
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 EXPECT_EQ(kBaseTimeMs - 1, 349 EXPECT_EQ(kBaseTimeMs - 1,
344 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000); 350 (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
345 EXPECT_EQ(kTimeoutTimeMs - kBaseTimeMs, delta_vec[1] / 1000); 351 EXPECT_EQ(kTimeoutTimeMs - kBaseTimeMs, delta_vec[1] / 1000);
346 EXPECT_EQ(1, delta_vec[2] / 1000); 352 EXPECT_EQ(1, delta_vec[2] / 1000);
347 return true; 353 return true;
348 })); 354 }));
349 355
350 Process(); 356 Process();
351 } 357 }
352 358
359 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsZeroBeforeFirstProcess) {
360 EXPECT_EQ(0, proxy_.TimeUntilNextProcess());
361 }
362
363 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsMinIntervalOn300kbps) {
364 EXPECT_CALL(bitrate_controller_, AvailableBandwidth(testing::NotNull()))
365 .Times(1)
366 .WillOnce(Invoke([](uint32_t* bitrate) {
367 *bitrate = 300000;
368 return false;
369 }));
370
371 Process();
372 EXPECT_EQ(RemoteEstimatorProxy::kMinSendIntervalMs,
373 proxy_.TimeUntilNextProcess());
374 }
375
376 TEST_F(RemoteEstimatorProxyTest, TimeUntilNextProcessIsMaxIntervalOn20kbps) {
377 EXPECT_CALL(bitrate_controller_, AvailableBandwidth(testing::NotNull()))
378 .Times(1)
379 .WillOnce(Invoke([](uint32_t* bitrate) {
380 *bitrate = 20000;
381 return false;
382 }));
383
384 Process();
385 EXPECT_EQ(RemoteEstimatorProxy::kMaxSendIntervalMs,
386 proxy_.TimeUntilNextProcess());
387 }
388
389 TEST_F(RemoteEstimatorProxyTest, TwccReportsUse5PercentOfAvailableBandwidth) {
390 EXPECT_CALL(bitrate_controller_, AvailableBandwidth(testing::NotNull()))
391 .Times(1)
392 .WillOnce(Invoke([](uint32_t* bitrate) {
393 *bitrate = 80000;
394 return false;
395 }));
396 Process();
397 // 80kbps * 0.05 = TwccReportSize(52B * 8b/B) * 1000ms / SendInterval(104ms)
398 EXPECT_EQ(104, proxy_.TimeUntilNextProcess());
399 }
400
353 } // namespace webrtc 401 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698