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

Unified Diff: webrtc/base/bitrateallocationstrategy.h

Issue 2996643002: BWE allocation strategy
Patch Set: BWE allocation strategy Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/base/bitrateallocationstrategy.h
diff --git a/webrtc/base/bitrateallocationstrategy.h b/webrtc/base/bitrateallocationstrategy.h
new file mode 100644
index 0000000000000000000000000000000000000000..53836f7669ec3821e3052a32da75c5e63f0c6fdc
--- /dev/null
+++ b/webrtc/base/bitrateallocationstrategy.h
@@ -0,0 +1,84 @@
+/*
+ * 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_BASE_BITRATEALLOCATIONSTRATEGY_H_
+#define WEBRTC_BASE_BITRATEALLOCATIONSTRATEGY_H_
+
+#include <map>
+#include <string>
+#include <vector>
+#include "webrtc/base/checks.h"
+#include "webrtc/base/refcountedobject.h"
+
+namespace rtc {
+
+// Plugable strategy allows configuration of bitrate allocation per media track
+class BitrateAllocationStrategyConfig {
+ 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)
+ : min_bitrate_bps(track_config.min_bitrate_bps),
+ max_bitrate_bps(track_config.max_bitrate_bps),
+ enforce_min_bitrate(track_config.enforce_min_bitrate),
+ track_id(track_config.track_id) {}
+ 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::map<std::string, uint32_t> TrackAllocations;
+ // Track ID to track config
+ typedef std::map<std::string, TrackConfig> TrackConfigs;
+
+ virtual ~BitrateAllocationStrategyConfig() = default;
+};
+
+// The base class future allocation strategies will inherit
+class BitrateAllocationStrategy
+ : public RefCountedObject<BitrateAllocationStrategyConfig> {
+ public:
+ // Will be called by bitrate allocator, should return allocated bitrate
+ // for every track.
+ virtual TrackAllocations AllocateBitrates(
+ uint32_t available_bitrate,
+ const TrackConfigs& track_configs) = 0;
+
+ TrackAllocations SetAllBitratesToMinimum(const TrackConfigs& track_configs);
+ TrackAllocations DistributeBitratesEvenly(const TrackConfigs& track_configs,
+ uint32_t available_bitrate);
+};
+
+// 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_BASE_BITRATEALLOCATIONSTRATEGY_H_

Powered by Google App Engine
This is Rietveld 408576698