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

Unified Diff: webrtc/video/vie_encoder.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/video/vie_encoder.cc
diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/vie_encoder.cc
index 95a6f5a18c9f54a8139292fcfd05167cfdc8af3c..0097e823ad02edbc8dd4bcd60d7fc8bed34cea3c 100644
--- a/webrtc/video/vie_encoder.cc
+++ b/webrtc/video/vie_encoder.cc
@@ -19,6 +19,7 @@
#include "webrtc/base/trace_event.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/modules/pacing/paced_sender.h"
+#include "webrtc/modules/video_coding/include/video_bitrate_allocator_factory.h"
#include "webrtc/modules/video_coding/include/video_coding.h"
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
#include "webrtc/video/overuse_frame_detector.h"
@@ -351,6 +352,7 @@ void ViEEncoder::Stop() {
source_proxy_->SetSource(nullptr);
encoder_queue_.PostTask([this] {
RTC_DCHECK_RUN_ON(&encoder_queue_);
+ rate_allocator_.reset();
video_sender_.RegisterExternalEncoder(nullptr, settings_.payload_type,
false);
overuse_detector_.StopCheckForOveruse();
@@ -438,6 +440,8 @@ void ViEEncoder::ReconfigureEncoder() {
codec.startBitrate = std::min(codec.startBitrate, codec.maxBitrate);
codec.expect_encode_from_texture = last_frame_info_->is_texture;
+ rate_allocator_ = VideoBitrateAllocatorFactory::GetBitrateAllocator(&codec);
perkj_webrtc 2016/10/25 11:02:27 This looks much better I think. But one more ques
sprang_webrtc 2016/10/25 11:43:03 Hm, I'm not sure. It'll become a little messy beca
+
bool success = video_sender_.RegisterSendCodec(
&codec, number_of_cores_,
static_cast<uint32_t>(max_data_payload_length_)) == VCM_OK;
@@ -446,17 +450,16 @@ void ViEEncoder::ReconfigureEncoder() {
RTC_DCHECK(success);
}
- rate_allocator_.reset(new SimulcastRateAllocator(codec));
if (stats_proxy_) {
- stats_proxy_->OnEncoderReconfigured(encoder_config_,
- rate_allocator_->GetPreferedBitrate());
+ int frame_rate = stats_proxy_->GetSendFrameRate();
+ if (frame_rate == 0)
+ frame_rate = codec.maxFramerate;
+ stats_proxy_->OnEncoderReconfigured(
+ encoder_config_, rate_allocator_->GetPreferedBitrate(frame_rate));
}
pending_encoder_reconfiguration_ = false;
- if (stats_proxy_) {
- stats_proxy_->OnEncoderReconfigured(encoder_config_,
- rate_allocator_->GetPreferedBitrate());
- }
+
sink_->OnEncoderConfigurationChanged(
std::move(streams), encoder_config_.min_transmit_bitrate_bps);
}
@@ -679,7 +682,7 @@ void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
<< " rtt " << round_trip_time_ms;
video_sender_.SetChannelParameters(bitrate_bps, fraction_lost,
- round_trip_time_ms);
+ round_trip_time_ms, rate_allocator_.get());
encoder_start_bitrate_bps_ =
bitrate_bps != 0 ? bitrate_bps : encoder_start_bitrate_bps_;

Powered by Google App Engine
This is Rietveld 408576698