Skip to content

Commit d9aa36c

Browse files
committed
Merge remote-tracking branch 'upstream/release52' into bbc-release52
2 parents fcc85e8 + f8a1d75 commit d9aa36c

File tree

7 files changed

+63
-29
lines changed

7 files changed

+63
-29
lines changed

packages/job-worker/src/playout/model/PlayoutModel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,12 @@ export interface PlayoutModel extends PlayoutModelReadonly, StudioPlayoutModelBa
344344
*/
345345
setQuickLoopMarker(type: 'start' | 'end', marker: QuickLoopMarker | null): void
346346

347+
/**
348+
* Returns any segmentId's that are found between 2 quickloop markers, none will be returned if
349+
* the end is before the start.
350+
* @param start A quickloop marker
351+
* @param end A quickloop marker
352+
*/
347353
getSegmentsBetweenQuickLoopMarker(start: QuickLoopMarker, end: QuickLoopMarker): SegmentId[]
348354

349355
calculatePartTimings(

packages/job-worker/src/playout/model/implementation/PlayoutModelImpl.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,11 @@ export class PlayoutModelImpl extends PlayoutModelReadonlyImpl implements Playou
594594

595595
if (regenerateActivationId) this.playlistImpl.activationId = getRandomId()
596596

597-
// reset quickloop:
598-
this.setQuickLoopMarker('start', null)
599-
this.setQuickLoopMarker('end', null)
597+
// reset quickloop if applicable:
598+
if (this.playlist.quickLoop && !this.playlist.quickLoop.locked) {
599+
this.setQuickLoopMarker('start', null)
600+
this.setQuickLoopMarker('end', null)
601+
}
600602

601603
this.#playlistHasChanged = true
602604
}

packages/job-worker/src/playout/model/services/QuickLoopService.ts

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -150,35 +150,55 @@ export class QuickLoopService {
150150
}
151151

