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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 min_frame_samples == o.min_frame_samples && | 99 min_frame_samples == o.min_frame_samples && |
100 min_process_count == o.min_process_count && | 100 min_process_count == o.min_process_count && |
101 high_threshold_consecutive_count == o.high_threshold_consecutive_count; | 101 high_threshold_consecutive_count == o.high_threshold_consecutive_count; |
102 } | 102 } |
103 }; | 103 }; |
104 | 104 |
105 struct CpuOveruseMetrics { | 105 struct CpuOveruseMetrics { |
106 CpuOveruseMetrics() | 106 CpuOveruseMetrics() |
107 : capture_jitter_ms(-1), | 107 : capture_jitter_ms(-1), |
108 avg_encode_time_ms(-1), | 108 avg_encode_time_ms(-1), |
109 encode_usage_percent(-1), | 109 encode_usage_percent(-1) {} |
110 capture_queue_delay_ms_per_s(-1) {} | |
111 | 110 |
112 int capture_jitter_ms; // The current estimated jitter in ms based on | 111 int capture_jitter_ms; // The current estimated jitter in ms based on |
113 // incoming captured frames. | 112 // incoming captured frames. |
114 int avg_encode_time_ms; // The average encode time in ms. | 113 int avg_encode_time_ms; // The average encode time in ms. |
115 int encode_usage_percent; // The average encode time divided by the average | 114 int encode_usage_percent; // The average encode time divided by the average |
116 // time difference between incoming captured frames. | 115 // time difference between incoming captured frames. |
117 int capture_queue_delay_ms_per_s; // The current time delay between an | |
118 // incoming captured frame until the frame | |
119 // is being processed. The delay is | |
120 // expressed in ms delay per second. | |
121 }; | 116 }; |
122 | 117 |
123 class CpuOveruseMetricsObserver { | 118 class CpuOveruseMetricsObserver { |
124 public: | 119 public: |
125 virtual ~CpuOveruseMetricsObserver() {} | 120 virtual ~CpuOveruseMetricsObserver() {} |
126 virtual void CpuOveruseMetricsUpdated(const CpuOveruseMetrics& metrics) = 0; | 121 virtual void CpuOveruseMetricsUpdated(const CpuOveruseMetrics& metrics) = 0; |
127 }; | 122 }; |
128 | 123 |
129 // TODO(pbos): Move this somewhere appropriate. | 124 // TODO(pbos): Move this somewhere appropriate. |
130 class Statistics { | 125 class Statistics { |
(...skipping 23 matching lines...) Expand all Loading... |
154 public: | 149 public: |
155 OveruseFrameDetector(Clock* clock, | 150 OveruseFrameDetector(Clock* clock, |
156 const CpuOveruseOptions& options, | 151 const CpuOveruseOptions& options, |
157 CpuOveruseObserver* overuse_observer, | 152 CpuOveruseObserver* overuse_observer, |
158 CpuOveruseMetricsObserver* metrics_observer); | 153 CpuOveruseMetricsObserver* metrics_observer); |
159 ~OveruseFrameDetector(); | 154 ~OveruseFrameDetector(); |
160 | 155 |
161 // Called for each captured frame. | 156 // Called for each captured frame. |
162 void FrameCaptured(int width, int height, int64_t capture_time_ms); | 157 void FrameCaptured(int width, int height, int64_t capture_time_ms); |
163 | 158 |
164 // Called when the processing of a captured frame is started. | |
165 void FrameProcessingStarted(); | |
166 | |
167 // Called for each encoded frame. | 159 // Called for each encoded frame. |
168 void FrameEncoded(int encode_time_ms); | 160 void FrameEncoded(int encode_time_ms); |
169 | 161 |
170 // Called for each sent frame. | 162 // Called for each sent frame. |
171 void FrameSent(int64_t capture_time_ms); | 163 void FrameSent(int64_t capture_time_ms); |
172 | 164 |
173 // Only public for testing. | 165 // Only public for testing. |
174 int CaptureQueueDelayMsPerS() const; | |
175 int LastProcessingTimeMs() const; | 166 int LastProcessingTimeMs() const; |
176 int FramesInQueue() const; | 167 int FramesInQueue() const; |
177 | 168 |
178 // Implements Module. | 169 // Implements Module. |
179 int64_t TimeUntilNextProcess() override; | 170 int64_t TimeUntilNextProcess() override; |
180 int32_t Process() override; | 171 int32_t Process() override; |
181 | 172 |
182 private: | 173 private: |
183 class EncodeTimeAvg; | 174 class EncodeTimeAvg; |
184 class SendProcessingUsage; | 175 class SendProcessingUsage; |
185 class CaptureQueueDelay; | |
186 class FrameQueue; | 176 class FrameQueue; |
187 | 177 |
188 void UpdateCpuOveruseMetrics() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 178 void UpdateCpuOveruseMetrics() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
189 | 179 |
190 // TODO(asapersson): This method is only used on one thread, so it shouldn't | 180 // TODO(asapersson): This method is only used on one thread, so it shouldn't |
191 // need a guard. | 181 // need a guard. |
192 void AddProcessingTime(int elapsed_ms) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 182 void AddProcessingTime(int elapsed_ms) EXCLUSIVE_LOCKS_REQUIRED(crit_); |
193 | 183 |
194 // TODO(asapersson): This method is always called on the processing thread. | 184 // TODO(asapersson): This method is always called on the processing thread. |
195 // If locking is required, consider doing that locking inside the | 185 // If locking is required, consider doing that locking inside the |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 int64_t last_encode_sample_ms_; // Only accessed by one thread. | 230 int64_t last_encode_sample_ms_; // Only accessed by one thread. |
241 | 231 |
242 // TODO(asapersson): Can these be regular members (avoid separate heap | 232 // TODO(asapersson): Can these be regular members (avoid separate heap |
243 // allocs)? | 233 // allocs)? |
244 const rtc::scoped_ptr<EncodeTimeAvg> encode_time_ GUARDED_BY(crit_); | 234 const rtc::scoped_ptr<EncodeTimeAvg> encode_time_ GUARDED_BY(crit_); |
245 const rtc::scoped_ptr<SendProcessingUsage> usage_ GUARDED_BY(crit_); | 235 const rtc::scoped_ptr<SendProcessingUsage> usage_ GUARDED_BY(crit_); |
246 const rtc::scoped_ptr<FrameQueue> frame_queue_ GUARDED_BY(crit_); | 236 const rtc::scoped_ptr<FrameQueue> frame_queue_ GUARDED_BY(crit_); |
247 | 237 |
248 int64_t last_sample_time_ms_; // Only accessed by one thread. | 238 int64_t last_sample_time_ms_; // Only accessed by one thread. |
249 | 239 |
250 const rtc::scoped_ptr<CaptureQueueDelay> capture_queue_delay_ | |
251 GUARDED_BY(crit_); | |
252 | |
253 rtc::ThreadChecker processing_thread_; | 240 rtc::ThreadChecker processing_thread_; |
254 | 241 |
255 DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector); | 242 DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector); |
256 }; | 243 }; |
257 | 244 |
258 } // namespace webrtc | 245 } // namespace webrtc |
259 | 246 |
260 #endif // WEBRTC_VIDEO_ENGINE_OVERUSE_FRAME_DETECTOR_H_ | 247 #endif // WEBRTC_VIDEO_ENGINE_OVERUSE_FRAME_DETECTOR_H_ |
OLD | NEW |