OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2017 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 WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_ |
| 12 #define WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_ |
| 13 |
| 14 #include <map> |
| 15 #include <memory> |
| 16 #include <string> |
| 17 #include <vector> |
| 18 #include "webrtc/rtc_base/checks.h" |
| 19 #include "webrtc/rtc_base/refcount.h" |
| 20 #include "webrtc/rtc_base/refcountedobject.h" |
| 21 |
| 22 namespace rtc { |
| 23 |
| 24 // Plugable strategy allows configuration of bitrate allocation per media track |
| 25 class BitrateAllocationStrategy : public RefCountedObject<RefCountInterface> { |
| 26 public: |
| 27 struct TrackConfig { |
| 28 TrackConfig(uint32_t min_bitrate_bps, |
| 29 uint32_t max_bitrate_bps, |
| 30 bool enforce_min_bitrate, |
| 31 std::string track_id) |
| 32 : min_bitrate_bps(min_bitrate_bps), |
| 33 max_bitrate_bps(max_bitrate_bps), |
| 34 enforce_min_bitrate(enforce_min_bitrate), |
| 35 track_id(track_id) {} |
| 36 TrackConfig(const TrackConfig& track_config) = default; |
| 37 TrackConfig() {} |
| 38 |
| 39 uint32_t min_bitrate_bps; |
| 40 uint32_t max_bitrate_bps; |
| 41 bool enforce_min_bitrate; |
| 42 std::string track_id; |
| 43 }; |
| 44 |
| 45 // Track ID to track bitrate allocation |
| 46 typedef std::map<std::string, uint32_t> TrackAllocations; |
| 47 typedef std::vector<std::unique_ptr<TrackConfig>> TrackConfigs; |
| 48 |
| 49 TrackAllocations SetAllBitratesToMinimum(const TrackConfigs& track_configs); |
| 50 TrackAllocations DistributeBitratesEvenly(const TrackConfigs& track_configs, |
| 51 uint32_t available_bitrate); |
| 52 |
| 53 virtual TrackAllocations AllocateBitrates( |
| 54 uint32_t available_bitrate, |
| 55 const TrackConfigs& track_configs) = 0; |
| 56 }; |
| 57 |
| 58 // Simple allocation strategy giving priority to audio at low bitrates |
| 59 class AudioPriorityBitrateAllocationStrategy |
| 60 : public BitrateAllocationStrategy { |
| 61 public: |
| 62 AudioPriorityBitrateAllocationStrategy(std::string audio_track_id, |
| 63 uint32_t sufficient_audio_bitrate); |
| 64 TrackAllocations AllocateBitrates(uint32_t available_bitrate, |
| 65 const TrackConfigs& track_configs) override; |
| 66 |
| 67 private: |
| 68 std::string audio_track_id_; |
| 69 uint32_t sufficient_audio_bitrate_; |
| 70 }; |
| 71 } // namespace rtc |
| 72 |
| 73 #endif // WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_ |
OLD | NEW |