Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc

Issue 1527003002: [rtp_rtcp] RtcpReceiverTest rewritten using public available interface (observers) instead intermid… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 11 #include <memory>
12 12
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #include "webrtc/base/rate_limiter.h" 15 #include "webrtc/base/rate_limiter.h"
16 #include "webrtc/common_types.h" 16 #include "webrtc/common_types.h"
17 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.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" 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" 19 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl e_stream.h"
20 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtcp_observers.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h" 21 #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/rtcp_sender.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" 23 #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" 24 #include "webrtc/test/null_transport.h"
25 #include "webrtc/typedefs.h" 25 #include "webrtc/typedefs.h"
26 26
27 namespace webrtc { 27 namespace webrtc {
28 namespace { 28 namespace {
29 using ::testing::_;
29 30
30 class TestTransport : public Transport { 31 class TestTransport : public Transport {
31 public: 32 public:
32 explicit TestTransport(RTCPReceiver* rtcp_receiver) 33 explicit TestTransport(RTCPReceiver* rtcp_receiver)
33 : rtcp_receiver_(rtcp_receiver) {} 34 : rtcp_receiver_(rtcp_receiver) {}
34 35
35 bool SendRtp(const uint8_t* /*data*/, 36 bool SendRtp(const uint8_t* /*data*/,
36 size_t /*len*/, 37 size_t /*len*/,
37 const PacketOptions& options) override { 38 const PacketOptions& options) override {
38 return false; 39 return false;
39 } 40 }
40 bool SendRtcp(const uint8_t* packet, size_t packetLength) override { 41 bool SendRtcp(const uint8_t* packet, size_t packet_size) override {
41 RTCPUtility::RTCPParserV2 rtcpParser(packet, packetLength, 42 EXPECT_TRUE(rtcp_receiver_->IncomingPacket(packet, packet_size));
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; 43 return true;
54 } 44 }
55 45
56 private: 46 private:
57 RTCPReceiver* rtcp_receiver_; 47 RTCPReceiver* rtcp_receiver_;
58 }; 48 };
59 49
60 class RtcpFormatRembTest : public ::testing::Test { 50 class RtcpFormatRembTest : public ::testing::Test {
61 protected: 51 protected:
62 RtcpFormatRembTest() 52 RtcpFormatRembTest()
(...skipping 14 matching lines...) Expand all
77 67
78 OverUseDetectorOptions over_use_detector_options_; 68 OverUseDetectorOptions over_use_detector_options_;
79 Clock* system_clock_; 69 Clock* system_clock_;
80 ModuleRtpRtcpImpl* dummy_rtp_rtcp_impl_; 70 ModuleRtpRtcpImpl* dummy_rtp_rtcp_impl_;
81 std::unique_ptr<ReceiveStatistics> receive_statistics_; 71 std::unique_ptr<ReceiveStatistics> receive_statistics_;
82 RTCPSender* rtcp_sender_; 72 RTCPSender* rtcp_sender_;
83 RTCPReceiver* rtcp_receiver_; 73 RTCPReceiver* rtcp_receiver_;
84 TestTransport* test_transport_; 74 TestTransport* test_transport_;
85 test::NullTransport null_transport_; 75 test::NullTransport null_transport_;
86 MockRemoteBitrateObserver remote_bitrate_observer_; 76 MockRemoteBitrateObserver remote_bitrate_observer_;
77 MockRtcpBandwidthObserver test_bitrate_observer_;
87 std::unique_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; 78 std::unique_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_;
88 RateLimiter retransmission_rate_limiter_; 79 RateLimiter retransmission_rate_limiter_;
89 }; 80 };
90 81
91 void RtcpFormatRembTest::SetUp() { 82 void RtcpFormatRembTest::SetUp() {
92 RtpRtcp::Configuration configuration; 83 RtpRtcp::Configuration configuration;
93 configuration.audio = false; 84 configuration.audio = false;
94 configuration.clock = system_clock_; 85 configuration.clock = system_clock_;
95 configuration.remote_bitrate_estimator = remote_bitrate_estimator_.get(); 86 configuration.remote_bitrate_estimator = remote_bitrate_estimator_.get();
96 configuration.outgoing_transport = &null_transport_; 87 configuration.outgoing_transport = &null_transport_;
97 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; 88 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
98 dummy_rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration); 89 dummy_rtp_rtcp_impl_ = new ModuleRtpRtcpImpl(configuration);
99 rtcp_receiver_ = new RTCPReceiver(system_clock_, false, nullptr, nullptr, 90 rtcp_receiver_ =
100 nullptr, nullptr, dummy_rtp_rtcp_impl_); 91 new RTCPReceiver(system_clock_, false, nullptr, &test_bitrate_observer_,
92 nullptr, nullptr, dummy_rtp_rtcp_impl_);
101 test_transport_ = new TestTransport(rtcp_receiver_); 93 test_transport_ = new TestTransport(rtcp_receiver_);
102 rtcp_sender_ = new RTCPSender(false, system_clock_, receive_statistics_.get(), 94 rtcp_sender_ = new RTCPSender(false, system_clock_, receive_statistics_.get(),
103 nullptr, nullptr, test_transport_); 95 nullptr, nullptr, test_transport_);
104 } 96 }
105 97
106 void RtcpFormatRembTest::TearDown() { 98 void RtcpFormatRembTest::TearDown() {
107 delete rtcp_sender_; 99 delete rtcp_sender_;
108 delete rtcp_receiver_; 100 delete rtcp_receiver_;
109 delete dummy_rtp_rtcp_impl_; 101 delete dummy_rtp_rtcp_impl_;
110 delete test_transport_; 102 delete test_transport_;
111 } 103 }
112 104
113 TEST_F(RtcpFormatRembTest, TestRembStatus) { 105 TEST_F(RtcpFormatRembTest, TestRembStatus) {
114 EXPECT_FALSE(rtcp_sender_->REMB()); 106 EXPECT_FALSE(rtcp_sender_->REMB());
115 rtcp_sender_->SetREMBStatus(true); 107 rtcp_sender_->SetREMBStatus(true);
116 EXPECT_TRUE(rtcp_sender_->REMB()); 108 EXPECT_TRUE(rtcp_sender_->REMB());
117 rtcp_sender_->SetREMBStatus(false); 109 rtcp_sender_->SetREMBStatus(false);
118 EXPECT_FALSE(rtcp_sender_->REMB()); 110 EXPECT_FALSE(rtcp_sender_->REMB());
119 } 111 }
120 112
121 TEST_F(RtcpFormatRembTest, TestNonCompund) { 113 TEST_F(RtcpFormatRembTest, TestNonCompund) {
122 uint32_t SSRC = 456789; 114 uint32_t SSRC = 456789;
123 rtcp_sender_->SetRTCPStatus(RtcpMode::kReducedSize); 115 rtcp_sender_->SetRTCPStatus(RtcpMode::kReducedSize);
124 rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>(1, SSRC)); 116 rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>(1, SSRC));
125 RTCPSender::FeedbackState feedback_state = 117 RTCPSender::FeedbackState feedback_state =
126 dummy_rtp_rtcp_impl_->GetFeedbackState(); 118 dummy_rtp_rtcp_impl_->GetFeedbackState();
119 EXPECT_CALL(test_bitrate_observer_, OnReceivedRtcpReceiverReport(_, _, _))
120 .Times(0);
121 EXPECT_CALL(test_bitrate_observer_, OnReceivedEstimatedBitrate(1234));
127 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb)); 122 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb));
128 } 123 }
129 124
130 TEST_F(RtcpFormatRembTest, TestCompund) { 125 TEST_F(RtcpFormatRembTest, TestCompund) {
131 uint32_t SSRCs[2] = {456789, 98765}; 126 uint32_t SSRCs[2] = {456789, 98765};
132 rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound); 127 rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound);
133 rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>(SSRCs, SSRCs + 2)); 128 rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>(SSRCs, SSRCs + 2));
134 RTCPSender::FeedbackState feedback_state = 129 RTCPSender::FeedbackState feedback_state =
135 dummy_rtp_rtcp_impl_->GetFeedbackState(); 130 dummy_rtp_rtcp_impl_->GetFeedbackState();
131 EXPECT_CALL(test_bitrate_observer_, OnReceivedRtcpReceiverReport(_, _, _));
132 EXPECT_CALL(test_bitrate_observer_, OnReceivedEstimatedBitrate(1234));
136 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb)); 133 EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb));
137 } 134 }
138 } // namespace 135 } // namespace
139 } // namespace webrtc 136 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/mocks/mock_rtcp_observers.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698