Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: webrtc/video/vie_encoder.h

Issue 2398963003: Move usage of QualityScaler to ViEEncoder. (Closed)
Patch Set: Report dropped frames to ViEEncoder Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/video/vie_encoder.h
diff --git a/webrtc/video/vie_encoder.h b/webrtc/video/vie_encoder.h
index 433e9ceb5eb0ae2ad2a95ee97bcfb9b27fbd6ce3..5f65e16343193d6098192cff5cf9b0761e06224d 100644
--- a/webrtc/video/vie_encoder.h
+++ b/webrtc/video/vie_encoder.h
@@ -25,6 +25,7 @@
#include "webrtc/common_video/rotation.h"
#include "webrtc/media/base/videosinkinterface.h"
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
+#include "webrtc/modules/video_coding/utility/quality_scaler.h"
#include "webrtc/modules/video_coding/video_coding_impl.h"
#include "webrtc/modules/video_processing/include/video_processing.h"
#include "webrtc/system_wrappers/include/atomic32.h"
@@ -49,7 +50,7 @@ class SendStatisticsProxy;
class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
public EncodedImageCallback,
public VCMSendStatisticsCallback,
- public CpuOveruseObserver {
+ public ScalingObserverInterface {
public:
// Interface for receiving encoded video frames and notifications about
// configuration changes.
@@ -60,8 +61,10 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
int min_transmit_bitrate_bps) = 0;
};
- // Down grade resolution at most 2 times for CPU reasons.
+ // Downscale resolution at most 2 times for CPU reasons.
static const int kMaxCpuDowngrades = 2;
+ // Downscale resolution at most 2 times for low-quality reasons.
+ static const int kMaxQualityDowngrades = 2;
ViEEncoder(uint32_t number_of_cores,
SendStatisticsProxy* stats_proxy,
@@ -110,14 +113,14 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
int64_t round_trip_time_ms);
protected:
- // Used for testing. For example the |CpuOveruseObserver| methods must be
- // called on |encoder_queue_|.
+ // Used for testing. For example the |ScalingObserverInterface| methods must
+ // be called on |encoder_queue_|.
rtc::TaskQueue* encoder_queue() { return &encoder_queue_; }
- // webrtc::CpuOveruseObserver implementation.
+ // webrtc::ScalingObserverInterface implementation.
// These methods are protected for easier testing.
- void OveruseDetected() override;
- void NormalUsage() override;
+ void ScaleUp(ScaleReason reason) override;
+ void ScaleDown(ScaleReason reason) override;
private:
class ConfigureEncoderTask;
@@ -159,6 +162,8 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
const CodecSpecificInfo* codec_specific_info,
const RTPFragmentationHeader* fragmentation) override;
+ void OnDroppedFrame() override;
stefan-webrtc 2016/11/25 10:45:25 Should / can we add tests for this which would hav
kthelgason 2016/11/25 12:34:01 As to whether we should, I think the answer is yes
+
bool EncoderPaused() const;
void TraceFrameDropStart();
void TraceFrameDropEnd();
@@ -174,6 +179,7 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_);
OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_);
+ std::unique_ptr<QualityScaler> quality_scaler_ ACCESS_ON(&encoder_queue_);
SendStatisticsProxy* const stats_proxy_;
rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_;
@@ -200,12 +206,11 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>,
bool has_received_rpsi_ ACCESS_ON(&encoder_queue_);
uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_);
Clock* const clock_;
-
- VideoSendStream::DegradationPreference degradation_preference_
- ACCESS_ON(&encoder_queue_);
- // Counter used for deciding if the video resolution is currently
- // restricted by CPU usage.
- int cpu_restricted_counter_ ACCESS_ON(&encoder_queue_);
+ // Counters used for deciding if the video resolution is currently
+ // restricted, and if so, why.
+ int scale_counter_[kScaleReasonSize] ACCESS_ON(&encoder_queue_) = {0};
+ // Set depending on degradation preferences
+ bool scaling_enabled_ ACCESS_ON(&encoder_queue_) = false;
int last_frame_width_ ACCESS_ON(&encoder_queue_);
int last_frame_height_ ACCESS_ON(&encoder_queue_);

Powered by Google App Engine
This is Rietveld 408576698