Skip to content

Commit

Permalink
Merge pull request #1163 from nrkno/fix/piece-dependent-diff
Browse files Browse the repository at this point in the history
fix(Client): Piece-dependency for expectedDuration calculation causes the Diff to be inconsistent (SOFIE-3004)
  • Loading branch information
jstarpl authored Mar 5, 2024
2 parents edf9fed + c862582 commit 0559563
Show file tree
Hide file tree
Showing 27 changed files with 45 additions and 321 deletions.
4 changes: 0 additions & 4 deletions meteor/client/lib/__tests__/rundown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('client/lib/rundown', () => {
[],
new Map(),
parts.map((part) => part._id),
new Map(),
currentPartInstance,
nextPartInstance
)
Expand Down Expand Up @@ -115,7 +114,6 @@ describe('client/lib/rundown', () => {
[],
new Map(),
parts.map((part) => part._id),
new Map(),
currentPartInstance,
nextPartInstance
)
Expand Down Expand Up @@ -201,7 +199,6 @@ describe('client/lib/rundown', () => {
[],
new Map(),
parts.map((part) => part._id),
new Map(),
currentPartInstance,
nextPartInstance
)
Expand Down Expand Up @@ -364,7 +361,6 @@ describe('client/lib/rundown', () => {
[],
new Map(),
parts.map((part) => part._id),
new Map(),
currentPartInstance,
nextPartInstance
)
Expand Down
138 changes: 1 addition & 137 deletions meteor/client/lib/__tests__/rundownTiming.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { DBSegment } from '../../../lib/collections/Segments'
import { DBRundown } from '../../../lib/collections/Rundowns'
import { literal, protectString } from '../../../lib/lib'
import { RundownTimingCalculator, RundownTimingContext } from '../rundownTiming'
import { IBlueprintPieceType, PlaylistTimingType } from '@sofie-automation/blueprints-integration'
import { PlaylistTimingType } from '@sofie-automation/blueprints-integration'
import { PartId, RundownId, SegmentId } from '@sofie-automation/corelib/dist/dataModel/Ids'
import { CalculateTimingsPiece } from '@sofie-automation/corelib/dist/playout/timings'

const DEFAULT_DURATION = 0
const DEFAULT_NONZERO_DURATION = 4000
Expand Down Expand Up @@ -112,7 +111,6 @@ describe('rundown Timing Calculator', () => {
undefined,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -175,7 +173,6 @@ describe('rundown Timing Calculator', () => {
undefined,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -277,7 +274,6 @@ describe('rundown Timing Calculator', () => {
undefined,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -381,7 +377,6 @@ describe('rundown Timing Calculator', () => {
undefined,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -509,7 +504,6 @@ describe('rundown Timing Calculator', () => {
undefined,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -612,7 +606,6 @@ describe('rundown Timing Calculator', () => {
undefined,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_NONZERO_DURATION,
[]
Expand Down Expand Up @@ -743,7 +736,6 @@ describe('rundown Timing Calculator', () => {
undefined,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_NONZERO_DURATION,
[]
Expand Down Expand Up @@ -868,7 +860,6 @@ describe('rundown Timing Calculator', () => {
undefined,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -943,127 +934,6 @@ describe('rundown Timing Calculator', () => {
)
})

it('Adds Piece preroll to Part durations', () => {
const timing = new RundownTimingCalculator()
const playlist: RundownPlaylist = makeMockPlaylist()
playlist.timing = {
type: 'forward-time' as any,
expectedStart: 0,
expectedDuration: 40000,
}
const rundownId = 'rundown1'
const segmentId1 = 'segment1'
const segmentId2 = 'segment2'
const segmentsMap: Map<SegmentId, DBSegment> = new Map()
segmentsMap.set(protectString<SegmentId>(segmentId1), makeMockSegment(segmentId1, 0, rundownId))
segmentsMap.set(protectString<SegmentId>(segmentId2), makeMockSegment(segmentId2, 0, rundownId))
const parts: Part[] = []
parts.push(makeMockPart('part1', 0, rundownId, segmentId1, { expectedDuration: 1000 }))
parts.push(makeMockPart('part2', 0, rundownId, segmentId1, { expectedDuration: 1000 }))
parts.push(makeMockPart('part3', 0, rundownId, segmentId2, { expectedDuration: 1000 }))
parts.push(makeMockPart('part4', 0, rundownId, segmentId2, { expectedDuration: 1000 }))
const piecesMap: Map<PartId, CalculateTimingsPiece[]> = new Map()
piecesMap.set(protectString('part1'), [
literal<CalculateTimingsPiece>({
enable: {
start: 0,
},
prerollDuration: 5000,
pieceType: IBlueprintPieceType.Normal,
}),
])
piecesMap.set(protectString('part2'), [
literal<CalculateTimingsPiece>({
enable: {
start: 0,
},
prerollDuration: 240,
pieceType: IBlueprintPieceType.Normal,
}),
])
const partInstancesMap: Map<PartId, PartInstance> = new Map()
const rundown = makeMockRundown(rundownId, playlist)
const rundowns = [rundown]
const result = timing.updateDurations(
0,
false,
playlist,
rundowns,
undefined,
parts,
partInstancesMap,
piecesMap,
segmentsMap,
DEFAULT_DURATION,
[]
)
expect(result).toEqual(
literal<RundownTimingContext>({
isLowResolution: false,
asDisplayedPlaylistDuration: 9240,
asPlayedPlaylistDuration: 9240,
currentPartInstanceId: null,
currentPartWillAutoNext: false,
currentTime: 0,
rundownExpectedDurations: {
[rundownId]: 9240,
},
rundownAsPlayedDurations: {
[rundownId]: 9240,
},
partCountdown: {
part1: 0,
part2: 6000,
part3: 7240,
part4: 8240,
},
partDisplayDurations: {
part1: 6000,
part2: 1240,
part3: 1000,
part4: 1000,
},
partDisplayStartsAt: {
part1: 0,
part2: 6000,
part3: 7240,
part4: 8240,
},
partDurations: {
part1: 6000,
part2: 1240,
part3: 1000,
part4: 1000,
},
partExpectedDurations: {
part1: 6000,
part2: 1240,
part3: 1000,
part4: 1000,
},
partPlayed: {
part1: 0,
part2: 0,
part3: 0,
part4: 0,
},
partStartsAt: {
part1: 0,
part2: 6000,
part3: 7240,
part4: 8240,
},
remainingPlaylistDuration: 9240,
totalPlaylistDuration: 9240,
breakIsLastRundown: undefined,
remainingTimeOnCurrentPart: undefined,
rundownsBeforeNextBreak: undefined,
segmentBudgetDurations: {},
segmentStartedPlayback: {},
})
)
})

it('Back-time: Can find the next expectedStart rundown anchor when it is in a future segment', () => {
const timing = new RundownTimingCalculator()
const playlist: RundownPlaylist = makeMockPlaylist()
Expand Down Expand Up @@ -1140,7 +1010,6 @@ describe('rundown Timing Calculator', () => {
rundown,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -1289,7 +1158,6 @@ describe('rundown Timing Calculator', () => {
rundown,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -1444,7 +1312,6 @@ describe('rundown Timing Calculator', () => {
rundown,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -1593,7 +1460,6 @@ describe('rundown Timing Calculator', () => {
rundown,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -1742,7 +1608,6 @@ describe('rundown Timing Calculator', () => {
rundown,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down Expand Up @@ -1897,7 +1762,6 @@ describe('rundown Timing Calculator', () => {
rundown,
parts,
partInstancesMap,
new Map(),
segmentsMap,
DEFAULT_DURATION,
[]
Expand Down
21 changes: 5 additions & 16 deletions meteor/client/lib/rundown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ import { FindOptions } from '../../lib/collections/lib'
import { getShowHiddenSourceLayers } from './localStorage'
import { Rundown } from '../../lib/collections/Rundowns'
import { IStudioSettings } from '@sofie-automation/corelib/dist/dataModel/Studio'
import {
calculatePartInstanceExpectedDurationWithPreroll,
CalculateTimingsPiece,
} from '@sofie-automation/corelib/dist/playout/timings'
import { calculatePartInstanceExpectedDurationWithPreroll } from '@sofie-automation/corelib/dist/playout/timings'
import { AdLibPieceUi } from './shelf'
import { UIShowStyleBase } from '../../lib/api/showStyles'
import { PartId, PieceId, RundownId, SegmentId, ShowStyleBaseId } from '@sofie-automation/corelib/dist/dataModel/Ids'
Expand All @@ -59,17 +56,14 @@ export namespace RundownUtils {

export function getSegmentDuration(
parts: Array<PartUi>,
pieces: Map<PartId, CalculateTimingsPiece[]>,
// pieces: Map<PartId, CalculateTimingsPiece[]>,
display?: boolean
): number {
return parts.reduce((memo, part) => {
return (
memo +
(part.instance.timings?.duration ||
calculatePartInstanceExpectedDurationWithPreroll(
part.instance,
pieces.get(part.instance.part._id) ?? []
) ||
calculatePartInstanceExpectedDurationWithPreroll(part.instance) ||
part.renderedDuration ||
(display ? Settings.defaultDisplayDuration : 0))
)
Expand Down Expand Up @@ -205,7 +199,6 @@ export namespace RundownUtils {
scrollLeft: number,
scrollWidth: number,
part: PartUi,
pieces: CalculateTimingsPiece[],
partStartsAt: number | undefined,
partDuration: number | undefined,
piece?: PieceUi
Expand All @@ -225,7 +218,7 @@ export namespace RundownUtils {
? part.instance.timings.duration + (part.instance.timings?.playOffset || 0)
: (partDuration ||
part.renderedDuration ||
calculatePartInstanceExpectedDurationWithPreroll(part.instance, pieces) ||
calculatePartInstanceExpectedDurationWithPreroll(part.instance) ||
0) - (piece.renderedInPoint || 0)))
: part.instance.timings?.duration !== undefined
? part.instance.timings.duration + (part.instance.timings?.playOffset || 0)
Expand Down Expand Up @@ -299,7 +292,6 @@ export namespace RundownUtils {
rundownsBeforeThisInPlaylist: RundownId[],
rundownsToShowstyles: Map<RundownId, ShowStyleBaseId>,
orderedAllPartIds: PartId[],
pieces: Map<PartId, CalculateTimingsPiece[]>,
currentPartInstance: PartInstance | undefined,
nextPartInstance: PartInstance | undefined,
pieceInstanceSimulation = false,
Expand Down Expand Up @@ -430,10 +422,7 @@ export namespace RundownUtils {
partsE = segmentInfo.partInstances.map((partInstance, itIndex) => {
const partTimeline: SuperTimeline.TimelineObject[] = []

const partExpectedDuration = calculatePartInstanceExpectedDurationWithPreroll(
partInstance,
pieces.get(partInstance.part._id) ?? []
)
const partExpectedDuration = calculatePartInstanceExpectedDurationWithPreroll(partInstance)

// extend objects to match the Extended interface
const partE = literal<PartExtended>({
Expand Down
Loading

0 comments on commit 0559563

Please sign in to comment.