]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - shared/models/server/job.model.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / shared / models / server / job.model.ts
... / ...
CommitLineData
1import { ContextType } from '../activitypub/context'
2import { VideoState } from '../videos'
3import { VideoResolution } from '../videos/file/video-resolution.enum'
4import { VideoStudioTaskCut } from '../videos/studio'
5import { SendEmailOptions } from './emailer.model'
6
7export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused' | 'waiting-children'
8
9export type JobType =
10 | 'activitypub-cleaner'
11 | 'activitypub-follow'
12 | 'activitypub-http-broadcast-parallel'
13 | 'activitypub-http-broadcast'
14 | 'activitypub-http-fetcher'
15 | 'activitypub-http-unicast'
16 | 'activitypub-refresher'
17 | 'actor-keys'
18 | 'after-video-channel-import'
19 | 'email'
20 | 'federate-video'
21 | 'transcoding-job-builder'
22 | 'manage-video-torrent'
23 | 'move-to-object-storage'
24 | 'notify'
25 | 'video-channel-import'
26 | 'video-file-import'
27 | 'video-import'
28 | 'video-live-ending'
29 | 'video-redundancy'
30 | 'video-studio-edition'
31 | 'video-transcoding'
32 | 'videos-views-stats'
33
34export interface Job {
35 id: number | string
36 state: JobState | 'unknown'
37 type: JobType
38 data: any
39 priority: number
40 progress: number
41 error: any
42 createdAt: Date | string
43 finishedOn: Date | string
44 processedOn: Date | string
45
46 parent?: {
47 id: string
48 }
49}
50
51export type ActivitypubHttpBroadcastPayload = {
52 uris: string[]
53 contextType: ContextType
54 body: any
55 signatureActorId?: number
56}
57
58export type ActivitypubFollowPayload = {
59 followerActorId: number
60 name: string
61 host: string
62 isAutoFollow?: boolean
63 assertIsChannel?: boolean
64}
65
66export type FetchType = 'activity' | 'video-shares' | 'video-comments' | 'account-playlists'
67export type ActivitypubHttpFetcherPayload = {
68 uri: string
69 type: FetchType
70 videoId?: number
71}
72
73export type ActivitypubHttpUnicastPayload = {
74 uri: string
75 contextType: ContextType
76 signatureActorId?: number
77 body: object
78}
79
80export type RefreshPayload = {
81 type: 'video' | 'video-playlist' | 'actor'
82 url: string
83}
84
85export type EmailPayload = SendEmailOptions
86
87export type VideoFileImportPayload = {
88 videoUUID: string
89 filePath: string
90}
91
92// ---------------------------------------------------------------------------
93
94export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file'
95export type VideoImportYoutubeDLPayloadType = 'youtube-dl'
96
97export interface VideoImportYoutubeDLPayload {
98 type: VideoImportYoutubeDLPayloadType
99 videoImportId: number
100
101 fileExt?: string
102}
103
104export interface VideoImportTorrentPayload {
105 type: VideoImportTorrentPayloadType
106 videoImportId: number
107}
108
109export type VideoImportPayload = (VideoImportYoutubeDLPayload | VideoImportTorrentPayload) & {
110 preventException: boolean
111}
112
113export interface VideoImportPreventExceptionResult {
114 resultType: 'success' | 'error'
115}
116
117// ---------------------------------------------------------------------------
118
119export type VideoRedundancyPayload = {
120 videoId: number
121}
122
123export type ManageVideoTorrentPayload =
124 {
125 action: 'create'
126 videoId: number
127 videoFileId: number
128 } | {
129 action: 'update-metadata'
130
131 videoId?: number
132 streamingPlaylistId?: number
133
134 videoFileId: number
135 }
136
137// Video transcoding payloads
138
139interface BaseTranscodingPayload {
140 videoUUID: string
141 isNewVideo?: boolean
142}
143
144export interface HLSTranscodingPayload extends BaseTranscodingPayload {
145 type: 'new-resolution-to-hls'
146 resolution: VideoResolution
147 fps: number
148 copyCodecs: boolean
149
150 deleteWebTorrentFiles: boolean
151}
152
153export interface NewWebTorrentResolutionTranscodingPayload extends BaseTranscodingPayload {
154 type: 'new-resolution-to-webtorrent'
155 resolution: VideoResolution
156 fps: number
157}
158
159export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
160 type: 'merge-audio-to-webtorrent'
161
162 resolution: VideoResolution
163 fps: number
164
165 hasChildren: boolean
166}
167
168export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
169 type: 'optimize-to-webtorrent'
170
171 quickTranscode: boolean
172
173 hasChildren: boolean
174}
175
176export type VideoTranscodingPayload =
177 HLSTranscodingPayload
178 | NewWebTorrentResolutionTranscodingPayload
179 | OptimizeTranscodingPayload
180 | MergeAudioTranscodingPayload
181
182export interface VideoLiveEndingPayload {
183 videoId: number
184 publishedAt: string
185 liveSessionId: number
186 streamingPlaylistId: number
187
188 replayDirectory?: string
189}
190
191export interface ActorKeysPayload {
192 actorId: number
193}
194
195export interface DeleteResumableUploadMetaFilePayload {
196 filepath: string
197}
198
199export interface MoveObjectStoragePayload {
200 videoUUID: string
201 isNewVideo: boolean
202 previousVideoState: VideoState
203}
204
205export type VideoStudioTaskCutPayload = VideoStudioTaskCut
206
207export type VideoStudioTaskIntroPayload = {
208 name: 'add-intro'
209
210 options: {
211 file: string
212 }
213}
214
215export type VideoStudioTaskOutroPayload = {
216 name: 'add-outro'
217
218 options: {
219 file: string
220 }
221}
222
223export type VideoStudioTaskWatermarkPayload = {
224 name: 'add-watermark'
225
226 options: {
227 file: string
228
229 watermarkSizeRatio: number
230 horitonzalMarginRatio: number
231 verticalMarginRatio: number
232 }
233}
234
235export type VideoStudioTaskPayload =
236 VideoStudioTaskCutPayload |
237 VideoStudioTaskIntroPayload |
238 VideoStudioTaskOutroPayload |
239 VideoStudioTaskWatermarkPayload
240
241export interface VideoStudioEditionPayload {
242 videoUUID: string
243 tasks: VideoStudioTaskPayload[]
244}
245
246// ---------------------------------------------------------------------------
247
248export interface VideoChannelImportPayload {
249 externalChannelUrl: string
250 videoChannelId: number
251
252 partOfChannelSyncId?: number
253}
254
255export interface AfterVideoChannelImportPayload {
256 channelSyncId: number
257}
258
259// ---------------------------------------------------------------------------
260
261export type NotifyPayload =
262 {
263 action: 'new-video'
264 videoUUID: string
265 }
266
267// ---------------------------------------------------------------------------
268
269export interface FederateVideoPayload {
270 videoUUID: string
271 isNewVideo: boolean
272}
273
274// ---------------------------------------------------------------------------
275
276export interface TranscodingJobBuilderPayload {
277 videoUUID: string
278
279 optimizeJob?: {
280 isNewVideo: boolean
281 }
282
283 // Array of jobs to create
284 jobs?: {
285 type: 'video-transcoding'
286 payload: VideoTranscodingPayload
287 priority?: number
288 }[]
289
290 // Array of sequential jobs to create
291 sequentialJobs?: {
292 type: 'video-transcoding'
293 payload: VideoTranscodingPayload
294 priority?: number
295 }[][]
296}