Skip to content

Commit

Permalink
fix: Improve setting pieceId on TimelineObjs for onTimelineGenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Aug 6, 2019
1 parent 440750e commit 5fccdd7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
2 changes: 2 additions & 0 deletions meteor/lib/collections/Timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface TimelineObjGeneric extends TimelineObjectCoreExt {
/** Studio installation Id */
studioId: string
rundownId?: string
/** Piece the object originated from */
pieceId?: string

objectType: TimelineObjType

Expand Down
3 changes: 2 additions & 1 deletion meteor/server/api/playout/adlib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export namespace ServerPlayoutAdLibAPI {
// @ts-ignore _id
_id: obj.id || obj._id,
studioId: '', // set later
objectType: TimelineObjType.RUNDOWN
objectType: TimelineObjType.RUNDOWN,
pieceId: newPiece._id
})
})
),
Expand Down
13 changes: 5 additions & 8 deletions meteor/server/api/playout/lookahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ export function getLookeaheadObjects (rundownData: RundownData, studio: Studio):
const lookaheadDepth = mapping.lookahead === LookaheadMode.PRELOAD ? mapping.lookaheadDepth || 1 : 1 // TODO - test other modes
const lookaheadObjs = findLookaheadForlayer(rundownData, layerId, mapping.lookahead, lookaheadDepth)

if (layerId === 'casparcg_player_clip_pending') {
console.log('lookahead res:', JSON.stringify(lookaheadObjs))
}

