diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-16 15:14:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-17 08:47:03 +0200 |
commit | 8ebf2a5d5d126e6ef9b89109124adf2a5e9e293d (patch) | |
tree | eee3ef972943be629519c2dc97928878dbd2d732 /server/lib/job-queue | |
parent | fd6584844b070cfc283902aba26f2853473e83d1 (diff) | |
download | PeerTube-8ebf2a5d5d126e6ef9b89109124adf2a5e9e293d.tar.gz PeerTube-8ebf2a5d5d126e6ef9b89109124adf2a5e9e293d.tar.zst PeerTube-8ebf2a5d5d126e6ef9b89109124adf2a5e9e293d.zip |
Refactor live manager
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r-- | server/lib/job-queue/handlers/video-live-ending.ts | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 517b90abc..9eba41bf8 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts | |||
@@ -3,7 +3,7 @@ import { pathExists, readdir, remove } from 'fs-extra' | |||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' | 4 | import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' |
5 | import { VIDEO_LIVE } from '@server/initializers/constants' | 5 | import { VIDEO_LIVE } from '@server/initializers/constants' |
6 | import { LiveManager } from '@server/lib/live-manager' | 6 | import { buildConcatenatedName, cleanupLive, LiveSegmentShaStore } from '@server/lib/live' |
7 | import { generateVideoMiniature } from '@server/lib/thumbnail' | 7 | import { generateVideoMiniature } from '@server/lib/thumbnail' |
8 | import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/video-transcoding' | 8 | import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/video-transcoding' |
9 | import { publishAndFederateIfNeeded } from '@server/lib/video' | 9 | import { publishAndFederateIfNeeded } from '@server/lib/video' |
@@ -12,7 +12,7 @@ import { VideoModel } from '@server/models/video/video' | |||
12 | import { VideoFileModel } from '@server/models/video/video-file' | 12 | import { VideoFileModel } from '@server/models/video/video-file' |
13 | import { VideoLiveModel } from '@server/models/video/video-live' | 13 | import { VideoLiveModel } from '@server/models/video/video-live' |
14 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | 14 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' |
15 | import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models' | 15 | import { MVideo, MVideoLive } from '@server/types/models' |
16 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' | 16 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' |
17 | import { logger } from '../../../helpers/logger' | 17 | import { logger } from '../../../helpers/logger' |
18 | 18 | ||
@@ -37,7 +37,7 @@ async function processVideoLiveEnding (job: Bull.Job) { | |||
37 | return | 37 | return |
38 | } | 38 | } |
39 | 39 | ||
40 | LiveManager.Instance.cleanupShaSegments(video.uuid) | 40 | LiveSegmentShaStore.Instance.cleanupShaSegments(video.uuid) |
41 | 41 | ||
42 | if (live.saveReplay !== true) { | 42 | if (live.saveReplay !== true) { |
43 | return cleanupLive(video, streamingPlaylist) | 43 | return cleanupLive(video, streamingPlaylist) |
@@ -46,19 +46,10 @@ async function processVideoLiveEnding (job: Bull.Job) { | |||
46 | return saveLive(video, live) | 46 | return saveLive(video, live) |
47 | } | 47 | } |
48 | 48 | ||
49 | async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { | ||
50 | const hlsDirectory = getHLSDirectory(video) | ||
51 | |||
52 | await remove(hlsDirectory) | ||
53 | |||
54 | await streamingPlaylist.destroy() | ||
55 | } | ||
56 | |||
57 | // --------------------------------------------------------------------------- | 49 | // --------------------------------------------------------------------------- |
58 | 50 | ||
59 | export { | 51 | export { |
60 | processVideoLiveEnding, | 52 | processVideoLiveEnding |
61 | cleanupLive | ||
62 | } | 53 | } |
63 | 54 | ||
64 | // --------------------------------------------------------------------------- | 55 | // --------------------------------------------------------------------------- |
@@ -94,7 +85,7 @@ async function saveLive (video: MVideo, live: MVideoLive) { | |||
94 | let durationDone = false | 85 | let durationDone = false |
95 | 86 | ||
96 | for (const playlistFile of playlistFiles) { | 87 | for (const playlistFile of playlistFiles) { |
97 | const concatenatedTsFile = LiveManager.Instance.buildConcatenatedName(playlistFile) | 88 | const concatenatedTsFile = buildConcatenatedName(playlistFile) |
98 | const concatenatedTsFilePath = join(replayDirectory, concatenatedTsFile) | 89 | const concatenatedTsFilePath = join(replayDirectory, concatenatedTsFile) |
99 | 90 | ||
100 | const probe = await ffprobePromise(concatenatedTsFilePath) | 91 | const probe = await ffprobePromise(concatenatedTsFilePath) |