From afb371d940531a5a8aafb5895b369b9cdecd555b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Jan 2023 09:04:02 +0100 Subject: Refactor playlist creation for lives --- server/lib/live/live-manager.ts | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'server/lib/live/live-manager.ts') 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 { } from '@server/helpers/ffmpeg' import { logger, loggerTagsFactory } from '@server/helpers/logger' import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' -import { P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE } from '@server/initializers/constants' +import { VIDEO_LIVE } from '@server/initializers/constants' import { UserModel } from '@server/models/user/user' import { VideoModel } from '@server/models/video/video' import { VideoLiveModel } from '@server/models/video/video-live' import { VideoLiveSessionModel } from '@server/models/video/video-live-session' import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' -import { MStreamingPlaylistVideo, MVideo, MVideoLiveSession, MVideoLiveVideo } from '@server/types/models' +import { MVideo, MVideoLiveSession, MVideoLiveVideo } from '@server/types/models' import { pick, wait } from '@shared/core-utils' -import { LiveVideoError, VideoState, VideoStorage, VideoStreamingPlaylistType } from '@shared/models' +import { LiveVideoError, VideoState } from '@shared/models' import { federateVideoIfNeeded } from '../activitypub/videos' import { JobQueue } from '../job-queue' -import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '../paths' +import { getLiveReplayBaseDirectory } from '../paths' import { PeerTubeSocket } from '../peertube-socket' import { Hooks } from '../plugins/hooks' import { LiveQuotaStore } from './live-quota-store' @@ -255,13 +255,10 @@ class LiveManager { { allResolutions, ...lTags(sessionId, video.uuid) } ) - const streamingPlaylist = await this.createLivePlaylist(video, allResolutions) - return this.runMuxingSession({ sessionId, videoLive, - streamingPlaylist, inputUrl, fps, bitrate, @@ -275,7 +272,6 @@ class LiveManager { sessionId: string videoLive: MVideoLiveVideo - streamingPlaylist: MStreamingPlaylistVideo inputUrl: string fps: number bitrate: number @@ -298,7 +294,7 @@ class LiveManager { videoLive, user, - ...pick(options, [ 'streamingPlaylist', 'inputUrl', 'bitrate', 'ratio', 'fps', 'allResolutions', 'hasAudio' ]) + ...pick(options, [ 'inputUrl', 'bitrate', 'ratio', 'fps', 'allResolutions', 'hasAudio' ]) }) muxingSession.on('live-ready', () => this.publishAndFederateLive(videoLive, localLTags)) @@ -474,26 +470,6 @@ class LiveManager { return resolutionsEnabled } - private async createLivePlaylist (video: MVideo, allResolutions: number[]): Promise { - const playlist = await VideoStreamingPlaylistModel.loadOrGenerate(video) - - playlist.playlistFilename = generateHLSMasterPlaylistFilename(true) - playlist.segmentsSha256Filename = generateHlsSha256SegmentsFilename(true) - - playlist.p2pMediaLoaderPeerVersion = P2P_MEDIA_LOADER_PEER_VERSION - playlist.type = VideoStreamingPlaylistType.HLS - - playlist.storage = CONFIG.OBJECT_STORAGE.ENABLED - ? VideoStorage.OBJECT_STORAGE - : VideoStorage.FILE_SYSTEM - - if (playlist.storage === VideoStorage.FILE_SYSTEM) { - playlist.assignP2PMediaLoaderInfoHashes(video, allResolutions) - } - - return playlist.save() - } - private saveStartingSession (videoLive: MVideoLiveVideo) { const liveSession = new VideoLiveSessionModel({ startDate: new Date(), -- cgit v1.2.3