OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 // Remove RED header of incoming packet and store as a virtual RTP packet. | 85 // Remove RED header of incoming packet and store as a virtual RTP packet. |
86 std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> received_packet( | 86 std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> received_packet( |
87 new ForwardErrorCorrection::ReceivedPacket()); | 87 new ForwardErrorCorrection::ReceivedPacket()); |
88 received_packet->pkt = new ForwardErrorCorrection::Packet(); | 88 received_packet->pkt = new ForwardErrorCorrection::Packet(); |
89 | 89 |
90 // Get payload type from RED header and sequence number from RTP header. | 90 // Get payload type from RED header and sequence number from RTP header. |
91 uint8_t payload_type = incoming_rtp_packet[header.headerLength] & 0x7f; | 91 uint8_t payload_type = incoming_rtp_packet[header.headerLength] & 0x7f; |
92 received_packet->is_fec = payload_type == ulpfec_payload_type; | 92 received_packet->is_fec = payload_type == ulpfec_payload_type; |
93 received_packet->ssrc = header.ssrc; | |
94 received_packet->seq_num = header.sequenceNumber; | 93 received_packet->seq_num = header.sequenceNumber; |
95 | 94 |
96 uint16_t block_length = 0; | 95 uint16_t block_length = 0; |
97 if (incoming_rtp_packet[header.headerLength] & 0x80) { | 96 if (incoming_rtp_packet[header.headerLength] & 0x80) { |
98 // f bit set in RED header, i.e. there are more than one RED header blocks. | 97 // f bit set in RED header, i.e. there are more than one RED header blocks. |
99 red_header_length = 4; | 98 red_header_length = 4; |
100 if (payload_data_length < red_header_length + 1u) { | 99 if (payload_data_length < red_header_length + 1u) { |
101 LOG(LS_WARNING) << "Corrupt/truncated FEC packet."; | 100 LOG(LS_WARNING) << "Corrupt/truncated FEC packet."; |
102 return -1; | 101 return -1; |
103 } | 102 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // Copy payload data. | 148 // Copy payload data. |
150 memcpy(received_packet->pkt->data + header.headerLength, | 149 memcpy(received_packet->pkt->data + header.headerLength, |
151 incoming_rtp_packet + header.headerLength + red_header_length, | 150 incoming_rtp_packet + header.headerLength + red_header_length, |
152 block_length); | 151 block_length); |
153 received_packet->pkt->length = block_length; | 152 received_packet->pkt->length = block_length; |
154 | 153 |
155 second_received_packet.reset(new ForwardErrorCorrection::ReceivedPacket); | 154 second_received_packet.reset(new ForwardErrorCorrection::ReceivedPacket); |
156 second_received_packet->pkt = new ForwardErrorCorrection::Packet; | 155 second_received_packet->pkt = new ForwardErrorCorrection::Packet; |
157 | 156 |
158 second_received_packet->is_fec = true; | 157 second_received_packet->is_fec = true; |
159 second_received_packet->ssrc = header.ssrc; | |
160 second_received_packet->seq_num = header.sequenceNumber; | 158 second_received_packet->seq_num = header.sequenceNumber; |
161 ++packet_counter_.num_fec_packets; | 159 ++packet_counter_.num_fec_packets; |
162 | 160 |
163 // Copy FEC payload data. | 161 // Copy FEC payload data. |
164 memcpy(second_received_packet->pkt->data, | 162 memcpy(second_received_packet->pkt->data, |
165 incoming_rtp_packet + header.headerLength + red_header_length + | 163 incoming_rtp_packet + header.headerLength + red_header_length + |
166 block_length, | 164 block_length, |
167 payload_data_length - red_header_length - block_length); | 165 payload_data_length - red_header_length - block_length); |
168 | 166 |
169 second_received_packet->pkt->length = | 167 second_received_packet->pkt->length = |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 return -1; | 238 return -1; |
241 } | 239 } |
242 crit_sect_.Enter(); | 240 crit_sect_.Enter(); |
243 recovered_packet->returned = true; | 241 recovered_packet->returned = true; |
244 } | 242 } |
245 crit_sect_.Leave(); | 243 crit_sect_.Leave(); |
246 return 0; | 244 return 0; |
247 } | 245 } |
248 | 246 |
249 } // namespace webrtc | 247 } // namespace webrtc |
OLD | NEW |