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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 size_t payload_length, | 132 size_t payload_length, |
133 size_t rtp_header_length) { | 133 size_t rtp_header_length) { |
134 assert(fec_packets_.empty()); | 134 assert(fec_packets_.empty()); |
135 if (media_packets_fec_.empty()) { | 135 if (media_packets_fec_.empty()) { |
136 params_ = new_params_; | 136 params_ = new_params_; |
137 } | 137 } |
138 bool complete_frame = false; | 138 bool complete_frame = false; |
139 const bool marker_bit = (data_buffer[1] & kRtpMarkerBitMask) ? true : false; | 139 const bool marker_bit = (data_buffer[1] & kRtpMarkerBitMask) ? true : false; |
140 if (media_packets_fec_.size() < ForwardErrorCorrection::kMaxMediaPackets) { | 140 if (media_packets_fec_.size() < ForwardErrorCorrection::kMaxMediaPackets) { |
141 // Generic FEC can only protect up to kMaxMediaPackets packets. | 141 // Generic FEC can only protect up to kMaxMediaPackets packets. |
142 ForwardErrorCorrection::Packet* packet = new ForwardErrorCorrection::Packet; | 142 std::unique_ptr<ForwardErrorCorrection::Packet> packet( |
143 new ForwardErrorCorrection::Packet); | |
stefan-webrtc
2016/06/29 19:36:18
()
brandtr
2016/06/30 14:05:55
Done.
| |
143 packet->length = payload_length + rtp_header_length; | 144 packet->length = payload_length + rtp_header_length; |
144 memcpy(packet->data, data_buffer, packet->length); | 145 memcpy(packet->data, data_buffer, packet->length); |
145 media_packets_fec_.push_back(packet); | 146 media_packets_fec_.push_back(std::move(packet)); |
146 } | 147 } |
147 if (marker_bit) { | 148 if (marker_bit) { |
148 ++num_frames_; | 149 ++num_frames_; |
149 complete_frame = true; | 150 complete_frame = true; |
150 } | 151 } |
151 // Produce FEC over at most |params_.max_fec_frames| frames, or as soon as: | 152 // Produce FEC over at most |params_.max_fec_frames| frames, or as soon as: |
152 // (1) the excess overhead (actual overhead - requested/target overhead) is | 153 // (1) the excess overhead (actual overhead - requested/target overhead) is |
153 // less than |kMaxExcessOverhead|, and | 154 // less than |kMaxExcessOverhead|, and |
154 // (2) at least |minimum_media_packets_fec_| media packets is reached. | 155 // (2) at least |minimum_media_packets_fec_| media packets is reached. |
155 if (complete_frame && | 156 if (complete_frame && |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 size_t rtp_header_length) { | 212 size_t rtp_header_length) { |
212 std::vector<RedPacket*> fec_packets; | 213 std::vector<RedPacket*> fec_packets; |
213 fec_packets.reserve(fec_packets_.size()); | 214 fec_packets.reserve(fec_packets_.size()); |
214 uint16_t sequence_number = first_seq_num; | 215 uint16_t sequence_number = first_seq_num; |
215 while (!fec_packets_.empty()) { | 216 while (!fec_packets_.empty()) { |
216 // Build FEC packet. The FEC packets in |fec_packets_| doesn't | 217 // Build FEC packet. The FEC packets in |fec_packets_| doesn't |
217 // have RTP headers, so we're reusing the header from the last | 218 // have RTP headers, so we're reusing the header from the last |
218 // media packet. | 219 // media packet. |
219 ForwardErrorCorrection::Packet* packet_to_send = fec_packets_.front(); | 220 ForwardErrorCorrection::Packet* packet_to_send = fec_packets_.front(); |
220 ForwardErrorCorrection::Packet* last_media_packet = | 221 ForwardErrorCorrection::Packet* last_media_packet = |
221 media_packets_fec_.back(); | 222 media_packets_fec_.back().get(); |
222 | 223 |
223 RedPacket* red_packet = new RedPacket( | 224 RedPacket* red_packet = new RedPacket( |
224 packet_to_send->length + kREDForFECHeaderLength + rtp_header_length); | 225 packet_to_send->length + kREDForFECHeaderLength + rtp_header_length); |
225 red_packet->CreateHeader(last_media_packet->data, rtp_header_length, | 226 red_packet->CreateHeader(last_media_packet->data, rtp_header_length, |
226 red_pl_type, fec_pl_type); | 227 red_pl_type, fec_pl_type); |
227 red_packet->SetSeqNum(sequence_number++); | 228 red_packet->SetSeqNum(sequence_number++); |
228 red_packet->ClearMarkerBit(); | 229 red_packet->ClearMarkerBit(); |
229 red_packet->AssignPayload(packet_to_send->data, packet_to_send->length); | 230 red_packet->AssignPayload(packet_to_send->data, packet_to_send->length); |
230 | 231 |
231 fec_packets.push_back(red_packet); | 232 fec_packets.push_back(red_packet); |
(...skipping 11 matching lines...) Expand all Loading... | |
243 // protection factor produced by video_coding module and how the FEC | 244 // protection factor produced by video_coding module and how the FEC |
244 // generation is implemented. | 245 // generation is implemented. |
245 assert(!media_packets_fec_.empty()); | 246 assert(!media_packets_fec_.empty()); |
246 int num_fec_packets = fec_->GetNumberOfFecPackets(media_packets_fec_.size(), | 247 int num_fec_packets = fec_->GetNumberOfFecPackets(media_packets_fec_.size(), |
247 params_.fec_rate); | 248 params_.fec_rate); |
248 // Return the overhead in Q8. | 249 // Return the overhead in Q8. |
249 return (num_fec_packets << 8) / media_packets_fec_.size(); | 250 return (num_fec_packets << 8) / media_packets_fec_.size(); |
250 } | 251 } |
251 | 252 |
252 void ProducerFec::DeletePackets() { | 253 void ProducerFec::DeletePackets() { |
253 while (!media_packets_fec_.empty()) { | 254 media_packets_fec_.clear(); |
254 delete media_packets_fec_.front(); | |
255 media_packets_fec_.pop_front(); | |
256 } | |
257 assert(media_packets_fec_.empty()); | 255 assert(media_packets_fec_.empty()); |
258 } | 256 } |
259 | 257 |
260 } // namespace webrtc | 258 } // namespace webrtc |
OLD | NEW |