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 = | 142 std::unique_ptr<ForwardErrorCorrection::Packet> packet( |
143 new ForwardErrorCorrection::Packet(); | 143 new ForwardErrorCorrection::Packet()); |
144 packet->length = payload_length + rtp_header_length; | 144 packet->length = payload_length + rtp_header_length; |
145 memcpy(packet->data, data_buffer, packet->length); | 145 memcpy(packet->data, data_buffer, packet->length); |
146 media_packets_fec_.push_back(packet); | 146 media_packets_fec_.push_back(std::move(packet)); |
147 } | 147 } |
148 if (marker_bit) { | 148 if (marker_bit) { |
149 ++num_frames_; | 149 ++num_frames_; |
150 complete_frame = true; | 150 complete_frame = true; |
151 } | 151 } |
152 // 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: |
153 // (1) the excess overhead (actual overhead - requested/target overhead) is | 153 // (1) the excess overhead (actual overhead - requested/target overhead) is |
154 // less than |kMaxExcessOverhead|, and | 154 // less than |kMaxExcessOverhead|, and |
155 // (2) at least |minimum_media_packets_fec_| media packets is reached. | 155 // (2) at least |minimum_media_packets_fec_| media packets is reached. |
156 if (complete_frame && | 156 if (complete_frame && |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 size_t rtp_header_length) { | 212 size_t rtp_header_length) { |
213 std::vector<RedPacket*> fec_packets; | 213 std::vector<RedPacket*> fec_packets; |
214 fec_packets.reserve(fec_packets_.size()); | 214 fec_packets.reserve(fec_packets_.size()); |
215 uint16_t sequence_number = first_seq_num; | 215 uint16_t sequence_number = first_seq_num; |
216 while (!fec_packets_.empty()) { | 216 while (!fec_packets_.empty()) { |
217 // Build FEC packet. The FEC packets in |fec_packets_| doesn't | 217 // Build FEC packet. The FEC packets in |fec_packets_| doesn't |
218 // 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 |
219 // media packet. | 219 // media packet. |
220 ForwardErrorCorrection::Packet* packet_to_send = fec_packets_.front(); | 220 ForwardErrorCorrection::Packet* packet_to_send = fec_packets_.front(); |
221 ForwardErrorCorrection::Packet* last_media_packet = | 221 ForwardErrorCorrection::Packet* last_media_packet = |
222 media_packets_fec_.back(); | 222 media_packets_fec_.back().get(); |
223 | 223 |
224 RedPacket* red_packet = new RedPacket( | 224 RedPacket* red_packet = new RedPacket( |
225 packet_to_send->length + kREDForFECHeaderLength + rtp_header_length); | 225 packet_to_send->length + kREDForFECHeaderLength + rtp_header_length); |
226 red_packet->CreateHeader(last_media_packet->data, rtp_header_length, | 226 red_packet->CreateHeader(last_media_packet->data, rtp_header_length, |
227 red_pl_type, fec_pl_type); | 227 red_pl_type, fec_pl_type); |
228 red_packet->SetSeqNum(sequence_number++); | 228 red_packet->SetSeqNum(sequence_number++); |
229 red_packet->ClearMarkerBit(); | 229 red_packet->ClearMarkerBit(); |
230 red_packet->AssignPayload(packet_to_send->data, packet_to_send->length); | 230 red_packet->AssignPayload(packet_to_send->data, packet_to_send->length); |
231 | 231 |
232 fec_packets.push_back(red_packet); | 232 fec_packets.push_back(red_packet); |
(...skipping 11 matching lines...) Expand all Loading... | |
244 // protection factor produced by video_coding module and how the FEC | 244 // protection factor produced by video_coding module and how the FEC |
245 // generation is implemented. | 245 // generation is implemented. |
246 assert(!media_packets_fec_.empty()); | 246 assert(!media_packets_fec_.empty()); |
247 int num_fec_packets = fec_->GetNumberOfFecPackets(media_packets_fec_.size(), | 247 int num_fec_packets = fec_->GetNumberOfFecPackets(media_packets_fec_.size(), |
248 params_.fec_rate); | 248 params_.fec_rate); |
249 // Return the overhead in Q8. | 249 // Return the overhead in Q8. |
250 return (num_fec_packets << 8) / media_packets_fec_.size(); | 250 return (num_fec_packets << 8) / media_packets_fec_.size(); |
251 } | 251 } |
252 | 252 |
253 void ProducerFec::DeletePackets() { | 253 void ProducerFec::DeletePackets() { |
254 while (!media_packets_fec_.empty()) { | 254 media_packets_fec_.clear(); |
255 delete media_packets_fec_.front(); | |
256 media_packets_fec_.pop_front(); | |
257 } | |
258 assert(media_packets_fec_.empty()); | 255 assert(media_packets_fec_.empty()); |
danilchap
2016/06/30 19:58:37
remove this assert
brandtr
2016/07/01 10:45:34
Done.
| |
259 } | 256 } |
260 | 257 |
261 } // namespace webrtc | 258 } // namespace webrtc |
OLD | NEW |