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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override; 42 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
43 int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation, 43 int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation,
44 uint32_t framerate) override; 44 uint32_t framerate) override;
45 bool SupportsNativeHandle() const override; 45 bool SupportsNativeHandle() const override;
46 ScalingSettings GetScalingSettings() const override; 46 ScalingSettings GetScalingSettings() const override;
47 const char *ImplementationName() const override; 47 const char *ImplementationName() const override;
48 48
49 private: 49 private:
50 bool InitFallbackEncoder(); 50 bool InitFallbackEncoder();
51 51
52 // If |forced_fallback_possible_| is true:
53 // The forced fallback is requested if the target bitrate is below |low_kbps|
54 // for more than |min_low_ms| and the input video resolution is not larger
55 // than |kMaxPixels|.
56 // If the bitrate is above |high_kbps|, the forced fallback is requested to
57 // immediately be stopped.
58 class ForcedFallbackParams {
59 public:
60 bool ShouldStart(uint32_t bitrate_kbps, const VideoCodec& codec);
61 bool ShouldStop(uint32_t bitrate_kbps) const {
mflodman 2017/08/15 08:00:04 My preference, so feel free to ignore. I prefer t
62 return bitrate_kbps >= high_kbps;
63 }
64 void Reset() { start_ms.reset(); }
65 bool IsValid(const VideoCodec& codec) const {
66 return codec.width * codec.height <= kMaxPixels;
67 }
68 rtc::Optional<int64_t> start_ms; // Set when bitrate is below |low_kbps|.
69 uint32_t low_kbps = 100;
70 uint32_t high_kbps = 150;
71 int64_t min_low_ms = 10000;
72 const int kMaxPixels = 320 * 240;
73 };
74
75 bool RequestForcedFallback();
76 bool TryReleaseForcedFallbackEncoder();
77 bool TryReInitForcedFallbackEncoder();
78 void ValidateSettingsForForcedFallback();
79 bool IsForcedFallbackActive() const;
80
52 // Settings used in the last InitEncode call and used if a dynamic fallback to 81 // Settings used in the last InitEncode call and used if a dynamic fallback to
53 // software is required. 82 // software is required.
54 VideoCodec codec_settings_; 83 VideoCodec codec_settings_;
55 int32_t number_of_cores_; 84 int32_t number_of_cores_;
56 size_t max_payload_size_; 85 size_t max_payload_size_;
57 86
58 // The last bitrate/framerate set, and a flag for noting they are set. 87 // The last bitrate/framerate set, and a flag for noting they are set.
59 bool rates_set_; 88 bool rates_set_;
60 BitrateAllocation bitrate_allocation_; 89 BitrateAllocation bitrate_allocation_;
61 uint32_t framerate_; 90 uint32_t framerate_;
62 91
63 // The last channel parameters set, and a flag for noting they are set. 92 // The last channel parameters set, and a flag for noting they are set.
64 bool channel_parameters_set_; 93 bool channel_parameters_set_;
65 uint32_t packet_loss_; 94 uint32_t packet_loss_;
66 int64_t rtt_; 95 int64_t rtt_;
67 96
68 const cricket::VideoCodec codec_; 97 const cricket::VideoCodec codec_;
69 webrtc::VideoEncoder* const encoder_; 98 webrtc::VideoEncoder* const encoder_;
70 99
71 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; 100 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_;
72 std::string fallback_implementation_name_; 101 std::string fallback_implementation_name_;
73 EncodedImageCallback* callback_; 102 EncodedImageCallback* callback_;
103
104 bool forced_fallback_possible_;
105 ForcedFallbackParams forced_fallback_;
74 }; 106 };
75 107
76 } // namespace webrtc 108 } // namespace webrtc
77 109
78 #endif // WEBRTC_MEDIA_ENGINE_VIDEOENCODERSOFTWAREFALLBACKWRAPPER_H_ 110 #endif // WEBRTC_MEDIA_ENGINE_VIDEOENCODERSOFTWAREFALLBACKWRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698