]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/live/live-utils.ts
Fix live quota tests
[github/Chocobozzz/PeerTube.git] / server / lib / live / live-utils.ts
index c0dec9829b8cfe1a3b1b6d2f8dcf34283a4d2a4d..3fb3ce1cee998886f96f8f3dce6d0888b678f0dc 100644 (file)
@@ -1,8 +1,9 @@
 import { pathExists, readdir, remove } from 'fs-extra'
 import { basename, join } from 'path'
 import { logger } from '@server/helpers/logger'
+import { VIDEO_LIVE } from '@server/initializers/constants'
 import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models'
-import { VideoStorage } from '@shared/models'
+import { LiveVideoLatencyMode, VideoStorage } from '@shared/models'
 import { listHLSFileKeysOf, removeHLSFileObjectStorageByFullKey, removeHLSObjectStorage } from '../object-storage'
 import { getLiveDirectory } from '../paths'
 
@@ -37,10 +38,19 @@ async function cleanupTMPLiveFiles (video: MVideo, streamingPlaylist: MStreaming
   await cleanupTMPLiveFilesFromFilesystem(video)
 }
 
+function getLiveSegmentTime (latencyMode: LiveVideoLatencyMode) {
+  if (latencyMode === LiveVideoLatencyMode.SMALL_LATENCY) {
+    return VIDEO_LIVE.SEGMENT_TIME_SECONDS.SMALL_LATENCY
+  }
+
+  return VIDEO_LIVE.SEGMENT_TIME_SECONDS.DEFAULT_LATENCY
+}
+
 export {
   cleanupAndDestroyPermanentLive,
   cleanupUnsavedNormalLive,
   cleanupTMPLiveFiles,
+  getLiveSegmentTime,
   buildConcatenatedName
 }