Skip to content

Commit c336948

Browse files
committed
wip: global piece prepare time
1 parent 2fbbef5 commit c336948

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

packages/job-worker/src/playout/timeline/rundown.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@ import _ = require('underscore')
2828
import { getPieceEnableInsidePart, transformPieceGroupAndObjects } from './piece'
2929
import { logger } from '../../logging'
3030

31+
const DEFAULT_ABSOLUTE_PIECE_PREPARE_TIME = 30000
32+
3133
/**
3234
* Some additional data used by the timeline generation process
3335
* Fields are populated as it progresses through generation, and consumed during the finalisation
3436
*/
3537
export interface RundownTimelineTimingContext {
38+
/**
39+
* How long an absolute timed piece should be on the timeline before it is played
40+
* This is a constant derived from the settings
41+
*/
42+
readonly absolutePiecePrepareTime: number
43+
3644
currentPartGroup: TimelineObjGroupPart
3745
currentPartDuration: number | undefined
3846

@@ -140,10 +148,10 @@ export function buildTimelineObjsForRundown(
140148
const currentPartGroup = createPartGroup(partInstancesInfo.current.partInstance, currentPartEnable)
141149

142150
const timingContext: RundownTimelineTimingContext = {
151+
absolutePiecePrepareTime:
152+
context.studio.settings.rundownGlobalPiecesPrepareTime || DEFAULT_ABSOLUTE_PIECE_PREPARE_TIME,
143153
currentPartGroup,
144154
currentPartDuration: currentPartEnable.duration,
145-
146-
// regenerateTimelineAt: For future use
147155
}
148156

149157
// Start generating objects
@@ -280,19 +288,21 @@ function generateCurrentInfinitePieceObjects(
280288
return []
281289
}
282290

283-
const { pieceEnable, infiniteGroupEnable, nowInParent } = calculateInfinitePieceEnable(
291+
const pieceEnable = calculateInfinitePieceEnable(
284292
currentPartInfo,
285293
timingContext,
286294
pieceInstance,
287295
currentTime,
288296
currentPartInstanceTimings
289297
)
298+
// Not allowed to be generated
299+
if (!pieceEnable) return []
290300

291301
const { pieceInstanceWithUpdatedEndCap, cappedInfiniteGroupEnable } = applyInfinitePieceGroupEndCap(
292302
currentPartInfo,
293303
timingContext,
294304
pieceInstance,
295-
infiniteGroupEnable,
305+
pieceEnable.infiniteGroupEnable,
296306
currentPartInstanceTimings,
297307
nextPartInstanceTimings,
298308
nextPartInfinites.get(pieceInstance.infinite.infiniteInstanceId)
@@ -317,9 +327,9 @@ function generateCurrentInfinitePieceObjects(
317327
...transformPieceGroupAndObjects(
318328
activePlaylist._id,
319329
infiniteGroup,
320-
nowInParent,
330+
pieceEnable.nowInParent,
321331
pieceInstanceWithUpdatedEndCap,
322-
pieceEnable,
332+
pieceEnable.pieceEnable,
323333
0,
324334
groupClasses,
325335
isInHold,
@@ -355,6 +365,15 @@ function calculateInfinitePieceEnable(
355365
const infiniteGroupStart = pieceInstance.plannedStartedPlayback ?? pieceInstance.piece.enable.start
356366

357367
if (typeof infiniteGroupStart === 'number') {
368+
if (infiniteGroupStart > currentTime + timingContext.absolutePiecePrepareTime) {
369+
// This piece is starting too far in the future, omit it from the timeline
370+
timingContext.regenerateTimelineAt = Math.min(
371+
timingContext.regenerateTimelineAt ?? Number.POSITIVE_INFINITY,
372+
infiniteGroupStart - timingContext.absolutePiecePrepareTime
373+
)
374+
return null
375+
}
376+
358377
nowInParent = currentTime - infiniteGroupStart
359378
} else {
360379
// We should never hit this, but in case start is "now"

packages/shared-lib/src/core/model/StudioSettings.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,9 @@ export interface IStudioSettings {
9191
* Doubleclick changes behaviour as selector for userediting
9292
*/
9393
enableUserEdits?: boolean
94+
95+
/**
96+
* How long before their start time a rundown owned piece be added to the timeline
97+
*/
98+
rundownGlobalPiecesPrepareTime?: number
9499
}

packages/webui/src/client/ui/Settings/Studio/Generic.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,23 @@ function StudioSettings({ studio }: { studio: DBStudio }): JSX.Element {
461461
>
462462
{(value, handleUpdate) => <CheckboxControl value={!!value} handleUpdate={handleUpdate} />}
463463
</LabelAndOverridesForCheckbox>
464+
465+
<LabelAndOverridesForInt
466+
label={t('Rundown Global Piece Prepare Time')}
467+
item={wrappedItem}
468+
itemKey={'rundownGlobalPiecesPrepareTime'}
469+
overrideHelper={overrideHelper}
470+
hint={t('How much preparation time to add to global pieces on the timeline before they are played')}
471+
>
472+
{(value, handleUpdate) => (
473+
<IntInputControl
474+
modifiedClassName="bghl"
475+
classNames="input text-input input-l"
476+
value={value}
477+
handleUpdate={handleUpdate}
478+
/>
479+
)}
480+
</LabelAndOverridesForInt>
464481
</>
465482
)
466483
}

0 commit comments

Comments
 (0)