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 |
(...skipping 91 matching lines...) Loading... |
102 count_++; | 102 count_++; |
103 const unsigned char* ptr = static_cast<const unsigned char*>(data); | 103 const unsigned char* ptr = static_cast<const unsigned char*>(data); |
104 uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11]; | 104 uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11]; |
105 if (ssrc == rtx_ssrc_) count_rtx_ssrc_++; | 105 if (ssrc == rtx_ssrc_) count_rtx_ssrc_++; |
106 uint16_t sequence_number = (ptr[2] << 8) + ptr[3]; | 106 uint16_t sequence_number = (ptr[2] << 8) + ptr[3]; |
107 size_t packet_length = len; | 107 size_t packet_length = len; |
108 // TODO(pbos): Figure out why this needs to be initialized. Likely this | 108 // TODO(pbos): Figure out why this needs to be initialized. Likely this |
109 // is hiding a bug either in test setup or other code. | 109 // is hiding a bug either in test setup or other code. |
110 // https://code.google.com/p/webrtc/issues/detail?id=3183 | 110 // https://code.google.com/p/webrtc/issues/detail?id=3183 |
111 uint8_t restored_packet[1500] = {0}; | 111 uint8_t restored_packet[1500] = {0}; |
112 uint8_t* restored_packet_ptr = restored_packet; | |
113 RTPHeader header; | 112 RTPHeader header; |
114 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); | 113 rtc::scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); |
115 if (!parser->Parse(ptr, len, &header)) { | 114 if (!parser->Parse(ptr, len, &header)) { |
116 return false; | 115 return false; |
117 } | 116 } |
118 | 117 |
119 if (!rtp_payload_registry_->IsRtx(header)) { | 118 if (!rtp_payload_registry_->IsRtx(header)) { |
120 // Don't store retransmitted packets since we compare it to the list | 119 // Don't store retransmitted packets since we compare it to the list |
121 // created by the receiver. | 120 // created by the receiver. |
122 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(), | 121 expected_sequence_numbers_.insert(expected_sequence_numbers_.end(), |
123 sequence_number); | 122 sequence_number); |
124 } | 123 } |
125 if (packet_loss_ > 0) { | 124 if (packet_loss_ > 0) { |
126 if ((count_ % packet_loss_) == 0) { | 125 if ((count_ % packet_loss_) == 0) { |
127 return true; | 126 return true; |
128 } | 127 } |
129 } else if (count_ >= consecutive_drop_start_ && | 128 } else if (count_ >= consecutive_drop_start_ && |
130 count_ < consecutive_drop_end_) { | 129 count_ < consecutive_drop_end_) { |
131 return true; | 130 return true; |
132 } | 131 } |
133 if (rtp_payload_registry_->IsRtx(header)) { | 132 if (rtp_payload_registry_->IsRtx(header)) { |
134 // Remove the RTX header and parse the original RTP header. | 133 // Remove the RTX header and parse the original RTP header. |
135 EXPECT_TRUE(rtp_payload_registry_->RestoreOriginalPacket( | 134 EXPECT_TRUE(rtp_payload_registry_->RestoreOriginalPacket( |
136 &restored_packet_ptr, ptr, &packet_length, rtp_receiver_->SSRC(), | 135 restored_packet, ptr, &packet_length, rtp_receiver_->SSRC(), header)); |
137 header)); | 136 if (!parser->Parse(restored_packet, packet_length, &header)) { |
138 if (!parser->Parse(restored_packet_ptr, packet_length, &header)) { | |
139 return false; | 137 return false; |
140 } | 138 } |
141 } else { | 139 } else { |
142 rtp_payload_registry_->SetIncomingPayloadType(header); | 140 rtp_payload_registry_->SetIncomingPayloadType(header); |
143 } | 141 } |
144 | 142 |
145 restored_packet_ptr += header.headerLength; | 143 const uint8_t* restored_packet_payload = |
| 144 restored_packet + header.headerLength; |
146 packet_length -= header.headerLength; | 145 packet_length -= header.headerLength; |
147 PayloadUnion payload_specific; | 146 PayloadUnion payload_specific; |
148 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, | 147 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, |
149 &payload_specific)) { | 148 &payload_specific)) { |
150 return false; | 149 return false; |
151 } | 150 } |
152 if (!rtp_receiver_->IncomingRtpPacket(header, restored_packet_ptr, | 151 if (!rtp_receiver_->IncomingRtpPacket(header, restored_packet_payload, |
153 packet_length, payload_specific, | 152 packet_length, payload_specific, |
154 true)) { | 153 true)) { |
155 return false; | 154 return false; |
156 } | 155 } |
157 return true; | 156 return true; |
158 } | 157 } |
159 | 158 |
160 bool SendRtcp(const uint8_t* data, size_t len) override { | 159 bool SendRtcp(const uint8_t* data, size_t len) override { |
161 return module_->IncomingRtcpPacket((const uint8_t*)data, len) == 0; | 160 return module_->IncomingRtcpPacket((const uint8_t*)data, len) == 0; |
162 } | 161 } |
(...skipping 181 matching lines...) Loading... |
344 | 343 |
345 TEST_F(RtpRtcpRtxNackTest, RtxNack) { | 344 TEST_F(RtpRtcpRtxNackTest, RtxNack) { |
346 RunRtxTest(kRtxRetransmitted, 10); | 345 RunRtxTest(kRtxRetransmitted, 10); |
347 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin())); | 346 EXPECT_EQ(kTestSequenceNumber, *(receiver_.sequence_numbers_.begin())); |
348 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1, | 347 EXPECT_EQ(kTestSequenceNumber + kTestNumberOfPackets - 1, |
349 *(receiver_.sequence_numbers_.rbegin())); | 348 *(receiver_.sequence_numbers_.rbegin())); |
350 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size()); | 349 EXPECT_EQ(kTestNumberOfPackets, receiver_.sequence_numbers_.size()); |
351 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_); | 350 EXPECT_EQ(kTestNumberOfRtxPackets, transport_.count_rtx_ssrc_); |
352 EXPECT_TRUE(ExpectedPacketsReceived()); | 351 EXPECT_TRUE(ExpectedPacketsReceived()); |
353 } | 352 } |
OLD | NEW |