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

Side by Side Diff: webrtc/modules/utility/source/helpers_ios.mm

Issue 1723163002: Adds low complexity audio mode for single core CPUs (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 | « webrtc/modules/utility/include/helpers_ios.h ('k') | 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) 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 // Internal helper method used by GetDeviceName() to return device name.
27 const char* LookUpRealName(const char* raw_name) {
28 // Lookup table which maps raw device names to real (human readable) names.
29 struct {
30 const char* raw_name;
31 const char* real_name;
32 } device_names[] = {
33 {"iPhone1,1", "iPhone 1G"},
34 {"iPhone1,2", "iPhone 3G"},
35 {"iPhone2,1", "iPhone 3GS"},
36 {"iPhone3,1", "iPhone 4"},
37 {"iPhone3,3", "Verizon iPhone 4"},
38 {"iPhone4,1", "iPhone 4S"},
39 {"iPhone5,1", "iPhone 5 (GSM)"},
40 {"iPhone5,2", "iPhone 5 (GSM+CDMA)"},
41 {"iPhone5,3", "iPhone 5c (GSM)"},
42 {"iPhone5,4", "iPhone 5c (GSM+CDMA)"},
43 {"iPhone6,1", "iPhone 5s (GSM)"},
44 {"iPhone6,2", "iPhone 5s (GSM+CDMA)"},
45 {"iPhone7,1", "iPhone 6 Plus"},
46 {"iPhone7,2", "iPhone 6"},
47 {"iPhone8,1", "iPhone 6s"},
48 {"iPhone8,2", "iPhone 6s Plus"},
49 {"iPod1,1", "iPod Touch 1G"},
50 {"iPod2,1", "iPod Touch 2G"},
51 {"iPod3,1", "iPod Touch 3G"},
52 {"iPod4,1", "iPod Touch 4G"},
53 {"iPod5,1", "iPod Touch 5G"},
54 {"iPad1,1", "iPad"},
55 {"iPad2,1", "iPad 2 (WiFi)"},
56 {"iPad2,2", "iPad 2 (GSM)"},
57 {"iPad2,3", "iPad 2 (CDMA)"},
58 {"iPad2,4", "iPad 2 (WiFi)"},
59 {"iPad2,5", "iPad Mini (WiFi)"},
60 {"iPad2,6", "iPad Mini (GSM)"},
61 {"iPad2,7", "iPad Mini (GSM+CDMA)"},
62 {"iPad3,1", "iPad 3 (WiFi)"},
63 {"iPad3,2", "iPad 3 (GSM+CDMA)"},
64 {"iPad3,3", "iPad 3 (GSM)"},
65 {"iPad3,4", "iPad 4 (WiFi)"},
66 {"iPad3,5", "iPad 4 (GSM)"},
67 {"iPad3,6", "iPad 4 (GSM+CDMA)"},
68 {"iPad4,1", "iPad Air (WiFi)"},
69 {"iPad4,2", "iPad Air (Cellular)"},
70 {"iPad4,4", "iPad mini 2G (WiFi)"},
71 {"iPad4,5", "iPad mini 2G (Cellular)"},
72 {"i386", "Simulator"},
73 {"x86_64", "Simulator"},
74 };
75
76 for (auto& d : device_names) {
77 if (strcmp(d.raw_name, raw_name) == 0)
78 return d.real_name;
79 }
80 LOG(LS_WARNING) << "Failed to find device name (" << raw_name << ")";
81 return "";
82 }
83
26 // TODO(henrika): move to shared location. 84 // TODO(henrika): move to shared location.
27 // See https://code.google.com/p/webrtc/issues/detail?id=4773 for details. 85 // See https://code.google.com/p/webrtc/issues/detail?id=4773 for details.
28 NSString* NSStringFromStdString(const std::string& stdString) { 86 NSString* NSStringFromStdString(const std::string& stdString) {
29 // std::string may contain null termination character so we construct 87 // std::string may contain null termination character so we construct
30 // using length. 88 // using length.
31 return [[NSString alloc] initWithBytes:stdString.data() 89 return [[NSString alloc] initWithBytes:stdString.data()
32 length:stdString.length() 90 length:stdString.length()
33 encoding:NSUTF8StringEncoding]; 91 encoding:NSUTF8StringEncoding];
34 } 92 }
35 93
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 NSString* deviceModel = [[UIDevice currentDevice] model]; 140 NSString* deviceModel = [[UIDevice currentDevice] model];
83 return StdStringFromNSString(deviceModel); 141 return StdStringFromNSString(deviceModel);
84 } 142 }
85 143
86 std::string GetDeviceName() { 144 std::string GetDeviceName() {
87 size_t size; 145 size_t size;
88 sysctlbyname("hw.machine", NULL, &size, NULL, 0); 146 sysctlbyname("hw.machine", NULL, &size, NULL, 0);
89 rtc::scoped_ptr<char[]> machine; 147 rtc::scoped_ptr<char[]> machine;
90 machine.reset(new char[size]); 148 machine.reset(new char[size]);
91 sysctlbyname("hw.machine", machine.get(), &size, NULL, 0); 149 sysctlbyname("hw.machine", machine.get(), &size, NULL, 0);
92 std::string raw_name(machine.get()); 150 return std::string(LookUpRealName(machine.get()));
93 if (!raw_name.compare("iPhone1,1")) 151 }
94 return std::string("iPhone 1G"); 152
95 if (!raw_name.compare("iPhone1,2")) 153 std::string GetProcessName() {
96 return std::string("iPhone 3G"); 154 NSString* processName = [NSProcessInfo processInfo].processName;
tkchin_webrtc 2016/02/23 17:39:27 The conversion to std::string seems unneeded becau
henrika_webrtc 2016/02/24 11:52:47 Filed https://bugs.chromium.org/p/webrtc/issues/de
97 if (!raw_name.compare("iPhone2,1")) 155 return StdStringFromNSString(processName);
98 return std::string("iPhone 3GS"); 156 }
99 if (!raw_name.compare("iPhone3,1")) 157
100 return std::string("iPhone 4"); 158 int GetProcessID() {
101 if (!raw_name.compare("iPhone3,3")) 159 return [NSProcessInfo processInfo].processIdentifier;
102 return std::string("Verizon iPhone 4"); 160 }
103 if (!raw_name.compare("iPhone4,1")) 161
104 return std::string("iPhone 4S"); 162 std::string GetOSVersionString() {
105 if (!raw_name.compare("iPhone5,1")) 163 NSString* osVersion =
106 return std::string("iPhone 5 (GSM)"); 164 [NSProcessInfo processInfo].operatingSystemVersionString;
107 if (!raw_name.compare("iPhone5,2")) 165 return StdStringFromNSString(osVersion);
108 return std::string("iPhone 5 (GSM+CDMA)"); 166 }
109 if (!raw_name.compare("iPhone5,3")) 167
110 return std::string("iPhone 5c (GSM)"); 168 int GetProcessorCount() {
111 if (!raw_name.compare("iPhone5,4")) 169 return [NSProcessInfo processInfo].processorCount;
112 return std::string("iPhone 5c (GSM+CDMA)"); 170 }
113 if (!raw_name.compare("iPhone6,1")) 171
114 return std::string("iPhone 5s (GSM)"); 172 bool GetLowPowerModeEnabled() {
115 if (!raw_name.compare("iPhone6,2")) 173 return [NSProcessInfo processInfo].lowPowerModeEnabled;
116 return std::string("iPhone 5s (GSM+CDMA)");
117 if (!raw_name.compare("iPhone7,1"))
118 return std::string("iPhone 6 Plus");
119 if (!raw_name.compare("iPhone7,2"))
120 return std::string("iPhone 6");
121 if (!raw_name.compare("iPhone8,1"))
122 return std::string("iPhone 6s");
123 if (!raw_name.compare("iPhone8,2"))
124 return std::string("iPhone 6s Plus");
125 if (!raw_name.compare("iPod1,1"))
126 return std::string("iPod Touch 1G");
127 if (!raw_name.compare("iPod2,1"))
128 return std::string("iPod Touch 2G");
129 if (!raw_name.compare("iPod3,1"))
130 return std::string("iPod Touch 3G");
131 if (!raw_name.compare("iPod4,1"))
132 return std::string("iPod Touch 4G");
133 if (!raw_name.compare("iPod5,1"))
134 return std::string("iPod Touch 5G");
135 if (!raw_name.compare("iPad1,1"))
136 return std::string("iPad");
137 if (!raw_name.compare("iPad2,1"))
138 return std::string("iPad 2 (WiFi)");
139 if (!raw_name.compare("iPad2,2"))
140 return std::string("iPad 2 (GSM)");
141 if (!raw_name.compare("iPad2,3"))
142 return std::string("iPad 2 (CDMA)");
143 if (!raw_name.compare("iPad2,4"))
144 return std::string("iPad 2 (WiFi)");
145 if (!raw_name.compare("iPad2,5"))
146 return std::string("iPad Mini (WiFi)");
147 if (!raw_name.compare("iPad2,6"))
148 return std::string("iPad Mini (GSM)");
149 if (!raw_name.compare("iPad2,7"))
150 return std::string("iPad Mini (GSM+CDMA)");
151 if (!raw_name.compare("iPad3,1"))
152 return std::string("iPad 3 (WiFi)");
153 if (!raw_name.compare("iPad3,2"))
154 return std::string("iPad 3 (GSM+CDMA)");
155 if (!raw_name.compare("iPad3,3"))
156 return std::string("iPad 3 (GSM)");
157 if (!raw_name.compare("iPad3,4"))
158 return std::string("iPad 4 (WiFi)");
159 if (!raw_name.compare("iPad3,5"))
160 return std::string("iPad 4 (GSM)");
161 if (!raw_name.compare("iPad3,6"))
162 return std::string("iPad 4 (GSM+CDMA)");
163 if (!raw_name.compare("iPad4,1"))
164 return std::string("iPad Air (WiFi)");
165 if (!raw_name.compare("iPad4,2"))
166 return std::string("iPad Air (Cellular)");
167 if (!raw_name.compare("iPad4,4"))
168 return std::string("iPad mini 2G (WiFi)");
169 if (!raw_name.compare("iPad4,5"))
170 return std::string("iPad mini 2G (Cellular)");
171 if (!raw_name.compare("i386"))
172 return std::string("Simulator");
173 if (!raw_name.compare("x86_64"))
174 return std::string("Simulator");
175 LOG(LS_WARNING) << "Failed to find device name (" << raw_name << ")";
176 return raw_name;
177 } 174 }
178 175
179 } // namespace ios 176 } // namespace ios
180 } // namespace webrtc 177 } // namespace webrtc
181 178
182 #endif // defined(WEBRTC_IOS) 179 #endif // defined(WEBRTC_IOS)
OLDNEW
« no previous file with comments | « webrtc/modules/utility/include/helpers_ios.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698