| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | |
| 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 #include <memory> | |
| 12 | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | |
| 14 | |
| 15 #include "webrtc/base/rate_limiter.h" | |
| 16 #include "webrtc/common_types.h" | |
| 17 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | |
| 18 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_observer.h" | |
| 19 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" | |
| 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h" | |
| 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" | |
| 22 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" | |
| 23 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | |
| 24 #include "webrtc/test/null_transport.h" | |
| 25 #include "webrtc/typedefs.h" | |
| 26 | |
| 27 namespace webrtc { | |
| 28 namespace { | |
| 29 | |
| 30 class TestTransport : public Transport { | |
| 31 public: | |
| 32 explicit TestTransport(RTCPReceiver* rtcp_receiver) | |
| 33 : rtcp_receiver_(rtcp_receiver) {} | |
| 34 | |
| 35 bool SendRtp(const uint8_t* /*data*/, | |
| 36 size_t /*len*/, | |
| 37 const PacketOptions& options) override { | |
| 38 return false; | |
| 39 } | |
| 40 bool SendRtcp(const uint8_t* packet, size_t packetLength) override { | |
| 41 RTCPUtility::RTCPParserV2 rtcpParser(packet, packetLength, | |
| 42 true); // Allow non-compound RTCP | |
| 43 | |
| 44 EXPECT_TRUE(rtcpParser.IsValid()); | |
| 45 RTCPHelp::RTCPPacketInformation rtcpPacketInformation; | |
| 46 EXPECT_EQ(0, rtcp_receiver_->IncomingRTCPPacket(rtcpPacketInformation, | |
| 47 &rtcpParser)); | |
| 48 | |
| 49 EXPECT_EQ((uint32_t)kRtcpRemb, | |
| 50 rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpRemb); | |
| 51 EXPECT_EQ((uint32_t)1234, | |
| 52 rtcpPacketInformation.receiverEstimatedMaxBitrate); | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 private: | |
| 57 RTCPReceiver* rtcp_receiver_; | |
| 58 }; | |
| 59 | |
| 60 class RtcpFormatRembTest : public ::testing::Test { | |
| 61 protected: | |
| 62 RtcpFormatRembTest() | |
| 63 : over_use_detector_options_(), | |
| 64 system_clock_(Clock::GetRealTimeClock()), | |
| 65 dummy_rtp_rtcp_impl_(nullptr), | |
| 66 receive_statistics_(ReceiveStatistics::Create(system_clock_)), | |
| 67 rtcp_sender_(nullptr), | |
| 68 rtcp_receiver_(nullptr), | |
| 69 test_transport_(nullptr), | |
| 70 remote_bitrate_observer_(), | |
| 71 remote_bitrate_estimator_( | |
| 72 new RemoteBitrateEstimatorSingleStream(&remote_bitrate_observer_, | |
| 73 system_clock_)), | |
| 74 retransmission_rate_limiter_(Clock::GetRealTimeClock(), 1000) {} | |
| 75 void SetUp() override; | |
| 76 void TearDown() override; | |
| 77 | |
| 78 OverUseDetectorOptions over_use_detector_options_; | |
| 79 Clock* system_clock_; | |
| 80 ModuleRtpRtcpImpl* dummy_rtp_rtcp_impl_; | |
| 81 std::unique_ptr<ReceiveStatistics> receive_statistics_; | |
| 82 RTCPSender* rtcp_sender_; | |
| 83 RTCPReceiver* rtcp_receiver_; | |
| 84 TestTransport* test_transport_; | |
| 85 test::NullTransport null_transport_; | |
| 86 MockRemoteBitrateObserver remote_bitrate_observer_; | |
| 87 std::unique_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; | |
| 88 RateLimiter retransmission_rate_limiter_; | |
| 89 }; | |
| 90 | |
| 91 void RtcpFormatRembTest::SetUp() { | |
| 92 RtpRtcp::Configuration configuration; | |
| 93 configuration.audio = false; | |
| 94 configuration.clock = system_clock_; | |
| 95 configuration.remote_bitrate_estimator = remote_bitrate_estimator_.get(); | |
| 96 configuration.outgoing_transport = &null_transport_; | |
| 97 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; | |
| 98 dummy_rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration); | |
| 99 rtcp_receiver_ = new RTCPReceiver(system_clock_, false, nullptr, nullptr, | |
| 100 nullptr, nullptr, dummy_rtp_rtcp_impl_); | |
| 101 test_transport_ = new TestTransport(rtcp_receiver_); | |
| 102 rtcp_sender_ = new RTCPSender(false, system_clock_, receive_statistics_.get(), | |
| 103 nullptr, nullptr, test_transport_); | |
| 104 } | |
| 105 | |
| 106 void RtcpFormatRembTest::TearDown() { | |
| 107 delete rtcp_sender_; | |
| 108 delete rtcp_receiver_; | |
| 109 delete dummy_rtp_rtcp_impl_; | |
| 110 delete test_transport_; | |
| 111 } | |
| 112 | |
| 113 TEST_F(RtcpFormatRembTest, TestRembStatus) { | |
| 114 EXPECT_FALSE(rtcp_sender_->REMB()); | |
| 115 rtcp_sender_->SetREMBStatus(true); | |
| 116 EXPECT_TRUE(rtcp_sender_->REMB()); | |
| 117 rtcp_sender_->SetREMBStatus(false); | |
| 118 EXPECT_FALSE(rtcp_sender_->REMB()); | |
| 119 } | |
| 120 | |
| 121 TEST_F(RtcpFormatRembTest, TestNonCompund) { | |
| 122 uint32_t SSRC = 456789; | |
| 123 rtcp_sender_->SetRTCPStatus(RtcpMode::kReducedSize); | |
| 124 rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>(1, SSRC)); | |
| 125 RTCPSender::FeedbackState feedback_state = | |
| 126 dummy_rtp_rtcp_impl_->GetFeedbackState(); | |
| 127 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb)); | |
| 128 } | |
| 129 | |
| 130 TEST_F(RtcpFormatRembTest, TestCompund) { | |
| 131 uint32_t SSRCs[2] = {456789, 98765}; | |
| 132 rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound); | |
| 133 rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>(SSRCs, SSRCs + 2)); | |
| 134 RTCPSender::FeedbackState feedback_state = | |
| 135 dummy_rtp_rtcp_impl_->GetFeedbackState(); | |
| 136 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb)); | |
| 137 } | |
| 138 } // namespace | |
| 139 } // namespace webrtc | |
| OLD | NEW |