aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorevgeny <me@ch1p.com>2018-12-25 23:36:22 +0300
committerevgeny <me@ch1p.com>2018-12-25 23:36:22 +0300
commit2e4bb8471d80a341c2439ef6d6b0bcd929e72abc (patch)
tree32a51cf87d95d0f2ff554f171ac18bf3abf9d14e
parent2322dec6a4341b7ac6fcf60462e738533252a57f (diff)
upd
-rw-r--r--index.mm11
-rw-r--r--package.json2
2 files changed, 8 insertions, 5 deletions
diff --git a/index.mm b/index.mm
index 6599ff7..423af50 100644
--- a/index.mm
+++ b/index.mm
@@ -34,6 +34,11 @@ std::string ConvertAuthorizationStatus(AVAuthorizationStatus status) {
}
}
+bool isMojave() {
+ NSOperatingSystemVersion minimumSupportedOSVersion = { .majorVersion = 10, .minorVersion = 14, .patchVersion = 0 };
+ return [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:minimumSupportedOSVersion];
+}
+
struct Baton {
uv_work_t request;
Persistent<Function> callback;
@@ -96,9 +101,7 @@ void AskForMediaAccess(const v8::FunctionCallbackInfo<Value>& args) {
Local<Function> cbFunc = Local<Function>::Cast(args[1]);
if (auto type = ParseMediaType(mediaType)) {
- NSOperatingSystemVersion minimumSupportedOSVersion = { .majorVersion = 10, .minorVersion = 14, .patchVersion = 0 };
- BOOL isSupported = [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:minimumSupportedOSVersion];
- if (isSupported) {
+ if (isMojave()) {
Baton *baton = new Baton;
baton->type = type;
baton->callback.Reset(isolate, cbFunc);
@@ -133,7 +136,7 @@ void GetMediaAccessStatus(const v8::FunctionCallbackInfo<Value>& args) {
std::string mediaType(*mediaTypeValue);
if (auto type = ParseMediaType(mediaType)) {
- if (@available(macOS 10.14, *)) {
+ if (isMojave()) {
args.GetReturnValue().Set(String::NewFromUtf8(isolate, ConvertAuthorizationStatus(
[AVCaptureDevice authorizationStatusForMediaType:type]).c_str()));
} else {
diff --git a/package.json b/package.json
index 9cedefe..da46883 100644
--- a/package.json
+++ b/package.json
@@ -11,5 +11,5 @@
"install": "node-gyp rebuild",
"test": "node index.js"
},
- "version": "1.0.1"
+ "version": "1.0.2"
}