diff --git a/webrtc/experiments.h b/webrtc/experiments.h index 0fe1cd1c5..f6d54a079 100644 --- a/webrtc/experiments.h +++ b/webrtc/experiments.h @@ -21,5 +21,12 @@ struct PaddingStrategy { const bool redundant_payloads; }; + +struct RemoteBitrateEstimatorMinRate { + RemoteBitrateEstimatorMinRate() : min_rate(30000) {} + RemoteBitrateEstimatorMinRate(uint32_t min_rate) : min_rate(min_rate) {} + + uint32_t min_rate; +}; } // namespace webrtc #endif // WEBRTC_EXPERIMENTS_H_ diff --git a/webrtc/video_engine/vie_base_impl.cc b/webrtc/video_engine/vie_base_impl.cc index 9b466b2c6..d9276f5dc 100644 --- a/webrtc/video_engine/vie_base_impl.cc +++ b/webrtc/video_engine/vie_base_impl.cc @@ -154,9 +154,15 @@ int ViEBaseImpl::CpuOveruseMeasures(int video_channel, } int ViEBaseImpl::CreateChannel(int& video_channel) { // NOLINT + return CreateChannel(video_channel, static_cast(NULL)); +} + +int ViEBaseImpl::CreateChannel(int& video_channel, // NOLINT + const Config* config) { WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(shared_data_.instance_id()), "%s", __FUNCTION__); - if (shared_data_.channel_manager()->CreateChannel(&video_channel) == -1) { + if (shared_data_.channel_manager()->CreateChannel(&video_channel, + config) == -1) { WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_.instance_id()), "%s: Could not create channel", __FUNCTION__); video_channel = -1; diff --git a/webrtc/video_engine/vie_base_impl.h b/webrtc/video_engine/vie_base_impl.h index 231efc9a6..04c1b40a1 100644 --- a/webrtc/video_engine/vie_base_impl.h +++ b/webrtc/video_engine/vie_base_impl.h @@ -39,6 +39,8 @@ class ViEBaseImpl int* encode_usage_percent, int* capture_queue_delay_ms_per_s); virtual int CreateChannel(int& video_channel); // NOLINT + virtual int CreateChannel(int& video_channel, // NOLINT + const Config* config); virtual int CreateChannel(int& video_channel, // NOLINT int original_channel); virtual int CreateReceiveChannel(int& video_channel, // NOLINT diff --git a/webrtc/video_engine/vie_channel_group.cc b/webrtc/video_engine/vie_channel_group.cc index f079a10e5..f79d65a0c 100644 --- a/webrtc/video_engine/vie_channel_group.cc +++ b/webrtc/video_engine/vie_channel_group.cc @@ -11,6 +11,7 @@ #include "webrtc/video_engine/vie_channel_group.h" #include "webrtc/common.h" +#include "webrtc/experiments.h" #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" @@ -31,13 +32,14 @@ static const uint32_t kTimeOffsetSwitchThreshold = 30; class WrappingBitrateEstimator : public RemoteBitrateEstimator { public: WrappingBitrateEstimator(int engine_id, RemoteBitrateObserver* observer, - Clock* clock, ProcessThread* process_thread) + Clock* clock, ProcessThread* process_thread, + const Config& config) : observer_(observer), clock_(clock), process_thread_(process_thread), crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), engine_id_(engine_id), - min_bitrate_bps_(30000), + min_bitrate_bps_(config.Get().min_rate), rbe_(RemoteBitrateEstimatorFactory().Create(observer_, clock_, min_bitrate_bps_)), using_absolute_send_time_(false), @@ -131,15 +133,23 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator { } // namespace ChannelGroup::ChannelGroup(int engine_id, ProcessThread* process_thread, - const Config& config) + const Config* config) : remb_(new VieRemb()), bitrate_controller_(BitrateController::CreateBitrateController(true)), call_stats_(new CallStats()), - remote_bitrate_estimator_(new WrappingBitrateEstimator(engine_id, - remb_.get(), Clock::GetRealTimeClock(), - process_thread)), encoder_state_feedback_(new EncoderStateFeedback()), + config_(config), + own_config_(), process_thread_(process_thread) { + if (!config) { + own_config_.reset(new Config); + config_ = own_config_.get(); + } + assert(config_); // Must have a valid config pointer here. + remote_bitrate_estimator_.reset( + new WrappingBitrateEstimator(engine_id, remb_.get(), + Clock::GetRealTimeClock(), process_thread, + *config_)), call_stats_->RegisterStatsObserver(remote_bitrate_estimator_.get()); process_thread->RegisterModule(call_stats_.get()); } diff --git a/webrtc/video_engine/vie_channel_group.h b/webrtc/video_engine/vie_channel_group.h index 95a042ef0..036967f2e 100644 --- a/webrtc/video_engine/vie_channel_group.h +++ b/webrtc/video_engine/vie_channel_group.h @@ -32,7 +32,7 @@ class VieRemb; class ChannelGroup { public: ChannelGroup(int engine_id, ProcessThread* process_thread, - const Config& config); + const Config* config); ~ChannelGroup(); void AddChannel(int channel_id); @@ -57,6 +57,9 @@ class ChannelGroup { scoped_ptr remote_bitrate_estimator_; scoped_ptr encoder_state_feedback_; ChannelSet channels_; + const Config* config_; + // Placeholder for the case where this owns the config. + scoped_ptr own_config_; // Registered at construct time and assumed to outlive this class. ProcessThread* process_thread_; diff --git a/webrtc/video_engine/vie_channel_manager.cc b/webrtc/video_engine/vie_channel_manager.cc index b62e2829b..37e469281 100644 --- a/webrtc/video_engine/vie_channel_manager.cc +++ b/webrtc/video_engine/vie_channel_manager.cc @@ -10,6 +10,7 @@ #include "webrtc/video_engine/vie_channel_manager.h" +#include "webrtc/common.h" #include "webrtc/engine_configurations.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" #include "webrtc/modules/utility/interface/process_thread.h" @@ -37,7 +38,7 @@ ViEChannelManager::ViEChannelManager( voice_sync_interface_(NULL), voice_engine_(NULL), module_process_thread_(NULL), - config_(config) { + engine_config_(config) { WEBRTC_TRACE(kTraceMemory, kTraceVideo, ViEId(engine_id), "ViEChannelManager::ViEChannelManager(engine_id: %d)", engine_id); @@ -79,7 +80,8 @@ void ViEChannelManager::SetModuleProcessThread( module_process_thread_ = module_process_thread; } -int ViEChannelManager::CreateChannel(int* channel_id) { +int ViEChannelManager::CreateChannel(int* channel_id, + const Config* channel_group_config) { CriticalSectionScoped cs(channel_id_critsect_); // Get a new channel id. @@ -90,11 +92,11 @@ int ViEChannelManager::CreateChannel(int* channel_id) { // Create a new channel group and add this channel. ChannelGroup* group = new ChannelGroup(engine_id_, module_process_thread_, - config_); + channel_group_config); BitrateController* bitrate_controller = group->GetBitrateController(); ViEEncoder* vie_encoder = new ViEEncoder(engine_id_, new_channel_id, number_of_cores_, - config_, + engine_config_, *module_process_thread_, bitrate_controller); @@ -163,7 +165,7 @@ int ViEChannelManager::CreateChannel(int* channel_id, if (sender) { // We need to create a new ViEEncoder. vie_encoder = new ViEEncoder(engine_id_, new_channel_id, number_of_cores_, - config_, + engine_config_, *module_process_thread_, bitrate_controller); if (!(vie_encoder->Init() && @@ -402,7 +404,7 @@ bool ViEChannelManager::CreateChannelObject( ViEChannel* vie_channel = new ViEChannel(channel_id, engine_id_, number_of_cores_, - config_, + engine_config_, *module_process_thread_, intra_frame_observer, bandwidth_observer, diff --git a/webrtc/video_engine/vie_channel_manager.h b/webrtc/video_engine/vie_channel_manager.h index db9eb1134..83250980c 100644 --- a/webrtc/video_engine/vie_channel_manager.h +++ b/webrtc/video_engine/vie_channel_manager.h @@ -50,7 +50,8 @@ class ViEChannelManager: private ViEManagerBase { void SetModuleProcessThread(ProcessThread* module_process_thread); // Creates a new channel. 'channel_id' will be the id of the created channel. - int CreateChannel(int* channel_id); + int CreateChannel(int* channel_id, + const Config* config); // Creates a new channel grouped with |original_channel|. The new channel // will get its own |ViEEncoder| if |sender| is set to true. It will be a @@ -131,7 +132,7 @@ class ViEChannelManager: private ViEManagerBase { VoiceEngine* voice_engine_; ProcessThread* module_process_thread_; - const Config& config_; + const Config& engine_config_; }; class ViEChannelManagerScoped: private ViEManagerScopedBase {