/
Device.js
40 lines (34 loc) · 916 Bytes
/
Device.js
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
"use strict";
class Device {
// basically an enum
static direction = {
input: "input",
output: "output",
};
static type = {
audio: "audio",
video: "video",
};
constructor(id, label, dir) {
if (typeof id === "object" && id !== null) {
this.constructorForDeviceObject(id, label);
} else {
this.id = id;
this.label = label;
this.dir = dir;
this.isInput = dir === Device.direction.input;
this.isOutput = !this.isInput;
}
}
constructorForDeviceObject(dev, dir) {
this.id = dev.deviceId;
this.label = dev.label;
this.dir = dir;
this.isInput = dir === Device.direction.input;
this.isOutput = !this.isInput;
}
copy() {
return new Device(this.id, this.label, this.dir);
}
}
module.exports = Device;