| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | |
| 139 CpuOveruseOptions GetCpuOveruseOptions(bool full_overuse_time) { | 110 CpuOveruseOptions GetCpuOveruseOptions(bool full_overuse_time) { |
| 140 CpuOveruseOptions options; | 111 CpuOveruseOptions options; |
| 141 if (full_overuse_time) { | 112 if (full_overuse_time) { |
| 142 options.low_encode_usage_threshold_percent = 100; | 113 options.low_encode_usage_threshold_percent = 100; |
| 143 options.high_encode_usage_threshold_percent = 120; | 114 options.high_encode_usage_threshold_percent = 120; |
| 144 } | 115 } |
| 145 return options; | 116 return options; |
| 146 } | 117 } |
| 147 } // namespace | 118 } // namespace |
| 148 | 119 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 RTC_NOTREACHED() << "Registering unsupported RTP extension."; | 208 RTC_NOTREACHED() << "Registering unsupported RTP extension."; |
| 238 } | 209 } |
| 239 } | 210 } |
| 240 | 211 |
| 241 RtpRtcp* rtp_module = vie_channel_.rtp_rtcp(); | 212 RtpRtcp* rtp_module = vie_channel_.rtp_rtcp(); |
| 242 remb_->AddRembSender(rtp_module); | 213 remb_->AddRembSender(rtp_module); |
| 243 rtp_module->SetREMBStatus(true); | 214 rtp_module->SetREMBStatus(true); |
| 244 | 215 |
| 245 // Enable NACK, FEC or both. | 216 // Enable NACK, FEC or both. |
| 246 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; | 217 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; |
| 247 bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; | 218 const 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 } | |
| 260 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. | 219 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. |
| 261 vie_channel_.SetProtectionMode(enable_protection_nack, enable_protection_fec, | 220 vie_channel_.SetProtectionMode(enable_protection_nack, enable_protection_fec, |
| 262 config_.rtp.fec.red_payload_type, | 221 config_.rtp.fec.red_payload_type, |
| 263 config_.rtp.fec.ulpfec_payload_type); | 222 config_.rtp.fec.ulpfec_payload_type); |
| 264 vie_encoder_.SetProtectionMethod(enable_protection_nack, | 223 vie_encoder_.SetProtectionMethod(enable_protection_nack, |
| 265 enable_protection_fec); | 224 enable_protection_fec); |
| 266 | 225 |
| 267 ConfigureSsrcs(); | 226 ConfigureSsrcs(); |
| 268 | 227 |
| 269 vie_channel_.SetRTCPCName(config_.rtp.c_name.c_str()); | 228 vie_channel_.SetRTCPCName(config_.rtp.c_name.c_str()); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 bool VideoSendStream::ReconfigureVideoEncoder( | 317 bool VideoSendStream::ReconfigureVideoEncoder( |
| 359 const VideoEncoderConfig& config) { | 318 const VideoEncoderConfig& config) { |
| 360 TRACE_EVENT0("webrtc", "VideoSendStream::(Re)configureVideoEncoder"); | 319 TRACE_EVENT0("webrtc", "VideoSendStream::(Re)configureVideoEncoder"); |
| 361 LOG(LS_INFO) << "(Re)configureVideoEncoder: " << config.ToString(); | 320 LOG(LS_INFO) << "(Re)configureVideoEncoder: " << config.ToString(); |
| 362 const std::vector<VideoStream>& streams = config.streams; | 321 const std::vector<VideoStream>& streams = config.streams; |
| 363 RTC_DCHECK(!streams.empty()); | 322 RTC_DCHECK(!streams.empty()); |
| 364 RTC_DCHECK_GE(config_.rtp.ssrcs.size(), streams.size()); | 323 RTC_DCHECK_GE(config_.rtp.ssrcs.size(), streams.size()); |
| 365 | 324 |
| 366 VideoCodec video_codec; | 325 VideoCodec video_codec; |
| 367 memset(&video_codec, 0, sizeof(video_codec)); | 326 memset(&video_codec, 0, sizeof(video_codec)); |
| 368 video_codec.codecType = | 327 if (config_.encoder_settings.payload_name == "VP8") { |
| 369 PayloadNameToCodecType(config_.encoder_settings.payload_name); | 328 video_codec.codecType = kVideoCodecVP8; |
| 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 } |
| 370 | 336 |
| 371 switch (config.content_type) { | 337 switch (config.content_type) { |
| 372 case VideoEncoderConfig::ContentType::kRealtimeVideo: | 338 case VideoEncoderConfig::ContentType::kRealtimeVideo: |
| 373 video_codec.mode = kRealtimeVideo; | 339 video_codec.mode = kRealtimeVideo; |
| 374 break; | 340 break; |
| 375 case VideoEncoderConfig::ContentType::kScreen: | 341 case VideoEncoderConfig::ContentType::kScreen: |
| 376 video_codec.mode = kScreensharing; | 342 video_codec.mode = kScreensharing; |
| 377 if (config.streams.size() == 1 && | 343 if (config.streams.size() == 1 && |
| 378 config.streams[0].temporal_layer_thresholds_bps.size() == 1) { | 344 config.streams[0].temporal_layer_thresholds_bps.size() == 1) { |
| 379 video_codec.targetBitrate = | 345 video_codec.targetBitrate = |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 used_ssrcs.resize(static_cast<size_t>(video_codec.numberOfSimulcastStreams)); | 598 used_ssrcs.resize(static_cast<size_t>(video_codec.numberOfSimulcastStreams)); |
| 633 vie_encoder_.SetSsrcs(used_ssrcs); | 599 vie_encoder_.SetSsrcs(used_ssrcs); |
| 634 | 600 |
| 635 // Restart the media flow | 601 // Restart the media flow |
| 636 vie_encoder_.Restart(); | 602 vie_encoder_.Restart(); |
| 637 | 603 |
| 638 return true; | 604 return true; |
| 639 } | 605 } |
| 640 } // namespace internal | 606 } // namespace internal |
| 641 } // namespace webrtc | 607 } // namespace webrtc |
| OLD | NEW |