Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: webrtc/rtc_base/bitrateallocationstrategy.h

Issue 2996643002: BWE allocation strategy
Patch Set: Comments handling Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/rtc_base/BUILD.gn ('k') | webrtc/rtc_base/bitrateallocationstrategy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/array_view.h"
19 #include "webrtc/rtc_base/checks.h"
20 #include "webrtc/rtc_base/refcount.h"
21 #include "webrtc/rtc_base/refcountedobject.h"
22
23 namespace rtc {
24
25 // Plugable strategy allows configuration of bitrate allocation per media track.
26 // The strategy should provide allocation for every track passed with
27 // track_configs in AllocateBitrates. The allocations are constrained by
28 // max_bitrate_bps, min_bitrate_bps defining the track supported range and
29 // enforce_min_bitrate indicating if the track my be paused by allocating 0
30 // bitrate.
31 class BitrateAllocationStrategy {
32 public:
33 struct TrackConfig {
34 TrackConfig(uint32_t min_bitrate_bps,
35 uint32_t max_bitrate_bps,
36 bool enforce_min_bitrate,
37 std::string track_id)
38 : min_bitrate_bps(min_bitrate_bps),
39 max_bitrate_bps(max_bitrate_bps),
40 enforce_min_bitrate(enforce_min_bitrate),
41 track_id(track_id) {}
42 TrackConfig(const TrackConfig& track_config) = default;
43 virtual ~TrackConfig() = default;
44 TrackConfig() {}
45
46 // Minimum bitrate supported by track.
47 uint32_t min_bitrate_bps;
48
49 // Maximum bitrate supported by track.
50 uint32_t max_bitrate_bps;
51
52 // True means track may not be paused by allocating 0 bitrate.
53 bool enforce_min_bitrate;
54
55 // MediaStreamTrack ID as defined by application. May be empty.
56 std::string track_id;
57 };
58
59 static std::vector<uint32_t> SetAllBitratesToMinimum(
60 const ArrayView<const TrackConfig*> track_configs);
61 static std::vector<uint32_t> DistributeBitratesEvenly(
62 const ArrayView<const TrackConfig*> track_configs,
63 uint32_t available_bitrate);
64
65 // Strategy is expected to allocate all available_bitrate up to the sum of
66 // max_bitrate_bps of all tracks. If available_bitrate is less than the sum of
67 // min_bitrate_bps of all tracks, tracks having enforce_min_bitrate set to
68 // false may get 0 allocation and are suppoused to pause, tracks with
69 // enforce_min_bitrate set to true are expecting to get min_bitrate_bps.
70 //
71 // If the strategy will allocate more than available_bitrate it may cause
72 // overuse of the currently available network capacity and may cause increase
73 // in RTT and packet loss. Allocating less than available bitrate may cause
74 // available_bitrate decrease.
75 virtual std::vector<uint32_t> AllocateBitrates(
76 uint32_t available_bitrate,
77 const ArrayView<const TrackConfig*> track_configs) = 0;
78
79 virtual ~BitrateAllocationStrategy() = default;
80 };
81
82 // Simple allocation strategy giving priority to audio until
83 // sufficient_audio_bitrate is reached. Bitrate is distributed evenly between
84 // the tracks after sufficient_audio_bitrate is reached. This implementation
85 // does not pause tracks even if enforce_min_bitrate is false.
86 class AudioPriorityBitrateAllocationStrategy
87 : public BitrateAllocationStrategy {
88 public:
89 AudioPriorityBitrateAllocationStrategy(std::string audio_track_id,
90 uint32_t sufficient_audio_bitrate);
91 std::vector<uint32_t> AllocateBitrates(
92 uint32_t available_bitrate,
93 const ArrayView<const TrackConfig*> track_configs) override;
94
95 private:
96 std::string audio_track_id_;
97 uint32_t sufficient_audio_bitrate_;
98 };
99 } // namespace rtc
100
101 #endif // WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_
OLDNEW
« no previous file with comments | « webrtc/rtc_base/BUILD.gn ('k') | webrtc/rtc_base/bitrateallocationstrategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698