| 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 |
| 11 #include "webrtc/media/engine/videoencodersoftwarefallbackwrapper.h" | 11 #include "webrtc/media/engine/videoencodersoftwarefallbackwrapper.h" |
| 12 | 12 |
| 13 #include "webrtc/media/base/h264_profile_level_id.h" |
| 13 #include "webrtc/media/engine/internalencoderfactory.h" | 14 #include "webrtc/media/engine/internalencoderfactory.h" |
| 14 #include "webrtc/modules/video_coding/include/video_error_codes.h" | 15 #include "webrtc/modules/video_coding/include/video_error_codes.h" |
| 15 #include "webrtc/rtc_base/checks.h" | 16 #include "webrtc/rtc_base/checks.h" |
| 16 #include "webrtc/rtc_base/logging.h" | 17 #include "webrtc/rtc_base/logging.h" |
| 17 #include "webrtc/rtc_base/timeutils.h" | 18 #include "webrtc/rtc_base/timeutils.h" |
| 18 #include "webrtc/system_wrappers/include/field_trial.h" | 19 #include "webrtc/system_wrappers/include/field_trial.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 namespace { | 22 namespace { |
| 22 const char kVp8ForceFallbackEncoderFieldTrial[] = | 23 const char kVp8ForceFallbackEncoderFieldTrial[] = |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 callback_(nullptr), | 83 callback_(nullptr), |
| 83 forced_fallback_possible_(EnableForcedFallback(codec)) { | 84 forced_fallback_possible_(EnableForcedFallback(codec)) { |
| 84 if (forced_fallback_possible_) { | 85 if (forced_fallback_possible_) { |
| 85 GetForcedFallbackParamsFromFieldTrialGroup(&forced_fallback_.low_kbps, | 86 GetForcedFallbackParamsFromFieldTrialGroup(&forced_fallback_.low_kbps, |
| 86 &forced_fallback_.high_kbps, | 87 &forced_fallback_.high_kbps, |
| 87 &forced_fallback_.min_low_ms); | 88 &forced_fallback_.min_low_ms); |
| 88 } | 89 } |
| 89 } | 90 } |
| 90 | 91 |
| 91 bool VideoEncoderSoftwareFallbackWrapper::InitFallbackEncoder() { | 92 bool VideoEncoderSoftwareFallbackWrapper::InitFallbackEncoder() { |
| 93 MaybeModifyCodecForFallback(); |
| 92 cricket::InternalEncoderFactory internal_factory; | 94 cricket::InternalEncoderFactory internal_factory; |
| 93 if (!FindMatchingCodec(internal_factory.supported_codecs(), codec_)) { | 95 if (!FindMatchingCodec(internal_factory.supported_codecs(), codec_)) { |
| 94 LOG(LS_WARNING) | 96 LOG(LS_WARNING) |
| 95 << "Encoder requesting fallback to codec not supported in software."; | 97 << "Encoder requesting fallback to codec not supported in software."; |
| 96 return false; | 98 return false; |
| 97 } | 99 } |
| 98 fallback_encoder_.reset(internal_factory.CreateVideoEncoder(codec_)); | 100 fallback_encoder_.reset(internal_factory.CreateVideoEncoder(codec_)); |
| 99 if (fallback_encoder_->InitEncode(&codec_settings_, number_of_cores_, | 101 if (fallback_encoder_->InitEncode(&codec_settings_, number_of_cores_, |
| 100 max_payload_size_) != | 102 max_payload_size_) != |
| 101 WEBRTC_VIDEO_CODEC_OK) { | 103 WEBRTC_VIDEO_CODEC_OK) { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 return false; | 350 return false; |
| 349 } | 351 } |
| 350 | 352 |
| 351 bool VideoEncoderSoftwareFallbackWrapper::ForcedFallbackParams::ShouldStop( | 353 bool VideoEncoderSoftwareFallbackWrapper::ForcedFallbackParams::ShouldStop( |
| 352 uint32_t bitrate_kbps, | 354 uint32_t bitrate_kbps, |
| 353 const VideoCodec& codec) const { | 355 const VideoCodec& codec) const { |
| 354 return bitrate_kbps >= high_kbps && | 356 return bitrate_kbps >= high_kbps && |
| 355 (codec.width * codec.height >= kMinPixelsStop); | 357 (codec.width * codec.height >= kMinPixelsStop); |
| 356 } | 358 } |
| 357 | 359 |
| 360 void VideoEncoderSoftwareFallbackWrapper::MaybeModifyCodecForFallback() { |
| 361 // We have a specific case for H264 ConstrainedBaseline because that is the |
| 362 // only supported profile in Sw fallback. |
| 363 if (!cricket::CodecNamesEq(codec_.name.c_str(), cricket::kH264CodecName)) |
| 364 return; |
| 365 codec_.SetParam(cricket::kH264FmtpProfileLevelId, |
| 366 cricket::kH264ProfileLevelConstrainedBaseline); |
| 367 } |
| 368 |
| 358 } // namespace webrtc | 369 } // namespace webrtc |
| OLD | NEW |