Skip to content

Commit

Permalink
Merge pull request #312 from nrkno/feat/hyperdeck-state-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian authored Dec 18, 2023
2 parents a238f67 + ff5e91e commit 5dd45c1
Show file tree
Hide file tree
Showing 11 changed files with 1,194 additions and 1,172 deletions.
2 changes: 1 addition & 1 deletion packages/timeline-state-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"eventemitter3": "^4.0.7",
"got": "^11.8.6",
"hpagent": "^1.2.0",
"hyperdeck-connection": "^0.5.0",
"hyperdeck-connection": "2.0.0-nightly-master-20231205-105655-157a483.0",
"klona": "^2.0.6",
"obs-websocket-js": "^4.0.3",
"osc": "^2.4.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from 'events'

import { TransportStatus, Commands } from 'hyperdeck-connection'
import { TransportStatus, Commands, VideoFormat, SlotStatus } from 'hyperdeck-connection'

const setTimeoutOrg = setTimeout

Expand All @@ -9,7 +9,7 @@ export interface HyperdeckOptions {
debug?: boolean
}

export { TransportStatus, Commands }
export { TransportStatus, Commands, VideoFormat, SlotStatus }

const hyperdeckmockInstances: Array<Hyperdeck> = []

Expand All @@ -24,7 +24,7 @@ export class Hyperdeck extends EventEmitter {
private _host: string
private _port: number

private _mockCommandReceiver?: (cmd: Commands.AbstractCommand) => Promise<any>
private _mockCommandReceiver?: (cmd: Commands.AbstractCommand<any>) => Promise<any>

constructor(_options?: HyperdeckOptions) {
super()
Expand All @@ -51,6 +51,9 @@ export class Hyperdeck extends EventEmitter {
async disconnect(): Promise<void> {
this._connectionActive = false

const ind = hyperdeckmockInstances.indexOf(this)
if (ind !== -1) hyperdeckmockInstances.splice(ind, 1)

if (!this._connected) return Promise.resolve()

return new Promise((resolve, reject) => {
Expand All @@ -62,7 +65,7 @@ export class Hyperdeck extends EventEmitter {
})
}

async sendCommand(command: Commands.AbstractCommand): Promise<any> {
async sendCommand(command: Commands.AbstractCommand<any>): Promise<any> {
if (this._mockCommandReceiver) {
return this._mockCommandReceiver(command)
}
Expand All @@ -75,7 +78,7 @@ export class Hyperdeck extends EventEmitter {
const res: Commands.DeviceInfoCommandResponse = {
protocolVersion: 1.9,
model: 'Mock HyperDeck for TSR',
slots: '2',
slots: 2,
}
return Promise.resolve(res)
} else if (command instanceof Commands.TransportInfoCommand) {
Expand All @@ -87,7 +90,7 @@ export class Hyperdeck extends EventEmitter {
return Promise.resolve()
}

public setMockCommandReceiver(fcn: (cmd: Commands.AbstractCommand) => Promise<any>) {
public setMockCommandReceiver(fcn: (cmd: Commands.AbstractCommand<any>) => Promise<any>) {
this._mockCommandReceiver = fcn
}
get connected() {
Expand Down
14 changes: 3 additions & 11 deletions packages/timeline-state-resolver/src/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
DeviceOptionsAtem,
DeviceOptionsTCPSend,
DeviceOptionsQuantel,
DeviceOptionsHyperdeck,
} from 'timeline-state-resolver-types'

import { DoOnTime } from './devices/doOnTime'
Expand All @@ -41,7 +42,6 @@ import { DeviceContainer } from './devices/deviceContainer'
import { CasparCGDevice, DeviceOptionsCasparCGInternal } from './integrations/casparCG'
import { LawoDevice, DeviceOptionsLawoInternal } from './integrations/lawo'
import { PanasonicPtzDevice, DeviceOptionsPanasonicPTZInternal } from './integrations/panasonicPTZ'
import { HyperdeckDevice, DeviceOptionsHyperdeckInternal } from './integrations/hyperdeck'
import { PharosDevice, DeviceOptionsPharosInternal } from './integrations/pharos'
import { SisyfosMessageDevice, DeviceOptionsSisyfosInternal } from './integrations/sisyfos'
import { SingularLiveDevice, DeviceOptionsSingularLiveInternal } from './integrations/singularLive'
Expand Down Expand Up @@ -528,15 +528,6 @@ export class Conductor extends EventEmitter<ConductorEvents> {
getCurrentTime,
threadedClassOptions
)
case DeviceType.HYPERDECK:
return DeviceContainer.create<DeviceOptionsHyperdeckInternal, typeof HyperdeckDevice>(
'../../dist/integrations/hyperdeck/index.js',
'HyperdeckDevice',
deviceId,
deviceOptions,
getCurrentTime,
threadedClassOptions
)
case DeviceType.PHAROS:
return DeviceContainer.create<DeviceOptionsPharosInternal, typeof PharosDevice>(
'../../dist/integrations/pharos/index.js',
Expand Down Expand Up @@ -631,6 +622,7 @@ export class Conductor extends EventEmitter<ConductorEvents> {
case DeviceType.ATEM:
case DeviceType.HTTPSEND:
case DeviceType.HTTPWATCHER:
case DeviceType.HYPERDECK:
case DeviceType.OSC:
case DeviceType.SHOTOKU:
case DeviceType.TCPSEND:
Expand Down Expand Up @@ -1544,7 +1536,7 @@ export type DeviceOptionsAnyInternal =
| DeviceOptionsHTTPWatcher
| DeviceOptionsPanasonicPTZInternal
| DeviceOptionsTCPSend
| DeviceOptionsHyperdeckInternal
| DeviceOptionsHyperdeck
| DeviceOptionsPharosInternal
| DeviceOptionsOBSInternal
| DeviceOptionsOSC
Expand Down
Loading

0 comments on commit 5dd45c1

Please sign in to comment.