OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 <algorithm> | 11 #include <algorithm> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 16 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 17 #include "webrtc/modules/pacing/mock/mock_paced_sender.h" |
17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
18 | 19 |
| 20 using ::testing::Exactly; |
| 21 using ::testing::Return; |
| 22 |
| 23 using webrtc::BitrateController; |
| 24 using webrtc::BitrateObserver; |
| 25 using webrtc::PacedSender; |
19 using webrtc::RtcpBandwidthObserver; | 26 using webrtc::RtcpBandwidthObserver; |
20 using webrtc::BitrateObserver; | |
21 using webrtc::BitrateController; | |
22 | 27 |
23 uint8_t WeightedLoss(int num_packets1, uint8_t fraction_loss1, | 28 uint8_t WeightedLoss(int num_packets1, uint8_t fraction_loss1, |
24 int num_packets2, uint8_t fraction_loss2) { | 29 int num_packets2, uint8_t fraction_loss2) { |
25 int weighted_sum = num_packets1 * fraction_loss1 + | 30 int weighted_sum = num_packets1 * fraction_loss1 + |
26 num_packets2 * fraction_loss2; | 31 num_packets2 * fraction_loss2; |
27 int total_num_packets = num_packets1 + num_packets2; | 32 int total_num_packets = num_packets1 + num_packets2; |
28 return (weighted_sum + total_num_packets / 2) / total_num_packets; | 33 return (weighted_sum + total_num_packets / 2) / total_num_packets; |
29 } | 34 } |
30 | 35 |
31 webrtc::RTCPReportBlock CreateReportBlock( | 36 webrtc::RTCPReportBlock CreateReportBlock( |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 EXPECT_EQ(120000, bitrate_observer_.last_bitrate_); | 397 EXPECT_EQ(120000, bitrate_observer_.last_bitrate_); |
393 controller_->SetReservedBitrate(50000); | 398 controller_->SetReservedBitrate(50000); |
394 bandwidth_observer_->OnReceivedEstimatedBitrate(120000); | 399 bandwidth_observer_->OnReceivedEstimatedBitrate(120000); |
395 // Limited by min bitrate. | 400 // Limited by min bitrate. |
396 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); | 401 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); |
397 | 402 |
398 controller_->SetReservedBitrate(10000); | 403 controller_->SetReservedBitrate(10000); |
399 bandwidth_observer_->OnReceivedEstimatedBitrate(1); | 404 bandwidth_observer_->OnReceivedEstimatedBitrate(1); |
400 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); | 405 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); |
401 } | 406 } |
OLD | NEW |