Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOF-2203: Uses part index in segment to assign action rank. #248

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/tv2-common/actions/executeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ const STOPPABLE_GRAPHICS_LAYERS = [
SharedSourceLayer.PgmGraphicsTLF
]

const EXECUTE_ACTION_PART_INDEX: number = 0

export interface ActionExecutionSettings<BlueprintConfig extends TV2ShowStyleConfig = TV2ShowStyleConfig> {
EvaluateCues: (
context: ShowStyleContext<BlueprintConfig>,
Expand All @@ -117,6 +119,7 @@ export interface ActionExecutionSettings<BlueprintConfig extends TV2ShowStyleCon
mediaSubscriptions: HackPartMediaObjectSubscription[],
cues: CueDefinition[],
partDefinition: PartDefinition,
partIndex: number,
options: EvaluateCuesOptions
) => void
DVEGeneratorOptions: DVEOptions
Expand Down Expand Up @@ -471,10 +474,21 @@ async function executeActionSelectServerClip<
})
}

settings.EvaluateCues(context, basePart.part.part, grafikPieces, [], [], [], partDefinition.cues, partDefinition, {
excludeAdlibs: true,
selectedCueTypes: [CueType.Graphic]
})
settings.EvaluateCues(
context,
basePart.part.part,
grafikPieces,
[],
[],
[],
partDefinition.cues,
partDefinition,
EXECUTE_ACTION_PART_INDEX,
{
excludeAdlibs: true,
selectedCueTypes: [CueType.Graphic]
}
)

if (basePart.invalid || !activeServerPiece || !serverDataStore) {
context.core.notifyUserWarning(`Could not start server clip`)
Expand Down
59 changes: 16 additions & 43 deletions src/tv2-common/evaluateCues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
} from './inewsConversion'

const PART_RANK_FRACTION_FACTOR: number = 1000
const CUE_RANK_FRACTION_FACTOR: number = PART_RANK_FRACTION_FACTOR * 100

export interface Adlib {
rank: number
Expand Down Expand Up @@ -193,15 +194,17 @@ export async function EvaluateCuesBase(
mediaSubscriptions: HackPartMediaObjectSubscription[],
cues: CueDefinition[],
partDefinition: PartDefinition,
options: EvaluateCuesOptions
options: EvaluateCuesOptions,
partIndex: number
) {
let adLibRank = 1
const result = new EvaluateCueResult()

for (const cue of cues) {
if (cue && !SkipCue(cue, options.selectedCueTypes, options.excludeAdlibs, options.adlibsOnly)) {
const shouldAdlib = !!(options.adlib || cue.adlib)
const adlib = shouldAdlib ? { rank: getRankForPartDefinition(adLibRank, partDefinition) } : undefined
const adlibRank: number = getRankForPartDefinition(adLibRank, partDefinition, partIndex)
const adlib = shouldAdlib ? { rank: adlibRank } : undefined

switch (cue.type) {
case CueType.Graphic:
Expand All @@ -221,7 +224,7 @@ export async function EvaluateCuesBase(
partDefinition.externalId,
cue,
partDefinition,
getRankForPartDefinition(adLibRank, partDefinition),
adlibRank,
adlib
)
)
Expand All @@ -237,33 +240,17 @@ export async function EvaluateCuesBase(
cue,
partDefinition,
shouldAdlib,
getRankForPartDefinition(adLibRank, partDefinition)
adlibRank
)
)
}
break
case CueType.DVE:
if (showStyleOptions.EvaluateCueDVE) {
showStyleOptions.EvaluateCueDVE(
context,
pieces,
actions,
partDefinition,
cue,
shouldAdlib,
getRankForPartDefinition(adLibRank, partDefinition)
)
showStyleOptions.EvaluateCueDVE(context, pieces, actions, partDefinition, cue, shouldAdlib, adlibRank)
// Always make an adlib for DVEs
if (!shouldAdlib) {
showStyleOptions.EvaluateCueDVE(
context,
pieces,
actions,
partDefinition,
cue,
true,
getRankForPartDefinition(adLibRank, partDefinition)
)
showStyleOptions.EvaluateCueDVE(context, pieces, actions, partDefinition, cue, true, adlibRank)
}
}
break
Expand All @@ -275,7 +262,7 @@ export async function EvaluateCuesBase(
mediaSubscriptions,
cue,
partDefinition,
getRankForPartDefinition(adLibRank, partDefinition)
adlibRank
)
}
break
Expand All @@ -288,15 +275,7 @@ export async function EvaluateCuesBase(
break
case CueType.Jingle:
if (showStyleOptions.EvaluateCueJingle) {
showStyleOptions.EvaluateCueJingle(
context,
pieces,
actions,
cue,
partDefinition,
shouldAdlib,
getRankForPartDefinition(adLibRank, partDefinition)
)
showStyleOptions.EvaluateCueJingle(context, pieces, actions, cue, partDefinition, shouldAdlib, adlibRank)
}
break
case CueType.LYD:
Expand All @@ -309,20 +288,14 @@ export async function EvaluateCuesBase(
cue,
partDefinition,
shouldAdlib,
getRankForPartDefinition(adLibRank, partDefinition)
adlibRank
)
}
break
case CueType.GraphicDesign:
if (showStyleOptions.EvaluateCueGraphicDesign) {
result.push(
showStyleOptions.EvaluateCueGraphicDesign(
context,
partDefinition.externalId,
cue,
shouldAdlib,
getRankForPartDefinition(adLibRank, partDefinition)
)
showStyleOptions.EvaluateCueGraphicDesign(context, partDefinition.externalId, cue, shouldAdlib, adlibRank)
)
}
break
Expand Down Expand Up @@ -352,7 +325,7 @@ export async function EvaluateCuesBase(
partDefinition.externalId,
cue,
shouldAdlib,
getRankForPartDefinition(adLibRank, partDefinition)
adlibRank
)
)
}
Expand Down Expand Up @@ -441,8 +414,8 @@ export async function EvaluateCuesBase(
})
}

