Skip to content

Commit

Permalink
feat: expose new commands on atem class
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Apr 6, 2021
1 parent f241a0c commit efbeb3d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 6 deletions.
32 changes: 29 additions & 3 deletions src/atem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventEmitter } from 'eventemitter3'
import { AtemState, AtemStateUtil, InvalidIdError } from './state'
import { AtemState, AtemStateUtil, InvalidIdError, ColorGeneratorState } from './state'
import { AtemSocket } from './lib/atemSocket'
import { ISerializableCommand, IDeserializedCommand } from './commands/CommandBase'
import * as Commands from './commands'
Expand Down Expand Up @@ -414,8 +414,34 @@ export class Atem extends BasicAtem {
return this.sendCommand(command)
}

public setMultiViewerSource(newProps: OmitReadonly<MultiViewerSourceState>, mv = 0): Promise<void> {
const command = new Commands.MultiViewerSourceCommand(mv, newProps.windowIndex, newProps.source)
/** @deprecated Use setMultiViewerWindowSource instead */
public setMultiViewerSource(
newProps: Pick<MultiViewerSourceState, 'windowIndex' | 'source'>,
mv = 0
): Promise<void> {
return this.setMultiViewerWindowSource(newProps.source, mv, newProps.windowIndex)
}
public setMultiViewerWindowSource(source: number, mv = 0, window = 0): Promise<void> {
const command = new Commands.MultiViewerSourceCommand(mv, window, source)
return this.sendCommand(command)
}
public setMultiViewerWindowSafeAreaEnabled(safeAreaEnabled: boolean, mv = 0, window = 0): Promise<void> {
const command = new Commands.MultiViewerWindowSafeAreaCommand(mv, window, safeAreaEnabled)
return this.sendCommand(command)
}
public setMultiViewerWindowVuEnabled(vuEnabled: boolean, mv = 0, window = 0): Promise<void> {
const command = new Commands.MultiViewerWindowVuMeterCommand(mv, window, vuEnabled)
return this.sendCommand(command)
}

public setMultiViewerVuOpacity(opacity: number, mv = 0): Promise<void> {
const command = new Commands.MultiViewerVuOpacityCommand(mv, opacity)
return this.sendCommand(command)
}

public setColorGeneratorColour(newProps: Partial<ColorGeneratorState>, index = 0): Promise<void> {
const command = new Commands.ColorGeneratorCommand(index)
command.updateProps(newProps)
return this.sendCommand(command)
}

Expand Down
5 changes: 3 additions & 2 deletions src/commands/Settings/MultiViewerSourceCommand.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { BasicWritableCommand, DeserializedCommand } from '../CommandBase'
import { AtemState, AtemStateUtil, InvalidIdError } from '../../state'
import { MultiViewerSourceState } from '../../state/settings'
import { OmitReadonly } from '../../lib/types'

export class MultiViewerSourceCommand extends BasicWritableCommand<OmitReadonly<MultiViewerSourceState>> {
export class MultiViewerSourceCommand extends BasicWritableCommand<
Pick<MultiViewerSourceState, 'windowIndex' | 'source'>
> {
public static readonly rawName = 'CMvI'

public readonly multiViewerId: number
Expand Down
2 changes: 1 addition & 1 deletion src/commands/Settings/MultiViewerWindowVuMeterCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class MultiViewerWindowVuMeterCommand extends BasicWritableCommand<{ vuEn
const buffer = Buffer.alloc(4)
buffer.writeUInt8(this.multiViewerId, 0)
buffer.writeUInt8(this.windowIndex || 0, 1)
buffer.writeUInt16BE(this.properties.vuEnabled ? 1 : 0, 2)
buffer.writeUInt8(this.properties.vuEnabled ? 1 : 0, 2)
return buffer
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/Settings/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './MultiViewerSourceCommand'
export * from './MultiViewerPropertiesCommand'
export * from './MultiViewerVuOpacityCommand'
export * from './MultiViewerWindowVuMeterCommand'
export * from './MultiViewerWindowSafeAreaCommand'
export * from './VideoMode'
14 changes: 14 additions & 0 deletions src/commands/__tests__/converters-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,5 +1021,19 @@ export const DefaultCommandConverters: CommandTestConverterSet = {
propertyAliases: {
opacity: (val: number): PropertyAliasResult => ({ val: Math.round(val) })
}
},
VuMS: {
idAliases: {
multiViewerId: 'multiviewIndex',
windowIndex: 'windowIndex'
},
propertyAliases: {}
},
VuMC: {
idAliases: {
multiViewerId: 'multiviewIndex',
windowIndex: 'windowIndex'
},
propertyAliases: {}
}
}

0 comments on commit efbeb3d

Please sign in to comment.