Merge DegradationPreference enums.

This replaces webrtc::VideoSendStream::DegradationPreference with
webrtc::DegradationPreference, and adds "DISABLED".

It's still not wired up from RtpSenderInterface::SetParameters to the
underlying video engine; that would be the next step.

Bug: webrtc:8830
Change-Id: I582ffd04eaef33c73d9892e52e789804c933b864
Reviewed-on: https://webrtc-review.googlesource.com/77024
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23276}
This commit is contained in:
Taylor Brandstetter 2018-05-16 14:20:41 -07:00 committed by Commit Bot
parent cd469a4ce5
commit 49fcc10de6
18 changed files with 189 additions and 247 deletions

View File

@ -66,10 +66,27 @@ enum class DtxStatus {
ENABLED, ENABLED,
}; };
// Based on the spec in
// https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference.
// These options are enforced on a best-effort basis. For instance, all of
// these options may suffer some frame drops in order to avoid queuing.
// TODO(sprang): Look into possibility of more strictly enforcing the
// maintain-framerate option.
// TODO(deadbeef): Default to "balanced", as the spec indicates?
enum class DegradationPreference { enum class DegradationPreference {
// Don't take any actions based on over-utilization signals. Not part of the
// web API.
DISABLED,
// On over-use, request lower frame rate, possibly causing frame drops.
MAINTAIN_FRAMERATE, MAINTAIN_FRAMERATE,
// On over-use, request lower resolution, possibly causing down-scaling.
MAINTAIN_RESOLUTION, MAINTAIN_RESOLUTION,
// Try to strike a "pleasing" balance between frame rate or resolution.
BALANCED, BALANCED,
// TODO(deadbeef): Remove once downstream code referencing
// "webrtc::VideoSendStream::DegradationPreference::kMaintainResolution" is
// updated.
kMaintainResolution = MAINTAIN_RESOLUTION
}; };
extern const double kDefaultBitratePriority; extern const double kDefaultBitratePriority;

View File

