aboutsummaryrefslogtreecommitdiff
path: root/call/adaptation/video_stream_adapter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'call/adaptation/video_stream_adapter.cc')
-rw-r--r--call/adaptation/video_stream_adapter.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/call/adaptation/video_stream_adapter.cc b/call/adaptation/video_stream_adapter.cc
index 6620eff311..64e1a77786 100644
--- a/call/adaptation/video_stream_adapter.cc
+++ b/call/adaptation/video_stream_adapter.cc
@@ -416,8 +416,10 @@ VideoStreamAdapter::AdaptIfFpsDiffInsufficient(
const VideoStreamInputState& input_state,
const RestrictionsWithCounters& restrictions) const {
RTC_DCHECK_EQ(degradation_preference_, DegradationPreference::BALANCED);
+ int frame_size_pixels = input_state.single_active_stream_pixels().value_or(
+ input_state.frame_size_pixels().value());
absl::optional<int> min_fps_diff =
- balanced_settings_.MinFpsDiff(input_state.frame_size_pixels().value());
+ balanced_settings_.MinFpsDiff(frame_size_pixels);
if (current_restrictions_.counters.fps_adaptations <
restrictions.counters.fps_adaptations &&
min_fps_diff && input_state.frames_per_second() > 0) {
@@ -502,9 +504,10 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::DecreaseFramerate(
if (degradation_preference_ == DegradationPreference::MAINTAIN_RESOLUTION) {
max_frame_rate = GetLowerFrameRateThan(input_state.frames_per_second());
} else if (degradation_preference_ == DegradationPreference::BALANCED) {
- max_frame_rate =
- balanced_settings_.MinFps(input_state.video_codec_type(),
- input_state.frame_size_pixels().value());
+ int frame_size_pixels = input_state.single_active_stream_pixels().value_or(
+ input_state.frame_size_pixels().value());
+ max_frame_rate = balanced_settings_.MinFps(input_state.video_codec_type(),
+ frame_size_pixels);
} else {
RTC_NOTREACHED();
max_frame_rate = GetLowerFrameRateThan(input_state.frames_per_second());
@@ -561,12 +564,21 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::IncreaseFramerate(
if (degradation_preference_ == DegradationPreference::MAINTAIN_RESOLUTION) {
max_frame_rate = GetHigherFrameRateThan(input_state.frames_per_second());
} else if (degradation_preference_ == DegradationPreference::BALANCED) {
- max_frame_rate =
- balanced_settings_.MaxFps(input_state.video_codec_type(),
- input_state.frame_size_pixels().value());
+ int frame_size_pixels = input_state.single_active_stream_pixels().value_or(
+ input_state.frame_size_pixels().value());
+ max_frame_rate = balanced_settings_.MaxFps(input_state.video_codec_type(),
+ frame_size_pixels);
+ // Temporary fix for cases when there are fewer framerate adaptation steps
+ // up than down. Make number of down/up steps equal.
+ if (max_frame_rate == std::numeric_limits<int>::max() &&
+ current_restrictions.counters.fps_adaptations > 1) {
+ // Do not unrestrict framerate to allow additional adaptation up steps.
+ RTC_LOG(LS_INFO) << "Modifying framerate due to remaining fps count.";
+ max_frame_rate -= current_restrictions.counters.fps_adaptations;
+ }
// In BALANCED, the max_frame_rate must be checked before proceeding. This
// is because the MaxFps might be the current Fps and so the balanced
- // settings may want to scale up the resolution.=
+ // settings may want to scale up the resolution.
if (!CanIncreaseFrameRateTo(max_frame_rate,
current_restrictions.restrictions)) {
return Adaptation::Status::kLimitReached;