Move AdaptationCounters from video/ to api/
- Rename AdaptationCounters to VideoAdaptationCounters - Move VideoAdaptationCounters to the api/ folder - Move related tests to api/test/ folder - Remove VideoAdaptationCounters::operator- Bug: webrtc:11392 Change-Id: I0de2537e9c8dd9cf29a2ecceee00f92a5b155c83 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172920 Commit-Queue: Evan Shrubsole <eshr@google.com> Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31006}
This commit is contained in:
parent
2288256c9a
commit
c70b1028d4
@ -229,7 +229,17 @@ rtc_library("video_stream_decoder_create") {
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("video_stream_encoder") {
|
||||
rtc_library("video_adaptation") {
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"video_adaptation_counters.cc",
|
||||
"video_adaptation_counters.h",
|
||||
]
|
||||
|
||||
deps = [ "../../rtc_base:checks" ]
|
||||
}
|
||||
|
||||
rtc_source_set("video_stream_encoder") {
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"video_stream_encoder_interface.h",
|
||||
|
||||
@ -12,9 +12,11 @@ rtc_library("rtc_api_video_unittests") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"color_space_unittest.cc",
|
||||
"video_adaptation_counters_unittest.cc",
|
||||
"video_bitrate_allocation_unittest.cc",
|
||||
]
|
||||
deps = [
|
||||
"..:video_adaptation",
|
||||
"..:video_bitrate_allocation",
|
||||
"..:video_frame",
|
||||
"..:video_rtp_headers",
|
||||
|
||||
@ -8,43 +8,25 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "video/adaptation/adaptation_counters.h"
|
||||
#include "api/video/video_adaptation_counters.h"
|
||||
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST(AdaptationCountersTest, Addition) {
|
||||
AdaptationCounters a{0, 0};
|
||||
AdaptationCounters b{1, 2};
|
||||
AdaptationCounters total = a + b;
|
||||
VideoAdaptationCounters a{0, 0};
|
||||
VideoAdaptationCounters b{1, 2};
|
||||
VideoAdaptationCounters total = a + b;
|
||||
EXPECT_EQ(1, total.resolution_adaptations);
|
||||
EXPECT_EQ(2, total.fps_adaptations);
|
||||
}
|
||||
|
||||
TEST(AdaptationCountersTest, Subtraction) {
|
||||
AdaptationCounters a{0, 1};
|
||||
AdaptationCounters b{2, 1};
|
||||
AdaptationCounters diff = a - b;
|
||||
EXPECT_EQ(-2, diff.resolution_adaptations);
|
||||
EXPECT_EQ(0, diff.fps_adaptations);
|
||||
}
|
||||
|
||||
TEST(AdaptationCountersTest, Equality) {
|
||||
AdaptationCounters a{1, 2};
|
||||
AdaptationCounters b{2, 1};
|
||||
VideoAdaptationCounters a{1, 2};
|
||||
VideoAdaptationCounters b{2, 1};
|
||||
EXPECT_EQ(a, a);
|
||||
EXPECT_NE(a, b);
|
||||
}
|
||||
|
||||
TEST(AdaptationCountersTest, SelfAdditionSubtraction) {
|
||||
AdaptationCounters a{1, 0};
|
||||
AdaptationCounters b{0, 1};
|
||||
|
||||
EXPECT_EQ(a, a + b - b);
|
||||
EXPECT_EQ(a, b + a - b);
|
||||
EXPECT_EQ(a, a - b + b);
|
||||
EXPECT_EQ(a, b - b + a);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -8,31 +8,26 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "video/adaptation/adaptation_counters.h"
|
||||
#include "api/video/video_adaptation_counters.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
bool AdaptationCounters::operator==(const AdaptationCounters& rhs) const {
|
||||
bool VideoAdaptationCounters::operator==(
|
||||
const VideoAdaptationCounters& rhs) const {
|
||||
return fps_adaptations == rhs.fps_adaptations &&
|
||||
resolution_adaptations == rhs.resolution_adaptations;
|
||||
}
|
||||
|
||||
bool AdaptationCounters::operator!=(const AdaptationCounters& rhs) const {
|
||||
bool VideoAdaptationCounters::operator!=(
|
||||
const VideoAdaptationCounters& rhs) const {
|
||||
return !(rhs == *this);
|
||||
}
|
||||
|
||||
AdaptationCounters AdaptationCounters::operator+(
|
||||
const AdaptationCounters& other) const {
|
||||
return AdaptationCounters(
|
||||
VideoAdaptationCounters VideoAdaptationCounters::operator+(
|
||||
const VideoAdaptationCounters& other) const {
|
||||
return VideoAdaptationCounters(
|
||||
resolution_adaptations + other.resolution_adaptations,
|
||||
fps_adaptations + other.fps_adaptations);
|
||||
}
|
||||
|
||||
AdaptationCounters AdaptationCounters::operator-(
|
||||
const AdaptationCounters& other) const {
|
||||
return AdaptationCounters(
|
||||
resolution_adaptations - other.resolution_adaptations,
|
||||
fps_adaptations - other.fps_adaptations);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -8,26 +8,30 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VIDEO_ADAPTATION_ADAPTATION_COUNTERS_H_
|
||||
#define VIDEO_ADAPTATION_ADAPTATION_COUNTERS_H_
|
||||
#ifndef API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_
|
||||
#define API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Counts the number of adaptations have resulted due to resource overuse.
|
||||
// Today we can adapt resolution and fps.
|
||||
struct AdaptationCounters {
|
||||
AdaptationCounters() : resolution_adaptations(0), fps_adaptations(0) {}
|
||||
AdaptationCounters(int resolution_adaptations, int fps_adaptations)
|
||||
struct VideoAdaptationCounters {
|
||||
VideoAdaptationCounters() : resolution_adaptations(0), fps_adaptations(0) {}
|
||||
VideoAdaptationCounters(int resolution_adaptations, int fps_adaptations)
|
||||
: resolution_adaptations(resolution_adaptations),
|
||||
fps_adaptations(fps_adaptations) {}
|
||||
fps_adaptations(fps_adaptations) {
|
||||
RTC_DCHECK_GE(resolution_adaptations, 0);
|
||||
RTC_DCHECK_GE(fps_adaptations, 0);
|
||||
}
|
||||
|
||||
int Total() const { return fps_adaptations + resolution_adaptations; }
|
||||
|
||||
bool operator==(const AdaptationCounters& rhs) const;
|
||||
bool operator!=(const AdaptationCounters& rhs) const;
|
||||
bool operator==(const VideoAdaptationCounters& rhs) const;
|
||||
bool operator!=(const VideoAdaptationCounters& rhs) const;
|
||||
|
||||
AdaptationCounters operator+(const AdaptationCounters& other) const;
|
||||
AdaptationCounters operator-(const AdaptationCounters& other) const;
|
||||
VideoAdaptationCounters operator+(const VideoAdaptationCounters& other) const;
|
||||
|
||||
int resolution_adaptations;
|
||||
int fps_adaptations;
|
||||
@ -35,4 +39,4 @@ struct AdaptationCounters {
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // VIDEO_ADAPTATION_ADAPTATION_COUNTERS_H_
|
||||
#endif // API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_
|
||||
@ -10,8 +10,6 @@ import("../../webrtc.gni")
|
||||
|
||||
rtc_library("video_adaptation") {
|
||||
sources = [
|
||||
"adaptation_counters.cc",
|
||||
"adaptation_counters.h",
|
||||
"encode_usage_resource.cc",
|
||||
"encode_usage_resource.h",
|
||||
"overuse_frame_detector.cc",
|
||||
@ -27,6 +25,7 @@ rtc_library("video_adaptation") {
|
||||
deps = [
|
||||
"../../api:rtp_parameters",
|
||||
"../../api/task_queue:task_queue",
|
||||
"../../api/video:video_adaptation",
|
||||
"../../api/video:video_frame",
|
||||
"../../api/video:video_stream_encoder",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
@ -59,7 +58,6 @@ if (rtc_include_tests) {
|
||||
|
||||
defines = []
|
||||
sources = [
|
||||
"adaptation_counters_unittest.cc",
|
||||
"overuse_frame_detector_unittest.cc",
|
||||
"resource_adaptation_processor_unittest.cc",
|
||||
"video_stream_adapter_unittest.cc",
|
||||
@ -67,6 +65,7 @@ if (rtc_include_tests) {
|
||||
deps = [
|
||||
":video_adaptation",
|
||||
"../../api/video:encoded_image",
|
||||
"../../api/video:video_adaptation",
|
||||
"../../api/video:video_frame_i420",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
"../../call/adaptation:resource_adaptation",
|
||||
|
||||
@ -67,12 +67,12 @@ VideoSourceRestrictions ApplyDegradationPreference(
|
||||
return source_restrictions;
|
||||
}
|
||||
|
||||
// Returns AdaptationCounters where constraints that don't apply to the
|
||||
// Returns VideoAdaptationCounters where constraints that don't apply to the
|
||||
// degredation preference are cleared. This behaviour must reflect that of
|
||||
// ApplyDegredationPreference for SourceRestrictions. Any to that method must
|
||||
// also change this one.
|
||||
AdaptationCounters ApplyDegradationPreference(
|
||||
AdaptationCounters counters,
|
||||
VideoAdaptationCounters ApplyDegradationPreference(
|
||||
VideoAdaptationCounters counters,
|
||||
DegradationPreference degradation_preference) {
|
||||
switch (degradation_preference) {
|
||||
case DegradationPreference::BALANCED:
|
||||
@ -256,7 +256,7 @@ void ResourceAdaptationProcessor::SetDegradationPreference(
|
||||
if (stream_adapter_->SetDegradationPreference(degradation_preference) ==
|
||||
VideoStreamAdapter::SetDegradationPreferenceResult::
|
||||
kRestrictionsCleared) {
|
||||
active_counts_.fill(AdaptationCounters());
|
||||
active_counts_.fill(VideoAdaptationCounters());
|
||||
}
|
||||
MaybeUpdateVideoSourceRestrictions();
|
||||
}
|
||||
@ -292,7 +292,7 @@ void ResourceAdaptationProcessor::SetEncoderRates(
|
||||
|
||||
void ResourceAdaptationProcessor::ResetVideoSourceRestrictions() {
|
||||
stream_adapter_->ClearRestrictions();
|
||||
active_counts_.fill(AdaptationCounters());
|
||||
active_counts_.fill(VideoAdaptationCounters());
|
||||
MaybeUpdateVideoSourceRestrictions();
|
||||
}
|
||||
|
||||
@ -301,7 +301,8 @@ void ResourceAdaptationProcessor::OnFrame(const VideoFrame& frame) {
|
||||
}
|
||||
|
||||
void ResourceAdaptationProcessor::OnFrameDroppedDueToSize() {
|
||||
AdaptationCounters counters_before = stream_adapter_->adaptation_counters();
|
||||
VideoAdaptationCounters counters_before =
|
||||
stream_adapter_->adaptation_counters();
|
||||
OnResourceOveruse(AdaptationObserverInterface::AdaptReason::kQuality);
|
||||
if (degradation_preference() == DegradationPreference::BALANCED &&
|
||||
stream_adapter_->adaptation_counters().fps_adaptations >
|
||||
@ -570,24 +571,28 @@ void ResourceAdaptationProcessor::MaybeUpdateTargetFrameRate() {
|
||||
}
|
||||
|
||||
void ResourceAdaptationProcessor::OnAdaptationCountChanged(
|
||||
const AdaptationCounters& adaptation_count,
|
||||
AdaptationCounters* active_count,
|
||||
AdaptationCounters* other_active) {
|
||||
const VideoAdaptationCounters& adaptation_count,
|
||||
VideoAdaptationCounters* active_count,
|
||||
VideoAdaptationCounters* other_active) {
|
||||
RTC_DCHECK(active_count);
|
||||
RTC_DCHECK(other_active);
|
||||
const int active_total = active_count->Total();
|
||||
const int other_total = other_active->Total();
|
||||
const AdaptationCounters prev_total = *active_count + *other_active;
|
||||
const AdaptationCounters delta = adaptation_count - prev_total;
|
||||
const VideoAdaptationCounters prev_total = *active_count + *other_active;
|
||||
const int delta_resolution_adaptations =
|
||||
adaptation_count.resolution_adaptations -
|
||||
prev_total.resolution_adaptations;
|
||||
const int delta_fps_adaptations =
|
||||
adaptation_count.fps_adaptations - prev_total.fps_adaptations;
|
||||
|
||||
RTC_DCHECK_EQ(
|
||||
std::abs(delta.resolution_adaptations) + std::abs(delta.fps_adaptations),
|
||||
std::abs(delta_resolution_adaptations) + std::abs(delta_fps_adaptations),
|
||||
1)
|
||||
<< "Adaptation took more than one step!";
|
||||
|
||||
if (delta.resolution_adaptations > 0) {
|
||||
if (delta_resolution_adaptations > 0) {
|
||||
++active_count->resolution_adaptations;
|
||||
} else if (delta.resolution_adaptations < 0) {
|
||||
} else if (delta_resolution_adaptations < 0) {
|
||||
if (active_count->resolution_adaptations == 0) {
|
||||
RTC_DCHECK_GT(active_count->fps_adaptations, 0) << "No downgrades left";
|
||||
RTC_DCHECK_GT(other_active->resolution_adaptations, 0)
|
||||
@ -600,9 +605,9 @@ void ResourceAdaptationProcessor::OnAdaptationCountChanged(
|
||||
--active_count->resolution_adaptations;
|
||||
}
|
||||
}
|
||||
if (delta.fps_adaptations > 0) {
|
||||
if (delta_fps_adaptations > 0) {
|
||||
++active_count->fps_adaptations;
|
||||
} else if (delta.fps_adaptations < 0) {
|
||||
} else if (delta_fps_adaptations < 0) {
|
||||
if (active_count->fps_adaptations == 0) {
|
||||
RTC_DCHECK_GT(active_count->resolution_adaptations, 0)
|
||||
<< "No downgrades left";
|
||||
@ -619,7 +624,9 @@ void ResourceAdaptationProcessor::OnAdaptationCountChanged(
|
||||
|
||||
RTC_DCHECK(*active_count + *other_active == adaptation_count);
|
||||
RTC_DCHECK_EQ(other_active->Total(), other_total);
|
||||
RTC_DCHECK_EQ(active_count->Total(), active_total + delta.Total());
|
||||
RTC_DCHECK_EQ(
|
||||
active_count->Total(),
|
||||
active_total + delta_resolution_adaptations + delta_fps_adaptations);
|
||||
RTC_DCHECK_GE(active_count->resolution_adaptations, 0);
|
||||
RTC_DCHECK_GE(active_count->fps_adaptations, 0);
|
||||
RTC_DCHECK_GE(other_active->resolution_adaptations, 0);
|
||||
@ -630,9 +637,9 @@ void ResourceAdaptationProcessor::OnAdaptationCountChanged(
|
||||
void ResourceAdaptationProcessor::UpdateAdaptationStats(
|
||||
AdaptationObserverInterface::AdaptReason reason) {
|
||||
// Update active counts
|
||||
AdaptationCounters& active_count = active_counts_[reason];
|
||||
AdaptationCounters& other_active = active_counts_[(reason + 1) % 2];
|
||||
const AdaptationCounters total_counts =
|
||||
VideoAdaptationCounters& active_count = active_counts_[reason];
|
||||
VideoAdaptationCounters& other_active = active_counts_[(reason + 1) % 2];
|
||||
const VideoAdaptationCounters total_counts =
|
||||
stream_adapter_->adaptation_counters();
|
||||
|
||||
OnAdaptationCountChanged(total_counts, &active_count, &other_active);
|
||||
@ -658,7 +665,7 @@ ResourceAdaptationProcessor::GetActiveCounts(
|
||||
AdaptationObserverInterface::AdaptReason reason) {
|
||||
// TODO(https://crbug.com/webrtc/11392) Ideally this shuold be moved out of
|
||||
// this class and into the encoder_stats_observer_.
|
||||
const AdaptationCounters counters = active_counts_[reason];
|
||||
const VideoAdaptationCounters counters = active_counts_[reason];
|
||||
|
||||
VideoStreamEncoderObserver::AdaptationSteps counts =
|
||||
VideoStreamEncoderObserver::AdaptationSteps();
|
||||
@ -720,9 +727,9 @@ void ResourceAdaptationProcessor::MaybePerformQualityRampupExperiment() {
|
||||
}
|
||||
// TODO(https://crbug.com/webrtc/11392): See if we can rely on the total
|
||||
// counts or the stats, and not the active counts.
|
||||
const AdaptationCounters& qp_counts =
|
||||
const VideoAdaptationCounters& qp_counts =
|
||||
std::get<AdaptationObserverInterface::kQuality>(active_counts_);
|
||||
const AdaptationCounters& cpu_counts =
|
||||
const VideoAdaptationCounters& cpu_counts =
|
||||
std::get<AdaptationObserverInterface::kCpu>(active_counts_);
|
||||
if (try_quality_rampup && qp_counts.resolution_adaptations > 0 &&
|
||||
cpu_counts.Total() == 0) {
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/rtp_parameters.h"
|
||||
#include "api/video/video_adaptation_counters.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video/video_source_interface.h"
|
||||
#include "api/video/video_stream_encoder_observer.h"
|
||||
@ -31,7 +32,6 @@
|
||||
#include "rtc_base/experiments/quality_scaler_settings.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "video/adaptation/adaptation_counters.h"
|
||||
#include "video/adaptation/encode_usage_resource.h"
|
||||
#include "video/adaptation/overuse_frame_detector.h"
|
||||
#include "video/adaptation/quality_scaler_resource.h"
|
||||
@ -123,9 +123,9 @@ class ResourceAdaptationProcessor : public ResourceAdaptationProcessorInterface,
|
||||
// The "other" count is the number of adaptations for the other reason.
|
||||
// This must be called for each adaptation step made.
|
||||
static void OnAdaptationCountChanged(
|
||||
const AdaptationCounters& adaptation_count,
|
||||
AdaptationCounters* active_count,
|
||||
AdaptationCounters* other_active);
|
||||
const VideoAdaptationCounters& adaptation_count,
|
||||
VideoAdaptationCounters* active_count,
|
||||
VideoAdaptationCounters* other_active);
|
||||
|
||||
private:
|
||||
class InitialFrameDropper;
|
||||
@ -216,7 +216,8 @@ class ResourceAdaptationProcessor : public ResourceAdaptationProcessorInterface,
|
||||
// encoder_stats_observer_; Counters used for deciding if the video resolution
|
||||
// or framerate is currently restricted, and if so, why, on a per degradation
|
||||
// preference basis.
|
||||
std::array<AdaptationCounters, AdaptationObserverInterface::kScaleReasonSize>
|
||||
std::array<VideoAdaptationCounters,
|
||||
AdaptationObserverInterface::kScaleReasonSize>
|
||||
active_counts_;
|
||||
};
|
||||
|
||||
|
||||
@ -10,87 +10,87 @@
|
||||
|
||||
#include "video/adaptation/resource_adaptation_processor.h"
|
||||
|
||||
#include "api/video/video_adaptation_counters.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
#include "video/adaptation/adaptation_counters.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST(ResourceAdaptationProcessorTest, FirstAdaptationDown_Fps) {
|
||||
AdaptationCounters cpu;
|
||||
AdaptationCounters qp;
|
||||
AdaptationCounters total(0, 1);
|
||||
VideoAdaptationCounters cpu;
|
||||
VideoAdaptationCounters qp;
|
||||
VideoAdaptationCounters total(0, 1);
|
||||
|
||||
ResourceAdaptationProcessor::OnAdaptationCountChanged(total, &cpu, &qp);
|
||||
AdaptationCounters expected_cpu(0, 1);
|
||||
AdaptationCounters expected_qp;
|
||||
VideoAdaptationCounters expected_cpu(0, 1);
|
||||
VideoAdaptationCounters expected_qp;
|
||||
EXPECT_EQ(expected_cpu, cpu);
|
||||
EXPECT_EQ(expected_qp, qp);
|
||||
}
|
||||
|
||||
TEST(ResourceAdaptationProcessorTest, FirstAdaptationDown_Resolution) {
|
||||
AdaptationCounters cpu;
|
||||
AdaptationCounters qp;
|
||||
AdaptationCounters total(1, 0);
|
||||
VideoAdaptationCounters cpu;
|
||||
VideoAdaptationCounters qp;
|
||||
VideoAdaptationCounters total(1, 0);
|
||||
|
||||
ResourceAdaptationProcessor::OnAdaptationCountChanged(total, &cpu, &qp);
|
||||
AdaptationCounters expected_cpu(1, 0);
|
||||
AdaptationCounters expected_qp;
|
||||
VideoAdaptationCounters expected_cpu(1, 0);
|
||||
VideoAdaptationCounters expected_qp;
|
||||
EXPECT_EQ(expected_cpu, cpu);
|
||||
EXPECT_EQ(expected_qp, qp);
|
||||
}
|
||||
|
||||
TEST(ResourceAdaptationProcessorTest, LastAdaptUp_Fps) {
|
||||
AdaptationCounters cpu(0, 1);
|
||||
AdaptationCounters qp;
|
||||
AdaptationCounters total;
|
||||
VideoAdaptationCounters cpu(0, 1);
|
||||
VideoAdaptationCounters qp;
|
||||
VideoAdaptationCounters total;
|
||||
|
||||
ResourceAdaptationProcessor::OnAdaptationCountChanged(total, &cpu, &qp);
|
||||
AdaptationCounters expected_cpu;
|
||||
AdaptationCounters expected_qp;
|
||||
VideoAdaptationCounters expected_cpu;
|
||||
VideoAdaptationCounters expected_qp;
|
||||
EXPECT_EQ(expected_cpu, cpu);
|
||||
EXPECT_EQ(expected_qp, qp);
|
||||
}
|
||||
|
||||
TEST(ResourceAdaptationProcessorTest, LastAdaptUp_Resolution) {
|
||||
AdaptationCounters cpu(1, 0);
|
||||
AdaptationCounters qp;
|
||||
AdaptationCounters total;
|
||||
VideoAdaptationCounters cpu(1, 0);
|
||||
VideoAdaptationCounters qp;
|
||||
VideoAdaptationCounters total;
|
||||
|
||||
ResourceAdaptationProcessor::OnAdaptationCountChanged(total, &cpu, &qp);
|
||||
AdaptationCounters expected_cpu;
|
||||
AdaptationCounters expected_qp;
|
||||
VideoAdaptationCounters expected_cpu;
|
||||
VideoAdaptationCounters expected_qp;
|
||||
EXPECT_EQ(expected_cpu, cpu);
|
||||
EXPECT_EQ(expected_qp, qp);
|
||||
}
|
||||
|
||||
TEST(ResourceAdaptationProcessorTest, AdaptUpWithBorrow_Resolution) {
|
||||
AdaptationCounters cpu(0, 1);
|
||||
AdaptationCounters qp(1, 0);
|
||||
AdaptationCounters total(0, 1);
|
||||
VideoAdaptationCounters cpu(0, 1);
|
||||
VideoAdaptationCounters qp(1, 0);
|
||||
VideoAdaptationCounters total(0, 1);
|
||||
|
||||
// CPU adaptation for resolution, but no resolution adaptation left from CPU.
|
||||
// We then borrow the resolution adaptation from qp, and give qp the fps
|
||||
// adaptation from CPU.
|
||||
ResourceAdaptationProcessor::OnAdaptationCountChanged(total, &cpu, &qp);
|
||||
|
||||
AdaptationCounters expected_cpu(0, 0);
|
||||
AdaptationCounters expected_qp(0, 1);
|
||||
VideoAdaptationCounters expected_cpu(0, 0);
|
||||
VideoAdaptationCounters expected_qp(0, 1);
|
||||
EXPECT_EQ(expected_cpu, cpu);
|
||||
EXPECT_EQ(expected_qp, qp);
|
||||
}
|
||||
|
||||
TEST(ResourceAdaptationProcessorTest, AdaptUpWithBorrow_Fps) {
|
||||
AdaptationCounters cpu(1, 0);
|
||||
AdaptationCounters qp(0, 1);
|
||||
AdaptationCounters total(1, 0);
|
||||
VideoAdaptationCounters cpu(1, 0);
|
||||
VideoAdaptationCounters qp(0, 1);
|
||||
VideoAdaptationCounters total(1, 0);
|
||||
|
||||
// CPU adaptation for fps, but no fps adaptation left from CPU. We then borrow
|
||||
// the fps adaptation from qp, and give qp the resolution adaptation from CPU.
|
||||
ResourceAdaptationProcessor::OnAdaptationCountChanged(total, &cpu, &qp);
|
||||
|
||||
AdaptationCounters expected_cpu(0, 0);
|
||||
AdaptationCounters expected_qp(1, 0);
|
||||
VideoAdaptationCounters expected_cpu(0, 0);
|
||||
VideoAdaptationCounters expected_qp(1, 0);
|
||||
EXPECT_EQ(expected_cpu, cpu);
|
||||
EXPECT_EQ(expected_qp, qp);
|
||||
}
|
||||
|
||||
@ -152,10 +152,12 @@ class VideoStreamAdapter::VideoSourceRestrictor {
|
||||
VideoSourceRestrictions source_restrictions() const {
|
||||
return source_restrictions_;
|
||||
}
|
||||
const AdaptationCounters& adaptation_counters() const { return adaptations_; }
|
||||
const VideoAdaptationCounters& adaptation_counters() const {
|
||||
return adaptations_;
|
||||
}
|
||||
void ClearRestrictions() {
|
||||
source_restrictions_ = VideoSourceRestrictions();
|
||||
adaptations_ = AdaptationCounters();
|
||||
adaptations_ = VideoAdaptationCounters();
|
||||
}
|
||||
|
||||
void SetMinPixelsPerFrame(int min_pixels_per_frame) {
|
||||
@ -294,7 +296,7 @@ class VideoStreamAdapter::VideoSourceRestrictor {
|
||||
int min_pixels_per_frame_ = 0;
|
||||
// Current State.
|
||||
VideoSourceRestrictions source_restrictions_;
|
||||
AdaptationCounters adaptations_;
|
||||
VideoAdaptationCounters adaptations_;
|
||||
};
|
||||
|
||||
// static
|
||||
@ -331,7 +333,7 @@ VideoSourceRestrictions VideoStreamAdapter::source_restrictions() const {
|
||||
return source_restrictor_->source_restrictions();
|
||||
}
|
||||
|
||||
const AdaptationCounters& VideoStreamAdapter::adaptation_counters() const {
|
||||
const VideoAdaptationCounters& VideoStreamAdapter::adaptation_counters() const {
|
||||
return source_restrictor_->adaptation_counters();
|
||||
}
|
||||
|
||||
|
||||
@ -15,12 +15,12 @@
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/rtp_parameters.h"
|
||||
#include "api/video/video_adaptation_counters.h"
|
||||
#include "call/adaptation/encoder_settings.h"
|
||||
#include "call/adaptation/resource.h"
|
||||
#include "call/adaptation/video_source_restrictions.h"
|
||||
#include "modules/video_coding/utility/quality_scaler.h"
|
||||
#include "rtc_base/experiments/balanced_degradation_settings.h"
|
||||
#include "video/adaptation/adaptation_counters.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -138,7 +138,7 @@ class VideoStreamAdapter {
|
||||
~VideoStreamAdapter();
|
||||
|
||||
VideoSourceRestrictions source_restrictions() const;
|
||||
const AdaptationCounters& adaptation_counters() const;
|
||||
const VideoAdaptationCounters& adaptation_counters() const;
|
||||
// TODO(hbos): Can we get rid of any external dependencies on
|
||||
// BalancedDegradationPreference? How the adaptor generates possible next
|
||||
// steps for adaptation should be an implementation detail. Can the relevant
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user