@ -171,9 +171,8 @@ class BitrateEstimatorTest : public test::CallTest {
frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create(
kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt, kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt,
kDefaultFramerate, Clock::GetRealTimeClock())); kDefaultFramerate, Clock::GetRealTimeClock()));
send_stream_->SetSource( send_stream_->SetSource(frame_generator_capturer_.get(),
frame_generator_capturer_.get(), DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
send_stream_->Start(); send_stream_->Start();
frame_generator_capturer_->Start(); frame_generator_capturer_->Start();

View File

@ -266,22 +266,10 @@ class VideoSendStream {
// When a stream is stopped, it can't receive, process or deliver packets. // When a stream is stopped, it can't receive, process or deliver packets.
virtual void Stop() = 0; virtual void Stop() = 0;
// Based on the spec in // TODO(deadbeef): Remove once downstream code referencing
// https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference. // "webrtc::VideoSendStream::DegradationPreference::kMaintainResolution" is
// These options are enforced on a best-effort basis. For instance, all of // updated.
// these options may suffer some frame drops in order to avoid queuing. using DegradationPreference = webrtc::DegradationPreference;
// TODO(sprang): Look into possibility of more strictly enforcing the
// maintain-framerate option.
enum class DegradationPreference {
// Don't take any actions based on over-utilization signals.
kDegradationDisabled,
// On over-use, request lower frame rate, possibly causing frame drops.
kMaintainResolution,
// On over-use, request lower resolution, possibly causing down-scaling.
kMaintainFramerate,
// Try to strike a "pleasing" balance between frame rate or resolution.
kBalanced,
};
virtual void SetSource( virtual void SetSource(
rtc::VideoSourceInterface<webrtc::VideoFrame>* source, rtc::VideoSourceInterface<webrtc::VideoFrame>* source,

View File

@ -270,26 +270,25 @@ void FakeVideoSendStream::Stop() {
void FakeVideoSendStream::SetSource( void FakeVideoSendStream::SetSource(
rtc::VideoSourceInterface<webrtc::VideoFrame>* source, rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
const webrtc::VideoSendStream::DegradationPreference& const webrtc::DegradationPreference& degradation_preference) {
degradation_preference) {
RTC_DCHECK(source != source_); RTC_DCHECK(source != source_);
if (source_) if (source_)
source_->RemoveSink(this); source_->RemoveSink(this);
source_ = source; source_ = source;
switch (degradation_preference) { switch (degradation_preference) {
case DegradationPreference::kMaintainFramerate: case webrtc::DegradationPreference::MAINTAIN_FRAMERATE:
resolution_scaling_enabled_ = true; resolution_scaling_enabled_ = true;
framerate_scaling_enabled_ = false; framerate_scaling_enabled_ = false;
break; break;
case DegradationPreference::kMaintainResolution: case webrtc::DegradationPreference::MAINTAIN_RESOLUTION:
resolution_scaling_enabled_ = false; resolution_scaling_enabled_ = false;
framerate_scaling_enabled_ = true; framerate_scaling_enabled_ = true;
break; break;
case DegradationPreference::kBalanced: case webrtc::DegradationPreference::BALANCED:
resolution_scaling_enabled_ = true; resolution_scaling_enabled_ = true;
framerate_scaling_enabled_ = true; framerate_scaling_enabled_ = true;
break; break;
case DegradationPreference::kDegradationDisabled: case webrtc::DegradationPreference::DISABLED:
resolution_scaling_enabled_ = false; resolution_scaling_enabled_ = false;
framerate_scaling_enabled_ = false; framerate_scaling_enabled_ = false;
break; break;

View File

@ -163,9 +163,9 @@ class FakeVideoSendStream final
const std::vector<bool> active_layers) override; const std::vector<bool> active_layers) override;
void Start() override; void Start() override;
void Stop() override; void Stop() override;
void SetSource(rtc::VideoSourceInterface<webrtc::VideoFrame>* source, void SetSource(
const webrtc::VideoSendStream::DegradationPreference& rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
degradation_preference) override; const webrtc::DegradationPreference& degradation_preference) override;
webrtc::VideoSendStream::Stats GetStats() override; webrtc::VideoSendStream::Stats GetStats() override;
void ReconfigureVideoEncoder(webrtc::VideoEncoderConfig config) override; void ReconfigureVideoEncoder(webrtc::VideoEncoderConfig config) override;

View File

@ -39,8 +39,6 @@
#include "rtc_base/trace_event.h" #include "rtc_base/trace_event.h"
#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/field_trial.h"
using DegradationPreference = webrtc::VideoSendStream::DegradationPreference;
namespace cricket { namespace cricket {
// Hack in order to pass in |receive_stream_id| to legacy clients. // Hack in order to pass in |receive_stream_id| to legacy clients.
@ -1686,7 +1684,7 @@ bool WebRtcVideoChannel::WebRtcVideoSendStream::SetVideoSend(
} }
if (source_ && stream_) { if (source_ && stream_) {
stream_->SetSource(nullptr, DegradationPreference::kDegradationDisabled); stream_->SetSource(nullptr, webrtc::DegradationPreference::DISABLED);
} }
// Switch to the new source. // Switch to the new source.
source_ = source; source_ = source;
@ -1696,23 +1694,25 @@ bool WebRtcVideoChannel::WebRtcVideoSendStream::SetVideoSend(
return true; return true;
} }
webrtc::VideoSendStream::DegradationPreference webrtc::DegradationPreference
WebRtcVideoChannel::WebRtcVideoSendStream::GetDegradationPreference() const { WebRtcVideoChannel::WebRtcVideoSendStream::GetDegradationPreference() const {
// Do not adapt resolution for screen content as this will likely // Do not adapt resolution for screen content as this will likely
// result in blurry and unreadable text. // result in blurry and unreadable text.
// |this| acts like a VideoSource to make sure SinkWants are handled on the // |this| acts like a VideoSource to make sure SinkWants are handled on the
// correct thread. // correct thread.
DegradationPreference degradation_preference; webrtc::DegradationPreference degradation_preference;
if (!enable_cpu_overuse_detection_) { if (!enable_cpu_overuse_detection_) {
degradation_preference = DegradationPreference::kDegradationDisabled; degradation_preference = webrtc::DegradationPreference::DISABLED;
} else { } else {
if (parameters_.options.is_screencast.value_or(false)) { if (parameters_.options.is_screencast.value_or(false)) {
degradation_preference = DegradationPreference::kMaintainResolution; degradation_preference =
webrtc::DegradationPreference::MAINTAIN_RESOLUTION;
} else if (webrtc::field_trial::IsEnabled( } else if (webrtc::field_trial::IsEnabled(
"WebRTC-Video-BalancedDegradation")) { "WebRTC-Video-BalancedDegradation")) {
degradation_preference = DegradationPreference::kBalanced; degradation_preference = webrtc::DegradationPreference::BALANCED;
} else { } else {
degradation_preference = DegradationPreference::kMaintainFramerate; degradation_preference =
webrtc::DegradationPreference::MAINTAIN_FRAMERATE;
} }
} }
return degradation_preference; return degradation_preference;

View File

@ -324,8 +324,8 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport {
// and whether or not the encoding in |rtp_parameters_| is active. // and whether or not the encoding in |rtp_parameters_| is active.
void UpdateSendState(); void UpdateSendState();
webrtc::VideoSendStream::DegradationPreference GetDegradationPreference() webrtc::DegradationPreference GetDegradationPreference() const
const RTC_EXCLUSIVE_LOCKS_REQUIRED(&thread_checker_); RTC_EXCLUSIVE_LOCKS_REQUIRED(&thread_checker_);
rtc::ThreadChecker thread_checker_; rtc::ThreadChecker thread_checker_;
rtc::AsyncInvoker invoker_; rtc::AsyncInvoker invoker_;

View File

@ -323,9 +323,8 @@ void CallTest::CreateFrameGeneratorCapturerWithDrift(Clock* clock,
int height) { int height) {
frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create(
width, height, rtc::nullopt, rtc::nullopt, framerate * speed, clock)); width, height, rtc::nullopt, rtc::nullopt, framerate * speed, clock));
video_send_stream_->SetSource( video_send_stream_->SetSource(frame_generator_capturer_.get(),
frame_generator_capturer_.get(), DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
} }
void CallTest::CreateFrameGeneratorCapturer(int framerate, void CallTest::CreateFrameGeneratorCapturer(int framerate,
@ -333,9 +332,8 @@ void CallTest::CreateFrameGeneratorCapturer(int framerate,
int height) { int height) {
frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create(
width, height, rtc::nullopt, rtc::nullopt, framerate, clock_)); width, height, rtc::nullopt, rtc::nullopt, framerate, clock_));
video_send_stream_->SetSource( video_send_stream_->SetSource(frame_generator_capturer_.get(),
frame_generator_capturer_.get(), DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
} }
void CallTest::CreateFakeAudioDevices( void CallTest::CreateFakeAudioDevices(

View File

@ -135,9 +135,8 @@ TEST_P(CallOperationEndToEndTest, RendersSingleDelayedFrame) {
std::unique_ptr<test::FrameGenerator> frame_generator( std::unique_ptr<test::FrameGenerator> frame_generator(
test::FrameGenerator::CreateSquareGenerator( test::FrameGenerator::CreateSquareGenerator(
kWidth, kHeight, rtc::nullopt, rtc::nullopt)); kWidth, kHeight, rtc::nullopt, rtc::nullopt));
video_send_stream_->SetSource( video_send_stream_->SetSource(&frame_forwarder,
&frame_forwarder, DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
frame_forwarder.IncomingCapturedFrame(*frame_generator->NextFrame()); frame_forwarder.IncomingCapturedFrame(*frame_generator->NextFrame());
}); });
@ -192,9 +191,8 @@ TEST_P(CallOperationEndToEndTest, TransmitsFirstFrame) {
frame_generator = test::FrameGenerator::CreateSquareGenerator( frame_generator = test::FrameGenerator::CreateSquareGenerator(
kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt); kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt);
video_send_stream_->SetSource( video_send_stream_->SetSource(&frame_forwarder,
&frame_forwarder, DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
frame_forwarder.IncomingCapturedFrame(*frame_generator->NextFrame()); frame_forwarder.IncomingCapturedFrame(*frame_generator->NextFrame());
}); });
@ -271,8 +269,8 @@ TEST_P(CallOperationEndToEndTest, ObserversEncodedFrames) {
frame_generator = test::FrameGenerator::CreateSquareGenerator( frame_generator = test::FrameGenerator::CreateSquareGenerator(
kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt); kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt);
video_send_stream_->SetSource( video_send_stream_->SetSource(&forwarder,
&forwarder, VideoSendStream::DegradationPreference::kMaintainFramerate); DegradationPreference::MAINTAIN_FRAMERATE);
forwarder.IncomingCapturedFrame(*frame_generator->NextFrame()); forwarder.IncomingCapturedFrame(*frame_generator->NextFrame());
}); });

View File

@ -101,9 +101,8 @@ void MultiStreamTester::RunTest() {
frame_generators[i] = test::FrameGeneratorCapturer::Create( frame_generators[i] = test::FrameGeneratorCapturer::Create(
width, height, rtc::nullopt, rtc::nullopt, 30, width, height, rtc::nullopt, rtc::nullopt, 30,
Clock::GetRealTimeClock()); Clock::GetRealTimeClock());
send_streams[i]->SetSource( send_streams[i]->SetSource(frame_generators[i],
frame_generators[i], DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
frame_generators[i]->Start(); frame_generators[i]->Start();
} }
}); });

View File

@ -560,9 +560,8 @@ TEST_F(StatsEndToEndTest, MAYBE_ContentTypeSwitches) {
sender_call_->DestroyVideoSendStream(video_send_stream_); sender_call_->DestroyVideoSendStream(video_send_stream_);
video_send_stream_ = sender_call_->CreateVideoSendStream( video_send_stream_ = sender_call_->CreateVideoSendStream(
video_send_config_.Copy(), encoder_config_with_screenshare.Copy()); video_send_config_.Copy(), encoder_config_with_screenshare.Copy());
video_send_stream_->SetSource( video_send_stream_->SetSource(frame_generator_capturer_.get(),
frame_generator_capturer_.get(), DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
video_send_stream_->Start(); video_send_stream_->Start();
}); });

View File

@ -19,7 +19,7 @@ class MockVideoStreamEncoder : public VideoStreamEncoderInterface {
public: public:
MOCK_METHOD2(SetSource, MOCK_METHOD2(SetSource,
void(rtc::VideoSourceInterface<VideoFrame>*, void(rtc::VideoSourceInterface<VideoFrame>*,
const VideoSendStream::DegradationPreference&)); const DegradationPreference&));
MOCK_METHOD2(SetSink, void(EncoderSink*, bool)); MOCK_METHOD2(SetSink, void(EncoderSink*, bool));
MOCK_METHOD1(SetStartBitrate, void(int)); MOCK_METHOD1(SetStartBitrate, void(int));
MOCK_METHOD0(SendKeyFrame, void()); MOCK_METHOD0(SendKeyFrame, void());

View File

@ -1518,8 +1518,7 @@ void VideoQualityTest::SetupVideo(Transport* send_transport,
// Fill out codec settings. // Fill out codec settings.
video_encoder_configs_[video_idx].content_type = video_encoder_configs_[video_idx].content_type =
VideoEncoderConfig::ContentType::kScreen; VideoEncoderConfig::ContentType::kScreen;
degradation_preference_ = degradation_preference_ = DegradationPreference::MAINTAIN_RESOLUTION;
VideoSendStream::DegradationPreference::kMaintainResolution;
if (params_.video[video_idx].codec == "VP8") { if (params_.video[video_idx].codec == "VP8") {
VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings();
vp8_settings.denoisingOn = false; vp8_settings.denoisingOn = false;

View File

@ -179,8 +179,8 @@ class VideoQualityTest : public test::CallTest {
int receive_logs_; int receive_logs_;
int send_logs_; int send_logs_;
VideoSendStream::DegradationPreference degradation_preference_ = DegradationPreference degradation_preference_ =
VideoSendStream::DegradationPreference::kMaintainFramerate; DegradationPreference::MAINTAIN_FRAMERATE;
Params params_; Params params_;
std::unique_ptr<webrtc::RtcEventLog> recv_event_log_; std::unique_ptr<webrtc::RtcEventLog> recv_event_log_;

View File

@ -1864,9 +1864,8 @@ TEST_F(VideoSendStreamTest, RespectsMinTransmitBitrateAfterContentSwitch) {
video_encoder_config_ = encoder_config.Copy(); video_encoder_config_ = encoder_config.Copy();
video_send_stream_ = sender_call_->CreateVideoSendStream( video_send_stream_ = sender_call_->CreateVideoSendStream(
video_send_config_.Copy(), video_encoder_config_.Copy()); video_send_config_.Copy(), video_encoder_config_.Copy());
video_send_stream_->SetSource( video_send_stream_->SetSource(frame_generator_capturer_.get(),
frame_generator_capturer_.get(), DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
Start(); Start();
}); });
}; };
@ -2110,9 +2109,7 @@ TEST_F(VideoSendStreamTest, VideoSendStreamStopSetEncoderRateToZero) {
CreateVideoStreams(); CreateVideoStreams();
// Inject a frame, to force encoder creation. // Inject a frame, to force encoder creation.
video_send_stream_->Start(); video_send_stream_->Start();
video_send_stream_->SetSource( video_send_stream_->SetSource(&forwarder, DegradationPreference::DISABLED);
&forwarder,
VideoSendStream::DegradationPreference::kDegradationDisabled);
forwarder.IncomingCapturedFrame(CreateVideoFrame(640, 480, 4)); forwarder.IncomingCapturedFrame(CreateVideoFrame(640, 480, 4));
}); });
@ -2164,9 +2161,7 @@ TEST_F(VideoSendStreamTest, VideoSendStreamUpdateActiveSimulcastLayers) {
// Inject a frame, to force encoder creation. // Inject a frame, to force encoder creation.
video_send_stream_->Start(); video_send_stream_->Start();
video_send_stream_->SetSource( video_send_stream_->SetSource(&forwarder, DegradationPreference::DISABLED);
&forwarder,
VideoSendStream::DegradationPreference::kDegradationDisabled);
forwarder.IncomingCapturedFrame(CreateVideoFrame(640, 480, 4)); forwarder.IncomingCapturedFrame(CreateVideoFrame(640, 480, 4));
}); });
@ -2262,8 +2257,8 @@ TEST_F(VideoSendStreamTest, CapturesTextureAndVideoFrames) {
video_send_stream_->Start(); video_send_stream_->Start();
test::FrameForwarder forwarder; test::FrameForwarder forwarder;
video_send_stream_->SetSource( video_send_stream_->SetSource(&forwarder,
&forwarder, VideoSendStream::DegradationPreference::kMaintainFramerate); DegradationPreference::MAINTAIN_FRAMERATE);
for (size_t i = 0; i < input_frames.size(); i++) { for (size_t i = 0; i < input_frames.size(); i++) {
forwarder.IncomingCapturedFrame(input_frames[i]); forwarder.IncomingCapturedFrame(input_frames[i]);
// Wait until the output frame is received before sending the next input // Wait until the output frame is received before sending the next input
@ -2271,8 +2266,8 @@ TEST_F(VideoSendStreamTest, CapturesTextureAndVideoFrames) {
observer.WaitOutputFrame(); observer.WaitOutputFrame();
} }
video_send_stream_->Stop(); video_send_stream_->Stop();
video_send_stream_->SetSource( video_send_stream_->SetSource(nullptr,
nullptr, VideoSendStream::DegradationPreference::kMaintainFramerate); DegradationPreference::MAINTAIN_FRAMERATE);
}); });
// Test if the input and output frames are the same. render_time_ms and // Test if the input and output frames are the same. render_time_ms and
@ -3619,8 +3614,8 @@ void VideoSendStreamTest::TestRequestSourceRotateVideo(
CreateVideoStreams(); CreateVideoStreams();
test::FrameForwarder forwarder; test::FrameForwarder forwarder;
video_send_stream_->SetSource( video_send_stream_->SetSource(&forwarder,
&forwarder, VideoSendStream::DegradationPreference::kMaintainFramerate); DegradationPreference::MAINTAIN_FRAMERATE);
EXPECT_TRUE(forwarder.sink_wants().rotation_applied != EXPECT_TRUE(forwarder.sink_wants().rotation_applied !=
support_orientation_ext); support_orientation_ext);
@ -3991,9 +3986,8 @@ TEST_F(VideoSendStreamTest, SwitchesToScreenshareAndBack) {
video_encoder_config_ = encoder_config.Copy(); video_encoder_config_ = encoder_config.Copy();
video_send_stream_ = sender_call_->CreateVideoSendStream( video_send_stream_ = sender_call_->CreateVideoSendStream(
video_send_config_.Copy(), video_encoder_config_.Copy()); video_send_config_.Copy(), video_encoder_config_.Copy());
video_send_stream_->SetSource( video_send_stream_->SetSource(frame_generator_capturer_.get(),
frame_generator_capturer_.get(), DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
test->OnVideoStreamsCreated(video_send_stream_, video_receive_streams_); test->OnVideoStreamsCreated(video_send_stream_, video_receive_streams_);
Start(); Start();
}); });

