aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/peertube-runner/server/process/process.ts
blob: ef231cb38fff54ee2496812e3ca427eb744388bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { logger } from 'packages/peertube-runner/shared/logger'
import {
  RunnerJobLiveRTMPHLSTranscodingPayload,
  RunnerJobVideoEditionTranscodingPayload,
  RunnerJobVODAudioMergeTranscodingPayload,
  RunnerJobVODHLSTranscodingPayload,
  RunnerJobVODWebVideoTranscodingPayload
} from '@shared/models'
import { processAudioMergeTranscoding, processHLSTranscoding, ProcessOptions, processWebVideoTranscoding } from './shared'
import { ProcessLiveRTMPHLSTranscoding } from './shared/process-live'
import { processStudioTranscoding } from './shared/process-studio'

export async function processJob (options: ProcessOptions) {
  const { server, job } = options

  logger.info(`[${server.url}] Processing job of type ${job.type}: ${job.uuid}`, { payload: job.payload })

  if (job.type === 'vod-audio-merge-transcoding') {
    await processAudioMergeTranscoding(options as ProcessOptions<RunnerJobVODAudioMergeTranscodingPayload>)
  } else if (job.type === 'vod-web-video-transcoding') {
    await processWebVideoTranscoding(options as ProcessOptions<RunnerJobVODWebVideoTranscodingPayload>)
  } else if (job.type === 'vod-hls-transcoding') {
    await processHLSTranscoding(options as ProcessOptions<RunnerJobVODHLSTranscodingPayload>)
  } else if (job.type === 'live-rtmp-hls-transcoding') {
    await new ProcessLiveRTMPHLSTranscoding(options as ProcessOptions<RunnerJobLiveRTMPHLSTranscodingPayload>).process()
  } else if (job.type === 'video-edition-transcoding') {
    await processStudioTranscoding(options as ProcessOptions<RunnerJobVideoEditionTranscodingPayload>)
  } else {
    logger.error(`Unknown job ${job.type} to process`)
    return
  }

  logger.info(`[${server.url}] Finished processing job of type ${job.type}: ${job.uuid}`)
}