summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/webrtc/video_engine/vie_channel_group.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/webrtc/video_engine/vie_channel_group.cc')
-rw-r--r--chromium/third_party/webrtc/video_engine/vie_channel_group.cc107
1 files changed, 79 insertions, 28 deletions
diff --git a/chromium/third_party/webrtc/video_engine/vie_channel_group.cc b/chromium/third_party/webrtc/video_engine/vie_channel_group.cc
index f079a10e584..35df3bbf7c1 100644
--- a/chromium/third_party/webrtc/video_engine/vie_channel_group.cc
+++ b/chromium/third_party/webrtc/video_engine/vie_channel_group.cc
@@ -11,12 +11,14 @@
#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"
#include "webrtc/modules/utility/interface/process_thread.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
-#include "webrtc/system_wrappers/interface/trace.h"
+#include "webrtc/system_wrappers/interface/logging.h"
+#include "webrtc/system_wrappers/interface/thread_annotations.h"
#include "webrtc/video_engine/call_stats.h"
#include "webrtc/video_engine/encoder_state_feedback.h"
#include "webrtc/video_engine/vie_channel.h"
@@ -31,14 +33,18 @@ 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),
- rbe_(RemoteBitrateEstimatorFactory().Create(observer_, clock_,
+ min_bitrate_bps_(config.Get<RemoteBitrateEstimatorMinRate>().min_rate),
+ rate_control_type_(kMimdControl),
+ rbe_(RemoteBitrateEstimatorFactory().Create(observer_,
+ clock_,
+ rate_control_type_,
min_bitrate_bps_)),
using_absolute_send_time_(false),
packets_since_absolute_send_time_(0) {
@@ -53,7 +59,7 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator {
int payload_size,
const RTPHeader& header) {
CriticalSectionScoped cs(crit_sect_.get());
- PickEstimator(header);
+ PickEstimatorFromHeader(header);
rbe_->IncomingPacket(arrival_time_ms, payload_size, header);
}
@@ -83,19 +89,32 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator {
return rbe_->LatestEstimate(ssrcs, bitrate_bps);
}
+ virtual bool GetStats(ReceiveBandwidthEstimatorStats* output) const {
+ CriticalSectionScoped cs(crit_sect_.get());
+ return rbe_->GetStats(output);
+ }
+
+ void SetConfig(const webrtc::Config& config) {
+ CriticalSectionScoped cs(crit_sect_.get());
+ RateControlType new_control_type =
+ config.Get<AimdRemoteRateControl>().enabled ? kAimdControl :
+ kMimdControl;
+ if (new_control_type != rate_control_type_) {
+ rate_control_type_ = new_control_type;
+ PickEstimator();
+ }
+ }
+
private:
- // Instantiate RBE for Time Offset or Absolute Send Time extensions.
- void PickEstimator(const RTPHeader& header) {
+ void PickEstimatorFromHeader(const RTPHeader& header)
+ EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) {
if (header.extension.hasAbsoluteSendTime) {
// If we see AST in header, switch RBE strategy immediately.
if (!using_absolute_send_time_) {
- process_thread_->DeRegisterModule(rbe_.get());
- WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(engine_id_),
- "WrappingBitrateEstimator: Switching to absolute send time RBE.");
- rbe_.reset(AbsoluteSendTimeRemoteBitrateEstimatorFactory().Create(
- observer_, clock_, min_bitrate_bps_));
- process_thread_->RegisterModule(rbe_.get());
+ LOG(LS_INFO) <<
+ "WrappingBitrateEstimator: Switching to absolute send time RBE.";
using_absolute_send_time_ = true;
+ PickEstimator();
}
packets_since_absolute_send_time_ = 0;
} else {
@@ -103,25 +122,35 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator {
if (using_absolute_send_time_) {
++packets_since_absolute_send_time_;
if (packets_since_absolute_send_time_ >= kTimeOffsetSwitchThreshold) {
- process_thread_->DeRegisterModule(rbe_.get());
- WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(engine_id_),
- "WrappingBitrateEstimator: Switching to transmission time offset "
- "RBE.");
- rbe_.reset(RemoteBitrateEstimatorFactory().Create(observer_, clock_,
- min_bitrate_bps_));
- process_thread_->RegisterModule(rbe_.get());
+ LOG(LS_INFO) << "WrappingBitrateEstimator: Switching to transmission "
+ << "time offset RBE.";
using_absolute_send_time_ = false;
+ PickEstimator();
}
}
}
}
+ // Instantiate RBE for Time Offset or Absolute Send Time extensions.
+ void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) {
+ process_thread_->DeRegisterModule(rbe_.get());
+ if (using_absolute_send_time_) {
+ rbe_.reset(AbsoluteSendTimeRemoteBitrateEstimatorFactory().Create(
+ observer_, clock_, rate_control_type_, min_bitrate_bps_));
+ } else {
+ rbe_.reset(RemoteBitrateEstimatorFactory().Create(
+ observer_, clock_, rate_control_type_, min_bitrate_bps_));
+ }
+ process_thread_->RegisterModule(rbe_.get());
+ }
+
RemoteBitrateObserver* observer_;
Clock* clock_;
ProcessThread* process_thread_;
scoped_ptr<CriticalSectionWrapper> crit_sect_;
const int engine_id_;
const uint32_t min_bitrate_bps_;
+ RateControlType rate_control_type_;
scoped_ptr<RemoteBitrateEstimator> rbe_;
bool using_absolute_send_time_;
uint32_t packets_since_absolute_send_time_;
@@ -130,23 +159,39 @@ class WrappingBitrateEstimator : public RemoteBitrateEstimator {
};
} // namespace
-ChannelGroup::ChannelGroup(int engine_id, ProcessThread* process_thread,
- const Config& config)
+ChannelGroup::ChannelGroup(int engine_id,
+ ProcessThread* process_thread,
+ const Config* config)
: remb_(new VieRemb()),
- bitrate_controller_(BitrateController::CreateBitrateController(true)),
+ bitrate_controller_(
+ BitrateController::CreateBitrateController(Clock::GetRealTimeClock(),
+ 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) {
- call_stats_->RegisterStatsObserver(remote_bitrate_estimator_.get());
+ 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());
+ process_thread->RegisterModule(bitrate_controller_.get());
}
ChannelGroup::~ChannelGroup() {
- call_stats_->DeregisterStatsObserver(remote_bitrate_estimator_.get());
+ process_thread_->DeRegisterModule(bitrate_controller_.get());
process_thread_->DeRegisterModule(call_stats_.get());
+ call_stats_->DeregisterStatsObserver(remote_bitrate_estimator_.get());
assert(channels_.empty());
assert(!remb_->InUse());
}
@@ -208,4 +253,10 @@ bool ChannelGroup::SetChannelRembStatus(int channel_id, bool sender,
}
return true;
}
+
+void ChannelGroup::SetBandwidthEstimationConfig(const webrtc::Config& config) {
+ WrappingBitrateEstimator* estimator =
+ static_cast<WrappingBitrateEstimator*>(remote_bitrate_estimator_.get());
+ estimator->SetConfig(config);
+}
} // namespace webrtc