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

Unified Diff: webrtc/modules/video_coding/video_bitrate_allocator_factory.cc

Issue 2434073003: Extract bitrate allocation of spatial/temporal layers out of codec impl. (Closed)
Patch Set: Fixed sign mismatch 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
Index: webrtc/modules/video_coding/video_bitrate_allocator_factory.cc
diff --git a/webrtc/modules/video_coding/video_bitrate_allocator_factory.cc b/webrtc/modules/video_coding/video_bitrate_allocator_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d97755c8a3344b979250522214a16fdd14da8be8
--- /dev/null
+++ b/webrtc/modules/video_coding/video_bitrate_allocator_factory.cc
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2016 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.
+ */
+
+#include "webrtc/modules/video_coding/include/video_bitrate_allocator_factory.h"
+
+#include "webrtc/base/basictypes.h"
+#include "webrtc/common_video/include/video_bitrate_allocator.h"
+#include "webrtc/common_types.h"
+#include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h"
+#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
+#include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h"
+#include "webrtc/modules/video_coding/utility/default_video_bitrate_allocator.h"
+#include "webrtc/system_wrappers/include/clock.h"
+
+namespace webrtc {
+
+struct ScreenshareTemporalLayersFactory : webrtc::TemporalLayersFactory {
+ ScreenshareTemporalLayersFactory() {}
+ virtual ~ScreenshareTemporalLayersFactory() {}
+
+ virtual webrtc::TemporalLayers* Create(int simulcast_id,
+ int num_temporal_layers,
+ uint8_t initial_tl0_pic_idx) const {
+ webrtc::TemporalLayers* tl = new webrtc::ScreenshareLayers(
+ num_temporal_layers, rand(), webrtc::Clock::GetRealTimeClock());
+ if (listener_)
+ listener_->OnTemporalLayersCreated(simulcast_id, tl);
+ return tl;
+ }
+};
+
+std::unique_ptr<VideoBitrateAllocator>
+VideoBitrateAllocatorFactory::GetBitrateAllocator(VideoCodec* codec) {
perkj_webrtc 2016/10/27 12:57:31 it feels weird that GetBitrateAllocator take a non
sprang_webrtc 2016/11/01 18:03:16 I don't think it makes sense to have the rate allo
+ std::unique_ptr<VideoBitrateAllocator> rate_allocator;
+
+ switch (codec->codecType) {
+ case kVideoCodecVP8: {
+ // Set up default VP8 temporal layer factory, if not provided.
+ std::unique_ptr<TemporalLayersFactory> tl_factory;
+ if (!codec->codecSpecific.VP8.tl_factory) {
+ if (codec->mode == kScreensharing &&
+ codec->numberOfSimulcastStreams == 1 &&
+ codec->codecSpecific.VP8.numberOfTemporalLayers == 2) {
+ // Conference mode temporal layering for screen content.
+ tl_factory.reset(new ScreenshareTemporalLayersFactory());
+ } else {
+ // Standard video temporal layers.
+ tl_factory.reset(new TemporalLayersFactory());
+ }
+ codec->codecSpecific.VP8.tl_factory = tl_factory.get();
+ }
+ rate_allocator.reset(
+ new SimulcastRateAllocator(*codec, std::move(tl_factory)));
+ codec->codecSpecific.VP8.tl_factory->SetListener(
+ static_cast<SimulcastRateAllocator*>(rate_allocator.get()));
+ } break;
+ default:
+ rate_allocator.reset(new DefaultVideoBitrateAllocator(*codec));
+ }
+
+ return rate_allocator;
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698