Skip to content

Commit

Permalink
Merge branch 'contribute/EAV-343' of github.com:tv2norge-collab/sofie…
Browse files Browse the repository at this point in the history
…-timeline-state-resolver into release52

# Conflicts:
#	packages/timeline-state-resolver-types/src/integrations/vmix.ts
#	packages/timeline-state-resolver/src/integrations/vmix/__tests__/connection.spec.ts
#	packages/timeline-state-resolver/src/integrations/vmix/__tests__/vMixStateDiffer.spec.ts
#	packages/timeline-state-resolver/src/integrations/vmix/__tests__/vMixTimelineStateConverter.spec.ts
#	packages/timeline-state-resolver/src/integrations/vmix/connection.ts
#	packages/timeline-state-resolver/src/integrations/vmix/vMixCommands.ts
#	packages/timeline-state-resolver/src/integrations/vmix/vMixStateDiffer.ts
#	packages/timeline-state-resolver/src/integrations/vmix/vMixTimelineStateConverter.ts
  • Loading branch information
nytamin committed Nov 27, 2024
2 parents 842fbf3 + 02db182 commit ad41ae6
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export enum VMixCommand {
LIST_REMOVE_ALL = 'LIST_REMOVE_ALL',
RESTART_INPUT = 'RESTART_INPUT',
BROWSER_NAVIGATE = 'BROWSER_NAVIGATE',
SELECT_INDEX = 'SELECT_INDEX',
}

export type TimelineContentVMixAny =
Expand Down Expand Up @@ -192,6 +193,13 @@ export interface TimelineContentVMixInput extends TimelineContentVMixBase {

/** The URL for Browser input */
url?: string

/**
* Photos, List: Selects item in List
* Virtual Set: Zooms to selected preset using the current speed settings
* starts from 1
*/
index?: number
}

export interface TimelineContentVMixOutput extends TimelineContentVMixBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,18 @@ describe('VMixCommandSender', () => {
value: 'https%3A%2F%2Fexample.com',
})
})
it('selects index', async () => {
const { sender, mockConnection } = createTestee()
await sender.sendCommand({
command: VMixCommand.SELECT_INDEX,
input: 5,
value: 3,
})

expect(mockConnection.sendCommandFunction).toHaveBeenCalledTimes(1)
expect(mockConnection.sendCommandFunction).toHaveBeenLastCalledWith('SelectIndex', {
input: 5,
value: 3,
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,25 @@ describe('VMixStateDiffer', () => {
value: url,
})
})
it('sets index', () => {
const differ = createTestee()

const oldState = makeMockFullState()
const newState = makeMockFullState()

oldState.reportedState.existingInputs['99'] = differ.getDefaultInputState(99)

newState.reportedState.existingInputs['99'] = differ.getDefaultInputState(99)
const index = 3
newState.reportedState.existingInputs['99'].index = index

const commands = differ.getCommandsToAchieveState(Date.now(), oldState, newState)

expect(commands.length).toBe(1)
expect(commands[0].command).toMatchObject({
command: VMixCommand.SELECT_INDEX,
input: '99',
value: index,
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,26 @@ describe('VMixTimelineStateConverter', () => {
)
expect(result.reportedState.existingInputs['1'].url).toEqual(url)
})
it('supports index', () => {
const converter = createTestee()
const index = 3
const result = converter.getVMixStateFromTimelineState(
wrapInTimelineState({
inp0: wrapInTimelineObject('inp0', {
deviceType: DeviceType.VMIX,
index,
type: TimelineContentTypeVMix.INPUT,
}),
}),
{
inp0: wrapInMapping({
mappingType: MappingVmixType.Input,
index: '1',
}),
}
)
expect(result.reportedState.existingInputs['1'].index).toEqual(index)
})

// TODO: maybe we can't trust the defaults when adding an input? Make this test pass eventually
// it('tracks audio state for mapped inputs added by us', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ export class VMixCommandSender {
return this.restart(command.input)
case VMixCommand.BROWSER_NAVIGATE:
return this.browserNavigate(command.input, command.value)
case VMixCommand.SELECT_INDEX:
return this.selectIndex(command.input, command.value)
default:
throw new Error(`vmixAPI: Command ${((command || {}) as any).command} not implemented`)
}
Expand Down Expand Up @@ -473,6 +475,10 @@ export class VMixCommandSender {
return this.sendCommandFunction(`BrowserNavigate`, { input, value: encodeURIComponent(value) })
}

public async selectIndex(input: string | number, value: number): Promise<any> {
return this.sendCommandFunction(`SelectIndex`, { input, value })
}

private async sendCommandFunction(func: string, args: SentCommandArgs) {
return this.vMixConnection.sendCommandFunction(func, args)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ export interface VMixStateCommandBrowserNavigate extends VMixStateCommandBase {
input: string | number
value: string
}
export interface VMixStateCommanSelectIndex extends VMixStateCommandBase {
command: VMixCommand.SELECT_INDEX
input: string | number
value: number
}
export type VMixStateCommand =
| VMixStateCommandPreviewInput
| VMixStateCommandTransition
Expand Down Expand Up @@ -254,6 +259,7 @@ export type VMixStateCommand =
| VMixStateCommandListRemoveAll
| VMixStateCommandRestart
| VMixStateCommandBrowserNavigate
| VMixStateCommanSelectIndex

export enum CommandContext {
None = 'none',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface VMixInput {
listFilePaths?: string[]
restart?: boolean
url?: string
index?: number
}

export interface VMixInputAudio {
Expand Down Expand Up @@ -595,6 +596,17 @@ export class VMixStateDiffer {
timelineId: '',
})
}
if (input.index !== undefined && oldInput.index !== input.index) {
commands.push({
command: {
command: VMixCommand.SELECT_INDEX,
input: key,
value: input.index,
},
context: CommandContext.None,
timelineId: '',
})
}
return { preTransitionCommands, postTransitionCommands }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class VMixTimelineStateConverter {
listFilePaths: content.listFilePaths,
restart: content.restart,
url: content.url,
index: content.index,
},
{ key: mapping.options.index, filePath: content.filePath },
layerName
Expand Down

0 comments on commit ad41ae6

Please sign in to comment.