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

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

Issue 2540363003: Wire up rtcp xr target bitrate on receive side. (Closed)
Patch Set: Actual fuzzer fix Created 4 years 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 "webrtc/base/arraysize.h" 13 #include "webrtc/base/arraysize.h"
14 #include "webrtc/base/array_view.h" 14 #include "webrtc/base/array_view.h"
15 #include "webrtc/base/random.h" 15 #include "webrtc/base/random.h"
16 #include "webrtc/common_types.h" 16 #include "webrtc/common_types.h"
17 #include "webrtc/common_video/include/video_bitrate_allocator.h"
17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h"
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 }; 90 };
90 91
91 class MockModuleRtpRtcp : public RTCPReceiver::ModuleRtpRtcp { 92 class MockModuleRtpRtcp : public RTCPReceiver::ModuleRtpRtcp {
92 public: 93 public:
93 MOCK_METHOD1(SetTmmbn, void(std::vector<rtcp::TmmbItem>)); 94 MOCK_METHOD1(SetTmmbn, void(std::vector<rtcp::TmmbItem>));
94 MOCK_METHOD0(OnRequestSendReport, void()); 95 MOCK_METHOD0(OnRequestSendReport, void());
95 MOCK_METHOD1(OnReceivedNack, void(const std::vector<uint16_t>&)); 96 MOCK_METHOD1(OnReceivedNack, void(const std::vector<uint16_t>&));
96 MOCK_METHOD1(OnReceivedRtcpReportBlocks, void(const ReportBlockList&)); 97 MOCK_METHOD1(OnReceivedRtcpReportBlocks, void(const ReportBlockList&));
97 }; 98 };
98 99
100 class MockVideoBitrateAllocationObserver
101 : public VideoBitrateAllocationObserver {
102 public:
103 MOCK_METHOD1(OnBitrateAllocationUpdated,
104 void(const BitrateAllocation& allocation));
105 };
106
99 // SSRC of remote peer, that sends rtcp packet to the rtcp receiver under test. 107 // SSRC of remote peer, that sends rtcp packet to the rtcp receiver under test.
100 constexpr uint32_t kSenderSsrc = 0x10203; 108 constexpr uint32_t kSenderSsrc = 0x10203;
101 // SSRCs of local peer, that rtcp packet addressed to. 109 // SSRCs of local peer, that rtcp packet addressed to.
102 constexpr uint32_t kReceiverMainSsrc = 0x123456; 110 constexpr uint32_t kReceiverMainSsrc = 0x123456;
103 // RtcpReceiver can accept several ssrc, e.g. regular and rtx streams. 111 // RtcpReceiver can accept several ssrc, e.g. regular and rtx streams.
104 constexpr uint32_t kReceiverExtraSsrc = 0x1234567; 112 constexpr uint32_t kReceiverExtraSsrc = 0x1234567;
105 // SSRCs to ignore (i.e. not configured in RtcpReceiver). 113 // SSRCs to ignore (i.e. not configured in RtcpReceiver).
106 constexpr uint32_t kNotToUsSsrc = 0x654321; 114 constexpr uint32_t kNotToUsSsrc = 0x654321;
107 constexpr uint32_t kUnknownSenderSsrc = 0x54321; 115 constexpr uint32_t kUnknownSenderSsrc = 0x54321;
108 116
109 } // namespace 117 } // namespace
110 118
111 class RtcpReceiverTest : public ::testing::Test { 119 class RtcpReceiverTest : public ::testing::Test {
112 protected: 120 protected:
113 RtcpReceiverTest() 121 RtcpReceiverTest()
114 : system_clock_(1335900000), 122 : system_clock_(1335900000),
115 rtcp_receiver_(&system_clock_, 123 rtcp_receiver_(&system_clock_,
116 false, 124 false,
117 &packet_type_counter_observer_, 125 &packet_type_counter_observer_,
118 &bandwidth_observer_, 126 &bandwidth_observer_,
119 &intra_frame_observer_, 127 &intra_frame_observer_,
120 &transport_feedback_observer_, 128 &transport_feedback_observer_,
129 &bitrate_allocation_observer_,
121 &rtp_rtcp_impl_) {} 130 &rtp_rtcp_impl_) {}
122 void SetUp() { 131 void SetUp() {
123 std::set<uint32_t> ssrcs = {kReceiverMainSsrc, kReceiverExtraSsrc}; 132 std::set<uint32_t> ssrcs = {kReceiverMainSsrc, kReceiverExtraSsrc};
124 rtcp_receiver_.SetSsrcs(kReceiverMainSsrc, ssrcs); 133 rtcp_receiver_.SetSsrcs(kReceiverMainSsrc, ssrcs);
125 134
126 rtcp_receiver_.SetRemoteSSRC(kSenderSsrc); 135 rtcp_receiver_.SetRemoteSSRC(kSenderSsrc);
127 } 136 }
128 137
129 void InjectRtcpPacket(rtc::ArrayView<const uint8_t> raw) { 138 void InjectRtcpPacket(rtc::ArrayView<const uint8_t> raw) {
130 rtcp_receiver_.IncomingPacket(raw.data(), raw.size()); 139 rtcp_receiver_.IncomingPacket(raw.data(), raw.size());
131 } 140 }
132 141
133 void InjectRtcpPacket(const rtcp::RtcpPacket& packet) { 142 void InjectRtcpPacket(const rtcp::RtcpPacket& packet) {
134 rtc::Buffer raw = packet.Build(); 143 rtc::Buffer raw = packet.Build();
135 rtcp_receiver_.IncomingPacket(raw.data(), raw.size()); 144 rtcp_receiver_.IncomingPacket(raw.data(), raw.size());
136 } 145 }
137 146
138 SimulatedClock system_clock_; 147 SimulatedClock system_clock_;
139 // Callbacks to packet_type_counter_observer are frequent but most of the time 148 // Callbacks to packet_type_counter_observer are frequent but most of the time
140 // are not interesting. 149 // are not interesting.
141 NiceMock<MockRtcpPacketTypeCounterObserver> packet_type_counter_observer_; 150 NiceMock<MockRtcpPacketTypeCounterObserver> packet_type_counter_observer_;
142 StrictMock<MockRtcpBandwidthObserver> bandwidth_observer_; 151 StrictMock<MockRtcpBandwidthObserver> bandwidth_observer_;
143 StrictMock<MockRtcpIntraFrameObserver> intra_frame_observer_; 152 StrictMock<MockRtcpIntraFrameObserver> intra_frame_observer_;
144 StrictMock<MockTransportFeedbackObserver> transport_feedback_observer_; 153 StrictMock<MockTransportFeedbackObserver> transport_feedback_observer_;
154 StrictMock<MockVideoBitrateAllocationObserver> bitrate_allocation_observer_;
145 StrictMock<MockModuleRtpRtcp> rtp_rtcp_impl_; 155 StrictMock<MockModuleRtpRtcp> rtp_rtcp_impl_;
146 156
147 RTCPReceiver rtcp_receiver_; 157 RTCPReceiver rtcp_receiver_;
148 }; 158 };
149 159
150 TEST_F(RtcpReceiverTest, BrokenPacketIsIgnored) { 160 TEST_F(RtcpReceiverTest, BrokenPacketIsIgnored) {
151 const uint8_t bad_packet[] = {0, 0, 0, 0}; 161 const uint8_t bad_packet[] = {0, 0, 0, 0};
152 EXPECT_CALL(packet_type_counter_observer_, 162 EXPECT_CALL(packet_type_counter_observer_,
153 RtcpPacketTypesCounterUpdated(_, _)) 163 RtcpPacketTypesCounterUpdated(_, _))
154 .Times(0); 164 .Times(0);
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 1269
1260 TEST_F(RtcpReceiverTest, ForceSenderReport) { 1270 TEST_F(RtcpReceiverTest, ForceSenderReport) {
1261 rtcp::RapidResyncRequest rr; 1271 rtcp::RapidResyncRequest rr;
1262 rr.SetSenderSsrc(kSenderSsrc); 1272 rr.SetSenderSsrc(kSenderSsrc);
1263 rr.SetMediaSsrc(kReceiverMainSsrc); 1273 rr.SetMediaSsrc(kReceiverMainSsrc);
1264 1274
1265 EXPECT_CALL(rtp_rtcp_impl_, OnRequestSendReport()); 1275 EXPECT_CALL(rtp_rtcp_impl_, OnRequestSendReport());
1266 InjectRtcpPacket(rr); 1276 InjectRtcpPacket(rr);
1267 } 1277 }
1268 1278
1279 TEST_F(RtcpReceiverTest, ReceivesTargetBitrate) {
1280 BitrateAllocation expected_allocation;
1281 expected_allocation.SetBitrate(0, 0, 10000);
1282 expected_allocation.SetBitrate(0, 1, 20000);
1283 expected_allocation.SetBitrate(1, 0, 40000);
1284 expected_allocation.SetBitrate(1, 1, 80000);
1285
1286 rtcp::TargetBitrate bitrate;
1287 bitrate.AddTargetBitrate(0, 0, expected_allocation.GetBitrate(0, 0) / 1000);
1288 bitrate.AddTargetBitrate(0, 1, expected_allocation.GetBitrate(0, 1) / 1000);
1289 bitrate.AddTargetBitrate(1, 0, expected_allocation.GetBitrate(1, 0) / 1000);
1290 bitrate.AddTargetBitrate(1, 1, expected_allocation.GetBitrate(1, 1) / 1000);
1291
1292 rtcp::ExtendedReports xr;
1293 xr.SetTargetBitrate(bitrate);
1294
1295 EXPECT_CALL(bitrate_allocation_observer_,
1296 OnBitrateAllocationUpdated(expected_allocation));
1297 InjectRtcpPacket(xr);
1298 }
1299
1269 } // namespace webrtc 1300 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc ('k') | webrtc/modules/rtp_rtcp/source/rtcp_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698