Skip to content

Commit

Permalink
wip: support vMix script
Browse files Browse the repository at this point in the history
  • Loading branch information
ianshade committed Oct 10, 2023
1 parent 7ff8a5c commit d244049
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
16 changes: 16 additions & 0 deletions apps/app/src/lib/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
TimelineContentHyperdeckTransport,
TimelineContentTCPRequest,
TimelineContentAtemAudioRouting,
TimelineContentVMixScript,
} from 'timeline-state-resolver-types'
import { ResourceAny, ResourceType } from '@shared/models'
import { assertNever, literal } from '@shared/lib'
Expand Down Expand Up @@ -551,6 +552,20 @@ export function TSRTimelineObjFromResource(resource: ResourceAny): TSRTimelineOb
position: 255,
},
})
} else if (resource.resourceType === ResourceType.VMIX_SCRIPT) {
return literal<TSRTimelineObj<TimelineContentVMixScript>>({
id: shortID(),
layer: '', // set later
enable: {
start: 0,
duration: INFINITE_DURATION,
},
content: {
deviceType: DeviceType.VMIX,
type: TimelineContentTypeVMix.SCRIPT,
name: '',
},
})
} else if (resource.resourceType === ResourceType.OSC_MESSAGE) {
return literal<TSRTimelineObj<TimelineContentOSCMessage>>({
id: shortID(),
Expand Down Expand Up @@ -691,6 +706,7 @@ export function getClassNameFromResource(resource: ResourceAny): string {
case ResourceType.ATEM_SSRC_PROPS:
return 'SSRC'
case ResourceType.ATEM_MACRO_PLAYER:
case ResourceType.VMIX_SCRIPT:
return 'Macros'
case ResourceType.ATEM_AUDIO_CHANNEL:
return 'Audio'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export const ResourceData: React.FC<{ resource: ResourceAny }> = ({ resource })
return <ResourceDataInner title="vMix Fader">{universalRows}</ResourceDataInner>
} else if (resource.resourceType === ResourceType.VMIX_PREVIEW) {
return <ResourceDataInner title="vMix Preview">{universalRows}</ResourceDataInner>
} else if (resource.resourceType === ResourceType.VMIX_SCRIPT) {
return <ResourceDataInner title="vMix Streaming">{universalRows}</ResourceDataInner>
} else if (resource.resourceType === ResourceType.OSC_MESSAGE) {
return <ResourceDataInner title="OSC Message">{universalRows}</ResourceDataInner>
} else if (resource.resourceType === ResourceType.HTTP_REQUEST) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const ResourceLibraryItem = function ResourceLibraryItem({ resource, sele
resource.resourceType === ResourceType.VMIX_FADE_TO_BLACK ||
resource.resourceType === ResourceType.VMIX_FADER ||
resource.resourceType === ResourceType.VMIX_PREVIEW ||
resource.resourceType === ResourceType.VMIX_SCRIPT ||
resource.resourceType === ResourceType.OSC_MESSAGE ||
resource.resourceType === ResourceType.OBS_RENDER ||
resource.resourceType === ResourceType.OBS_MUTE ||
Expand Down
3 changes: 3 additions & 0 deletions shared/packages/lib/src/Resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export function describeResource(resource: ResourceAny): GeneralResourceType {
return GeneralResourceType.FADER
case ResourceType.VMIX_PREVIEW:
return GeneralResourceType.PREVIEW
case ResourceType.VMIX_SCRIPT:
return GeneralResourceType.MACRO_PLAYER
case ResourceType.OSC_MESSAGE:
return GeneralResourceType.OSC
case ResourceType.HTTP_REQUEST:
Expand Down Expand Up @@ -592,6 +594,7 @@ export function getResourceLocatorFromResource(resource: ResourceAny): string {
case ResourceType.VMIX_PREVIEW:
case ResourceType.VMIX_RECORDING:
case ResourceType.VMIX_STREAMING:
case ResourceType.VMIX_SCRIPT:
return '0'
case ResourceType.VMIX_INPUT:
// todo: something might be wrong here, type doesn't seem to be used
Expand Down
5 changes: 5 additions & 0 deletions shared/packages/models/src/resource/VMix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type VMixAny =
| VMixExternal
| VMixFadeToBlack
| VMixFader
| VMixScript

export interface VMixInput extends ResourceBase {
resourceType: ResourceType.VMIX_INPUT
Expand Down Expand Up @@ -59,3 +60,7 @@ export interface VMixFadeToBlack extends ResourceBase {
export interface VMixFader extends ResourceBase {
resourceType: ResourceType.VMIX_FADER
}

export interface VMixScript extends ResourceBase {
resourceType: ResourceType.VMIX_SCRIPT
}
13 changes: 13 additions & 0 deletions shared/packages/tsr-bridge/src/sideload/VMix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
MetadataAny,
MetadataType,
TSRDeviceId,
VMixScript,
} from '@shared/models'
import { SideLoadDevice } from './sideload'
import { LoggerLike } from '@shared/api'
Expand Down Expand Up @@ -205,6 +206,18 @@ export class VMixSideload implements SideLoadDevice {
resources.set(resource.id, resource)
}

// Script
{
const resource: VMixScript = {
resourceType: ResourceType.VMIX_SCRIPT,
deviceId: this.deviceId,
id: protectString(''), // set by getResourceIdFromResource() later
displayName: 'Script',
}
resource.id = getResourceIdFromResource(resource)
resources.set(resource.id, resource)
}

return {
resources: Array.from(resources.values()),
metadata,
Expand Down

0 comments on commit d244049

Please sign in to comment.