Connect webrtc::Config to WrappingBitrateEstimator

This is the second CL for this change. Connection to the ViE API
remains to be done.

BUG=2698
R=mflodman@webrtc.org, stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/5769004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5455 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org 2014-01-29 08:47:15 +00:00
parent c7c7a531f3
commit 41907748cb
7 changed files with 47 additions and 16 deletions

View File

@ -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_

View File

@ -154,9 +154,15 @@ int ViEBaseImpl::CpuOveruseMeasures(int video_channel,
}
int ViEBaseImpl::CreateChannel(int& video_channel) { // NOLINT
return CreateChannel(video_channel, static_cast<const Config*>(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;

View File

@ -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

View File

@ -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<RemoteBitrateEstimatorMinRate>().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());
}

View File

@ -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<RemoteBitrateEstimator> remote_bitrate_estimator_;
scoped_ptr<EncoderStateFeedback> encoder_state_feedback_;
ChannelSet channels_;
const Config* config_;
// Placeholder for the case where this owns the config.
scoped_ptr<Config> own_config_;
// Registered at construct time and assumed to outlive this class.
ProcessThread* process_thread_;

View File

@ -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,

View File

@ -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 {