]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/live/live.ts
Fix lint
[github/Chocobozzz/PeerTube.git] / server / tests / api / live / live.ts
index 0b405dd94dcbfe44b48c8d2a6cd1f1f93f09a9ea..b8c4c1e293390899e53ca4e88a5906bf16a4881f 100644 (file)
@@ -3,11 +3,20 @@
 import 'mocha'
 import * as chai from 'chai'
 import { basename, join } from 'path'
-import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
+import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg'
+import { checkLiveCleanup, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import {
+  HttpStatusCode,
+  LiveVideo,
+  LiveVideoCreate,
+  LiveVideoLatencyMode,
+  VideoDetails,
+  VideoPrivacy,
+  VideoState,
+  VideoStreamingPlaylistType
+} from '@shared/models'
 import {
-  checkLiveCleanupAfterSave,
-  checkLiveSegmentHash,
-  checkResolutionsInMasterPlaylist,
   cleanupTests,
   createMultipleServers,
   doubleFollow,
@@ -20,20 +29,9 @@ import {
   setDefaultVideoChannel,
   stopFfmpeg,
   testFfmpegStreamError,
-  testImage,
-  wait,
   waitJobs,
   waitUntilLivePublishedOnAllServers
-} from '@shared/extra-utils'
-import {
-  HttpStatusCode,
-  LiveVideo,
-  LiveVideoCreate,
-  VideoDetails,
-  VideoPrivacy,
-  VideoState,
-  VideoStreamingPlaylistType
-} from '@shared/models'
+} from '@shared/server-commands'
 
 const expect = chai.expect
 
@@ -55,6 +53,9 @@ describe('Test live', function () {
         live: {
           enabled: true,
           allowReplay: true,
+          latencySetting: {
+            enabled: true
+          },
           transcoding: {
             enabled: false
           }
@@ -88,6 +89,7 @@ describe('Test live', function () {
         commentsEnabled: false,
         downloadEnabled: false,
         saveReplay: true,
+        latencyMode: LiveVideoLatencyMode.SMALL_LATENCY,
         privacy: VideoPrivacy.PUBLIC,
         previewfile: 'video_short1-preview.webm.jpg',
         thumbnailfile: 'video_short1.webm.jpg'
@@ -129,11 +131,12 @@ describe('Test live', function () {
           expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
           expect(live.streamKey).to.not.be.empty
         } else {
-          expect(live.rtmpUrl).to.be.null
-          expect(live.streamKey).to.be.null
+          expect(live.rtmpUrl).to.not.exist
+          expect(live.streamKey).to.not.exist
         }
 
         expect(live.saveReplay).to.be.true
+        expect(live.latencyMode).to.equal(LiveVideoLatencyMode.SMALL_LATENCY)
       }
     })
 
@@ -178,7 +181,7 @@ describe('Test live', function () {
     it('Should update the live', async function () {
       this.timeout(10000)
 
-      await commands[0].update({ videoId: liveVideoUUID, fields: { saveReplay: false } })
+      await commands[0].update({ videoId: liveVideoUUID, fields: { saveReplay: false, latencyMode: LiveVideoLatencyMode.DEFAULT } })
       await waitJobs(servers)
     })
 
@@ -190,11 +193,12 @@ describe('Test live', function () {
           expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
           expect(live.streamKey).to.not.be.empty
         } else {
-          expect(live.rtmpUrl).to.be.null
-          expect(live.streamKey).to.be.null
+          expect(live.rtmpUrl).to.not.exist
+          expect(live.streamKey).to.not.exist
         }
 
         expect(live.saveReplay).to.be.false
+        expect(live.latencyMode).to.equal(LiveVideoLatencyMode.DEFAULT)
       }
     })
 
@@ -421,6 +425,7 @@ describe('Test live', function () {
             transcoding: {
               enabled: true,
               resolutions: {
+                '144p': resolutions.includes(144),
                 '240p': resolutions.includes(240),
                 '360p': resolutions.includes(360),
                 '480p': resolutions.includes(480),
@@ -497,7 +502,7 @@ describe('Test live', function () {
     })
 
     it('Should enable transcoding with some resolutions and correctly save them', async function () {
-      this.timeout(200000)
+      this.timeout(400_000)
 
       const resolutions = [ 240, 360, 720 ]
 
@@ -564,7 +569,7 @@ describe('Test live', function () {
           const segmentPath = servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
 
           const probe = await ffprobePromise(segmentPath)
-          const videoStream = await getVideoStreamFromFile(segmentPath, probe)
+          const videoStream = await getVideoStream(segmentPath, probe)
 
           expect(probe.format.bit_rate).to.be.below(maxBitrateLimits[videoStream.height])
           expect(probe.format.bit_rate).to.be.at.least(minBitrateLimits[videoStream.height])
@@ -578,7 +583,7 @@ describe('Test live', function () {
     it('Should correctly have cleaned up the live files', async function () {
       this.timeout(30000)
 
-      await checkLiveCleanupAfterSave(servers[0], liveVideoId, [ 240, 360, 720 ])
+      await checkLiveCleanup(servers[0], liveVideoId, [ 240, 360, 720 ])
     })
   })