View File

@ -48,7 +48,7 @@ const int64_t kPendingFrameTimeoutMs = 1000;
// to try and achieve desired bitrate. // to try and achieve desired bitrate.
const int kMaxInitialFramedrop = 4; const int kMaxInitialFramedrop = 4;
// Initial limits for kBalanced degradation preference. // Initial limits for BALANCED degradation preference.
int MinFps(int pixels) { int MinFps(int pixels) {
if (pixels <= 320 * 240) { if (pixels <= 320 * 240) {
return 7; return 7;
@ -71,20 +71,14 @@ int MaxFps(int pixels) {
} }
} }
bool IsResolutionScalingEnabled( bool IsResolutionScalingEnabled(DegradationPreference degradation_preference) {
VideoSendStream::DegradationPreference degradation_preference) { return degradation_preference == DegradationPreference::MAINTAIN_FRAMERATE ||
return degradation_preference == degradation_preference == DegradationPreference::BALANCED;
VideoSendStream::DegradationPreference::kMaintainFramerate ||
degradation_preference ==
VideoSendStream::DegradationPreference::kBalanced;
} }
bool IsFramerateScalingEnabled( bool IsFramerateScalingEnabled(DegradationPreference degradation_preference) {
VideoSendStream::DegradationPreference degradation_preference) { return degradation_preference == DegradationPreference::MAINTAIN_RESOLUTION ||
return degradation_preference == degradation_preference == DegradationPreference::BALANCED;
VideoSendStream::DegradationPreference::kMaintainResolution ||
degradation_preference ==
VideoSendStream::DegradationPreference::kBalanced;
} }
// TODO(pbos): Lower these thresholds (to closer to 100%) when we handle // TODO(pbos): Lower these thresholds (to closer to 100%) when we handle
@ -117,13 +111,11 @@ class VideoStreamEncoder::VideoSourceProxy {
public: public:
explicit VideoSourceProxy(VideoStreamEncoder* video_stream_encoder) explicit VideoSourceProxy(VideoStreamEncoder* video_stream_encoder)
: video_stream_encoder_(video_stream_encoder), : video_stream_encoder_(video_stream_encoder),
degradation_preference_( degradation_preference_(DegradationPreference::DISABLED),
VideoSendStream::DegradationPreference::kDegradationDisabled),
source_(nullptr) {} source_(nullptr) {}
void SetSource( void SetSource(rtc::VideoSourceInterface<VideoFrame>* source,
rtc::VideoSourceInterface<VideoFrame>* source, const DegradationPreference& degradation_preference) {
const VideoSendStream::DegradationPreference& degradation_preference) {
// Called on libjingle's worker thread. // Called on libjingle's worker thread.
RTC_DCHECK_CALLED_SEQUENTIALLY(&main_checker_); RTC_DCHECK_CALLED_SEQUENTIALLY(&main_checker_);
rtc::VideoSourceInterface<VideoFrame>* old_source = nullptr; rtc::VideoSourceInterface<VideoFrame>* old_source = nullptr;
@ -294,16 +286,16 @@ class VideoStreamEncoder::VideoSourceProxy {
// Clear any constraints from the current sink wants that don't apply to // Clear any constraints from the current sink wants that don't apply to
// the used degradation_preference. // the used degradation_preference.
switch (degradation_preference_) { switch (degradation_preference_) {
case VideoSendStream::DegradationPreference::kBalanced: case DegradationPreference::BALANCED:
break; break;
case VideoSendStream::DegradationPreference::kMaintainFramerate: case DegradationPreference::MAINTAIN_FRAMERATE:
wants.max_framerate_fps = std::numeric_limits<int>::max(); wants.max_framerate_fps = std::numeric_limits<int>::max();
break; break;
case VideoSendStream::DegradationPreference::kMaintainResolution: case DegradationPreference::MAINTAIN_RESOLUTION:
wants.max_pixel_count = std::numeric_limits<int>::max(); wants.max_pixel_count = std::numeric_limits<int>::max();
wants.target_pixel_count.reset(); wants.target_pixel_count.reset();
break; break;
case VideoSendStream::DegradationPreference::kDegradationDisabled: case DegradationPreference::DISABLED:
wants.max_pixel_count = std::numeric_limits<int>::max(); wants.max_pixel_count = std::numeric_limits<int>::max();
wants.target_pixel_count.reset(); wants.target_pixel_count.reset();
wants.max_framerate_fps = std::numeric_limits<int>::max(); wants.max_framerate_fps = std::numeric_limits<int>::max();
@ -315,8 +307,7 @@ class VideoStreamEncoder::VideoSourceProxy {
rtc::SequencedTaskChecker main_checker_; rtc::SequencedTaskChecker main_checker_;
VideoStreamEncoder* const video_stream_encoder_; VideoStreamEncoder* const video_stream_encoder_;
rtc::VideoSinkWants sink_wants_ RTC_GUARDED_BY(&crit_); rtc::VideoSinkWants sink_wants_ RTC_GUARDED_BY(&crit_);
VideoSendStream::DegradationPreference degradation_preference_ DegradationPreference degradation_preference_ RTC_GUARDED_BY(&crit_);
RTC_GUARDED_BY(&crit_);
rtc::VideoSourceInterface<VideoFrame>* source_ RTC_GUARDED_BY(&crit_); rtc::VideoSourceInterface<VideoFrame>* source_ RTC_GUARDED_BY(&crit_);
RTC_DISALLOW_COPY_AND_ASSIGN(VideoSourceProxy); RTC_DISALLOW_COPY_AND_ASSIGN(VideoSourceProxy);
@ -347,8 +338,7 @@ VideoStreamEncoder::VideoStreamEncoder(
last_observed_bitrate_bps_(0), last_observed_bitrate_bps_(0),
encoder_paused_and_dropped_frame_(false), encoder_paused_and_dropped_frame_(false),
clock_(Clock::GetRealTimeClock()), clock_(Clock::GetRealTimeClock()),
degradation_preference_( degradation_preference_(DegradationPreference::DISABLED),
VideoSendStream::DegradationPreference::kDegradationDisabled),
posted_frames_waiting_for_encode_(0), posted_frames_waiting_for_encode_(0),
last_captured_timestamp_(0), last_captured_timestamp_(0),
delta_ntp_internal_ms_(clock_->CurrentNtpInMilliseconds() - delta_ntp_internal_ms_(clock_->CurrentNtpInMilliseconds() -
@ -370,7 +360,7 @@ VideoStreamEncoder::~VideoStreamEncoder() {
void VideoStreamEncoder::Stop() { void VideoStreamEncoder::Stop() {
RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK_RUN_ON(&thread_checker_);
source_proxy_->SetSource(nullptr, VideoSendStream::DegradationPreference()); source_proxy_->SetSource(nullptr, DegradationPreference());
encoder_queue_.PostTask([this] { encoder_queue_.PostTask([this] {
RTC_DCHECK_RUN_ON(&encoder_queue_); RTC_DCHECK_RUN_ON(&encoder_queue_);
overuse_detector_->StopCheckForOveruse(); overuse_detector_->StopCheckForOveruse();
@ -396,7 +386,7 @@ void VideoStreamEncoder::SetBitrateObserver(
void VideoStreamEncoder::SetSource( void VideoStreamEncoder::SetSource(
rtc::VideoSourceInterface<VideoFrame>* source, rtc::VideoSourceInterface<VideoFrame>* source,
const VideoSendStream::DegradationPreference& degradation_preference) { const DegradationPreference& degradation_preference) {
RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK_RUN_ON(&thread_checker_);
source_proxy_->SetSource(source, degradation_preference); source_proxy_->SetSource(source, degradation_preference);
encoder_queue_.PostTask([this, degradation_preference] { encoder_queue_.PostTask([this, degradation_preference] {
@ -405,10 +395,8 @@ void VideoStreamEncoder::SetSource(
// Reset adaptation state, so that we're not tricked into thinking there's // Reset adaptation state, so that we're not tricked into thinking there's
// an already pending request of the same type. // an already pending request of the same type.
last_adaptation_request_.reset(); last_adaptation_request_.reset();
if (degradation_preference == if (degradation_preference == DegradationPreference::BALANCED ||
VideoSendStream::DegradationPreference::kBalanced || degradation_preference_ == DegradationPreference::BALANCED) {
degradation_preference_ ==
VideoSendStream::DegradationPreference::kBalanced) {
// TODO(asapersson): Consider removing |adapt_counters_| map and use one // TODO(asapersson): Consider removing |adapt_counters_| map and use one
// AdaptCounter for all modes. // AdaptCounter for all modes.
source_proxy_->ResetPixelFpsCount(); source_proxy_->ResetPixelFpsCount();
@ -985,9 +973,9 @@ void VideoStreamEncoder::AdaptDown(AdaptReason reason) {
last_adaptation_request_->mode_ == AdaptationRequest::Mode::kAdaptDown; last_adaptation_request_->mode_ == AdaptationRequest::Mode::kAdaptDown;
switch (degradation_preference_) { switch (degradation_preference_) {
case VideoSendStream::DegradationPreference::kBalanced: case DegradationPreference::BALANCED:
break; break;
case VideoSendStream::DegradationPreference::kMaintainFramerate: case DegradationPreference::MAINTAIN_FRAMERATE:
if (downgrade_requested && if (downgrade_requested &&
adaptation_request.input_pixel_count_ >= adaptation_request.input_pixel_count_ >=
last_adaptation_request_->input_pixel_count_) { last_adaptation_request_->input_pixel_count_) {
@ -996,7 +984,7 @@ void VideoStreamEncoder::AdaptDown(AdaptReason reason) {
return; return;
} }
break; break;
case VideoSendStream::DegradationPreference::kMaintainResolution: case DegradationPreference::MAINTAIN_RESOLUTION:
if (adaptation_request.framerate_fps_ <= 0 || if (adaptation_request.framerate_fps_ <= 0 ||
(downgrade_requested && (downgrade_requested &&
adaptation_request.framerate_fps_ < kMinFramerateFps)) { adaptation_request.framerate_fps_ < kMinFramerateFps)) {
@ -1009,12 +997,12 @@ void VideoStreamEncoder::AdaptDown(AdaptReason reason) {
return; return;
} }
break; break;
case VideoSendStream::DegradationPreference::kDegradationDisabled: case DegradationPreference::DISABLED:
return; return;
} }
switch (degradation_preference_) { switch (degradation_preference_) {
case VideoSendStream::DegradationPreference::kBalanced: { case DegradationPreference::BALANCED: {
// Try scale down framerate, if lower. // Try scale down framerate, if lower.
int fps = MinFps(last_frame_info_->pixel_count()); int fps = MinFps(last_frame_info_->pixel_count());
if (source_proxy_->RestrictFramerate(fps)) { if (source_proxy_->RestrictFramerate(fps)) {
@ -1024,7 +1012,7 @@ void VideoStreamEncoder::AdaptDown(AdaptReason reason) {
// Scale down resolution. // Scale down resolution.
RTC_FALLTHROUGH(); RTC_FALLTHROUGH();
} }
case VideoSendStream::DegradationPreference::kMaintainFramerate: { case DegradationPreference::MAINTAIN_FRAMERATE: {
// Scale down resolution. // Scale down resolution.
bool min_pixels_reached = false; bool min_pixels_reached = false;
if (!source_proxy_->RequestResolutionLowerThan( if (!source_proxy_->RequestResolutionLowerThan(
@ -1038,7 +1026,7 @@ void VideoStreamEncoder::AdaptDown(AdaptReason reason) {
GetAdaptCounter().IncrementResolution(reason); GetAdaptCounter().IncrementResolution(reason);
break; break;
} }
case VideoSendStream::DegradationPreference::kMaintainResolution: { case DegradationPreference::MAINTAIN_RESOLUTION: {
// Scale down framerate. // Scale down framerate.
const int requested_framerate = source_proxy_->RequestFramerateLowerThan( const int requested_framerate = source_proxy_->RequestFramerateLowerThan(
adaptation_request.framerate_fps_); adaptation_request.framerate_fps_);
@ -1050,7 +1038,7 @@ void VideoStreamEncoder::AdaptDown(AdaptReason reason) {
GetAdaptCounter().IncrementFramerate(reason); GetAdaptCounter().IncrementFramerate(reason);
break; break;
} }
case VideoSendStream::DegradationPreference::kDegradationDisabled: case DegradationPreference::DISABLED:
RTC_NOTREACHED(); RTC_NOTREACHED();
} }
@ -1079,8 +1067,7 @@ void VideoStreamEncoder::AdaptUp(AdaptReason reason) {
last_adaptation_request_ && last_adaptation_request_ &&
last_adaptation_request_->mode_ == AdaptationRequest::Mode::kAdaptUp; last_adaptation_request_->mode_ == AdaptationRequest::Mode::kAdaptUp;
if (degradation_preference_ == if (degradation_preference_ == DegradationPreference::MAINTAIN_FRAMERATE) {
VideoSendStream::DegradationPreference::kMaintainFramerate) {
if (adapt_up_requested && if (adapt_up_requested &&
adaptation_request.input_pixel_count_ <= adaptation_request.input_pixel_count_ <=
last_adaptation_request_->input_pixel_count_) { last_adaptation_request_->input_pixel_count_) {
@ -1091,7 +1078,7 @@ void VideoStreamEncoder::AdaptUp(AdaptReason reason) {
} }
switch (degradation_preference_) { switch (degradation_preference_) {
case VideoSendStream::DegradationPreference::kBalanced: { case DegradationPreference::BALANCED: {
// Try scale up framerate, if higher. // Try scale up framerate, if higher.
int fps = MaxFps(last_frame_info_->pixel_count()); int fps = MaxFps(last_frame_info_->pixel_count());
if (source_proxy_->IncreaseFramerate(fps)) { if (source_proxy_->IncreaseFramerate(fps)) {
@ -1107,7 +1094,7 @@ void VideoStreamEncoder::AdaptUp(AdaptReason reason) {
// Scale up resolution. // Scale up resolution.
RTC_FALLTHROUGH(); RTC_FALLTHROUGH();
} }
case VideoSendStream::DegradationPreference::kMaintainFramerate: { case DegradationPreference::MAINTAIN_FRAMERATE: {
// Scale up resolution. // Scale up resolution.
int pixel_count = adaptation_request.input_pixel_count_; int pixel_count = adaptation_request.input_pixel_count_;
if (adapt_counter.ResolutionCount() == 1) { if (adapt_counter.ResolutionCount() == 1) {
@ -1119,7 +1106,7 @@ void VideoStreamEncoder::AdaptUp(AdaptReason reason) {
GetAdaptCounter().DecrementResolution(reason); GetAdaptCounter().DecrementResolution(reason);
break; break;
} }
case VideoSendStream::DegradationPreference::kMaintainResolution: { case DegradationPreference::MAINTAIN_RESOLUTION: {
// Scale up framerate. // Scale up framerate.
int fps = adaptation_request.framerate_fps_; int fps = adaptation_request.framerate_fps_;
if (adapt_counter.FramerateCount() == 1) { if (adapt_counter.FramerateCount() == 1) {
@ -1138,7 +1125,7 @@ void VideoStreamEncoder::AdaptUp(AdaptReason reason) {
GetAdaptCounter().DecrementFramerate(reason); GetAdaptCounter().DecrementFramerate(reason);
break; break;
} }
case VideoSendStream::DegradationPreference::kDegradationDisabled: case DegradationPreference::DISABLED:
return; return;
} }

View File

@ -17,6 +17,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "api/rtpparameters.h" // For DegradationPreference.
#include "api/video/video_rotation.h" #include "api/video/video_rotation.h"
#include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder.h"
#include "api/video/video_sink_interface.h" #include "api/video/video_sink_interface.h"
@ -32,7 +33,6 @@
#include "rtc_base/task_queue.h" #include "rtc_base/task_queue.h"
#include "typedefs.h" // NOLINT(build/include) #include "typedefs.h" // NOLINT(build/include)
#include "video/overuse_frame_detector.h" #include "video/overuse_frame_detector.h"
#include "call/video_send_stream.h"
namespace webrtc { namespace webrtc {
@ -51,7 +51,7 @@ class VideoStreamEncoderInterface : public rtc::VideoSinkInterface<VideoFrame> {
}; };
virtual void SetSource( virtual void SetSource(
rtc::VideoSourceInterface<VideoFrame>* source, rtc::VideoSourceInterface<VideoFrame>* source,
const VideoSendStream::DegradationPreference& degradation_preference) = 0; const DegradationPreference& degradation_preference) = 0;
virtual void SetSink(EncoderSink* sink, bool rotation_applied) = 0; virtual void SetSink(EncoderSink* sink, bool rotation_applied) = 0;
virtual void SetStartBitrate(int start_bitrate_bps) = 0; virtual void SetStartBitrate(int start_bitrate_bps) = 0;
@ -99,8 +99,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
// |degradation_preference| control whether or not resolution or frame rate // |degradation_preference| control whether or not resolution or frame rate
// may be reduced. // may be reduced.
void SetSource(rtc::VideoSourceInterface<VideoFrame>* source, void SetSource(rtc::VideoSourceInterface<VideoFrame>* source,
const VideoSendStream::DegradationPreference& const DegradationPreference& degradation_preference) override;
degradation_preference) override;
// Sets the |sink| that gets the encoded frames. |rotation_applied| means // Sets the |sink| that gets the encoded frames. |rotation_applied| means
// that the source must support rotation. Only set |rotation_applied| if the // that the source must support rotation. Only set |rotation_applied| if the
@ -281,11 +280,10 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
// basis. // basis.
// TODO(sprang): Replace this with a state holding a relative overuse measure // TODO(sprang): Replace this with a state holding a relative overuse measure
// instead, that can be translated into suitable down-scale or fps limit. // instead, that can be translated into suitable down-scale or fps limit.
std::map<const VideoSendStream::DegradationPreference, AdaptCounter> std::map<const DegradationPreference, AdaptCounter> adapt_counters_
adapt_counters_ RTC_GUARDED_BY(&encoder_queue_);
// Set depending on degradation preferences.
VideoSendStream::DegradationPreference degradation_preference_
RTC_GUARDED_BY(&encoder_queue_); RTC_GUARDED_BY(&encoder_queue_);
// Set depending on degradation preferences.
DegradationPreference degradation_preference_ RTC_GUARDED_BY(&encoder_queue_);
struct AdaptationRequest { struct AdaptationRequest {
// The pixel count produced by the source at the time of the adaptation. // The pixel count produced by the source at the time of the adaptation.

View File

@ -39,7 +39,6 @@ const int64_t kFrameTimeoutMs = 100;
namespace webrtc { namespace webrtc {
using DegredationPreference = VideoSendStream::DegradationPreference;
using ScaleReason = AdaptationObserverInterface::AdaptReason; using ScaleReason = AdaptationObserverInterface::AdaptReason;
using ::testing::_; using ::testing::_;
using ::testing::Return; using ::testing::Return;
@ -311,8 +310,7 @@ class VideoStreamEncoderTest : public ::testing::Test {
stats_proxy_.get(), video_send_config_.encoder_settings)); stats_proxy_.get(), video_send_config_.encoder_settings));
video_stream_encoder_->SetSink(&sink_, false /* rotation_applied */); video_stream_encoder_->SetSink(&sink_, false /* rotation_applied */);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&video_source_, &video_source_, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
video_stream_encoder_->SetStartBitrate(kTargetBitrateBps); video_stream_encoder_->SetStartBitrate(kTargetBitrateBps);
video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config), video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
kMaxPayloadLength); kMaxPayloadLength);
@ -837,8 +835,7 @@ TEST_F(VideoStreamEncoderTest, SwitchSourceDeregisterEncoderAsSink) {
EXPECT_TRUE(video_source_.has_sinks()); EXPECT_TRUE(video_source_.has_sinks());
test::FrameForwarder new_video_source; test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
EXPECT_FALSE(video_source_.has_sinks()); EXPECT_FALSE(video_source_.has_sinks());
EXPECT_TRUE(new_video_source.has_sinks()); EXPECT_TRUE(new_video_source.has_sinks());
@ -861,11 +858,10 @@ TEST_F(VideoStreamEncoderTest, TestCpuDowngrades_BalancedMode) {
// adaptation manually by mocking the stats proxy. // adaptation manually by mocking the stats proxy.
video_source_.set_adaptation_enabled(true); video_source_.set_adaptation_enabled(true);
// Enable kBalanced preference, no initial limitation. // Enable BALANCED preference, no initial limitation.
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&video_source_,
&video_source_, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
VerifyNoLimitation(video_source_.sink_wants()); VerifyNoLimitation(video_source_.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution); EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate); EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
@ -977,8 +973,7 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
// Set new source, switch to maintain-resolution. // Set new source, switch to maintain-resolution.
test::FrameForwarder new_video_source; test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
// Initially no degradation registered. // Initially no degradation registered.
VerifyNoLimitation(new_video_source.sink_wants()); VerifyNoLimitation(new_video_source.sink_wants());
@ -1003,9 +998,8 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
EXPECT_LT(new_video_source.sink_wants().max_framerate_fps, kInputFps); EXPECT_LT(new_video_source.sink_wants().max_framerate_fps, kInputFps);
// Turn off degradation completely. // Turn off degradation completely.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&new_video_source,
&new_video_source, webrtc::DegradationPreference::DISABLED);
VideoSendStream::DegradationPreference::kDegradationDisabled);
VerifyNoLimitation(new_video_source.sink_wants()); VerifyNoLimitation(new_video_source.sink_wants());
video_stream_encoder_->TriggerCpuOveruse(); video_stream_encoder_->TriggerCpuOveruse();
@ -1019,8 +1013,7 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
// Calling SetSource with resolution scaling enabled apply the old SinkWants. // Calling SetSource with resolution scaling enabled apply the old SinkWants.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
EXPECT_LT(new_video_source.sink_wants().max_pixel_count, EXPECT_LT(new_video_source.sink_wants().max_pixel_count,
kFrameWidth * kFrameHeight); kFrameWidth * kFrameHeight);
EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count); EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
@ -1029,8 +1022,7 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
// Calling SetSource with framerate scaling enabled apply the old SinkWants. // Calling SetSource with framerate scaling enabled apply the old SinkWants.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count); EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
EXPECT_EQ(std::numeric_limits<int>::max(), EXPECT_EQ(std::numeric_limits<int>::max(),
new_video_source.sink_wants().max_pixel_count); new_video_source.sink_wants().max_pixel_count);
@ -1129,8 +1121,7 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
// Set new source with adaptation still enabled. // Set new source with adaptation still enabled.
test::FrameForwarder new_video_source; test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
new_video_source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight)); new_video_source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
WaitForEncodedFrame(3); WaitForEncodedFrame(3);
@ -1140,9 +1131,8 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
EXPECT_EQ(1, stats.number_of_cpu_adapt_changes); EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
// Set adaptation disabled. // Set adaptation disabled.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&new_video_source,
&new_video_source, webrtc::DegradationPreference::DISABLED);
VideoSendStream::DegradationPreference::kDegradationDisabled);
new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight)); new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
WaitForEncodedFrame(4); WaitForEncodedFrame(4);
@ -1153,8 +1143,7 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
// Set adaptation back to enabled. // Set adaptation back to enabled.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
new_video_source.IncomingCapturedFrame(CreateFrame(5, kWidth, kHeight)); new_video_source.IncomingCapturedFrame(CreateFrame(5, kWidth, kHeight));
WaitForEncodedFrame(5); WaitForEncodedFrame(5);
@ -1190,9 +1179,8 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
// Set new source with adaptation still enabled. // Set new source with adaptation still enabled.
test::FrameForwarder new_video_source; test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&new_video_source,
&new_video_source, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
new_video_source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight)); new_video_source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2); WaitForEncodedFrame(2);
@ -1211,9 +1199,8 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
EXPECT_EQ(1, stats.number_of_quality_adapt_changes); EXPECT_EQ(1, stats.number_of_quality_adapt_changes);
// Set new source with adaptation still enabled. // Set new source with adaptation still enabled.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&new_video_source,
&new_video_source, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight)); new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
WaitForEncodedFrame(4); WaitForEncodedFrame(4);
@ -1224,8 +1211,7 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
// Disable resolution scaling. // Disable resolution scaling.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
new_video_source.IncomingCapturedFrame(CreateFrame(5, kWidth, kHeight)); new_video_source.IncomingCapturedFrame(CreateFrame(5, kWidth, kHeight));
WaitForEncodedFrame(5); WaitForEncodedFrame(5);
@ -1313,8 +1299,7 @@ TEST_F(VideoStreamEncoderTest,
// Set new source with adaptation still enabled. // Set new source with adaptation still enabled.
test::FrameForwarder new_video_source; test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
new_video_source.IncomingCapturedFrame( new_video_source.IncomingCapturedFrame(
CreateFrame(sequence, kWidth, kHeight)); CreateFrame(sequence, kWidth, kHeight));
@ -1326,8 +1311,7 @@ TEST_F(VideoStreamEncoderTest,
// Set cpu adaptation by frame dropping. // Set cpu adaptation by frame dropping.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
new_video_source.IncomingCapturedFrame( new_video_source.IncomingCapturedFrame(
CreateFrame(sequence, kWidth, kHeight)); CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++); WaitForEncodedFrame(sequence++);
@ -1356,9 +1340,8 @@ TEST_F(VideoStreamEncoderTest,
EXPECT_EQ(2, stats.number_of_cpu_adapt_changes); EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
// Disable CPU adaptation. // Disable CPU adaptation.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&new_video_source,
&new_video_source, webrtc::DegradationPreference::DISABLED);
VideoSendStream::DegradationPreference::kDegradationDisabled);
new_video_source.IncomingCapturedFrame( new_video_source.IncomingCapturedFrame(
CreateFrame(sequence, kWidth, kHeight)); CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++); WaitForEncodedFrame(sequence++);
@ -1380,8 +1363,7 @@ TEST_F(VideoStreamEncoderTest,
// Switch back the source with resolution adaptation enabled. // Switch back the source with resolution adaptation enabled.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&video_source_, &video_source_, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
VideoSendStream::DegradationPreference::kMaintainFramerate);
video_source_.IncomingCapturedFrame(CreateFrame(sequence, kWidth, kHeight)); video_source_.IncomingCapturedFrame(CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++); WaitForEncodedFrame(sequence++);
stats = stats_proxy_->GetStats(); stats = stats_proxy_->GetStats();
@ -1400,8 +1382,7 @@ TEST_F(VideoStreamEncoderTest,
// Back to the source with adaptation off, set it back to maintain-resolution. // Back to the source with adaptation off, set it back to maintain-resolution.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
new_video_source.IncomingCapturedFrame( new_video_source.IncomingCapturedFrame(
CreateFrame(sequence, kWidth, kHeight)); CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++); WaitForEncodedFrame(sequence++);
@ -1465,8 +1446,7 @@ TEST_F(VideoStreamEncoderTest,
// Set resolution scaling disabled. // Set resolution scaling disabled.
test::FrameForwarder new_video_source; test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
// Trigger scale down. // Trigger scale down.
video_stream_encoder_->TriggerQualityLow(); video_stream_encoder_->TriggerQualityLow();
@ -1495,10 +1475,10 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation. // Enable MAINTAIN_FRAMERATE preference, no initial limitation.
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate); &source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(1); WaitForEncodedFrame(1);
@ -1527,11 +1507,10 @@ TEST_F(VideoStreamEncoderTest, SkipsSameOrLargerAdaptDownRequest_BalancedMode) {
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation. // Enable BALANCED preference, no initial limitation.
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&source,
&source, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(1); sink_.WaitForEncodedFrame(1);
VerifyNoLimitation(source.sink_wants()); VerifyNoLimitation(source.sink_wants());
@ -1568,10 +1547,10 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation. // Enable MAINTAIN_FRAMERATE preference, no initial limitation.
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate); &source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight); WaitForEncodedFrame(kWidth, kHeight);
@ -1594,10 +1573,10 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainResolution preference, no initial limitation. // Enable MAINTAIN_RESOLUTION preference, no initial limitation.
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution); &source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight); WaitForEncodedFrame(kWidth, kHeight);
@ -1619,11 +1598,10 @@ TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_BalancedMode) {
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation. // Enable BALANCED preference, no initial limitation.
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&source,
&source, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight); sink_.WaitForEncodedFrame(kWidth, kHeight);
@ -1647,10 +1625,10 @@ TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_DisabledMode) {
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kDegradationDisabled preference, no initial limitation. // Enable DISABLED preference, no initial limitation.
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&source,
&source, VideoSendStream::DegradationPreference::kDegradationDisabled); webrtc::DegradationPreference::DISABLED);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight); sink_.WaitForEncodedFrame(kWidth, kHeight);
@ -1675,11 +1653,11 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation. // Enable MAINTAIN_FRAMERATE preference, no initial limitation.
AdaptingFrameForwarder source; AdaptingFrameForwarder source;
source.set_adaptation_enabled(true); source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate); &source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(1); WaitForEncodedFrame(1);
@ -1716,7 +1694,7 @@ TEST_F(VideoStreamEncoderTest,
stats.input_frame_rate = kInputFps; stats.input_frame_rate = kInputFps;
stats_proxy_->SetMockStats(stats); stats_proxy_->SetMockStats(stats);
// Expect no scaling to begin with (preference: kMaintainFramerate). // Expect no scaling to begin with (preference: MAINTAIN_FRAMERATE).
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(1); sink_.WaitForEncodedFrame(1);
VerifyNoLimitation(video_source_.sink_wants()); VerifyNoLimitation(video_source_.sink_wants());
@ -1727,11 +1705,10 @@ TEST_F(VideoStreamEncoderTest,
sink_.WaitForEncodedFrame(2); sink_.WaitForEncodedFrame(2);
VerifyFpsMaxResolutionLt(video_source_.sink_wants(), kWidth * kHeight); VerifyFpsMaxResolutionLt(video_source_.sink_wants(), kWidth * kHeight);
// Enable kMaintainResolution preference. // Enable MAINTAIN_RESOLUTION preference.
test::FrameForwarder new_video_source; test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&new_video_source, &new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
VerifyNoLimitation(new_video_source.sink_wants()); VerifyNoLimitation(new_video_source.sink_wants());
// Trigger adapt down, expect reduced framerate. // Trigger adapt down, expect reduced framerate.
@ -1788,11 +1765,11 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation. // Enable MAINTAIN_FRAMERATE preference, no initial limitation.
AdaptingFrameForwarder source; AdaptingFrameForwarder source;
source.set_adaptation_enabled(true); source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate); &source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight); WaitForEncodedFrame(kWidth, kHeight);
@ -1841,12 +1818,11 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation. // Enable BALANCED preference, no initial limitation.
AdaptingFrameForwarder source; AdaptingFrameForwarder source;
source.set_adaptation_enabled(true); source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&source,
&source, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight); sink_.WaitForEncodedFrame(kWidth, kHeight);
@ -1895,11 +1871,11 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720; const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation. // Enable MAINTAIN_FRAMERATE preference, no initial limitation.
AdaptingFrameForwarder source; AdaptingFrameForwarder source;
source.set_adaptation_enabled(true); source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate); &source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight); WaitForEncodedFrame(kWidth, kHeight);
@ -2049,9 +2025,8 @@ TEST_F(VideoStreamEncoderTest,
const int kWidth = 640; const int kWidth = 640;
const int kHeight = 360; const int kHeight = 360;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&video_source_,
&video_source_, webrtc::DegradationPreference::DISABLED);
VideoSendStream::DegradationPreference::kDegradationDisabled);
for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight)); video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight));
@ -2114,7 +2089,7 @@ TEST_F(VideoStreamEncoderTest, OveruseDetectorUpdatedOnReconfigureAndAdaption) {
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution); &source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
// Insert a single frame, triggering initial configuration. // Insert a single frame, triggering initial configuration.
source.IncomingCapturedFrame(CreateFrame(1, kFrameWidth, kFrameHeight)); source.IncomingCapturedFrame(CreateFrame(1, kFrameWidth, kFrameHeight));
@ -2174,7 +2149,7 @@ TEST_F(VideoStreamEncoderTest,
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution); &source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
// Trigger initial configuration. // Trigger initial configuration.
VideoEncoderConfig video_encoder_config; VideoEncoderConfig video_encoder_config;
@ -2237,7 +2212,7 @@ TEST_F(VideoStreamEncoderTest,
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution); &source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
// Trigger initial configuration. // Trigger initial configuration.
VideoEncoderConfig video_encoder_config; VideoEncoderConfig video_encoder_config;
@ -2268,7 +2243,7 @@ TEST_F(VideoStreamEncoderTest,
// Change degradation preference to not enable framerate scaling. Target // Change degradation preference to not enable framerate scaling. Target
// framerate should be changed to codec defined limit. // framerate should be changed to codec defined limit.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate); &source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
video_stream_encoder_->WaitUntilTaskQueueIsIdle(); video_stream_encoder_->WaitUntilTaskQueueIsIdle();
EXPECT_EQ( EXPECT_EQ(
video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(), video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
@ -2336,8 +2311,7 @@ TEST_F(VideoStreamEncoderTest,
// Set degradation preference. // Set degradation preference.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&video_source_, &video_source_, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
// Frame should not be dropped, even if it's too large. // Frame should not be dropped, even if it's too large.
@ -2360,9 +2334,8 @@ TEST_F(VideoStreamEncoderTest, InitialFrameDropOffWhenEncoderDisabledScaling) {
video_stream_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0);
// Force quality scaler reconfiguration by resetting the source. // Force quality scaler reconfiguration by resetting the source.
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&video_source_,
&video_source_, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
// Frame should not be dropped, even if it's too large. // Frame should not be dropped, even if it's too large.
@ -2378,10 +2351,10 @@ TEST_F(VideoStreamEncoderTest,
const int kTooSmallHeight = 10; const int kTooSmallHeight = 10;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation. // Enable MAINTAIN_FRAMERATE preference, no initial limitation.
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate); &source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
VerifyNoLimitation(source.sink_wants()); VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution); EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
@ -2403,11 +2376,10 @@ TEST_F(VideoStreamEncoderTest,
const int kFpsLimit = 7; const int kFpsLimit = 7;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation. // Enable BALANCED preference, no initial limitation.
test::FrameForwarder source; test::FrameForwarder source;
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&source,
&source, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
VerifyNoLimitation(source.sink_wants()); VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution); EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate); EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
@ -2484,8 +2456,7 @@ TEST_F(VideoStreamEncoderTest,
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&video_source_, &video_source_, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
video_source_.set_adaptation_enabled(true); video_source_.set_adaptation_enabled(true);
int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec; int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec;
@ -2586,8 +2557,7 @@ TEST_F(VideoStreamEncoderTest, DoesntAdaptDownPastMinFramerate) {
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(
&video_source_, &video_source_, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VideoSendStream::DegradationPreference::kMaintainResolution);
video_source_.set_adaptation_enabled(true); video_source_.set_adaptation_enabled(true);
int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec; int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec;
@ -2626,12 +2596,11 @@ TEST_F(VideoStreamEncoderTest,
int64_t timestamp_ms = kFrameIntervalMs; int64_t timestamp_ms = kFrameIntervalMs;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation. // Enable BALANCED preference, no initial limitation.
AdaptingFrameForwarder source; AdaptingFrameForwarder source;
source.set_adaptation_enabled(true); source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&source,
&source, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
timestamp_ms += kFrameIntervalMs; timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight); WaitForEncodedFrame(kWidth, kHeight);
@ -2807,12 +2776,11 @@ TEST_F(VideoStreamEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Framerate) {
int64_t timestamp_ms = kFrameIntervalMs; int64_t timestamp_ms = kFrameIntervalMs;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation. // Enable BALANCED preference, no initial limitation.
AdaptingFrameForwarder source; AdaptingFrameForwarder source;
source.set_adaptation_enabled(true); source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&source,
&source, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
timestamp_ms += kFrameIntervalMs; timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight); WaitForEncodedFrame(kWidth, kHeight);
@ -2921,12 +2889,11 @@ TEST_F(VideoStreamEncoderTest,
int64_t timestamp_ms = kFrameIntervalMs; int64_t timestamp_ms = kFrameIntervalMs;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation. // Enable BALANCED preference, no initial limitation.
AdaptingFrameForwarder source; AdaptingFrameForwarder source;
source.set_adaptation_enabled(true); source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource( video_stream_encoder_->SetSource(&source,
&source, webrtc::DegradationPreference::BALANCED);
VideoSendStream::DegradationPreference::kBalanced);
timestamp_ms += kFrameIntervalMs; timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight)); source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight); WaitForEncodedFrame(kWidth, kHeight);