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

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

Issue 2996643002: BWE allocation strategy
Patch Set: Documentation and 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
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 std::vector<uint32_t> SetAllBitratesToMinimum(
60 const ArrayView<const TrackConfig*> track_configs);
61 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.
Taylor Brandstetter 2017/09/15 01:24:41 nit: Paragraph break here?
alexnarest 2017/09/15 08:29:40 Done.
70 // If the strategy will allocate more than available_bitrate it may cause
71 // overuse of the currently available network capacity and may cause increase
72 // in RTT and packet loss. Allocating less than available bitrate may cause
73 // available_bitrate decrease.
74 virtual std::vector<uint32_t> AllocateBitrates(
75 uint32_t available_bitrate,
76 const ArrayView<const TrackConfig*> track_configs) = 0;
77
78 virtual ~BitrateAllocationStrategy() = default;
79 };
80
81 // Simple allocation strategy giving priority to audio until
82 // sufficient_audio_bitrate is reached. Bitrate is distributed evenly between
83 // the tracks after sufficient_audio_bitrate is reached.
84 class AudioPriorityBitrateAllocationStrategy
85 : public BitrateAllocationStrategy {
86 public:
87 AudioPriorityBitrateAllocationStrategy(std::string audio_track_id,
88 uint32_t sufficient_audio_bitrate);
89 std::vector<uint32_t> AllocateBitrates(
90 uint32_t available_bitrate,
91 const ArrayView<const TrackConfig*> track_configs) override;
92
93 private:
94 std::string audio_track_id_;
95 uint32_t sufficient_audio_bitrate_;
96 };
97 } // namespace rtc
98
99 #endif // WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698