Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add object to timeline to trigger a regeneration at point in time #1384

Open
wants to merge 1 commit into
base: release53
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meteor/server/api/__tests__/cleanup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ async function setDefaultDatatoDB(env: DefaultEnvironment, now: number) {
generationVersions: {} as any,
timelineBlob: '' as any,
timelineHash: '' as any,
regenerateTimelineToken: undefined,
})
await TimelineDatastore.mutableCollection.insertAsync({
_id: getRandomId(),
Expand Down
2 changes: 2 additions & 0 deletions meteor/server/lib/__tests__/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('server/lib', () => {
generated: 1234,
timelineBlob: serializeTimelineBlob(mystudioObjs),
generationVersions: {} as any,
regenerateTimelineToken: undefined,
})

const mystudio2Objs: Array<TimelineObjGeneric> = [
Expand All @@ -62,6 +63,7 @@ describe('server/lib', () => {
generated: 1234,
timelineBlob: serializeTimelineBlob(mystudio2Objs),
generationVersions: {} as any,
regenerateTimelineToken: undefined,
})

const options: SaveIntoDbHooks<any> = {
Expand Down
17 changes: 17 additions & 0 deletions packages/corelib/src/dataModel/Timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
PartPlaybackCallbackData,
PiecePlaybackCallbackData,
PlayoutChangedType,
TriggerRegenerationCallbackData,
} from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
export { PartPlaybackCallbackData, PiecePlaybackCallbackData }

Expand Down Expand Up @@ -74,6 +75,16 @@ export interface TimelineObjPieceAbstract extends Omit<TimelineObjRundown, 'enab
}
}

export interface TimelineObjRegenerateTrigger extends TimelineObjRundown {
// used for sending callbacks
content: {
deviceType: TSR.DeviceType.ABSTRACT
type: 'callback'
callBack: PlayoutChangedType.TRIGGER_REGENERATION
callBackData: TriggerRegenerationCallbackData
}
}

export function updateLookaheadLayer(obj: TimelineObjRundown): void {
// Set lookaheadForLayer to reference the original layer:
obj.lookaheadForLayer = obj.layer
Expand Down Expand Up @@ -102,4 +113,10 @@ export interface TimelineComplete {
timelineBlob: TimelineBlob
/** Version numbers of sofie at the time the timeline was generated */
generationVersions: TimelineCompleteGenerationVersions

/**
* A special regenerate object can be on the timeline to trigger a regeneration at a certain point
* It uses this token to verify that the regeneration request is valid
*/
regenerateTimelineToken: string | undefined
}
9 changes: 6 additions & 3 deletions packages/job-worker/src/playout/__tests__/playout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ import { DBPartInstance } from '@sofie-automation/corelib/dist/dataModel/PartIns
import { ReadonlyDeep } from 'type-fest'
import { adjustFakeTime, getCurrentTime, useFakeCurrentTime } from '../../__mocks__/time'
import { PieceLifespan } from '@sofie-automation/blueprints-integration'
import { PlayoutChangedType } from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
import {
PlayoutChangedResult,
PlayoutChangedType,
} from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
import { ProcessedShowStyleCompound } from '../../jobs'
import { handleOnPlayoutPlaybackChanged } from '../timings'
import { sleep } from '@sofie-automation/shared-lib/dist/lib/lib'
Expand Down Expand Up @@ -592,7 +595,7 @@ describe('Playout API', () => {
time: now,
},
},
...pieceInstances.map((pieceInstance) => {
...pieceInstances.map((pieceInstance): PlayoutChangedResult => {
return {
type: PlayoutChangedType.PIECE_PLAYBACK_STARTED,
objId: 'objectId',
Expand Down Expand Up @@ -685,7 +688,7 @@ describe('Playout API', () => {
time: now,
},
},
...pieceInstances.map((pieceInstance) => {
...pieceInstances.map((pieceInstance): PlayoutChangedResult => {
return {
type: PlayoutChangedType.PIECE_PLAYBACK_STOPPED,
objId: 'objectId',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ describe('Resolved Pieces', () => {
partStarted,
// Approximate `calculatedTimings`, for the partInstances which already have it cached
calculatedTimings: getPartTimingsOrDefaults(partInstance, pieceInstances),
regenerateTimelineAt: undefined,
}
}

Expand Down
25 changes: 13 additions & 12 deletions packages/job-worker/src/playout/__tests__/timeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,19 @@ async function doOnPlayoutPlaybackChanged(
}
: undefined,
// The piece controlObjects start offset into the part, so need a manual offset
...Object.entries<number | null>(timings.pieceOffsets).map(([pieceInstanceId, offset]) =>
offset !== null
? {
type: PlayoutChangedType.PIECE_PLAYBACK_STARTED,
data: {
partInstanceId: timings.partId,
pieceInstanceId: protectString(pieceInstanceId),
time: timings.baseTime + offset,
},
objId: getPieceControlObjectId(protectString(pieceInstanceId)),
}
: undefined
...Object.entries<number | null>(timings.pieceOffsets).map(
([pieceInstanceId, offset]): PlayoutChangedResult | undefined =>
offset !== null
? {
type: PlayoutChangedType.PIECE_PLAYBACK_STARTED,
data: {
partInstanceId: timings.partId,
pieceInstanceId: protectString(pieceInstanceId),
time: timings.baseTime + offset,
},
objId: getPieceControlObjectId(protectString(pieceInstanceId)),
}
: undefined
),
]),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
partStarted: getCurrentTime() + 546,
pieceInstances: ['1', '2'] as any,
calculatedTimings: { inTransitionStart: null } as any,
regenerateTimelineAt: undefined,
}

const expectedPrevious = {
Expand All @@ -299,6 +300,7 @@
partStarted: getCurrentTime() + 865,
pieceInstances: ['3', '4'] as any,
calculatedTimings: { inTransitionStart: null } as any,
regenerateTimelineAt: undefined,
}
const expectedCurrent = {
part: partInstancesInfo.current.partInstance,
Expand All @@ -319,6 +321,7 @@
partStarted: getCurrentTime() + 142,
pieceInstances: ['5'] as any,
calculatedTimings: { inTransitionStart: null } as any,
regenerateTimelineAt: undefined,
}
const expectedNext = {
part: partInstancesInfo.next.partInstance,
Expand All @@ -341,7 +344,7 @@
await expectLookaheadForLayerMock(playlistId, [expectedCurrent, expectedNext], expectedPrevious, fakeParts)
})

// test('Pieces', () => {

Check warning on line 347 in packages/job-worker/src/playout/lookahead/__tests__/lookahead.test.ts

View workflow job for this annotation

GitHub Actions / Lint Package (job-worker)

Some tests seem to be commented
// const fakeParts = partIds.map((p) => ({ _id: p })) as Part[]
// getOrderedPartsAfterPlayheadMock.mockReturnValue(fakeParts)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,14 +812,16 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou

setTimeline(
timelineObjs: TimelineObjGeneric[],
generationVersions: TimelineCompleteGenerationVersions
generationVersions: TimelineCompleteGenerationVersions,
regenerateTimelineToken: string | undefined
): ReadonlyDeep<TimelineComplete> {
this.timelineImpl = {
_id: this.context.studioId,
timelineHash: getRandomId(), // randomized on every timeline change
generated: getCurrentTime(),
timelineBlob: serializeTimelineBlob(timelineObjs),
generationVersions: generationVersions,
regenerateTimelineToken: regenerateTimelineToken,
}
this.#timelineHasChanged = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ describe('buildTimelineObjsForRundown', () => {
partInstance: createMockPartInstance('part0'),
pieceInstances: [],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand All @@ -221,6 +222,7 @@ describe('buildTimelineObjsForRundown', () => {
partInstance: createMockPartInstance('part0'),
pieceInstances: [createMockPieceInstance('piece0')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -254,6 +256,7 @@ describe('buildTimelineObjsForRundown', () => {
),
pieceInstances: [createMockPieceInstance('piece0')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand All @@ -279,13 +282,15 @@ describe('buildTimelineObjsForRundown', () => {
partInstance: createMockPartInstance('part0'),
pieceInstances: [createMockPieceInstance('piece0')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
next: {
nowInPart: 0,
partStarted: undefined,
partInstance: createMockPartInstance('part1'),
pieceInstances: [createMockPieceInstance('piece1')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand All @@ -312,13 +317,15 @@ describe('buildTimelineObjsForRundown', () => {
partInstance: createMockPartInstance('part0', { autoNext: true, expectedDuration: 5000 }),
pieceInstances: [createMockPieceInstance('piece0')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
next: {
nowInPart: 0,
partStarted: undefined,
partInstance: createMockPartInstance('part1'),
pieceInstances: [createMockPieceInstance('piece1')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -353,13 +360,15 @@ describe('buildTimelineObjsForRundown', () => {
),
pieceInstances: [createMockPieceInstance('piece9')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
current: {
nowInPart: 1234,
partStarted: 5678,
partInstance: createMockPartInstance('part0'),
pieceInstances: [createMockPieceInstance('piece0')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -395,6 +404,7 @@ describe('buildTimelineObjsForRundown', () => {
),
pieceInstances: [createMockPieceInstance('piece9'), createMockPieceInstance('piece8')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
current: {
nowInPart: 1234,
Expand All @@ -409,6 +419,7 @@ describe('buildTimelineObjsForRundown', () => {
fromPartPostroll: 400,
fromPartKeepalive: 100,
},
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -448,6 +459,7 @@ describe('buildTimelineObjsForRundown', () => {
}),
],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
current: {
nowInPart: 1234,
Expand All @@ -462,6 +474,7 @@ describe('buildTimelineObjsForRundown', () => {
fromPartPostroll: 400,
fromPartKeepalive: 100,
},
regenerateTimelineAt: undefined,
},
}

Expand All @@ -488,6 +501,7 @@ describe('buildTimelineObjsForRundown', () => {
partInstance: createMockPartInstance('part0', { autoNext: true, expectedDuration: 5000 }),
pieceInstances: [createMockPieceInstance('piece0')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
next: {
nowInPart: 0,
Expand All @@ -502,6 +516,7 @@ describe('buildTimelineObjsForRundown', () => {
fromPartPostroll: 400,
fromPartKeepalive: 100,
},
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -543,6 +558,7 @@ describe('buildTimelineObjsForRundown', () => {
}),
],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
next: {
nowInPart: 0,
Expand All @@ -565,6 +581,7 @@ describe('buildTimelineObjsForRundown', () => {
fromPartPostroll: 400,
fromPartKeepalive: 100,
},
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -597,6 +614,7 @@ describe('buildTimelineObjsForRundown', () => {
),
pieceInstances: [createMockPieceInstance('piece9')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
}

it('infinite starting in current', () => {
Expand All @@ -613,6 +631,7 @@ describe('buildTimelineObjsForRundown', () => {
createMockInfinitePieceInstance('piece1', {}, { plannedStartedPlayback: undefined }),
],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -641,6 +660,7 @@ describe('buildTimelineObjsForRundown', () => {
partInstance: createMockPartInstance('part0'),
pieceInstances: [createMockPieceInstance('piece0')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -669,6 +689,7 @@ describe('buildTimelineObjsForRundown', () => {
partInstance: createMockPartInstance('part0'),
pieceInstances: [createMockPieceInstance('piece0')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -696,6 +717,7 @@ describe('buildTimelineObjsForRundown', () => {
partInstance: createMockPartInstance('part0'),
pieceInstances: [createMockPieceInstance('piece0'), continueInfinitePiece(infinitePiece)],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -727,6 +749,7 @@ describe('buildTimelineObjsForRundown', () => {
),
pieceInstances: [createMockPieceInstance('piece0'), infinitePiece],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
next: {
nowInPart: 0,
Expand All @@ -742,6 +765,7 @@ describe('buildTimelineObjsForRundown', () => {
),
pieceInstances: [createMockPieceInstance('piece1'), continueInfinitePiece(infinitePiece)],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -771,6 +795,7 @@ describe('buildTimelineObjsForRundown', () => {
),
pieceInstances: [createMockPieceInstance('piece0'), createMockInfinitePieceInstance('piece6')],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
next: {
nowInPart: 0,
Expand All @@ -789,6 +814,7 @@ describe('buildTimelineObjsForRundown', () => {
...DEFAULT_PART_TIMINGS,
fromPartKeepalive: 100,
},
regenerateTimelineAt: undefined,
},
}

Expand Down Expand Up @@ -821,6 +847,7 @@ describe('buildTimelineObjsForRundown', () => {
createMockInfinitePieceInstance('piece6', { excludeDuringPartKeepalive: true }),
],
calculatedTimings: DEFAULT_PART_TIMINGS,
regenerateTimelineAt: undefined,
},
next: {
nowInPart: 0,
Expand All @@ -839,6 +866,7 @@ describe('buildTimelineObjsForRundown', () => {
...DEFAULT_PART_TIMINGS,
fromPartKeepalive: 100,
},
regenerateTimelineAt: undefined,
},
}

Expand Down
Loading
Loading