OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 #if defined(WEBRTC_IOS) | 11 #if defined(WEBRTC_IOS) |
12 | 12 |
13 #import <AVFoundation/AVFoundation.h> | 13 #import <AVFoundation/AVFoundation.h> |
14 #import <Foundation/Foundation.h> | 14 #import <Foundation/Foundation.h> |
15 #import <sys/sysctl.h> | 15 #import <sys/sysctl.h> |
16 #import <UIKit/UIKit.h> | 16 #import <UIKit/UIKit.h> |
17 | 17 |
18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
20 #include "webrtc/base/scoped_ptr.h" | 20 #include "webrtc/base/scoped_ptr.h" |
21 #include "webrtc/modules/utility/include/helpers_ios.h" | 21 #include "webrtc/modules/utility/include/helpers_ios.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 namespace ios { | 24 namespace ios { |
25 | 25 |
26 #define SYSTEM_VERSION_EQUAL_TO(v) \ | |
27 ([[[UIDevice currentDevice] systemVersion] \ | |
tkchin_webrtc
2016/03/01 21:51:34
can just use doubleValue to make these comparisons
henrika_webrtc
2016/03/02 14:49:50
Great idea, thanks!
| |
28 compare:v \ | |
29 options:NSNumericSearch] == NSOrderedSame) | |
30 #define SYSTEM_VERSION_GREATER_THAN(v) \ | |
31 ([[[UIDevice currentDevice] systemVersion] \ | |
32 compare:v \ | |
33 options:NSNumericSearch] == NSOrderedDescending) | |
34 #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) \ | |
35 ([[[UIDevice currentDevice] systemVersion] \ | |
36 compare:v \ | |
37 options:NSNumericSearch] != NSOrderedAscending) | |
38 #define SYSTEM_VERSION_LESS_THAN(v) \ | |
39 ([[[UIDevice currentDevice] systemVersion] \ | |
40 compare:v \ | |
41 options:NSNumericSearch] == NSOrderedAscending) | |
42 #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) \ | |
43 ([[[UIDevice currentDevice] systemVersion] \ | |
44 compare:v \ | |
45 options:NSNumericSearch] != NSOrderedDescending) | |
46 | |
26 // Internal helper method used by GetDeviceName() to return device name. | 47 // Internal helper method used by GetDeviceName() to return device name. |
27 const char* LookUpRealName(const char* raw_name) { | 48 const char* LookUpRealName(const char* raw_name) { |
28 // Lookup table which maps raw device names to real (human readable) names. | 49 // Lookup table which maps raw device names to real (human readable) names. |
29 struct { | 50 struct { |
30 const char* raw_name; | 51 const char* raw_name; |
31 const char* real_name; | 52 const char* real_name; |
32 } device_names[] = { | 53 } device_names[] = { |
33 {"iPhone1,1", "iPhone 1G"}, | 54 {"iPhone1,1", "iPhone 1G"}, |
34 {"iPhone1,2", "iPhone 3G"}, | 55 {"iPhone1,2", "iPhone 3G"}, |
35 {"iPhone2,1", "iPhone 3GS"}, | 56 {"iPhone2,1", "iPhone 3GS"}, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 std::string GetOSVersionString() { | 183 std::string GetOSVersionString() { |
163 NSString* osVersion = | 184 NSString* osVersion = |
164 [NSProcessInfo processInfo].operatingSystemVersionString; | 185 [NSProcessInfo processInfo].operatingSystemVersionString; |
165 return StdStringFromNSString(osVersion); | 186 return StdStringFromNSString(osVersion); |
166 } | 187 } |
167 | 188 |
168 int GetProcessorCount() { | 189 int GetProcessorCount() { |
169 return [NSProcessInfo processInfo].processorCount; | 190 return [NSProcessInfo processInfo].processorCount; |
170 } | 191 } |
171 | 192 |
193 #if defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0 | |
172 bool GetLowPowerModeEnabled() { | 194 bool GetLowPowerModeEnabled() { |
195 // lowPoweredModeEnabled is only available on iOS9+. | |
196 if | |
197 SYSTEM_VERSION_LESS_THAN(@"9.0.0") { | |
tkchin_webrtc
2016/03/01 21:51:33
Wouldn't use macros. Instead have a bunch of funct
henrika_webrtc
2016/03/02 14:49:50
Done.
| |
198 LOG(LS_WARNING) << "webrtc::ios::GetLowPowerModeEnabled() is not " | |
199 "supported. Requires at least iOS 9.0"; | |
200 return false; | |
201 } | |
173 NSProcessInfo* info = [NSProcessInfo processInfo]; | 202 NSProcessInfo* info = [NSProcessInfo processInfo]; |
174 // lowPoweredModeEnabled is only available on iOS9+. | 203 return info.lowPowerModeEnabled; |
175 if ([info respondsToSelector:@selector(lowPoweredModeEnabled)]) { | |
176 return info.lowPowerModeEnabled; | |
177 } | |
178 return false; | |
179 } | 204 } |
205 #else | |
206 // TODO(henrika): can't use iOS 9 APIs as the SDK version doesn't support | |
tkchin_webrtc
2016/03/01 21:51:34
If it's unavailable we should just not use it. Tha
henrika_webrtc
2016/03/02 14:49:50
Done.
| |
207 // them. What is the best thing to do here? User will get linker error; | |
208 // should be sufficient, right? | |
209 #endif | |
180 | 210 |
181 } // namespace ios | 211 } // namespace ios |
182 } // namespace webrtc | 212 } // namespace webrtc |
183 | 213 |
184 #endif // defined(WEBRTC_IOS) | 214 #endif // defined(WEBRTC_IOS) |
OLD | NEW |