blob: 1db39a403b71a1ffcb2d9d2a2f1d708adfbc67e1 [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
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stddef.h>
15#include <stdint.h>
Ying Wang3b790f32018-01-19 17:58:57 +010016#include <memory>
17#include <vector>
Yves Gerey3e707812018-11-28 16:47:49 +010018
Ying Wang3b790f32018-01-19 17:58:57 +010019#include "api/fec_controller.h"
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "common_types.h" // NOLINT(build/include)
Ying Wang3b790f32018-01-19 17:58:57 +010021#include "modules/video_coding/media_opt_util.h"
Steve Anton10542f22019-01-11 09:11:00 -080022#include "rtc_base/constructor_magic.h"
23#include "rtc_base/critical_section.h"
Yves Gerey3e707812018-11-28 16:47:49 +010024#include "rtc_base/thread_annotations.h"
Ying Wang3b790f32018-01-19 17:58:57 +010025#include "system_wrappers/include/clock.h"
26
27namespace webrtc {
28
29class FecControllerDefault : public FecController {
30 public:
31 FecControllerDefault(Clock* clock,
32 VCMProtectionCallback* protection_callback);
33 explicit FecControllerDefault(Clock* clock);
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020034 ~FecControllerDefault() override;
Ying Wang3b790f32018-01-19 17:58:57 +010035 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;
Ying Wang0dd1b0a2018-02-20 12:50:27 +010047 void UpdateWithEncodedData(const size_t encoded_image_length,
48 const FrameType encoded_image_frametype) override;
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020049 bool UseLossVectorMask() override;
Ying Wang68b2df72018-10-22 16:50:43 +020050 float GetProtectionOverheadRateThreshold();
Ying Wang3b790f32018-01-19 17:58:57 +010051
52 private:
53 enum { kBitrateAverageWinMs = 1000 };
54 Clock* const clock_;
55 VCMProtectionCallback* protection_callback_;
56 rtc::CriticalSection crit_sect_;
57 std::unique_ptr<media_optimization::VCMLossProtectionLogic> loss_prot_logic_
58 RTC_GUARDED_BY(crit_sect_);
59 size_t max_payload_size_ RTC_GUARDED_BY(crit_sect_);
60 RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerDefault);
Ying Wang68b2df72018-10-22 16:50:43 +020061 const float overhead_threshold_;
Ying Wang3b790f32018-01-19 17:58:57 +010062};
63
64} // namespace webrtc
65#endif // MODULES_VIDEO_CODING_FEC_CONTROLLER_DEFAULT_H_