
This CL simply moves the VideoSourceRestrictor from being an inner class of OveruseFrameDetectorResourceAdaptationModule to a new class, VideoStreamAdapter. In follow-up CLs, the responsibility of determining what the next step for adapting up or down should also be moved to the VideoStreamAdapter. The end-goal is that the VideoStreamAdapter takes care of "can adapt?" and "do adapt!" type of logic so that a multi-stream aware adaptation module can decide which stream (adapter) to adapt, and the adapter can take care of the nitty gritty details of doing so. In this CL the "can?"/"do!" part is realized but not the logic for determining what the next step up or down is, and the class interface needs improvement. This CL also sets up the video/adaptation/ subdirectory and moves the AdaptationCounters class here. Other adaptation-related classes (e.g. the module and its resources) should move into this directory as well in the future. Bug: webrtc:11393 Change-Id: I2c12c1281eca854c62791abb65f0aca47a119726 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/169542 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30705}
67 lines
2.4 KiB
C++
67 lines
2.4 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.
|
|
*/
|
|
|
|
#ifndef VIDEO_ADAPTATION_VIDEO_STREAM_ADAPTER_H_
|
|
#define VIDEO_ADAPTATION_VIDEO_STREAM_ADAPTER_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "call/adaptation/video_source_restrictions.h"
|
|
#include "video/adaptation/adaptation_counters.h"
|
|
|
|
namespace webrtc {
|
|
|
|
// Owns the VideoSourceRestriction for a single stream and is responsible for
|
|
// adapting it up or down when told to do so. This class serves the following
|
|
// purposes:
|
|
// 1. Keep track of a stream's restrictions.
|
|
// 2. Provide valid ways to adapt up or down the stream's restrictions.
|
|
// 3. Modify the stream's restrictions in one of the valid ways.
|
|
class VideoStreamAdapter {
|
|
public:
|
|
static const int kMinFramerateFps;
|
|
|
|
static int GetLowerFrameRateThan(int fps);
|
|
static int GetHigherFrameRateThan(int fps);
|
|
static int GetLowerResolutionThan(int pixel_count);
|
|
static int GetHigherResolutionThan(int pixel_count);
|
|
|
|
VideoStreamAdapter();
|
|
~VideoStreamAdapter();
|
|
|
|
// TODO(hbos): Why isn't this const?
|
|
VideoSourceRestrictions source_restrictions() const;
|
|
const AdaptationCounters& adaptation_counters() const;
|
|
void ClearRestrictions();
|
|
|
|
// "Can adapt?" and "do adapt!" methods.
|
|
// TODO(https://crbug.com/webrtc/11393): Make the adapter responsible for
|
|
// deciding what the next step are, i.e. taking on degradation preference
|
|
// logic. Then, these can be expressed either as CanAdaptUp() and DoAdaptUp()
|
|
// or as GetNextRestrictionsUp() and ApplyRestrictions().
|
|
bool CanDecreaseResolutionTo(int target_pixels, int min_pixels_per_frame);
|
|
void DecreaseResolutionTo(int target_pixels, int min_pixels_per_frame);
|
|
bool CanIncreaseResolutionTo(int target_pixels);
|
|
void IncreaseResolutionTo(int target_pixels);
|
|
bool CanDecreaseFrameRateTo(int max_frame_rate);
|
|
void DecreaseFrameRateTo(int max_frame_rate);
|
|
bool CanIncreaseFrameRateTo(int max_frame_rate);
|
|
void IncreaseFrameRateTo(int max_frame_rate);
|
|
|
|
private:
|
|
class VideoSourceRestrictor;
|
|
|
|
const std::unique_ptr<VideoSourceRestrictor> source_restrictor_;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // VIDEO_ADAPTATION_VIDEO_STREAM_ADAPTER_H_
|