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 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // | 149 // |
150 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. | 150 // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. |
151 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0; | 151 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0; |
152 | 152 |
153 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } | 153 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; } |
154 virtual void OnDroppedFrame() {} | 154 virtual void OnDroppedFrame() {} |
155 virtual bool SupportsNativeHandle() const { return false; } | 155 virtual bool SupportsNativeHandle() const { return false; } |
156 virtual const char* ImplementationName() const { return "unknown"; } | 156 virtual const char* ImplementationName() const { return "unknown"; } |
157 }; | 157 }; |
158 | 158 |
159 // 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 | |
161 // hardware restrictions, such as max resolution. | |
162 class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder { | |
163 public: | |
164 VideoEncoderSoftwareFallbackWrapper(VideoCodecType codec_type, | |
165 webrtc::VideoEncoder* encoder); | |
166 | |
167 int32_t InitEncode(const VideoCodec* codec_settings, | |
168 int32_t number_of_cores, | |
169 size_t max_payload_size) override; | |
170 | |
171 int32_t RegisterEncodeCompleteCallback( | |
172 EncodedImageCallback* callback) override; | |
173 | |
174 int32_t Release() override; | |
175 int32_t Encode(const VideoFrame& frame, | |
176 const CodecSpecificInfo* codec_specific_info, | |
177 const std::vector<FrameType>* frame_types) override; | |
178 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; | |
179 | |
180 int32_t SetRates(uint32_t bitrate, uint32_t framerate) override; | |
181 void OnDroppedFrame() override; | |
182 bool SupportsNativeHandle() const override; | |
183 | |
184 private: | |
185 bool InitFallbackEncoder(); | |
186 | |
187 // Settings used in the last InitEncode call and used if a dynamic fallback to | |
188 // software is required. | |
189 VideoCodec codec_settings_; | |
190 int32_t number_of_cores_; | |
191 size_t max_payload_size_; | |
192 | |
193 // The last bitrate/framerate set, and a flag for noting they are set. | |
194 bool rates_set_; | |
195 uint32_t bitrate_; | |
196 uint32_t framerate_; | |
197 | |
198 // The last channel parameters set, and a flag for noting they are set. | |
199 bool channel_parameters_set_; | |
200 uint32_t packet_loss_; | |
201 int64_t rtt_; | |
202 | |
203 const EncoderType encoder_type_; | |
204 webrtc::VideoEncoder* const encoder_; | |
205 | |
206 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; | |
207 std::string fallback_implementation_name_; | |
208 EncodedImageCallback* callback_; | |
209 }; | |
210 } // namespace webrtc | 159 } // namespace webrtc |
211 #endif // WEBRTC_VIDEO_ENCODER_H_ | 160 #endif // WEBRTC_VIDEO_ENCODER_H_ |
OLD | NEW |