]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/server/job.model.ts
Fix live ending job that breaks new live session
[github/Chocobozzz/PeerTube.git] / shared / models / server / job.model.ts
1 import { ContextType } from '../activitypub/context'
2 import { VideoState } from '../videos'
3 import { VideoStudioTaskCut } from '../videos/studio'
4 import { VideoResolution } from '../videos/file/video-resolution.enum'
5 import { SendEmailOptions } from './emailer.model'
6
7 export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused'
8
9 export type JobType =
10 | 'activitypub-http-unicast'
11 | 'activitypub-http-broadcast'
12 | 'activitypub-http-fetcher'
13 | 'activitypub-cleaner'
14 | 'activitypub-follow'
15 | 'video-file-import'
16 | 'video-transcoding'
17 | 'email'
18 | 'video-import'
19 | 'videos-views-stats'
20 | 'activitypub-refresher'
21 | 'video-redundancy'
22 | 'video-live-ending'
23 | 'actor-keys'
24 | 'manage-video-torrent'
25 | 'move-to-object-storage'
26 | 'video-studio-edition'
27
28 export interface Job {
29 id: number
30 state: JobState
31 type: JobType
32 data: any
33 priority: number
34 progress: number
35 error: any
36 createdAt: Date | string
37 finishedOn: Date | string
38 processedOn: Date | string
39 }
40
41 export type ActivitypubHttpBroadcastPayload = {
42 uris: string[]
43 contextType: ContextType
44 body: any
45 signatureActorId?: number
46 }
47
48 export type ActivitypubFollowPayload = {
49 followerActorId: number
50 name: string
51 host: string
52 isAutoFollow?: boolean
53 assertIsChannel?: boolean
54 }
55
56 export type FetchType = 'activity' | 'video-shares' | 'video-comments' | 'account-playlists'
57 export type ActivitypubHttpFetcherPayload = {
58 uri: string
59 type: FetchType
60 videoId?: number
61 }
62
63 export type ActivitypubHttpUnicastPayload = {
64 uri: string
65 contextType: ContextType
66 signatureActorId?: number
67 body: object
68 }
69
70 export type RefreshPayload = {
71 type: 'video' | 'video-playlist' | 'actor'
72 url: string
73 }
74
75 export type EmailPayload = SendEmailOptions
76
77 export type VideoFileImportPayload = {
78 videoUUID: string
79 filePath: string
80 }
81
82 export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file'
83 export type VideoImportYoutubeDLPayloadType = 'youtube-dl'
84
85 export type VideoImportYoutubeDLPayload = {
86 type: VideoImportYoutubeDLPayloadType
87 videoImportId: number
88
89 fileExt?: string
90 }
91 export type VideoImportTorrentPayload = {
92 type: VideoImportTorrentPayloadType
93 videoImportId: number
94 }
95 export type VideoImportPayload = VideoImportYoutubeDLPayload | VideoImportTorrentPayload
96
97 export type VideoRedundancyPayload = {
98 videoId: number
99 }
100
101 export type ManageVideoTorrentPayload =
102 {
103 action: 'create'
104 videoId: number
105 videoFileId: number
106 } | {
107 action: 'update-metadata'
108
109 videoId?: number
110 streamingPlaylistId?: number
111
112 videoFileId: number
113 }
114
115 // Video transcoding payloads
116
117 interface BaseTranscodingPayload {
118 videoUUID: string
119 isNewVideo?: boolean
120 }
121
122 export interface HLSTranscodingPayload extends BaseTranscodingPayload {
123 type: 'new-resolution-to-hls'
124 resolution: VideoResolution
125 copyCodecs: boolean
126
127 hasAudio: boolean
128 isPortraitMode?: boolean
129
130 autoDeleteWebTorrentIfNeeded: boolean
131 isMaxQuality: boolean
132 }
133
134 export interface NewWebTorrentResolutionTranscodingPayload extends BaseTranscodingPayload {
135 type: 'new-resolution-to-webtorrent'
136 resolution: VideoResolution
137
138 hasAudio: boolean
139 createHLSIfNeeded: boolean
140
141 isPortraitMode?: boolean
142 }
143
144 export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
145 type: 'merge-audio-to-webtorrent'
146 resolution: VideoResolution
147 createHLSIfNeeded: true
148 }
149
150 export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
151 type: 'optimize-to-webtorrent'
152 }
153
154 export type VideoTranscodingPayload =
155 HLSTranscodingPayload
156 | NewWebTorrentResolutionTranscodingPayload
157 | OptimizeTranscodingPayload
158 | MergeAudioTranscodingPayload
159
160 export interface VideoLiveEndingPayload {
161 videoId: number
162 publishedAt: string
163 liveSessionId: number
164 streamingPlaylistId: number
165
166 replayDirectory?: string
167 }
168
169 export interface ActorKeysPayload {
170 actorId: number
171 }
172
173 export interface DeleteResumableUploadMetaFilePayload {
174 filepath: string
175 }
176
177 export interface MoveObjectStoragePayload {
178 videoUUID: string
179 isNewVideo: boolean
180 previousVideoState: VideoState
181 }
182
183 export type VideoStudioTaskCutPayload = VideoStudioTaskCut
184
185 export type VideoStudioTaskIntroPayload = {
186 name: 'add-intro'
187
188 options: {
189 file: string
190 }
191 }
192
193 export type VideoStudioTaskOutroPayload = {
194 name: 'add-outro'
195
196 options: {
197 file: string
198 }
199 }
200
201 export type VideoStudioTaskWatermarkPayload = {
202 name: 'add-watermark'
203
204 options: {
205 file: string
206 }
207 }
208
209 export type VideoStudioTaskPayload =
210 VideoStudioTaskCutPayload |
211 VideoStudioTaskIntroPayload |
212 VideoStudioTaskOutroPayload |
213 VideoStudioTaskWatermarkPayload
214
215 export interface VideoStudioEditionPayload {
216 videoUUID: string
217 tasks: VideoStudioTaskPayload[]
218 }