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/experiments/rate_control_settings.h" 23 #include "rtc_base/experiments/stable_target_rate_experiment.h" 24 25 namespace webrtc { 26 27 class SimulcastRateAllocator : public VideoBitrateAllocator { 28 public: 29 explicit SimulcastRateAllocator(const VideoCodec& codec); 30 ~SimulcastRateAllocator() override; 31 32 SimulcastRateAllocator(const SimulcastRateAllocator&) = delete; 33 SimulcastRateAllocator& operator=(const SimulcastRateAllocator&) = delete; 34 35 VideoBitrateAllocation Allocate( 36 VideoBitrateAllocationParameters parameters) override; 37 const VideoCodec& GetCodec() const; 38 39 static float GetTemporalRateAllocation(int num_layers, 40 int temporal_id, 41 bool base_heavy_tl3_alloc); 42 43 void SetLegacyConferenceMode(bool mode) override; 44 45 private: 46 void DistributeAllocationToSimulcastLayers( 47 DataRate total_bitrate, 48 DataRate stable_bitrate, 49 VideoBitrateAllocation* allocated_bitrates); 50 void DistributeAllocationToTemporalLayers( 51 VideoBitrateAllocation* allocated_bitrates) const; 52 std::vector<uint32_t> DefaultTemporalLayerAllocation(int bitrate_kbps, 53 int max_bitrate_kbps, 54 int simulcast_id) const; 55 std::vector<uint32_t> ScreenshareTemporalLayerAllocation( 56 int bitrate_kbps, 57 int max_bitrate_kbps, 58 int simulcast_id) const; 59 int NumTemporalStreams(size_t simulcast_id) const; 60 61 const VideoCodec codec_; 62 const StableTargetRateExperiment stable_rate_settings_; 63 const RateControlSettings rate_control_settings_; 64 std::vector<bool> stream_enabled_; 65 bool legacy_conference_mode_; 66 }; 67 68 } // namespace webrtc 69 70 #endif // MODULES_VIDEO_CODING_UTILITY_SIMULCAST_RATE_ALLOCATOR_H_ 71