Index: webrtc/video/vie_encoder.h |
diff --git a/webrtc/video/vie_encoder.h b/webrtc/video/vie_encoder.h |
index 213ff6d0a24c2c788663fce1de7c3f15f8c7a680..e209f5d14a5537974691942ad4718dda9e71a44d 100644 |
--- a/webrtc/video/vie_encoder.h |
+++ b/webrtc/video/vie_encoder.h |
@@ -62,6 +62,11 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
int min_transmit_bitrate_bps) = 0; |
}; |
+ struct AdaptCounts { |
+ int resolution = 0; |
+ int fps = 0; |
+ }; |
sprang_webrtc
2017/05/10 09:34:23
Maybe this can be declared together with the count
åsapersson
2017/05/10 09:54:53
The struct is public.
|
+ |
// Downscale resolution at most 2 times for CPU reasons. |
static const int kMaxCpuResolutionDowngrades = 2; |
// Downscale framerate at most 4 times. |
@@ -175,9 +180,49 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
void TraceFrameDropStart(); |
void TraceFrameDropEnd(); |
- const std::vector<int>& GetScaleCounters() |
+ // Class holding adaptation information. |
+ class AdaptCounter { |
+ public: |
+ AdaptCounter(); |
+ ~AdaptCounter(); |
sprang_webrtc
2017/05/10 09:34:24
nit: virtual destructor or final class
åsapersson
2017/05/10 09:54:53
Done.
|
+ |
+ // Get number of adaptation downscales for |reason|. |
+ AdaptCounts Counts(int reason) const; |
+ |
+ std::string ToString() const; |
+ |
+ void IncrementFramerate(int reason, int delta); |
+ void IncrementResolution(int reason, int delta); |
+ |
+ // Gets the total number of downgrades (for all adapt reasons). |
+ int FramerateCount() const; |
+ int ResolutionCount() const; |
+ int TotalCount() const; |
+ |
+ // Gets the total number of downgrades for |reason|. |
+ int FramerateCount(int reason) const; |
+ int ResolutionCount(int reason) const; |
+ int TotalCount(int reason) const; |
+ |
+ private: |
+ std::string ToString(const std::vector<int>& counters) const; |
+ int Count(const std::vector<int>& counters) const; |
+ |
+ // Degradation counters holding number of framerate/resolution reductions |
+ // per adapt reason. |
+ std::vector<int> fps_counters_; |
+ std::vector<int> resolution_counters_; |
+ }; |
+ |
+ const AdaptCounter& GetAdaptCounter() |
+ EXCLUSIVE_LOCKS_REQUIRED(&encoder_queue_); |
+ void IncrementFramerateCounter(AdaptReason reason, int delta) |
+ EXCLUSIVE_LOCKS_REQUIRED(&encoder_queue_); |
kthelgason
2017/05/09 11:50:15
I've been using the RUN_ON macro for asserting tha
åsapersson
2017/05/10 08:24:45
Done.
|
+ void IncrementResolutionCounter(AdaptReason reason, int delta) |
+ EXCLUSIVE_LOCKS_REQUIRED(&encoder_queue_); |
+ void UpdateAdaptationStats(AdaptReason reason) |
EXCLUSIVE_LOCKS_REQUIRED(&encoder_queue_); |
- void IncrementScaleCounter(int reason, int delta) |
+ ViEEncoder::AdaptCounts GetActiveCounts(AdaptReason reason) |
EXCLUSIVE_LOCKS_REQUIRED(&encoder_queue_); |
rtc::Event shutdown_event_; |
@@ -217,13 +262,14 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); |
bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); |
Clock* const clock_; |
- // Counters used for deciding if the video resolution is currently |
- // restricted, and if so, why, on a per degradation preference basis. |
+ // Counters used for deciding if the video resolution or framerate is |
+ // currently restricted, and if so, why, on a per degradation preference |
+ // basis. |
// TODO(sprang): Replace this with a state holding a relative overuse measure |
// instead, that can be translated into suitable down-scale or fps limit. |
- std::map<const VideoSendStream::DegradationPreference, std::vector<int>> |
- scale_counters_ ACCESS_ON(&encoder_queue_); |
- // Set depending on degradation preferences |
+ std::map<const VideoSendStream::DegradationPreference, AdaptCounter> |
+ adapt_counters_ ACCESS_ON(&encoder_queue_); |
+ // Set depending on degradation preferences. |
VideoSendStream::DegradationPreference degradation_preference_ |
ACCESS_ON(&encoder_queue_); |