fec_controller_default.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef MODULES_VIDEO_CODING_FEC_CONTROLLER_DEFAULT_H_
  11. #define MODULES_VIDEO_CODING_FEC_CONTROLLER_DEFAULT_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <memory>
  15. #include <vector>
  16. #include "api/fec_controller.h"
  17. #include "modules/video_coding/media_opt_util.h"
  18. #include "rtc_base/constructor_magic.h"
  19. #include "rtc_base/synchronization/mutex.h"
  20. #include "rtc_base/thread_annotations.h"
  21. #include "system_wrappers/include/clock.h"
  22. namespace webrtc {
  23. class FecControllerDefault : public FecController {
  24. public:
  25. FecControllerDefault(Clock* clock,
  26. VCMProtectionCallback* protection_callback);
  27. explicit FecControllerDefault(Clock* clock);
  28. ~FecControllerDefault() override;
  29. void SetProtectionCallback(
  30. VCMProtectionCallback* protection_callback) override;
  31. void SetProtectionMethod(bool enable_fec, bool enable_nack) override;
  32. void SetEncodingData(size_t width,
  33. size_t height,
  34. size_t num_temporal_layers,
  35. size_t max_payload_size) override;
  36. uint32_t UpdateFecRates(uint32_t estimated_bitrate_bps,
  37. int actual_framerate_fps,
  38. uint8_t fraction_lost,
  39. std::vector<bool> loss_mask_vector,
  40. int64_t round_trip_time_ms) override;
  41. void UpdateWithEncodedData(
  42. const size_t encoded_image_length,
  43. const VideoFrameType encoded_image_frametype) override;
  44. bool UseLossVectorMask() override;
  45. float GetProtectionOverheadRateThreshold();
  46. private:
  47. enum { kBitrateAverageWinMs = 1000 };
  48. Clock* const clock_;
  49. VCMProtectionCallback* protection_callback_;
  50. Mutex mutex_;
  51. std::unique_ptr<media_optimization::VCMLossProtectionLogic> loss_prot_logic_
  52. RTC_GUARDED_BY(mutex_);
  53. size_t max_payload_size_ RTC_GUARDED_BY(mutex_);
  54. RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerDefault);
  55. const float overhead_threshold_;
  56. };
  57. } // namespace webrtc
  58. #endif // MODULES_VIDEO_CODING_FEC_CONTROLLER_DEFAULT_H_