function getRankForPartDefinition(rank: number, partDefinition: PartDefinition): number {
return partDefinition.segmentRank + rank / PART_RANK_FRACTION_FACTOR
function getRankForPartDefinition(cueIndex: number, partDefinition: PartDefinition, partIndex: number): number {
return partDefinition.segmentRank + partIndex / PART_RANK_FRACTION_FACTOR + cueIndex / CUE_RANK_FRACTION_FACTOR
}

export function SkipCue(
Expand Down
57 changes: 35 additions & 22 deletions src/tv2-common/getSegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,52 +35,62 @@ export interface GetSegmentShowstyleOptions<ShowStyleConfig extends TV2ShowStyle
CreatePartUnknown: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinition,
partIndex: number,
totalWords: number,
asAdlibs?: boolean
) => BlueprintResultPart | Promise<BlueprintResultPart>
CreatePartIntro?: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinition,
partIndex: number,
totalWords: number
) => BlueprintResultPart | Promise<BlueprintResultPart>
CreatePartKam?: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinitionKam,
partIndex: number,
totalWords: number
) => BlueprintResultPart | Promise<BlueprintResultPart>
CreatePartServer?: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinition,
partIndex: number,
partProps: ServerPartProps
) => BlueprintResultPart | Promise<BlueprintResultPart>
CreatePartTeknik?: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinitionTeknik,
partIndex: number,
totalWords: number
) => BlueprintResultPart | Promise<BlueprintResultPart>
CreatePartGrafik?: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinitionGrafik,
partIndex: number,
totalWords: number
) => BlueprintResultPart | Promise<BlueprintResultPart>
CreatePartEkstern?: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinitionEkstern,
partIndex: number,
totalWords: number
) => BlueprintResultPart | Promise<BlueprintResultPart>
CreatePartTelefon?: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinitionTelefon,
partIndex: number,
totalWords: number
) => BlueprintResultPart | Promise<BlueprintResultPart>
CreatePartDVE?: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinitionDVE,
partIndex: number,
totalWords: number
) => BlueprintResultPart | Promise<BlueprintResultPart>
CreatePartEVS?: (
context: ShowStyleContext<ShowStyleConfig>,
partDefinition: PartDefinitionEVS,
partIndex: number,
totalWords: number
) => BlueprintResultPart | Promise<BlueprintResultPart>
}
Expand Down Expand Up @@ -161,23 +171,26 @@ export async function getSegmentBase<ShowStyleConfig extends TV2ShowStyleConfig>
const totalTime = TimeFromINewsField(iNewsStory.fields.totalTime)
const tapeTime = TimeFromINewsField(iNewsStory.fields.tapeTime)

