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}
diff --git a/video/end_to_end_tests/call_operation_tests.cc b/video/end_to_end_tests/call_operation_tests.cc
index d90b85e..ed06aa8 100644
--- a/video/end_to_end_tests/call_operation_tests.cc
+++ b/video/end_to_end_tests/call_operation_tests.cc
@@ -135,9 +135,8 @@
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 @@
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 @@
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());
});
diff --git a/video/end_to_end_tests/multi_stream_tester.cc b/video/end_to_end_tests/multi_stream_tester.cc
index e818cf4..4ed3af6 100644
--- a/video/end_to_end_tests/multi_stream_tester.cc
+++ b/video/end_to_end_tests/multi_stream_tester.cc
@@ -101,9 +101,8 @@
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();
}
});
diff --git a/video/end_to_end_tests/stats_tests.cc b/video/end_to_end_tests/stats_tests.cc
index f3d2194..8f993e0 100644
--- a/video/end_to_end_tests/stats_tests.cc
+++ b/video/end_to_end_tests/stats_tests.cc
@@ -560,9 +560,8 @@
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();
});
diff --git a/video/test/mock_video_stream_encoder.h b/video/test/mock_video_stream_encoder.h
index 684962df..efba400 100644
--- a/video/test/mock_video_stream_encoder.h
+++ b/video/test/mock_video_stream_encoder.h
@@ -19,7 +19,7 @@
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());
diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc
index 11fea23..b87e604 100644
--- a/video/video_quality_test.cc
+++ b/video/video_quality_test.cc
@@ -1518,8 +1518,7 @@
// 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;
diff --git a/video/video_quality_test.h b/video/video_quality_test.h
index 1671745..034cf90 100644
--- a/video/video_quality_test.h
+++ b/video/video_quality_test.h
@@ -179,8 +179,8 @@
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_;
diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc
index bee80ac..4a72e25 100644
--- a/video/video_send_stream_tests.cc
+++ b/video/video_send_stream_tests.cc
@@ -1864,9 +1864,8 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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();
});
diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc
index 1b7f2f7..48d99cc 100644
--- a/video/video_stream_encoder.cc
+++ b/video/video_stream_encoder.cc
@@ -48,7 +48,7 @@
// 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 @@
}
}
-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 @@
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 @@
// 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 @@
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 @@
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 @@
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::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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
GetAdaptCounter().IncrementFramerate(reason);
break;
}
- case VideoSendStream::DegradationPreference::kDegradationDisabled:
+ case DegradationPreference::DISABLED:
RTC_NOTREACHED();
}
@@ -1079,8 +1067,7 @@
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 @@
}
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 @@
// 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 @@
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 @@
GetAdaptCounter().DecrementFramerate(reason);
break;
}
- case VideoSendStream::DegradationPreference::kDegradationDisabled:
+ case DegradationPreference::DISABLED:
return;
}
diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h
index 2feee27..84c054f 100644
--- a/video/video_stream_encoder.h
+++ b/video/video_stream_encoder.h
@@ -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 @@
};
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 @@
// |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 @@
// 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.
diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc
index ab2d8af..b18abbe 100644
--- a/video/video_stream_encoder_unittest.cc
+++ b/video/video_stream_encoder_unittest.cc
@@ -39,7 +39,6 @@
namespace webrtc {
-using DegredationPreference = VideoSendStream::DegradationPreference;
using ScaleReason = AdaptationObserverInterface::AdaptReason;
using ::testing::_;
using ::testing::Return;
@@ -311,8 +310,7 @@
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 @@
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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);