1 import EventEmitter from 'events'
2 import { LoggerTagsFn } from '@server/helpers/logger'
3 import { MStreamingPlaylistVideo, MVideoLiveVideo } from '@server/types/models'
4 import { LiveVideoError } from '@shared/models'
6 interface TranscodingWrapperEvents {
9 'error': (options: { err: Error }) => void
12 declare interface AbstractTranscodingWrapper {
13 on<U extends keyof TranscodingWrapperEvents>(
14 event: U, listener: TranscodingWrapperEvents[U]
17 emit<U extends keyof TranscodingWrapperEvents>(
18 event: U, ...args: Parameters<TranscodingWrapperEvents[U]>
22 interface AbstractTranscodingWrapperOptions {
23 streamingPlaylist: MStreamingPlaylistVideo
24 videoLive: MVideoLiveVideo
29 inputPublicUrl: string
41 segmentListSize: number
42 segmentDuration: number
47 abstract class AbstractTranscodingWrapper extends EventEmitter {
48 protected readonly videoLive: MVideoLiveVideo
50 protected readonly toTranscode: {
55 protected readonly inputLocalUrl: string
56 protected readonly inputPublicUrl: string
58 protected readonly fps: number
59 protected readonly bitrate: number
60 protected readonly ratio: number
61 protected readonly hasAudio: boolean
63 protected readonly segmentListSize: number
64 protected readonly segmentDuration: number
66 protected readonly videoUUID: string
68 protected readonly outDirectory: string
70 protected readonly lTags: LoggerTagsFn
72 protected readonly streamingPlaylist: MStreamingPlaylistVideo
74 constructor (options: AbstractTranscodingWrapperOptions) {
77 this.lTags = options.lTags
79 this.videoLive = options.videoLive
80 this.videoUUID = options.videoLive.Video.uuid
81 this.streamingPlaylist = options.streamingPlaylist
83 this.inputLocalUrl = options.inputLocalUrl
84 this.inputPublicUrl = options.inputPublicUrl
86 this.fps = options.fps
87 this.toTranscode = options.toTranscode
89 this.bitrate = options.bitrate
90 this.ratio = options.ratio
91 this.hasAudio = options.hasAudio
93 this.segmentListSize = options.segmentListSize
94 this.segmentDuration = options.segmentDuration
96 this.outDirectory = options.outDirectory
99 abstract run (): Promise<void>
101 abstract abort (error?: LiveVideoError): void
105 AbstractTranscodingWrapper,
106 AbstractTranscodingWrapperOptions