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

Unified Diff: webrtc/common_types.h

Issue 2434073003: Extract bitrate allocation of spatial/temporal layers out of codec impl. (Closed)
Patch Set: Updated tl listener registration. Fixed tests. Created 4 years, 2 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
« no previous file with comments | « no previous file | webrtc/common_video/BUILD.gn » ('j') | webrtc/common_video/include/video_bitrate_allocator.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_types.h
diff --git a/webrtc/common_types.h b/webrtc/common_types.h
index b1842ef59598e78e86f99f71d495661b0d1a9483..eeceaa3a73dec55e772e52fb68e2f0c8b17be5fe 100644
--- a/webrtc/common_types.h
+++ b/webrtc/common_types.h
@@ -622,6 +622,56 @@ struct VideoCodec {
bool operator!=(const VideoCodec& other) const = delete;
};
+struct BitrateAllocation {
perkj_webrtc 2016/10/21 08:24:28 please use class.
sprang_webrtc 2016/10/25 10:44:25 Agreed. This started out as a simple struct (that'
+ static const size_t kMaxBitrateBps = 100000000;
+ BitrateAllocation() = default;
+
+ bool set_bitrate(size_t spatial_index,
+ size_t temporal_index,
+ uint32_t bitrate_bps) {
+ assert(spatial_index < kMaxSpatialLayers);
perkj_webrtc 2016/10/21 08:24:28 CHECK or DCHECK instead of assert.
sprang_webrtc 2016/10/25 10:44:25 For some reason, everything here used assert and c
+ assert(temporal_index < kMaxTemporalStreams);
+ if (bitrate_bps > kMaxBitrateBps ||
+ sum - bitrates[spatial_index][temporal_index] + bitrate_bps >
+ kMaxBitrateBps) {
+ return false;
+ }
+ sum -= bitrates[spatial_index][temporal_index];
perkj_webrtc 2016/10/21 08:24:28 please move implementation to a cc file.
sprang_webrtc 2016/10/25 10:44:25 Done.
+ bitrates[spatial_index][temporal_index] = bitrate_bps;
+ sum += bitrate_bps;
+ return true;
+ }
+
+ uint32_t get_bitrate(size_t spatial_index, size_t temporal_index) const {
+ assert(spatial_index < kMaxSpatialLayers);
perkj_webrtc 2016/10/21 08:24:28 dito
sprang_webrtc 2016/10/25 10:44:25 Done.
+ assert(temporal_index < kMaxSimulcastStreams);
+ return bitrates[spatial_index][temporal_index];
+ }
+
+ // Get the sum of all the temporal layer for a specific spatial layer.
+ uint32_t get_spatial_layer_sum(size_t spatial_index) const {
+ assert(spatial_index < kMaxSpatialLayers);
+ uint32_t sum = 0;
+ for (int i = 0; i < kMaxTemporalStreams; ++i)
+ sum += bitrates[spatial_index][i];
+ return sum;
+ }
+
+ uint32_t get_sum_bps() const { return sum; } // Sum of all bitrates.
+ uint32_t get_sum_kbps() const { return (sum + 500) / 1000; }
+
+ inline bool operator==(const BitrateAllocation& other) const {
+ return memcmp(bitrates, other.bitrates, sizeof(bitrates)) == 0;
+ }
+ inline bool operator!=(const BitrateAllocation& other) const {
+ return !(*this == other);
+ }
+
+ private:
+ uint32_t sum = 0;
perkj_webrtc 2016/10/21 08:24:28 sum_
sprang_webrtc 2016/10/25 10:44:25 Done.
+ uint32_t bitrates[kMaxSpatialLayers][kMaxTemporalStreams] = {};
perkj_webrtc 2016/10/21 08:24:28 bitrates_
sprang_webrtc 2016/10/25 10:44:25 Done.
+};
+
// Bandwidth over-use detector options. These are used to drive
// experimentation with bandwidth estimation parameters.
// See modules/remote_bitrate_estimator/overuse_detector.h
« no previous file with comments | « no previous file | webrtc/common_video/BUILD.gn » ('j') | webrtc/common_video/include/video_bitrate_allocator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698