OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // frames before resetting estimations. | 60 // frames before resetting estimations. |
61 int min_frame_samples; // The minimum number of frames required. | 61 int min_frame_samples; // The minimum number of frames required. |
62 int min_process_count; // The number of initial process times required before | 62 int min_process_count; // The number of initial process times required before |
63 // triggering an overuse/underuse. | 63 // triggering an overuse/underuse. |
64 int high_threshold_consecutive_count; // The number of consecutive checks | 64 int high_threshold_consecutive_count; // The number of consecutive checks |
65 // above the high threshold before | 65 // above the high threshold before |
66 // triggering an overuse. | 66 // triggering an overuse. |
67 }; | 67 }; |
68 | 68 |
69 struct CpuOveruseMetrics { | 69 struct CpuOveruseMetrics { |
70 CpuOveruseMetrics() | 70 CpuOveruseMetrics() : encode_usage_percent(-1) {} |
71 : avg_encode_time_ms(-1), | |
72 encode_usage_percent(-1) {} | |
73 | 71 |
74 int avg_encode_time_ms; // Average encode time in ms. | |
75 int encode_usage_percent; // Average encode time divided by the average time | 72 int encode_usage_percent; // Average encode time divided by the average time |
76 // difference between incoming captured frames. | 73 // difference between incoming captured frames. |
77 }; | 74 }; |
78 | 75 |
79 class CpuOveruseMetricsObserver { | 76 class CpuOveruseMetricsObserver { |
80 public: | 77 public: |
81 virtual ~CpuOveruseMetricsObserver() {} | 78 virtual ~CpuOveruseMetricsObserver() {} |
82 virtual void CpuOveruseMetricsUpdated(const CpuOveruseMetrics& metrics) = 0; | 79 virtual void CpuOveruseMetricsUpdated(const CpuOveruseMetrics& metrics) = 0; |
83 }; | 80 }; |
84 | 81 |
(...skipping 19 matching lines...) Expand all Loading... |
104 | 101 |
105 // Only public for testing. | 102 // Only public for testing. |
106 int LastProcessingTimeMs() const; | 103 int LastProcessingTimeMs() const; |
107 int FramesInQueue() const; | 104 int FramesInQueue() const; |
108 | 105 |
109 // Implements Module. | 106 // Implements Module. |
110 int64_t TimeUntilNextProcess() override; | 107 int64_t TimeUntilNextProcess() override; |
111 int32_t Process() override; | 108 int32_t Process() override; |
112 | 109 |
113 private: | 110 private: |
114 class EncodeTimeAvg; | |
115 class SendProcessingUsage; | 111 class SendProcessingUsage; |
116 class FrameQueue; | 112 class FrameQueue; |
117 | 113 |
118 void UpdateCpuOveruseMetrics() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 114 void UpdateCpuOveruseMetrics() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
119 | 115 |
120 // TODO(asapersson): This method is only used on one thread, so it shouldn't | 116 // TODO(asapersson): This method is only used on one thread, so it shouldn't |
121 // need a guard. | 117 // need a guard. |
122 void AddProcessingTime(int elapsed_ms) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 118 void AddProcessingTime(int elapsed_ms) EXCLUSIVE_LOCKS_REQUIRED(crit_); |
123 | 119 |
124 // Only called on the processing thread. | 120 // Only called on the processing thread. |
(...skipping 30 matching lines...) Expand all Loading... |
155 | 151 |
156 // These seven members are only accessed on the processing thread. | 152 // These seven members are only accessed on the processing thread. |
157 int64_t next_process_time_; | 153 int64_t next_process_time_; |
158 int64_t last_overuse_time_; | 154 int64_t last_overuse_time_; |
159 int checks_above_threshold_; | 155 int checks_above_threshold_; |
160 int num_overuse_detections_; | 156 int num_overuse_detections_; |
161 int64_t last_rampup_time_; | 157 int64_t last_rampup_time_; |
162 bool in_quick_rampup_; | 158 bool in_quick_rampup_; |
163 int current_rampup_delay_ms_; | 159 int current_rampup_delay_ms_; |
164 | 160 |
165 int64_t last_encode_sample_ms_; // Only accessed by one thread. | |
166 int64_t last_sample_time_ms_; // Only accessed by one thread. | 161 int64_t last_sample_time_ms_; // Only accessed by one thread. |
167 | 162 |
168 // TODO(asapersson): Can these be regular members (avoid separate heap | 163 // TODO(asapersson): Can these be regular members (avoid separate heap |
169 // allocs)? | 164 // allocs)? |
170 const rtc::scoped_ptr<EncodeTimeAvg> encode_time_ GUARDED_BY(crit_); | |
171 const rtc::scoped_ptr<SendProcessingUsage> usage_ GUARDED_BY(crit_); | 165 const rtc::scoped_ptr<SendProcessingUsage> usage_ GUARDED_BY(crit_); |
172 const rtc::scoped_ptr<FrameQueue> frame_queue_ GUARDED_BY(crit_); | 166 const rtc::scoped_ptr<FrameQueue> frame_queue_ GUARDED_BY(crit_); |
173 | 167 |
174 rtc::ThreadChecker processing_thread_; | 168 rtc::ThreadChecker processing_thread_; |
175 | 169 |
176 RTC_DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector); | 170 RTC_DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector); |
177 }; | 171 }; |
178 | 172 |
179 } // namespace webrtc | 173 } // namespace webrtc |
180 | 174 |
181 #endif // WEBRTC_VIDEO_ENGINE_OVERUSE_FRAME_DETECTOR_H_ | 175 #endif // WEBRTC_VIDEO_ENGINE_OVERUSE_FRAME_DETECTOR_H_ |
OLD | NEW |