OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 typedef int AdaptReason; | 94 typedef int AdaptReason; |
95 | 95 |
96 CoordinatedVideoAdapter(); | 96 CoordinatedVideoAdapter(); |
97 virtual ~CoordinatedVideoAdapter() {} | 97 virtual ~CoordinatedVideoAdapter() {} |
98 | 98 |
99 virtual void SetInputFormat(const VideoFormat& format); | 99 virtual void SetInputFormat(const VideoFormat& format); |
100 | 100 |
101 // Enable or disable video adaptation due to the change of the CPU load. | 101 // Enable or disable video adaptation due to the change of the CPU load. |
102 void set_cpu_adaptation(bool enable) { cpu_adaptation_ = enable; } | 102 void set_cpu_adaptation(bool enable) { cpu_adaptation_ = enable; } |
103 bool cpu_adaptation() const { return cpu_adaptation_; } | 103 bool cpu_adaptation() const { return cpu_adaptation_; } |
104 // Enable or disable smoothing when doing CPU adaptation. When smoothing is | |
105 // enabled, system CPU load is tracked using an exponential weighted | |
106 // average. | |
107 void set_cpu_smoothing(bool enable); | |
108 bool cpu_smoothing() const { return cpu_smoothing_; } | |
109 // Enable or disable video adaptation due to the change of the GD | 104 // Enable or disable video adaptation due to the change of the GD |
110 void set_gd_adaptation(bool enable) { gd_adaptation_ = enable; } | 105 void set_gd_adaptation(bool enable) { gd_adaptation_ = enable; } |
111 bool gd_adaptation() const { return gd_adaptation_; } | 106 bool gd_adaptation() const { return gd_adaptation_; } |
112 // Enable or disable video adaptation due to the change of the View | 107 // Enable or disable video adaptation due to the change of the View |
113 void set_view_adaptation(bool enable) { view_adaptation_ = enable; } | 108 void set_view_adaptation(bool enable) { view_adaptation_ = enable; } |
114 bool view_adaptation() const { return view_adaptation_; } | 109 bool view_adaptation() const { return view_adaptation_; } |
115 // Enable or disable video adaptation to fast switch View | 110 // Enable or disable video adaptation to fast switch View |
116 void set_view_switch(bool enable) { view_switch_ = enable; } | 111 void set_view_switch(bool enable) { view_switch_ = enable; } |
117 bool view_switch() const { return view_switch_; } | 112 bool view_switch() const { return view_switch_; } |
118 | 113 |
119 CoordinatedVideoAdapter::AdaptReason adapt_reason() const { | 114 CoordinatedVideoAdapter::AdaptReason adapt_reason() const { |
120 return adapt_reason_; | 115 return adapt_reason_; |
121 } | 116 } |
122 | 117 |
123 // When the video is decreased, set the waiting time for CPU adaptation to | |
124 // decrease video again. | |
125 void set_cpu_load_min_samples(int cpu_load_min_samples); | |
126 int cpu_load_min_samples() const { return cpu_load_min_samples_; } | |
127 // CPU system load high threshold for reducing resolution. e.g. 0.85f | |
128 void set_high_system_threshold(float high_system_threshold); | |
129 float high_system_threshold() const { return high_system_threshold_; } | |
130 // CPU system load low threshold for increasing resolution. e.g. 0.70f | |
131 void set_low_system_threshold(float low_system_threshold); | |
132 float low_system_threshold() const { return low_system_threshold_; } | |
133 // CPU process load threshold for reducing resolution. e.g. 0.10f | |
134 void set_process_threshold(float process_threshold); | |
135 float process_threshold() const { return process_threshold_; } | |
pthatcher1
2016/02/17 23:05:56
Do we not need all this anymore, or did it get mov
perkj_webrtc
2016/02/18 13:22:46
void OnCpuResolutionRequest(AdaptRequest request)
nisse-webrtc
2016/02/18 14:03:42
Would it simplify things with a separate cl deleti
pthatcher1
2016/02/19 06:08:39
That's exactly what I was thinking.
| |
136 | |
137 // Handle the format request from the server via Jingle update message. | 118 // Handle the format request from the server via Jingle update message. |
138 void OnOutputFormatRequest(const VideoFormat& format); | 119 void OnOutputFormatRequest(const VideoFormat& format); |
120 void OnLimitResolution(int max_number_of_pixels); | |
139 // Handle the resolution request from the encoder due to bandwidth changes. | 121 // Handle the resolution request from the encoder due to bandwidth changes. |
140 void OnEncoderResolutionRequest(int width, int height, AdaptRequest request); | 122 void OnEncoderResolutionRequest(int width, int height, AdaptRequest request); |
141 // Handle the resolution request for CPU overuse. | |
142 void OnCpuResolutionRequest(AdaptRequest request); | |
143 // Handle the CPU load provided by a CPU monitor. | |
144 void OnCpuLoadUpdated(int current_cpus, int max_cpus, | |
145 float process_load, float system_load); | |
146 | |
147 sigslot::signal0<> SignalCpuAdaptationUnable; | |
148 | 123 |
149 private: | 124 private: |
150 // Adapt to the minimum of the formats the server requests, the CPU wants, and | 125 // Adapt to the minimum of the formats the server requests, the CPU wants, and |
151 // the encoder wants. Returns true if resolution changed. | 126 // the encoder wants. Returns true if resolution changed. |
152 bool AdaptToMinimumFormat(int* new_width, int* new_height); | 127 bool AdaptToMinimumFormat(int* new_width, int* new_height); |
153 bool IsMinimumFormat(int pixels); | 128 bool IsMinimumFormat(int pixels); |
154 void StepPixelCount(CoordinatedVideoAdapter::AdaptRequest request, | 129 void StepPixelCount(CoordinatedVideoAdapter::AdaptRequest request, |
155 int* num_pixels); | 130 int* num_pixels); |
156 CoordinatedVideoAdapter::AdaptRequest FindCpuRequest( | 131 CoordinatedVideoAdapter::AdaptRequest FindCpuRequest( |
157 int current_cpus, int max_cpus, | 132 int current_cpus, int max_cpus, |
158 float process_load, float system_load); | 133 float process_load, float system_load); |
159 | 134 |
160 bool cpu_adaptation_; // True if cpu adaptation is enabled. | 135 bool cpu_adaptation_; // True if cpu adaptation is enabled. |
161 bool cpu_smoothing_; // True if cpu smoothing is enabled (with adaptation). | 136 bool cpu_smoothing_; // True if cpu smoothing is enabled (with adaptation). |
162 bool gd_adaptation_; // True if gd adaptation is enabled. | 137 bool gd_adaptation_; // True if gd adaptation is enabled. |
163 bool view_adaptation_; // True if view adaptation is enabled. | 138 bool view_adaptation_; // True if view adaptation is enabled. |
164 bool view_switch_; // True if view switch is enabled. | 139 bool view_switch_; // True if view switch is enabled. |
165 int cpu_downgrade_count_; | 140 |
166 int cpu_load_min_samples_; | |
167 int cpu_load_num_samples_; | |
168 // cpu system load thresholds relative to max cpus. | |
169 float high_system_threshold_; | |
170 float low_system_threshold_; | |
171 // cpu process load thresholds relative to current cpus. | |
172 float process_threshold_; | |
173 // Video formats that the server view requests, the CPU wants, and the encoder | 141 // Video formats that the server view requests, the CPU wants, and the encoder |
174 // wants respectively. The adapted output format is the minimum of these. | 142 // wants respectively. The adapted output format is the minimum of these. |
175 int view_desired_num_pixels_; | 143 int view_desired_num_pixels_; |
176 int64_t view_desired_interval_; | 144 int64_t view_desired_interval_; |
177 int encoder_desired_num_pixels_; | 145 int encoder_desired_num_pixels_; |
178 int cpu_desired_num_pixels_; | 146 int cpu_desired_num_pixels_; |
179 CoordinatedVideoAdapter::AdaptReason adapt_reason_; | 147 CoordinatedVideoAdapter::AdaptReason adapt_reason_; |
180 // The critical section to protect handling requests. | 148 // The critical section to protect handling requests. |
181 rtc::CriticalSection request_critical_section_; | 149 rtc::CriticalSection request_critical_section_; |
182 | 150 |
183 // The weighted average of cpu load over time. It's always updated (if cpu | 151 // The weighted average of cpu load over time. It's always updated (if cpu |
184 // adaptation is on), but only used if cpu_smoothing_ is set. | 152 // adaptation is on), but only used if cpu_smoothing_ is set. |
185 float system_load_average_; | 153 float system_load_average_; |
186 | 154 |
187 RTC_DISALLOW_COPY_AND_ASSIGN(CoordinatedVideoAdapter); | 155 RTC_DISALLOW_COPY_AND_ASSIGN(CoordinatedVideoAdapter); |
188 }; | 156 }; |
189 | 157 |
190 } // namespace cricket | 158 } // namespace cricket |
191 | 159 |
192 #endif // WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_ // NOLINT | 160 #endif // WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_ // NOLINT |
OLD | NEW |