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/test/rtcp_packet_parser.h" | 17 #include "webrtc/test/rtcp_packet_parser.h" |
18 | 18 |
19 using ::testing::ElementsAre; | 19 using ::testing::ElementsAre; |
20 | 20 |
21 using webrtc::rtcp::App; | 21 using webrtc::rtcp::App; |
22 using webrtc::rtcp::Bye; | 22 using webrtc::rtcp::Bye; |
23 using webrtc::rtcp::Dlrr; | 23 using webrtc::rtcp::Dlrr; |
24 using webrtc::rtcp::Empty; | 24 using webrtc::rtcp::Empty; |
25 using webrtc::rtcp::Fir; | 25 using webrtc::rtcp::Fir; |
26 using webrtc::rtcp::Nack; | 26 using webrtc::rtcp::Nack; |
27 using webrtc::rtcp::Pli; | |
28 using webrtc::rtcp::Sdes; | 27 using webrtc::rtcp::Sdes; |
29 using webrtc::rtcp::SenderReport; | 28 using webrtc::rtcp::SenderReport; |
30 using webrtc::rtcp::Sli; | 29 using webrtc::rtcp::Sli; |
31 using webrtc::rtcp::RawPacket; | 30 using webrtc::rtcp::RawPacket; |
32 using webrtc::rtcp::ReceiverReport; | 31 using webrtc::rtcp::ReceiverReport; |
33 using webrtc::rtcp::Remb; | 32 using webrtc::rtcp::Remb; |
34 using webrtc::rtcp::ReportBlock; | 33 using webrtc::rtcp::ReportBlock; |
35 using webrtc::rtcp::Rpsi; | 34 using webrtc::rtcp::Rpsi; |
36 using webrtc::rtcp::Rrtr; | 35 using webrtc::rtcp::Rrtr; |
37 using webrtc::rtcp::SenderReport; | 36 using webrtc::rtcp::SenderReport; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 286 |
288 rtc::scoped_ptr<RawPacket> packet(sdes.Build()); | 287 rtc::scoped_ptr<RawPacket> packet(sdes.Build()); |
289 RtcpPacketParser parser; | 288 RtcpPacketParser parser; |
290 parser.Parse(packet->Buffer(), packet->Length()); | 289 parser.Parse(packet->Buffer(), packet->Length()); |
291 EXPECT_EQ(1, parser.sdes()->num_packets()); | 290 EXPECT_EQ(1, parser.sdes()->num_packets()); |
292 EXPECT_EQ(1, parser.sdes_chunk()->num_packets()); | 291 EXPECT_EQ(1, parser.sdes_chunk()->num_packets()); |
293 EXPECT_EQ(kSenderSsrc, parser.sdes_chunk()->Ssrc()); | 292 EXPECT_EQ(kSenderSsrc, parser.sdes_chunk()->Ssrc()); |
294 EXPECT_EQ("", parser.sdes_chunk()->Cname()); | 293 EXPECT_EQ("", parser.sdes_chunk()->Cname()); |
295 } | 294 } |
296 | 295 |
297 TEST(RtcpPacketTest, Pli) { | |
298 Pli pli; | |
299 pli.From(kSenderSsrc); | |
300 pli.To(kRemoteSsrc); | |
301 | |
302 rtc::scoped_ptr<RawPacket> packet(pli.Build()); | |
303 RtcpPacketParser parser; | |
304 parser.Parse(packet->Buffer(), packet->Length()); | |
305 EXPECT_EQ(1, parser.pli()->num_packets()); | |
306 EXPECT_EQ(kSenderSsrc, parser.pli()->Ssrc()); | |
307 EXPECT_EQ(kRemoteSsrc, parser.pli()->MediaSsrc()); | |
308 } | |
309 | |
310 TEST(RtcpPacketTest, Sli) { | 296 TEST(RtcpPacketTest, Sli) { |
311 const uint16_t kFirstMb = 7777; | 297 const uint16_t kFirstMb = 7777; |
312 const uint16_t kNumberOfMb = 6666; | 298 const uint16_t kNumberOfMb = 6666; |
313 const uint8_t kPictureId = 60; | 299 const uint8_t kPictureId = 60; |
314 Sli sli; | 300 Sli sli; |
315 sli.From(kSenderSsrc); | 301 sli.From(kSenderSsrc); |
316 sli.To(kRemoteSsrc); | 302 sli.To(kRemoteSsrc); |
317 sli.WithFirstMb(kFirstMb); | 303 sli.WithFirstMb(kFirstMb); |
318 sli.WithNumberOfMb(kNumberOfMb); | 304 sli.WithNumberOfMb(kNumberOfMb); |
319 sli.WithPictureId(kPictureId); | 305 sli.WithPictureId(kPictureId); |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 EXPECT_TRUE(xr.WithDlrr(&dlrr)); | 1020 EXPECT_TRUE(xr.WithDlrr(&dlrr)); |
1035 EXPECT_FALSE(xr.WithDlrr(&dlrr)); | 1021 EXPECT_FALSE(xr.WithDlrr(&dlrr)); |
1036 | 1022 |
1037 VoipMetric voip_metric; | 1023 VoipMetric voip_metric; |
1038 for (int i = 0; i < kMaxBlocks; ++i) | 1024 for (int i = 0; i < kMaxBlocks; ++i) |
1039 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); | 1025 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); |
1040 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); | 1026 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); |
1041 } | 1027 } |
1042 | 1028 |
1043 } // namespace webrtc | 1029 } // namespace webrtc |
OLD | NEW |