OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 <algorithm> | 11 #include <algorithm> |
12 #include <iterator> | 12 #include <iterator> |
13 #include <list> | 13 #include <list> |
14 #include <memory> | |
15 #include <set> | 14 #include <set> |
16 | 15 |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "webrtc/base/scoped_ptr.h" |
18 #include "webrtc/common_types.h" | 18 #include "webrtc/common_types.h" |
19 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 19 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
22 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
25 #include "webrtc/transport.h" | 25 #include "webrtc/transport.h" |
26 | 26 |
27 namespace webrtc { | 27 namespace webrtc { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 const PacketOptions& options) override { | 98 const PacketOptions& options) override { |
99 count_++; | 99 count_++; |
100 const unsigned char* ptr = static_cast<const unsigned char*>(data); | 100 const unsigned char* ptr = static_cast<const unsigned char*>(data); |
101 uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11]; | 101 uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11]; |
102 if (ssrc == rtx_ssrc_) | 102 if (ssrc == rtx_ssrc_) |
103 count_rtx_ssrc_++; | 103 count_rtx_ssrc_++; |
104 uint16_t sequence_number = (ptr[2] << 8) + ptr[3]; | 104 uint16_t sequence_number = (ptr[2] << 8) + ptr[3]; |
105 size_t packet_length = len; | 105 size_t packet_length = len; |
106 uint8_t restored_packet[1500]; | 106 uint8_t restored_packet[1500]; |
107 RTPHeader header; | 107 RTPHeader header; |
108 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); | 108 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); |
109 if (!parser->Parse(ptr, len, &header)) { | 109 if (!parser->Parse(ptr, len, &header)) { |
110 return false; | 110 return false; |
111 } | 111 } |
112 | 112 |
113 if (!rtp_payload_registry_->IsRtx(header)) { | 113 if (!rtp_payload_registry_->IsRtx(header)) { |
114 // Don't store retransmitted packets since we compare it to the list | 114 // Don't store retransmitted packets since we compare it to the list |
115 // created by the receiver. | 115 // created by the receiver. |
116 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(), | 116 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(), |
117 sequence_number); | 117 sequence_number); |
118 } | 118 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 fake_clock.AdvanceTimeMilliseconds(28); // 33ms - 5ms delay. | 272 fake_clock.AdvanceTimeMilliseconds(28); // 33ms - 5ms delay. |
273 rtp_rtcp_module_->Process(); | 273 rtp_rtcp_module_->Process(); |
274 // Prepare next frame. | 274 // Prepare next frame. |
275 timestamp += 3000; | 275 timestamp += 3000; |
276 } | 276 } |
277 receiver_.sequence_numbers_.sort(); | 277 receiver_.sequence_numbers_.sort(); |
278 } | 278 } |
279 | 279 |
280 void TearDown() override { delete rtp_rtcp_module_; } | 280 void TearDown() override { delete rtp_rtcp_module_; } |
281 | 281 |
282 std::unique_ptr<ReceiveStatistics> receive_statistics_; | 282 rtc::scoped_ptr<ReceiveStatistics> receive_statistics_; |
283 RTPPayloadRegistry rtp_payload_registry_; | 283 RTPPayloadRegistry rtp_payload_registry_; |
284 std::unique_ptr<RtpReceiver> rtp_receiver_; | 284 rtc::scoped_ptr<RtpReceiver> rtp_receiver_; |
285 RtpRtcp* rtp_rtcp_module_; | 285 RtpRtcp* rtp_rtcp_module_; |
286 std::unique_ptr<TestRtpFeedback> rtp_feedback_; | 286 rtc::scoped_ptr<TestRtpFeedback> rtp_feedback_; |
287 RtxLoopBackTransport transport_; | 287 RtxLoopBackTransport transport_; |
288 VerifyingRtxReceiver receiver_; | 288 VerifyingRtxReceiver receiver_; |
289 uint8_t payload_data[65000]; | 289 uint8_t payload_data[65000]; |
290 size_t payload_data_length; | 290 size_t payload_data_length; |
291 SimulatedClock fake_clock; | 291 SimulatedClock fake_clock; |
292 }; | 292 }; |
293 | 293 |
294 TEST_F(RtpRtcpRtxNackTest, LongNackList) { | 294 TEST_F(RtpRtcpRtxNackTest, LongNackList) { |
295 const int kNumPacketsToDrop = 900; | 295 const int kNumPacketsToDrop = 900; |
296 const int kNumRequiredRtcp = 4; | 296 const int kNumRequiredRtcp = 4; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 RunRtxTest(kRtxRetransmitted, 10); | 333 RunRtxTest(kRtxRetransmitted, 10); |
334 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin())); | 334 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin())); |
335 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1, | 335 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1, |
336 *(receiver_.sequence_numbers_.rbegin())); | 336 *(receiver_.sequence_numbers_.rbegin())); |
337 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size()); | 337 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size()); |
338 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_); | 338 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_); |
339 EXPECT_TRUE(ExpectedPacketsReceived()); | 339 EXPECT_TRUE(ExpectedPacketsReceived()); |
340 } | 340 } |
341 | 341 |
342 } // namespace webrtc | 342 } // namespace webrtc |
OLD | NEW |