mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 1 | /* |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | |
| 12 | // This file includes unit tests for ViERemb. |
| 13 | |
| 14 | #include <gmock/gmock.h> |
| 15 | #include <gtest/gtest.h> |
| 16 | |
mflodman@webrtc.org | f89fb9d | 2012-11-22 09:41:42 +0000 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
mflodman@webrtc.org | c289f9f | 2012-11-16 13:24:18 +0000 | [diff] [blame] | 19 | #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" |
| 20 | #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" |
| 21 | #include "webrtc/modules/utility/interface/process_thread.h" |
| 22 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
| 23 | #include "webrtc/system_wrappers/interface/tick_util.h" |
| 24 | #include "webrtc/video_engine/vie_remb.h" |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 25 | |
| 26 | using ::testing::_; |
| 27 | using ::testing::AnyNumber; |
| 28 | using ::testing::Return; |
| 29 | |
| 30 | namespace webrtc { |
| 31 | |
mflodman@webrtc.org | 9ec883e | 2012-03-05 17:12:41 +0000 | [diff] [blame] | 32 | class TestProcessThread : public ProcessThread { |
| 33 | public: |
| 34 | explicit TestProcessThread() {} |
| 35 | ~TestProcessThread() {} |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 36 | virtual int32_t Start() { return 0; } |
| 37 | virtual int32_t Stop() { return 0; } |
| 38 | virtual int32_t RegisterModule(const Module* module) { return 0; } |
| 39 | virtual int32_t DeRegisterModule(const Module* module) { return 0; } |
mflodman@webrtc.org | 9ec883e | 2012-03-05 17:12:41 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 42 | class ViERembTest : public ::testing::Test { |
| 43 | protected: |
| 44 | virtual void SetUp() { |
mflodman@webrtc.org | c289f9f | 2012-11-16 13:24:18 +0000 | [diff] [blame] | 45 | TickTime::UseFakeClock(12345); |
mflodman@webrtc.org | 9ec883e | 2012-03-05 17:12:41 +0000 | [diff] [blame] | 46 | process_thread_.reset(new TestProcessThread); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 47 | vie_remb_.reset(new VieRemb()); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 48 | } |
mflodman@webrtc.org | 9ec883e | 2012-03-05 17:12:41 +0000 | [diff] [blame] | 49 | scoped_ptr<TestProcessThread> process_thread_; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 50 | scoped_ptr<VieRemb> vie_remb_; |
| 51 | }; |
| 52 | |
mflodman@webrtc.org | ab2610f | 2012-06-29 10:05:28 +0000 | [diff] [blame] | 53 | TEST_F(ViERembTest, OneModuleTestForSendingRemb) { |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 54 | MockRtpRtcp rtp; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 55 | vie_remb_->AddReceiveChannel(&rtp); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 56 | vie_remb_->AddRembSender(&rtp); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 57 | |
| 58 | const unsigned int bitrate_estimate = 456; |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 59 | unsigned int ssrc = 1234; |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 60 | std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 61 | |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 62 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 63 | |
mflodman@webrtc.org | c289f9f | 2012-11-16 13:24:18 +0000 | [diff] [blame] | 64 | TickTime::AdvanceFakeClock(1000); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 65 | EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _)) |
| 66 | .Times(1); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 67 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 68 | |
| 69 | // Lower bitrate to send another REMB packet. |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 70 | EXPECT_CALL(rtp, SetREMBData(bitrate_estimate - 100, 1, _)) |
| 71 | .Times(1); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 72 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate - 100); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 73 | |
| 74 | vie_remb_->RemoveReceiveChannel(&rtp); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 75 | vie_remb_->RemoveRembSender(&rtp); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 76 | } |
| 77 | |
mflodman@webrtc.org | ab2610f | 2012-06-29 10:05:28 +0000 | [diff] [blame] | 78 | TEST_F(ViERembTest, LowerEstimateToSendRemb) { |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 79 | MockRtpRtcp rtp; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 80 | vie_remb_->AddReceiveChannel(&rtp); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 81 | vie_remb_->AddRembSender(&rtp); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 82 | |
| 83 | unsigned int bitrate_estimate = 456; |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 84 | unsigned int ssrc = 1234; |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 85 | std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 86 | |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 87 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 88 | // Call OnReceiveBitrateChanged twice to get a first estimate. |
mflodman@webrtc.org | c289f9f | 2012-11-16 13:24:18 +0000 | [diff] [blame] | 89 | TickTime::AdvanceFakeClock(1000); |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 90 | EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _)) |
| 91 | .Times(1); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 92 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 93 | |
| 94 | // Lower the estimate with more than 3% to trigger a call to SetREMBData right |
| 95 | // away. |
| 96 | bitrate_estimate = bitrate_estimate - 100; |
| 97 | EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _)) |
| 98 | .Times(1); |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 99 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 100 | } |
| 101 | |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 102 | TEST_F(ViERembTest, VerifyIncreasingAndDecreasing) { |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 103 | MockRtpRtcp rtp_0; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 104 | MockRtpRtcp rtp_1; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 105 | vie_remb_->AddReceiveChannel(&rtp_0); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 106 | vie_remb_->AddRembSender(&rtp_0); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 107 | vie_remb_->AddReceiveChannel(&rtp_1); |
| 108 | |
| 109 | unsigned int bitrate_estimate[] = { 456, 789 }; |
| 110 | unsigned int ssrc[] = { 1234, 5678 }; |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 111 | std::vector<unsigned int> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0])); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 112 | |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 113 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate[0]); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 114 | |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 115 | // Call OnReceiveBitrateChanged twice to get a first estimate. |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 116 | EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate[0], 2, _)) |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 117 | .Times(1); |
mflodman@webrtc.org | c289f9f | 2012-11-16 13:24:18 +0000 | [diff] [blame] | 118 | TickTime::AdvanceFakeClock(1000); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 119 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate[0]); |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 120 | |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 121 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate[1] + 100); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 122 | |
| 123 | // Lower the estimate to trigger a callback. |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 124 | EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate[1], 2, _)) |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 125 | .Times(1); |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 126 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate[1]); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 127 | |
| 128 | vie_remb_->RemoveReceiveChannel(&rtp_0); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 129 | vie_remb_->RemoveRembSender(&rtp_0); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 130 | vie_remb_->RemoveReceiveChannel(&rtp_1); |
| 131 | } |
| 132 | |
mflodman@webrtc.org | ab2610f | 2012-06-29 10:05:28 +0000 | [diff] [blame] | 133 | TEST_F(ViERembTest, NoRembForIncreasedBitrate) { |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 134 | MockRtpRtcp rtp_0; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 135 | MockRtpRtcp rtp_1; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 136 | vie_remb_->AddReceiveChannel(&rtp_0); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 137 | vie_remb_->AddRembSender(&rtp_0); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 138 | vie_remb_->AddReceiveChannel(&rtp_1); |
| 139 | |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 140 | unsigned int bitrate_estimate = 456; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 141 | unsigned int ssrc[] = { 1234, 5678 }; |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 142 | std::vector<unsigned int> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0])); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 143 | |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 144 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 145 | // Call OnReceiveBitrateChanged twice to get a first estimate. |
mflodman@webrtc.org | c289f9f | 2012-11-16 13:24:18 +0000 | [diff] [blame] | 146 | TickTime::AdvanceFakeClock(1000); |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 147 | EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate, 2, _)) |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 148 | .Times(1); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 149 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 150 | |
| 151 | // Increased estimate shouldn't trigger a callback right away. |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 152 | EXPECT_CALL(rtp_0, SetREMBData(_, _, _)) |
| 153 | .Times(0); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 154 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate + 1); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 155 | |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 156 | // Decreasing the estimate less than 3% shouldn't trigger a new callback. |
mflodman@webrtc.org | ab2610f | 2012-06-29 10:05:28 +0000 | [diff] [blame] | 157 | EXPECT_CALL(rtp_0, SetREMBData(_, _, _)) |
| 158 | .Times(0); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 159 | int lower_estimate = bitrate_estimate * 98 / 100; |
| 160 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, lower_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 161 | |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 162 | vie_remb_->RemoveReceiveChannel(&rtp_1); |
| 163 | vie_remb_->RemoveReceiveChannel(&rtp_0); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 164 | vie_remb_->RemoveRembSender(&rtp_0); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 165 | } |
| 166 | |
mflodman@webrtc.org | ab2610f | 2012-06-29 10:05:28 +0000 | [diff] [blame] | 167 | TEST_F(ViERembTest, ChangeSendRtpModule) { |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 168 | MockRtpRtcp rtp_0; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 169 | MockRtpRtcp rtp_1; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 170 | vie_remb_->AddReceiveChannel(&rtp_0); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 171 | vie_remb_->AddRembSender(&rtp_0); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 172 | vie_remb_->AddReceiveChannel(&rtp_1); |
| 173 | |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 174 | unsigned int bitrate_estimate = 456; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 175 | unsigned int ssrc[] = { 1234, 5678 }; |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 176 | std::vector<unsigned int> ssrcs(ssrc, ssrc + sizeof(ssrc) / sizeof(ssrc[0])); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 177 | |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 178 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 179 | // Call OnReceiveBitrateChanged twice to get a first estimate. |
mflodman@webrtc.org | c289f9f | 2012-11-16 13:24:18 +0000 | [diff] [blame] | 180 | TickTime::AdvanceFakeClock(1000); |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 181 | EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate, 2, _)) |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 182 | .Times(1); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 183 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 184 | |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 185 | // Decrease estimate to trigger a REMB. |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 186 | bitrate_estimate = bitrate_estimate - 100; |
| 187 | EXPECT_CALL(rtp_0, SetREMBData(bitrate_estimate, 2, _)) |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 188 | .Times(1); |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 189 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 190 | |
| 191 | // Remove the sending module, add it again -> should get remb on the second |
| 192 | // module. |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 193 | vie_remb_->RemoveRembSender(&rtp_0); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 194 | vie_remb_->AddRembSender(&rtp_1); |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 195 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 196 | |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 197 | bitrate_estimate = bitrate_estimate - 100; |
| 198 | EXPECT_CALL(rtp_1, SetREMBData(bitrate_estimate, 2, _)) |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 199 | .Times(1); |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 200 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 201 | |
| 202 | vie_remb_->RemoveReceiveChannel(&rtp_0); |
| 203 | vie_remb_->RemoveReceiveChannel(&rtp_1); |
| 204 | } |
| 205 | |
mflodman@webrtc.org | ab2610f | 2012-06-29 10:05:28 +0000 | [diff] [blame] | 206 | TEST_F(ViERembTest, OnlyOneRembForDoubleProcess) { |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 207 | MockRtpRtcp rtp; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 208 | unsigned int bitrate_estimate = 456; |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 209 | unsigned int ssrc = 1234; |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 210 | std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 211 | |
| 212 | vie_remb_->AddReceiveChannel(&rtp); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 213 | vie_remb_->AddRembSender(&rtp); |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 214 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 215 | // Call OnReceiveBitrateChanged twice to get a first estimate. |
mflodman@webrtc.org | c289f9f | 2012-11-16 13:24:18 +0000 | [diff] [blame] | 216 | TickTime::AdvanceFakeClock(1000); |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 217 | EXPECT_CALL(rtp, SetREMBData(_, _, _)) |
| 218 | .Times(1); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 219 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 220 | |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 221 | // Lower the estimate, should trigger a call to SetREMBData right away. |
| 222 | bitrate_estimate = bitrate_estimate - 100; |
| 223 | EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, 1, _)) |
| 224 | .Times(1); |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 225 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 226 | |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 227 | // Call OnReceiveBitrateChanged again, this should not trigger a new callback. |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 228 | EXPECT_CALL(rtp, SetREMBData(_, _, _)) |
| 229 | .Times(0); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 230 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 231 | vie_remb_->RemoveReceiveChannel(&rtp); |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 232 | vie_remb_->RemoveRembSender(&rtp); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 233 | } |
| 234 | |
mflodman@webrtc.org | 5284d6e | 2012-04-23 13:22:26 +0000 | [diff] [blame] | 235 | // Only register receiving modules and make sure we fallback to trigger a REMB |
| 236 | // packet on this one. |
mflodman@webrtc.org | ab2610f | 2012-06-29 10:05:28 +0000 | [diff] [blame] | 237 | TEST_F(ViERembTest, NoSendingRtpModule) { |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 238 | MockRtpRtcp rtp; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 239 | vie_remb_->AddReceiveChannel(&rtp); |
| 240 | |
| 241 | unsigned int bitrate_estimate = 456; |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 242 | unsigned int ssrc = 1234; |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 243 | std::vector<unsigned int> ssrcs(&ssrc, &ssrc + 1); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 244 | |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 245 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 246 | |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 247 | // Call OnReceiveBitrateChanged twice to get a first estimate. |
mflodman@webrtc.org | c289f9f | 2012-11-16 13:24:18 +0000 | [diff] [blame] | 248 | TickTime::AdvanceFakeClock(1000); |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 249 | EXPECT_CALL(rtp, SetREMBData(_, _, _)) |
| 250 | .Times(1); |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 251 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 252 | |
mflodman@webrtc.org | 5284d6e | 2012-04-23 13:22:26 +0000 | [diff] [blame] | 253 | // Lower the estimate to trigger a new packet REMB packet. |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 254 | bitrate_estimate = bitrate_estimate - 100; |
| 255 | EXPECT_CALL(rtp, SetREMBData(_, _, _)) |
mflodman@webrtc.org | 5284d6e | 2012-04-23 13:22:26 +0000 | [diff] [blame] | 256 | .Times(1); |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 257 | vie_remb_->OnReceiveBitrateChanged(&ssrcs, bitrate_estimate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | } // namespace webrtc |