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/receiver_report.h" | |
17 #include "webrtc/test/rtcp_packet_parser.h" | 18 #include "webrtc/test/rtcp_packet_parser.h" |
18 | 19 |
19 using ::testing::ElementsAre; | 20 using ::testing::ElementsAre; |
20 | 21 |
21 using webrtc::rtcp::App; | 22 using webrtc::rtcp::App; |
22 using webrtc::rtcp::Bye; | 23 using webrtc::rtcp::Bye; |
23 using webrtc::rtcp::Dlrr; | 24 using webrtc::rtcp::Dlrr; |
24 using webrtc::rtcp::Empty; | 25 using webrtc::rtcp::Empty; |
25 using webrtc::rtcp::Fir; | 26 using webrtc::rtcp::Fir; |
26 using webrtc::rtcp::Nack; | 27 using webrtc::rtcp::Nack; |
27 using webrtc::rtcp::Pli; | 28 using webrtc::rtcp::Pli; |
28 using webrtc::rtcp::Sdes; | 29 using webrtc::rtcp::Sdes; |
29 using webrtc::rtcp::SenderReport; | 30 using webrtc::rtcp::SenderReport; |
30 using webrtc::rtcp::Sli; | 31 using webrtc::rtcp::Sli; |
31 using webrtc::rtcp::RawPacket; | 32 using webrtc::rtcp::RawPacket; |
33 using webrtc::rtcp::Remb; | |
åsapersson
2015/12/03 13:56:42
alphabetic order
danilchap
2015/12/03 14:23:16
Done.
| |
32 using webrtc::rtcp::ReceiverReport; | 34 using webrtc::rtcp::ReceiverReport; |
33 using webrtc::rtcp::Remb; | |
34 using webrtc::rtcp::ReportBlock; | 35 using webrtc::rtcp::ReportBlock; |
35 using webrtc::rtcp::Rpsi; | 36 using webrtc::rtcp::Rpsi; |
36 using webrtc::rtcp::Rrtr; | 37 using webrtc::rtcp::Rrtr; |
37 using webrtc::rtcp::SenderReport; | 38 using webrtc::rtcp::SenderReport; |
38 using webrtc::rtcp::Tmmbn; | 39 using webrtc::rtcp::Tmmbn; |
39 using webrtc::rtcp::Tmmbr; | 40 using webrtc::rtcp::Tmmbr; |
40 using webrtc::rtcp::VoipMetric; | 41 using webrtc::rtcp::VoipMetric; |
41 using webrtc::rtcp::Xr; | 42 using webrtc::rtcp::Xr; |
42 using webrtc::test::RtcpPacketParser; | 43 using webrtc::test::RtcpPacketParser; |
43 | 44 |
44 namespace webrtc { | 45 namespace webrtc { |
45 | 46 |
46 const uint32_t kSenderSsrc = 0x12345678; | 47 const uint32_t kSenderSsrc = 0x12345678; |
47 const uint32_t kRemoteSsrc = 0x23456789; | 48 const uint32_t kRemoteSsrc = 0x23456789; |
48 | 49 |
49 TEST(RtcpPacketTest, Rr) { | |
50 ReceiverReport rr; | |
51 rr.From(kSenderSsrc); | |
52 | |
53 rtc::scoped_ptr<RawPacket> packet(rr.Build()); | |
54 RtcpPacketParser parser; | |
55 parser.Parse(packet->Buffer(), packet->Length()); | |
56 EXPECT_EQ(1, parser.receiver_report()->num_packets()); | |
57 EXPECT_EQ(kSenderSsrc, parser.receiver_report()->Ssrc()); | |
58 EXPECT_EQ(0, parser.report_block()->num_packets()); | |
59 } | |
60 | |
61 TEST(RtcpPacketTest, RrWithOneReportBlock) { | |
62 ReportBlock rb; | |
63 rb.To(kRemoteSsrc); | |
64 rb.WithFractionLost(55); | |
65 rb.WithCumulativeLost(0x111111); | |
66 rb.WithExtHighestSeqNum(0x22222222); | |
67 rb.WithJitter(0x33333333); | |
68 rb.WithLastSr(0x44444444); | |
69 rb.WithDelayLastSr(0x55555555); | |
70 | |
71 ReceiverReport rr; | |
72 rr.From(kSenderSsrc); | |
73 EXPECT_TRUE(rr.WithReportBlock(rb)); | |
74 | |
75 rtc::scoped_ptr<RawPacket> packet(rr.Build()); | |
76 RtcpPacketParser parser; | |
77 parser.Parse(packet->Buffer(), packet->Length()); | |
78 EXPECT_EQ(1, parser.receiver_report()->num_packets()); | |
79 EXPECT_EQ(kSenderSsrc, parser.receiver_report()->Ssrc()); | |
80 EXPECT_EQ(1, parser.report_block()->num_packets()); | |
81 EXPECT_EQ(kRemoteSsrc, parser.report_block()->Ssrc()); | |
82 EXPECT_EQ(55U, parser.report_block()->FractionLost()); | |
83 EXPECT_EQ(0x111111U, parser.report_block()->CumPacketLost()); | |
84 EXPECT_EQ(0x22222222U, parser.report_block()->ExtHighestSeqNum()); | |
85 EXPECT_EQ(0x33333333U, parser.report_block()->Jitter()); | |
86 EXPECT_EQ(0x44444444U, parser.report_block()->LastSr()); | |
87 EXPECT_EQ(0x55555555U, parser.report_block()->DelayLastSr()); | |
88 } | |
89 | |
90 TEST(RtcpPacketTest, RrWithTwoReportBlocks) { | |
91 ReportBlock rb1; | |
92 rb1.To(kRemoteSsrc); | |
93 ReportBlock rb2; | |
94 rb2.To(kRemoteSsrc + 1); | |
95 | |
96 ReceiverReport rr; | |
97 rr.From(kSenderSsrc); | |
98 EXPECT_TRUE(rr.WithReportBlock(rb1)); | |
99 EXPECT_TRUE(rr.WithReportBlock(rb2)); | |
100 | |
101 rtc::scoped_ptr<RawPacket> packet(rr.Build()); | |
102 RtcpPacketParser parser; | |
103 parser.Parse(packet->Buffer(), packet->Length()); | |
104 EXPECT_EQ(1, parser.receiver_report()->num_packets()); | |
105 EXPECT_EQ(kSenderSsrc, parser.receiver_report()->Ssrc()); | |
106 EXPECT_EQ(2, parser.report_block()->num_packets()); | |
107 EXPECT_EQ(1, parser.report_blocks_per_ssrc(kRemoteSsrc)); | |
108 EXPECT_EQ(1, parser.report_blocks_per_ssrc(kRemoteSsrc + 1)); | |
109 } | |
110 | |
111 TEST(RtcpPacketTest, RrWithTooManyReportBlocks) { | |
112 ReceiverReport rr; | |
113 rr.From(kSenderSsrc); | |
114 const int kMaxReportBlocks = (1 << 5) - 1; | |
115 ReportBlock rb; | |
116 for (int i = 0; i < kMaxReportBlocks; ++i) { | |
117 rb.To(kRemoteSsrc + i); | |
118 EXPECT_TRUE(rr.WithReportBlock(rb)); | |
119 } | |
120 rb.To(kRemoteSsrc + kMaxReportBlocks); | |
121 EXPECT_FALSE(rr.WithReportBlock(rb)); | |
122 } | |
123 | |
124 TEST(RtcpPacketTest, Sr) { | 50 TEST(RtcpPacketTest, Sr) { |
125 SenderReport sr; | 51 SenderReport sr; |
126 sr.From(kSenderSsrc); | 52 sr.From(kSenderSsrc); |
127 sr.WithNtpSec(0x11111111); | 53 sr.WithNtpSec(0x11111111); |
128 sr.WithNtpFrac(0x22222222); | 54 sr.WithNtpFrac(0x22222222); |
129 sr.WithRtpTimestamp(0x33333333); | 55 sr.WithRtpTimestamp(0x33333333); |
130 sr.WithPacketCount(0x44444444); | 56 sr.WithPacketCount(0x44444444); |
131 sr.WithOctetCount(0x55555555); | 57 sr.WithOctetCount(0x55555555); |
132 | 58 |
133 rtc::scoped_ptr<RawPacket> packet(sr.Build()); | 59 rtc::scoped_ptr<RawPacket> packet(sr.Build()); |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1034 EXPECT_TRUE(xr.WithDlrr(&dlrr)); | 960 EXPECT_TRUE(xr.WithDlrr(&dlrr)); |
1035 EXPECT_FALSE(xr.WithDlrr(&dlrr)); | 961 EXPECT_FALSE(xr.WithDlrr(&dlrr)); |
1036 | 962 |
1037 VoipMetric voip_metric; | 963 VoipMetric voip_metric; |
1038 for (int i = 0; i < kMaxBlocks; ++i) | 964 for (int i = 0; i < kMaxBlocks; ++i) |
1039 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); | 965 EXPECT_TRUE(xr.WithVoipMetric(&voip_metric)); |
1040 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); | 966 EXPECT_FALSE(xr.WithVoipMetric(&voip_metric)); |
1041 } | 967 } |
1042 | 968 |
1043 } // namespace webrtc | 969 } // namespace webrtc |
OLD | NEW |