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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Called for each captured frame. | 80 // Called for each captured frame. |
81 void FrameCaptured(const VideoFrame& frame, int64_t time_when_first_seen_us); | 81 void FrameCaptured(const VideoFrame& frame, int64_t time_when_first_seen_us); |
82 | 82 |
83 // Called for each sent frame. | 83 // Called for each sent frame. |
84 void FrameSent(uint32_t timestamp, int64_t time_sent_in_us); | 84 void FrameSent(uint32_t timestamp, int64_t time_sent_in_us); |
85 | 85 |
86 protected: | 86 protected: |
87 void CheckForOveruse(); // Protected for test purposes. | 87 void CheckForOveruse(); // Protected for test purposes. |
88 | 88 |
89 private: | 89 private: |
90 class OverdoseInjector; | |
91 class SendProcessingUsage; | 90 class SendProcessingUsage; |
92 class CheckOveruseTask; | 91 class CheckOveruseTask; |
93 struct FrameTiming { | 92 struct FrameTiming { |
94 FrameTiming(int64_t capture_time_us, uint32_t timestamp, int64_t now) | 93 FrameTiming(int64_t capture_time_us, uint32_t timestamp, int64_t now) |
95 : capture_time_us(capture_time_us), | 94 : capture_time_us(capture_time_us), |
96 timestamp(timestamp), | 95 timestamp(timestamp), |
97 capture_us(now), | 96 capture_us(now), |
98 last_send_us(-1) {} | 97 last_send_us(-1) {} |
99 int64_t capture_time_us; | 98 int64_t capture_time_us; |
100 uint32_t timestamp; | 99 uint32_t timestamp; |
101 int64_t capture_us; | 100 int64_t capture_us; |
102 int64_t last_send_us; | 101 int64_t last_send_us; |
103 }; | 102 }; |
104 | 103 |
105 void EncodedFrameTimeMeasured(int encode_duration_ms); | 104 void EncodedFrameTimeMeasured(int encode_duration_ms); |
106 bool IsOverusing(const CpuOveruseMetrics& metrics); | 105 bool IsOverusing(const CpuOveruseMetrics& metrics); |
107 bool IsUnderusing(const CpuOveruseMetrics& metrics, int64_t time_now); | 106 bool IsUnderusing(const CpuOveruseMetrics& metrics, int64_t time_now); |
108 | 107 |
109 bool FrameTimeoutDetected(int64_t now) const; | 108 bool FrameTimeoutDetected(int64_t now) const; |
110 bool FrameSizeChanged(int num_pixels) const; | 109 bool FrameSizeChanged(int num_pixels) const; |
111 | 110 |
112 void ResetAll(int num_pixels); | 111 void ResetAll(int num_pixels); |
113 | 112 |
114 static std::unique_ptr<SendProcessingUsage> CreateSendProcessingUsage( | |
115 const CpuOveruseOptions& options); | |
116 | |
117 rtc::SequencedTaskChecker task_checker_; | 113 rtc::SequencedTaskChecker task_checker_; |
118 // Owned by the task queue from where StartCheckForOveruse is called. | 114 // Owned by the task queue from where StartCheckForOveruse is called. |
119 CheckOveruseTask* check_overuse_task_; | 115 CheckOveruseTask* check_overuse_task_; |
120 | 116 |
121 const CpuOveruseOptions options_; | 117 const CpuOveruseOptions options_; |
122 | 118 |
123 // Observer getting overuse reports. | 119 // Observer getting overuse reports. |
124 AdaptationObserverInterface* const observer_; | 120 AdaptationObserverInterface* const observer_; |
125 EncodedFrameObserver* const encoder_timing_; | 121 EncodedFrameObserver* const encoder_timing_; |
126 | 122 |
(...skipping 19 matching lines...) Expand all Loading... |
146 // allocs)? | 142 // allocs)? |
147 const std::unique_ptr<SendProcessingUsage> usage_ GUARDED_BY(task_checker_); | 143 const std::unique_ptr<SendProcessingUsage> usage_ GUARDED_BY(task_checker_); |
148 std::list<FrameTiming> frame_timing_ GUARDED_BY(task_checker_); | 144 std::list<FrameTiming> frame_timing_ GUARDED_BY(task_checker_); |
149 | 145 |
150 RTC_DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector); | 146 RTC_DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector); |
151 }; | 147 }; |
152 | 148 |
153 } // namespace webrtc | 149 } // namespace webrtc |
154 | 150 |
155 #endif // WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_ | 151 #endif // WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_ |
OLD | NEW |