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

Side by Side Diff: webrtc/video/video_send_stream.cc

Issue 1687303002: Don't send FEC for H.264 with NACK enabled. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: RED or FEC Created 4 years, 10 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
« no previous file with comments | « webrtc/video/end_to_end_tests.cc ('k') | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 ss << ", render_delay_ms: " << render_delay_ms; 100 ss << ", render_delay_ms: " << render_delay_ms;
101 ss << ", target_delay_ms: " << target_delay_ms; 101 ss << ", target_delay_ms: " << target_delay_ms;
102 ss << ", suspend_below_min_bitrate: " << (suspend_below_min_bitrate ? "on" 102 ss << ", suspend_below_min_bitrate: " << (suspend_below_min_bitrate ? "on"
103 : "off"); 103 : "off");
104 ss << '}'; 104 ss << '}';
105 return ss.str(); 105 return ss.str();
106 } 106 }
107 107
108 namespace { 108 namespace {
109 109
110 VideoCodecType PayloadNameToCodecType(const std::string& payload_name) {
111 if (payload_name == "VP8")
112 return kVideoCodecVP8;
113 if (payload_name == "VP9")
114 return kVideoCodecVP9;
115 if (payload_name == "H264")
116 return kVideoCodecH264;
117 return kVideoCodecGeneric;
118 }
119
120 bool PayloadTypeSupportsSkippingFecPackets(const std::string& payload_name) {
121 switch (PayloadNameToCodecType(payload_name)) {
122 case kVideoCodecVP8:
123 case kVideoCodecVP9:
124 return true;
125 case kVideoCodecH264:
126 case kVideoCodecGeneric:
127 return false;
128 case kVideoCodecI420:
129 case kVideoCodecRED:
130 case kVideoCodecULPFEC:
131 case kVideoCodecUnknown:
132 RTC_NOTREACHED();
133 return false;
134 }
135 RTC_NOTREACHED();
136 return false;
137 }
138
110 CpuOveruseOptions GetCpuOveruseOptions(bool full_overuse_time) { 139 CpuOveruseOptions GetCpuOveruseOptions(bool full_overuse_time) {
111 CpuOveruseOptions options; 140 CpuOveruseOptions options;
112 if (full_overuse_time) { 141 if (full_overuse_time) {
113 options.low_encode_usage_threshold_percent = 100; 142 options.low_encode_usage_threshold_percent = 100;
114 options.high_encode_usage_threshold_percent = 120; 143 options.high_encode_usage_threshold_percent = 120;
115 } 144 }
116 return options; 145 return options;
117 } 146 }
118 } // namespace 147 } // namespace
119 148
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 RTC_NOTREACHED() << "Registering unsupported RTP extension."; 237 RTC_NOTREACHED() << "Registering unsupported RTP extension.";
209 } 238 }
210 } 239 }
211 240
212 RtpRtcp* rtp_module = vie_channel_.rtp_rtcp(); 241 RtpRtcp* rtp_module = vie_channel_.rtp_rtcp();
213 remb_->AddRembSender(rtp_module); 242 remb_->AddRembSender(rtp_module);
214 rtp_module->SetREMBStatus(true); 243 rtp_module->SetREMBStatus(true);
215 244
216 // Enable NACK, FEC or both. 245 // Enable NACK, FEC or both.
217 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; 246 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0;
218 const bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; 247 bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1;
248 // Payload types without picture ID cannot determine that a stream is complete
249 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is
250 // a waste of bandwidth since FEC packets still have to be transmitted. Note
251 // that this is not the case with FLEXFEC.
252 if (enable_protection_nack &&
253 !PayloadTypeSupportsSkippingFecPackets(
254 config_.encoder_settings.payload_name)) {
255 LOG(LS_WARNING) << "Transmitting payload type without picture ID using"
256 "NACK+FEC is a waste of bandwidth since FEC packets "
257 "also have to be retransmitted. Disabling FEC.";
258 enable_protection_fec = false;
259 }
219 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. 260 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future.
220 vie_channel_.SetProtectionMode(enable_protection_nack, enable_protection_fec, 261 vie_channel_.SetProtectionMode(enable_protection_nack, enable_protection_fec,
221 config_.rtp.fec.red_payload_type, 262 config_.rtp.fec.red_payload_type,
222 config_.rtp.fec.ulpfec_payload_type); 263 config_.rtp.fec.ulpfec_payload_type);
223 vie_encoder_.SetProtectionMethod(enable_protection_nack, 264 vie_encoder_.SetProtectionMethod(enable_protection_nack,
224 enable_protection_fec); 265 enable_protection_fec);
225 266
226 ConfigureSsrcs(); 267 ConfigureSsrcs();
227 268
228 vie_channel_.SetRTCPCName(config_.rtp.c_name.c_str()); 269 vie_channel_.SetRTCPCName(config_.rtp.c_name.c_str());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 bool VideoSendStream::ReconfigureVideoEncoder( 358 bool VideoSendStream::ReconfigureVideoEncoder(
318 const VideoEncoderConfig& config) { 359 const VideoEncoderConfig& config) {
319 TRACE_EVENT0("webrtc", "VideoSendStream::(Re)configureVideoEncoder"); 360 TRACE_EVENT0("webrtc", "VideoSendStream::(Re)configureVideoEncoder");
320 LOG(LS_INFO) << "(Re)configureVideoEncoder: " << config.ToString(); 361 LOG(LS_INFO) << "(Re)configureVideoEncoder: " << config.ToString();
321 const std::vector<VideoStream>& streams = config.streams; 362 const std::vector<VideoStream>& streams = config.streams;
322 RTC_DCHECK(!streams.empty()); 363 RTC_DCHECK(!streams.empty());
323 RTC_DCHECK_GE(config_.rtp.ssrcs.size(), streams.size()); 364 RTC_DCHECK_GE(config_.rtp.ssrcs.size(), streams.size());
324 365
325 VideoCodec video_codec; 366 VideoCodec video_codec;
326 memset(&video_codec, 0, sizeof(video_codec)); 367 memset(&video_codec, 0, sizeof(video_codec));
327 if (config_.encoder_settings.payload_name == "VP8") { 368 video_codec.codecType =
328 video_codec.codecType = kVideoCodecVP8; 369 PayloadNameToCodecType(config_.encoder_settings.payload_name);
329 } else if (config_.encoder_settings.payload_name == "VP9") {
330 video_codec.codecType = kVideoCodecVP9;
331 } else if (config_.encoder_settings.payload_name == "H264") {
332 video_codec.codecType = kVideoCodecH264;
333 } else {
334 video_codec.codecType = kVideoCodecGeneric;
335 }
336 370
337 switch (config.content_type) { 371 switch (config.content_type) {
338 case VideoEncoderConfig::ContentType::kRealtimeVideo: 372 case VideoEncoderConfig::ContentType::kRealtimeVideo:
339 video_codec.mode = kRealtimeVideo; 373 video_codec.mode = kRealtimeVideo;
340 break; 374 break;
341 case VideoEncoderConfig::ContentType::kScreen: 375 case VideoEncoderConfig::ContentType::kScreen:
342 video_codec.mode = kScreensharing; 376 video_codec.mode = kScreensharing;
343 if (config.streams.size() == 1 && 377 if (config.streams.size() == 1 &&
344 config.streams[0].temporal_layer_thresholds_bps.size() == 1) { 378 config.streams[0].temporal_layer_thresholds_bps.size() == 1) {
345 video_codec.targetBitrate = 379 video_codec.targetBitrate =
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 used_ssrcs.resize(static_cast<size_t>(video_codec.numberOfSimulcastStreams)); 632 used_ssrcs.resize(static_cast<size_t>(video_codec.numberOfSimulcastStreams));
599 vie_encoder_.SetSsrcs(used_ssrcs); 633 vie_encoder_.SetSsrcs(used_ssrcs);
600 634
601 // Restart the media flow 635 // Restart the media flow
602 vie_encoder_.Restart(); 636 vie_encoder_.Restart();
603 637
604 return true; 638 return true;
605 } 639 }
606 } // namespace internal 640 } // namespace internal
607 } // namespace webrtc 641 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/end_to_end_tests.cc ('k') | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698