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

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

Powered by Google App Engine
This is Rietveld 408576698