OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 constexpr uint32_t kJitter2 = 0x22242628; | 24 constexpr uint32_t kJitter2 = 0x22242628; |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 TEST(RtcpPacketExtendedJitterReportTest, CreateAndParseWithoutItems) { | 27 TEST(RtcpPacketExtendedJitterReportTest, CreateAndParseWithoutItems) { |
28 ExtendedJitterReport ij; | 28 ExtendedJitterReport ij; |
29 rtc::Buffer raw = ij.Build(); | 29 rtc::Buffer raw = ij.Build(); |
30 | 30 |
31 ExtendedJitterReport parsed; | 31 ExtendedJitterReport parsed; |
32 EXPECT_TRUE(test::ParseSinglePacket(raw, &parsed)); | 32 EXPECT_TRUE(test::ParseSinglePacket(raw, &parsed)); |
33 | 33 |
34 EXPECT_THAT(parsed.jitter_values(), IsEmpty()); | 34 EXPECT_THAT(parsed.jitters(), IsEmpty()); |
35 } | 35 } |
36 | 36 |
37 TEST(RtcpPacketExtendedJitterReportTest, CreateAndParseWithOneItem) { | 37 TEST(RtcpPacketExtendedJitterReportTest, CreateAndParseWithOneItem) { |
38 ExtendedJitterReport ij; | 38 ExtendedJitterReport ij; |
39 EXPECT_TRUE(ij.SetJitterValues({kJitter1})); | 39 EXPECT_TRUE(ij.WithJitter(kJitter1)); |
40 rtc::Buffer raw = ij.Build(); | 40 rtc::Buffer raw = ij.Build(); |
41 | 41 |
42 ExtendedJitterReport parsed; | 42 ExtendedJitterReport parsed; |
43 EXPECT_TRUE(test::ParseSinglePacket(raw, &parsed)); | 43 EXPECT_TRUE(test::ParseSinglePacket(raw, &parsed)); |
44 | 44 |
45 EXPECT_THAT(parsed.jitter_values(), ElementsAre(kJitter1)); | 45 EXPECT_THAT(parsed.jitters(), ElementsAre(kJitter1)); |
46 } | 46 } |
47 | 47 |
48 TEST(RtcpPacketExtendedJitterReportTest, CreateAndParseWithTwoItems) { | 48 TEST(RtcpPacketExtendedJitterReportTest, CreateAndParseWithTwoItems) { |
49 ExtendedJitterReport ij; | 49 ExtendedJitterReport ij; |
50 EXPECT_TRUE(ij.SetJitterValues({kJitter1, kJitter2})); | 50 EXPECT_TRUE(ij.WithJitter(kJitter1)); |
| 51 EXPECT_TRUE(ij.WithJitter(kJitter2)); |
51 rtc::Buffer raw = ij.Build(); | 52 rtc::Buffer raw = ij.Build(); |
52 | 53 |
53 ExtendedJitterReport parsed; | 54 ExtendedJitterReport parsed; |
54 EXPECT_TRUE(test::ParseSinglePacket(raw, &parsed)); | 55 EXPECT_TRUE(test::ParseSinglePacket(raw, &parsed)); |
55 | 56 |
56 EXPECT_THAT(parsed.jitter_values(), ElementsAre(kJitter1, kJitter2)); | 57 EXPECT_THAT(parsed.jitters(), ElementsAre(kJitter1, kJitter2)); |
57 } | 58 } |
58 | 59 |
59 TEST(RtcpPacketExtendedJitterReportTest, CreateWithTooManyItems) { | 60 TEST(RtcpPacketExtendedJitterReportTest, CreateWithTooManyItems) { |
60 ExtendedJitterReport ij; | 61 ExtendedJitterReport ij; |
61 const int kMaxItems = ExtendedJitterReport::kMaxNumberOfJitterValues; | 62 const int kMaxIjItems = (1 << 5) - 1; |
62 EXPECT_FALSE( | 63 for (int i = 0; i < kMaxIjItems; ++i) { |
63 ij.SetJitterValues(std::vector<uint32_t>(kMaxItems + 1, kJitter1))); | 64 EXPECT_TRUE(ij.WithJitter(i)); |
64 EXPECT_TRUE(ij.SetJitterValues(std::vector<uint32_t>(kMaxItems, kJitter1))); | 65 } |
| 66 EXPECT_FALSE(ij.WithJitter(kMaxIjItems)); |
65 } | 67 } |
66 | 68 |
67 TEST(RtcpPacketExtendedJitterReportTest, ParseFailsWithTooManyItems) { | 69 TEST(RtcpPacketExtendedJitterReportTest, ParseFailsWithTooManyItems) { |
68 ExtendedJitterReport ij; | 70 ExtendedJitterReport ij; |
69 ij.SetJitterValues({kJitter1}); | 71 ij.WithJitter(kJitter1); |
70 rtc::Buffer raw = ij.Build(); | 72 rtc::Buffer raw = ij.Build(); |
71 raw[0]++; // Damage packet: increase jitter count by 1. | 73 raw[0]++; // Damage packet: increase jitter count by 1. |
72 ExtendedJitterReport parsed; | 74 ExtendedJitterReport parsed; |
73 EXPECT_FALSE(test::ParseSinglePacket(raw, &parsed)); | 75 EXPECT_FALSE(test::ParseSinglePacket(raw, &parsed)); |
74 } | 76 } |
75 | 77 |
76 } // namespace webrtc | 78 } // namespace webrtc |
OLD | NEW |