Skip to content

Commit

Permalink
Merge pull request #216 from tv2/SOF-1502/use-animatable-dve-locators
Browse files Browse the repository at this point in the history
Sof 1502/use animatable dve locators
  • Loading branch information
KvelaGorrrrnio authored Aug 21, 2023
2 parents a3de331 + 6ceb2b4 commit 7d3ea23
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
45 changes: 35 additions & 10 deletions src/tv2-common/content/dve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export interface DVEOptions {
type BoxConfig = DVEConfigBox & { source: number }
type BoxSources = Array<(VTContent | CameraContent | RemoteContent | GraphicsContent) & SplitsContentBoxProperties>

const DEFAULT_LOCATOR_TYPE = 'locators'

export function MakeContentDVEBase<
StudioConfig extends TV2StudioConfigBase,
ShowStyleConfig extends TV2BlueprintConfigBase<StudioConfig>
Expand Down Expand Up @@ -275,14 +277,9 @@ export function MakeContentDVE2<
}
})

let graphicsTemplateStyle: any = ''
try {
if (dveConfig.DVEGraphicsTemplateJSON) {
graphicsTemplateStyle = JSON.parse(dveConfig.DVEGraphicsTemplateJSON.toString())
}
} catch {
context.core.notifyUserWarning(`DVE Graphics Template JSON is not valid for ${dveConfig.DVEName}`)
}
const graphicsTemplate = getDveGraphicsTemplate(dveConfig, context.core.notifyUserWarning)
const graphicsTemplateStyle = getDveGraphicsTemplateStyle(graphicsTemplate)
const locatorType = getDveLocatorType(graphicsTemplate)

let keyFile = dveConfig.DVEGraphicsKey ? dveConfig.DVEGraphicsKey.toString() : undefined
let frameFile = dveConfig.DVEGraphicsFrame ? dveConfig.DVEGraphicsFrame.toString() : undefined
Expand Down Expand Up @@ -331,9 +328,9 @@ export function MakeContentDVE2<
enable: { start: 0 },
priority: 1,
layer: SharedGraphicLLayer.GraphicLLayerLocators,
content: CreateHTMLRendererContent(context.config, 'locators', {
content: CreateHTMLRendererContent(context.config, locatorType, {
...graphicsTemplateContent,
style: graphicsTemplateStyle ?? {}
style: graphicsTemplateStyle
})
}),
...(keyFile
Expand Down Expand Up @@ -378,6 +375,34 @@ export function MakeContentDVE2<
}
}

function getDveGraphicsTemplate(dveConfigInput: DVEConfigInput, notifyUserWarning: (message: string) => void): object {
try {
const dveGraphicsTemplate = JSON.parse(dveConfigInput.DVEGraphicsTemplateJSON)
if (!isValidDveGraphicsTemplate(dveGraphicsTemplate)) {
notifyUserWarning(`DVE Graphics Template for ${dveConfigInput.DVEName} is invalid.`)
return {}
}
return dveGraphicsTemplate
} catch {
notifyUserWarning(`DVE Graphics Template JSON for ${dveConfigInput.DVEName} is ill-formed.`)
return {}
}
}

function isValidDveGraphicsTemplate(dveGraphicsTemplate: unknown): dveGraphicsTemplate is object {
return typeof dveGraphicsTemplate === 'object' && dveGraphicsTemplate !== null
}

function getDveGraphicsTemplateStyle(dveGraphicsTemplate: { locatorType?: string }): object {
const { locatorType, ...dveGraphicsTemplateStyle } = dveGraphicsTemplate
return dveGraphicsTemplateStyle
}

function getDveLocatorType(dveGraphicsTemplate: { locatorType?: string }): string {
const { locatorType } = dveGraphicsTemplate
return locatorType ?? DEFAULT_LOCATOR_TYPE
}

const setBoxSource = (
boxConfig: BoxConfig,
boxSources: BoxSources,
Expand Down
20 changes: 15 additions & 5 deletions src/tv2-common/helpers/graphics/caspar/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SharedGraphicLLayer } from 'tv2-constants'

export function CreateHTMLRendererContent(
config: TV2ShowStyleConfig,
mappedTemplate: string,
graphicTemplateName: string,
data: object
): TSR.TimelineObjCCGTemplate['content'] {
return {
Expand All @@ -22,7 +22,7 @@ export function CreateHTMLRendererContent(
name: getHtmlTemplateName(config),
data: {
display: 'program',
slots: getHtmlTemplateContent(config, mappedTemplate, data),
slots: getHtmlTemplateContent(config, graphicTemplateName, data),
partialUpdate: true
},
useStopCommand: false,
Expand All @@ -32,12 +32,22 @@ export function CreateHTMLRendererContent(
}
}

function getMappedGraphicsTemplateName(templateName: string): string {
switch (templateName) {
case 'locators-afvb':
return 'locators'
default:
return templateName
}
}

export function getHtmlTemplateContent(
config: TV2ShowStyleConfig,
graphicTemplate: string,
graphicTemplateName: string,
data: object
): Partial<Slots> {
const layer = getTimelineLayerForGraphic(config, graphicTemplate)
const mappedGraphicTemplateName = getMappedGraphicsTemplateName(graphicTemplateName)
const layer = getTimelineLayerForGraphic(config, mappedGraphicTemplateName)

const slot = layerToHTMLGraphicSlot[layer]

Expand All @@ -49,7 +59,7 @@ export function getHtmlTemplateContent(
[slot]: {
display: 'program',
payload: {
type: graphicTemplate,
type: graphicTemplateName,
...data
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tv2_afvd_showstyle/config-manifests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export const showStyleConfigManifest: ConfigManifestEntry[] = [
'The Sofie Layer mapping to use in playback. This will ensure proper viz transition logic by matching the viz layers.',
type: ConfigManifestEntryType.LAYER_MAPPINGS,
filters: {
deviceTypes: [TSR.DeviceType.VIZMSE]
deviceTypes: [TSR.DeviceType.VIZMSE, TSR.DeviceType.CASPARCG]
},
multiple: false,
required: true,
Expand Down

0 comments on commit 7d3ea23

Please sign in to comment.