blob: fd8f1425f49e97d30f660f214e88f31f981926b4 [file] [log] [blame]
mflodman351424e2017-08-10 02:43:14 -07001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#include "api/video_codecs/video_encoder.h"
mflodman351424e2017-08-10 02:43:14 -070012
13namespace webrtc {
14
15// TODO(mflodman): Add default complexity for VP9 and VP9.
16VideoCodecVP8 VideoEncoder::GetDefaultVp8Settings() {
17 VideoCodecVP8 vp8_settings;
18 memset(&vp8_settings, 0, sizeof(vp8_settings));
19
mflodman351424e2017-08-10 02:43:14 -070020 vp8_settings.numberOfTemporalLayers = 1;
21 vp8_settings.denoisingOn = true;
mflodman351424e2017-08-10 02:43:14 -070022 vp8_settings.automaticResizeOn = false;
23 vp8_settings.frameDroppingOn = true;
24 vp8_settings.keyFrameInterval = 3000;
25
26 return vp8_settings;
27}
28
29VideoCodecVP9 VideoEncoder::GetDefaultVp9Settings() {
30 VideoCodecVP9 vp9_settings;
31 memset(&vp9_settings, 0, sizeof(vp9_settings));
32
mflodman351424e2017-08-10 02:43:14 -070033 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;
41
42 return vp9_settings;
43}
44
45VideoCodecH264 VideoEncoder::GetDefaultH264Settings() {
46 VideoCodecH264 h264_settings;
47 memset(&h264_settings, 0, sizeof(h264_settings));
48
49 h264_settings.frameDroppingOn = true;
50 h264_settings.keyFrameInterval = 3000;
51 h264_settings.spsData = nullptr;
52 h264_settings.spsLen = 0;
53 h264_settings.ppsData = nullptr;
54 h264_settings.ppsLen = 0;
55 h264_settings.profile = H264::kProfileConstrainedBaseline;
56
57 return h264_settings;
58}
59
Niels Möller225c7872018-02-22 15:03:53 +010060VideoEncoder::ScalingSettings::ScalingSettings() = default;
mflodman351424e2017-08-10 02:43:14 -070061
Niels Möller225c7872018-02-22 15:03:53 +010062VideoEncoder::ScalingSettings::ScalingSettings(KOff) : ScalingSettings() {}
63
64VideoEncoder::ScalingSettings::ScalingSettings(int low, int high)
65 : thresholds(QpThresholds(low, high)) {}
66
67VideoEncoder::ScalingSettings::ScalingSettings(int low,
asapersson142fcc92017-08-17 08:58:54 -070068 int high,
69 int min_pixels)
Niels Möller225c7872018-02-22 15:03:53 +010070 : thresholds(QpThresholds(low, high)), min_pixels_per_frame(min_pixels) {}
asapersson142fcc92017-08-17 08:58:54 -070071
Niels Möller225c7872018-02-22 15:03:53 +010072VideoEncoder::ScalingSettings::ScalingSettings(const ScalingSettings&) =
73 default;
mflodman351424e2017-08-10 02:43:14 -070074
75VideoEncoder::ScalingSettings::~ScalingSettings() {}
76
Niels Möller225c7872018-02-22 15:03:53 +010077// static
78constexpr VideoEncoder::ScalingSettings::KOff
79 VideoEncoder::ScalingSettings::kOff;
mflodman351424e2017-08-10 02:43:14 -070080
81int32_t VideoEncoder::SetRates(uint32_t bitrate, uint32_t framerate) {
82 RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated.";
83 return -1;
84}
85
86int32_t VideoEncoder::SetRateAllocation(
Erik Språng566124a2018-04-23 12:32:22 +020087 const VideoBitrateAllocation& allocation,
mflodman351424e2017-08-10 02:43:14 -070088 uint32_t framerate) {
89 return SetRates(allocation.get_sum_kbps(), framerate);
90}
91
92VideoEncoder::ScalingSettings VideoEncoder::GetScalingSettings() const {
Niels Möller225c7872018-02-22 15:03:53 +010093 return ScalingSettings::kOff;
mflodman351424e2017-08-10 02:43:14 -070094}
95
mflodman351424e2017-08-10 02:43:14 -070096bool VideoEncoder::SupportsNativeHandle() const {
97 return false;
98}
99
100const char* VideoEncoder::ImplementationName() const {
101 return "unknown";
102}
103} // namespace webrtc