Skip to content
This repository was archived by the owner on Dec 17, 2022. It is now read-only.

Commit 6eb1750

Browse files
committed
Mostly just formatting updates to xo standard.
1 parent 2aa1d5b commit 6eb1750

File tree

7 files changed

+722
-710
lines changed

7 files changed

+722
-710
lines changed

ControllerAtem.js

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,134 @@
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';
44

5-
const log = debug(`sio:atem`)
5+
const log = debug('sio:atem');
66

7-
const ATEM_DEFAULT_ADDRESS = '192.168.10.240'
7+
const ATEM_DEFAULT_ADDRESS = '192.168.10.240';
88

99
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');
1313

14-
this.componentName = 'ATEM Controller'
14+
this.componentName = 'ATEM Controller';
1515

16-
this.sessionId = -1
16+
this.sessionId = -1;
1717

18-
this._address = options.address || ATEM_DEFAULT_ADDRESS
19-
this._atem = undefined
18+
this._address = options.address || ATEM_DEFAULT_ADDRESS;
19+
this._atem = undefined;
20+
}
2021

21-
return this
22-
}
22+
connect(options = {}) {
23+
this._address = options.address || ATEM_DEFAULT_ADDRESS;
2324

24-
connect(options = {}) {
25-
this._address = options.address || ATEM_DEFAULT_ADDRESS
25+
this._atem = new Atem();
2626

27-
this._atem = new Atem()
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));
2830

29-
// this._atem.on('debug', (msg) => this.log('debug', msg))
30-
this._atem.on('info', (msg) => this.log('info', msg))
31-
this._atem.on('error', (msg) => this.log('error', msg))
31+
this._atem.on('disconnected', () => {
32+
this.log('info', 'Disconnected');
33+
this.emit('disconnect', {sessionId: this.sessionId});
34+
});
3235

33-
this._atem.on('disconnected', () => {
34-
this.log('info', 'Disconnected')
35-
this.emit('disconnect', { sessionId: this.sessionId })
36-
})
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+
});
3741

38-
this._atem.on('connected', () => {
39-
this.log('info', `Connected`)
40-
this.sessionId = this.sessionId + 1
41-
this.emit('connected', { isReconnect: (this.sessionId > 0), sessionId: this.sessionId })
42-
})
42+
this._atem.on('stateChanged', (state, pathToChange) => this.emit('stateChanged', {state, pathToChange}));
43+
this._atem.on('receivedCommand', command => this.emit('receivedCommand', {command}));
4344

44-
this._atem.on('stateChanged', (state, pathToChange) => this.emit('stateChanged', { state, pathToChange }))
45-
this._atem.on('receivedCommand', (command) => this.emit('receivedCommand', { command }))
45+
this._atem.connect(this._address).catch(error => {
46+
this.log('error', error);
47+
});
48+
}
4649

47-
this._atem.connect(this._address).catch((e) => {
48-
this.log('error', e)
49-
})
50-
}
50+
disconnect() {
51+
if (this._atem) {
52+
this._atem.disconnect();
53+
}
54+
}
5155

52-
disconnect() {
53-
if (this._atem) this._atem.disconnect()
54-
}
56+
getState() {
57+
return this._atem.state;
58+
}
5559

56-
getState() {
57-
return this._atem.state
58-
}
60+
getProgramInput(me = 0) {
61+
return this._atem.state.video.mixEffects[me].programInput;
62+
}
5963

60-
getProgramInput(me = 0) {
61-
return this._atem.state.video.mixEffects[me].programInput
62-
}
64+
getPreviewInput(me = 0) {
65+
return this._atem.state.video.mixEffects[me].previewInput;
66+
}
6367

64-
getPreviewInput(me = 0) {
65-
return this._atem.state.video.mixEffects[me].previewInput
66-
}
68+
isUpstreamKeyerActive(me = 0, usk = 0) {
69+
return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].onAir;
70+
}
6771

68-
isUpstreamKeyerActive(me = 0, usk = 0) {
69-
return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].onAir
70-
}
72+
getUpstreamKeyerFillSource(me = 0, usk = 0) {
73+
return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].fillSource;
74+
}
7175

72-
getUpstreamKeyerFillSource(me = 0, usk = 0) {
73-
return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].fillSource
74-
}
76+
getUpstreamKeyerType(me = 0, usk = 0) {
77+
return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].mixEffectKeyType;
78+
}
7579

76-
getUpstreamKeyerType(me = 0, usk = 0) {
77-
return this._atem.state.video.mixEffects[me].upstreamKeyers[usk].mixEffectKeyType
78-
}
80+
getTransitionDuration(me = 0) {
81+
return this._atem.state.video.mixEffects[me].transitionSettings.mix.rate;
82+
}
7983

