Skip to content

Commit 77e101e

Browse files
authored
feat: option to disable HOLD & direct play (#32)
1 parent 460a2a9 commit 77e101e

File tree

19 files changed

+137
-9
lines changed

19 files changed

+137
-9
lines changed

meteor/__mocks__/defaultCollectionObjects.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ export function defaultStudio(_id: StudioId): DBStudio {
110110
mediaPreviewsUrl: '',
111111
minimumTakeSpan: DEFAULT_MINIMUM_TAKE_SPAN,
112112
fallbackPartDuration: DEFAULT_FALLBACK_PART_DURATION,
113+
allowHold: false,
114+
allowPieceDirectPlay: false,
113115
}),
114116
_rundownVersionHash: '',
115117
routeSetsWithOverrides: wrapDefaultObject({}),

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { PeripheralDevice, PeripheralDeviceType } from '@sofie-automation/coreli
1010
import { Blueprint } from '@sofie-automation/corelib/dist/dataModel/Blueprint'
1111
import { BucketId, ShowStyleBaseId, ShowStyleVariantId, StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
1212
import { DBStudio, IStudioSettings } from '@sofie-automation/corelib/dist/dataModel/Studio'
13-
import { assertNever, getRandomId, literal } from '@sofie-automation/corelib/dist/lib'
13+
import { assertNever, Complete, getRandomId, literal } from '@sofie-automation/corelib/dist/lib'
1414
import { protectString, unprotectString } from '@sofie-automation/corelib/dist/protectedString'
1515
import {
1616
applyAndValidateOverrides,
@@ -296,7 +296,7 @@ export async function studioFrom(apiStudio: APIStudio, existingId?: StudioId): P
296296
}
297297
}
298298

299-
export function APIStudioFrom(studio: DBStudio): APIStudio {
299+
export function APIStudioFrom(studio: DBStudio): Complete<APIStudio> {
300300
const studioSettings = APIStudioSettingsFrom(applyAndValidateOverrides(studio.settingsWithOverrides).obj)
301301

302302
return {
@@ -309,7 +309,7 @@ export function APIStudioFrom(studio: DBStudio): APIStudio {
309309
}
310310
}
311311

312-
export function studioSettingsFrom(apiStudioSettings: APIStudioSettings): IStudioSettings {
312+
export function studioSettingsFrom(apiStudioSettings: APIStudioSettings): Complete<IStudioSettings> {
313313
return {
314314
frameRate: apiStudioSettings.frameRate,
315315
mediaPreviewsUrl: apiStudioSettings.mediaPreviewsUrl,
@@ -325,10 +325,13 @@ export function studioSettingsFrom(apiStudioSettings: APIStudioSettings): IStudi
325325
enableQuickLoop: apiStudioSettings.enableQuickLoop,
326326
forceQuickLoopAutoNext: forceQuickLoopAutoNextFrom(apiStudioSettings.forceQuickLoopAutoNext),
327327
fallbackPartDuration: apiStudioSettings.fallbackPartDuration ?? DEFAULT_FALLBACK_PART_DURATION,
328+
allowAdlibTestingSegment: apiStudioSettings.allowAdlibTestingSegment,
329+
allowHold: apiStudioSettings.allowHold ?? true, // Backwards compatible
330+
allowPieceDirectPlay: apiStudioSettings.allowPieceDirectPlay ?? true, // Backwards compatible
328331
}
329332
}
330333

331-
export function APIStudioSettingsFrom(settings: IStudioSettings): APIStudioSettings {
334+
export function APIStudioSettingsFrom(settings: IStudioSettings): Complete<APIStudioSettings> {
332335
return {
333336
frameRate: settings.frameRate,
334337
mediaPreviewsUrl: settings.mediaPreviewsUrl,
@@ -344,6 +347,9 @@ export function APIStudioSettingsFrom(settings: IStudioSettings): APIStudioSetti
344347
enableQuickLoop: settings.enableQuickLoop,
345348
forceQuickLoopAutoNext: APIForceQuickLoopAutoNextFrom(settings.forceQuickLoopAutoNext),
346349
fallbackPartDuration: settings.fallbackPartDuration,
350+
allowAdlibTestingSegment: settings.allowAdlibTestingSegment,
351+
allowHold: settings.allowHold,
352+
allowPieceDirectPlay: settings.allowPieceDirectPlay,
347353
}
348354
}
349355

meteor/server/api/studio/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export async function insertStudioInner(organizationId: OrganizationId | null, n
4949
frameRate: 25,
5050
mediaPreviewsUrl: '',
5151
minimumTakeSpan: DEFAULT_MINIMUM_TAKE_SPAN,
52+
allowHold: false,
53+
allowPieceDirectPlay: false,
5254
}),
5355
_rundownVersionHash: '',
5456
routeSetsWithOverrides: wrapDefaultObject({}),

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,7 @@ export interface APIStudioSettings {
186186
forceQuickLoopAutoNext?: 'disabled' | 'enabled_when_valid_duration' | 'enabled_forcing_min_duration'
187187
minimumTakeSpan?: number
188188
fallbackPartDuration?: number
189+
allowAdlibTestingSegment?: boolean
190+
allowHold?: boolean
191+
allowPieceDirectPlay?: boolean
189192
}

meteor/server/migration/0_1_0.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export const addSteps = addMigrationSteps('0.1.0', [
3333
frameRate: 25,
3434
mediaPreviewsUrl: '',
3535
minimumTakeSpan: DEFAULT_MINIMUM_TAKE_SPAN,
36+
allowHold: false,
37+
allowPieceDirectPlay: false,
3638
}),
3739
mappingsWithOverrides: wrapDefaultObject({}),
3840
blueprintConfigWithOverrides: wrapDefaultObject({}),

meteor/server/migration/X_X_X.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,43 @@ export const addSteps = addMigrationSteps(CURRENT_SYSTEM_VERSION, [
310310
}
311311
},
312312
},
313+
314+
{
315+
id: `add studio settings allowHold & allowPieceDirectPlay`,
316+
canBeRunAutomatically: true,
317+
validate: async () => {
318+
const studios = await Studios.findFetchAsync({
319+
$or: [
320+
{ 'settings.allowHold': { $exists: false } },
321+
{ 'settings.allowPieceDirectPlay': { $exists: false } },
322+
],
323+
})
324+
325+
if (studios.length > 0) {
326+
return 'studios must have settings.allowHold and settings.allowPieceDirectPlay defined'
327+
}
328+
329+
return false
330+
},
331+
migrate: async () => {
332+
const studios = await Studios.findFetchAsync({
333+
$or: [
334+
{ 'settings.allowHold': { $exists: false } },
335+
{ 'settings.allowPieceDirectPlay': { $exists: false } },
336+
],
337+
})
338+
339+
for (const studio of studios) {
340+
// Populate the settings to be backwards compatible
341+
await Studios.updateAsync(studio._id, {
342+
$set: {
343+
'settings.allowHold': true,
344+
'settings.allowPieceDirectPlay': true,
345+
},
346+
})
347+
}
348+
},
349+
},
313350
])
314351

