Add support for a forced software encoder fallback.
Make it possible to switch from VP8 HW -> VP8 SW -> VP8 HW depending on bitrate and resolution. BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/2988963002 Cr-Commit-Position: refs/heads/master@{#19362}
This commit is contained in:
@ -49,6 +49,33 @@ class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder {
|
||||
private:
|
||||
bool InitFallbackEncoder();
|
||||
|
||||
// If |forced_fallback_possible_| is true:
|
||||
// The forced fallback is requested if the target bitrate is below |low_kbps|
|
||||
// for more than |min_low_ms| and the input video resolution is not larger
|
||||
// than |kMaxPixels|.
|
||||
// If the bitrate is above |high_kbps|, the forced fallback is requested to
|
||||
// immediately be stopped.
|
||||
class ForcedFallbackParams {
|
||||
public:
|
||||
bool ShouldStart(uint32_t bitrate_kbps, const VideoCodec& codec);
|
||||
bool ShouldStop(uint32_t bitrate_kbps) const;
|
||||
void Reset() { start_ms.reset(); }
|
||||
bool IsValid(const VideoCodec& codec) const {
|
||||
return codec.width * codec.height <= kMaxPixels;
|
||||
}
|
||||
rtc::Optional<int64_t> start_ms; // Set when bitrate is below |low_kbps|.
|
||||
uint32_t low_kbps = 100;
|
||||
uint32_t high_kbps = 150;
|
||||
int64_t min_low_ms = 10000;
|
||||
const int kMaxPixels = 320 * 240;
|
||||
};
|
||||
|
||||
bool RequestForcedFallback();
|
||||
bool TryReleaseForcedFallbackEncoder();
|
||||
bool TryReInitForcedFallbackEncoder();
|
||||
void ValidateSettingsForForcedFallback();
|
||||
bool IsForcedFallbackActive() const;
|
||||
|
||||
// Settings used in the last InitEncode call and used if a dynamic fallback to
|
||||
// software is required.
|
||||
VideoCodec codec_settings_;
|
||||
@ -71,6 +98,9 @@ class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder {
|
||||
std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_;
|
||||
std::string fallback_implementation_name_;
|
||||
EncodedImageCallback* callback_;
|
||||
|
||||
bool forced_fallback_possible_;
|
||||
ForcedFallbackParams forced_fallback_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user