Chromium Code Reviews| Index: webrtc/rtc_base/bitrateallocationstrategy.h |
| diff --git a/webrtc/rtc_base/bitrateallocationstrategy.h b/webrtc/rtc_base/bitrateallocationstrategy.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..129816d510415016253672709977b0073770ccb0 |
| --- /dev/null |
| +++ b/webrtc/rtc_base/bitrateallocationstrategy.h |
| @@ -0,0 +1,76 @@ |
| +/* |
|
Taylor Brandstetter
2017/09/11 16:55:07
Not sure if this has been discussed before, but do
alexnarest
2017/09/14 13:08:34
I thought rtc_base/ is relevant because this provi
Taylor Brandstetter
2017/09/15 01:26:21
Something I forgot from the round of comments I ju
nisse-webrtc
2017/09/15 07:05:44
Agreed. When moving to api/, be extra careful abou
|
| + * Copyright 2017 The WebRTC Project Authors. All rights reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#ifndef WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_ |
| +#define WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_ |
| + |
| +#include <map> |
| +#include <memory> |
| +#include <string> |
| +#include <vector> |
| +#include "webrtc/rtc_base/array_view.h" |
| +#include "webrtc/rtc_base/checks.h" |
| +#include "webrtc/rtc_base/refcount.h" |
| +#include "webrtc/rtc_base/refcountedobject.h" |
| + |
| +namespace rtc { |
| + |
| +// Plugable strategy allows configuration of bitrate allocation per media track. |
|
Taylor Brandstetter
2017/09/11 16:55:07
Would be nice to have a more detailed explanation
alexnarest
2017/09/14 13:08:33
Done.
|
| +class BitrateAllocationStrategy { |
| + public: |
|
Taylor Brandstetter
2017/09/11 16:55:07
Can you document the arguments to TrackConfig's co
alexnarest
2017/09/14 13:08:34
Done.
|
| + struct TrackConfig { |
| + TrackConfig(uint32_t min_bitrate_bps, |
| + uint32_t max_bitrate_bps, |
| + bool enforce_min_bitrate, |
| + std::string track_id) |
| + : min_bitrate_bps(min_bitrate_bps), |
| + max_bitrate_bps(max_bitrate_bps), |
| + enforce_min_bitrate(enforce_min_bitrate), |
| + track_id(track_id) {} |
| + TrackConfig(const TrackConfig& track_config) = default; |
| + virtual ~TrackConfig() = default; |
| + TrackConfig() {} |
| + |
| + uint32_t min_bitrate_bps; |
| + uint32_t max_bitrate_bps; |
| + bool enforce_min_bitrate; |
| + std::string track_id; |
| + }; |
| + |
| + std::vector<uint32_t> SetAllBitratesToMinimum( |
| + const ArrayView<const TrackConfig*> track_configs); |
| + std::vector<uint32_t> DistributeBitratesEvenly( |
| + const ArrayView<const TrackConfig*> track_configs, |
| + uint32_t available_bitrate); |
|
Taylor Brandstetter
2017/09/11 16:55:07
If these methods aren't virtual, do they need to b
alexnarest
2017/09/14 13:08:34
These are utility methods. Future strategies will
Taylor Brandstetter
2017/09/15 01:24:41
I understand. I just think it would be cleaner if
nisse-webrtc
2017/09/15 07:05:44
Are they intended as internal utility functions, o
|
| + |
| + virtual std::vector<uint32_t> AllocateBitrates( |
|
Taylor Brandstetter
2017/09/11 16:55:06
Some comments around this would be helpful. Some q
alexnarest
2017/09/14 13:08:33
Done.
|
| + uint32_t available_bitrate, |
| + const ArrayView<const TrackConfig*> track_configs) = 0; |
| + |
| + virtual ~BitrateAllocationStrategy() = default; |
| +}; |
| + |
| +// Simple allocation strategy giving priority to audio at low bitrates. |
|
Taylor Brandstetter
2017/09/11 16:55:06
Can this comment elaborate a bit more? I'd summari
alexnarest
2017/09/14 13:08:34
Done.
|
| +class AudioPriorityBitrateAllocationStrategy |
| + : public BitrateAllocationStrategy { |
| + public: |
| + AudioPriorityBitrateAllocationStrategy(std::string audio_track_id, |
| + uint32_t sufficient_audio_bitrate); |
| + std::vector<uint32_t> AllocateBitrates( |
| + uint32_t available_bitrate, |
| + const ArrayView<const TrackConfig*> track_configs) override; |
| + |
| + private: |
| + std::string audio_track_id_; |
| + uint32_t sufficient_audio_bitrate_; |
| +}; |
| +} // namespace rtc |
| + |
| +#endif // WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_ |