Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef MODULES_VIDEO_CODING_FEC_CONTROLLER_DEFAULT_H_ |
| 12 | #define MODULES_VIDEO_CODING_FEC_CONTROLLER_DEFAULT_H_ |
| 13 | |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 17:08:33 | [diff] [blame] | 16 | |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 17 | #include <memory> |
| 18 | #include <vector> |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 19 | |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 20 | #include "api/fec_controller.h" |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 21 | #include "modules/video_coding/media_opt_util.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 22 | #include "rtc_base/constructor_magic.h" |
Markus Handell | 6deec38 | 2020-07-07 10:17:12 | [diff] [blame] | 23 | #include "rtc_base/synchronization/mutex.h" |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 24 | #include "rtc_base/thread_annotations.h" |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 25 | #include "system_wrappers/include/clock.h" |
| 26 | |
| 27 | namespace webrtc { |
| 28 | |
| 29 | class FecControllerDefault : public FecController { |
| 30 | public: |
| 31 | FecControllerDefault(Clock* clock, |
| 32 | VCMProtectionCallback* protection_callback); |
| 33 | explicit FecControllerDefault(Clock* clock); |
Mirko Bonadei | 8fdcac3 | 2018-08-28 14:30:18 | [diff] [blame] | 34 | ~FecControllerDefault() override; |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 35 | void SetProtectionCallback( |
| 36 | VCMProtectionCallback* protection_callback) override; |
| 37 | void SetProtectionMethod(bool enable_fec, bool enable_nack) override; |
| 38 | void SetEncodingData(size_t width, |
| 39 | size_t height, |
| 40 | size_t num_temporal_layers, |
| 41 | size_t max_payload_size) override; |
| 42 | uint32_t UpdateFecRates(uint32_t estimated_bitrate_bps, |
| 43 | int actual_framerate_fps, |
| 44 | uint8_t fraction_lost, |
| 45 | std::vector<bool> loss_mask_vector, |
| 46 | int64_t round_trip_time_ms) override; |
Niels Möller | 87e2d78 | 2019-03-07 09:18:23 | [diff] [blame] | 47 | void UpdateWithEncodedData( |
| 48 | const size_t encoded_image_length, |
| 49 | const VideoFrameType encoded_image_frametype) override; |
Mirko Bonadei | 8fdcac3 | 2018-08-28 14:30:18 | [diff] [blame] | 50 | bool UseLossVectorMask() override; |
Ying Wang | 68b2df7 | 2018-10-22 14:50:43 | [diff] [blame] | 51 | float GetProtectionOverheadRateThreshold(); |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 52 | |
| 53 | private: |
| 54 | enum { kBitrateAverageWinMs = 1000 }; |
| 55 | Clock* const clock_; |
| 56 | VCMProtectionCallback* protection_callback_; |
Markus Handell | 6deec38 | 2020-07-07 10:17:12 | [diff] [blame] | 57 | Mutex mutex_; |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 58 | std::unique_ptr<media_optimization::VCMLossProtectionLogic> loss_prot_logic_ |
Markus Handell | 6deec38 | 2020-07-07 10:17:12 | [diff] [blame] | 59 | RTC_GUARDED_BY(mutex_); |
| 60 | size_t max_payload_size_ RTC_GUARDED_BY(mutex_); |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 61 | RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerDefault); |
Ying Wang | 68b2df7 | 2018-10-22 14:50:43 | [diff] [blame] | 62 | const float overhead_threshold_; |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | } // namespace webrtc |
| 66 | #endif // MODULES_VIDEO_CODING_FEC_CONTROLLER_DEFAULT_H_ |