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: time of day pieces #1406

Draft
wants to merge 1 commit into
base: release53
Choose a base branch
from
Draft
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/__mocks__/helpers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ export async function setupMockShowStyleBlueprint(
rundown,
globalAdLibPieces: [],
globalActions: [],
globalPieces: [],
baseline: { timelineObjects: [] },
}
},
Expand Down
5 changes: 3 additions & 2 deletions meteor/server/api/deviceTriggers/TagsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceIns
import { PieceInstanceFields, ContentCache } from './reactiveContentCacheForPieceInstances'
import { SourceLayers } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase'
import {
createPartCurrentTimes,
PieceInstanceWithTimings,
processAndPrunePieceInstanceTimings,
} from '@sofie-automation/corelib/dist/playout/processAndPrune'
import { applyAndValidateOverrides } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
import { IWrappedAdLib } from '@sofie-automation/meteor-lib/dist/triggers/actionFilterChainCompilers'
import { areSetsEqual, doSetsIntersect } from '@sofie-automation/corelib/dist/lib'
import { getCurrentTime } from '../../lib/lib'

export class TagsService {
protected onAirPiecesTags: Set<string> = new Set()
Expand Down Expand Up @@ -130,12 +132,11 @@ export class TagsService {
): PieceInstanceWithTimings[] {
// Approximate when 'now' is in the PartInstance, so that any adlibbed Pieces will be timed roughly correctly
const partStarted = partInstanceTimings?.plannedStartedPlayback
const nowInPart = partStarted === undefined ? 0 : Date.now() - partStarted

return processAndPrunePieceInstanceTimings(
sourceLayers,
pieceInstances as PieceInstance[],
nowInPart,
createPartCurrentTimes(getCurrentTime(), partStarted),
false,
false
)
Expand Down
1 change: 1 addition & 0 deletions meteor/server/api/ingest/packageInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
case ExpectedPackageDBType.ADLIB_ACTION:
case ExpectedPackageDBType.BASELINE_ADLIB_PIECE:
case ExpectedPackageDBType.BASELINE_ADLIB_ACTION:
case ExpectedPackageDBType.BASELINE_PIECE:

Check warning on line 38 in meteor/server/api/ingest/packageInfo.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/api/ingest/packageInfo.ts#L38

Added line #L38 was not covered by tests
case ExpectedPackageDBType.RUNDOWN_BASELINE_OBJECTS:
onUpdatedPackageInfoForRundownDebounce(pkg)
break
Expand Down
2 changes: 2 additions & 0 deletions meteor/server/api/rest/v1/typeConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@
allowPieceDirectPlay: apiStudioSettings.allowPieceDirectPlay ?? true, // Backwards compatible
enableBuckets: apiStudioSettings.enableBuckets ?? true, // Backwards compatible
enableEvaluationForm: apiStudioSettings.enableEvaluationForm ?? true, // Backwards compatible
rundownGlobalPiecesPrepareTime: apiStudioSettings.rundownGlobalPiecesPrepareTime,

Check warning on line 391 in meteor/server/api/rest/v1/typeConversion.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/api/rest/v1/typeConversion.ts#L391

Added line #L391 was not covered by tests
}
}

Expand All @@ -413,6 +414,7 @@
allowPieceDirectPlay: settings.allowPieceDirectPlay,
enableBuckets: settings.enableBuckets,
enableEvaluationForm: settings.enableEvaluationForm,
rundownGlobalPiecesPrepareTime: settings.rundownGlobalPiecesPrepareTime,

Check warning on line 417 in meteor/server/api/rest/v1/typeConversion.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/api/rest/v1/typeConversion.ts#L417

Added line #L417 was not covered by tests
}
}

Expand Down
1 change: 1 addition & 0 deletions meteor/server/lib/rest/v1/studios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,5 @@
allowPieceDirectPlay?: boolean
enableBuckets?: boolean
enableEvaluationForm?: boolean
rundownGlobalPiecesPrepareTime?: number

Check warning on line 225 in meteor/server/lib/rest/v1/studios.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/lib/rest/v1/studios.ts#L225

