|
1 |
| -import debug from 'debug'; |
2 |
| -import {Atem} from 'atem-connection'; |
3 |
| -import {EventEmitter} from 'inf-ee'; |
| 1 | +import debug from 'debug' |
| 2 | +import { Atem } from 'atem-connection' |
| 3 | +import { EventEmitter } from 'inf-ee' |
4 | 4 |
|
5 |
| -const log = debug('sio:atem'); |
| 5 | +const log = debug('sio:atem') |
6 | 6 |
|
7 |
| -const ATEM_DEFAULT_ADDRESS = '192.168.10.240'; |
| 7 | +const ATEM_DEFAULT_ADDRESS = '192.168.10.240' |
8 | 8 |
|
9 | 9 | export class ControllerAtem extends EventEmitter {
|
10 |
| - constructor(options = {}) { |
11 |
| - super(); |
12 |
| - console.log('Constructing ATEM Controller'); |
| 10 | + constructor(options = {}) { |
| 11 | + super() |
| 12 | + console.log('Constructing ATEM Controller') |
13 | 13 |
|
14 |
| - this.componentName = 'ATEM Controller'; |
| 14 | + this.componentName = 'ATEM Controller' |
15 | 15 |
|
16 |
| - this.sessionId = -1; |
| 16 | + this.sessionId = -1 |
17 | 17 |
|
18 |
| - this._address = options.address || ATEM_DEFAULT_ADDRESS; |
19 |
| - this._atem = undefined; |
20 |
| - } |
| 18 | + this._address = options.address || ATEM_DEFAULT_ADDRESS |
| 19 | + this._atem = undefined |
| 20 | + } |
21 | 21 |
|
22 |
| - connect(options = {}) { |
23 |
| - this._address = options.address || ATEM_DEFAULT_ADDRESS; |
| 22 | + connect(options = {}) { |
| 23 | + this._address = options.address || ATEM_DEFAULT_ADDRESS |
24 | 24 |
|
25 |
| - this._atem = new Atem(); |
| 25 | + this._atem = new Atem() |
26 | 26 |
|
27 |
| - // This._atem.on('debug', (msg) => this.log('debug', msg)) |
28 |
| - this._atem.on('info', message => this.log('info', message)); |
29 |
| - this._atem.on('error', message => this.log('error', message)); |
| 27 | + // This._atem.on('debug', (msg) => this.log('debug', msg)) |
| 28 | + this._atem.on('info', (message) => this.log('info', message)) |
| 29 | + this._atem.on('error', (message) => this.log('error', message)) |
30 | 30 |
|
31 |
| - this._atem.on('disconnected', () => { |
32 |
| - this.log('info', 'Disconnected'); |
33 |
| - this.emit('disconnect', {sessionId: this.sessionId}); |
34 |
| - }); |
| 31 | + this._atem.on('disconnected', () => { |
| 32 | + this.log('info', 'Disconnected') |
| 33 | + this.emit('disconnect', { sessionId: this.sessionId }) |
| 34 | + }) |
35 | 35 |
|
36 |
| - this._atem.on('connected', () => { |
37 |
| - this.log('info', 'Connected'); |
38 |
| - this.sessionId += 1; |
39 |
| - this.emit('connected', {isReconnect: (this.sessionId > 0), sessionId: this.sessionId}); |
40 |
| - }); |
| 36 | + this._atem.on('connected', () => { |
| 37 | + this.log('info', 'Connected') |
| 38 | + this.sessionId += 1 |
| 39 | + this.emit('connected', { isReconnect: this.sessionId > 0, sessionId: this.sessionId }) |
| 40 | + }) |
41 | 41 |
|
42 |
| - this._atem.on('stateChanged', (state, pathToChange) => this.emit('stateChanged', {state, pathToChange})); |
43 |
| - this._atem.on('receivedCommand', command => this.emit('receivedCommand', {command})); |
| 42 | + this._atem.on('stateChanged', (state, pathToChange) => this.emit('stateChanged', { state, pathToChange })) |
| 43 | + this._atem.on('receivedCommand', (command) => this.emit('receivedCommand', { command })) |
44 | 44 |
|
45 |
| - this._atem.connect(this._address).catch(error => { |
46 |
| - this.log('error', error); |
47 |
| - }); |
48 |
| - } |
| 45 | + this._atem.connect(this._address).catch((error) => { |
| 46 | + this.log('error', error) |
| 47 | + }) |
| 48 | + } |
49 | 49 |
|
50 |
| - disconnect() { |
51 |
| - if (this._atem) { |
52 |
| - this._atem.disconnect(); |
53 |
| - } |
54 |
| - } |
| 50 | + disconnect() { |
| 51 | + if (this._atem) { |
| 52 | + this._atem.disconnect() |
| 53 | + } |
| 54 | + } |
55 | 55 |
|
56 |
| - getState() { |
57 |
| - return this._atem.state; |
58 |
| - } |
| 56 | + getState() { |
| 57 | + return this._atem.state |
| 58 | + } |
59 | 59 |
|
60 |
| - getProgramInput(me = 0) { |
61 |
| - return this._atem.state.video.mixEffects[me].programInput; |
62 |
| - } |
| 60 | + getProgramInput(me = 0) { |
| 61 | + return this._atem.state.video.mixEffects[me].programInput |
| 62 | + } |
63 | 63 |
|
64 |
| - getPreviewInput(me = 0) { |
65 |
| - return this._atem.state.video.mixEffects[me].previewInput; |
66 |
| - } |
| 64 | + getPreviewInput(me = 0) { |
| 65 | + return this._atem.state.video.mixEffects[me].previewInput |
| 66 | + } |
67 | 67 |
|
68 |
| - isUpstreamKeyerActive(me = 0, usk = 0) { |
69 |
| - return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].onAir; |
70 |
| - } |
| 68 | + isUpstreamKeyerActive(me = 0, usk = 0) { |
| 69 | + return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].onAir |
| 70 | + } |
71 | 71 |
|
72 |
| - getUpstreamKeyerFillSource(me = 0, usk = 0) { |
73 |
| - return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].fillSource; |
74 |
| - } |
| 72 | + getUpstreamKeyerFillSource(me = 0, usk = 0) { |
| 73 | + return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].fillSource |
| 74 | + } |
75 | 75 |
|
76 |
| - getUpstreamKeyerType(me = 0, usk = 0) { |
77 |
| - return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].mixEffectKeyType; |
78 |
| - } |
| 76 | + getUpstreamKeyerType(me = 0, usk = 0) { |
| 77 | + return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].mixEffectKeyType |
| 78 | + } |
79 | 79 |
|
80 |
| - getTransitionDuration(me = 0) { |
81 |
| - return this._atem.state.video.mixEffects[me].transitionSettings.mix.rate; |
82 |
| - } |
| 80 | + getTransitionDuration(me = 0) { |
| 81 | + return this._atem.state.video.mixEffects[me].transitionSettings.mix.rate |
| 82 | + } |
83 | 83 |
|
84 |
| - setUpstreamKeyerType(...args) { |
85 |
| - return this._atem.setUpstreamKeyerType(...args); |
86 |
| - } |
| 84 | + setUpstreamKeyerType(...args) { |
| 85 | + return this._atem.setUpstreamKeyerType(...args) |
| 86 | + } |
87 | 87 |
|
88 |
| - setUpstreamKeyerDVESettings(...args) { |
89 |
| - return this._atem.setUpstreamKeyerDVESettings(...args); |
90 |
| - } |
| 88 | + setUpstreamKeyerDVESettings(...args) { |
| 89 | + return this._atem.setUpstreamKeyerDVESettings(...args) |
| 90 | + } |
91 | 91 |
|
92 |
| - changePreviewInput(...args) { |
93 |
| - return this._atem.changePreviewInput(...args); |
94 |
| - } |
| 92 | + changePreviewInput(...args) { |
| 93 | + return this._atem.changePreviewInput(...args) |
| 94 | + } |
95 | 95 |
|
96 |
| - setTransitionStyle(...args) { |
97 |
| - return this._atem.setTransitionStyle(...args); |
98 |
| - } |
| 96 | + setTransitionStyle(...args) { |
| 97 | + return this._atem.setTransitionStyle(...args) |
| 98 | + } |
99 | 99 |
|
100 |
| - setUpstreamKeyerFillSource(...args) { |
101 |
| - return this._atem.setUpstreamKeyerFillSource(...args); |
102 |
| - } |
| 100 | + setUpstreamKeyerFillSource(...args) { |
| 101 | + return this._atem.setUpstreamKeyerFillSource(...args) |
| 102 | + } |
103 | 103 |
|
104 |
| - autoTransition(...args) { |
105 |
| - return this._atem.autoTransition(...args); |
106 |
| - } |
| 104 | + autoTransition(...args) { |
| 105 | + return this._atem.autoTransition(...args) |
| 106 | + } |
107 | 107 |
|
108 |
| - cut(...args) { |
109 |
| - return this._atem.cut(...args); |
110 |
| - } |
| 108 | + cut(...args) { |
| 109 | + return this._atem.cut(...args) |
| 110 | + } |
111 | 111 |
|
112 |
| - setFairlightAudioMixerSourceProps(...args) { |
113 |
| - return this._atem.setFairlightAudioMixerSourceProps(...args); |
114 |
| - } |
| 112 | + setFairlightAudioMixerSourceProps(...args) { |
| 113 | + return this._atem.setFairlightAudioMixerSourceProps(...args) |
| 114 | + } |
115 | 115 |
|
116 |
| - fadeToBlack(...args) { |
117 |
| - return this._atem.fadeToBlack(...args); |
118 |
| - } |
119 |
| - |
120 |
| - setUpstreamKeyerFlyKeyKeyframe(...args) { |
121 |
| - return this._atem.setUpstreamKeyerFlyKeyKeyframe(...args); |
122 |
| - } |
123 |
| - |
124 |
| - runUpstreamKeyerFlyKeyTo(...args) { |
125 |
| - return this._atem.runUpstreamKeyerFlyKeyTo(...args); |
126 |
| - } |
127 |
| - |
128 |
| - log(level, ...args) { |
129 |
| - this.emit('log', {component: this.componentName, level: level.toLowerCase(), message: args}); |
130 |
| - log(`${level.toLowerCase()}: ${args}`); |
131 |
| - } |
| 116 | + fadeToBlack(...args) { |
| 117 | + return this._atem.fadeToBlack(...args) |
| 118 | + } |
| 119 | + |
| 120 | + setUpstreamKeyerFlyKeyKeyframe(...args) { |
| 121 | + return this._atem.setUpstreamKeyerFlyKeyKeyframe(...args) |
| 122 | + } |
| 123 | + |
| 124 | + runUpstreamKeyerFlyKeyTo(...args) { |
| 125 | + return this._atem.runUpstreamKeyerFlyKeyTo(...args) |
| 126 | + } |
| 127 | + |
| 128 | + log(level, ...args) { |
| 129 | + this.emit('log', { component: this.componentName, level: level.toLowerCase(), message: args }) |
| 130 | + log(`${level.toLowerCase()}: ${args}`) |
| 131 | + } |
132 | 132 | }
|
133 | 133 |
|
134 |
| -export default ControllerAtem; |
| 134 | +export default ControllerAtem |
0 commit comments