Chromium Code Reviews| 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 |
| 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
| 12 | 12 |
| 13 #include <utility> | |
| 14 | |
| 13 #include "webrtc/test/gmock.h" | 15 #include "webrtc/test/gmock.h" |
| 14 #include "webrtc/test/gtest.h" | 16 #include "webrtc/test/gtest.h" |
| 15 #include "webrtc/test/rtcp_packet_parser.h" | 17 #include "webrtc/test/rtcp_packet_parser.h" |
| 16 | 18 |
| 17 using testing::ElementsAreArray; | 19 using testing::ElementsAreArray; |
| 18 using testing::IsEmpty; | 20 using testing::IsEmpty; |
| 19 using testing::make_tuple; | 21 using testing::make_tuple; |
| 20 using webrtc::rtcp::ReceiverReport; | 22 using webrtc::rtcp::ReceiverReport; |
| 21 using webrtc::rtcp::ReportBlock; | 23 using webrtc::rtcp::ReportBlock; |
| 22 | 24 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 | 112 |
| 111 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc()); | 113 EXPECT_EQ(kSenderSsrc, parsed.sender_ssrc()); |
| 112 EXPECT_EQ(2u, parsed.report_blocks().size()); | 114 EXPECT_EQ(2u, parsed.report_blocks().size()); |
| 113 EXPECT_EQ(kRemoteSsrc, parsed.report_blocks()[0].source_ssrc()); | 115 EXPECT_EQ(kRemoteSsrc, parsed.report_blocks()[0].source_ssrc()); |
| 114 EXPECT_EQ(kRemoteSsrc + 1, parsed.report_blocks()[1].source_ssrc()); | 116 EXPECT_EQ(kRemoteSsrc + 1, parsed.report_blocks()[1].source_ssrc()); |
| 115 } | 117 } |
| 116 | 118 |
| 117 TEST(RtcpPacketReceiverReportTest, CreateWithTooManyReportBlocks) { | 119 TEST(RtcpPacketReceiverReportTest, CreateWithTooManyReportBlocks) { |
| 118 ReceiverReport rr; | 120 ReceiverReport rr; |
| 119 rr.SetSenderSsrc(kSenderSsrc); | 121 rr.SetSenderSsrc(kSenderSsrc); |
| 120 const size_t kMaxReportBlocks = (1 << 5) - 1; | |
| 121 ReportBlock rb; | 122 ReportBlock rb; |
| 122 for (size_t i = 0; i < kMaxReportBlocks; ++i) { | 123 for (size_t i = 0; i < ReceiverReport::kMaxNumberOfReportBlocks; ++i) { |
| 123 rb.SetMediaSsrc(kRemoteSsrc + i); | 124 rb.SetMediaSsrc(kRemoteSsrc + i); |
| 124 EXPECT_TRUE(rr.AddReportBlock(rb)); | 125 EXPECT_TRUE(rr.AddReportBlock(rb)); |
| 125 } | 126 } |
| 126 rb.SetMediaSsrc(kRemoteSsrc + kMaxReportBlocks); | 127 rb.SetMediaSsrc(kRemoteSsrc - 1); |
|
eladalon
2017/07/25 13:26:09
IMHO, as a second pair of eyes, it was clearer wit
danilchap
2017/07/25 13:39:00
I'll add + kMax back since it is clearer.
| |
| 127 EXPECT_FALSE(rr.AddReportBlock(rb)); | 128 EXPECT_FALSE(rr.AddReportBlock(rb)); |
| 128 } | 129 } |
| 129 | 130 |
| 131 TEST(RtcpPacketReceiverReportTest, SetReportBlocksOverwritesOldBlocks) { | |
| 132 ReceiverReport rr; | |
| 133 ReportBlock report_block; | |
| 134 // Use jitter field of the report blocks to distinguish them. | |
| 135 report_block.SetJitter(1001u); | |
| 136 rr.AddReportBlock(report_block); | |
| 137 ASSERT_EQ(rr.report_blocks().size(), 1u); | |
| 138 ASSERT_EQ(rr.report_blocks()[0].jitter(), 1001u); | |
| 139 | |
| 140 std::vector<ReportBlock> blocks(3u); | |
| 141 blocks[0].SetJitter(2001u); | |
| 142 blocks[1].SetJitter(3001u); | |
| 143 blocks[2].SetJitter(4001u); | |
| 144 EXPECT_TRUE(rr.SetReportBlocks(blocks)); | |
| 145 ASSERT_EQ(rr.report_blocks().size(), 3u); | |
| 146 EXPECT_EQ(rr.report_blocks()[0].jitter(), 2001u); | |
| 147 EXPECT_EQ(rr.report_blocks()[1].jitter(), 3001u); | |
| 148 EXPECT_EQ(rr.report_blocks()[2].jitter(), 4001u); | |
| 149 } | |
| 150 | |
| 151 TEST(RtcpPacketReceiverReportTest, SetReportBlocksMaxLimit) { | |
| 152 ReceiverReport rr; | |
| 153 std::vector<ReportBlock> max_blocks(ReceiverReport::kMaxNumberOfReportBlocks); | |
| 154 EXPECT_TRUE(rr.SetReportBlocks(std::move(max_blocks))); | |
| 155 | |
| 156 std::vector<ReportBlock> one_too_many_blocks( | |
| 157 ReceiverReport::kMaxNumberOfReportBlocks + 1); | |
| 158 EXPECT_FALSE(rr.SetReportBlocks(std::move(one_too_many_blocks))); | |
| 159 } | |
| 160 | |
| 130 } // namespace webrtc | 161 } // namespace webrtc |
| OLD | NEW |