• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_UTILITY_SIMULCAST_RATE_ALLOCATOR_H_
12 #define MODULES_VIDEO_CODING_UTILITY_SIMULCAST_RATE_ALLOCATOR_H_
13 
14 #include <stddef.h>
15 #include <stdint.h>
16 
17 #include <vector>
18 
19 #include "api/video/video_bitrate_allocation.h"
20 #include "api/video/video_bitrate_allocator.h"
21 #include "api/video_codecs/video_codec.h"
22 #include "rtc_base/constructor_magic.h"
23 #include "rtc_base/experiments/rate_control_settings.h"
24 #include "rtc_base/experiments/stable_target_rate_experiment.h"
25 
26 namespace webrtc {
27 
28 class SimulcastRateAllocator : public VideoBitrateAllocator {
29  public:
30   explicit SimulcastRateAllocator(const VideoCodec& codec);
31   ~SimulcastRateAllocator() override;
32 
33   VideoBitrateAllocation Allocate(
34       VideoBitrateAllocationParameters parameters) override;
35   const VideoCodec& GetCodec() const;
36 
37   static float GetTemporalRateAllocation(int num_layers,
38                                          int temporal_id,
39                                          bool base_heavy_tl3_alloc);
40 
41  private:
42   void DistributeAllocationToSimulcastLayers(
43       DataRate total_bitrate,
44       DataRate stable_bitrate,
45       VideoBitrateAllocation* allocated_bitrates);
46   void DistributeAllocationToTemporalLayers(
47       VideoBitrateAllocation* allocated_bitrates) const;
48   std::vector<uint32_t> DefaultTemporalLayerAllocation(int bitrate_kbps,
49                                                        int max_bitrate_kbps,
50                                                        int simulcast_id) const;
51   std::vector<uint32_t> ScreenshareTemporalLayerAllocation(
52       int bitrate_kbps,
53       int max_bitrate_kbps,
54       int simulcast_id) const;
55   int NumTemporalStreams(size_t simulcast_id) const;
56 
57   const VideoCodec codec_;
58   const StableTargetRateExperiment stable_rate_settings_;
59   const RateControlSettings rate_control_settings_;
60   std::vector<bool> stream_enabled_;
61 
62   RTC_DISALLOW_COPY_AND_ASSIGN(SimulcastRateAllocator);
63 };
64 
65 }  // namespace webrtc
66 
67 #endif  // MODULES_VIDEO_CODING_UTILITY_SIMULCAST_RATE_ALLOCATOR_H_
68