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..8d0b915477944d3b0cd47a6d918cb39b6dbc465c |
| --- /dev/null |
| +++ b/webrtc/rtc_base/bitrateallocationstrategy.h |
| @@ -0,0 +1,73 @@ |
| +/* |
| + * 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/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 |
|
stefan-webrtc
2017/09/05 10:42:48
End with .
alexnarest
2017/09/05 13:37:46
Done.
|
| +class BitrateAllocationStrategy : public RefCountedObject<RefCountInterface> { |
| + public: |
| + 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; |
| + TrackConfig() {} |
| + |
| + uint32_t min_bitrate_bps; |
| + uint32_t max_bitrate_bps; |
| + bool enforce_min_bitrate; |
| + std::string track_id; |
| + }; |
| + |
| + // Track ID to track bitrate allocation |
| + typedef std::vector<uint32_t> TrackAllocations; |
| + typedef std::vector<std::unique_ptr<TrackConfig>> TrackConfigs; |
|
nisse-webrtc
2017/09/05 11:03:46
It's recommended to avoid convenience aliases. See
alexnarest
2017/09/05 13:37:46
I agree about TrackAllocations and removed it.
I t
|
| + |
| + TrackAllocations SetAllBitratesToMinimum(const TrackConfigs& track_configs); |
| + TrackAllocations DistributeBitratesEvenly(const TrackConfigs& track_configs, |
| + uint32_t available_bitrate); |
| + |
| + virtual TrackAllocations AllocateBitrates( |
| + uint32_t available_bitrate, |
| + const TrackConfigs& track_configs) = 0; |
| +}; |
| + |
| +// Simple allocation strategy giving priority to audio at low bitrates |
| +class AudioPriorityBitrateAllocationStrategy |
| + : public BitrateAllocationStrategy { |
| + public: |
| + AudioPriorityBitrateAllocationStrategy(std::string audio_track_id, |
| + uint32_t sufficient_audio_bitrate); |
| + TrackAllocations AllocateBitrates(uint32_t available_bitrate, |
| + const TrackConfigs& track_configs) override; |
| + |
| + private: |
| + std::string audio_track_id_; |
| + uint32_t sufficient_audio_bitrate_; |
| +}; |
| +} // namespace rtc |
| + |
| +#endif // WEBRTC_RTC_BASE_BITRATEALLOCATIONSTRATEGY_H_ |