blob: cca1658a999946f26ed5b480afdf968b64f77eea [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>
Jonas Olssona4d87372019-07-05 19:08:33 +020016
Ying Wang3b790f32018-01-19 17:58:57 +010017#include <memory>
18#include <vector>
Yves Gerey3e707812018-11-28 16:47:49 +010019
Ying Wang3b790f32018-01-19 17:58:57 +010020#include "api/fec_controller.h"
Ying Wang3b790f32018-01-19 17:58:57 +010021#include "modules/video_coding/media_opt_util.h"
Markus Handell6deec382020-07-07 12:17:12 +020022#include "rtc_base/synchronization/mutex.h"
Yves Gerey3e707812018-11-28 16:47:49 +010023#include "rtc_base/thread_annotations.h"
Ying Wang3b790f32018-01-19 17:58:57 +010024#include "system_wrappers/include/clock.h"
25
26namespace webrtc {
27
28class FecControllerDefault : public FecController {
29 public:
30 FecControllerDefault(Clock* clock,
31 VCMProtectionCallback* protection_callback);
32 explicit FecControllerDefault(Clock* clock);
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020033 ~FecControllerDefault() override;
Byoungchan Lee604fd2f2022-01-21 09:49:39 +090034
35 FecControllerDefault(const FecControllerDefault&) = delete;
36 FecControllerDefault& operator=(const FecControllerDefault&) = delete;
37
Ying Wang3b790f32018-01-19 17:58:57 +010038 void SetProtectionCallback(
39 VCMProtectionCallback* protection_callback) override;
40 void SetProtectionMethod(bool enable_fec, bool enable_nack) override;
41 void SetEncodingData(size_t width,
42 size_t height,
43 size_t num_temporal_layers,
44 size_t max_payload_size) override;
45 uint32_t UpdateFecRates(uint32_t estimated_bitrate_bps,
46 int actual_framerate_fps,
47 uint8_t fraction_lost,
48 std::vector<bool> loss_mask_vector,
49 int64_t round_trip_time_ms) override;
Niels Möller87e2d782019-03-07 10:18:23 +010050 void UpdateWithEncodedData(
51 const size_t encoded_image_length,
52 const VideoFrameType encoded_image_frametype) override;
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020053 bool UseLossVectorMask() override;
Ying Wang68b2df72018-10-22 16:50:43 +020054 float GetProtectionOverheadRateThreshold();
Ying Wang3b790f32018-01-19 17:58:57 +010055
56 private:
57 enum { kBitrateAverageWinMs = 1000 };
58 Clock* const clock_;
59 VCMProtectionCallback* protection_callback_;
Markus Handell6deec382020-07-07 12:17:12 +020060 Mutex mutex_;
Ying Wang3b790f32018-01-19 17:58:57 +010061 std::unique_ptr<media_optimization::VCMLossProtectionLogic> loss_prot_logic_
Markus Handell6deec382020-07-07 12:17:12 +020062 RTC_GUARDED_BY(mutex_);
63 size_t max_payload_size_ RTC_GUARDED_BY(mutex_);
Byoungchan Lee604fd2f2022-01-21 09:49:39 +090064
Ying Wang68b2df72018-10-22 16:50:43 +020065 const float overhead_threshold_;
Ying Wang3b790f32018-01-19 17:58:57 +010066};
67
68} // namespace webrtc
69#endif // MODULES_VIDEO_CODING_FEC_CONTROLLER_DEFAULT_H_