mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "api/video_codecs/video_encoder.h" |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 12 | |
| 13 | namespace webrtc { |
| 14 | |
| 15 | // TODO(mflodman): Add default complexity for VP9 and VP9. |
| 16 | VideoCodecVP8 VideoEncoder::GetDefaultVp8Settings() { |
| 17 | VideoCodecVP8 vp8_settings; |
| 18 | memset(&vp8_settings, 0, sizeof(vp8_settings)); |
| 19 | |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 20 | vp8_settings.numberOfTemporalLayers = 1; |
| 21 | vp8_settings.denoisingOn = true; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 22 | vp8_settings.automaticResizeOn = false; |
| 23 | vp8_settings.frameDroppingOn = true; |
| 24 | vp8_settings.keyFrameInterval = 3000; |
| 25 | |
| 26 | return vp8_settings; |
| 27 | } |
| 28 | |
| 29 | VideoCodecVP9 VideoEncoder::GetDefaultVp9Settings() { |
| 30 | VideoCodecVP9 vp9_settings; |
| 31 | memset(&vp9_settings, 0, sizeof(vp9_settings)); |
| 32 | |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 33 | vp9_settings.numberOfTemporalLayers = 1; |
| 34 | vp9_settings.denoisingOn = true; |
| 35 | vp9_settings.frameDroppingOn = true; |
| 36 | vp9_settings.keyFrameInterval = 3000; |
| 37 | vp9_settings.adaptiveQpMode = true; |
| 38 | vp9_settings.automaticResizeOn = true; |
| 39 | vp9_settings.numberOfSpatialLayers = 1; |
| 40 | vp9_settings.flexibleMode = false; |
Sergey Silkin | 6a8f30e | 2018-04-26 11:03:49 +0200 | [diff] [blame^] | 41 | vp9_settings.interLayerPred = InterLayerPredMode::kOn; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 42 | |
| 43 | return vp9_settings; |
| 44 | } |
| 45 | |
| 46 | VideoCodecH264 VideoEncoder::GetDefaultH264Settings() { |
| 47 | VideoCodecH264 h264_settings; |
| 48 | memset(&h264_settings, 0, sizeof(h264_settings)); |
| 49 | |
| 50 | h264_settings.frameDroppingOn = true; |
| 51 | h264_settings.keyFrameInterval = 3000; |
| 52 | h264_settings.spsData = nullptr; |
| 53 | h264_settings.spsLen = 0; |
| 54 | h264_settings.ppsData = nullptr; |
| 55 | h264_settings.ppsLen = 0; |
| 56 | h264_settings.profile = H264::kProfileConstrainedBaseline; |
| 57 | |
| 58 | return h264_settings; |
| 59 | } |
| 60 | |
Niels Möller | 225c787 | 2018-02-22 15:03:53 +0100 | [diff] [blame] | 61 | VideoEncoder::ScalingSettings::ScalingSettings() = default; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 62 | |
Niels Möller | 225c787 | 2018-02-22 15:03:53 +0100 | [diff] [blame] | 63 | VideoEncoder::ScalingSettings::ScalingSettings(KOff) : ScalingSettings() {} |
| 64 | |
| 65 | VideoEncoder::ScalingSettings::ScalingSettings(int low, int high) |
| 66 | : thresholds(QpThresholds(low, high)) {} |
| 67 | |
| 68 | VideoEncoder::ScalingSettings::ScalingSettings(int low, |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 69 | int high, |
| 70 | int min_pixels) |
Niels Möller | 225c787 | 2018-02-22 15:03:53 +0100 | [diff] [blame] | 71 | : thresholds(QpThresholds(low, high)), min_pixels_per_frame(min_pixels) {} |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 72 | |
Niels Möller | 225c787 | 2018-02-22 15:03:53 +0100 | [diff] [blame] | 73 | VideoEncoder::ScalingSettings::ScalingSettings(const ScalingSettings&) = |
| 74 | default; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 75 | |
| 76 | VideoEncoder::ScalingSettings::~ScalingSettings() {} |
| 77 | |
Niels Möller | 225c787 | 2018-02-22 15:03:53 +0100 | [diff] [blame] | 78 | // static |
| 79 | constexpr VideoEncoder::ScalingSettings::KOff |
| 80 | VideoEncoder::ScalingSettings::kOff; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 81 | |
| 82 | int32_t VideoEncoder::SetRates(uint32_t bitrate, uint32_t framerate) { |
| 83 | RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated."; |
| 84 | return -1; |
| 85 | } |
| 86 | |
| 87 | int32_t VideoEncoder::SetRateAllocation( |
Erik Språng | 566124a | 2018-04-23 12:32:22 +0200 | [diff] [blame] | 88 | const VideoBitrateAllocation& allocation, |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 89 | uint32_t framerate) { |
| 90 | return SetRates(allocation.get_sum_kbps(), framerate); |
| 91 | } |
| 92 | |
| 93 | VideoEncoder::ScalingSettings VideoEncoder::GetScalingSettings() const { |
Niels Möller | 225c787 | 2018-02-22 15:03:53 +0100 | [diff] [blame] | 94 | return ScalingSettings::kOff; |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 95 | } |
| 96 | |
mflodman | 351424e | 2017-08-10 02:43:14 -0700 | [diff] [blame] | 97 | bool VideoEncoder::SupportsNativeHandle() const { |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | const char* VideoEncoder::ImplementationName() const { |
| 102 | return "unknown"; |
| 103 | } |
| 104 | } // namespace webrtc |