Skip to content

Commit 0559563

Browse files
authored
Merge pull request Sofie-Automation#1163 from nrkno/fix/piece-dependent-diff
fix(Client): Piece-dependency for expectedDuration calculation causes the Diff to be inconsistent (SOFIE-3004)
2 parents edf9fed + c862582 commit 0559563

27 files changed

+45
-321
lines changed

meteor/client/lib/__tests__/rundown.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ describe('client/lib/rundown', () => {
5353
[],
5454
new Map(),
5555
parts.map((part) => part._id),
56-
new Map(),
5756
currentPartInstance,
5857
nextPartInstance
5958
)
@@ -115,7 +114,6 @@ describe('client/lib/rundown', () => {
115114
[],
116115
new Map(),
117116
parts.map((part) => part._id),
118-
new Map(),
119117
currentPartInstance,
120118
nextPartInstance
121119
)
@@ -201,7 +199,6 @@ describe('client/lib/rundown', () => {
201199
[],
202200
new Map(),
203201
parts.map((part) => part._id),
204-
new Map(),
205202
currentPartInstance,
206203
nextPartInstance
207204
)
@@ -364,7 +361,6 @@ describe('client/lib/rundown', () => {
364361
[],
365362
new Map(),
366363
parts.map((part) => part._id),
367-
new Map(),
368364
currentPartInstance,
369365
nextPartInstance
370366
)

meteor/client/lib/__tests__/rundownTiming.test.ts

Lines changed: 1 addition & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { DBSegment } from '../../../lib/collections/Segments'
55
import { DBRundown } from '../../../lib/collections/Rundowns'
66
import { literal, protectString } from '../../../lib/lib'
77
import { RundownTimingCalculator, RundownTimingContext } from '../rundownTiming'
8-
import { IBlueprintPieceType, PlaylistTimingType } from '@sofie-automation/blueprints-integration'
8+
import { PlaylistTimingType } from '@sofie-automation/blueprints-integration'
99
import { PartId, RundownId, SegmentId } from '@sofie-automation/corelib/dist/dataModel/Ids'
10-
import { CalculateTimingsPiece } from '@sofie-automation/corelib/dist/playout/timings'
1110

1211
const DEFAULT_DURATION = 0
1312
const DEFAULT_NONZERO_DURATION = 4000
@@ -112,7 +111,6 @@ describe('rundown Timing Calculator', () => {
112111
undefined,
113112
parts,
114113
partInstancesMap,
115-
new Map(),
116114
segmentsMap,
117115
DEFAULT_DURATION,
118116
[]
@@ -175,7 +173,6 @@ describe('rundown Timing Calculator', () => {
175173
undefined,
176174
parts,
177175
partInstancesMap,
178-
new Map(),
179176
segmentsMap,
180177
DEFAULT_DURATION,
181178
[]
@@ -277,7 +274,6 @@ describe('rundown Timing Calculator', () => {
277274
undefined,
278275
parts,
279276
partInstancesMap,
280-
new Map(),
281277
segmentsMap,
282278
DEFAULT_DURATION,
283279
[]
@@ -381,7 +377,6 @@ describe('rundown Timing Calculator', () => {
381377
undefined,
382378
parts,
383379
partInstancesMap,
384-
new Map(),
385380
segmentsMap,
386381
DEFAULT_DURATION,
387382
[]
@@ -509,7 +504,6 @@ describe('rundown Timing Calculator', () => {
509504
undefined,
510505
parts,
511506
partInstancesMap,
512-
new Map(),
513507
segmentsMap,
514508
DEFAULT_DURATION,
515509
[]
@@ -612,7 +606,6 @@ describe('rundown Timing Calculator', () => {
612606
undefined,
613607
parts,
614608
partInstancesMap,
615-
new Map(),
616609
segmentsMap,
617610
DEFAULT_NONZERO_DURATION,
618611
[]
@@ -743,7 +736,6 @@ describe('rundown Timing Calculator', () => {
743736
undefined,
744737
parts,
745738
partInstancesMap,
746-
new Map(),
747739
segmentsMap,
748740
DEFAULT_NONZERO_DURATION,
749741
[]
@@ -868,7 +860,6 @@ describe('rundown Timing Calculator', () => {
868860
undefined,
869861
parts,
870862
partInstancesMap,
871-
new Map(),
872863
segmentsMap,
873864
DEFAULT_DURATION,
874865
[]
@@ -943,127 +934,6 @@ describe('rundown Timing Calculator', () => {
943934
)
944935
})
945936

946-
it('Adds Piece preroll to Part durations', () => {
947-
const timing = new RundownTimingCalculator()
948-
const playlist: RundownPlaylist = makeMockPlaylist()
949-
playlist.timing = {
950-
type: 'forward-time' as any,
951-
expectedStart: 0,
952-
expectedDuration: 40000,
953-
}
954-
const rundownId = 'rundown1'
955-
const segmentId1 = 'segment1'
956-
const segmentId2 = 'segment2'
957-
const segmentsMap: Map<SegmentId, DBSegment> = new Map()
958-
segmentsMap.set(protectString<SegmentId>(segmentId1), makeMockSegment(segmentId1, 0, rundownId))
959-
segmentsMap.set(protectString<SegmentId>(segmentId2), makeMockSegment(segmentId2, 0, rundownId))
960-
const parts: Part[] = []
961-
parts.push(makeMockPart('part1', 0, rundownId, segmentId1, { expectedDuration: 1000 }))
962-
parts.push(makeMockPart('part2', 0, rundownId, segmentId1, { expectedDuration: 1000 }))
963-
parts.push(makeMockPart('part3', 0, rundownId, segmentId2, { expectedDuration: 1000 }))
964-
parts.push(makeMockPart('part4', 0, rundownId, segmentId2, { expectedDuration: 1000 }))
965-
const piecesMap: Map<PartId, CalculateTimingsPiece[]> = new Map()
966-
piecesMap.set(protectString('part1'), [
967-
literal<CalculateTimingsPiece>({
968-
enable: {
969-
start: 0,
970-
},
971-
prerollDuration: 5000,
972-
pieceType: IBlueprintPieceType.Normal,
973-
}),
974-
])
975-
piecesMap.set(protectString('part2'), [
976-
literal<CalculateTimingsPiece>({
977-
enable: {
978-
start: 0,
979-
},
980-
prerollDuration: 240,
981-
pieceType: IBlueprintPieceType.Normal,
982-
}),
983-
])
984-
const partInstancesMap: Map<PartId, PartInstance> = new Map()
985-
const rundown = makeMockRundown(rundownId, playlist)
986-
const rundowns = [rundown]
987-
const result = timing.updateDurations(
988-
0,
989-
false,
990-
playlist,
991-
rundowns,
992-
undefined,
993-
parts,
994-
partInstancesMap,
995-
piecesMap,
996-
segmentsMap,
997-
DEFAULT_DURATION,
998-
[]
999-
)
1000-
expect(result).toEqual(
1001-
literal<RundownTimingContext>({
1002-
isLowResolution: false,
1003-
asDisplayedPlaylistDuration: 9240,
1004-
asPlayedPlaylistDuration: 9240,
1005-
currentPartInstanceId: null,
1006-
currentPartWillAutoNext: false,
1007-
currentTime: 0,
1008-
rundownExpectedDurations: {
1009-
[rundownId]: 9240,
1010-
},
1011-
rundownAsPlayedDurations: {
1012-
[rundownId]: 9240,
1013-
},
1014-
partCountdown: {
1015-
part1: 0,
1016-
part2: 6000,
1017-
part3: 7240,
1018-
part4: 8240,
1019-
},
1020-
partDisplayDurations: {
1021-
part1: 6000,
1022-
part2: 1240,
1023-
part3: 1000,
1024-
part4: 1000,
1025-
},
1026-
partDisplayStartsAt: {
1027-
part1: 0,
1028-
part2: 6000,
1029-
part3: 7240,
1030-
part4: 8240,
1031-
},
1032-
partDurations: {
1033-
part1: 6000,
1034-
part2: 1240,
1035-
part3: 1000,
1036-
part4: 1000,
1037-
},
1038-
partExpectedDurations: {
1039-
part1: 6000,
1040-
part2: 1240,
1041-
part3: 1000,
1042-
part4: 1000,
1043-
},
1044-
partPlayed: {
1045-
part1: 0,
1046-
part2: 0,
1047-
part3: 0,
1048-
part4: 0,
1049-
},
1050-
partStartsAt: {
1051-
part1: 0,
1052-
part2: 6000,
1053-
part3: 7240,
1054-
part4: 8240,
1055-
},
1056-
remainingPlaylistDuration: 9240,
1057-
totalPlaylistDuration: 9240,
1058-
breakIsLastRundown: undefined,
1059-
remainingTimeOnCurrentPart: undefined,
1060-
rundownsBeforeNextBreak: undefined,
1061-
segmentBudgetDurations: {},
1062-
segmentStartedPlayback: {},
1063-
})
1064-
)
1065-
})
1066-
1067937
it('Back-time: Can find the next expectedStart rundown anchor when it is in a future segment', () => {
1068938
const timing = new RundownTimingCalculator()
1069939
const playlist: RundownPlaylist = makeMockPlaylist()
@@ -1140,7 +1010,6 @@ describe('rundown Timing Calculator', () => {
11401010
rundown,
11411011
parts,
11421012
partInstancesMap,
1143-
new Map(),
11441013
segmentsMap,
11451014
DEFAULT_DURATION,
11461015
[]
@@ -1289,7 +1158,6 @@ describe('rundown Timing Calculator', () => {
12891158
rundown,
12901159
parts,
12911160
partInstancesMap,
1292-
new Map(),
12931161
segmentsMap,
12941162
DEFAULT_DURATION,
12951163
[]
@@ -1444,7 +1312,6 @@ describe('rundown Timing Calculator', () => {
14441312
rundown,
14451313
parts,
14461314
partInstancesMap,
1447-
new Map(),
14481315
segmentsMap,
14491316
DEFAULT_DURATION,
14501317
[]
@@ -1593,7 +1460,6 @@ describe('rundown Timing Calculator', () => {
15931460
rundown,
15941461
parts,
15951462
partInstancesMap,
1596-
new Map(),
15971463
segmentsMap,
15981464
DEFAULT_DURATION,
15991465
[]
@@ -1742,7 +1608,6 @@ describe('rundown Timing Calculator', () => {
17421608
rundown,
17431609
parts,
17441610
partInstancesMap,
1745-
new Map(),
17461611
segmentsMap,
17471612
DEFAULT_DURATION,
17481613
[]
@@ -1897,7 +1762,6 @@ describe('rundown Timing Calculator', () => {
18971762
rundown,
18981763
parts,
18991764
partInstancesMap,
1900-
new Map(),
19011765
segmentsMap,
19021766
DEFAULT_DURATION,
19031767
[]

meteor/client/lib/rundown.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ import { FindOptions } from '../../lib/collections/lib'
3636
import { getShowHiddenSourceLayers } from './localStorage'
3737
import { Rundown } from '../../lib/collections/Rundowns'
3838
import { IStudioSettings } from '@sofie-automation/corelib/dist/dataModel/Studio'
39-
import {
40-
calculatePartInstanceExpectedDurationWithPreroll,
41-
CalculateTimingsPiece,
42-
} from '@sofie-automation/corelib/dist/playout/timings'
39+
import { calculatePartInstanceExpectedDurationWithPreroll } from '@sofie-automation/corelib/dist/playout/timings'
4340
import { AdLibPieceUi } from './shelf'
4441
import { UIShowStyleBase } from '../../lib/api/showStyles'
4542
import { PartId, PieceId, RundownId, SegmentId, ShowStyleBaseId } from '@sofie-automation/corelib/dist/dataModel/Ids'
@@ -59,17 +56,14 @@ export namespace RundownUtils {
5956

6057
export function getSegmentDuration(
6158
parts: Array<PartUi>,
62-
pieces: Map<PartId, CalculateTimingsPiece[]>,
59+
// pieces: Map<PartId, CalculateTimingsPiece[]>,
6360
display?: boolean
6461
): number {
6562
return parts.reduce((memo, part) => {
6663
return (
6764
memo +
6865
(part.instance.timings?.duration ||
69-
calculatePartInstanceExpectedDurationWithPreroll(
70-
part.instance,
71-
pieces.get(part.instance.part._id) ?? []
72-
) ||
66+
calculatePartInstanceExpectedDurationWithPreroll(part.instance) ||
7367
part.renderedDuration ||
7468
(display ? Settings.defaultDisplayDuration : 0))
7569
)
@@ -205,7 +199,6 @@ export namespace RundownUtils {
205199
scrollLeft: number,
206200
scrollWidth: number,
207201
part: PartUi,
208-
pieces: CalculateTimingsPiece[],
209202
partStartsAt: number | undefined,
210203
partDuration: number | undefined,
211204
piece?: PieceUi
@@ -225,7 +218,7 @@ export namespace RundownUtils {
225218
? part.instance.timings.duration + (part.instance.timings?.playOffset || 0)
226219
: (partDuration ||
227220
part.renderedDuration ||
228-
calculatePartInstanceExpectedDurationWithPreroll(part.instance, pieces) ||
221+
calculatePartInstanceExpectedDurationWithPreroll(part.instance) ||
229222
0) - (piece.renderedInPoint || 0)))
230223
: part.instance.timings?.duration !== undefined
231224
? part.instance.timings.duration + (part.instance.timings?.playOffset || 0)
@@ -299,7 +292,6 @@ export namespace RundownUtils {
299292
rundownsBeforeThisInPlaylist: RundownId[],
300293
rundownsToShowstyles: Map<RundownId, ShowStyleBaseId>,
301294
orderedAllPartIds: PartId[],
302-
pieces: Map<PartId, CalculateTimingsPiece[]>,
303295
currentPartInstance: PartInstance | undefined,
304296
nextPartInstance: PartInstance | undefined,
305297
pieceInstanceSimulation = false,
@@ -430,10 +422,7 @@ export namespace RundownUtils {
430422
partsE = segmentInfo.partInstances.map((partInstance, itIndex) => {
431423
const partTimeline: SuperTimeline.TimelineObject[] = []
432424

433-
const partExpectedDuration = calculatePartInstanceExpectedDurationWithPreroll(
434-
partInstance,
435-
pieces.get(partInstance.part._id) ?? []
436-
)
425+
const partExpectedDuration = calculatePartInstanceExpectedDurationWithPreroll(partInstance)
437426

438427
// extend objects to match the Extended interface
439428
const partE = literal<PartExtended>({

0 commit comments

Comments
 (0)