| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 const size_t kMaxReportBlocks = (1 << 5) - 1; | 104 const size_t kMaxReportBlocks = (1 << 5) - 1; |
| 105 ReportBlock rb; | 105 ReportBlock rb; |
| 106 for (size_t i = 0; i < kMaxReportBlocks; ++i) { | 106 for (size_t i = 0; i < kMaxReportBlocks; ++i) { |
| 107 rb.SetMediaSsrc(kRemoteSsrc + i); | 107 rb.SetMediaSsrc(kRemoteSsrc + i); |
| 108 EXPECT_TRUE(sr.AddReportBlock(rb)); | 108 EXPECT_TRUE(sr.AddReportBlock(rb)); |
| 109 } | 109 } |
| 110 rb.SetMediaSsrc(kRemoteSsrc + kMaxReportBlocks); | 110 rb.SetMediaSsrc(kRemoteSsrc + kMaxReportBlocks); |
| 111 EXPECT_FALSE(sr.AddReportBlock(rb)); | 111 EXPECT_FALSE(sr.AddReportBlock(rb)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 TEST(RtcpPacketSenderReportTest, SetReportBlocksOverwritesOldBlocks) { |
| 115 SenderReport sr; |
| 116 ReportBlock report_block; |
| 117 // Use jitter field of the report blocks to distinguish them. |
| 118 report_block.SetJitter(1001); |
| 119 sr.AddReportBlock(report_block); |
| 120 ASSERT_EQ(sr.report_blocks().size(), 1u); |
| 121 ASSERT_EQ(sr.report_blocks()[0].jitter(), 1001u); |
| 122 |
| 123 std::vector<ReportBlock> blocks(3); |
| 124 blocks[0].SetJitter(2001); |
| 125 blocks[1].SetJitter(3001); |
| 126 blocks[2].SetJitter(4001); |
| 127 EXPECT_TRUE(sr.SetReportBlocks(blocks)); |
| 128 ASSERT_EQ(sr.report_blocks().size(), 3u); |
| 129 EXPECT_EQ(sr.report_blocks()[0].jitter(), 2001u); |
| 130 EXPECT_EQ(sr.report_blocks()[1].jitter(), 3001u); |
| 131 EXPECT_EQ(sr.report_blocks()[2].jitter(), 4001u); |
| 132 } |
| 133 |
| 134 TEST(RtcpPacketSenderReportTest, CanSetMax31ReportBlock) { |
| 135 SenderReport sr; |
| 136 const size_t kMaxReportBlocks = (1 << 5) - 1; |
| 137 |
| 138 std::vector<ReportBlock> blocks(kMaxReportBlocks); |
| 139 EXPECT_TRUE(sr.SetReportBlocks(blocks)); |
| 140 |
| 141 blocks.push_back(ReportBlock()); |
| 142 EXPECT_FALSE(sr.SetReportBlocks(blocks)); |
| 143 } |
| 144 |
| 114 } // namespace webrtc | 145 } // namespace webrtc |
| OLD | NEW |