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

Side by Side Diff: webrtc/video/overuse_frame_detector.h

Issue 2398963003: Move usage of QualityScaler to ViEEncoder. (Closed)
Patch Set: rebase Created 4 years 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 unified diff | Download patch
OLDNEW
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
11 #ifndef WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_ 11 #ifndef WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_
12 #define WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_ 12 #define WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_
13 13
14 #include <list> 14 #include <list>
15 #include <memory> 15 #include <memory>
16 16
17 #include "webrtc/base/analytics/exp_filter.h" 17 #include "webrtc/base/analytics/exp_filter.h"
18 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/optional.h" 19 #include "webrtc/base/optional.h"
20 #include "webrtc/base/sequenced_task_checker.h" 20 #include "webrtc/base/sequenced_task_checker.h"
21 #include "webrtc/base/task_queue.h" 21 #include "webrtc/base/task_queue.h"
22 #include "webrtc/base/thread_annotations.h" 22 #include "webrtc/base/thread_annotations.h"
23 #include "webrtc/modules/video_coding/utility/quality_scaler.h"
23 24
24 namespace webrtc { 25 namespace webrtc {
25 26
26 class Clock; 27 class Clock;
27 class EncodedFrameObserver; 28 class EncodedFrameObserver;
28 class VideoFrame; 29 class VideoFrame;
29 30
30 // CpuOveruseObserver is called when a system overuse is detected and
31 // VideoEngine cannot keep up the encoding frequency.
32 class CpuOveruseObserver {
33 public:
34 // Called as soon as an overuse is detected.
35 virtual void OveruseDetected() = 0;
36 // Called periodically when the system is not overused any longer.
37 virtual void NormalUsage() = 0;
38
39 protected:
40 virtual ~CpuOveruseObserver() {}
41 };
42
43 struct CpuOveruseOptions { 31 struct CpuOveruseOptions {
44 CpuOveruseOptions(); 32 CpuOveruseOptions();
45 33
46 int low_encode_usage_threshold_percent; // Threshold for triggering underuse. 34 int low_encode_usage_threshold_percent; // Threshold for triggering underuse.
47 int high_encode_usage_threshold_percent; // Threshold for triggering overuse. 35 int high_encode_usage_threshold_percent; // Threshold for triggering overuse.
48 // General settings. 36 // General settings.
49 int frame_timeout_interval_ms; // The maximum allowed interval between two 37 int frame_timeout_interval_ms; // The maximum allowed interval between two
50 // frames before resetting estimations. 38 // frames before resetting estimations.
51 int min_frame_samples; // The minimum number of frames required. 39 int min_frame_samples; // The minimum number of frames required.
52 int min_process_count; // The number of initial process times required before 40 int min_process_count; // The number of initial process times required before
(...skipping 19 matching lines...) Expand all
72 60
73 // Use to detect system overuse based on the send-side processing time of 61 // Use to detect system overuse based on the send-side processing time of
74 // incoming frames. All methods must be called on a single task queue but it can 62 // incoming frames. All methods must be called on a single task queue but it can
75 // be created and destroyed on an arbitrary thread. 63 // be created and destroyed on an arbitrary thread.
76 // OveruseFrameDetector::StartCheckForOveruse must be called to periodically 64 // OveruseFrameDetector::StartCheckForOveruse must be called to periodically
77 // check for overuse. 65 // check for overuse.
78 class OveruseFrameDetector { 66 class OveruseFrameDetector {
79 public: 67 public:
80 OveruseFrameDetector(Clock* clock, 68 OveruseFrameDetector(Clock* clock,
81 const CpuOveruseOptions& options, 69 const CpuOveruseOptions& options,
82 CpuOveruseObserver* overuse_observer, 70 ScalingObserverInterface* overuse_observer,
83 EncodedFrameObserver* encoder_timing_, 71 EncodedFrameObserver* encoder_timing_,
84 CpuOveruseMetricsObserver* metrics_observer); 72 CpuOveruseMetricsObserver* metrics_observer);
85 ~OveruseFrameDetector(); 73 ~OveruseFrameDetector();
86 74
87 // Start to periodically check for overuse. 75 // Start to periodically check for overuse.
88 void StartCheckForOveruse(); 76 void StartCheckForOveruse();
89 77
90 // StopCheckForOveruse must be called before destruction if 78 // StopCheckForOveruse must be called before destruction if
91 // StartCheckForOveruse has been called. 79 // StartCheckForOveruse has been called.
92 void StopCheckForOveruse(); 80 void StopCheckForOveruse();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 112
125 void ResetAll(int num_pixels); 113 void ResetAll(int num_pixels);
126 114
127 rtc::SequencedTaskChecker task_checker_; 115 rtc::SequencedTaskChecker task_checker_;
128 // Owned by the task queue from where StartCheckForOveruse is called. 116 // Owned by the task queue from where StartCheckForOveruse is called.
129 CheckOveruseTask* check_overuse_task_; 117 CheckOveruseTask* check_overuse_task_;
130 118
131 const CpuOveruseOptions options_; 119 const CpuOveruseOptions options_;
132 120
133 // Observer getting overuse reports. 121 // Observer getting overuse reports.
134 CpuOveruseObserver* const observer_; 122 ScalingObserverInterface* const observer_;
135 EncodedFrameObserver* const encoder_timing_; 123 EncodedFrameObserver* const encoder_timing_;
136 124
137 // Stats metrics. 125 // Stats metrics.
138 CpuOveruseMetricsObserver* const metrics_observer_; 126 CpuOveruseMetricsObserver* const metrics_observer_;
139 rtc::Optional<CpuOveruseMetrics> metrics_ GUARDED_BY(task_checker_); 127 rtc::Optional<CpuOveruseMetrics> metrics_ GUARDED_BY(task_checker_);
140 Clock* const clock_; 128 Clock* const clock_;
141 129
142 int64_t num_process_times_ GUARDED_BY(task_checker_); 130 int64_t num_process_times_ GUARDED_BY(task_checker_);
143 131
144 int64_t last_capture_time_ms_ GUARDED_BY(task_checker_); 132 int64_t last_capture_time_ms_ GUARDED_BY(task_checker_);
(...skipping 12 matching lines...) Expand all
157 // allocs)? 145 // allocs)?
158 const std::unique_ptr<SendProcessingUsage> usage_ GUARDED_BY(task_checker_); 146 const std::unique_ptr<SendProcessingUsage> usage_ GUARDED_BY(task_checker_);
159 std::list<FrameTiming> frame_timing_ GUARDED_BY(task_checker_); 147 std::list<FrameTiming> frame_timing_ GUARDED_BY(task_checker_);
160 148
161 RTC_DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector); 149 RTC_DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector);
162 }; 150 };
163 151
164 } // namespace webrtc 152 } // namespace webrtc
165 153
166 #endif // WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_ 154 #endif // WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_
OLDNEW
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.mm ('k') | webrtc/video/overuse_frame_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698