| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 callback_(nullptr), | 83 callback_(nullptr), |
| 84 forced_fallback_possible_(EnableForcedFallback(codec)) { | 84 forced_fallback_possible_(EnableForcedFallback(codec)) { |
| 85 if (forced_fallback_possible_) { | 85 if (forced_fallback_possible_) { |
| 86 GetForcedFallbackParamsFromFieldTrialGroup(&forced_fallback_.low_kbps, | 86 GetForcedFallbackParamsFromFieldTrialGroup(&forced_fallback_.low_kbps, |
| 87 &forced_fallback_.high_kbps, | 87 &forced_fallback_.high_kbps, |
| 88 &forced_fallback_.min_low_ms); | 88 &forced_fallback_.min_low_ms); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool VideoEncoderSoftwareFallbackWrapper::InitFallbackEncoder() { | 92 bool VideoEncoderSoftwareFallbackWrapper::InitFallbackEncoder() { |
| 93 LOG(LS_WARNING) << "Encoder falling back to software encoding."; |
| 93 MaybeModifyCodecForFallback(); | 94 MaybeModifyCodecForFallback(); |
| 94 cricket::InternalEncoderFactory internal_factory; | 95 cricket::InternalEncoderFactory internal_factory; |
| 95 if (!FindMatchingCodec(internal_factory.supported_codecs(), codec_)) { | 96 if (!FindMatchingCodec(internal_factory.supported_codecs(), codec_)) { |
| 96 LOG(LS_WARNING) | 97 LOG(LS_WARNING) |
| 97 << "Encoder requesting fallback to codec not supported in software."; | 98 << "Encoder requesting fallback to codec not supported in software."; |
| 98 return false; | 99 return false; |
| 99 } | 100 } |
| 100 fallback_encoder_.reset(internal_factory.CreateVideoEncoder(codec_)); | 101 fallback_encoder_.reset(internal_factory.CreateVideoEncoder(codec_)); |
| 101 if (fallback_encoder_->InitEncode(&codec_settings_, number_of_cores_, | 102 if (fallback_encoder_->InitEncode(&codec_settings_, number_of_cores_, |
| 102 max_payload_size_) != | 103 max_payload_size_) != |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 141 |
| 141 // Try to reinit forced software codec if it is in use. | 142 // Try to reinit forced software codec if it is in use. |
| 142 if (TryReInitForcedFallbackEncoder()) { | 143 if (TryReInitForcedFallbackEncoder()) { |
| 143 return WEBRTC_VIDEO_CODEC_OK; | 144 return WEBRTC_VIDEO_CODEC_OK; |
| 144 } | 145 } |
| 145 forced_fallback_.Reset(); | 146 forced_fallback_.Reset(); |
| 146 | 147 |
| 147 int32_t ret = | 148 int32_t ret = |
| 148 encoder_->InitEncode(codec_settings, number_of_cores, max_payload_size); | 149 encoder_->InitEncode(codec_settings, number_of_cores, max_payload_size); |
| 149 if (ret == WEBRTC_VIDEO_CODEC_OK || codec_.name.empty()) { | 150 if (ret == WEBRTC_VIDEO_CODEC_OK || codec_.name.empty()) { |
| 150 if (fallback_encoder_) | 151 if (fallback_encoder_) { |
| 152 LOG(LS_WARNING) |
| 153 << "InitEncode OK, no longer using the software fallback encoder."; |
| 151 fallback_encoder_->Release(); | 154 fallback_encoder_->Release(); |
| 155 } |
| 152 fallback_encoder_.reset(); | 156 fallback_encoder_.reset(); |
| 153 if (callback_) | 157 if (callback_) |
| 154 encoder_->RegisterEncodeCompleteCallback(callback_); | 158 encoder_->RegisterEncodeCompleteCallback(callback_); |
| 155 return ret; | 159 return ret; |
| 156 } | 160 } |
| 157 // Try to instantiate software codec. | 161 // Try to instantiate software codec. |
| 158 if (InitFallbackEncoder()) { | 162 if (InitFallbackEncoder()) { |
| 159 return WEBRTC_VIDEO_CODEC_OK; | 163 return WEBRTC_VIDEO_CODEC_OK; |
| 160 } | 164 } |
| 161 // Software encoder failed, use original return code. | 165 // Software encoder failed, use original return code. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 void VideoEncoderSoftwareFallbackWrapper::MaybeModifyCodecForFallback() { | 364 void VideoEncoderSoftwareFallbackWrapper::MaybeModifyCodecForFallback() { |
| 361 // We have a specific case for H264 ConstrainedBaseline because that is the | 365 // We have a specific case for H264 ConstrainedBaseline because that is the |
| 362 // only supported profile in Sw fallback. | 366 // only supported profile in Sw fallback. |
| 363 if (!cricket::CodecNamesEq(codec_.name.c_str(), cricket::kH264CodecName)) | 367 if (!cricket::CodecNamesEq(codec_.name.c_str(), cricket::kH264CodecName)) |
| 364 return; | 368 return; |
| 365 codec_.SetParam(cricket::kH264FmtpProfileLevelId, | 369 codec_.SetParam(cricket::kH264FmtpProfileLevelId, |
| 366 cricket::kH264ProfileLevelConstrainedBaseline); | 370 cricket::kH264ProfileLevelConstrainedBaseline); |
| 367 } | 371 } |
| 368 | 372 |
| 369 } // namespace webrtc | 373 } // namespace webrtc |
| OLD | NEW |