Skip to content
Closed
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
5 changes: 5 additions & 0 deletions meteor/__mocks__/defaultCollectionObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export function defaultRundownPlaylist(_id: RundownPlaylistId, studioId: StudioI
type: 'none' as any,
},
rundownIdsInOrder: [],
tTimers: [
{ index: 1, label: '', mode: null },
{ index: 2, label: '', mode: null },
{ index: 3, label: '', mode: null },
],
}
}
export function defaultRundown(
Expand Down
1 change: 1 addition & 0 deletions meteor/server/__tests__/cronjobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ describe('cronjobs', () => {
type: PlaylistTimingType.None,
},
activationId: protectString(''),
tTimers: [] as any,
})

return {
Expand Down
1 change: 1 addition & 0 deletions meteor/server/api/__tests__/externalMessageQueue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('Test external message queue static methods', () => {
type: PlaylistTimingType.None,
},
rundownIdsInOrder: [protectString('rundown_1')],
tTimers: [] as any,
})
await Rundowns.mutableCollection.insertAsync({
_id: protectString('rundown_1'),
Expand Down
1 change: 1 addition & 0 deletions meteor/server/api/__tests__/peripheralDevice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('test peripheralDevice general API methods', () => {
type: PlaylistTimingType.None,
},
rundownIdsInOrder: [rundownID],
tTimers: [] as any,
})
await Rundowns.mutableCollection.insertAsync({
_id: rundownID,
Expand Down
226 changes: 226 additions & 0 deletions meteor/server/api/rest/v1/playlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
RundownPlaylistId,
SegmentId,
} from '@sofie-automation/corelib/dist/dataModel/Ids'
import { RundownTTimerIndex } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
import { Match, check } from '../../../lib/check'
import { PlaylistsRestAPI } from '../../../lib/rest/v1'
import { Meteor } from 'meteor/meteor'
Expand Down Expand Up @@ -544,6 +545,133 @@ class PlaylistsServerAPI implements PlaylistsRestAPI {
}
)
}

async tTimerStartCountdown(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex,
duration: number,
stopAtZero?: boolean,
startPaused?: boolean
): Promise<ClientAPI.ClientResponse<void>> {
return ServerClientAPI.runUserActionInLogForPlaylistOnWorker(
this.context.getMethodContext(connection),
event,
getCurrentTime(),
rundownPlaylistId,
() => {
check(rundownPlaylistId, String)
check(timerIndex, Number)
check(duration, Number)
check(stopAtZero, Match.Optional(Boolean))
check(startPaused, Match.Optional(Boolean))
},
StudioJobs.TTimerStartCountdown,
{
playlistId: rundownPlaylistId,
timerIndex,
duration,
stopAtZero: !!stopAtZero,
startPaused: !!startPaused,
}
)
}

async tTimerStartFreeRun(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex,
startPaused?: boolean
): Promise<ClientAPI.ClientResponse<void>> {
return ServerClientAPI.runUserActionInLogForPlaylistOnWorker(
this.context.getMethodContext(connection),
event,
getCurrentTime(),
rundownPlaylistId,
() => {
check(rundownPlaylistId, String)
check(timerIndex, Number)
check(startPaused, Match.Optional(Boolean))
},
StudioJobs.TTimerStartFreeRun,
{
playlistId: rundownPlaylistId,
timerIndex,
startPaused: !!startPaused,
}
)
}

async tTimerPause(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex
): Promise<ClientAPI.ClientResponse<void>> {
return ServerClientAPI.runUserActionInLogForPlaylistOnWorker(
this.context.getMethodContext(connection),
event,
getCurrentTime(),
rundownPlaylistId,
() => {
check(rundownPlaylistId, String)
check(timerIndex, Number)
},
StudioJobs.TTimerPause,
{
playlistId: rundownPlaylistId,
timerIndex,
}
)
}

