Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: webrtc/video_encoder.h

Issue 2398963003: Move usage of QualityScaler to ViEEncoder. (Closed)
Patch Set: Fix flaky test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
22 #include "webrtc/modules/video_coding/utility/quality_scaler.h"
21 23
22 namespace webrtc { 24 namespace webrtc {
23 25
24 class RTPFragmentationHeader; 26 class RTPFragmentationHeader;
25 // TODO(pbos): Expose these through a public (root) header or change these APIs. 27 // TODO(pbos): Expose these through a public (root) header or change these APIs.
26 struct CodecSpecificInfo; 28 struct CodecSpecificInfo;
27 class VideoCodec; 29 class VideoCodec;
28 30
29 class EncodedImageCallback { 31 class EncodedImageCallback {
30 public: 32 public:
(...skipping 30 matching lines...) Expand all
61 }; 63 };
62 64
63 class VideoEncoder { 65 class VideoEncoder {
64 public: 66 public:
65 enum EncoderType { 67 enum EncoderType {
66 kH264, 68 kH264,
67 kVp8, 69 kVp8,
68 kVp9, 70 kVp9,
69 kUnsupportedCodec, 71 kUnsupportedCodec,
70 }; 72 };
71
72 static VideoEncoder* Create(EncoderType codec_type); 73 static VideoEncoder* Create(EncoderType codec_type);
73 // Returns true if this type of encoder can be created using 74 // Returns true if this type of encoder can be created using
74 // VideoEncoder::Create. 75 // VideoEncoder::Create.
75 static bool IsSupportedSoftware(EncoderType codec_type); 76 static bool IsSupportedSoftware(EncoderType codec_type);
76 static EncoderType CodecToEncoderType(VideoCodecType codec_type); 77 static EncoderType CodecToEncoderType(VideoCodecType codec_type);
77 78
78 static VideoCodecVP8 GetDefaultVp8Settings(); 79 static VideoCodecVP8 GetDefaultVp8Settings();
79 static VideoCodecVP9 GetDefaultVp9Settings(); 80 static VideoCodecVP9 GetDefaultVp9Settings();
80 static VideoCodecH264 GetDefaultH264Settings(); 81 static VideoCodecH264 GetDefaultH264Settings();
81 82
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 144
144 // Inform the encoder about the new target bit rate. 145 // Inform the encoder about the new target bit rate.
145 // 146 //
146 // Input: 147 // Input:
147 // - bitrate : New target bit rate 148 // - bitrate : New target bit rate
148 // - framerate : The target frame rate 149 // - framerate : The target frame rate
149 // 150 //
150 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. 151 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
151 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0; 152 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0;
152 153
154 // Any encoder implementation wishing to use the WebRTC provided
155 // quality scaler must implement this method.
156 virtual QualityScaler::Settings GetQPThresholds() const {
157 return QualityScaler::Settings(false);
158 }
159
153 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } 160 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; }
154 virtual void OnDroppedFrame() {} 161 virtual void OnDroppedFrame() {}
155 virtual bool SupportsNativeHandle() const { return false; } 162 virtual bool SupportsNativeHandle() const { return false; }
156 virtual const char* ImplementationName() const { return "unknown"; } 163 virtual const char* ImplementationName() const { return "unknown"; }
157 }; 164 };
158 165
159 // Class used to wrap external VideoEncoders to provide a fallback option on 166 // Class used to wrap external VideoEncoders to provide a fallback option on
160 // software encoding when a hardware encoder fails to encode a stream due to 167 // software encoding when a hardware encoder fails to encode a stream due to
161 // hardware restrictions, such as max resolution. 168 // hardware restrictions, such as max resolution.
162 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder { 169 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder {
(...skipping 10 matching lines...) Expand all
173 180
174 int32_t Release() override; 181 int32_t Release() override;
175 int32_t Encode(const VideoFrame& frame, 182 int32_t Encode(const VideoFrame& frame,
176 const CodecSpecificInfo* codec_specific_info, 183 const CodecSpecificInfo* codec_specific_info,
177 const std::vector<FrameType>* frame_types) override; 184 const std::vector<FrameType>* frame_types) override;
178 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; 185 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
179 186
180 int32_t SetRates(uint32_t bitrate, uint32_t framerate) override; 187 int32_t SetRates(uint32_t bitrate, uint32_t framerate) override;
181 void OnDroppedFrame() override; 188 void OnDroppedFrame() override;
182 bool SupportsNativeHandle() const override; 189 bool SupportsNativeHandle() const override;
190 QualityScaler::Settings GetQPThresholds() const override;
183 191
184 private: 192 private:
185 bool InitFallbackEncoder(); 193 bool InitFallbackEncoder();
186 194
187 // Settings used in the last InitEncode call and used if a dynamic fallback to 195 // Settings used in the last InitEncode call and used if a dynamic fallback to
188 // software is required. 196 // software is required.
189 VideoCodec codec_settings_; 197 VideoCodec codec_settings_;
190 int32_t number_of_cores_; 198 int32_t number_of_cores_;
191 size_t max_payload_size_; 199 size_t max_payload_size_;
192 200
193 // The last bitrate/framerate set, and a flag for noting they are set. 201 // The last bitrate/framerate set, and a flag for noting they are set.
194 bool rates_set_; 202 bool rates_set_;
195 uint32_t bitrate_; 203 uint32_t bitrate_;
196 uint32_t framerate_; 204 uint32_t framerate_;
197 205
198 // The last channel parameters set, and a flag for noting they are set. 206 // The last channel parameters set, and a flag for noting they are set.
199 bool channel_parameters_set_; 207 bool channel_parameters_set_;
200 uint32_t packet_loss_; 208 uint32_t packet_loss_;
201 int64_t rtt_; 209 int64_t rtt_;
202 210
203 const EncoderType encoder_type_; 211 const EncoderType encoder_type_;
204 webrtc::VideoEncoder* const encoder_; 212 webrtc::VideoEncoder* const encoder_;
205 213
206 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; 214 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_;
207 std::string fallback_implementation_name_; 215 std::string fallback_implementation_name_;
208 EncodedImageCallback* callback_; 216 EncodedImageCallback* callback_;
209 }; 217 };
210 } // namespace webrtc 218 } // namespace webrtc
211 #endif // WEBRTC_VIDEO_ENCODER_H_ 219 #endif // WEBRTC_VIDEO_ENCODER_H_
OLDNEW
« webrtc/video/vie_encoder.cc ('K') | « webrtc/video/vie_encoder_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698