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