]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/models/server/job.model.ts
Fix next video state after optimize/audio merge
[github/Chocobozzz/PeerTube.git] / shared / models / server / job.model.ts
CommitLineData
e307e4fc 1import { ContextType } from '../activitypub/context'
1808a1f8 2import { VideoState } from '../videos'
ad5db104 3import { VideoResolution } from '../videos/file/video-resolution.enum'
84cae54e 4import { VideoStudioTaskCut } from '../videos/studio'
0fecf427 5import { SendEmailOptions } from './emailer.model'
8dc8a34e 6
5a921e7b 7export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused' | 'waiting-children'
94a5ff8a 8
a1587156 9export type JobType =
74d249bc 10 | 'activitypub-cleaner'
a1587156 11 | 'activitypub-follow'
0567049a
C
12 | 'activitypub-http-broadcast-parallel'
13 | 'activitypub-http-broadcast'
14 | 'activitypub-http-fetcher'
15 | 'activitypub-http-unicast'
a1587156 16 | 'activitypub-refresher'
8795d6f2 17 | 'actor-keys'
0567049a
C
18 | 'after-video-channel-import'
19 | 'email'
20 | 'federate-video'
0c9668f7 21 | 'transcoding-job-builder'
f012319a 22 | 'manage-video-torrent'
0305db28 23 | 'move-to-object-storage'
bd911b54 24 | 'notify'
0567049a
C
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'
5cd80545
C
33
34export interface Job {
5a921e7b
C
35 id: number | string
36 state: JobState | 'unknown'
94a5ff8a 37 type: JobType
a1587156 38 data: any
77d7e851 39 priority: number
3b01f4c0 40 progress: number
a1587156 41 error: any
1061c73f
C
42 createdAt: Date | string
43 finishedOn: Date | string
44 processedOn: Date | string
0c9668f7
C
45
46 parent?: {
47 id: string
48 }
5cd80545 49}
8dc8a34e
C
50
51export type ActivitypubHttpBroadcastPayload = {
52 uris: string[]
a219c910 53 contextType: ContextType
8dc8a34e 54 body: any
a219c910 55 signatureActorId?: number
8dc8a34e
C
56}
57
58export type ActivitypubFollowPayload = {
59 followerActorId: number
60 name: string
61 host: string
62 isAutoFollow?: boolean
63 assertIsChannel?: boolean
64}
65
57e4e1c1 66export type FetchType = 'activity' | 'video-shares' | 'video-comments' | 'account-playlists'
8dc8a34e
C
67export type ActivitypubHttpFetcherPayload = {
68 uri: string
69 type: FetchType
70 videoId?: number
8dc8a34e
C
71}
72
73export type ActivitypubHttpUnicastPayload = {
74 uri: string
a219c910 75 contextType: ContextType
8dc8a34e 76 signatureActorId?: number
db4b15f2 77 body: object
8dc8a34e
C
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
2a491182
F
92// ---------------------------------------------------------------------------
93
2158ac90
RK
94export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file'
95export type VideoImportYoutubeDLPayloadType = 'youtube-dl'
96
2a491182 97export interface VideoImportYoutubeDLPayload {
2158ac90 98 type: VideoImportYoutubeDLPayloadType
8dc8a34e
C
99 videoImportId: number
100
8dc8a34e
C
101 fileExt?: string
102}
2a491182
F
103
104export interface VideoImportTorrentPayload {
2158ac90 105 type: VideoImportTorrentPayloadType
8dc8a34e
C
106 videoImportId: number
107}
2a491182
F
108
109export type VideoImportPayload = (VideoImportYoutubeDLPayload | VideoImportTorrentPayload) & {
110 preventException: boolean
111}
112
113export interface VideoImportPreventExceptionResult {
114 resultType: 'success' | 'error'
115}
116
117// ---------------------------------------------------------------------------
8dc8a34e
C
118
119export type VideoRedundancyPayload = {
120 videoId: number
121}
122
f012319a
C
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
8dc8a34e
C
137// Video transcoding payloads
138
139interface BaseTranscodingPayload {
140 videoUUID: string
141 isNewVideo?: boolean
142}
143
24516aa2
C
144export interface HLSTranscodingPayload extends BaseTranscodingPayload {
145 type: 'new-resolution-to-hls'
8dc8a34e 146 resolution: VideoResolution
0c9668f7 147 fps: number
8dc8a34e 148 copyCodecs: boolean
ad5db104 149
0c9668f7 150 deleteWebTorrentFiles: boolean
8dc8a34e
C
151}
152
0f11ec8d 153export interface NewWebTorrentResolutionTranscodingPayload extends BaseTranscodingPayload {
24516aa2 154 type: 'new-resolution-to-webtorrent'
8dc8a34e 155 resolution: VideoResolution
0c9668f7 156 fps: number
8dc8a34e
C
157}
158
159export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
24516aa2 160 type: 'merge-audio-to-webtorrent'
cc2abbc3 161
8dc8a34e 162 resolution: VideoResolution
0c9668f7 163 fps: number
cc2abbc3
C
164
165 hasChildren: boolean
8dc8a34e
C
166}
167
168export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
24516aa2 169 type: 'optimize-to-webtorrent'
0c9668f7
C
170
171 quickTranscode: boolean
cc2abbc3
C
172
173 hasChildren: boolean
8dc8a34e
C
174}
175
176export type VideoTranscodingPayload =
177 HLSTranscodingPayload
0f11ec8d 178 | NewWebTorrentResolutionTranscodingPayload
8dc8a34e
C
179 | OptimizeTranscodingPayload
180 | MergeAudioTranscodingPayload
a5cf76af
C
181
182export interface VideoLiveEndingPayload {
183 videoId: number
4ec52d04 184 publishedAt: string
26e3e98f 185 liveSessionId: number
cdd83816 186 streamingPlaylistId: number
4ec52d04
C
187
188 replayDirectory?: string
a5cf76af 189}
8795d6f2
C
190
191export interface ActorKeysPayload {
192 actorId: number
193}
0305db28 194
276250f0
RK
195export interface DeleteResumableUploadMetaFilePayload {
196 filepath: string
197}
198
0305db28
JB
199export interface MoveObjectStoragePayload {
200 videoUUID: string
201 isNewVideo: boolean
1808a1f8 202 previousVideoState: VideoState
0305db28 203}
c729caf6 204
92e66e04 205export type VideoStudioTaskCutPayload = VideoStudioTaskCut
c729caf6 206
92e66e04 207export type VideoStudioTaskIntroPayload = {
c729caf6
C
208 name: 'add-intro'
209
210 options: {
211 file: string
212 }
213}
214
92e66e04 215export type VideoStudioTaskOutroPayload = {
c729caf6
C
216 name: 'add-outro'
217
218 options: {
219 file: string
220 }
221}
222
92e66e04 223export type VideoStudioTaskWatermarkPayload = {
c729caf6
C
224 name: 'add-watermark'
225
226 options: {
227 file: string
228 }
229}
230
92e66e04
C
231export type VideoStudioTaskPayload =
232 VideoStudioTaskCutPayload |
233 VideoStudioTaskIntroPayload |
234 VideoStudioTaskOutroPayload |
235 VideoStudioTaskWatermarkPayload
c729caf6 236
92e66e04 237export interface VideoStudioEditionPayload {
c729caf6 238 videoUUID: string
92e66e04 239 tasks: VideoStudioTaskPayload[]
c729caf6 240}
bd911b54
C
241
242// ---------------------------------------------------------------------------
243
2a491182
F
244export interface VideoChannelImportPayload {
245 externalChannelUrl: string
246 videoChannelId: number
a3b472a1
C
247
248 partOfChannelSyncId?: number
2a491182
F
249}
250
251export interface AfterVideoChannelImportPayload {
252 channelSyncId: number
253}
254
255// ---------------------------------------------------------------------------
256
bd911b54
C
257export type NotifyPayload =
258 {
259 action: 'new-video'
260 videoUUID: string
261 }
262
263// ---------------------------------------------------------------------------
264
265export interface FederateVideoPayload {
266 videoUUID: string
267 isNewVideo: boolean
268}
0c9668f7
C
269
270// ---------------------------------------------------------------------------
271
272export interface TranscodingJobBuilderPayload {
273 videoUUID: string
274
275 optimizeJob?: {
276 isNewVideo: boolean
277 }
278
279 // Array of jobs to create
280 jobs?: {
281 type: 'video-transcoding'
282 payload: VideoTranscodingPayload
283 priority?: number
284 }[]
285
286 // Array of sequential jobs to create
287 sequentialJobs?: {
288 type: 'video-transcoding'
289 payload: VideoTranscodingPayload
290 priority?: number
291 }[][]
292}