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 <string> | |
16 #include <vector> | |
17 #include "webrtc/rtc_base/checks.h" | |
18 #include "webrtc/rtc_base/refcountedobject.h" | |
19 | |
20 namespace rtc { | |
21 | |
22 // Plugable strategy allows configuration of bitrate allocation per media track | |
23 class BitrateAllocationStrategyConfig { | |
24 public: | |
25 struct TrackConfig { | |
26 TrackConfig(uint32_t min_bitrate_bps, | |
27 uint32_t max_bitrate_bps, | |
28 bool enforce_min_bitrate, | |
29 std::string track_id) | |
30 : min_bitrate_bps(min_bitrate_bps), | |
31 max_bitrate_bps(max_bitrate_bps), | |
32 enforce_min_bitrate(enforce_min_bitrate), | |
33 track_id(track_id) {} | |
34 TrackConfig(const TrackConfig& track_config) | |
nisse-webrtc
2017/08/22 11:46:05
Use "= default" for the copy constructor, if possi
alexnarest
2017/08/22 14:52:17
Done.
| |
35 : min_bitrate_bps(track_config.min_bitrate_bps), | |
36 max_bitrate_bps(track_config.max_bitrate_bps), | |
37 enforce_min_bitrate(track_config.enforce_min_bitrate), | |
38 track_id(track_config.track_id) {} | |
39 TrackConfig() {} | |
40 | |
41 uint32_t min_bitrate_bps; | |
42 uint32_t max_bitrate_bps; | |
43 bool enforce_min_bitrate; | |
44 std::string track_id; | |
nisse-webrtc
2017/08/22 11:46:06
Track ids are unclear to me. How are they assigned
alexnarest
2017/08/22 14:52:17
Track IDs are assigned by the app, for example ple
| |
45 }; | |
46 // Track ID to track bitrate allocation | |
47 typedef std::map<std::string, uint32_t> TrackAllocations; | |
48 // Track ID to track config | |
49 typedef std::map<std::string, TrackConfig> TrackConfigs; | |
nisse-webrtc
2017/08/22 11:46:05
Seems redundant to have track_ids inside TrackConf
alexnarest
2017/08/22 14:52:17
It can be done with the vectors but the map saves
nisse-webrtc
2017/08/22 15:23:34
Not sure. See my comments on that place.
alexnarest
2017/08/31 18:40:26
Done.
| |
50 | |
51 virtual ~BitrateAllocationStrategyConfig() = default; | |
52 }; | |
53 | |
54 // The base class future allocation strategies will inherit | |
55 class BitrateAllocationStrategy | |
56 : public RefCountedObject<BitrateAllocationStrategyConfig> { | |
nisse-webrtc
2017/08/22 11:46:06
This inheritance is puzzling to me, a strategy and
alexnarest
2017/08/22 14:52:17
Will renaming BitrateAllocationStrategyConfig to B
nisse-webrtc
2017/08/22 15:23:34
Sounds good. But don't do the Base class unless th
alexnarest
2017/08/31 18:40:27
Done.
| |
57 public: | |
58 // Will be called by bitrate allocator, should return allocated bitrate | |
59 // for every track. | |
60 virtual TrackAllocations AllocateBitrates( | |
61 uint32_t available_bitrate, | |
62 const TrackConfigs& track_configs) = 0; | |
63 | |
64 TrackAllocations SetAllBitratesToMinimum(const TrackConfigs& track_configs); | |
65 TrackAllocations DistributeBitratesEvenly(const TrackConfigs& track_configs, | |
66 uint32_t available_bitrate); | |
67 }; | |
68 | |
69 // Simple allocation strategy giving priority to audio at low bitrates | |
70 class AudioPriorityBitrateAllocationStrategy | |
71 : public BitrateAllocationStrategy { | |
72 public: | |
73 AudioPriorityBitrateAllocationStrategy(std::string audio_track_id, | |
74 uint32_t sufficient_audio_bitrate); | |
75 TrackAllocations AllocateBitrates(uint32_t available_bitrate, | |
76 const TrackConfigs& track_configs) override; | |
77 | |
78 private: | |
79 std::string audio_track_id_; | |
80 uint32_t sufficient_audio_bitrate_; | |
81 }; | |
82 } // namespace rtc | |
83 | |
84 #endif // WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_ | |
OLD | NEW |