| OLD | NEW |
| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 ss << ", render_delay_ms: " << render_delay_ms; | 103 ss << ", render_delay_ms: " << render_delay_ms; |
| 104 ss << ", target_delay_ms: " << target_delay_ms; | 104 ss << ", target_delay_ms: " << target_delay_ms; |
| 105 ss << ", suspend_below_min_bitrate: " << (suspend_below_min_bitrate ? "on" | 105 ss << ", suspend_below_min_bitrate: " << (suspend_below_min_bitrate ? "on" |
| 106 : "off"); | 106 : "off"); |
| 107 ss << '}'; | 107 ss << '}'; |
| 108 return ss.str(); | 108 return ss.str(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 namespace { | 111 namespace { |
| 112 | 112 |
| 113 VideoCodecType PayloadNameToCodecType(const std::string& payload_name) { |
| 114 if (payload_name == "VP8") |
| 115 return kVideoCodecVP8; |
| 116 if (payload_name == "VP9") |
| 117 return kVideoCodecVP9; |
| 118 if (payload_name == "H264") |
| 119 return kVideoCodecH264; |
| 120 return kVideoCodecGeneric; |
| 121 } |
| 122 |
| 123 bool PayloadTypeSupportsSkippingFecPackets(const std::string& payload_name) { |
| 124 switch (PayloadNameToCodecType(payload_name)) { |
| 125 case kVideoCodecVP8: |
| 126 case kVideoCodecVP9: |
| 127 return true; |
| 128 case kVideoCodecH264: |
| 129 case kVideoCodecGeneric: |
| 130 return false; |
| 131 case kVideoCodecI420: |
| 132 case kVideoCodecRED: |
| 133 case kVideoCodecULPFEC: |
| 134 case kVideoCodecUnknown: |
| 135 RTC_NOTREACHED(); |
| 136 return false; |
| 137 } |
| 138 RTC_NOTREACHED(); |
| 139 return false; |
| 140 } |
| 141 |
| 113 CpuOveruseOptions GetCpuOveruseOptions(bool full_overuse_time) { | 142 CpuOveruseOptions GetCpuOveruseOptions(bool full_overuse_time) { |
| 114 CpuOveruseOptions options; | 143 CpuOveruseOptions options; |
| 115 if (full_overuse_time) { | 144 if (full_overuse_time) { |
| 116 options.low_encode_usage_threshold_percent = 100; | 145 options.low_encode_usage_threshold_percent = 100; |
| 117 options.high_encode_usage_threshold_percent = 120; | 146 options.high_encode_usage_threshold_percent = 120; |
| 118 } | 147 } |
| 119 return options; | 148 return options; |
| 120 } | 149 } |
| 121 } // namespace | 150 } // namespace |
| 122 | 151 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 RTC_NOTREACHED() << "Registering unsupported RTP extension."; | 242 RTC_NOTREACHED() << "Registering unsupported RTP extension."; |
| 214 } | 243 } |
| 215 } | 244 } |
| 216 | 245 |
| 217 RtpRtcp* rtp_module = vie_channel_->rtp_rtcp(); | 246 RtpRtcp* rtp_module = vie_channel_->rtp_rtcp(); |
| 218 remb_->AddRembSender(rtp_module); | 247 remb_->AddRembSender(rtp_module); |
| 219 rtp_module->SetREMBStatus(true); | 248 rtp_module->SetREMBStatus(true); |
| 220 | 249 |
| 221 // Enable NACK, FEC or both. | 250 // Enable NACK, FEC or both. |
| 222 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; | 251 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; |
| 223 const bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; | 252 bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; |
| 253 // Payload types without picture ID cannot determine that a stream is complete |
| 254 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is |
| 255 // a waste of bandwidth since FEC packets still have to be transmitted. Note |
| 256 // that this is not the case with FLEXFEC. |
| 257 if (enable_protection_nack && |
| 258 !PayloadTypeSupportsSkippingFecPackets( |
| 259 config_.encoder_settings.payload_name)) { |
| 260 LOG(LS_WARNING) << "Transmitting payload type without picture ID using" |
| 261 "NACK+FEC is a waste of bandwidth since FEC packets " |
| 262 "also have to be retransmitted. Disabling FEC."; |
| 263 enable_protection_fec = false; |
| 264 } |
| 224 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. | 265 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. |
| 225 vie_channel_->SetProtectionMode(enable_protection_nack, enable_protection_fec, | 266 vie_channel_->SetProtectionMode(enable_protection_nack, enable_protection_fec, |
| 226 config_.rtp.fec.red_payload_type, | 267 config_.rtp.fec.red_payload_type, |
| 227 config_.rtp.fec.ulpfec_payload_type); | 268 config_.rtp.fec.ulpfec_payload_type); |
| 228 vie_encoder_->SetProtectionMethod(enable_protection_nack, | 269 vie_encoder_->SetProtectionMethod(enable_protection_nack, |
| 229 enable_protection_fec); | 270 enable_protection_fec); |
| 230 | 271 |
| 231 ConfigureSsrcs(); | 272 ConfigureSsrcs(); |
| 232 | 273 |
| 233 vie_channel_->SetRTCPCName(config_.rtp.c_name.c_str()); | 274 vie_channel_->SetRTCPCName(config_.rtp.c_name.c_str()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 bool VideoSendStream::ReconfigureVideoEncoder( | 370 bool VideoSendStream::ReconfigureVideoEncoder( |
| 330 const VideoEncoderConfig& config) { | 371 const VideoEncoderConfig& config) { |
| 331 TRACE_EVENT0("webrtc", "VideoSendStream::(Re)configureVideoEncoder"); | 372 TRACE_EVENT0("webrtc", "VideoSendStream::(Re)configureVideoEncoder"); |
| 332 LOG(LS_INFO) << "(Re)configureVideoEncoder: " << config.ToString(); | 373 LOG(LS_INFO) << "(Re)configureVideoEncoder: " << config.ToString(); |
| 333 const std::vector<VideoStream>& streams = config.streams; | 374 const std::vector<VideoStream>& streams = config.streams; |
| 334 RTC_DCHECK(!streams.empty()); | 375 RTC_DCHECK(!streams.empty()); |
| 335 RTC_DCHECK_GE(config_.rtp.ssrcs.size(), streams.size()); | 376 RTC_DCHECK_GE(config_.rtp.ssrcs.size(), streams.size()); |
| 336 | 377 |
| 337 VideoCodec video_codec; | 378 VideoCodec video_codec; |
| 338 memset(&video_codec, 0, sizeof(video_codec)); | 379 memset(&video_codec, 0, sizeof(video_codec)); |
| 339 if (config_.encoder_settings.payload_name == "VP8") { | 380 video_codec.codecType = |
| 340 video_codec.codecType = kVideoCodecVP8; | 381 PayloadNameToCodecType(config_.encoder_settings.payload_name); |
| 341 } else if (config_.encoder_settings.payload_name == "VP9") { | |
| 342 video_codec.codecType = kVideoCodecVP9; | |
| 343 } else if (config_.encoder_settings.payload_name == "H264") { | |
| 344 video_codec.codecType = kVideoCodecH264; | |
| 345 } else { | |
| 346 video_codec.codecType = kVideoCodecGeneric; | |
| 347 } | |
| 348 | 382 |
| 349 switch (config.content_type) { | 383 switch (config.content_type) { |
| 350 case VideoEncoderConfig::ContentType::kRealtimeVideo: | 384 case VideoEncoderConfig::ContentType::kRealtimeVideo: |
| 351 video_codec.mode = kRealtimeVideo; | 385 video_codec.mode = kRealtimeVideo; |
| 352 break; | 386 break; |
| 353 case VideoEncoderConfig::ContentType::kScreen: | 387 case VideoEncoderConfig::ContentType::kScreen: |
| 354 video_codec.mode = kScreensharing; | 388 video_codec.mode = kScreensharing; |
| 355 if (config.streams.size() == 1 && | 389 if (config.streams.size() == 1 && |
| 356 config.streams[0].temporal_layer_thresholds_bps.size() == 1) { | 390 config.streams[0].temporal_layer_thresholds_bps.size() == 1) { |
| 357 video_codec.targetBitrate = | 391 video_codec.targetBitrate = |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 vie_encoder_->SetSsrcs(used_ssrcs); | 646 vie_encoder_->SetSsrcs(used_ssrcs); |
| 613 | 647 |
| 614 // Restart the media flow | 648 // Restart the media flow |
| 615 vie_encoder_->Restart(); | 649 vie_encoder_->Restart(); |
| 616 | 650 |
| 617 return true; | 651 return true; |
| 618 } | 652 } |
| 619 | 653 |
| 620 } // namespace internal | 654 } // namespace internal |
| 621 } // namespace webrtc | 655 } // namespace webrtc |
| OLD | NEW |