Skip to content

Commit 64edef7

Browse files
committed
fix: multigateway mode
1 parent 0872b5a commit 64edef7

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

packages/job-worker/src/playout/timeline/multi-gateway.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,24 @@ function setPlannedTimingsOnPieceInstance(
262262
}
263263

264264
if (typeof pieceInstance.pieceInstance.piece.enable.start === 'number') {
265-
const plannedStart = partPlannedStart + pieceInstance.pieceInstance.piece.enable.start
265+
const plannedStart =
266+
(pieceInstance.pieceInstance.piece.enable.isAbsolute ? 0 : partPlannedStart) +
267+
pieceInstance.pieceInstance.piece.enable.start
266268
pieceInstance.setPlannedStartedPlayback(plannedStart)
267269

268270
const userDurationEnd =
269271
pieceInstance.pieceInstance.userDuration && 'endRelativeToPart' in pieceInstance.pieceInstance.userDuration
270272
? pieceInstance.pieceInstance.userDuration.endRelativeToPart
271273
: null
272-
const plannedEnd =
273-
userDurationEnd ??
274-
(pieceInstance.pieceInstance.piece.enable.duration
275-
? plannedStart + pieceInstance.pieceInstance.piece.enable.duration
276-
: partPlannedEnd)
274+
275+
let plannedEnd: number | undefined = userDurationEnd ?? undefined
276+
if (plannedEnd === undefined) {
277+
if (pieceInstance.pieceInstance.piece.enable.duration !== undefined) {
278+
plannedEnd = plannedStart + pieceInstance.pieceInstance.piece.enable.duration
279+
} else if (!pieceInstance.pieceInstance.piece.enable.isAbsolute) {
280+
plannedEnd = partPlannedEnd
281+
}
282+
}
277283

278284
pieceInstance.setPlannedStoppedPlayback(plannedEnd)
279285
}

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

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,34 @@ function calculateInfinitePieceEnable(
342342
}
343343

344344
let nowInParent = currentPartInfo.partTimes.nowInPart // Where is 'now' inside of the infiniteGroup?
345-
if (pieceInstance.plannedStartedPlayback !== undefined) {
345+
if (pieceInstance.piece.enable.isAbsolute) {
346+
// Piece is absolute, so we should use the absolute time. This is a special case for pieces belonging to the rundown directly.
347+
348+
const infiniteGroupStart = pieceInstance.plannedStartedPlayback ?? pieceInstance.piece.enable.start
349+
350+
if (typeof infiniteGroupStart === 'number') {
351+
nowInParent = currentTime - infiniteGroupStart
352+
} else {
353+
// We should never hit this, but in case start is "now"
354+
nowInParent = 0
355+
}
356+
357+
infiniteGroupEnable = { start: infiniteGroupStart }
358+
pieceEnable.start = 0
359+
360+
// nocommit prerollDuration?
361+
362+
// // If an end time has been set by a hotkey, then update the duration to be correct
363+
// if (pieceInstance.userDuration && pieceInstance.piece.enable.start !== 'now') {
364+
// if ('endRelativeToNow' in pieceInstance.userDuration) {
365+
// infiniteGroupEnable.duration =
366+
// pieceInstance.userDuration.endRelativeToNow - pieceInstance.piece.enable.start
367+
// } else {
368+
// // This should never be hit
369+
// infiniteGroupEnable.end = 'now'
370+
// }
371+
// }
372+
} else if (pieceInstance.plannedStartedPlayback !== undefined) {
346373
// We have a absolute start time, so we should use that.
347374
let infiniteGroupStart = pieceInstance.plannedStartedPlayback
348375
nowInParent = currentTime - pieceInstance.plannedStartedPlayback
@@ -370,31 +397,6 @@ function calculateInfinitePieceEnable(
370397
infiniteGroupEnable.end = 'now'
371398
}
372399
}
373-
} else if (pieceInstance.piece.enable.isAbsolute) {
374-
// Piece is absolute, so we should use the absolute time. This is a special case for pieces belonging to the rundown directly.
375-
376-
if (typeof pieceInstance.piece.enable.start === 'number') {
377-
nowInParent = currentTime - pieceInstance.piece.enable.start
378-
} else {
379-
// We should never hit this, but in case start is "now"
380-
nowInParent = 0
381-
}
382-
383-
infiniteGroupEnable = { start: pieceInstance.piece.enable.start }
384-
pieceEnable.start = 0
385-
386-
// nocommit prerollDuration?
387-
388-
// // If an end time has been set by a hotkey, then update the duration to be correct
389-
// if (pieceInstance.userDuration && pieceInstance.piece.enable.start !== 'now') {
390-
// if ('endRelativeToNow' in pieceInstance.userDuration) {
391-
// infiniteGroupEnable.duration =
392-
// pieceInstance.userDuration.endRelativeToNow - pieceInstance.piece.enable.start
393-
// } else {
394-
// // This should never be hit
395-
// infiniteGroupEnable.end = 'now'
396-
// }
397-
// }
398400
}
399401

400402
return {

0 commit comments

Comments
 (0)