-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (58 loc) · 2.32 KB
/
index.js
File metadata and controls
69 lines (58 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var Native = require('bindings')('BeboCaptureNative');
const util = require('util');
var promisify = util.promisify;
if (promisify == null) {
let Promise = require('bluebird');
promisify = Promise.promisify;
}
var BeboCapture = {
};
BeboCapture.getCapture = promisify(Native.getCapture);
BeboCapture.getDesktops = promisify(Native.getDesktops);
BeboCapture.getDesktopList = promisify(Native.getDesktops);
BeboCapture.getWindowList = promisify(Native.getWindowList);
BeboCapture.getConstraints = promisify(Native.getConstraints);
BeboCapture.signalCaptureReadRegistry = promisify(Native.signalCaptureReadRegistry);
BeboCapture.getForegroundWindow = promisify(Native.getForegroundWindow);
BeboCapture.isProcessElevated = promisify(Native.isProcessElevated);
BeboCapture.checkProcessElevation = promisify(Native.checkProcessElevation);
var setCapture = promisify(Native.setCapture);
BeboCapture.setCapture = (options) => {
if (!typeof (options) === 'object') {
return new Promise((_, reject) => { reject("invalid object") });
}
return setCapture(
options.type || "",
options.id || "",
options.name || options.label || "",
options.windowName || "",
options.windowClassName || "",
options.windowHandle || "0",
options.exeFullName || "",
options.antiCheat || false,
options.once || false);
}
var setConstraints = promisify(Native.setConstraints);
BeboCapture.setConstraints = (options) => {
if (!typeof (options) === 'object') {
return new Promise((_, reject) => { reject("invalid object") });
}
if (!options.width && !options.height && !options.fps) {
return Promise.reject("require params: width, height OR fps");
}
if ((options.width && typeof (options.width) !== 'number') ||
(options.height && typeof (options.height) !== 'number') ||
(options.fps && typeof (options.fps) !== 'number')) {
return Promise.reject("width, height, fps are not number");
}
if ((!options.width && options.width < 0) ||
(!options.height && options.height < 0) ||
(!options.fps && options.fps < 0)) {
return Promise.reject("invalid params value: width, height, fps need to be non negative");
}
return setConstraints(
options.width || 0,
options.height || 0,
options.fps || 0);
}
module.exports = BeboCapture;