diff options
Diffstat (limited to 'server/lib/live/live-manager.ts')
-rw-r--r-- | server/lib/live/live-manager.ts | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts index 014cd3fcf..f106d69fb 100644 --- a/server/lib/live/live-manager.ts +++ b/server/lib/live/live-manager.ts | |||
@@ -4,24 +4,25 @@ import { isTestInstance } from '@server/helpers/core-utils' | |||
4 | import { computeResolutionsToTranscode, getVideoFileFPS, getVideoFileResolution } from '@server/helpers/ffprobe-utils' | 4 | import { computeResolutionsToTranscode, getVideoFileFPS, getVideoFileResolution } from '@server/helpers/ffprobe-utils' |
5 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 5 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
6 | import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' | 6 | import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' |
7 | import { P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE, VIEW_LIFETIME, WEBSERVER } from '@server/initializers/constants' | 7 | import { P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE, VIEW_LIFETIME } from '@server/initializers/constants' |
8 | import { UserModel } from '@server/models/user/user' | 8 | import { UserModel } from '@server/models/user/user' |
9 | import { VideoModel } from '@server/models/video/video' | 9 | import { VideoModel } from '@server/models/video/video' |
10 | import { VideoLiveModel } from '@server/models/video/video-live' | 10 | import { VideoLiveModel } from '@server/models/video/video-live' |
11 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | 11 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' |
12 | import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoLiveVideo } from '@server/types/models' | 12 | import { MStreamingPlaylistVideo, MVideo, MVideoLiveVideo } from '@server/types/models' |
13 | import { VideoState, VideoStreamingPlaylistType } from '@shared/models' | 13 | import { VideoState, VideoStreamingPlaylistType } from '@shared/models' |
14 | import { federateVideoIfNeeded } from '../activitypub/videos' | 14 | import { federateVideoIfNeeded } from '../activitypub/videos' |
15 | import { JobQueue } from '../job-queue' | 15 | import { JobQueue } from '../job-queue' |
16 | import { PeerTubeSocket } from '../peertube-socket' | 16 | import { PeerTubeSocket } from '../peertube-socket' |
17 | import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename } from '../video-paths' | ||
17 | import { LiveQuotaStore } from './live-quota-store' | 18 | import { LiveQuotaStore } from './live-quota-store' |
18 | import { LiveSegmentShaStore } from './live-segment-sha-store' | 19 | import { LiveSegmentShaStore } from './live-segment-sha-store' |
19 | import { cleanupLive } from './live-utils' | 20 | import { cleanupLive } from './live-utils' |
20 | import { MuxingSession } from './shared' | 21 | import { MuxingSession } from './shared' |
21 | 22 | ||
22 | const NodeRtmpSession = require('node-media-server/node_rtmp_session') | 23 | const NodeRtmpSession = require('node-media-server/src/node_rtmp_session') |
23 | const context = require('node-media-server/node_core_ctx') | 24 | const context = require('node-media-server/src/node_core_ctx') |
24 | const nodeMediaServerLogger = require('node-media-server/node_core_logger') | 25 | const nodeMediaServerLogger = require('node-media-server/src/node_core_logger') |
25 | 26 | ||
26 | // Disable node media server logs | 27 | // Disable node media server logs |
27 | nodeMediaServerLogger.setLogType(0) | 28 | nodeMediaServerLogger.setLogType(0) |
@@ -392,19 +393,18 @@ class LiveManager { | |||
392 | return resolutionsEnabled.concat([ originResolution ]) | 393 | return resolutionsEnabled.concat([ originResolution ]) |
393 | } | 394 | } |
394 | 395 | ||
395 | private async createLivePlaylist (video: MVideo, allResolutions: number[]) { | 396 | private async createLivePlaylist (video: MVideo, allResolutions: number[]): Promise<MStreamingPlaylistVideo> { |
396 | const playlistUrl = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) | 397 | const playlist = await VideoStreamingPlaylistModel.loadOrGenerate(video) |
397 | const [ videoStreamingPlaylist ] = await VideoStreamingPlaylistModel.upsert({ | ||
398 | videoId: video.id, | ||
399 | playlistUrl, | ||
400 | segmentsSha256Url: WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid, video.isLive), | ||
401 | p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, allResolutions), | ||
402 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, | ||
403 | 398 | ||
404 | type: VideoStreamingPlaylistType.HLS | 399 | playlist.playlistFilename = generateHLSMasterPlaylistFilename(true) |
405 | }, { returning: true }) as [ MStreamingPlaylist, boolean ] | 400 | playlist.segmentsSha256Filename = generateHlsSha256SegmentsFilename(true) |
406 | 401 | ||
407 | return Object.assign(videoStreamingPlaylist, { Video: video }) | 402 | playlist.p2pMediaLoaderPeerVersion = P2P_MEDIA_LOADER_PEER_VERSION |
403 | playlist.type = VideoStreamingPlaylistType.HLS | ||
404 | |||
405 | playlist.assignP2PMediaLoaderInfoHashes(video, allResolutions) | ||
406 | |||
407 | return playlist.save() | ||
408 | } | 408 | } |
409 | 409 | ||
410 | static get Instance () { | 410 | static get Instance () { |