blob: 9d79a61d28ebbaeed7f0f31a51c7f7680ae44ae5 [file] [log] [blame]
Ying Wang3b790f32018-01-19 17:58:57 +01001/*
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
14#include <memory>
15#include <vector>
16#include "api/fec_controller.h"
17#include "modules/include/module_common_types.h"
18#include "modules/video_coding/media_opt_util.h"
19#include "rtc_base/criticalsection.h"
20#include "system_wrappers/include/clock.h"
21
22namespace webrtc {
23
24class FecControllerDefault : public FecController {
25 public:
26 FecControllerDefault(Clock* clock,
27 VCMProtectionCallback* protection_callback);
28 explicit FecControllerDefault(Clock* clock);
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020029 ~FecControllerDefault() override;
Ying Wang3b790f32018-01-19 17:58:57 +010030 void SetProtectionCallback(
31 VCMProtectionCallback* protection_callback) override;
32 void SetProtectionMethod(bool enable_fec, bool enable_nack) override;
33 void SetEncodingData(size_t width,
34 size_t height,
35 size_t num_temporal_layers,
36 size_t max_payload_size) override;
37 uint32_t UpdateFecRates(uint32_t estimated_bitrate_bps,
38 int actual_framerate_fps,
39 uint8_t fraction_lost,
40 std::vector<bool> loss_mask_vector,
41 int64_t round_trip_time_ms) override;
Ying Wang0dd1b0a2018-02-20 12:50:27 +010042 void UpdateWithEncodedData(const size_t encoded_image_length,
43 const FrameType encoded_image_frametype) override;
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020044 bool UseLossVectorMask() override;
Ying Wang68b2df72018-10-22 16:50:43 +020045 float GetProtectionOverheadRateThreshold();
Ying Wang3b790f32018-01-19 17:58:57 +010046
47 private:
48 enum { kBitrateAverageWinMs = 1000 };
49 Clock* const clock_;
50 VCMProtectionCallback* protection_callback_;
51 rtc::CriticalSection crit_sect_;
52 std::unique_ptr<media_optimization::VCMLossProtectionLogic> loss_prot_logic_
53 RTC_GUARDED_BY(crit_sect_);
54 size_t max_payload_size_ RTC_GUARDED_BY(crit_sect_);
55 RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerDefault);
Ying Wang68b2df72018-10-22 16:50:43 +020056 const float overhead_threshold_;
Ying Wang3b790f32018-01-19 17:58:57 +010057};
58
59} // namespace webrtc
60#endif // MODULES_VIDEO_CODING_FEC_CONTROLLER_DEFAULT_H_