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

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

Issue 1590883002: [rtp_rtcp] rtcp::Remb moved into own file (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 * This file includes unit tests for the RtcpPacket. 10 * This file includes unit tests for the RtcpPacket.
11 */ 11 */
12 12
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h"
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
20 #include "webrtc/test/rtcp_packet_parser.h" 20 #include "webrtc/test/rtcp_packet_parser.h"
21 21
22 using ::testing::ElementsAre; 22 using ::testing::ElementsAre;
23 23
24 using webrtc::rtcp::App; 24 using webrtc::rtcp::App;
25 using webrtc::rtcp::Bye; 25 using webrtc::rtcp::Bye;
26 using webrtc::rtcp::Dlrr; 26 using webrtc::rtcp::Dlrr;
27 using webrtc::rtcp::Fir; 27 using webrtc::rtcp::Fir;
28 using webrtc::rtcp::RawPacket; 28 using webrtc::rtcp::RawPacket;
29 using webrtc::rtcp::ReceiverReport; 29 using webrtc::rtcp::ReceiverReport;
30 using webrtc::rtcp::Remb;
31 using webrtc::rtcp::ReportBlock; 30 using webrtc::rtcp::ReportBlock;
32 using webrtc::rtcp::Rpsi; 31 using webrtc::rtcp::Rpsi;
33 using webrtc::rtcp::Rrtr; 32 using webrtc::rtcp::Rrtr;
34 using webrtc::rtcp::Sdes; 33 using webrtc::rtcp::Sdes;
35 using webrtc::rtcp::SenderReport; 34 using webrtc::rtcp::SenderReport;
36 using webrtc::rtcp::VoipMetric; 35 using webrtc::rtcp::VoipMetric;
37 using webrtc::rtcp::Xr; 36 using webrtc::rtcp::Xr;
38 using webrtc::test::RtcpPacketParser; 37 using webrtc::test::RtcpPacketParser;
39 38
40 namespace webrtc { 39 namespace webrtc {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 class Verifier : public rtcp::RtcpPacket::PacketReadyCallback { 316 class Verifier : public rtcp::RtcpPacket::PacketReadyCallback {
318 void OnPacketReady(uint8_t* data, size_t length) override { 317 void OnPacketReady(uint8_t* data, size_t length) override {
319 ADD_FAILURE() << "Packet should not fit within max size."; 318 ADD_FAILURE() << "Packet should not fit within max size.";
320 } 319 }
321 } verifier; 320 } verifier;
322 const size_t kBufferSize = kRrLength + kReportBlockLength - 1; 321 const size_t kBufferSize = kRrLength + kReportBlockLength - 1;
323 uint8_t buffer[kBufferSize]; 322 uint8_t buffer[kBufferSize];
324 EXPECT_FALSE(rr.BuildExternalBuffer(buffer, kBufferSize, &verifier)); 323 EXPECT_FALSE(rr.BuildExternalBuffer(buffer, kBufferSize, &verifier));
325 } 324 }
326 325
327 TEST(RtcpPacketTest, Remb) {
328 Remb remb;
329 remb.From(kSenderSsrc);
330 remb.AppliesTo(kRemoteSsrc);
331 remb.AppliesTo(kRemoteSsrc + 1);
332 remb.AppliesTo(kRemoteSsrc + 2);
333 remb.WithBitrateBps(261011);
334
335 rtc::scoped_ptr<RawPacket> packet(remb.Build());
336 RtcpPacketParser parser;
337 parser.Parse(packet->Buffer(), packet->Length());
338 EXPECT_EQ(1, parser.psfb_app()->num_packets());
339 EXPECT_EQ(kSenderSsrc, parser.psfb_app()->Ssrc());
340 EXPECT_EQ(1, parser.remb_item()->num_packets());
341 EXPECT_EQ(261011, parser.remb_item()->last_bitrate_bps());
342 std::vector<uint32_t> ssrcs = parser.remb_item()->last_ssrc_list();
343 EXPECT_EQ(kRemoteSsrc, ssrcs[0]);
344 EXPECT_EQ(kRemoteSsrc + 1, ssrcs[1]);
345 EXPECT_EQ(kRemoteSsrc + 2, ssrcs[2]);
346 }
347 326
348 TEST(RtcpPacketTest, XrWithNoReportBlocks) { 327 TEST(RtcpPacketTest, XrWithNoReportBlocks) {
349 Xr xr; 328 Xr xr;
350 xr.From(kSenderSsrc); 329 xr.From(kSenderSsrc);
351 330
352 rtc::scoped_ptr<RawPacket> packet(xr.Build()); 331 rtc::scoped_ptr<RawPacket> packet(xr.Build());
353 RtcpPacketParser parser; 332 RtcpPacketParser parser;
354 parser.Parse(packet->Buffer(), packet->Length()); 333 parser.Parse(packet->Buffer(), packet->Length());
355 EXPECT_EQ(1, parser.xr_header()->num_packets()); 334 EXPECT_EQ(1, parser.xr_header()->num_packets());
356 EXPECT_EQ(kSenderSsrc, parser.xr_header()->Ssrc()); 335 EXPECT_EQ(kSenderSsrc, parser.xr_header()->Ssrc());
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 EXPECT_TRUE(xr.WithDlrr(&dlrr)); 561 EXPECT_TRUE(xr.WithDlrr(&dlrr));
583 EXPECT_FALSE(xr.WithDlrr(&dlrr)); 562 EXPECT_FALSE(xr.WithDlrr(&dlrr));
584 563
585 VoipMetric voip_metric; 564 VoipMetric voip_metric;
586 for (int i = 0; i < kMaxBlocks; ++i) 565 for (int i = 0; i < kMaxBlocks; ++i)
587 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); 566 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric));
588 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); 567 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric));
589 } 568 }
590 569
591 } // namespace webrtc 570 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/remb_unittest.cc ('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