| 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 |
| 11 #include "webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h" | 11 #include "webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h" |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 | 14 |
| 15 #include <memory> |
| 16 |
| 15 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
| 16 #include "webrtc/base/scoped_ptr.h" | |
| 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h" |
| 19 | 20 |
| 20 // RFC 5109 | 21 // RFC 5109 |
| 21 namespace webrtc { | 22 namespace webrtc { |
| 22 | 23 |
| 23 FecReceiver* FecReceiver::Create(RtpData* callback) { | 24 FecReceiver* FecReceiver::Create(RtpData* callback) { |
| 24 return new FecReceiverImpl(callback); | 25 return new FecReceiverImpl(callback); |
| 25 } | 26 } |
| 26 | 27 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 size_t payload_data_length = packet_length - header.headerLength; | 81 size_t payload_data_length = packet_length - header.headerLength; |
| 81 | 82 |
| 82 if (payload_data_length == 0) { | 83 if (payload_data_length == 0) { |
| 83 LOG(LS_WARNING) << "Corrupt/truncated FEC packet."; | 84 LOG(LS_WARNING) << "Corrupt/truncated FEC packet."; |
| 84 return -1; | 85 return -1; |
| 85 } | 86 } |
| 86 | 87 |
| 87 // Add to list without RED header, aka a virtual RTP packet | 88 // Add to list without RED header, aka a virtual RTP packet |
| 88 // we remove the RED header | 89 // we remove the RED header |
| 89 | 90 |
| 90 rtc::scoped_ptr<ForwardErrorCorrection::ReceivedPacket> received_packet( | 91 std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> received_packet( |
| 91 new ForwardErrorCorrection::ReceivedPacket); | 92 new ForwardErrorCorrection::ReceivedPacket); |
| 92 received_packet->pkt = new ForwardErrorCorrection::Packet; | 93 received_packet->pkt = new ForwardErrorCorrection::Packet; |
| 93 | 94 |
| 94 // get payload type from RED header | 95 // get payload type from RED header |
| 95 uint8_t payload_type = | 96 uint8_t payload_type = |
| 96 incoming_rtp_packet[header.headerLength] & 0x7f; | 97 incoming_rtp_packet[header.headerLength] & 0x7f; |
| 97 | 98 |
| 98 received_packet->is_fec = payload_type == ulpfec_payload_type; | 99 received_packet->is_fec = payload_type == ulpfec_payload_type; |
| 99 received_packet->seq_num = header.sequenceNumber; | 100 received_packet->seq_num = header.sequenceNumber; |
| 100 | 101 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 128 } | 129 } |
| 129 // Check that the packet is long enough to contain data in the following | 130 // Check that the packet is long enough to contain data in the following |
| 130 // block. | 131 // block. |
| 131 if (blockLength > payload_data_length - (REDHeaderLength + 1)) { | 132 if (blockLength > payload_data_length - (REDHeaderLength + 1)) { |
| 132 LOG(LS_WARNING) << "Block length longer than packet."; | 133 LOG(LS_WARNING) << "Block length longer than packet."; |
| 133 return -1; | 134 return -1; |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 ++packet_counter_.num_packets; | 137 ++packet_counter_.num_packets; |
| 137 | 138 |
| 138 rtc::scoped_ptr<ForwardErrorCorrection::ReceivedPacket> | 139 std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> |
| 139 second_received_packet; | 140 second_received_packet; |
| 140 if (blockLength > 0) { | 141 if (blockLength > 0) { |
| 141 // handle block length, split into 2 packets | 142 // handle block length, split into 2 packets |
| 142 REDHeaderLength = 5; | 143 REDHeaderLength = 5; |
| 143 | 144 |
| 144 // copy the RTP header | 145 // copy the RTP header |
| 145 memcpy(received_packet->pkt->data, incoming_rtp_packet, | 146 memcpy(received_packet->pkt->data, incoming_rtp_packet, |
| 146 header.headerLength); | 147 header.headerLength); |
| 147 | 148 |
| 148 // replace the RED payload type | 149 // replace the RED payload type |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 return -1; | 251 return -1; |
| 251 } | 252 } |
| 252 crit_sect_.Enter(); | 253 crit_sect_.Enter(); |
| 253 (*it)->returned = true; | 254 (*it)->returned = true; |
| 254 } | 255 } |
| 255 crit_sect_.Leave(); | 256 crit_sect_.Leave(); |
| 256 return 0; | 257 return 0; |
| 257 } | 258 } |
| 258 | 259 |
| 259 } // namespace webrtc | 260 } // namespace webrtc |
| OLD | NEW |