| 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 <limits> | 11 #include <limits> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/base/scoped_ptr.h" | 18 #include "webrtc/base/scoped_ptr.h" |
| 19 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller
.h" |
| 19 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_estimator.h" | 20 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_estimator.h" |
| 20 #include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h" | 21 #include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h" |
| 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| 23 #include "webrtc/modules/utility/include/mock/mock_process_thread.h" | 24 #include "webrtc/modules/utility/include/mock/mock_process_thread.h" |
| 24 #include "webrtc/system_wrappers/include/clock.h" | 25 #include "webrtc/system_wrappers/include/clock.h" |
| 25 | 26 |
| 26 using ::testing::_; | 27 using ::testing::_; |
| 27 using ::testing::Invoke; | 28 using ::testing::Invoke; |
| 28 | 29 |
| 29 namespace webrtc { | 30 namespace webrtc { |
| 30 namespace test { | 31 namespace test { |
| 31 | 32 |
| 32 class TransportFeedbackAdapterTest : public ::testing::Test { | 33 class TransportFeedbackAdapterTest : public ::testing::Test { |
| 33 public: | 34 public: |
| 34 TransportFeedbackAdapterTest() | 35 TransportFeedbackAdapterTest() |
| 35 : clock_(0), | 36 : clock_(0), |
| 36 bitrate_estimator_(nullptr), | 37 bitrate_estimator_(nullptr), |
| 38 bitrate_controller_(this), |
| 37 receiver_estimated_bitrate_(0) {} | 39 receiver_estimated_bitrate_(0) {} |
| 38 | 40 |
| 39 virtual ~TransportFeedbackAdapterTest() {} | 41 virtual ~TransportFeedbackAdapterTest() {} |
| 40 | 42 |
| 41 virtual void SetUp() { | 43 virtual void SetUp() { |
| 42 adapter_.reset(new TransportFeedbackAdapter( | 44 adapter_.reset(new TransportFeedbackAdapter(&bitrate_controller_, &clock_, |
| 43 new RtcpBandwidthObserverAdapter(this), &clock_, &process_thread_)); | 45 &process_thread_)); |
| 44 | 46 |
| 45 bitrate_estimator_ = new MockRemoteBitrateEstimator(); | 47 bitrate_estimator_ = new MockRemoteBitrateEstimator(); |
| 46 EXPECT_CALL(process_thread_, RegisterModule(bitrate_estimator_)).Times(1); | 48 EXPECT_CALL(process_thread_, RegisterModule(bitrate_estimator_)).Times(1); |
| 47 adapter_->SetBitrateEstimator(bitrate_estimator_); | 49 adapter_->SetBitrateEstimator(bitrate_estimator_); |
| 48 } | 50 } |
| 49 | 51 |
| 50 virtual void TearDown() { | 52 virtual void TearDown() { |
| 51 EXPECT_CALL(process_thread_, DeRegisterModule(bitrate_estimator_)).Times(1); | 53 EXPECT_CALL(process_thread_, DeRegisterModule(bitrate_estimator_)).Times(1); |
| 52 adapter_.reset(); | 54 adapter_.reset(); |
| 53 } | 55 } |
| 54 | 56 |
| 55 protected: | 57 protected: |
| 56 // Proxy class used since TransportFeedbackAdapter will own the instance | 58 // Proxy class used since TransportFeedbackAdapter will own the instance |
| 57 // passed at construction. | 59 // passed at construction. |
| 58 class RtcpBandwidthObserverAdapter : public RtcpBandwidthObserver { | 60 class MockBitrateControllerAdapter : public MockBitrateController { |
| 59 public: | 61 public: |
| 60 explicit RtcpBandwidthObserverAdapter(TransportFeedbackAdapterTest* owner) | 62 explicit MockBitrateControllerAdapter(TransportFeedbackAdapterTest* owner) |
| 61 : owner_(owner) {} | 63 : MockBitrateController(), owner_(owner) {} |
| 62 | 64 |
| 63 void OnReceivedEstimatedBitrate(uint32_t bitrate) override { | 65 ~MockBitrateControllerAdapter() override {} |
| 64 owner_->receiver_estimated_bitrate_ = bitrate; | |
| 65 } | |
| 66 | 66 |
| 67 void OnReceivedRtcpReceiverReport(const ReportBlockList& report_blocks, | 67 void UpdateDelayBasedEstimate(uint32_t bitrate_bps) override { |
| 68 int64_t rtt, | 68 owner_->receiver_estimated_bitrate_ = bitrate_bps; |
| 69 int64_t now_ms) override { | |
| 70 RTC_NOTREACHED(); | |
| 71 } | 69 } |
| 72 | 70 |
| 73 TransportFeedbackAdapterTest* const owner_; | 71 TransportFeedbackAdapterTest* const owner_; |
| 74 }; | 72 }; |
| 75 | 73 |
| 76 void OnReceivedEstimatedBitrate(uint32_t bitrate) {} | 74 void OnReceivedEstimatedBitrate(uint32_t bitrate) {} |
| 77 | 75 |
| 78 void OnReceivedRtcpReceiverReport(const ReportBlockList& report_blocks, | 76 void OnReceivedRtcpReceiverReport(const ReportBlockList& report_blocks, |
| 79 int64_t rtt, | 77 int64_t rtt, |
| 80 int64_t now_ms) {} | 78 int64_t now_ms) {} |
| (...skipping 25 matching lines...) Expand all Loading... |
| 106 void OnSentPacket(PacketInfo info) { | 104 void OnSentPacket(PacketInfo info) { |
| 107 info.arrival_time_ms = 0; | 105 info.arrival_time_ms = 0; |
| 108 adapter_->AddPacket(info.sequence_number, info.payload_size, | 106 adapter_->AddPacket(info.sequence_number, info.payload_size, |
| 109 info.was_paced); | 107 info.was_paced); |
| 110 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms); | 108 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms); |
| 111 } | 109 } |
| 112 | 110 |
| 113 SimulatedClock clock_; | 111 SimulatedClock clock_; |
| 114 MockProcessThread process_thread_; | 112 MockProcessThread process_thread_; |
| 115 MockRemoteBitrateEstimator* bitrate_estimator_; | 113 MockRemoteBitrateEstimator* bitrate_estimator_; |
| 114 MockBitrateControllerAdapter bitrate_controller_; |
| 116 rtc::scoped_ptr<TransportFeedbackAdapter> adapter_; | 115 rtc::scoped_ptr<TransportFeedbackAdapter> adapter_; |
| 117 | 116 |
| 118 uint32_t receiver_estimated_bitrate_; | 117 uint32_t receiver_estimated_bitrate_; |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { | 120 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { |
| 122 std::vector<PacketInfo> packets; | 121 std::vector<PacketInfo> packets; |
| 123 packets.push_back(PacketInfo(100, 200, 0, 1500, true)); | 122 packets.push_back(PacketInfo(100, 200, 0, 1500, true)); |
| 124 packets.push_back(PacketInfo(110, 210, 1, 1500, true)); | 123 packets.push_back(PacketInfo(110, 210, 1, 1500, true)); |
| 125 packets.push_back(PacketInfo(120, 220, 2, 1500, true)); | 124 packets.push_back(PacketInfo(120, 220, 2, 1500, true)); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 })); | 315 })); |
| 317 adapter_->OnTransportFeedback(*feedback.get()); | 316 adapter_->OnTransportFeedback(*feedback.get()); |
| 318 | 317 |
| 319 sent_packets.push_back(info); | 318 sent_packets.push_back(info); |
| 320 | 319 |
| 321 ComparePacketVectors(sent_packets, received_feedback); | 320 ComparePacketVectors(sent_packets, received_feedback); |
| 322 } | 321 } |
| 323 | 322 |
| 324 } // namespace test | 323 } // namespace test |
| 325 } // namespace webrtc | 324 } // namespace webrtc |
| OLD | NEW |