async tTimerResume(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex
): Promise<ClientAPI.ClientResponse<void>> {
return ServerClientAPI.runUserActionInLogForPlaylistOnWorker(
this.context.getMethodContext(connection),
event,
getCurrentTime(),
rundownPlaylistId,
() => {
check(rundownPlaylistId, String)
check(timerIndex, Number)
},
StudioJobs.TTimerResume,
{
playlistId: rundownPlaylistId,
timerIndex,
}
)
}

async tTimerRestart(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex
): Promise<ClientAPI.ClientResponse<void>> {
return ServerClientAPI.runUserActionInLogForPlaylistOnWorker(
this.context.getMethodContext(connection),
event,
getCurrentTime(),
rundownPlaylistId,
() => {
check(rundownPlaylistId, String)
check(timerIndex, Number)
},
StudioJobs.TTimerRestart,
{
playlistId: rundownPlaylistId,
timerIndex,
}
)
}
}

class PlaylistsAPIFactory implements APIFactory<PlaylistsRestAPI> {
Expand Down Expand Up @@ -877,4 +1005,102 @@ export function registerRoutes(registerRoute: APIRegisterHook<PlaylistsRestAPI>)
return await serverAPI.recallStickyPiece(connection, event, playlistId, sourceLayerId)
}
)

registerRoute<
{ playlistId: string; timerIndex: string },
{ duration: number; stopAtZero?: boolean; startPaused?: boolean },
void
>(
'post',
'/playlists/:playlistId/t-timers/:timerIndex/countdown',
new Map([[404, [UserErrorMessage.RundownPlaylistNotFound]]]),
playlistsAPIFactory,
async (serverAPI, connection, event, params, body) => {
const rundownPlaylistId = protectString<RundownPlaylistId>(params.playlistId)
const timerIndex = Number.parseInt(params.timerIndex) as RundownTTimerIndex
logger.info(`API POST: t-timer countdown ${rundownPlaylistId} ${timerIndex}`)

check(rundownPlaylistId, String)
check(timerIndex, Number)
return await serverAPI.tTimerStartCountdown(
connection,
event,
rundownPlaylistId,
timerIndex,
body.duration,
body.stopAtZero,
body.startPaused
)
}
)

registerRoute<{ playlistId: string; timerIndex: string }, { startPaused?: boolean }, void>(
'post',
'/playlists/:playlistId/t-timers/:timerIndex/free-run',
new Map([[404, [UserErrorMessage.RundownPlaylistNotFound]]]),
playlistsAPIFactory,
async (serverAPI, connection, event, params, body) => {
const rundownPlaylistId = protectString<RundownPlaylistId>(params.playlistId)
const timerIndex = Number.parseInt(params.timerIndex) as RundownTTimerIndex
logger.info(`API POST: t-timer free-run ${rundownPlaylistId} ${timerIndex}`)

check(rundownPlaylistId, String)
check(timerIndex, Number)
return await serverAPI.tTimerStartFreeRun(
connection,
event,
rundownPlaylistId,
timerIndex,
body.startPaused
)
}
)

registerRoute<{ playlistId: string; timerIndex: string }, never, void>(
'post',
'/playlists/:playlistId/t-timers/:timerIndex/pause',
new Map([[404, [UserErrorMessage.RundownPlaylistNotFound]]]),
playlistsAPIFactory,
async (serverAPI, connection, event, params, _) => {
const rundownPlaylistId = protectString<RundownPlaylistId>(params.playlistId)
const timerIndex = Number.parseInt(params.timerIndex) as RundownTTimerIndex
logger.info(`API POST: t-timer pause ${rundownPlaylistId} ${timerIndex}`)

check(rundownPlaylistId, String)
check(timerIndex, Number)
return await serverAPI.tTimerPause(connection, event, rundownPlaylistId, timerIndex)
}
)

