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

Unified Diff: webrtc/media/engine/videoencodersoftwarefallbackwrapper.h

Issue 2988963002: Add support for a forced software encoder fallback. (Closed)
Patch Set: fix comment Created 3 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/media/engine/videoencodersoftwarefallbackwrapper.h
diff --git a/webrtc/media/engine/videoencodersoftwarefallbackwrapper.h b/webrtc/media/engine/videoencodersoftwarefallbackwrapper.h
index 61c1a11c8d32e798b043c033c3cbecde17b91df8..ab43986ccd0e5b7574c2b29902848bd8537cd42f 100644
--- a/webrtc/media/engine/videoencodersoftwarefallbackwrapper.h
+++ b/webrtc/media/engine/videoencodersoftwarefallbackwrapper.h
@@ -49,6 +49,35 @@ 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 {
mflodman 2017/08/15 08:00:04 My preference, so feel free to ignore. I prefer t
+ return bitrate_kbps >= high_kbps;
+ }
+ 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 +100,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

Powered by Google App Engine
This is Rietveld 408576698