diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index f7eaa4aaa7..d1a45be19a 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -241,7 +241,6 @@ if (rtc_include_tests) { "video_coding/include/mock/mock_vcm_callbacks.h", "video_coding/jitter_buffer_unittest.cc", "video_coding/jitter_estimator_tests.cc", - "video_coding/media_optimization_unittest.cc", "video_coding/nack_module_unittest.cc", "video_coding/percentile_filter_unittest.cc", "video_coding/protection_bitrate_calculator_unittest.cc", diff --git a/webrtc/modules/modules.gyp b/webrtc/modules/modules.gyp index dadc5a5e96..f0196e216d 100644 --- a/webrtc/modules/modules.gyp +++ b/webrtc/modules/modules.gyp @@ -369,7 +369,6 @@ 'video_coding/histogram_unittest.cc', 'video_coding/jitter_buffer_unittest.cc', 'video_coding/jitter_estimator_tests.cc', - 'video_coding/media_optimization_unittest.cc', 'video_coding/nack_module_unittest.cc', 'video_coding/video_packet_buffer_unittest.cc', 'video_coding/percentile_filter_unittest.cc', diff --git a/webrtc/modules/video_coding/include/video_coding.h b/webrtc/modules/video_coding/include/video_coding.h index 611206e325..062dda7080 100644 --- a/webrtc/modules/video_coding/include/video_coding.h +++ b/webrtc/modules/video_coding/include/video_coding.h @@ -472,15 +472,6 @@ class VideoCodingModule : public Module { // delayed by at least desired_delay_ms. virtual int SetMinReceiverDelay(int desired_delay_ms) = 0; - // 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|. - virtual void SuspendBelowMinBitrate() = 0; - - // Returns true if SuspendBelowMinBitrate is engaged and the video has been - // suspended due to bandwidth limitations; otherwise false. - virtual bool VideoSuspended() const = 0; - virtual void RegisterPostEncodeImageCallback( EncodedImageCallback* post_encode_callback) = 0; // Releases pending decode calls, permitting faster thread shutdown. diff --git a/webrtc/modules/video_coding/media_optimization.cc b/webrtc/modules/video_coding/media_optimization.cc index 7655649283..594c6650ff 100644 --- a/webrtc/modules/video_coding/media_optimization.cc +++ b/webrtc/modules/video_coding/media_optimization.cc @@ -46,11 +46,7 @@ MediaOptimization::MediaOptimization(Clock* clock) encoded_frame_samples_(), avg_sent_bit_rate_bps_(0), avg_sent_framerate_(0), - num_layers_(0), - suspension_enabled_(false), - video_suspended_(false), - suspension_threshold_bps_(0), - suspension_window_bps_(0) { + num_layers_(0) { memset(send_statistics_, 0, sizeof(send_statistics_)); memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_)); } @@ -136,8 +132,6 @@ uint32_t MediaOptimization::SetTargetRates(uint32_t target_bitrate, static_cast(video_target_bitrate_) / 1000.0f; frame_dropper_->SetRates(target_video_bitrate_kbps, incoming_frame_rate_); - CheckSuspendConditions(); - return video_target_bitrate_; } @@ -203,29 +197,11 @@ void MediaOptimization::EnableFrameDropper(bool enable) { frame_dropper_->Enable(enable); } -void MediaOptimization::SuspendBelowMinBitrate(int threshold_bps, - int window_bps) { - CriticalSectionScoped lock(crit_sect_.get()); - assert(threshold_bps > 0 && window_bps >= 0); - suspension_threshold_bps_ = threshold_bps; - suspension_window_bps_ = window_bps; - suspension_enabled_ = true; - video_suspended_ = false; -} - -bool MediaOptimization::IsVideoSuspended() const { - CriticalSectionScoped lock(crit_sect_.get()); - return video_suspended_; -} - bool MediaOptimization::DropFrame() { CriticalSectionScoped lock(crit_sect_.get()); UpdateIncomingFrameRate(); // Leak appropriate number of bytes. frame_dropper_->Leak((uint32_t)(InputFrameRateInternal() + 0.5f)); - if (video_suspended_) { - return true; // Drop all frames when muted. - } return frame_dropper_->DropFrame(); } @@ -311,26 +287,5 @@ void MediaOptimization::ProcessIncomingFrameRate(int64_t now) { } } } - -void MediaOptimization::CheckSuspendConditions() { - // Check conditions for SuspendBelowMinBitrate. |video_target_bitrate_| is in - // bps. - if (suspension_enabled_) { - if (!video_suspended_) { - // Check if we just went below the threshold. - if (video_target_bitrate_ < suspension_threshold_bps_) { - video_suspended_ = true; - } - } else { - // Video is already suspended. Check if we just went over the threshold - // with a margin. - if (video_target_bitrate_ > - suspension_threshold_bps_ + suspension_window_bps_) { - video_suspended_ = false; - } - } - } -} - } // namespace media_optimization } // namespace webrtc diff --git a/webrtc/modules/video_coding/media_optimization.h b/webrtc/modules/video_coding/media_optimization.h index a14bacdacf..62fc37f6c8 100644 --- a/webrtc/modules/video_coding/media_optimization.h +++ b/webrtc/modules/video_coding/media_optimization.h @@ -59,13 +59,6 @@ class MediaOptimization { int64_t round_trip_time_ms); void EnableFrameDropper(bool enable); - - // 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 SuspendBelowMinBitrate(int threshold_bps, int window_bps); - bool IsVideoSuspended() const; - bool DropFrame(); // Informs Media Optimization of encoded output. @@ -133,10 +126,6 @@ class MediaOptimization { uint32_t avg_sent_bit_rate_bps_ GUARDED_BY(crit_sect_); uint32_t avg_sent_framerate_ GUARDED_BY(crit_sect_); int num_layers_ GUARDED_BY(crit_sect_); - bool suspension_enabled_ GUARDED_BY(crit_sect_); - bool video_suspended_ GUARDED_BY(crit_sect_); - int suspension_threshold_bps_ GUARDED_BY(crit_sect_); - int suspension_window_bps_ GUARDED_BY(crit_sect_); }; } // namespace media_optimization } // namespace webrtc diff --git a/webrtc/modules/video_coding/media_optimization_unittest.cc b/webrtc/modules/video_coding/media_optimization_unittest.cc deleted file mode 100644 index 2263099f23..0000000000 --- a/webrtc/modules/video_coding/media_optimization_unittest.cc +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/modules/video_coding/media_optimization.h" -#include "webrtc/system_wrappers/include/clock.h" - -namespace webrtc { -namespace media_optimization { - -class TestMediaOptimization : public ::testing::Test { - protected: - enum { - kSampleRate = 90000 // RTP timestamps per second. - }; - - // Note: simulated clock starts at 1 seconds, since parts of webrtc use 0 as - // a special case (e.g. frame rate in media optimization). - TestMediaOptimization() - : clock_(1000), - media_opt_(&clock_), - frame_time_ms_(33), - next_timestamp_(0) {} - - // This method mimics what happens in VideoSender::AddVideoFrame. - void AddFrameAndAdvanceTime(uint32_t bitrate_bps, bool expect_frame_drop) { - bool frame_dropped = media_opt_.DropFrame(); - EXPECT_EQ(expect_frame_drop, frame_dropped); - if (!frame_dropped) { - size_t bytes_per_frame = bitrate_bps * frame_time_ms_ / (8 * 1000); - EncodedImage encoded_image; - encoded_image._length = bytes_per_frame; - encoded_image._timeStamp = next_timestamp_; - encoded_image._frameType = kVideoFrameKey; - ASSERT_EQ(VCM_OK, media_opt_.UpdateWithEncodedData(encoded_image)); - } - next_timestamp_ += frame_time_ms_ * kSampleRate / 1000; - clock_.AdvanceTimeMilliseconds(frame_time_ms_); - } - - SimulatedClock clock_; - MediaOptimization media_opt_; - int frame_time_ms_; - uint32_t next_timestamp_; -}; - -TEST_F(TestMediaOptimization, VerifyMuting) { - // 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 uint32_t kThresholdBps = 50000; - const uint32_t kWindowBps = 10000; - media_opt_.SuspendBelowMinBitrate(kThresholdBps, kWindowBps); - - // The video should not be suspended from the start. - EXPECT_FALSE(media_opt_.IsVideoSuspended()); - - uint32_t target_bitrate_kbps = 100; - media_opt_.SetTargetRates(target_bitrate_kbps * 1000, - 0, // Lossrate. - 100); // RTT in ms. - media_opt_.EnableFrameDropper(true); - for (int time = 0; time < 2000; time += frame_time_ms_) { - ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, false)); - } - - // Set the target rate below the limit for muting. - media_opt_.SetTargetRates(kThresholdBps - 1000, - 0, // Lossrate. - 100); // RTT in ms. - // 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_.IsVideoSuspended()); - ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true)); - } - - // Set the target above the limit for muting, but not above the - // limit + window. - media_opt_.SetTargetRates(kThresholdBps + 1000, - 0, // Lossrate. - 100); // RTT in ms. - // Expect the muter to stay muted. - // Test during 2 seconds. - for (int time = 0; time < 2000; time += frame_time_ms_) { - EXPECT_TRUE(media_opt_.IsVideoSuspended()); - ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true)); - } - - // Set the target above limit + window. - media_opt_.SetTargetRates(kThresholdBps + kWindowBps + 1000, - 0, // Lossrate. - 100); // RTT in ms. - // Expect the muter to disengage immediately. - // Test during 2 seconds. - for (int time = 0; time < 2000; time += frame_time_ms_) { - EXPECT_FALSE(media_opt_.IsVideoSuspended()); - ASSERT_NO_FATAL_FAILURE( - AddFrameAndAdvanceTime((kThresholdBps + kWindowBps) / 1000, false)); - } -} - -} // namespace media_optimization -} // namespace webrtc diff --git a/webrtc/modules/video_coding/video_coding_impl.cc b/webrtc/modules/video_coding/video_coding_impl.cc index bb81ba9f9e..8955e54db7 100644 --- a/webrtc/modules/video_coding/video_coding_impl.cc +++ b/webrtc/modules/video_coding/video_coding_impl.cc @@ -152,12 +152,6 @@ class VideoCodingModuleImpl : public VideoCodingModule { return sender_.EnableFrameDropper(enable); } - void SuspendBelowMinBitrate() override { - return sender_.SuspendBelowMinBitrate(); - } - - bool VideoSuspended() const override { return sender_.VideoSuspended(); } - int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec, int32_t numberOfCores, bool requireKeyFrame) override { diff --git a/webrtc/modules/video_coding/video_coding_impl.h b/webrtc/modules/video_coding/video_coding_impl.h index 6f48a23dbb..00bce1b99c 100644 --- a/webrtc/modules/video_coding/video_coding_impl.h +++ b/webrtc/modules/video_coding/video_coding_impl.h @@ -89,9 +89,6 @@ class VideoSender : public Module { int32_t IntraFrameRequest(size_t stream_index); int32_t EnableFrameDropper(bool enable); - void SuspendBelowMinBitrate(); - bool VideoSuspended() const; - int64_t TimeUntilNextProcess() override; void Process() override; diff --git a/webrtc/modules/video_coding/video_sender.cc b/webrtc/modules/video_coding/video_sender.cc index d7d8110921..f26be34776 100644 --- a/webrtc/modules/video_coding/video_sender.cc +++ b/webrtc/modules/video_coding/video_sender.cc @@ -364,23 +364,5 @@ int32_t VideoSender::EnableFrameDropper(bool enable) { _mediaOpt.EnableFrameDropper(enable); return VCM_OK; } - -void VideoSender::SuspendBelowMinBitrate() { - RTC_DCHECK(main_thread_.CalledOnValidThread()); - int threshold_bps; - if (current_codec_.numberOfSimulcastStreams == 0) { - threshold_bps = current_codec_.minBitrate * 1000; - } else { - threshold_bps = current_codec_.simulcastStream[0].minBitrate * 1000; - } - // 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.SuspendBelowMinBitrate(threshold_bps, window_bps); -} - -bool VideoSender::VideoSuspended() const { - return _mediaOpt.IsVideoSuspended(); -} } // namespace vcm } // namespace webrtc