Skip to content

Commit 74bea6c

Browse files
committed
feat: exclude pieces from part keepalive
1 parent 997e111 commit 74bea6c

File tree

10 files changed

+3322
-22
lines changed

10 files changed

+3322
-22
lines changed

packages/blueprints-integration/src/documents/piece.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ export interface IBlueprintPiece<TPrivateData = unknown, TPublicData = unknown>
3535
* User editing definitions for this piece
3636
*/
3737
userEditOperations?: UserEditingDefinition[]
38+
39+
/**
40+
* Whether to stop this piece before the 'keepalive' period of the part
41+
*/
42+
excludeDuringPartKeepalive?: boolean
3843
}
3944
export interface IBlueprintPieceDB<TPrivateData = unknown, TPublicData = unknown>
4045
extends IBlueprintPiece<TPrivateData, TPublicData> {

packages/corelib/src/playout/__tests__/timings.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ describe('Part Playout Timings', () => {
8080
fromPartRemaining: 0,
8181
fromPartPostroll: 0,
8282
toPartPostroll: 0,
83+
fromPartKeepalive: 0,
8384
})
8485
)
8586
})
@@ -102,6 +103,7 @@ describe('Part Playout Timings', () => {
102103
fromPartRemaining: 0,
103104
fromPartPostroll: 0,
104105
toPartPostroll: 0,
106+
fromPartKeepalive: 0,
105107
})
106108
)
107109
})
@@ -124,6 +126,7 @@ describe('Part Playout Timings', () => {
124126
fromPartRemaining: 231,
125127
fromPartPostroll: 231,
126128
toPartPostroll: 0,
129+
fromPartKeepalive: 0,
127130
})
128131
)
129132
})
@@ -146,6 +149,7 @@ describe('Part Playout Timings', () => {
146149
fromPartRemaining: 289,
147150
fromPartPostroll: 0,
148151
toPartPostroll: 0,
152+
fromPartKeepalive: 0,
149153
})
150154
)
151155
})
@@ -168,6 +172,7 @@ describe('Part Playout Timings', () => {
168172
fromPartRemaining: 231 + 289,
169173
fromPartPostroll: 231,
170174
toPartPostroll: 0,
175+
fromPartKeepalive: 0,
171176
})
172177
)
173178
})
@@ -191,6 +196,7 @@ describe('Part Playout Timings', () => {
191196
fromPartRemaining: 452,
192197
fromPartPostroll: 0,
193198
toPartPostroll: 0,
199+
fromPartKeepalive: 452,
194200
})
195201
)
196202
})
@@ -214,6 +220,7 @@ describe('Part Playout Timings', () => {
214220
fromPartRemaining: 231 + 452,
215221
fromPartPostroll: 231,
216222
toPartPostroll: 0,
223+
fromPartKeepalive: 452,
217224
})
218225
)
219226
})
@@ -238,6 +245,7 @@ describe('Part Playout Timings', () => {
238245
fromPartRemaining: 452,
239246
fromPartPostroll: 0,
240247
toPartPostroll: 0,
248+
fromPartKeepalive: 452,
241249
})
242250
)
243251
})
@@ -262,6 +270,7 @@ describe('Part Playout Timings', () => {
262270
fromPartRemaining: 231 + 452,
263271
fromPartPostroll: 231,
264272
toPartPostroll: 0,
273+
fromPartKeepalive: 452,
265274
})
266275
)
267276
})
@@ -286,6 +295,7 @@ describe('Part Playout Timings', () => {
286295
fromPartRemaining: 2256,
287296
fromPartPostroll: 0,
288297
toPartPostroll: 0,
298+
fromPartKeepalive: 452,
289299
})
290300
)
291301
})
@@ -310,6 +320,7 @@ describe('Part Playout Timings', () => {
310320
fromPartRemaining: 231 + 2256,
311321
fromPartPostroll: 231,
312322
toPartPostroll: 0,
323+
fromPartKeepalive: 452,
313324
})
314325
)
315326
})
@@ -331,6 +342,7 @@ describe('Part Playout Timings', () => {
331342
fromPartRemaining: 500,
332343
fromPartPostroll: 0,
333344
toPartPostroll: 0,
345+
fromPartKeepalive: 0,
334346
})
335347
)
336348
})
@@ -345,6 +357,7 @@ describe('Part Playout Timings', () => {
345357
fromPartRemaining: 500,
346358
fromPartPostroll: 0,
347359
toPartPostroll: 0,
360+
fromPartKeepalive: 0,
348361
})
349362
)
350363
})
@@ -365,6 +378,7 @@ describe('Part Playout Timings', () => {
365378
fromPartRemaining: 231 + 500,
366379
fromPartPostroll: 231,
367380
toPartPostroll: 0,
381+
fromPartKeepalive: 0,
368382
})
369383
)
370384
})
@@ -387,6 +401,7 @@ describe('Part Playout Timings', () => {
387401
fromPartRemaining: 500,
388402
fromPartPostroll: 0,
389403
toPartPostroll: 0,
404+
fromPartKeepalive: 0,
390405
})
391406
)
392407
})
@@ -409,6 +424,7 @@ describe('Part Playout Timings', () => {
409424
fromPartRemaining: 231 + 500,
410425
fromPartPostroll: 231,
411426
toPartPostroll: 0,
427+
fromPartKeepalive: 0,
412428
})
413429
)
414430
})
@@ -431,6 +447,7 @@ describe('Part Playout Timings', () => {
431447
fromPartRemaining: 823,
432448
fromPartPostroll: 0,
433449
toPartPostroll: 0,
450+
fromPartKeepalive: 0,
434451
})
435452
)
436453
})
@@ -453,6 +470,7 @@ describe('Part Playout Timings', () => {
453470
fromPartRemaining: 231 + 823,
454471
fromPartPostroll: 231,
455472
toPartPostroll: 0,
473+
fromPartKeepalive: 0,
456474
})
457475
)
458476
})
@@ -476,6 +494,7 @@ describe('Part Playout Timings', () => {
476494
fromPartRemaining: 500 + 452,
477495
fromPartPostroll: 0,
478496
toPartPostroll: 0,
497+
fromPartKeepalive: 452,
479498
})
480499
)
481500
})
@@ -499,6 +518,7 @@ describe('Part Playout Timings', () => {
499518
fromPartRemaining: 231 + 500 + 452,
500519
fromPartPostroll: 231,
501520
toPartPostroll: 0,
521+
fromPartKeepalive: 452,
502522
})
503523
)
504524
})
@@ -523,6 +543,7 @@ describe('Part Playout Timings', () => {
523543
fromPartRemaining: 500 + 452,
524544
fromPartPostroll: 0,
525545
toPartPostroll: 0,
546+
fromPartKeepalive: 452,
526547
})
527548
)
528549
})
@@ -547,6 +568,7 @@ describe('Part Playout Timings', () => {
547568
fromPartRemaining: 231 + 500 + 452,
548569
fromPartPostroll: 231,
549570
toPartPostroll: 0,
571+
fromPartKeepalive: 452,
550572
})
551573
)
552574
})
@@ -571,6 +593,7 @@ describe('Part Playout Timings', () => {
571593
fromPartRemaining: 2256,
572594
fromPartPostroll: 0,
573595
toPartPostroll: 0,
596+
fromPartKeepalive: 452,
574597
})
575598
)
576599
})
@@ -595,6 +618,7 @@ describe('Part Playout Timings', () => {
595618
fromPartRemaining: 231 + 2256,
596619
fromPartPostroll: 231,
597620
toPartPostroll: 0,
621+
fromPartKeepalive: 452,
598622
})
599623
)
600624
})
@@ -624,6 +648,7 @@ describe('Part Playout Timings', () => {
624648
fromPartRemaining: 500,
625649
fromPartPostroll: 0,
626650
toPartPostroll: 0,
651+
fromPartKeepalive: 0,
627652
})
628653
)
629654
})
@@ -653,6 +678,7 @@ describe('Part Playout Timings', () => {
653678
fromPartRemaining: 500 + 452,
654679
fromPartPostroll: 0,
655680
toPartPostroll: 0,
681+
fromPartKeepalive: 452,
656682
})
657683
)
658684
})
@@ -682,6 +708,7 @@ describe('Part Playout Timings', () => {
682708
fromPartRemaining: 231 + 500 + 452,
683709
fromPartPostroll: 231,
684710
toPartPostroll: 0,
711+
fromPartKeepalive: 452,
685712
})
686713
)
687714
})
@@ -710,6 +737,7 @@ describe('Part Playout Timings', () => {
710737
fromPartRemaining: 500,
711738
fromPartPostroll: 0,
712739
toPartPostroll: 0,
740+
fromPartKeepalive: 0,
713741
})
714742
)
715743
})
@@ -738,6 +766,7 @@ describe('Part Playout Timings', () => {
738766
fromPartRemaining: 231 + 500,
739767
fromPartPostroll: 231,
740768
toPartPostroll: 0,
769+
fromPartKeepalive: 0,
741770
})
742771
)
743772
})
@@ -764,6 +793,7 @@ describe('Part Playout Timings', () => {
764793
fromPartRemaining: 5000,
765794
fromPartPostroll: 0,
766795
toPartPostroll: 0,
796+
fromPartKeepalive: 5000,
767797
})
768798
)
769799
})
@@ -790,6 +820,7 @@ describe('Part Playout Timings', () => {
790820
fromPartRemaining: 500,
791821
fromPartPostroll: 0,
792822
toPartPostroll: 0,
823+
fromPartKeepalive: 0,
793824
})
794825
)
795826
})
@@ -816,6 +847,7 @@ describe('Part Playout Timings', () => {
816847
fromPartRemaining: 500,
817848
fromPartPostroll: 0,
818849
toPartPostroll: 0,
850+
fromPartKeepalive: 0,
819851
})
820852
)
821853
})
@@ -843,6 +875,7 @@ describe('Part Playout Timings', () => {
843875
fromPartRemaining: 231 + 5000,
844876
fromPartPostroll: 231,
845877
toPartPostroll: 0,
878+
fromPartKeepalive: 5000,
846879
})
847880
)
848881
})
@@ -869,6 +902,7 @@ describe('Part Playout Timings', () => {
869902
fromPartRemaining: 231 + 500,
870903
fromPartPostroll: 231,
871904
toPartPostroll: 0,
905+
fromPartKeepalive: 0,
872906
})
873907
)
874908
})
@@ -895,6 +929,7 @@ describe('Part Playout Timings', () => {
895929
fromPartRemaining: 231 + 500,
896930
fromPartPostroll: 231 + 0,
897931
toPartPostroll: 0 + 0,
932+
fromPartKeepalive: 0,
898933
})
899934
)
900935
})
@@ -924,6 +959,7 @@ describe('Part Playout Timings', () => {
924959
fromPartRemaining: 500 - 345 + 628,
925960
fromPartPostroll: 0,
926961
toPartPostroll: 0,
962+
fromPartKeepalive: 628,
927963
})
928964
)
929965
})
@@ -950,6 +986,7 @@ describe('Part Playout Timings', () => {
950986
fromPartRemaining: 231 + 500 - 345 + 628,
951987
fromPartPostroll: 231,
952988
toPartPostroll: 0,
989+
fromPartKeepalive: 628,
953990
})
954991
)
955992
})
@@ -976,6 +1013,7 @@ describe('Part Playout Timings', () => {
9761013
fromPartRemaining: 628,
9771014
fromPartPostroll: 0,
9781015
toPartPostroll: 0,
1016+
fromPartKeepalive: 628,
9791017
})
9801018
)
9811019
})
@@ -1002,6 +1040,7 @@ describe('Part Playout Timings', () => {
10021040
fromPartRemaining: 231 + 628,
10031041
fromPartPostroll: 231,
10041042
toPartPostroll: 0,
1043+
fromPartKeepalive: 628,
10051044
})
10061045
)
10071046
})
@@ -1030,6 +1069,7 @@ describe('Part Playout Timings', () => {
10301069
fromPartRemaining: 500 - 345 + 628,
10311070
fromPartPostroll: 0,
10321071
toPartPostroll: 0,
1072+
fromPartKeepalive: 628,
10331073
})
10341074
)
10351075
})
@@ -1058,6 +1098,7 @@ describe('Part Playout Timings', () => {
10581098
fromPartRemaining: 231 + 500 - 345 + 628,
10591099
fromPartPostroll: 231,
10601100
toPartPostroll: 0,
1101+
fromPartKeepalive: 628,
10611102
})
10621103
)
10631104
})
@@ -1086,6 +1127,7 @@ describe('Part Playout Timings', () => {
10861127
fromPartRemaining: 987,
10871128
fromPartPostroll: 0,
10881129
toPartPostroll: 0,
1130+
fromPartKeepalive: 628,
10891131
})
10901132
)
10911133
})
@@ -1114,6 +1156,7 @@ describe('Part Playout Timings', () => {
11141156
fromPartRemaining: 231 + 987,
11151157
fromPartPostroll: 231,
11161158
toPartPostroll: 0,
1159+
fromPartKeepalive: 628,
11171160
})
11181161
)
11191162
})

