aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/server-commands/videos/live-command.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/server-commands/videos/live-command.ts')
-rw-r--r--shared/server-commands/videos/live-command.ts71
1 files changed, 61 insertions, 10 deletions
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts
index d804fd883..84d127db2 100644
--- a/shared/server-commands/videos/live-command.ts
+++ b/shared/server-commands/videos/live-command.ts
@@ -15,6 +15,7 @@ import {
15 VideoState 15 VideoState
16} from '@shared/models' 16} from '@shared/models'
17import { unwrapBody } from '../requests' 17import { unwrapBody } from '../requests'
18import { ObjectStorageCommand } from '../server'
18import { AbstractCommand, OverrideCommandOptions } from '../shared' 19import { AbstractCommand, OverrideCommandOptions } from '../shared'
19import { sendRTMPStream, testFfmpegStreamError } from './live' 20import { sendRTMPStream, testFfmpegStreamError } from './live'
20 21
@@ -34,6 +35,8 @@ export class LiveCommand extends AbstractCommand {
34 }) 35 })
35 } 36 }
36 37
38 // ---------------------------------------------------------------------------
39
37 listSessions (options: OverrideCommandOptions & { 40 listSessions (options: OverrideCommandOptions & {
38 videoId: number | string 41 videoId: number | string
39 }) { 42 }) {
@@ -70,6 +73,8 @@ export class LiveCommand extends AbstractCommand {
70 }) 73 })
71 } 74 }
72 75
76 // ---------------------------------------------------------------------------
77
73 update (options: OverrideCommandOptions & { 78 update (options: OverrideCommandOptions & {
74 videoId: number | string 79 videoId: number | string
75 fields: LiveVideoUpdate 80 fields: LiveVideoUpdate
@@ -110,6 +115,8 @@ export class LiveCommand extends AbstractCommand {
110 return body.video 115 return body.video
111 } 116 }
112 117
118 // ---------------------------------------------------------------------------
119
113 async sendRTMPStreamInVideo (options: OverrideCommandOptions & { 120 async sendRTMPStreamInVideo (options: OverrideCommandOptions & {
114 videoId: number | string 121 videoId: number | string
115 fixtureName?: string 122 fixtureName?: string
@@ -130,6 +137,8 @@ export class LiveCommand extends AbstractCommand {
130 return testFfmpegStreamError(command, options.shouldHaveError) 137 return testFfmpegStreamError(command, options.shouldHaveError)
131 } 138 }
132 139
140 // ---------------------------------------------------------------------------
141
133 waitUntilPublished (options: OverrideCommandOptions & { 142 waitUntilPublished (options: OverrideCommandOptions & {
134 videoId: number | string 143 videoId: number | string
135 }) { 144 }) {
@@ -163,15 +172,45 @@ export class LiveCommand extends AbstractCommand {
163 return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, totalSessions * 2, false) 172 return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, totalSessions * 2, false)
164 } 173 }
165 174
166 getSegment (options: OverrideCommandOptions & { 175 waitUntilSegmentUpload (options: OverrideCommandOptions & {
176 playlistNumber: number
177 segment: number
178 totalSessions?: number
179 }) {
180 const { playlistNumber, segment, totalSessions = 1 } = options
181 const segmentName = `${playlistNumber}-00000${segment}.ts`
182
183 return this.server.servers.waitUntilLog(`${segmentName} in bucket `, totalSessions * 2, false)
184 }
185
186 async waitUntilReplacedByReplay (options: OverrideCommandOptions & {
187 videoId: number | string
188 }) {
189 let video: VideoDetails
190
191 do {
192 video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId })
193
194 await wait(500)
195 } while (video.isLive === true || video.state.id !== VideoState.PUBLISHED)
196 }
197
198 // ---------------------------------------------------------------------------
199
200 getSegmentFile (options: OverrideCommandOptions & {
167 videoUUID: string 201 videoUUID: string
168 playlistNumber: number 202 playlistNumber: number
169 segment: number 203 segment: number
204 objectStorage?: boolean // default false
170 }) { 205 }) {
171 const { playlistNumber, segment, videoUUID } = options 206 const { playlistNumber, segment, videoUUID, objectStorage = false } = options
172 207
173 const segmentName = `${playlistNumber}-00000${segment}.ts` 208 const segmentName = `${playlistNumber}-00000${segment}.ts`
174 const url = `${this.server.url}/static/streaming-playlists/hls/${videoUUID}/${segmentName}` 209 const baseUrl = objectStorage
210 ? ObjectStorageCommand.getPlaylistBaseUrl()
211 : `${this.server.url}/static/streaming-playlists/hls`
212
213 const url = `${baseUrl}/${videoUUID}/${segmentName}`
175 214
176 return this.getRawRequest({ 215 return this.getRawRequest({
177 ...options, 216 ...options,
@@ -182,18 +221,30 @@ export class LiveCommand extends AbstractCommand {
182 }) 221 })
183 } 222 }
184 223
185 async waitUntilReplacedByReplay (options: OverrideCommandOptions & { 224 getPlaylistFile (options: OverrideCommandOptions & {
186 videoId: number | string 225 videoUUID: string
226 playlistName: string
227 objectStorage?: boolean // default false
187 }) { 228 }) {
188 let video: VideoDetails 229 const { playlistName, videoUUID, objectStorage = false } = options
189 230
190 do { 231 const baseUrl = objectStorage
191 video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId }) 232 ? ObjectStorageCommand.getPlaylistBaseUrl()
233 : `${this.server.url}/static/streaming-playlists/hls`
192 234
193 await wait(500) 235 const url = `${baseUrl}/${videoUUID}/${playlistName}`
194 } while (video.isLive === true || video.state.id !== VideoState.PUBLISHED) 236
237 return this.getRawRequest({
238 ...options,
239
240 url,
241 implicitToken: false,
242 defaultExpectedStatus: HttpStatusCode.OK_200
243 })
195 } 244 }
196 245
246 // ---------------------------------------------------------------------------
247
197 async countPlaylists (options: OverrideCommandOptions & { 248 async countPlaylists (options: OverrideCommandOptions & {
198 videoUUID: string 249 videoUUID: string
199 }) { 250 }) {