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

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

Issue 1665173002: Experimental patch for adapting adaptation to CPU count on Mac. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webrtc/base/constructormagic.h" 14 #include "webrtc/base/constructormagic.h"
15 #include "webrtc/base/criticalsection.h" 15 #include "webrtc/base/criticalsection.h"
16 #include "webrtc/base/scoped_ptr.h" 16 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/base/exp_filter.h" 17 #include "webrtc/base/exp_filter.h"
18 #include "webrtc/base/thread_annotations.h" 18 #include "webrtc/base/thread_annotations.h"
19 #include "webrtc/base/thread_checker.h" 19 #include "webrtc/base/thread_checker.h"
20 #include "webrtc/modules/include/module.h" 20 #include "webrtc/modules/include/module.h"
21 21
22 #if WEBRTC_MAC
23 #include <mach/mach.h>
24 #endif
25
22 namespace webrtc { 26 namespace webrtc {
23 27
24 class Clock; 28 class Clock;
25 29
26 // CpuOveruseObserver is called when a system overuse is detected and 30 // CpuOveruseObserver is called when a system overuse is detected and
27 // VideoEngine cannot keep up the encoding frequency. 31 // VideoEngine cannot keep up the encoding frequency.
28 class CpuOveruseObserver { 32 class CpuOveruseObserver {
29 public: 33 public:
30 // Called as soon as an overuse is detected. 34 // Called as soon as an overuse is detected.
31 virtual void OveruseDetected() = 0; 35 virtual void OveruseDetected() = 0;
32 // Called periodically when the system is not overused any longer. 36 // Called periodically when the system is not overused any longer.
33 virtual void NormalUsage() = 0; 37 virtual void NormalUsage() = 0;
34 38
35 protected: 39 protected:
36 virtual ~CpuOveruseObserver() {} 40 virtual ~CpuOveruseObserver() {}
37 }; 41 };
38 42
39 struct CpuOveruseOptions { 43 struct CpuOveruseOptions {
40 CpuOveruseOptions() 44 CpuOveruseOptions()
41 : low_encode_usage_threshold_percent(55), 45 : low_encode_usage_threshold_percent(42),
tommi 2016/02/04 16:40:02 Is 42 something that should be set for all platfor
torbjorng (webrtc) 2016/02/04 16:54:58 I decreased this to make it about 85/2; the interv
42 high_encode_usage_threshold_percent(85),
43 frame_timeout_interval_ms(1500), 46 frame_timeout_interval_ms(1500),
44 min_frame_samples(120), 47 min_frame_samples(120),
45 min_process_count(3), 48 min_process_count(3),
46 high_threshold_consecutive_count(2) {} 49 high_threshold_consecutive_count(2) {
50 #if WEBRTC_MAC
tommi 2016/02/04 16:40:02 nit: #if defined(WEBRTC_MAC)
torbjorng (webrtc) 2016/02/04 16:54:59 Done.
51 // This is a proof-of-concept hack for letting the physical core count
52 // affect the interval into which we attempt to scale. For now, the code
53 // is Mac OS specific, since that's the platform were we saw the problem.
54 // Note that we make the interval 2x+epsilon wide, since scaling steps are
55 // close to that.
56 struct host_basic_info hbi;
57 mach_msg_type_number_t datasize;
58 // FIXME(torbjorng): Add syscall error checking, fallback code.
tommi 2016/02/04 16:40:02 nit: s/FIXME/TODO
torbjorng (webrtc) 2016/02/04 16:54:59 Done.
59 host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hbi, &datasize);
tommi 2016/02/04 16:40:02 does this work as expected inside the sandbox?
torbjorng (webrtc) 2016/02/04 16:54:58 Good question. I will verify that. I observed chr
60
61 if (hbi.physical_cpu == 1) {
62 low_encode_usage_threshold_percent = 17;
63 } else if (hbi.physical_cpu == 2) {
64 low_encode_usage_threshold_percent = 27;
65 } else {
66 // Init list default.
67 }
68 #endif
69 // Make high = low + epsilon.
70 high_encode_usage_threshold_percent
71 = 33 * low_encode_usage_threshold_percent / 16 + 1;
tommi 2016/02/04 16:40:02 nit: assignment operator on previous line (could a
torbjorng (webrtc) 2016/02/04 16:54:58 Done.
72 }
47 73
48 int low_encode_usage_threshold_percent; // Threshold for triggering underuse. 74 int low_encode_usage_threshold_percent; // Threshold for triggering underuse.
49 int high_encode_usage_threshold_percent; // Threshold for triggering overuse. 75 int high_encode_usage_threshold_percent; // Threshold for triggering overuse.
50 // General settings. 76 // General settings.
51 int frame_timeout_interval_ms; // The maximum allowed interval between two 77 int frame_timeout_interval_ms; // The maximum allowed interval between two
52 // frames before resetting estimations. 78 // frames before resetting estimations.
53 int min_frame_samples; // The minimum number of frames required. 79 int min_frame_samples; // The minimum number of frames required.
54 int min_process_count; // The number of initial process times required before 80 int min_process_count; // The number of initial process times required before
55 // triggering an overuse/underuse. 81 // triggering an overuse/underuse.
56 int high_threshold_consecutive_count; // The number of consecutive checks 82 int high_threshold_consecutive_count; // The number of consecutive checks
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 const rtc::scoped_ptr<FrameQueue> frame_queue_ GUARDED_BY(crit_); 181 const rtc::scoped_ptr<FrameQueue> frame_queue_ GUARDED_BY(crit_);
156 182
157 rtc::ThreadChecker processing_thread_; 183 rtc::ThreadChecker processing_thread_;
158 184
159 RTC_DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector); 185 RTC_DISALLOW_COPY_AND_ASSIGN(OveruseFrameDetector);
160 }; 186 };
161 187
162 } // namespace webrtc 188 } // namespace webrtc
163 189
164 #endif // WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_ 190 #endif // WEBRTC_VIDEO_OVERUSE_FRAME_DETECTOR_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698