| OLD | NEW |
| 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; | |
| 28 using webrtc::rtcp::RawPacket; | 27 using webrtc::rtcp::RawPacket; |
| 29 using webrtc::rtcp::ReceiverReport; | 28 using webrtc::rtcp::ReceiverReport; |
| 30 using webrtc::rtcp::ReportBlock; | 29 using webrtc::rtcp::ReportBlock; |
| 31 using webrtc::rtcp::Rpsi; | 30 using webrtc::rtcp::Rpsi; |
| 32 using webrtc::rtcp::Rrtr; | 31 using webrtc::rtcp::Rrtr; |
| 33 using webrtc::rtcp::Sdes; | 32 using webrtc::rtcp::Sdes; |
| 34 using webrtc::rtcp::SenderReport; | 33 using webrtc::rtcp::SenderReport; |
| 35 using webrtc::rtcp::VoipMetric; | 34 using webrtc::rtcp::VoipMetric; |
| 36 using webrtc::rtcp::Xr; | 35 using webrtc::rtcp::Xr; |
| 37 using webrtc::test::RtcpPacketParser; | 36 using webrtc::test::RtcpPacketParser; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 const uint16_t kNumberOfValidBytes = 10; | 279 const uint16_t kNumberOfValidBytes = 10; |
| 281 rpsi.WithPictureId(kPictureId); | 280 rpsi.WithPictureId(kPictureId); |
| 282 | 281 |
| 283 rtc::scoped_ptr<RawPacket> packet(rpsi.Build()); | 282 rtc::scoped_ptr<RawPacket> packet(rpsi.Build()); |
| 284 RtcpPacketParser parser; | 283 RtcpPacketParser parser; |
| 285 parser.Parse(packet->Buffer(), packet->Length()); | 284 parser.Parse(packet->Buffer(), packet->Length()); |
| 286 EXPECT_EQ(kNumberOfValidBytes * 8, parser.rpsi()->NumberOfValidBits()); | 285 EXPECT_EQ(kNumberOfValidBytes * 8, parser.rpsi()->NumberOfValidBits()); |
| 287 EXPECT_EQ(kPictureId, parser.rpsi()->PictureId()); | 286 EXPECT_EQ(kPictureId, parser.rpsi()->PictureId()); |
| 288 } | 287 } |
| 289 | 288 |
| 290 TEST(RtcpPacketTest, Fir) { | |
| 291 Fir fir; | |
| 292 fir.From(kSenderSsrc); | |
| 293 fir.To(kRemoteSsrc); | |
| 294 fir.WithCommandSeqNum(123); | |
| 295 | |
| 296 rtc::scoped_ptr<RawPacket> packet(fir.Build()); | |
| 297 RtcpPacketParser parser; | |
| 298 parser.Parse(packet->Buffer(), packet->Length()); | |
| 299 EXPECT_EQ(1, parser.fir()->num_packets()); | |
| 300 EXPECT_EQ(kSenderSsrc, parser.fir()->Ssrc()); | |
| 301 EXPECT_EQ(1, parser.fir_item()->num_packets()); | |
| 302 EXPECT_EQ(kRemoteSsrc, parser.fir_item()->Ssrc()); | |
| 303 EXPECT_EQ(123U, parser.fir_item()->SeqNum()); | |
| 304 } | |
| 305 | |
| 306 TEST(RtcpPacketTest, BuildWithTooSmallBuffer) { | 289 TEST(RtcpPacketTest, BuildWithTooSmallBuffer) { |
| 307 ReportBlock rb; | 290 ReportBlock rb; |
| 308 ReceiverReport rr; | 291 ReceiverReport rr; |
| 309 rr.From(kSenderSsrc); | 292 rr.From(kSenderSsrc); |
| 310 EXPECT_TRUE(rr.WithReportBlock(rb)); | 293 EXPECT_TRUE(rr.WithReportBlock(rb)); |
| 311 | 294 |
| 312 const size_t kRrLength = 8; | 295 const size_t kRrLength = 8; |
| 313 const size_t kReportBlockLength = 24; | 296 const size_t kReportBlockLength = 24; |
| 314 | 297 |
| 315 // No packet. | 298 // No packet. |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 EXPECT_TRUE(xr.WithDlrr(&dlrr)); | 544 EXPECT_TRUE(xr.WithDlrr(&dlrr)); |
| 562 EXPECT_FALSE(xr.WithDlrr(&dlrr)); | 545 EXPECT_FALSE(xr.WithDlrr(&dlrr)); |
| 563 | 546 |
| 564 VoipMetric voip_metric; | 547 VoipMetric voip_metric; |
| 565 for (int i = 0; i < kMaxBlocks; ++i) | 548 for (int i = 0; i < kMaxBlocks; ++i) |
| 566 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); | 549 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); |
| 567 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); | 550 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); |
| 568 } | 551 } |
| 569 | 552 |
| 570 } // namespace webrtc | 553 } // namespace webrtc |
| OLD | NEW |