315352
interface PartialOldICoreSystem {

meteor/server/migration/__tests__/migrations.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ describe('Migrations', () => {
125125
mediaPreviewsUrl: '',
126126
frameRate: 25,
127127
minimumTakeSpan: DEFAULT_MINIMUM_TAKE_SPAN,
128+
allowHold: true,
129+
allowPieceDirectPlay: true,
128130
}),
129131
mappingsWithOverrides: wrapDefaultObject({}),
130132
blueprintConfigWithOverrides: wrapDefaultObject({}),
@@ -163,6 +165,8 @@ describe('Migrations', () => {
163165
mediaPreviewsUrl: '',
164166
frameRate: 25,
165167
minimumTakeSpan: DEFAULT_MINIMUM_TAKE_SPAN,
168+
allowHold: true,
169+
allowPieceDirectPlay: true,
166170
}),
167171
mappingsWithOverrides: wrapDefaultObject({}),
168172
blueprintConfigWithOverrides: wrapDefaultObject({}),
@@ -201,6 +205,8 @@ describe('Migrations', () => {
201205
mediaPreviewsUrl: '',
202206
frameRate: 25,
203207
minimumTakeSpan: DEFAULT_MINIMUM_TAKE_SPAN,
208+
allowHold: true,
209+
allowPieceDirectPlay: true,
204210
}),
205211
mappingsWithOverrides: wrapDefaultObject({}),
206212
blueprintConfigWithOverrides: wrapDefaultObject({}),

meteor/server/publications/pieceContentStatusUI/__tests__/checkPieceContentStatus.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ describe('lib/mediaObjects', () => {
166166
test('getAcceptedFormats', () => {
167167
const acceptedFormats = getAcceptedFormats({
168168
supportedMediaFormats: '1920x1080i5000, 1280x720, i5000, i5000tff',
169-
mediaPreviewsUrl: '',
170169
frameRate: 25,
171-
minimumTakeSpan: DEFAULT_MINIMUM_TAKE_SPAN,
172170
})
173171
expect(acceptedFormats).toEqual([
174172
['1920', '1080', 'i', '5000', undefined],
@@ -251,6 +249,8 @@ describe('lib/mediaObjects', () => {
251249
supportedAudioStreams: '4',
252250
frameRate: 25,
253251
minimumTakeSpan: DEFAULT_MINIMUM_TAKE_SPAN,
252+
allowHold: false,
253+
allowPieceDirectPlay: false,
254254
}
255255

256256
const mockDefaultStudio = defaultStudio(protectString('studio0'))

meteor/server/publications/pieceContentStatusUI/checkPieceContentStatus.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ export function acceptFormat(format: string, formats: Array<Array<string>>): boo
147147
* [undefined, undefined, i, 5000, tff]
148148
* ]
149149
*/
150-
export function getAcceptedFormats(settings: IStudioSettings | undefined): Array<Array<string>> {
150+
export function getAcceptedFormats(
151+
settings: Pick<IStudioSettings, 'supportedMediaFormats' | 'frameRate'> | undefined
152+
): Array<Array<string>> {
151153
const formatsConfigField = settings ? settings.supportedMediaFormats : ''
152154
const formatsString: string =
153155
(formatsConfigField && formatsConfigField !== '' ? formatsConfigField : '1920x1080i5000') + ''

packages/job-worker/src/__mocks__/defaultCollectionObjects.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export function defaultStudio(_id: StudioId): DBStudio {
107107
mediaPreviewsUrl: '',
108108
minimumTakeSpan: DEFAULT_MINIMUM_TAKE_SPAN,
109109
allowAdlibTestingSegment: true,
110+
allowHold: true,
111+
allowPieceDirectPlay: true,
110112
}),
111113
routeSetsWithOverrides: wrapDefaultObject({}),
112114
routeSetExclusivityGroupsWithOverrides: wrapDefaultObject({}),

0 commit comments

Comments
 (0)