80-
getTransitionDuration(me = 0) {
81-
return this._atem.state.video.mixEffects[me].transitionSettings.mix.rate
82-
}
84+
setUpstreamKeyerType(...args) {
85+
return this._atem.setUpstreamKeyerType(...args);
86+
}
8387

84-
setUpstreamKeyerType(...args) {
85-
return this._atem.setUpstreamKeyerType.apply(this._atem, args)
86-
}
88+
setUpstreamKeyerDVESettings(...args) {
89+
return this._atem.setUpstreamKeyerDVESettings(...args);
90+
}
8791

88-
setUpstreamKeyerDVESettings(...args) {
89-
return this._atem.setUpstreamKeyerDVESettings.apply(this._atem, args)
90-
}
92+
changePreviewInput(...args) {
93+
return this._atem.changePreviewInput(...args);
94+
}
9195

92-
changePreviewInput(...args) {
93-
return this._atem.changePreviewInput.apply(this._atem, args)
94-
}
96+
setTransitionStyle(...args) {
97+
return this._atem.setTransitionStyle(...args);
98+
}
9599

96-
setTransitionStyle(...args) {
97-
return this._atem.setTransitionStyle.apply(this._atem, args)
98-
}
100+
setUpstreamKeyerFillSource(...args) {
101+
return this._atem.setUpstreamKeyerFillSource(...args);
102+
}
99103

100-
setUpstreamKeyerFillSource(...args) {
101-
return this._atem.setUpstreamKeyerFillSource.apply(this._atem, args)
102-
}
104+
autoTransition(...args) {
105+
return this._atem.autoTransition(...args);
106+
}
103107

104-
autoTransition(...args) {
105-
return this._atem.autoTransition.apply(this._atem, args)
106-
}
108+
cut(...args) {
109+
return this._atem.cut(...args);
110+
}
107111

108-
cut(...args) {
109-
return this._atem.cut.apply(this._atem, args)
110-
}
112+
setFairlightAudioMixerSourceProps(...args) {
113+
return this._atem.setFairlightAudioMixerSourceProps(...args);
114+
}
111115

112-
setFairlightAudioMixerSourceProps(...args) {
113-
return this._atem.setFairlightAudioMixerSourceProps.apply(this._atem, args)
114-
}
115-
116-
fadeToBlack(...args) {
117-
return this._atem.fadeToBlack.apply(this._atem, args)
118-
}
119-
120-
setUpstreamKeyerFlyKeyKeyframe(...args) {
121-
return this._atem.setUpstreamKeyerFlyKeyKeyframe.apply(this._atem, args)
122-
}
123-
124-
runUpstreamKeyerFlyKeyTo(...args) {
125-
return this._atem.runUpstreamKeyerFlyKeyTo.apply(this._atem, 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+
}
132132
}
133133

134-
export default ControllerAtem
134+
export default ControllerAtem;

ControllerConfig.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
import merge from 'deepmerge'
2-
import YAML from 'yaml'
3-
import fs from 'fs'
1+
import fs from 'node:fs';
2+
import merge from 'deepmerge';
3+
import YAML from 'yaml';
44

55
export class ControllerConfig {
6-
constructor() {
7-
this.config = undefined
8-
return this
9-
}
6+
constructor() {
7+
this.config = undefined;
8+
}
109

11-
async getConfig() {
12-
if (this.config) {
13-
console.log(`Config already loaded and just returning!`)
14-
return this.config
15-
}
10+
async getConfig() {
11+
if (this.config) {
12+
console.log('Config already loaded and just returning!');
13+
return this.config;
14+
}
1615

17-
console.log(`Loading the configuration from the YAML files`)
16+
console.log('Loading the configuration from the YAML files');
1817

19-
const configDefault = YAML.parse(fs.readFileSync('./config.default.yaml', 'utf8'))
20-
const configUser = YAML.parse(fs.readFileSync('./config.user.yaml', 'utf8'))
18+
const configDefault = YAML.parse(fs.readFileSync('./config.default.yaml', 'utf8'));
19+
const configUser = YAML.parse(fs.readFileSync('./config.user.yaml', 'utf8'));
2120

22-
this.config = merge(configDefault, configUser)
21+
this.config = merge(configDefault, configUser);
2322

24-
// console.log(`config:`, config)
23+
// Console.log(`config:`, config)
2524

26-
this.config.dve.stateMain = { ...this.config.dve.stateDefault }
27-
this.config.dve.stateCurrent = { ...this.config.dve.stateDefault }
25+
this.config.dve.stateMain = {...this.config.dve.stateDefault};
26+
this.config.dve.stateCurrent = {...this.config.dve.stateDefault};
2827

29-
return this.config
30-
}
28+
return this.config;
29+
}
3130
}
3231

33-
export default ControllerConfig
32+
export default ControllerConfig;

0 commit comments

Comments
 (0)