ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

51 lines
1.6 KiB

  1. import {
  2. RunnerJobLiveRTMPHLSTranscodingPayload,
  3. RunnerJobPayload,
  4. RunnerJobStudioTranscodingPayload,
  5. RunnerJobTranscriptionPayload,
  6. RunnerJobType,
  7. RunnerJobVODAudioMergeTranscodingPayload,
  8. RunnerJobVODHLSTranscodingPayload,
  9. RunnerJobVODWebVideoTranscodingPayload,
  10. VideoStudioTaskPayload
  11. } from '@peertube/peertube-models'
  12. const supportedMatrix: { [ id in RunnerJobType ]: (payload: RunnerJobPayload) => boolean } = {
  13. 'vod-web-video-transcoding': (_payload: RunnerJobVODWebVideoTranscodingPayload) => {
  14. return true
  15. },
  16. 'vod-hls-transcoding': (_payload: RunnerJobVODHLSTranscodingPayload) => {
  17. return true
  18. },
  19. 'vod-audio-merge-transcoding': (_payload: RunnerJobVODAudioMergeTranscodingPayload) => {
  20. return true
  21. },
  22. 'live-rtmp-hls-transcoding': (_payload: RunnerJobLiveRTMPHLSTranscodingPayload) => {
  23. return true
  24. },
  25. 'video-studio-transcoding': (payload: RunnerJobStudioTranscodingPayload) => {
  26. const tasks = payload?.tasks
  27. const supported = new Set<VideoStudioTaskPayload['name']>([ 'add-intro', 'add-outro', 'add-watermark', 'cut' ])
  28. if (!Array.isArray(tasks)) return false
  29. return tasks.every(t => t && supported.has(t.name))
  30. },
  31. 'video-transcription': (_payload: RunnerJobTranscriptionPayload) => {
  32. return true
  33. }
  34. }
  35. export function isJobSupported (job: { type: RunnerJobType, payload: RunnerJobPayload }, enabledJobs?: Set<RunnerJobType>) {
  36. if (enabledJobs && !enabledJobs.has(job.type)) return false
  37. const fn = supportedMatrix[job.type]
  38. if (!fn) return false
  39. return fn(job.payload as any)
  40. }
  41. export function getSupportedJobsList () {
  42. return Object.keys(supportedMatrix)
  43. }