152152
getSegmentsBetweenMarkers(startMarker: QuickLoopMarker, endMarker: QuickLoopMarker): SegmentId[] {
153-
const orderedParts = this.playoutModel.getAllOrderedParts()
154-
const rundownIds = this.playoutModel.getRundownIds()
155-
156-
const start = this.findQuickLoopMarkerPosition(startMarker, 'start', orderedParts, rundownIds)
157-
const end = this.findQuickLoopMarkerPosition(endMarker, 'end', orderedParts, rundownIds)
153+
const segments = this.playoutModel.getAllOrderedSegments()
154+
const segmentIds: SegmentId[] = []
158155

159-
if (this.areMarkersFlipped(start, end)) return []
156+
let passedStart = false
157+
let seenLastRundown = false
160158

161-
const segmentIds: Set<SegmentId> = new Set()
159+
for (const s of segments) {
160+
if (
161+
(!passedStart &&
162+
((startMarker.type === QuickLoopMarkerType.PART && s.getPart(startMarker.id)) ||
163+
(startMarker.type === QuickLoopMarkerType.SEGMENT && s.segment._id === startMarker.id) ||
164+
(startMarker.type === QuickLoopMarkerType.RUNDOWN &&
165+
s.segment.rundownId === startMarker.id))) ||
166+
startMarker.type === QuickLoopMarkerType.PLAYLIST
167+
) {
168+
// the start marker is inside this segment, is this segment, or this is the first segment that is in the loop
169+
// segments from here on are included in the loop
170+
passedStart = true
171+
}
162172

163-
for (const part of orderedParts) {
164-
const currentSegment = this.playoutModel.findSegment(part.segmentId)?.segment
165-
const currentRundownIndex = rundownIds.findIndex((id) => id === part.rundownId)
173+
if (endMarker.type === QuickLoopMarkerType.RUNDOWN) {
174+
// last rundown needs to be inclusive so we need to break once the rundownId is not equal to segment's rundownId
175+
if (s.segment.rundownId === endMarker.id) {
176+
if (!passedStart) {
177+
// we hit the end before the start so quit now:
178+
break
179+
}
180+
seenLastRundown = true
181+
} else if (seenLastRundown) {
182+
// we have passed the last rundown
183+
break
184+
}
185+
}
166186

167-
if (!currentSegment) continue // ???
187+
if (passedStart) {
188+
// passed the start but we have not seen the end yet
189+
segmentIds.push(s.segment._id)
190+
}
168191

169192
if (
170-
currentRundownIndex >= start.rundownRank &&
171-
currentRundownIndex <= end.rundownRank &&
172-
currentSegment._rank >= start.segmentRank &&
173-
currentSegment._rank <= end.segmentRank &&
174-
part._rank >= start.partRank &&
175-
part._rank <= start.partRank
193+
(endMarker.type === QuickLoopMarkerType.PART && s.getPart(endMarker.id)) ||
194+
(endMarker.type === QuickLoopMarkerType.SEGMENT && s.segment._id === endMarker.id)
176195
) {
177-
segmentIds.add(currentSegment._id)
196+
// the endMarker is in this segment or this segment is the end marker
197+
break
178198
}
179199
}
180200

181-
return Array.from(segmentIds.values())
201+
return segmentIds
182202
}
183203

184204
private areMarkersFlipped(startPosition: MarkerPosition, endPosition: MarkerPosition) {

packages/job-worker/src/playout/quickLoopMarkers.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { resetPartInstancesWithPieceInstances } from './lib'
99
import { QuickLoopMarker, QuickLoopMarkerType } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
1010
import { SegmentId } from '@sofie-automation/corelib/dist/dataModel/Ids'
1111
import { PlayoutModel } from './model/PlayoutModel'
12+
import { clone } from 'underscore'
1213

1314
export async function handleSetQuickLoopMarker(context: JobContext, data: SetQuickLoopMarkerProps): Promise<void> {
1415
return runJobWithPlayoutModel(
@@ -21,10 +22,8 @@ export async function handleSetQuickLoopMarker(context: JobContext, data: SetQui
2122
async (playoutModel) => {
2223
const playlist = playoutModel.playlist
2324
if (!playlist.activationId) throw new Error(`Playlist has no activationId!`)
24-
25-
const oldProps = playoutModel.playlist.quickLoop
25+
const oldProps = clone(playoutModel.playlist.quickLoop)
2626
const wasQuickLoopRunning = oldProps?.running
27-
2827
playoutModel.setQuickLoopMarker(data.type, data.marker)
2928

3029
const markerChanged = (

packages/live-status-gateway/api/schemas/activePlaylist.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $defs:
6363
expectedStart:
6464
description: Unix timestamp of when the playlist is expected to start (milliseconds). Required when the timingMode is set to forward-time.
6565
type: number
66-
expectedDuration:
66+
expectedDurationMs:
6767
description: Duration of the playlist in ms
6868
type: number
6969
expectedEnd:
@@ -89,7 +89,7 @@ $defs:
8989
timing:
9090
timingMode: 'forward-time'
9191
expectedStart: 1728895750727
92-
duration: 180000
92+
expectedDurationMs: 180000
9393
partBase:
9494
type: object
9595
properties:

packages/live-status-gateway/src/topics/__tests__/activePlaylist.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
1212
import { SegmentHandler } from '../../collections/segmentHandler'
1313
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
1414
import { CountdownType } from '@sofie-automation/blueprints-integration'
15+
import { PlaylistTimingType } from '@sofie-automation/blueprints-integration'
1516

1617
function makeEmptyTestPartInstances(): SelectedPartInstances {
1718
return {
@@ -50,6 +51,9 @@ describe('ActivePlaylistTopic', () => {
5051
rundownIds: unprotectStringArray(playlist.rundownIdsInOrder),
5152
publicData: undefined,
5253
quickLoop: undefined,
54+
timing: {
55+
timingMode: PlaylistTimingType.None,
56+
},
5357
}
5458

5559
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -141,6 +145,9 @@ describe('ActivePlaylistTopic', () => {
141145
rundownIds: unprotectStringArray(playlist.rundownIdsInOrder),
142146
publicData: { a: 'b' },
143147
quickLoop: undefined,
148+
timing: {
149+
timingMode: PlaylistTimingType.None,
150+
},
144151
}
145152

146153
// eslint-disable-next-line @typescript-eslint/unbound-method

packages/live-status-gateway/src/topics/activePlaylistTopic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export interface ActivePlaylistStatus {
7373
timingMode: PlaylistTimingType
7474
startedPlayback?: number
7575
expectedStart?: number
76-
expectedDuration?: number
76+
expectedDurationMs?: number
7777
expectedEnd?: number
7878
}
7979
}
@@ -181,7 +181,7 @@ export class ActivePlaylistTopic
181181
timing: {
182182
timingMode: this._activePlaylist.timing.type,
183183
startedPlayback: this._activePlaylist.startedPlayback,
184-
expectedDuration: this._activePlaylist.timing.expectedDuration,
184+
expectedDurationMs: this._activePlaylist.timing.expectedDuration,
185185
expectedStart:
186186
this._activePlaylist.timing.type !== PlaylistTimingType.None
187187
? this._activePlaylist.timing.expectedStart

0 commit comments

Comments
 (0)