for (const part of parsedParts) {
for (let partIndex = 0; partIndex < parsedParts.length; partIndex++) {
const partDefinition: PartDefinition = parsedParts[partIndex]
// Make orphaned secondary cues into adlibs
if (
GetNextPartCue(part, -1) === -1 &&
part.type === PartType.Unknown &&
part.cues.filter((cue) => cue.type === CueType.Jingle || cue.type === CueType.AdLib).length === 0
GetNextPartCue(partDefinition, -1) === -1 &&
partDefinition.type === PartType.Unknown &&
partDefinition.cues.filter((cue) => cue.type === CueType.Jingle || cue.type === CueType.AdLib).length === 0
) {
blueprintParts.push(await showStyleOptions.CreatePartUnknown(context, part, totalWords, true))
blueprintParts.push(
await showStyleOptions.CreatePartUnknown(context, partDefinition, partIndex, totalWords, true)
)
continue
}

const unpairedTargets = part.cues.filter(
const unpairedTargets = partDefinition.cues.filter(
(c) => c.type === CueType.UNPAIRED_TARGET && IsTargetingFull(c.target)
) as CueDefinitionUnpairedTarget[]
if (unpairedTargets.length) {
blueprintParts.push(
CreatePartInvalid(part, {
CreatePartInvalid(partDefinition, {
reason: `The part has one or more unpaired targets: ${unpairedTargets
.map((cue) => cue.iNewsCommand)
.join(', ')}`
Expand All @@ -189,21 +202,21 @@ export async function getSegmentBase<ShowStyleConfig extends TV2ShowStyleConfig>
continue
}

switch (part.type) {
switch (partDefinition.type) {
case PartType.INTRO:
if (showStyleOptions.CreatePartIntro) {
blueprintParts.push(await showStyleOptions.CreatePartIntro(context, part, totalWords))
blueprintParts.push(await showStyleOptions.CreatePartIntro(context, partDefinition, partIndex, totalWords))
}
break
case PartType.Kam:
if (showStyleOptions.CreatePartKam) {
blueprintParts.push(await showStyleOptions.CreatePartKam(context, part, totalWords))
blueprintParts.push(await showStyleOptions.CreatePartKam(context, partDefinition, partIndex, totalWords))
}
break
case PartType.Server:
if (showStyleOptions.CreatePartServer) {
blueprintParts.push(
await showStyleOptions.CreatePartServer(context, part, {
await showStyleOptions.CreatePartServer(context, partDefinition, partIndex, {
voLayer: false,
voLevels: false,
totalTime,
Expand All @@ -216,18 +229,18 @@ export async function getSegmentBase<ShowStyleConfig extends TV2ShowStyleConfig>
break
case PartType.Teknik:
if (showStyleOptions.CreatePartTeknik) {
blueprintParts.push(await showStyleOptions.CreatePartTeknik(context, part, totalWords))
blueprintParts.push(await showStyleOptions.CreatePartTeknik(context, partDefinition, partIndex, totalWords))
}
break
case PartType.Grafik:
if (showStyleOptions.CreatePartGrafik) {
blueprintParts.push(await showStyleOptions.CreatePartGrafik(context, part, totalWords))
blueprintParts.push(await showStyleOptions.CreatePartGrafik(context, partDefinition, partIndex, totalWords))
}
break
case PartType.VO:
if (showStyleOptions.CreatePartServer) {
blueprintParts.push(
await showStyleOptions.CreatePartServer(context, part, {
await showStyleOptions.CreatePartServer(context, partDefinition, partIndex, {
voLayer: true,
voLevels: true,
totalTime,
Expand All @@ -240,35 +253,35 @@ export async function getSegmentBase<ShowStyleConfig extends TV2ShowStyleConfig>
break
case PartType.DVE:
if (showStyleOptions.CreatePartDVE) {
blueprintParts.push(await showStyleOptions.CreatePartDVE(context, part, totalWords))
blueprintParts.push(await showStyleOptions.CreatePartDVE(context, partDefinition, partIndex, totalWords))
}
break
case PartType.REMOTE:
if (showStyleOptions.CreatePartEkstern) {
blueprintParts.push(await showStyleOptions.CreatePartEkstern(context, part, totalWords))
blueprintParts.push(await showStyleOptions.CreatePartEkstern(context, partDefinition, partIndex, totalWords))
}
break
case PartType.Telefon:
if (showStyleOptions.CreatePartTelefon) {
blueprintParts.push(await showStyleOptions.CreatePartTelefon(context, part, totalWords))
blueprintParts.push(await showStyleOptions.CreatePartTelefon(context, partDefinition, partIndex, totalWords))
}
break
case PartType.Unknown:
if (part.cues.length) {
blueprintParts.push(await showStyleOptions.CreatePartUnknown(context, part, totalWords))
if (partDefinition.cues.length) {
blueprintParts.push(await showStyleOptions.CreatePartUnknown(context, partDefinition, partIndex, totalWords))
}
break
case PartType.EVS:
if (showStyleOptions.CreatePartEVS) {
blueprintParts.push(await showStyleOptions.CreatePartEVS(context, part, totalWords))
blueprintParts.push(await showStyleOptions.CreatePartEVS(context, partDefinition, partIndex, totalWords))
}
break
default:
assertUnreachable(part)
assertUnreachable(partDefinition)
break
}

if (part.cues.filter((cue) => cue.type === CueType.Jingle).length) {
if (partDefinition.cues.filter((cue) => cue.type === CueType.Jingle).length) {
if (blueprintParts[blueprintParts.length - 1]) {
const t = blueprintParts[blueprintParts.length - 1].part.expectedDuration
if (t) {
Expand Down
4 changes: 3 additions & 1 deletion src/tv2_afvd_showstyle/helpers/pieces/evaluateCues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function EvaluateCues(
mediaSubscriptions: HackPartMediaObjectSubscription[],
cues: CueDefinition[],
partDefinition: PartDefinition,
partIndex: number,
options: EvaluateCuesOptions
) {
await EvaluateCuesBase(
Expand Down Expand Up @@ -65,6 +66,7 @@ export async function EvaluateCues(
mediaSubscriptions,
cues,
partDefinition,
options
options,
partIndex
)
}
Loading
Loading