]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/videos/live.ts
Try to fix live test
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / live.ts
index 85c83c5bb5c1363cff76bc5292b594a2c0c6e16e..34613496963b5a974c165a86993169c890abbf66 100644 (file)
@@ -69,6 +69,7 @@ function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = '
   command.outputOption('-c:v libx264')
   command.outputOption('-g 50')
   command.outputOption('-keyint_min 2')
+  command.outputOption('-r 60')
   command.outputOption('-f flv')
 
   const rtmpUrl = rtmpBaseUrl + '/' + streamKey
@@ -128,7 +129,19 @@ async function stopFfmpeg (command: ffmpeg.FfmpegCommand) {
   await wait(500)
 }
 
-async function waitUntilLiveStarts (url: string, token: string, videoId: number | string) {
+function waitUntilLiveStarts (url: string, token: string, videoId: number | string) {
+  return waitWhileLiveState(url, token, videoId, VideoState.WAITING_FOR_LIVE)
+}
+
+function waitUntilLivePublished (url: string, token: string, videoId: number | string) {
+  return waitWhileLiveState(url, token, videoId, VideoState.PUBLISHED)
+}
+
+function waitUntilLiveEnded (url: string, token: string, videoId: number | string) {
+  return waitWhileLiveState(url, token, videoId, VideoState.LIVE_ENDED)
+}
+
+async function waitWhileLiveState (url: string, token: string, videoId: number | string, state: VideoState) {
   let video: VideoDetails
 
   do {
@@ -136,7 +149,7 @@ async function waitUntilLiveStarts (url: string, token: string, videoId: number
     video = res.body
 
     await wait(500)
-  } while (video.state.id === VideoState.WAITING_FOR_LIVE)
+  } while (video.state.id === state)
 }
 
 async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
@@ -168,6 +181,7 @@ async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resoluti
 
 export {
   getLive,
+  waitUntilLivePublished,
   updateLive,
   waitUntilLiveStarts,
   createLive,
@@ -175,6 +189,7 @@ export {
   checkLiveCleanup,
   stopFfmpeg,
   sendRTMPStreamInVideo,
+  waitUntilLiveEnded,
   waitFfmpegUntilError,
   sendRTMPStream,
   testFfmpegStreamError