Index: webrtc/modules/video_coding/utility/quality_scaler.h |
diff --git a/webrtc/modules/video_coding/utility/quality_scaler.h b/webrtc/modules/video_coding/utility/quality_scaler.h |
index c0f94409ce30ee0d5b46260857bc42f696f72c01..29eaa50e7c87892a6d2603f9d78d2251592b39cc 100644 |
--- a/webrtc/modules/video_coding/utility/quality_scaler.h |
+++ b/webrtc/modules/video_coding/utility/quality_scaler.h |
@@ -12,10 +12,25 @@ |
#define WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ |
#include "webrtc/common_types.h" |
+#include "webrtc/video_frame.h" |
+#include "webrtc/base/sequenced_task_checker.h" |
#include "webrtc/common_video/include/i420_buffer_pool.h" |
#include "webrtc/modules/video_coding/utility/moving_average.h" |
namespace webrtc { |
+ |
+// An interface for a class that receives scale up/down requests. |
+class ScalingInterface { |
kthelgason
2016/10/06 14:34:13
It may make sense to place this somewhere else. So
|
+ public: |
+ // Called as soon as an overuse is detected. |
+ virtual void ScaleUp() = 0; |
+ // Called periodically when the system is not overused any longer. |
+ virtual void ScaleDown() = 0; |
+ |
+ protected: |
+ virtual ~ScalingInterface() {} |
+}; |
+ |
class QualityScaler { |
public: |
struct Resolution { |
@@ -24,46 +39,37 @@ class QualityScaler { |
}; |
QualityScaler(); |
- void Init(VideoCodecType codec_type, |
- int initial_bitrate_kbps, |
- int width, |
- int height, |
- int fps); |
- void Init(int low_qp_threshold, |
+ virtual ~QualityScaler(); |
+ void Init(ScalingInterface* obeserver_, VideoCodecType codec_type, int fps); |
+ void Init(ScalingInterface* obeserver_, |
+ int low_qp_threshold, |
int high_qp_threshold, |
- int initial_bitrate_kbps, |
- int width, |
- int height, |
int fps); |
+ void Stop(); |
void ReportFramerate(int framerate); |
- void ReportQP(int qp); |
void ReportDroppedFrame(); |
- void OnEncodeFrame(int width, int height); |
- Resolution GetScaledResolution() const; |
- rtc::scoped_refptr<VideoFrameBuffer> GetScaledBuffer( |
- const rtc::scoped_refptr<VideoFrameBuffer>& frame); |
- int downscale_shift() const { return downscale_shift_; } |
+ void ReportQP(int qp); |
+ void CheckQP(); |
+ // This method declared virtual to help with testing. |
+ virtual int64_t GetTimeoutMs(); |
private: |
+ class CheckQPTask; |
void ClearSamples(); |
- void ScaleUp(); |
- void ScaleDown(); |
- void UpdateTargetResolution(int width, int height); |
+ void ReportQPLow(); |
+ void ReportQPHigh(); |
- I420BufferPool pool_; |
+ ScalingInterface* observer_; |
+ CheckQPTask* check_qp_task_; |
+ rtc::SequencedTaskChecker task_checker_; |
- size_t num_samples_downscale_; |
- size_t num_samples_upscale_; |
bool fast_rampup_; |
+ int64_t measure_interval_; |
MovingAverage average_qp_; |
MovingAverage framedrop_percent_; |
int low_qp_threshold_; |
int high_qp_threshold_; |
- Resolution target_res_; |
- |
- int downscale_shift_; |
- int maximum_shift_; |
}; |
} // namespace webrtc |