Rename AutoMute to SuspendBelowMinBitrate

Changes all instances throughout the WebRTC stack.

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

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5130 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2013-11-18 12:18:43 +00:00
parent 28bf50f0ec
commit ce8e0936d9
17 changed files with 112 additions and 130 deletions

View File

@ -47,10 +47,10 @@ MediaOptimization::MediaOptimization(int32_t id, Clock* clock)
last_qm_update_time_(0),
last_change_time_(0),
num_layers_(0),
muting_enabled_(false),
video_muted_(false),
muter_threshold_bps_(0),
muter_window_bps_(0) {
suspension_enabled_(false),
video_suspended_(false),
suspension_threshold_bps_(0),
suspension_window_bps_(0) {
memset(send_statistics_, 0, sizeof(send_statistics_));
memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_));
}
@ -193,7 +193,7 @@ uint32_t MediaOptimization::SetTargetRates(uint32_t target_bitrate,
content_->ResetShortTermAvgData();
}
CheckAutoMuteConditions();
CheckSuspendConditions();
return target_bit_rate_;
}
@ -351,7 +351,7 @@ void MediaOptimization::EnableFrameDropper(bool enable) {
bool MediaOptimization::DropFrame() {
// Leak appropriate number of bytes.
frame_dropper_->Leak((uint32_t)(InputFrameRate() + 0.5f));
if (video_muted_) {
if (video_suspended_) {
return true; // Drop all frames when muted.
}
return frame_dropper_->DropFrame();
@ -418,17 +418,13 @@ int32_t MediaOptimization::SelectQuality() {
return VCM_OK;
}
void MediaOptimization::EnableAutoMuting(int threshold_bps, int window_bps) {
void MediaOptimization::SuspendBelowMinBitrate(int threshold_bps,
int window_bps) {
assert(threshold_bps > 0 && window_bps >= 0);
muter_threshold_bps_ = threshold_bps;
muter_window_bps_ = window_bps;
muting_enabled_ = true;
video_muted_ = false;
}
void MediaOptimization::DisableAutoMuting() {
muting_enabled_ = false;
video_muted_ = false;
suspension_threshold_bps_ = threshold_bps;
suspension_window_bps_ = window_bps;
suspension_enabled_ = true;
video_suspended_ = false;
}
// Private methods below this line.
@ -605,19 +601,20 @@ void MediaOptimization::ProcessIncomingFrameRate(int64_t now) {
}
}
void MediaOptimization::CheckAutoMuteConditions() {
// Check conditions for AutoMute. |target_bit_rate_| is in bps.
if (muting_enabled_) {
if (!video_muted_) {
void MediaOptimization::CheckSuspendConditions() {
// Check conditions for SuspendBelowMinBitrate. |target_bit_rate_| is in bps.
if (suspension_enabled_) {
if (!video_suspended_) {
// Check if we just went below the threshold.
if (target_bit_rate_ < muter_threshold_bps_) {
video_muted_ = true;
if (target_bit_rate_ < suspension_threshold_bps_) {
video_suspended_ = true;
}
} else {
// Video is already muted. Check if we just went over the threshold
// Video is already suspended. Check if we just went over the threshold
// with a margin.
if (target_bit_rate_ > muter_threshold_bps_ + muter_window_bps_) {
video_muted_ = false;
if (target_bit_rate_ >
suspension_threshold_bps_ + suspension_window_bps_) {
video_suspended_ = false;
}
}
}

View File

@ -120,18 +120,15 @@ class MediaOptimization {
// Computes new Quality Mode.
int32_t SelectQuality();
// Enables AutoMuter to turn off video when the rate drops below
// Lets the sender suspend video when the rate drops below
// |threshold_bps|, and turns back on when the rate goes back up above
// |threshold_bps| + |window_bps|.
void EnableAutoMuting(int threshold_bps, int window_bps);
// Disables AutoMuter.
void DisableAutoMuting();
void SuspendBelowMinBitrate(int threshold_bps, int window_bps);
// Accessors and mutators.
int32_t max_bit_rate() const { return max_bit_rate_; }
void set_max_payload_size(int32_t mtu) { max_payload_size_ = mtu; }
bool video_muted() const { return video_muted_; }
bool video_suspended() const { return video_suspended_; }
private:
typedef std::list<EncodedFrameSample> FrameSampleList;
@ -161,10 +158,10 @@ class MediaOptimization {
void ProcessIncomingFrameRate(int64_t now);
// Checks conditions for AutoMute. The method compares |target_bit_rate_|
// with the threshold values for AutoMute, and changes the state of
// |video_muted_| accordingly.
void CheckAutoMuteConditions();
// Checks conditions for suspending the video. The method compares
// |target_bit_rate_| with the threshold values for suspension, and changes
// the state of |video_suspended_| accordingly.
void CheckSuspendConditions();
int32_t id_;
Clock* clock_;
@ -195,10 +192,10 @@ class MediaOptimization {
int64_t last_qm_update_time_;
int64_t last_change_time_; // Content/user triggered.
int num_layers_;
bool muting_enabled_;
bool video_muted_;
int muter_threshold_bps_;
int muter_window_bps_;
bool suspension_enabled_;
bool video_suspended_;
int suspension_threshold_bps_;
int suspension_window_bps_;
}; // End of MediaOptimization class declaration.
} // namespace media_optimization

View File

@ -55,15 +55,15 @@ class TestMediaOptimization : public ::testing::Test {
TEST_F(TestMediaOptimization, VerifyMuting) {
// Enable video muter with these limits.
// Mute the video when the rate is below 50 kbps and unmute when it gets above
// 50 + 10 kbps again.
// Enable video suspension with these limits.
// Suspend the video when the rate is below 50 kbps and resume when it gets
// above 50 + 10 kbps again.
const int kThresholdBps = 50000;
const int kWindowBps = 10000;
media_opt_.EnableAutoMuting(kThresholdBps, kWindowBps);
media_opt_.SuspendBelowMinBitrate(kThresholdBps, kWindowBps);
// The video should not be muted from the start.
EXPECT_FALSE(media_opt_.video_muted());
// The video should not be suspended from the start.
EXPECT_FALSE(media_opt_.video_suspended());
int target_bitrate_kbps = 100;
media_opt_.SetTargetRates(target_bitrate_kbps * 1000,
@ -81,7 +81,7 @@ TEST_F(TestMediaOptimization, VerifyMuting) {
// Expect the muter to engage immediately and stay muted.
// Test during 2 seconds.
for (int time = 0; time < 2000; time += frame_time_ms_) {
EXPECT_TRUE(media_opt_.video_muted());
EXPECT_TRUE(media_opt_.video_suspended());
ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true));
}
@ -93,7 +93,7 @@ TEST_F(TestMediaOptimization, VerifyMuting) {
// Expect the muter to stay muted.
// Test during 2 seconds.
for (int time = 0; time < 2000; time += frame_time_ms_) {
EXPECT_TRUE(media_opt_.video_muted());
EXPECT_TRUE(media_opt_.video_suspended());
ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true));
}
@ -104,7 +104,7 @@ TEST_F(TestMediaOptimization, VerifyMuting) {
// Expect the muter to disengage immediately.
// Test during 2 seconds.
for (int time = 0; time < 2000; time += frame_time_ms_) {
EXPECT_FALSE(media_opt_.video_muted());
EXPECT_FALSE(media_opt_.video_suspended());
ASSERT_NO_FATAL_FAILURE(
AddFrameAndAdvanceTime((kThresholdBps + kWindowBps) / 1000, false));
}

View File

@ -197,16 +197,12 @@ class VideoCodingModuleImpl : public VideoCodingModule {
return sender_->StopDebugRecording();
}
virtual void EnableAutoMuting() {
return sender_->EnableAutoMuting();
virtual void SuspendBelowMinBitrate() {
return sender_->SuspendBelowMinBitrate();
}
virtual void DisableAutoMuting() {
return sender_->DisableAutoMuting();
}
virtual bool VideoMuted() const {
return sender_->VideoMuted();
virtual bool VideoSuspended() const {
return sender_->VideoSuspended();
}
virtual int32_t InitializeReceiver() OVERRIDE {

View File

@ -95,9 +95,8 @@ class VideoSender {
int StartDebugRecording(const char* file_name_utf8);
int StopDebugRecording();
void EnableAutoMuting();
void DisableAutoMuting();
bool VideoMuted() const;
void SuspendBelowMinBitrate();
bool VideoSuspended() const;
int32_t TimeUntilNextProcess();
int32_t Process();

View File

@ -422,11 +422,11 @@ int VideoSender::StopDebugRecording() {
return VCM_OK;
}
void VideoSender::EnableAutoMuting() {
void VideoSender::SuspendBelowMinBitrate() {
CriticalSectionScoped cs(_sendCritSect);
VideoCodec current_send_codec;
if (SendCodec(&current_send_codec) != 0) {
assert(false); // Must set a send codec before enabling auto-mute.
assert(false); // Must set a send codec before SuspendBelowMinBitrate.
return;
}
int threshold_bps;
@ -438,17 +438,12 @@ void VideoSender::EnableAutoMuting() {
// Set the hysteresis window to be at 10% of the threshold, but at least
// 10 kbps.
int window_bps = std::max(threshold_bps / 10, 10000);
_mediaOpt.EnableAutoMuting(threshold_bps, window_bps);
_mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps);
}
void VideoSender::DisableAutoMuting() {
bool VideoSender::VideoSuspended() const {
CriticalSectionScoped cs(_sendCritSect);
_mediaOpt.DisableAutoMuting();
}
bool VideoSender::VideoMuted() const {
CriticalSectionScoped cs(_sendCritSect);
return _mediaOpt.video_muted();
return _mediaOpt.video_suspended();
}
} // namespace vcm