diff options
Diffstat (limited to 'shared/extra-utils/videos/live.ts')
-rw-r--r-- | shared/extra-utils/videos/live.ts | 23 |
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' | |||
6 | import { omit } from 'lodash' | 6 | import { omit } from 'lodash' |
7 | import { join } from 'path' | 7 | import { join } from 'path' |
8 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models' | 8 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models' |
9 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
9 | import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs' | 10 | import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs' |
10 | import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests' | 11 | import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests' |
11 | import { ServerInfo } from '../server/servers' | 12 | import { ServerInfo, waitUntilLog } from '../server/servers' |
12 | import { getVideoWithToken } from './videos' | 13 | import { getVideoWithToken } from './videos' |
13 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
14 | 14 | ||
15 | function getLive (url: string, token: string, videoId: number | string, statusCodeExpected = HttpStatusCode.OK_200) { | 15 | function 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 | ||
139 | function waitUntilLiveStarts (url: string, token: string, videoId: number | string) { | ||
140 | return waitWhileLiveState(url, token, videoId, VideoState.WAITING_FOR_LIVE) | ||
141 | } | ||
142 | |||
143 | function waitUntilLivePublished (url: string, token: string, videoId: number | string) { | 139 | function 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 | ||
147 | function waitUntilLiveEnded (url: string, token: string, videoId: number | string) { | 143 | function 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 | |||
147 | function 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 | ||
151 | async function waitWhileLiveState (url: string, token: string, videoId: number | string, state: VideoState) { | 152 | async 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 | ||
162 | async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) { | 163 | async 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, |