// Add the objects that have some timing info
_.each(lookaheadObjs.timed, (entry, i) => {
const enable: TimelineTypes.TimelineEnable = {
Expand All @@ -60,7 +56,7 @@ export function getLookeaheadObjects (rundownData: RundownData, studio: Studio):
const finiteDuration = entry.partId === activeRundown.currentPartId || (currentPart && currentPart.autoNext && entry.partId === activeRundown.nextPartId)
enable.end = finiteDuration ? `#${entry.obj.id}.start` : undefined

mutateAndPushObject(entry.obj, `${i}`, enable, mapping, LOOKAHEAD_OBJ_PRIORITY)
mutateAndPushObject(entry.obj, `timed${i}`, enable, mapping, LOOKAHEAD_OBJ_PRIORITY)
})

// Add each of the future objects, that have no end point
Expand All @@ -71,7 +67,7 @@ export function getLookeaheadObjects (rundownData: RundownData, studio: Studio):

// Prioritise so that the earlier ones are higher, decreasing within the range 'reserved' for lookahead
const priority = futurePriorityScale * (futureObjCount - i)
mutateAndPushObject(entry.obj, `${i}`, { while: '1' }, mapping, priority)
mutateAndPushObject(entry.obj, `future${i}`, { while: '1' }, mapping, priority)
// We use while: 1 for the enabler, as any time before it should be active will be filled by either a playing object, or a timed lookahead.
// And this allows multiple futures to be timed in a way that allows them to co-exist
})
Expand Down Expand Up @@ -288,7 +284,6 @@ function getPartsOrderedByTime (rundownData: RundownData) {
function findObjectsForPart (rundownData: RundownData, layer: string, timeOrderedPartsWithPieces: PartInfoWithPieces[], startingPartOnLayerIndex: number, startingPartOnLayer: PartInfoWithPieces): TimelineObjRundown[] {
const activeRundown = rundownData.rundown


// Sanity check, if no part to search, then abort
if (!startingPartOnLayer || startingPartOnLayer.pieces.length === 0) {
return []
Expand All @@ -305,7 +300,8 @@ function findObjectsForPart (rundownData: RundownData, layer: string, timeOrdere
_id: '', // set later
studioId: '', // set later
objectType: TimelineObjType.RUNDOWN,
rundownId: rundownData.rundown._id
rundownId: rundownData.rundown._id,
pieceId: i._id
}))
}
})
Expand Down Expand Up @@ -372,6 +368,7 @@ function findObjectsForPart (rundownData: RundownData, layer: string, timeOrdere
studioId: '', // set later
objectType: TimelineObjType.RUNDOWN,
rundownId: rundownData.rundown._id,
pieceId: piece._id,
content: newContent
}))
}
Expand Down
8 changes: 6 additions & 2 deletions meteor/server/api/playout/pieces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export function createPieceGroupFirstObject (
_id: '', // set later
studioId: '', // set later
rundownId: piece.rundownId,
pieceId: piece._id,
objectType: TimelineObjType.RUNDOWN,
enable: { start: 0 },
layer: piece.sourceLayerId + '_firstobject',
Expand Down Expand Up @@ -148,6 +149,7 @@ export function createPieceGroup (
inGroup: partGroup && partGroup.id,
isGroup: true,
rundownId: piece.rundownId,
pieceId: piece._id,
objectType: TimelineObjType.RUNDOWN,
enable: calculatePieceTimelineEnable(piece),
layer: piece.sourceLayerId,
Expand Down Expand Up @@ -405,7 +407,8 @@ export function convertPieceToAdLibPiece (piece: Piece): AdLibPiece {
return extendMandadory<TimelineObjectCoreExt, TimelineObjGeneric>(obj, {
_id: '', // set later
studioId: '', // set later
objectType: TimelineObjType.RUNDOWN
objectType: TimelineObjType.RUNDOWN,
pieceId: newId
})
})
),
Expand Down Expand Up @@ -454,7 +457,8 @@ export function convertAdLibToPiece (adLibPiece: AdLibPiece | Piece, part: Part,
return extendMandadory<TimelineObjectCoreExt, TimelineObjGeneric>(obj, {
_id: '', // set later
studioId: '', // set later
objectType: TimelineObjType.RUNDOWN
objectType: TimelineObjType.RUNDOWN,
pieceId: newId
})
})
), newId + '_')
Expand Down
38 changes: 22 additions & 16 deletions meteor/server/api/playout/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,25 @@ function getTimelineRundown (studio: Studio): Promise<TimelineObjRundown[]> {
// const groupObjs = timelineObjs.filter(o => o.isGroup && ((o as any).isPartGroup || (o.metadata && o.metadata.pieceId)))
// const resolvedPieces = getResolvedPieces(currentPart)
const resolvedPieces = getResolvedPiecesFromFullTimeline(rundownData, timelineObjs)
const timelineObjs2 = _.map(timelineObjs, obj => {
let pieceId: string | undefined = undefined
if (obj.inGroup && obj.inGroup.indexOf(PlayoutTimelinePrefixes.PIECE_GROUP_PREFIX) === 0) {
pieceId = obj.inGroup.substring(PlayoutTimelinePrefixes.PIECE_GROUP_PREFIX.length)
}
return literal<OnGenerateTimelineObj & TimelineObjGeneric>({
...obj,
pieceId
})
})
const tlGenRes = waitForPromise(showStyleBlueprint.onTimelineGenerate(context, timelineObjs2, rundownData.rundown.previousPersistentState, currentPart.previousPartEndState, resolvedPieces.pieces, resolvedPieces.time))
// const timelineObjs2 = _.map(timelineObjs, obj => {
// let pieceId: string | undefined = undefined
// // TODO - this is a horrible way to define this ownership... as it will break with nested groups
// if (obj.inGroup) {
// // could start with 'previous_', so make sure to trim that off too
// const index = obj.inGroup.indexOf(PlayoutTimelinePrefixes.PIECE_GROUP_PREFIX)
// if (index !== -1) {
// pieceId = obj.inGroup.substring(index + PlayoutTimelinePrefixes.PIECE_GROUP_PREFIX.length)
// }
// }
// return literal<OnGenerateTimelineObj & TimelineObjGeneric>({
// ...obj,
// pieceId
// })
// })
const tlGenRes = waitForPromise(showStyleBlueprint.onTimelineGenerate(context, timelineObjs, rundownData.rundown.previousPersistentState, currentPart.previousPartEndState, resolvedPieces.pieces, resolvedPieces.time))
timelineObjs = _.map(tlGenRes.timeline, (object: OnGenerateTimelineObj) => {
return literal<TimelineObjGeneric>({
...omit(object, 'pieceId'),
...object,
_id: '', // set later
objectType: TimelineObjType.RUNDOWN,
studioId: studio._id
Expand All @@ -245,11 +250,11 @@ function getTimelineRundown (studio: Studio): Promise<TimelineObjRundown[]> {

resolve(
_.map<TimelineObjGeneric, TimelineObjRundown>(timelineObjs, (timelineObj) => {

return extendMandadory<TimelineObjGeneric, TimelineObjRundown>(timelineObj, {
return {
...omit(timelineObj, 'pieceId'), // pieceId is a temporary field that we dont need
rundownId: activeRundown._id,
objectType: TimelineObjType.RUNDOWN
})
}
})
)
} else {
Expand Down Expand Up @@ -723,7 +728,8 @@ function transformPartIntoTimeline (
studioId: '', // set later
inGroup: partGroup ? pieceGroup.id : undefined,
rundownId: rundown._id,
objectType: TimelineObjType.RUNDOWN
objectType: TimelineObjType.RUNDOWN,
pieceId: piece._id
})
})
}
Expand Down

0 comments on commit 5fccdd7

Please sign in to comment.