aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/live.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/videos/live.ts')
-rw-r--r--shared/extra-utils/videos/live.ts23
1 files changed, 12 insertions, 11 deletions
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts
index 4aa66622b..cbcfc09e4 100644
--- a/shared/extra-utils/videos/live.ts
+++ b/shared/extra-utils/videos/live.ts
@@ -6,11 +6,11 @@ import { pathExists, readdir } from 'fs-extra'
6import { omit } from 'lodash' 6import { omit } from 'lodash'
7import { join } from 'path' 7import { join } from 'path'
8import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models' 8import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models'
9import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
9import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs' 10import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs'
10import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests' 11import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests'
11import { ServerInfo } from '../server/servers' 12import { ServerInfo, waitUntilLog } from '../server/servers'
12import { getVideoWithToken } from './videos' 13import { getVideoWithToken } from './videos'
13import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
14 14
15function getLive (url: string, token: string, videoId: number | string, statusCodeExpected = HttpStatusCode.OK_200) { 15function getLive (url: string, token: string, videoId: number | string, statusCodeExpected = HttpStatusCode.OK_200) {
16 const path = '/api/v1/videos/live' 16 const path = '/api/v1/videos/live'
@@ -136,19 +136,20 @@ async function stopFfmpeg (command: ffmpeg.FfmpegCommand) {
136 await wait(500) 136 await wait(500)
137} 137}
138 138
139function waitUntilLiveStarts (url: string, token: string, videoId: number | string) {
140 return waitWhileLiveState(url, token, videoId, VideoState.WAITING_FOR_LIVE)
141}
142
143function waitUntilLivePublished (url: string, token: string, videoId: number | string) { 139function waitUntilLivePublished (url: string, token: string, videoId: number | string) {
144 return waitWhileLiveState(url, token, videoId, VideoState.PUBLISHED) 140 return waitUntilLiveState(url, token, videoId, VideoState.PUBLISHED)
145} 141}
146 142
147function waitUntilLiveEnded (url: string, token: string, videoId: number | string) { 143function waitUntilLiveEnded (url: string, token: string, videoId: number | string) {
148 return waitWhileLiveState(url, token, videoId, VideoState.LIVE_ENDED) 144 return waitUntilLiveState(url, token, videoId, VideoState.LIVE_ENDED)
145}
146
147function waitUntilLiveSegmentGeneration (server: ServerInfo, videoUUID: string, resolutionNum: number, segmentNum: number) {
148 const segmentName = `${resolutionNum}-00000${segmentNum}.ts`
149 return waitUntilLog(server, `${videoUUID}/${segmentName}`, 2, false)
149} 150}
150 151
151async function waitWhileLiveState (url: string, token: string, videoId: number | string, state: VideoState) { 152async function waitUntilLiveState (url: string, token: string, videoId: number | string, state: VideoState) {
152 let video: VideoDetails 153 let video: VideoDetails
153 154
154 do { 155 do {
@@ -156,7 +157,7 @@ async function waitWhileLiveState (url: string, token: string, videoId: number |
156 video = res.body 157 video = res.body
157 158
158 await wait(500) 159 await wait(500)
159 } while (video.state.id === state) 160 } while (video.state.id !== state)
160} 161}
161 162
162async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) { 163async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
@@ -200,10 +201,10 @@ export {
200 getPlaylistsCount, 201 getPlaylistsCount,
201 waitUntilLivePublished, 202 waitUntilLivePublished,
202 updateLive, 203 updateLive,
203 waitUntilLiveStarts,
204 createLive, 204 createLive,
205 runAndTestFfmpegStreamError, 205 runAndTestFfmpegStreamError,
206 checkLiveCleanup, 206 checkLiveCleanup,
207 waitUntilLiveSegmentGeneration,
207 stopFfmpeg, 208 stopFfmpeg,
208 sendRTMPStreamInVideo, 209 sendRTMPStreamInVideo,
209 waitUntilLiveEnded, 210 waitUntilLiveEnded,