Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Start(uint32_t kbps, const VideoCodec& codec); | |
|
brandtr
2017/08/09 09:05:03
How about naming these ShouldStart and ShouldStop
åsapersson
2017/08/09 09:50:36
Done.
| |
| 61 bool Stop(uint32_t kbps) const { return kbps >= high_kbps; } | |
| 62 void Reset() { start_ms.reset(); } | |
| 63 bool IsValid(const VideoCodec& codec) const { | |
| 64 return codec.width * codec.height <= kMaxPixels; | |
| 65 } | |
| 66 rtc::Optional<int64_t> start_ms; // Set when bitrate is below |low_kbps|. | |
| 67 uint32_t low_kbps = 100; | |
| 68 uint32_t high_kbps = 150; | |
| 69 int64_t min_low_ms = 10000; | |
| 70 const int kMaxPixels = 320 * 240; | |
| 71 }; | |
| 72 | |
| 73 bool RequestForcedFallback(); | |
| 74 bool TryReleaseForcedFallbackEncoder(); | |
| 75 bool TryReInitForcedFallbackEncoder(); | |
| 76 void ValidateSettingsForForcedFallback(); | |
| 77 bool IsForcedFallbackActive() const; | |
| 78 | |
| 52 // Settings used in the last InitEncode call and used if a dynamic fallback to | 79 // Settings used in the last InitEncode call and used if a dynamic fallback to |
| 53 // software is required. | 80 // software is required. |
| 54 VideoCodec codec_settings_; | 81 VideoCodec codec_settings_; |
| 55 int32_t number_of_cores_; | 82 int32_t number_of_cores_; |
| 56 size_t max_payload_size_; | 83 size_t max_payload_size_; |
| 57 | 84 |
| 58 // The last bitrate/framerate set, and a flag for noting they are set. | 85 // The last bitrate/framerate set, and a flag for noting they are set. |
| 59 bool rates_set_; | 86 bool rates_set_; |
| 60 BitrateAllocation bitrate_allocation_; | 87 BitrateAllocation bitrate_allocation_; |
| 61 uint32_t framerate_; | 88 uint32_t framerate_; |
| 62 | 89 |
| 63 // The last channel parameters set, and a flag for noting they are set. | 90 // The last channel parameters set, and a flag for noting they are set. |
| 64 bool channel_parameters_set_; | 91 bool channel_parameters_set_; |
| 65 uint32_t packet_loss_; | 92 uint32_t packet_loss_; |
| 66 int64_t rtt_; | 93 int64_t rtt_; |
| 67 | 94 |
| 68 const cricket::VideoCodec codec_; | 95 const cricket::VideoCodec codec_; |
| 69 webrtc::VideoEncoder* const encoder_; | 96 webrtc::VideoEncoder* const encoder_; |
| 70 | 97 |
| 71 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; | 98 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; |
| 72 std::string fallback_implementation_name_; | 99 std::string fallback_implementation_name_; |
| 73 EncodedImageCallback* callback_; | 100 EncodedImageCallback* callback_; |
| 101 | |
| 102 bool forced_fallback_possible_; | |
| 103 ForcedFallbackParams forced_fallback_; | |
| 74 }; | 104 }; |
| 75 | 105 |
| 76 } // namespace webrtc | 106 } // namespace webrtc |
| 77 | 107 |
| 78 #endif // WEBRTC_MEDIA_ENGINE_VIDEOENCODERSOFTWAREFALLBACKWRAPPER_H_ | 108 #endif // WEBRTC_MEDIA_ENGINE_VIDEOENCODERSOFTWAREFALLBACKWRAPPER_H_ |
| OLD | NEW |