Added line #L225 was not covered by tests
}
2 changes: 1 addition & 1 deletion meteor/server/migration/1_50_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@

const partIdLookup = new Map<PieceId | AdLibActionId | RundownBaselineAdLibActionId, PartId>()
for (const piece of pieces) {
partIdLookup.set(piece._id, piece.startPartId)
if (piece.startPartId) partIdLookup.set(piece._id, piece.startPartId)

Check warning on line 920 in meteor/server/migration/1_50_0.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/migration/1_50_0.ts#L920

Added line #L920 was not covered by tests
}
for (const adlib of adlibPieces) {
if (adlib.partId) partIdLookup.set(adlib._id, adlib.partId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
{
_id: protectString(`piece_${pieceId}`),

partId: pieceDoc.startPartId,
partId: pieceDoc.startPartId ?? undefined,

Check warning on line 110 in meteor/server/publications/pieceContentStatusUI/rundown/regenerateItems.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/pieceContentStatusUI/rundown/regenerateItems.ts#L110

Added line #L110 was not covered by tests
rundownId: pieceDoc.startRundownId,
pieceId: pieceId,

Expand Down Expand Up @@ -180,7 +180,7 @@
const res: UIPieceContentStatus = {
_id: protectString(`piece_${pieceId}`),

partId: pieceDoc.piece.startPartId,
partId: pieceDoc.piece.startPartId ?? undefined,

Check warning on line 183 in meteor/server/publications/pieceContentStatusUI/rundown/regenerateItems.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/publications/pieceContentStatusUI/rundown/regenerateItems.ts#L183

Added line #L183 was not covered by tests
rundownId: pieceDoc.rundownId,
pieceId: pieceId,

Expand Down
8 changes: 8 additions & 0 deletions packages/blueprints-integration/src/api/showStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import type {
IBlueprintSegment,
IBlueprintPiece,
IBlueprintPart,
IBlueprintRundownPiece,
IBlueprintRundownPieceDB,
} from '../documents'
import type { IBlueprintShowStyleVariant, IOutputLayer, ISourceLayer } from '../showStyle'
import type { TSR, OnGenerateTimelineObj, TimelineObjectCoreExt } from '../timeline'
Expand Down Expand Up @@ -266,6 +268,7 @@ export interface BlueprintResultRundown {
rundown: IBlueprintRundown
globalAdLibPieces: IBlueprintAdLibPiece[]
globalActions: IBlueprintActionManifest[]
globalPieces: IBlueprintRundownPiece[]
baseline: BlueprintResultBaseline
}
export interface BlueprintResultSegment {
Expand All @@ -292,6 +295,11 @@ export interface BlueprintSyncIngestNewData {
actions: IBlueprintActionManifest[]
/** A list of adlibs that have pieceInstances in the partInstance in question */
referencedAdlibs: IBlueprintAdLibPieceDB[]
/**
* The list of pieces which belong to the Rundown, and may be active
* Note: Some of these may have played and been stopped before the current PartInstance
*/
rundownPieces: IBlueprintRundownPieceDB[]
}

// TODO: add something like this later?
Expand Down
1 change: 1 addition & 0 deletions packages/blueprints-integration/src/documents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export * from './pieceInstance'
export * from './pieceGeneric'
export * from './playlistTiming'
export * from './rundown'
export * from './rundownPiece'
export * from './rundownPlaylist'
export * from './segment'
29 changes: 29 additions & 0 deletions packages/blueprints-integration/src/documents/rundownPiece.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { IBlueprintPieceGeneric } from './pieceGeneric'

/**
* A variant of a Piece, that is owned by the Rundown.
* This
*/
export interface IBlueprintRundownPiece<TPrivateData = unknown, TPublicData = unknown>
extends Omit<IBlueprintPieceGeneric<TPrivateData, TPublicData>, 'lifespan'> {
/** When the piece should be active on the timeline. */
enable: {
start: number
duration?: number

// For now, these pieces are always absolute (using wall time) rather than relative to the rundown
isAbsolute: true
}

/** Whether the piece is a real piece, or exists as a marker to stop an infinite piece. If virtual, it does not add any contents to the timeline */
virtual?: boolean

/** Whether the piece affects the output of the Studio or is describing an invisible state within the Studio */
notInVision?: boolean
}

/** The Rundown piece sent from Core */
export interface IBlueprintRundownPieceDB<TPrivateData = unknown, TPublicData = unknown>
extends IBlueprintRundownPiece<TPrivateData, TPublicData> {
_id: string
}
9 changes: 9 additions & 0 deletions packages/corelib/src/dataModel/ExpectedPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type ExpectedPackageFromRundownBaseline =
| ExpectedPackageDBFromBaselineAdLibAction
| ExpectedPackageDBFromBaselineAdLibPiece
| ExpectedPackageDBFromRundownBaselineObjects
| ExpectedPackageDBFromBaselinePiece

export type ExpectedPackageDBFromBucket = ExpectedPackageDBFromBucketAdLib | ExpectedPackageDBFromBucketAdLibAction

Expand All @@ -47,6 +48,7 @@ export enum ExpectedPackageDBType {
ADLIB_ACTION = 'adlib_action',
BASELINE_ADLIB_PIECE = 'baseline_adlib_piece',
BASELINE_ADLIB_ACTION = 'baseline_adlib_action',
BASELINE_PIECE = 'baseline_piece',
BUCKET_ADLIB = 'bucket_adlib',
BUCKET_ADLIB_ACTION = 'bucket_adlib_action',
RUNDOWN_BASELINE_OBJECTS = 'rundown_baseline_objects',
Expand Down Expand Up @@ -79,6 +81,13 @@ export interface ExpectedPackageDBFromPiece extends ExpectedPackageDBBase {
/** The rundown of the Piece this package belongs to */
rundownId: RundownId
}
export interface ExpectedPackageDBFromBaselinePiece extends ExpectedPackageDBBase {
fromPieceType: ExpectedPackageDBType.BASELINE_PIECE
/** The Piece this package belongs to */
pieceId: PieceId
/** The rundown of the Piece this package belongs to */
rundownId: RundownId
}

export interface ExpectedPackageDBFromBaselineAdLibPiece extends ExpectedPackageDBBase {
fromPieceType: ExpectedPackageDBType.BASELINE_ADLIB_PIECE
Expand Down
13 changes: 11 additions & 2 deletions packages/corelib/src/dataModel/Piece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ export interface PieceGeneric extends Omit<IBlueprintPieceGeneric, 'content'> {
export interface Piece
extends PieceGeneric,
Omit<IBlueprintPieceDB, '_id' | 'content' | 'userEditOperations' | 'userEditProperties'> {
/** Timeline enabler. When the piece should be active on the timeline. */
enable: {
start: number | 'now' // TODO - now will be removed from this eventually, but as it is not an acceptable value 99% of the time, that is not really breaking
duration?: number

// Pieces owned by the Rundown should always be absolute
isAbsolute?: boolean
}

/**
* This is the id of the rundown this piece starts playing in.
* Currently this is the only rundown the piece could be playing in
Expand All @@ -62,12 +71,12 @@ export interface Piece
* This is the id of the segment this piece starts playing in.
* It is the only segment the piece could be playing in, unless the piece has a lifespan which spans beyond the segment
*/
startSegmentId: SegmentId
startSegmentId: SegmentId | null
/**
* This is the id of the part this piece starts playing in.
* If the lifespan is WithinPart, it is the only part the piece could be playing in.
*/
startPartId: PartId
startPartId: PartId | null

/** Whether this piece is a special piece */
pieceType: IBlueprintPieceType
Expand Down
2 changes: 1 addition & 1 deletion packages/corelib/src/dataModel/PieceInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface PieceInstance {
_id: PieceInstanceId
/** The rundown this piece belongs to */
rundownId: RundownId
/** The part instace this piece belongs to */
/** The part instance this piece belongs to. */
partInstanceId: PartInstanceId

/** Whether this PieceInstance is a temprorary wrapping of a Piece */
Expand Down
Loading
Loading