Chromium Code Reviews

Side by Side Diff: webrtc/video_encoder.h

Issue 2489843002: Revert of Extract bitrate allocation of spatial/temporal layers out of codec impl. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « webrtc/video/vie_encoder_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base/checks.h"
19 #include "webrtc/common_types.h" 18 #include "webrtc/common_types.h"
20 #include "webrtc/typedefs.h" 19 #include "webrtc/typedefs.h"
21 #include "webrtc/video_frame.h" 20 #include "webrtc/video_frame.h"
22 21
23 namespace webrtc { 22 namespace webrtc {
24 23
25 class RTPFragmentationHeader; 24 class RTPFragmentationHeader;
26 // TODO(pbos): Expose these through a public (root) header or change these APIs. 25 // TODO(pbos): Expose these through a public (root) header or change these APIs.
27 struct CodecSpecificInfo; 26 struct CodecSpecificInfo;
28 class VideoCodec; 27 class VideoCodec;
(...skipping 113 matching lines...)
142 // <0 - Errors: WEBRTC_VIDEO_CODEC_ERROR 141 // <0 - Errors: WEBRTC_VIDEO_CODEC_ERROR
143 virtual int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) = 0; 142 virtual int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) = 0;
144 143
145 // Inform the encoder about the new target bit rate. 144 // Inform the encoder about the new target bit rate.
146 // 145 //
147 // Input: 146 // Input:
148 // - bitrate : New target bit rate 147 // - bitrate : New target bit rate
149 // - framerate : The target frame rate 148 // - framerate : The target frame rate
150 // 149 //
151 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. 150 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
152 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) { 151 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0;
153 RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated.";
154 return -1;
155 }
156
157 // Default fallback: Just use the sum of bitrates as the single target rate.
158 // TODO(sprang): Remove this default implementation when we remove SetRates().
159 virtual int32_t SetRateAllocation(const BitrateAllocation& allocation,
160 uint32_t framerate) {
161 return SetRates(allocation.get_sum_kbps(), framerate);
162 }
163 152
164 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } 153 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; }
165 virtual void OnDroppedFrame() {} 154 virtual void OnDroppedFrame() {}
166 virtual bool SupportsNativeHandle() const { return false; } 155 virtual bool SupportsNativeHandle() const { return false; }
167 virtual const char* ImplementationName() const { return "unknown"; } 156 virtual const char* ImplementationName() const { return "unknown"; }
168 }; 157 };
169 158
170 // Class used to wrap external VideoEncoders to provide a fallback option on 159 // Class used to wrap external VideoEncoders to provide a fallback option on
171 // software encoding when a hardware encoder fails to encode a stream due to 160 // software encoding when a hardware encoder fails to encode a stream due to
172 // hardware restrictions, such as max resolution. 161 // hardware restrictions, such as max resolution.
173 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder { 162 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder {
174 public: 163 public:
175 VideoEncoderSoftwareFallbackWrapper(VideoCodecType codec_type, 164 VideoEncoderSoftwareFallbackWrapper(VideoCodecType codec_type,
176 webrtc::VideoEncoder* encoder); 165 webrtc::VideoEncoder* encoder);
177 166
178 int32_t InitEncode(const VideoCodec* codec_settings, 167 int32_t InitEncode(const VideoCodec* codec_settings,
179 int32_t number_of_cores, 168 int32_t number_of_cores,
180 size_t max_payload_size) override; 169 size_t max_payload_size) override;
181 170
182 int32_t RegisterEncodeCompleteCallback( 171 int32_t RegisterEncodeCompleteCallback(
183 EncodedImageCallback* callback) override; 172 EncodedImageCallback* callback) override;
184 173
185 int32_t Release() override; 174 int32_t Release() override;
186 int32_t Encode(const VideoFrame& frame, 175 int32_t Encode(const VideoFrame& frame,
187 const CodecSpecificInfo* codec_specific_info, 176 const CodecSpecificInfo* codec_specific_info,
188 const std::vector<FrameType>* frame_types) override; 177 const std::vector<FrameType>* frame_types) override;
189 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; 178 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
190 int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation, 179
191 uint32_t framerate) override; 180 int32_t SetRates(uint32_t bitrate, uint32_t framerate) override;
192 void OnDroppedFrame() override; 181 void OnDroppedFrame() override;
193 bool SupportsNativeHandle() const override; 182 bool SupportsNativeHandle() const override;
194 183
195 private: 184 private:
196 bool InitFallbackEncoder(); 185 bool InitFallbackEncoder();
197 186
198 // Settings used in the last InitEncode call and used if a dynamic fallback to 187 // Settings used in the last InitEncode call and used if a dynamic fallback to
199 // software is required. 188 // software is required.
200 VideoCodec codec_settings_; 189 VideoCodec codec_settings_;
201 int32_t number_of_cores_; 190 int32_t number_of_cores_;
202 size_t max_payload_size_; 191 size_t max_payload_size_;
203 192
204 // The last bitrate/framerate set, and a flag for noting they are set. 193 // The last bitrate/framerate set, and a flag for noting they are set.
205 bool rates_set_; 194 bool rates_set_;
206 BitrateAllocation bitrate_allocation_; 195 uint32_t bitrate_;
207 uint32_t framerate_; 196 uint32_t framerate_;
208 197
209 // The last channel parameters set, and a flag for noting they are set. 198 // The last channel parameters set, and a flag for noting they are set.
210 bool channel_parameters_set_; 199 bool channel_parameters_set_;
211 uint32_t packet_loss_; 200 uint32_t packet_loss_;
212 int64_t rtt_; 201 int64_t rtt_;
213 202
214 const EncoderType encoder_type_; 203 const EncoderType encoder_type_;
215 webrtc::VideoEncoder* const encoder_; 204 webrtc::VideoEncoder* const encoder_;
216 205
217 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; 206 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_;
218 std::string fallback_implementation_name_; 207 std::string fallback_implementation_name_;
219 EncodedImageCallback* callback_; 208 EncodedImageCallback* callback_;
220 }; 209 };
221 } // namespace webrtc 210 } // namespace webrtc
222 #endif // WEBRTC_VIDEO_ENCODER_H_ 211 #endif // WEBRTC_VIDEO_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine