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