#include "call/adaptation/video_stream_adapter.h"
#include <algorithm>
#include <limits>
#include <utility>
#include "absl/types/optional.h"
#include "absl/types/variant.h"
#include "api/sequence_checker.h"
#include "api/video/video_adaptation_counters.h"
#include "api/video/video_adaptation_reason.h"
#include "api/video_codecs/video_encoder.h"
#include "call/adaptation/video_source_restrictions.h"
#include "call/adaptation/video_stream_input_state.h"
#include "modules/video_coding/svc/scalability_mode_util.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
namespace webrtc {
const int kMinFrameRateFps = …;
namespace {
int GetLowerFrameRateThan(int fps) { … }
int GetHigherFrameRateThan(int fps) { … }
int GetIncreasedMaxPixelsWanted(int target_pixels) { … }
bool CanDecreaseResolutionTo(int target_pixels,
int target_pixels_min,
const VideoStreamInputState& input_state,
const VideoSourceRestrictions& restrictions) { … }
bool CanIncreaseResolutionTo(int target_pixels,
const VideoSourceRestrictions& restrictions) { … }
bool CanDecreaseFrameRateTo(int max_frame_rate,
const VideoSourceRestrictions& restrictions) { … }
bool CanIncreaseFrameRateTo(int max_frame_rate,
const VideoSourceRestrictions& restrictions) { … }
bool MinPixelLimitReached(const VideoStreamInputState& input_state) { … }
}
VideoSourceRestrictionsListener::~VideoSourceRestrictionsListener() = default;
VideoSourceRestrictions FilterRestrictionsByDegradationPreference(
VideoSourceRestrictions source_restrictions,
DegradationPreference degradation_preference) { … }
int GetLowerResolutionThan(int pixel_count) { … }
int GetHigherResolutionThan(int pixel_count) { … }
const char* Adaptation::StatusToString(Adaptation::Status status) { … }
Adaptation::Adaptation(int validation_id,
VideoSourceRestrictions restrictions,
VideoAdaptationCounters counters,
VideoStreamInputState input_state)
: … { … }
Adaptation::Adaptation(int validation_id, Status invalid_status)
: … { … }
Adaptation::Status Adaptation::status() const { … }
const VideoStreamInputState& Adaptation::input_state() const { … }
const VideoSourceRestrictions& Adaptation::restrictions() const { … }
const VideoAdaptationCounters& Adaptation::counters() const { … }
VideoStreamAdapter::VideoStreamAdapter(
VideoStreamInputStateProvider* input_state_provider,
VideoStreamEncoderObserver* encoder_stats_observer,
const FieldTrialsView& field_trials)
: … { … }
VideoStreamAdapter::~VideoStreamAdapter() { … }
VideoSourceRestrictions VideoStreamAdapter::source_restrictions() const { … }
const VideoAdaptationCounters& VideoStreamAdapter::adaptation_counters() const { … }
void VideoStreamAdapter::ClearRestrictions() { … }
void VideoStreamAdapter::AddRestrictionsListener(
VideoSourceRestrictionsListener* restrictions_listener) { … }
void VideoStreamAdapter::RemoveRestrictionsListener(
VideoSourceRestrictionsListener* restrictions_listener) { … }
void VideoStreamAdapter::AddAdaptationConstraint(
AdaptationConstraint* adaptation_constraint) { … }
void VideoStreamAdapter::RemoveAdaptationConstraint(
AdaptationConstraint* adaptation_constraint) { … }
void VideoStreamAdapter::SetDegradationPreference(
DegradationPreference degradation_preference) { … }
struct VideoStreamAdapter::RestrictionsOrStateVisitor { … };
Adaptation VideoStreamAdapter::RestrictionsOrStateToAdaptation(
VideoStreamAdapter::RestrictionsOrState step_or_state,
const VideoStreamInputState& input_state) const { … }
Adaptation VideoStreamAdapter::GetAdaptationUp(
const VideoStreamInputState& input_state) const { … }
Adaptation VideoStreamAdapter::GetAdaptationUp() { … }
VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::GetAdaptationUpStep(
const VideoStreamInputState& input_state) const { … }
Adaptation VideoStreamAdapter::GetAdaptationDown() { … }
VideoStreamAdapter::RestrictionsOrState
VideoStreamAdapter::AdaptIfFpsDiffInsufficient(
const VideoStreamInputState& input_state,
const RestrictionsWithCounters& restrictions) const { … }
VideoStreamAdapter::RestrictionsOrState
VideoStreamAdapter::GetAdaptationDownStep(
const VideoStreamInputState& input_state,
const RestrictionsWithCounters& current_restrictions) const { … }
VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::DecreaseResolution(
const VideoStreamInputState& input_state,
const RestrictionsWithCounters& current_restrictions) { … }
VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::DecreaseFramerate(
const VideoStreamInputState& input_state,
const RestrictionsWithCounters& current_restrictions) const { … }
VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::IncreaseResolution(
const VideoStreamInputState& input_state,
const RestrictionsWithCounters& current_restrictions) { … }
VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::IncreaseFramerate(
const VideoStreamInputState& input_state,
const RestrictionsWithCounters& current_restrictions) const { … }
Adaptation VideoStreamAdapter::GetAdaptDownResolution() { … }
VideoStreamAdapter::RestrictionsOrState
VideoStreamAdapter::GetAdaptDownResolutionStepForBalanced(
const VideoStreamInputState& input_state) const { … }
void VideoStreamAdapter::ApplyAdaptation(
const Adaptation& adaptation,
rtc::scoped_refptr<Resource> resource) { … }
Adaptation VideoStreamAdapter::GetAdaptationTo(
const VideoAdaptationCounters& counters,
const VideoSourceRestrictions& restrictions) { … }
void VideoStreamAdapter::BroadcastVideoRestrictionsUpdate(
const VideoStreamInputState& input_state,
const rtc::scoped_refptr<Resource>& resource) { … }
bool VideoStreamAdapter::HasSufficientInputForAdaptation(
const VideoStreamInputState& input_state) const { … }
VideoStreamAdapter::AwaitingFrameSizeChange::AwaitingFrameSizeChange(
bool pixels_increased,
int frame_size_pixels)
: … { … }
absl::optional<uint32_t> VideoStreamAdapter::GetSingleActiveLayerPixels(
const VideoCodec& codec) { … }
}