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