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. |
(...skipping 16 matching lines...) Expand all Loading... |
27 using webrtc::rtcp::Empty; | 27 using webrtc::rtcp::Empty; |
28 using webrtc::rtcp::Fir; | 28 using webrtc::rtcp::Fir; |
29 using webrtc::rtcp::RawPacket; | 29 using webrtc::rtcp::RawPacket; |
30 using webrtc::rtcp::ReceiverReport; | 30 using webrtc::rtcp::ReceiverReport; |
31 using webrtc::rtcp::Remb; | 31 using webrtc::rtcp::Remb; |
32 using webrtc::rtcp::ReportBlock; | 32 using webrtc::rtcp::ReportBlock; |
33 using webrtc::rtcp::Rpsi; | 33 using webrtc::rtcp::Rpsi; |
34 using webrtc::rtcp::Rrtr; | 34 using webrtc::rtcp::Rrtr; |
35 using webrtc::rtcp::Sdes; | 35 using webrtc::rtcp::Sdes; |
36 using webrtc::rtcp::SenderReport; | 36 using webrtc::rtcp::SenderReport; |
37 using webrtc::rtcp::Sli; | |
38 using webrtc::rtcp::VoipMetric; | 37 using webrtc::rtcp::VoipMetric; |
39 using webrtc::rtcp::Xr; | 38 using webrtc::rtcp::Xr; |
40 using webrtc::test::RtcpPacketParser; | 39 using webrtc::test::RtcpPacketParser; |
41 | 40 |
42 namespace webrtc { | 41 namespace webrtc { |
43 | 42 |
44 const uint32_t kSenderSsrc = 0x12345678; | 43 const uint32_t kSenderSsrc = 0x12345678; |
45 const uint32_t kRemoteSsrc = 0x23456789; | 44 const uint32_t kRemoteSsrc = 0x23456789; |
46 | 45 |
47 TEST(RtcpPacketTest, Sr) { | 46 TEST(RtcpPacketTest, Sr) { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 209 |
211 rtc::scoped_ptr<RawPacket> packet(sdes.Build()); | 210 rtc::scoped_ptr<RawPacket> packet(sdes.Build()); |
212 RtcpPacketParser parser; | 211 RtcpPacketParser parser; |
213 parser.Parse(packet->Buffer(), packet->Length()); | 212 parser.Parse(packet->Buffer(), packet->Length()); |
214 EXPECT_EQ(1, parser.sdes()->num_packets()); | 213 EXPECT_EQ(1, parser.sdes()->num_packets()); |
215 EXPECT_EQ(1, parser.sdes_chunk()->num_packets()); | 214 EXPECT_EQ(1, parser.sdes_chunk()->num_packets()); |
216 EXPECT_EQ(kSenderSsrc, parser.sdes_chunk()->Ssrc()); | 215 EXPECT_EQ(kSenderSsrc, parser.sdes_chunk()->Ssrc()); |
217 EXPECT_EQ("", parser.sdes_chunk()->Cname()); | 216 EXPECT_EQ("", parser.sdes_chunk()->Cname()); |
218 } | 217 } |
219 | 218 |
220 TEST(RtcpPacketTest, Sli) { | |
221 const uint16_t kFirstMb = 7777; | |
222 const uint16_t kNumberOfMb = 6666; | |
223 const uint8_t kPictureId = 60; | |
224 Sli sli; | |
225 sli.From(kSenderSsrc); | |
226 sli.To(kRemoteSsrc); | |
227 sli.WithFirstMb(kFirstMb); | |
228 sli.WithNumberOfMb(kNumberOfMb); | |
229 sli.WithPictureId(kPictureId); | |
230 | |
231 rtc::scoped_ptr<RawPacket> packet(sli.Build()); | |
232 RtcpPacketParser parser; | |
233 parser.Parse(packet->Buffer(), packet->Length()); | |
234 EXPECT_EQ(1, parser.sli()->num_packets()); | |
235 EXPECT_EQ(kSenderSsrc, parser.sli()->Ssrc()); | |
236 EXPECT_EQ(kRemoteSsrc, parser.sli()->MediaSsrc()); | |
237 EXPECT_EQ(1, parser.sli_item()->num_packets()); | |
238 EXPECT_EQ(kFirstMb, parser.sli_item()->FirstMb()); | |
239 EXPECT_EQ(kNumberOfMb, parser.sli_item()->NumberOfMb()); | |
240 EXPECT_EQ(kPictureId, parser.sli_item()->PictureId()); | |
241 } | |
242 | |
243 TEST(RtcpPacketTest, Rpsi) { | 219 TEST(RtcpPacketTest, Rpsi) { |
244 Rpsi rpsi; | 220 Rpsi rpsi; |
245 // 1000001 (7 bits = 1 byte in native string). | 221 // 1000001 (7 bits = 1 byte in native string). |
246 const uint64_t kPictureId = 0x41; | 222 const uint64_t kPictureId = 0x41; |
247 const uint16_t kNumberOfValidBytes = 1; | 223 const uint16_t kNumberOfValidBytes = 1; |
248 rpsi.WithPayloadType(100); | 224 rpsi.WithPayloadType(100); |
249 rpsi.WithPictureId(kPictureId); | 225 rpsi.WithPictureId(kPictureId); |
250 | 226 |
251 rtc::scoped_ptr<RawPacket> packet(rpsi.Build()); | 227 rtc::scoped_ptr<RawPacket> packet(rpsi.Build()); |
252 RtcpPacketParser parser; | 228 RtcpPacketParser parser; |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 EXPECT_TRUE(xr.WithDlrr(&dlrr)); | 708 EXPECT_TRUE(xr.WithDlrr(&dlrr)); |
733 EXPECT_FALSE(xr.WithDlrr(&dlrr)); | 709 EXPECT_FALSE(xr.WithDlrr(&dlrr)); |
734 | 710 |
735 VoipMetric voip_metric; | 711 VoipMetric voip_metric; |
736 for (int i = 0; i < kMaxBlocks; ++i) | 712 for (int i = 0; i < kMaxBlocks; ++i) |
737 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); | 713 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); |
738 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); | 714 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); |
739 } | 715 } |
740 | 716 |
741 } // namespace webrtc | 717 } // namespace webrtc |
OLD | NEW |