aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/live/live-manager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/live/live-manager.ts')
-rw-r--r--server/lib/live/live-manager.ts34
1 files changed, 5 insertions, 29 deletions
diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts
index fa4e1df07..1d5b8bf14 100644
--- a/server/lib/live/live-manager.ts
+++ b/server/lib/live/live-manager.ts
@@ -13,18 +13,18 @@ import {
13} from '@server/helpers/ffmpeg' 13} from '@server/helpers/ffmpeg'
14import { logger, loggerTagsFactory } from '@server/helpers/logger' 14import { logger, loggerTagsFactory } from '@server/helpers/logger'
15import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' 15import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config'
16import { P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE } from '@server/initializers/constants' 16import { VIDEO_LIVE } from '@server/initializers/constants'
17import { UserModel } from '@server/models/user/user' 17import { UserModel } from '@server/models/user/user'
18import { VideoModel } from '@server/models/video/video' 18import { VideoModel } from '@server/models/video/video'
19import { VideoLiveModel } from '@server/models/video/video-live' 19import { VideoLiveModel } from '@server/models/video/video-live'
20import { VideoLiveSessionModel } from '@server/models/video/video-live-session' 20import { VideoLiveSessionModel } from '@server/models/video/video-live-session'
21import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' 21import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
22import { MStreamingPlaylistVideo, MVideo, MVideoLiveSession, MVideoLiveVideo } from '@server/types/models' 22import { MVideo, MVideoLiveSession, MVideoLiveVideo } from '@server/types/models'
23import { pick, wait } from '@shared/core-utils' 23import { pick, wait } from '@shared/core-utils'
24import { LiveVideoError, VideoState, VideoStorage, VideoStreamingPlaylistType } from '@shared/models' 24import { LiveVideoError, VideoState } from '@shared/models'
25import { federateVideoIfNeeded } from '../activitypub/videos' 25import { federateVideoIfNeeded } from '../activitypub/videos'
26import { JobQueue } from '../job-queue' 26import { JobQueue } from '../job-queue'
27import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '../paths' 27import { getLiveReplayBaseDirectory } from '../paths'
28import { PeerTubeSocket } from '../peertube-socket' 28import { PeerTubeSocket } from '../peertube-socket'
29import { Hooks } from '../plugins/hooks' 29import { Hooks } from '../plugins/hooks'
30import { LiveQuotaStore } from './live-quota-store' 30import { LiveQuotaStore } from './live-quota-store'
@@ -255,13 +255,10 @@ class LiveManager {
255 { allResolutions, ...lTags(sessionId, video.uuid) } 255 { allResolutions, ...lTags(sessionId, video.uuid) }
256 ) 256 )
257 257
258 const streamingPlaylist = await this.createLivePlaylist(video, allResolutions)
259
260 return this.runMuxingSession({ 258 return this.runMuxingSession({
261 sessionId, 259 sessionId,
262 videoLive, 260 videoLive,
263 261
264 streamingPlaylist,
265 inputUrl, 262 inputUrl,
266 fps, 263 fps,
267 bitrate, 264 bitrate,
@@ -275,7 +272,6 @@ class LiveManager {
275 sessionId: string 272 sessionId: string
276 videoLive: MVideoLiveVideo 273 videoLive: MVideoLiveVideo
277 274
278 streamingPlaylist: MStreamingPlaylistVideo
279 inputUrl: string 275 inputUrl: string
280 fps: number 276 fps: number
281 bitrate: number 277 bitrate: number
@@ -298,7 +294,7 @@ class LiveManager {
298 videoLive, 294 videoLive,
299 user, 295 user,
300 296
301 ...pick(options, [ 'streamingPlaylist', 'inputUrl', 'bitrate', 'ratio', 'fps', 'allResolutions', 'hasAudio' ]) 297 ...pick(options, [ 'inputUrl', 'bitrate', 'ratio', 'fps', 'allResolutions', 'hasAudio' ])
302 }) 298 })
303 299
304 muxingSession.on('live-ready', () => this.publishAndFederateLive(videoLive, localLTags)) 300 muxingSession.on('live-ready', () => this.publishAndFederateLive(videoLive, localLTags))
@@ -474,26 +470,6 @@ class LiveManager {
474 return resolutionsEnabled 470 return resolutionsEnabled
475 } 471 }
476 472
477 private async createLivePlaylist (video: MVideo, allResolutions: number[]): Promise<MStreamingPlaylistVideo> {
478 const playlist = await VideoStreamingPlaylistModel.loadOrGenerate(video)
479
480 playlist.playlistFilename = generateHLSMasterPlaylistFilename(true)
481 playlist.segmentsSha256Filename = generateHlsSha256SegmentsFilename(true)
482
483 playlist.p2pMediaLoaderPeerVersion = P2P_MEDIA_LOADER_PEER_VERSION
484 playlist.type = VideoStreamingPlaylistType.HLS
485
486 playlist.storage = CONFIG.OBJECT_STORAGE.ENABLED
487 ? VideoStorage.OBJECT_STORAGE
488 : VideoStorage.FILE_SYSTEM
489
490 if (playlist.storage === VideoStorage.FILE_SYSTEM) {
491 playlist.assignP2PMediaLoaderInfoHashes(video, allResolutions)
492 }
493
494 return playlist.save()
495 }
496
497 private saveStartingSession (videoLive: MVideoLiveVideo) { 473 private saveStartingSession (videoLive: MVideoLiveVideo) {
498 const liveSession = new VideoLiveSessionModel({ 474 const liveSession = new VideoLiveSessionModel({
499 startDate: new Date(), 475 startDate: new Date(),