Remove VideoStreamEncoderObserver::AdaptationReason::kNone
Replaces this with 2 methods instead, adding clarity.
ClearAdaptationStats
- Resets the adaptations statistics to 0. This is done,
when the degredation is reset, for example when the preference
is changed to/from BALANCED.
UpdateAdaptationMaskingSettings
- Updates the settings for adaptation statistics reporting.
This way we don't report quality adaptations if quality scaling
is not enabled (same for resolution/fps scaling).
The adaptation counting inside the SendStatisticsProxy is
now done in a struct that counts the totals, and then masks
out these counts based on the adaptation settings. The
MaskedAdaptationSteps uses optionals to hide the values we
shoudn't report, while the AdaptationSteps always hold the real
totals.
All tests have been updated to use the Reset/Clear method as needed.
Now that AdaptationCounters and AdaptSteps use the same structure,
AdaptationCounters was moved to api/video and replaces AdaptSteps.
The AdaptReason enum is also redundant now, and will be removed
in a follow-up CL.
R=hbos@webrtc.org
Bug: webrtc:11392
Change-Id: Iaed6488581325d341a056b5bbf76a01c19d6c282
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171685
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31083}
diff --git a/api/video/video_stream_encoder_observer.h b/api/video/video_stream_encoder_observer.h
index 9fd462c..ab889bc 100644
--- a/api/video/video_stream_encoder_observer.h
+++ b/api/video/video_stream_encoder_observer.h
@@ -15,6 +15,7 @@
#include <vector>
#include "absl/types/optional.h"
+#include "api/video/video_adaptation_counters.h"
#include "api/video/video_bitrate_allocation.h"
#include "api/video/video_codec_constants.h"
#include "api/video_codecs/video_encoder.h"
@@ -38,22 +39,27 @@
class VideoStreamEncoderObserver : public CpuOveruseMetricsObserver {
public:
- // Number of resolution and framerate reductions (unset if disabled).
- struct AdaptationSteps {
- AdaptationSteps();
- absl::optional<int> num_resolution_reductions = 0;
- absl::optional<int> num_framerate_reductions = 0;
- };
-
// TODO(nisse): There are too many enums to represent this. Besides
// this one, see AdaptationObserverInterface::AdaptReason and
// WebRtcVideoChannel::AdaptReason.
enum class AdaptationReason {
- kNone, // Used for reset of counters.
kCpu,
kQuality,
};
+ struct AdaptationSettings {
+ AdaptationSettings()
+ : resolution_scaling_enabled(false), framerate_scaling_enabled(false) {}
+
+ AdaptationSettings(bool resolution_scaling_enabled,
+ bool framerate_scaling_enabled)
+ : resolution_scaling_enabled(resolution_scaling_enabled),
+ framerate_scaling_enabled(framerate_scaling_enabled) {}
+
+ bool resolution_scaling_enabled;
+ bool framerate_scaling_enabled;
+ };
+
// TODO(nisse): Duplicates enum EncodedImageCallback::DropReason.
enum class DropReason {
kSource,
@@ -83,9 +89,15 @@
const VideoEncoderConfig& encoder_config,
const std::vector<VideoStream>& streams) = 0;
- virtual void OnAdaptationChanged(AdaptationReason reason,
- const AdaptationSteps& cpu_steps,
- const AdaptationSteps& quality_steps) = 0;
+ virtual void OnAdaptationChanged(
+ AdaptationReason reason,
+ const VideoAdaptationCounters& cpu_steps,
+ const VideoAdaptationCounters& quality_steps) = 0;
+ virtual void ClearAdaptationStats() = 0;
+
+ virtual void UpdateAdaptationSettings(
+ AdaptationSettings cpu_settings,
+ AdaptationSettings quality_settings) = 0;
virtual void OnMinPixelLimitReached() = 0;
virtual void OnInitialQualityResolutionAdaptDown() = 0;