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,
};
// 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 {
// 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,
// On over-use, request lower resolution, possibly causing down-scaling.
MAINTAIN_RESOLUTION,
// Try to strike a "pleasing" balance between frame rate or resolution.
BALANCED,
// TODO(deadbeef): Remove once downstream code referencing
// "webrtc::VideoSendStream::DegradationPreference::kMaintainResolution" is
// updated.
kMaintainResolution = MAINTAIN_RESOLUTION
};
extern const double kDefaultBitratePriority;

View File

@ -171,9 +171,8 @@ class BitrateEstimatorTest : public test::CallTest {
frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create(
kDefaultWidth, kDefaultHeight, rtc::nullopt, rtc::nullopt,
kDefaultFramerate, Clock::GetRealTimeClock()));
send_stream_->SetSource(
frame_generator_capturer_.get(),
VideoSendStream::DegradationPreference::kMaintainFramerate);
send_stream_->SetSource(frame_generator_capturer_.get(),
DegradationPreference::MAINTAIN_FRAMERATE);
send_stream_->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.
virtual void Stop() = 0;
// 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.
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,
};
// TODO(deadbeef): Remove once downstream code referencing
// "webrtc::VideoSendStream::DegradationPreference::kMaintainResolution" is
// updated.
using DegradationPreference = webrtc::DegradationPreference;
virtual void SetSource(
rtc::VideoSourceInterface<webrtc::VideoFrame>* source,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,6 +17,7 @@
#include <string>
#include <vector>
#include "api/rtpparameters.h" // For DegradationPreference.
#include "api/video/video_rotation.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video/video_sink_interface.h"
@ -32,7 +33,6 @@
#include "rtc_base/task_queue.h"
#include "typedefs.h" // NOLINT(build/include)
#include "video/overuse_frame_detector.h"
#include "call/video_send_stream.h"
namespace webrtc {
@ -51,7 +51,7 @@ class VideoStreamEncoderInterface : public rtc::VideoSinkInterface<VideoFrame> {
};
virtual void SetSource(
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 SetStartBitrate(int start_bitrate_bps) = 0;
@ -99,8 +99,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
// |degradation_preference| control whether or not resolution or frame rate
// may be reduced.
void SetSource(rtc::VideoSourceInterface<VideoFrame>* source,
const VideoSendStream::DegradationPreference&
degradation_preference) override;
const DegradationPreference& degradation_preference) override;
// Sets the |sink| that gets the encoded frames. |rotation_applied| means
// that the source must support rotation. Only set |rotation_applied| if the
@ -281,11 +280,10 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
// basis.
// TODO(sprang): Replace this with a state holding a relative overuse measure
// instead, that can be translated into suitable down-scale or fps limit.
std::map<const VideoSendStream::DegradationPreference, AdaptCounter>
adapt_counters_ RTC_GUARDED_BY(&encoder_queue_);
// Set depending on degradation preferences.
VideoSendStream::DegradationPreference degradation_preference_
std::map<const DegradationPreference, AdaptCounter> adapt_counters_
RTC_GUARDED_BY(&encoder_queue_);
// Set depending on degradation preferences.
DegradationPreference degradation_preference_ RTC_GUARDED_BY(&encoder_queue_);
struct AdaptationRequest {
// 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 {
using DegredationPreference = VideoSendStream::DegradationPreference;
using ScaleReason = AdaptationObserverInterface::AdaptReason;
using ::testing::_;
using ::testing::Return;
@ -311,8 +310,7 @@ class VideoStreamEncoderTest : public ::testing::Test {
stats_proxy_.get(), video_send_config_.encoder_settings));
video_stream_encoder_->SetSink(&sink_, false /* rotation_applied */);
video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainFramerate);
&video_source_, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
video_stream_encoder_->SetStartBitrate(kTargetBitrateBps);
video_stream_encoder_->ConfigureEncoder(std::move(video_encoder_config),
kMaxPayloadLength);
@ -837,8 +835,7 @@ TEST_F(VideoStreamEncoderTest, SwitchSourceDeregisterEncoderAsSink) {
EXPECT_TRUE(video_source_.has_sinks());
test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
EXPECT_FALSE(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.
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_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&video_source_,
webrtc::DegradationPreference::BALANCED);
VerifyNoLimitation(video_source_.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
@ -977,8 +973,7 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
// Set new source, switch to maintain-resolution.
test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
// Initially no degradation registered.
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);
// Turn off degradation completely.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kDegradationDisabled);
video_stream_encoder_->SetSource(&new_video_source,
webrtc::DegradationPreference::DISABLED);
VerifyNoLimitation(new_video_source.sink_wants());
video_stream_encoder_->TriggerCpuOveruse();
@ -1019,8 +1013,7 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
// Calling SetSource with resolution scaling enabled apply the old SinkWants.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
EXPECT_LT(new_video_source.sink_wants().max_pixel_count,
kFrameWidth * kFrameHeight);
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.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count);
EXPECT_EQ(std::numeric_limits<int>::max(),
new_video_source.sink_wants().max_pixel_count);
@ -1129,8 +1121,7 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
// Set new source with adaptation still enabled.
test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
new_video_source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
WaitForEncodedFrame(3);
@ -1140,9 +1131,8 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
EXPECT_EQ(1, stats.number_of_cpu_adapt_changes);
// Set adaptation disabled.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kDegradationDisabled);
video_stream_encoder_->SetSource(&new_video_source,
webrtc::DegradationPreference::DISABLED);
new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
WaitForEncodedFrame(4);
@ -1153,8 +1143,7 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsCpuAdaptation) {
// Set adaptation back to enabled.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
new_video_source.IncomingCapturedFrame(CreateFrame(5, kWidth, kHeight));
WaitForEncodedFrame(5);
@ -1190,9 +1179,8 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
// Set new source with adaptation still enabled.
test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&new_video_source,
webrtc::DegradationPreference::BALANCED);
new_video_source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
WaitForEncodedFrame(2);
@ -1211,9 +1199,8 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
EXPECT_EQ(1, stats.number_of_quality_adapt_changes);
// Set new source with adaptation still enabled.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&new_video_source,
webrtc::DegradationPreference::BALANCED);
new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
WaitForEncodedFrame(4);
@ -1224,8 +1211,7 @@ TEST_F(VideoStreamEncoderTest, SwitchingSourceKeepsQualityAdaptation) {
// Disable resolution scaling.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
new_video_source.IncomingCapturedFrame(CreateFrame(5, kWidth, kHeight));
WaitForEncodedFrame(5);
@ -1313,8 +1299,7 @@ TEST_F(VideoStreamEncoderTest,
// Set new source with adaptation still enabled.
test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainFramerate);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
new_video_source.IncomingCapturedFrame(
CreateFrame(sequence, kWidth, kHeight));
@ -1326,8 +1311,7 @@ TEST_F(VideoStreamEncoderTest,
// Set cpu adaptation by frame dropping.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
new_video_source.IncomingCapturedFrame(
CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++);
@ -1356,9 +1340,8 @@ TEST_F(VideoStreamEncoderTest,
EXPECT_EQ(2, stats.number_of_cpu_adapt_changes);
// Disable CPU adaptation.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kDegradationDisabled);
video_stream_encoder_->SetSource(&new_video_source,
webrtc::DegradationPreference::DISABLED);
new_video_source.IncomingCapturedFrame(
CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++);
@ -1380,8 +1363,7 @@ TEST_F(VideoStreamEncoderTest,
// Switch back the source with resolution adaptation enabled.
video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainFramerate);
&video_source_, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
video_source_.IncomingCapturedFrame(CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++);
stats = stats_proxy_->GetStats();
@ -1400,8 +1382,7 @@ TEST_F(VideoStreamEncoderTest,
// Back to the source with adaptation off, set it back to maintain-resolution.
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
new_video_source.IncomingCapturedFrame(
CreateFrame(sequence, kWidth, kHeight));
WaitForEncodedFrame(sequence++);
@ -1465,8 +1446,7 @@ TEST_F(VideoStreamEncoderTest,
// Set resolution scaling disabled.
test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
// Trigger scale down.
video_stream_encoder_->TriggerQualityLow();
@ -1495,10 +1475,10 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
&source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(1);
@ -1527,11 +1507,10 @@ TEST_F(VideoStreamEncoderTest, SkipsSameOrLargerAdaptDownRequest_BalancedMode) {
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
// Enable BALANCED preference, no initial limitation.
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&source,
webrtc::DegradationPreference::BALANCED);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(1);
VerifyNoLimitation(source.sink_wants());
@ -1568,10 +1547,10 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
&source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@ -1594,10 +1573,10 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainResolution preference, no initial limitation.
// Enable MAINTAIN_RESOLUTION preference, no initial limitation.
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution);
&source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@ -1619,11 +1598,10 @@ TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_BalancedMode) {
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
// Enable BALANCED preference, no initial limitation.
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&source,
webrtc::DegradationPreference::BALANCED);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight);
@ -1647,10 +1625,10 @@ TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_DisabledMode) {
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kDegradationDisabled preference, no initial limitation.
// Enable DISABLED preference, no initial limitation.
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kDegradationDisabled);
video_stream_encoder_->SetSource(&source,
webrtc::DegradationPreference::DISABLED);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight);
@ -1675,11 +1653,11 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
&source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(1);
@ -1716,7 +1694,7 @@ TEST_F(VideoStreamEncoderTest,
stats.input_frame_rate = kInputFps;
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));
sink_.WaitForEncodedFrame(1);
VerifyNoLimitation(video_source_.sink_wants());
@ -1727,11 +1705,10 @@ TEST_F(VideoStreamEncoderTest,
sink_.WaitForEncodedFrame(2);
VerifyFpsMaxResolutionLt(video_source_.sink_wants(), kWidth * kHeight);
// Enable kMaintainResolution preference.
// Enable MAINTAIN_RESOLUTION preference.
test::FrameForwarder new_video_source;
video_stream_encoder_->SetSource(
&new_video_source,
VideoSendStream::DegradationPreference::kMaintainResolution);
&new_video_source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
VerifyNoLimitation(new_video_source.sink_wants());
// Trigger adapt down, expect reduced framerate.
@ -1788,11 +1765,11 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
&source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@ -1841,12 +1818,11 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
// Enable BALANCED preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource(
&source,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&source,
webrtc::DegradationPreference::BALANCED);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
sink_.WaitForEncodedFrame(kWidth, kHeight);
@ -1895,11 +1871,11 @@ TEST_F(VideoStreamEncoderTest,
const int kHeight = 720;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
&source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@ -2049,9 +2025,8 @@ TEST_F(VideoStreamEncoderTest,
const int kWidth = 640;
const int kHeight = 360;
video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kDegradationDisabled);
video_stream_encoder_->SetSource(&video_source_,
webrtc::DegradationPreference::DISABLED);
for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight));
@ -2114,7 +2089,7 @@ TEST_F(VideoStreamEncoderTest, OveruseDetectorUpdatedOnReconfigureAndAdaption) {
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution);
&source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
// Insert a single frame, triggering initial configuration.
source.IncomingCapturedFrame(CreateFrame(1, kFrameWidth, kFrameHeight));
@ -2174,7 +2149,7 @@ TEST_F(VideoStreamEncoderTest,
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution);
&source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
// Trigger initial configuration.
VideoEncoderConfig video_encoder_config;
@ -2237,7 +2212,7 @@ TEST_F(VideoStreamEncoderTest,
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainResolution);
&source, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
// Trigger initial configuration.
VideoEncoderConfig video_encoder_config;
@ -2268,7 +2243,7 @@ TEST_F(VideoStreamEncoderTest,
// Change degradation preference to not enable framerate scaling. Target
// framerate should be changed to codec defined limit.
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
&source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
video_stream_encoder_->WaitUntilTaskQueueIsIdle();
EXPECT_EQ(
video_stream_encoder_->overuse_detector_proxy_->GetLastTargetFramerate(),
@ -2336,8 +2311,7 @@ TEST_F(VideoStreamEncoderTest,
// Set degradation preference.
video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainResolution);
&video_source_, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
// 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);
// Force quality scaler reconfiguration by resetting the source.
video_stream_encoder_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&video_source_,
webrtc::DegradationPreference::BALANCED);
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
// Frame should not be dropped, even if it's too large.
@ -2378,10 +2351,10 @@ TEST_F(VideoStreamEncoderTest,
const int kTooSmallHeight = 10;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kMaintainFramerate preference, no initial limitation.
// Enable MAINTAIN_FRAMERATE preference, no initial limitation.
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source, VideoSendStream::DegradationPreference::kMaintainFramerate);
&source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
@ -2403,11 +2376,10 @@ TEST_F(VideoStreamEncoderTest,
const int kFpsLimit = 7;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
// Enable BALANCED preference, no initial limitation.
test::FrameForwarder source;
video_stream_encoder_->SetSource(
&source,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&source,
webrtc::DegradationPreference::BALANCED);
VerifyNoLimitation(source.sink_wants());
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
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_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainResolution);
&video_source_, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
video_source_.set_adaptation_enabled(true);
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_->SetSource(
&video_source_,
VideoSendStream::DegradationPreference::kMaintainResolution);
&video_source_, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
video_source_.set_adaptation_enabled(true);
int64_t timestamp_ms = fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec;
@ -2626,12 +2596,11 @@ TEST_F(VideoStreamEncoderTest,
int64_t timestamp_ms = kFrameIntervalMs;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
// Enable BALANCED preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource(
&source,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&source,
webrtc::DegradationPreference::BALANCED);
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@ -2807,12 +2776,11 @@ TEST_F(VideoStreamEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Framerate) {
int64_t timestamp_ms = kFrameIntervalMs;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
// Enable BALANCED preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource(
&source,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&source,
webrtc::DegradationPreference::BALANCED);
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);
@ -2921,12 +2889,11 @@ TEST_F(VideoStreamEncoderTest,
int64_t timestamp_ms = kFrameIntervalMs;
video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
// Enable kBalanced preference, no initial limitation.
// Enable BALANCED preference, no initial limitation.
AdaptingFrameForwarder source;
source.set_adaptation_enabled(true);
video_stream_encoder_->SetSource(
&source,
VideoSendStream::DegradationPreference::kBalanced);
video_stream_encoder_->SetSource(&source,
webrtc::DegradationPreference::BALANCED);
timestamp_ms += kFrameIntervalMs;
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
WaitForEncodedFrame(kWidth, kHeight);