OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 #ifndef WEBRTC_VIDEO_ENCODER_H_ | 11 #ifndef WEBRTC_VIDEO_ENCODER_H_ |
12 #define WEBRTC_VIDEO_ENCODER_H_ | 12 #define WEBRTC_VIDEO_ENCODER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/common_types.h" | 18 #include "webrtc/common_types.h" |
19 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
20 #include "webrtc/video_frame.h" | 20 #include "webrtc/video_frame.h" |
| 21 #include "webrtc/base/optional.h" |
21 | 22 |
22 namespace webrtc { | 23 namespace webrtc { |
23 | 24 |
24 class RTPFragmentationHeader; | 25 class RTPFragmentationHeader; |
25 // TODO(pbos): Expose these through a public (root) header or change these APIs. | 26 // TODO(pbos): Expose these through a public (root) header or change these APIs. |
26 struct CodecSpecificInfo; | 27 struct CodecSpecificInfo; |
27 struct VideoCodec; | 28 struct VideoCodec; |
28 | 29 |
29 class EncodedImageCallback { | 30 class EncodedImageCallback { |
30 public: | 31 public: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 }; | 75 }; |
75 | 76 |
76 class VideoEncoder { | 77 class VideoEncoder { |
77 public: | 78 public: |
78 enum EncoderType { | 79 enum EncoderType { |
79 kH264, | 80 kH264, |
80 kVp8, | 81 kVp8, |
81 kVp9, | 82 kVp9, |
82 kUnsupportedCodec, | 83 kUnsupportedCodec, |
83 }; | 84 }; |
| 85 typedef std::pair<int, int> QPThresholds; |
84 | 86 |
85 static VideoEncoder* Create(EncoderType codec_type); | 87 static VideoEncoder* Create(EncoderType codec_type); |
86 | 88 |
87 static VideoCodecVP8 GetDefaultVp8Settings(); | 89 static VideoCodecVP8 GetDefaultVp8Settings(); |
88 static VideoCodecVP9 GetDefaultVp9Settings(); | 90 static VideoCodecVP9 GetDefaultVp9Settings(); |
89 static VideoCodecH264 GetDefaultH264Settings(); | 91 static VideoCodecH264 GetDefaultH264Settings(); |
90 | 92 |
91 virtual ~VideoEncoder() {} | 93 virtual ~VideoEncoder() {} |
92 | 94 |
93 // Initialize the encoder with the information from the codecSettings | 95 // Initialize the encoder with the information from the codecSettings |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 154 |
153 // Inform the encoder about the new target bit rate. | 155 // Inform the encoder about the new target bit rate. |
154 // | 156 // |
155 // Input: | 157 // Input: |
156 // - bitrate : New target bit rate | 158 // - bitrate : New target bit rate |
157 // - framerate : The target frame rate | 159 // - framerate : The target frame rate |
158 // | 160 // |
159 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. | 161 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. |
160 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0; | 162 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0; |
161 | 163 |
| 164 // If a specific set of thresholds are desired for quality scaling |
| 165 // an encoder implementation can override this method. |
| 166 virtual rtc::Optional<QPThresholds> GetQPThresholds() { |
| 167 return rtc::Optional<QPThresholds>(); |
| 168 } |
| 169 |
162 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } | 170 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } |
163 virtual void OnDroppedFrame() {} | 171 virtual void OnDroppedFrame() {} |
164 virtual bool SupportsNativeHandle() const { return false; } | 172 virtual bool SupportsNativeHandle() const { return false; } |
165 virtual const char* ImplementationName() const { return "unknown"; } | 173 virtual const char* ImplementationName() const { return "unknown"; } |
166 }; | 174 }; |
167 | 175 |
168 // Class used to wrap external VideoEncoders to provide a fallback option on | 176 // Class used to wrap external VideoEncoders to provide a fallback option on |
169 // software encoding when a hardware encoder fails to encode a stream due to | 177 // software encoding when a hardware encoder fails to encode a stream due to |
170 // hardware restrictions, such as max resolution. | 178 // hardware restrictions, such as max resolution. |
171 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder { | 179 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 219 |
212 const EncoderType encoder_type_; | 220 const EncoderType encoder_type_; |
213 webrtc::VideoEncoder* const encoder_; | 221 webrtc::VideoEncoder* const encoder_; |
214 | 222 |
215 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; | 223 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; |
216 std::string fallback_implementation_name_; | 224 std::string fallback_implementation_name_; |
217 EncodedImageCallback* callback_; | 225 EncodedImageCallback* callback_; |
218 }; | 226 }; |
219 } // namespace webrtc | 227 } // namespace webrtc |
220 #endif // WEBRTC_VIDEO_ENCODER_H_ | 228 #endif // WEBRTC_VIDEO_ENCODER_H_ |
OLD | NEW |