Skip to content

Commit

Permalink
feat: exclude pieces from part keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 8, 2025
1 parent 997e111 commit 74bea6c
Show file tree
Hide file tree
Showing 10 changed files with 3,322 additions and 22 deletions.
5 changes: 5 additions & 0 deletions packages/blueprints-integration/src/documents/piece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export interface IBlueprintPiece<TPrivateData = unknown, TPublicData = unknown>
* User editing definitions for this piece
*/
userEditOperations?: UserEditingDefinition[]

/**
* Whether to stop this piece before the 'keepalive' period of the part
*/
excludeDuringPartKeepalive?: boolean
}
export interface IBlueprintPieceDB<TPrivateData = unknown, TPublicData = unknown>
extends IBlueprintPiece<TPrivateData, TPublicData> {
Expand Down
43 changes: 43 additions & 0 deletions packages/corelib/src/playout/__tests__/timings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 0,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -102,6 +103,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 0,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -124,6 +126,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -146,6 +149,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 289,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -168,6 +172,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 289,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -191,6 +196,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 452,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -214,6 +220,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 452,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -238,6 +245,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 452,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -262,6 +270,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 452,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -286,6 +295,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 2256,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -310,6 +320,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 2256,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -331,6 +342,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -345,6 +357,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -365,6 +378,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -387,6 +401,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -409,6 +424,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -431,6 +447,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 823,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -453,6 +470,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 823,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -476,6 +494,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500 + 452,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -499,6 +518,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500 + 452,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -523,6 +543,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500 + 452,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -547,6 +568,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500 + 452,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -571,6 +593,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 2256,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand All @@ -595,6 +618,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 2256,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand Down Expand Up @@ -624,6 +648,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand Down Expand Up @@ -653,6 +678,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500 + 452,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand Down Expand Up @@ -682,6 +708,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500 + 452,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 452,
})
)
})
Expand Down Expand Up @@ -710,6 +737,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand Down Expand Up @@ -738,6 +766,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -764,6 +793,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 5000,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 5000,
})
)
})
Expand All @@ -790,6 +820,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -816,6 +847,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand Down Expand Up @@ -843,6 +875,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 5000,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 5000,
})
)
})
Expand All @@ -869,6 +902,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 0,
})
)
})
Expand All @@ -895,6 +929,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500,
fromPartPostroll: 231 + 0,
toPartPostroll: 0 + 0,
fromPartKeepalive: 0,
})
)
})
Expand Down Expand Up @@ -924,6 +959,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500 - 345 + 628,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 628,
})
)
})
Expand All @@ -950,6 +986,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500 - 345 + 628,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 628,
})
)
})
Expand All @@ -976,6 +1013,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 628,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 628,
})
)
})
Expand All @@ -1002,6 +1040,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 628,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 628,
})
)
})
Expand Down Expand Up @@ -1030,6 +1069,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 500 - 345 + 628,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 628,
})
)
})
Expand Down Expand Up @@ -1058,6 +1098,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 500 - 345 + 628,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 628,
})
)
})
Expand Down Expand Up @@ -1086,6 +1127,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 987,
fromPartPostroll: 0,
toPartPostroll: 0,
fromPartKeepalive: 628,
})
)
})
Expand Down Expand Up @@ -1114,6 +1156,7 @@ describe('Part Playout Timings', () => {
fromPartRemaining: 231 + 987,
fromPartPostroll: 231,
toPartPostroll: 0,
fromPartKeepalive: 628,
})
)
})
Expand Down
3 changes: 3 additions & 0 deletions packages/corelib/src/playout/timings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface PartCalculatedTimings {
toPartPostroll: number
fromPartRemaining: number // How long after the start of toPartGroup should fromPartGroup continue?
fromPartPostroll: number
fromPartKeepalive: number
}

export type CalculateTimingsPiece = Pick<Piece, 'enable' | 'prerollDuration' | 'postrollDuration' | 'pieceType'>
Expand Down Expand Up @@ -117,6 +118,7 @@ export function calculatePartTimings(
// The old part needs to continue for a while
fromPartRemaining: takeOffset + fromPartPostroll,
fromPartPostroll: fromPartPostroll,
fromPartKeepalive: 0,
}
} else {
// The amount of time needed to complete the outTransition before the 'take' point
Expand All @@ -136,6 +138,7 @@ export function calculatePartTimings(
toPartPostroll: toPartPostroll,
fromPartRemaining: takeOffset + inTransition.previousPartKeepaliveDuration + fromPartPostroll,
fromPartPostroll: fromPartPostroll,
fromPartKeepalive: inTransition.previousPartKeepaliveDuration,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/job-worker/src/blueprints/context/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const IBlueprintPieceObjectsSampleKeys = allKeysOfObject<IBlueprintPiece>
notInVision: true,
abSessions: true,
userEditOperations: true,
excludeDuringPartKeepalive: true,
})

// Compile a list of the keys which are allowed to be set
Expand Down Expand Up @@ -239,6 +240,7 @@ export function convertPieceToBlueprints(piece: ReadonlyDeep<PieceInstancePiece>
extendOnHold: piece.extendOnHold,
notInVision: piece.notInVision,
userEditOperations: translateUserEditsToBlueprint(piece.userEditOperations),
excludeDuringPartKeepalive: piece.excludeDuringPartKeepalive,
}

return obj
Expand Down
Loading

0 comments on commit 74bea6c

Please sign in to comment.