2023-05-04 08:29:34 -05:00
|
|
|
import {
|
|
|
|
RunnerJobLiveRTMPHLSTranscodingPayload,
|
|
|
|
RunnerJobPayload,
|
|
|
|
RunnerJobType,
|
2023-05-04 08:55:51 -05:00
|
|
|
RunnerJobStudioTranscodingPayload,
|
2023-05-04 08:29:34 -05:00
|
|
|
RunnerJobVODAudioMergeTranscodingPayload,
|
|
|
|
RunnerJobVODHLSTranscodingPayload,
|
|
|
|
RunnerJobVODWebVideoTranscodingPayload,
|
|
|
|
VideoStudioTaskPayload
|
|
|
|
} from '@shared/models'
|
|
|
|
|
|
|
|
const supportedMatrix = {
|
|
|
|
'vod-web-video-transcoding': (_payload: RunnerJobVODWebVideoTranscodingPayload) => {
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
'vod-hls-transcoding': (_payload: RunnerJobVODHLSTranscodingPayload) => {
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
'vod-audio-merge-transcoding': (_payload: RunnerJobVODAudioMergeTranscodingPayload) => {
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
'live-rtmp-hls-transcoding': (_payload: RunnerJobLiveRTMPHLSTranscodingPayload) => {
|
|
|
|
return true
|
|
|
|
},
|
2023-05-04 08:55:51 -05:00
|
|
|
'video-studio-transcoding': (payload: RunnerJobStudioTranscodingPayload) => {
|
2023-05-04 08:29:34 -05:00
|
|
|
const tasks = payload?.tasks
|
|
|
|
const supported = new Set<VideoStudioTaskPayload['name']>([ 'add-intro', 'add-outro', 'add-watermark', 'cut' ])
|
|
|
|
|
|
|
|
if (!Array.isArray(tasks)) return false
|
|
|
|
|
|
|
|
return tasks.every(t => t && supported.has(t.name))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isJobSupported (job: {
|
|
|
|
type: RunnerJobType
|
|
|
|
payload: RunnerJobPayload
|
|
|
|
}) {
|
|
|
|
const fn = supportedMatrix[job.type]
|
|
|
|
if (!fn) return false
|
|
|
|
|
|
|
|
return fn(job.payload as any)
|
|
|
|
}
|