packages/corelib/src/playout/timings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface PartCalculatedTimings {
5858
toPartPostroll: number
5959
fromPartRemaining: number // How long after the start of toPartGroup should fromPartGroup continue?
6060
fromPartPostroll: number
61+
fromPartKeepalive: number
6162
}
6263

6364
export type CalculateTimingsPiece = Pick<Piece, 'enable' | 'prerollDuration' | 'postrollDuration' | 'pieceType'>
@@ -117,6 +118,7 @@ export function calculatePartTimings(
117118
// The old part needs to continue for a while
118119
fromPartRemaining: takeOffset + fromPartPostroll,
119120
fromPartPostroll: fromPartPostroll,
121+
fromPartKeepalive: 0,
120122
}
121123
} else {
122124
// The amount of time needed to complete the outTransition before the 'take' point
@@ -136,6 +138,7 @@ export function calculatePartTimings(
136138
toPartPostroll: toPartPostroll,
137139
fromPartRemaining: takeOffset + inTransition.previousPartKeepaliveDuration + fromPartPostroll,
138140
fromPartPostroll: fromPartPostroll,
141+
fromPartKeepalive: inTransition.previousPartKeepaliveDuration,
139142
}
140143
}
141144
}

packages/job-worker/src/blueprints/context/lib.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export const IBlueprintPieceObjectsSampleKeys = allKeysOfObject<IBlueprintPiece>
9797
notInVision: true,
9898
abSessions: true,
9999
userEditOperations: true,
100+
excludeDuringPartKeepalive: true,
100101
})
101102

102103
// Compile a list of the keys which are allowed to be set
@@ -239,6 +240,7 @@ export function convertPieceToBlueprints(piece: ReadonlyDeep<PieceInstancePiece>
239240
extendOnHold: piece.extendOnHold,
240241
notInVision: piece.notInVision,
241242
userEditOperations: translateUserEditsToBlueprint(piece.userEditOperations),
243+
excludeDuringPartKeepalive: piece.excludeDuringPartKeepalive,
242244
}
243245

244246
return obj

0 commit comments

Comments
 (0)