Skip to content

Commit 8fb0383

Browse files
committed
wip: add nrk compatibility mode
1 parent 0832cd0 commit 8fb0383

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

packages/mos-gateway/src/$schemas/devices.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@
152152
"ui:description": "",
153153
"ui:summaryTitle": "Statuses",
154154
"default": true
155+
},
156+
"sendInRehearsal": {
157+
"type": "boolean",
158+
"ui:title": "Send when in Rehearsal mode",
159+
"ui:description": "",
160+
"default": false
161+
},
162+
"onlySendPlay": {
163+
"type": "boolean",
164+
"ui:title": "Only send PLAY statuses",
165+
"ui:description": "",
166+
"default": false
155167
}
156168
},
157169
"required": ["enabled"],

packages/mos-gateway/src/generated/devices.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ export interface MosDeviceConfig {
3535
}
3636
export interface MosDeviceStatusesConfig {
3737
enabled: boolean
38+
sendInRehearsal?: boolean
39+
onlySendPlay?: boolean
3840
}

packages/mos-gateway/src/mosStatusHandler.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class MosStatusHandler {
2323
readonly #logger: winston.Logger
2424
readonly #mosDevice: IMOSDevice
2525
readonly #coreMosHandler: CoreMosDeviceHandler
26+
readonly #config: MosDeviceStatusesConfig
2627
readonly #mosTypes: MosTypes
2728

2829
readonly #messageQueue = new Queue()
@@ -46,6 +47,7 @@ export class MosStatusHandler {
4647
this.#logger = logger
4748
this.#mosDevice = mosDevice
4849
this.#coreMosHandler = coreMosHandler
50+
this.#config = config
4951
this.#mosTypes = getMosTypes(strictMosTypes)
5052

5153
coreMosHandler.core
@@ -83,13 +85,18 @@ export class MosStatusHandler {
8385
this.#lastStatuses.delete(id)
8486
}
8587

86-
const statusDiff = diffStatuses(previousStatuses, newStatuses)
88+
const statusDiff = diffStatuses(this.#config, previousStatuses, newStatuses)
8789
if (statusDiff.length === 0) return
8890

8991
const diffTime = this.#mosTypes.mosTime.create(Date.now())
9092

9193
// nocommit - should this be done with some concurrency?
9294
for (const status of statusDiff) {
95+
// New implementation 2022 only sends PLAY, never stop, after getting advice from AP
96+
// Reason 1: NRK ENPS "sendt tid" (elapsed time) stopped working in ENPS 8/9 when doing STOP prior to PLAY
97+
// Reason 2: there's a delay between the STOP (yellow line disappears) and PLAY (yellow line re-appears), which annoys the users
98+
if (this.#config.onlySendPlay && status.mosStatus !== IMOSObjectStatus.PLAY) continue
99+
93100
this.#messageQueue
94101
.putOnQueue(async () => {
95102
const newStatus: IMOSStoryStatus = {
@@ -140,6 +147,7 @@ interface StoryStatusItem {
140147
}
141148

142149
function diffStatuses(
150+
config: MosDeviceStatusesConfig,
143151
previousStatuses: IngestRundownStatus | undefined,
144152
newStatuses: IngestRundownStatus | undefined
145153
): StoryStatusItem[] {
@@ -168,10 +176,10 @@ function diffStatuses(
168176
for (const [storyId, status] of newStories) {
169177
const previousStatus = previousStories.get(storyId)
170178

171-
const newMosStatus = buildMosStatus(status, newStatuses?.active)
179+
const newMosStatus = buildMosStatus(config, status, newStatuses?.active)
172180
if (
173181
newMosStatus !== null &&
174-
(!previousStatus || buildMosStatus(previousStatus, previousStatuses?.active) !== newMosStatus)
182+
(!previousStatus || buildMosStatus(config, previousStatus, previousStatuses?.active) !== newMosStatus)
175183
) {
176184
statuses.push({
177185
rundownExternalId,
@@ -199,17 +207,12 @@ function buildStoriesMap(state: IngestRundownStatus | undefined): Map<string, In
199207
}
200208

201209
function buildMosStatus(
210+
config: MosDeviceStatusesConfig,
202211
story: IngestPartStatus,
203212
active: IngestRundownStatus['active'] | undefined
204213
): IMOSObjectStatus | null {
205-
// nocommit - implement this rule.
206-
// nocommit - implement options to control behaviour of this
207-
// New implementation 2022 only sends PLAY, never stop, after getting advice from AP
208-
// Reason 1: NRK ENPS "sendt tid" (elapsed time) stopped working in ENPS 8/9 when doing STOP prior to PLAY
209-
// Reason 2: there's a delay between the STOP (yellow line disappears) and PLAY (yellow line re-appears), which annoys the users
210-
// nocommit TLDR: nrk only wants to send PLAY messages
211-
212214
if (active === 'inactive') return MOS_STATUS_UNKNOWN
215+
if (active === 'rehearsal' && !config.sendInRehearsal) return null
213216

214217
switch (story.playbackStatus) {
215218
case IngestPartPlaybackStatus.PLAY:

0 commit comments

Comments
 (0)