X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Flive%2Flive-utils.ts;h=3fb3ce1cee998886f96f8f3dce6d0888b678f0dc;hb=0c9668f77901e7540e2c7045eb0f2974a4842a69;hp=d2b8e3a55b8c1469f2e84b1c0f137e92f6a18da7;hpb=cfd57d2ca0bb058087f7dc90fcc3e8442b0288e1;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/live/live-utils.ts b/server/lib/live/live-utils.ts index d2b8e3a55..3fb3ce1ce 100644 --- a/server/lib/live/live-utils.ts +++ b/server/lib/live/live-utils.ts @@ -1,9 +1,10 @@ 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 { listHLSFileKeysOf, removeHLSFileObjectStorage, removeHLSObjectStorage } from '../object-storage' +import { LiveVideoLatencyMode, VideoStorage } from '@shared/models' +import { listHLSFileKeysOf, removeHLSFileObjectStorageByFullKey, removeHLSObjectStorage } from '../object-storage' import { getLiveDirectory } from '../paths' function buildConcatenatedName (segmentOrPlaylistPath: string) { @@ -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 } @@ -77,11 +87,13 @@ async function cleanupTMPLiveFilesFromFilesystem (video: MVideo) { async function cleanupTMPLiveFilesFromObjectStorage (streamingPlaylist: MStreamingPlaylistVideo) { if (streamingPlaylist.storage !== VideoStorage.OBJECT_STORAGE) return + logger.info('Cleanup TMP live files from object storage for %s.', streamingPlaylist.Video.uuid) + const keys = await listHLSFileKeysOf(streamingPlaylist) for (const key of keys) { if (isTMPLiveFile(key)) { - await removeHLSFileObjectStorage(streamingPlaylist, key) + await removeHLSFileObjectStorageByFullKey(key) } } }