registerRoute<{ playlistId: string; timerIndex: string }, never, void>(
'post',
'/playlists/:playlistId/t-timers/:timerIndex/resume',
new Map([[404, [UserErrorMessage.RundownPlaylistNotFound]]]),
playlistsAPIFactory,
async (serverAPI, connection, event, params, _) => {
const rundownPlaylistId = protectString<RundownPlaylistId>(params.playlistId)
const timerIndex = Number.parseInt(params.timerIndex) as RundownTTimerIndex
logger.info(`API POST: t-timer resume ${rundownPlaylistId} ${timerIndex}`)

check(rundownPlaylistId, String)
check(timerIndex, Number)
return await serverAPI.tTimerResume(connection, event, rundownPlaylistId, timerIndex)
}
)

registerRoute<{ playlistId: string; timerIndex: string }, never, void>(
'post',
'/playlists/:playlistId/t-timers/:timerIndex/restart',
new Map([[404, [UserErrorMessage.RundownPlaylistNotFound]]]),
playlistsAPIFactory,
async (serverAPI, connection, event, params, _) => {
const rundownPlaylistId = protectString<RundownPlaylistId>(params.playlistId)
const timerIndex = Number.parseInt(params.timerIndex) as RundownTTimerIndex
logger.info(`API POST: t-timer restart ${rundownPlaylistId} ${timerIndex}`)

check(rundownPlaylistId, String)
check(timerIndex, Number)
return await serverAPI.tTimerRestart(connection, event, rundownPlaylistId, timerIndex)
}
)
}
75 changes: 75 additions & 0 deletions meteor/server/lib/rest/v1/playlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SegmentId,
} from '@sofie-automation/corelib/dist/dataModel/Ids'
import { QueueNextSegmentResult } from '@sofie-automation/corelib/dist/worker/studio'
import { RundownTTimerIndex } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
import { Meteor } from 'meteor/meteor'

/* *************************************************************************
Expand Down Expand Up @@ -261,4 +262,78 @@ export interface PlaylistsRestAPI {
rundownPlaylistId: RundownPlaylistId,
sourceLayerId: string
): Promise<ClientAPI.ClientResponse<void>>
/**
* Configure a T-timer as a countdown.
* @param connection Connection data including client and header details
* @param event User event string
* @param rundownPlaylistId Target Playlist.
* @param timerIndex Index of the timer (1-3).
* @param duration Duration in seconds.
* @param stopAtZero Whether to stop at zero.
* @param startPaused Whether to start paused.
*/
tTimerStartCountdown(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex,
duration: number,
stopAtZero?: boolean,
startPaused?: boolean
): Promise<ClientAPI.ClientResponse<void>>

/**
* Configure a T-timer as a free-running timer.
* @param connection Connection data including client and header details
* @param event User event string
* @param rundownPlaylistId Target Playlist.
* @param timerIndex Index of the timer (1-3).
* @param startPaused Whether to start paused.
*/
tTimerStartFreeRun(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex,
startPaused?: boolean
): Promise<ClientAPI.ClientResponse<void>>
/**
* Pause a T-timer.
* @param connection Connection data including client and header details
* @param event User event string
* @param rundownPlaylistId Target Playlist.
* @param timerIndex Index of the timer (1-3).
*/
tTimerPause(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex
): Promise<ClientAPI.ClientResponse<void>>
/**
* Resume a T-timer.
* @param connection Connection data including client and header details
* @param event User event string
* @param rundownPlaylistId Target Playlist.
* @param timerIndex Index of the timer (1-3).
*/
tTimerResume(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex
): Promise<ClientAPI.ClientResponse<void>>
/**
* Restart a T-timer.
* @param connection Connection data including client and header details
* @param event User event string
* @param rundownPlaylistId Target Playlist.
* @param timerIndex Index of the timer (1-3).
*/
tTimerRestart(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
timerIndex: RundownTTimerIndex
): Promise<ClientAPI.ClientResponse<void>>
}
Loading