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 | |
| 11 | #include "webrtc/api/video_codecs/video_encoder.h" |
| 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 | |
| 20 | vp8_settings.resilience = kResilientStream; |
| 21 | vp8_settings.numberOfTemporalLayers = 1; |
| 22 | vp8_settings.denoisingOn = true; |
| 23 | vp8_settings.errorConcealmentOn = false; |
| 24 | vp8_settings.automaticResizeOn = false; |
| 25 | vp8_settings.frameDroppingOn = true; |
| 26 | vp8_settings.keyFrameInterval = 3000; |
| 27 | |
| 28 | return vp8_settings; |
| 29 | } |
| 30 | |
| 31 | VideoCodecVP9 VideoEncoder::GetDefaultVp9Settings() { |
| 32 | VideoCodecVP9 vp9_settings; |
| 33 | memset(&vp9_settings, 0, sizeof(vp9_settings)); |
| 34 | |
| 35 | vp9_settings.resilienceOn = true; |
| 36 | vp9_settings.numberOfTemporalLayers = 1; |
| 37 | vp9_settings.denoisingOn = true; |
| 38 | vp9_settings.frameDroppingOn = true; |
| 39 | vp9_settings.keyFrameInterval = 3000; |
| 40 | vp9_settings.adaptiveQpMode = true; |
| 41 | vp9_settings.automaticResizeOn = true; |
| 42 | vp9_settings.numberOfSpatialLayers = 1; |
| 43 | vp9_settings.flexibleMode = false; |
| 44 | |
| 45 | return vp9_settings; |
| 46 | } |
| 47 | |
| 48 | VideoCodecH264 VideoEncoder::GetDefaultH264Settings() { |
| 49 | VideoCodecH264 h264_settings; |
| 50 | memset(&h264_settings, 0, sizeof(h264_settings)); |
| 51 | |
| 52 | h264_settings.frameDroppingOn = true; |
| 53 | h264_settings.keyFrameInterval = 3000; |
| 54 | h264_settings.spsData = nullptr; |
| 55 | h264_settings.spsLen = 0; |
| 56 | h264_settings.ppsData = nullptr; |
| 57 | h264_settings.ppsLen = 0; |
| 58 | h264_settings.profile = H264::kProfileConstrainedBaseline; |
| 59 | |
| 60 | return h264_settings; |
| 61 | } |
| 62 | |
| 63 | VideoEncoder::ScalingSettings::ScalingSettings(bool on, int low, int high) |
| 64 | : enabled(on), |
| 65 | thresholds(rtc::Optional<QpThresholds>(QpThresholds(low, high))) {} |
| 66 | |
| 67 | VideoEncoder::ScalingSettings::ScalingSettings(bool on) : enabled(on) {} |
| 68 | |
| 69 | VideoEncoder::ScalingSettings::~ScalingSettings() {} |
| 70 | |
| 71 | |
| 72 | int32_t VideoEncoder::SetRates(uint32_t bitrate, uint32_t framerate) { |
| 73 | RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated."; |
| 74 | return -1; |
| 75 | } |
| 76 | |
| 77 | int32_t VideoEncoder::SetRateAllocation( |
| 78 | const BitrateAllocation& allocation, |
| 79 | uint32_t framerate) { |
| 80 | return SetRates(allocation.get_sum_kbps(), framerate); |
| 81 | } |
| 82 | |
| 83 | VideoEncoder::ScalingSettings VideoEncoder::GetScalingSettings() const { |
| 84 | return ScalingSettings(false); |
| 85 | } |
| 86 | |
| 87 | int32_t VideoEncoder::SetPeriodicKeyFrames(bool enable) { |
| 88 | return -1; |
| 89 | } |
| 90 | |
| 91 | bool VideoEncoder::SupportsNativeHandle() const { |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | const char* VideoEncoder::ImplementationName() const { |
| 96 | return "unknown"; |
| 97 | } |
| 98 | } // namespace webrtc |