Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/producer_fec.cc

Issue 2275443002: Minor fixes in FEC and RtpSender{,Video}. (pt. 2) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@header_reader_writer-pt1-move_copy_column
Patch Set: Rebase. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 uint8_t* RedPacket::data() const { 87 uint8_t* RedPacket::data() const {
88 return data_.get(); 88 return data_.get();
89 } 89 }
90 90
91 size_t RedPacket::length() const { 91 size_t RedPacket::length() const {
92 return length_; 92 return length_;
93 } 93 }
94 94
95 ProducerFec::ProducerFec(ForwardErrorCorrection* fec) 95 ProducerFec::ProducerFec()
96 : fec_(fec), 96 : num_protected_frames_(0),
97 media_packets_(),
98 generated_fec_packets_(),
99 num_protected_frames_(0),
100 num_important_packets_(0), 97 num_important_packets_(0),
101 min_num_media_packets_(1), 98 min_num_media_packets_(1) {
102 params_(),
103 new_params_() {
104 memset(&params_, 0, sizeof(params_)); 99 memset(&params_, 0, sizeof(params_));
105 memset(&new_params_, 0, sizeof(new_params_)); 100 memset(&new_params_, 0, sizeof(new_params_));
106 } 101 }
107 102
108 ProducerFec::~ProducerFec() { 103 ProducerFec::~ProducerFec() {
109 DeleteMediaPackets(); 104 DeleteMediaPackets();
110 } 105 }
111 106
112 std::unique_ptr<RedPacket> ProducerFec::BuildRedPacket( 107 std::unique_ptr<RedPacket> ProducerFec::BuildRedPacket(
113 const uint8_t* data_buffer, 108 const uint8_t* data_buffer,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 (num_protected_frames_ == params_.max_fec_frames || 168 (num_protected_frames_ == params_.max_fec_frames ||
174 (ExcessOverheadBelowMax() && MinimumMediaPacketsReached()))) { 169 (ExcessOverheadBelowMax() && MinimumMediaPacketsReached()))) {
175 RTC_DCHECK_LE(num_important_packets_, 170 RTC_DCHECK_LE(num_important_packets_,
176 static_cast<int>(ForwardErrorCorrection::kMaxMediaPackets)); 171 static_cast<int>(ForwardErrorCorrection::kMaxMediaPackets));
177 // TODO(pbos): Consider whether unequal protection should be enabled or not, 172 // TODO(pbos): Consider whether unequal protection should be enabled or not,
178 // it is currently always disabled. 173 // it is currently always disabled.
179 // 174 //
180 // Since unequal protection is disabled, the value of 175 // Since unequal protection is disabled, the value of
181 // |num_important_packets_| has no importance when calling GenerateFec(). 176 // |num_important_packets_| has no importance when calling GenerateFec().
182 constexpr bool kUseUnequalProtection = false; 177 constexpr bool kUseUnequalProtection = false;
183 int ret = fec_->GenerateFec(media_packets_, params_.fec_rate, 178 int ret = fec_.GenerateFec(media_packets_, params_.fec_rate,
184 num_important_packets_, kUseUnequalProtection, 179 num_important_packets_, kUseUnequalProtection,
185 params_.fec_mask_type, &generated_fec_packets_); 180 params_.fec_mask_type, &generated_fec_packets_);
186 if (generated_fec_packets_.empty()) { 181 if (generated_fec_packets_.empty()) {
187 num_protected_frames_ = 0; 182 num_protected_frames_ = 0;
188 DeleteMediaPackets(); 183 DeleteMediaPackets();
189 } 184 }
190 return ret; 185 return ret;
191 } 186 }
192 return 0; 187 return 0;
193 } 188 }
194 189
195 bool ProducerFec::ExcessOverheadBelowMax() const { 190 bool ProducerFec::ExcessOverheadBelowMax() const {
(...skipping 14 matching lines...) Expand all
210 } 205 }
211 206
212 bool ProducerFec::FecAvailable() const { 207 bool ProducerFec::FecAvailable() const {
213 return !generated_fec_packets_.empty(); 208 return !generated_fec_packets_.empty();
214 } 209 }
215 210
216 size_t ProducerFec::NumAvailableFecPackets() const { 211 size_t ProducerFec::NumAvailableFecPackets() const {
217 return generated_fec_packets_.size(); 212 return generated_fec_packets_.size();
218 } 213 }
219 214
215 size_t ProducerFec::MaxPacketOverhead() const {
216 return fec_.MaxPacketOverhead();
217 }
218
220 std::vector<std::unique_ptr<RedPacket>> ProducerFec::GetFecPacketsAsRed( 219 std::vector<std::unique_ptr<RedPacket>> ProducerFec::GetFecPacketsAsRed(
221 int red_payload_type, 220 int red_payload_type,
222 int ulpfec_payload_type, 221 int ulpfec_payload_type,
223 uint16_t first_seq_num, 222 uint16_t first_seq_num,
224 size_t rtp_header_length) { 223 size_t rtp_header_length) {
225 std::vector<std::unique_ptr<RedPacket>> red_packets; 224 std::vector<std::unique_ptr<RedPacket>> red_packets;
226 red_packets.reserve(generated_fec_packets_.size()); 225 red_packets.reserve(generated_fec_packets_.size());
227 RTC_DCHECK(!media_packets_.empty()); 226 RTC_DCHECK(!media_packets_.empty());
228 ForwardErrorCorrection::Packet* last_media_packet = 227 ForwardErrorCorrection::Packet* last_media_packet =
229 media_packets_.back().get(); 228 media_packets_.back().get();
(...skipping 21 matching lines...) Expand all
251 return red_packets; 250 return red_packets;
252 } 251 }
253 252
254 int ProducerFec::Overhead() const { 253 int ProducerFec::Overhead() const {
255 // Overhead is defined as relative to the number of media packets, and not 254 // Overhead is defined as relative to the number of media packets, and not
256 // relative to total number of packets. This definition is inherited from the 255 // relative to total number of packets. This definition is inherited from the
257 // protection factor produced by video_coding module and how the FEC 256 // protection factor produced by video_coding module and how the FEC
258 // generation is implemented. 257 // generation is implemented.
259 RTC_DCHECK(!media_packets_.empty()); 258 RTC_DCHECK(!media_packets_.empty());
260 int num_fec_packets = 259 int num_fec_packets =
261 fec_->GetNumberOfFecPackets(media_packets_.size(), params_.fec_rate); 260 fec_.NumFecPackets(media_packets_.size(), params_.fec_rate);
262 // Return the overhead in Q8. 261 // Return the overhead in Q8.
263 return (num_fec_packets << 8) / media_packets_.size(); 262 return (num_fec_packets << 8) / media_packets_.size();
264 } 263 }
265 264
266 void ProducerFec::DeleteMediaPackets() { 265 void ProducerFec::DeleteMediaPackets() {
267 media_packets_.clear(); 266 media_packets_.clear();
268 } 267 }
269 268
270 } // namespace webrtc 269 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/producer_fec.h ('k') | webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698