Files
platform-external-webrtc/call/adaptation/video_source_restrictions.cc
Henrik Boström ce0ea49001 VideoStreamEncoder configuring source/sink with VideoSourceController.
This is part of the work for making VideoStreamEncoder responsible for
configuring its source/sink and limiting the responsibility of
OveruseFrameDetectorResourceAdaptationModule to only output relevant
VideoSourceRestrictions.

BEFORE THIS CL

Prior to this CL, OveruseFrameDetector was responsible for performing
AddOrUpdateSink() on the source, which it did using its nested class
VideoSourceProxy.

AddOrUpdateSink() could happen for both adaptation and non-adaptation
related reasons. For example:
- Adaptation related: AdaptUp() or AdaptDown() happens, causing updated
  VideoSourceRestrictions.
- Non-adaptation related: VideoStreamEncoder asks the module to
  reconfigure the source/sink for it, such as with
  SetMaxFramerateAndAlignment() or SetWantsRotationApplied().

AFTER THIS CL

AddOrUpdateSink() is performed by VideoSourceController, which is owned
by VideoStreamEncoder. Any reconfiguration has to go through the
VideoStreamEncoder. This means that:
- Non-adaptation related settings happen between VideoStreamEncoder and
  VideoSourceController directly (without going through the adaptation
  module).
- Adaptation related changes can be expressed in terms of
  VideoSourceRestrictions. OveruseFrameDetectorResourceAdaptationModule
  only has to output the restrictions and not know or care about other
  source/sink settings.

For now, VideoSourceController has to know about DegradationPreference.
In a future CL, the DegradationPreference logic should move back to
the adaptation module. The VideoSourceRestrictions are fully capable of
expressing all possible source/sink values without the "modifier" that
is the degradation preference.

Bug: webrtc:11222
Change-Id: I0f058c4700ca108e2d9f212e38b61f6f728aa419
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162802
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#30228}
2020-01-13 11:14:04 +00:00

69 lines
2.3 KiB
C++

/*
* Copyright 2020 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "call/adaptation/video_source_restrictions.h"
#include <limits>
#include "rtc_base/checks.h"
namespace webrtc {
VideoSourceRestrictions::VideoSourceRestrictions()
: max_pixels_per_frame_(absl::nullopt),
target_pixels_per_frame_(absl::nullopt),
max_frame_rate_(absl::nullopt) {}
VideoSourceRestrictions::VideoSourceRestrictions(
absl::optional<size_t> max_pixels_per_frame,
absl::optional<size_t> target_pixels_per_frame,
absl::optional<double> max_frame_rate)
: max_pixels_per_frame_(std::move(max_pixels_per_frame)),
target_pixels_per_frame_(std::move(target_pixels_per_frame)),
max_frame_rate_(std::move(max_frame_rate)) {
RTC_DCHECK(!max_pixels_per_frame_.has_value() ||
max_pixels_per_frame_.value() <
static_cast<size_t>(std::numeric_limits<int>::max()));
RTC_DCHECK(!max_frame_rate_.has_value() ||
max_frame_rate_.value() < std::numeric_limits<int>::max());
RTC_DCHECK(!max_frame_rate_.has_value() || max_frame_rate_.value() > 0.0);
}
const absl::optional<size_t>& VideoSourceRestrictions::max_pixels_per_frame()
const {
return max_pixels_per_frame_;
}
const absl::optional<size_t>& VideoSourceRestrictions::target_pixels_per_frame()
const {
return target_pixels_per_frame_;
}
const absl::optional<double>& VideoSourceRestrictions::max_frame_rate() const {
return max_frame_rate_;
}
void VideoSourceRestrictions::set_max_pixels_per_frame(
absl::optional<size_t> max_pixels_per_frame) {
max_pixels_per_frame_ = std::move(max_pixels_per_frame);
}
void VideoSourceRestrictions::set_target_pixels_per_frame(
absl::optional<size_t> target_pixels_per_frame) {
target_pixels_per_frame_ = std::move(target_pixels_per_frame);
}
void VideoSourceRestrictions::set_max_frame_rate(
absl::optional<double> max_frame_rate) {
max_frame_rate_ = std::move(max_frame_rate);
}
} // namespace webrtc