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