aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts15
-rw-r--r--server/lib/live/live-manager.ts33
2 files changed, 36 insertions, 12 deletions
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts
index c6263f55a..2f3a971bd 100644
--- a/server/lib/job-queue/handlers/video-live-ending.ts
+++ b/server/lib/job-queue/handlers/video-live-ending.ts
@@ -19,6 +19,7 @@ import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@serv
19import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' 19import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
20import { logger, loggerTagsFactory } from '../../../helpers/logger' 20import { logger, loggerTagsFactory } from '../../../helpers/logger'
21import { VideoPathManager } from '@server/lib/video-path-manager' 21import { VideoPathManager } from '@server/lib/video-path-manager'
22import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting'
22 23
23const lTags = loggerTagsFactory('live', 'job') 24const lTags = loggerTagsFactory('live', 'job')
24 25
@@ -60,7 +61,13 @@ async function processVideoLiveEnding (job: Job) {
60 return cleanupLiveAndFederate({ permanentLive, video, streamingPlaylistId: payload.streamingPlaylistId }) 61 return cleanupLiveAndFederate({ permanentLive, video, streamingPlaylistId: payload.streamingPlaylistId })
61 } 62 }
62 63
63 return replaceLiveByReplay({ video, liveSession, live, permanentLive, replayDirectory: payload.replayDirectory }) 64 return replaceLiveByReplay({
65 video,
66 liveSession,
67 live,
68 permanentLive,
69 replayDirectory: payload.replayDirectory
70 })
64} 71}
65 72
66// --------------------------------------------------------------------------- 73// ---------------------------------------------------------------------------
@@ -79,6 +86,8 @@ async function saveReplayToExternalVideo (options: {
79}) { 86}) {
80 const { liveVideo, liveSession, publishedAt, replayDirectory } = options 87 const { liveVideo, liveSession, publishedAt, replayDirectory } = options
81 88
89 const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId)
90
82 const replayVideo = new VideoModel({ 91 const replayVideo = new VideoModel({
83 name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`, 92 name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`,
84 isLive: false, 93 isLive: false,
@@ -95,7 +104,7 @@ async function saveReplayToExternalVideo (options: {
95 nsfw: liveVideo.nsfw, 104 nsfw: liveVideo.nsfw,
96 description: liveVideo.description, 105 description: liveVideo.description,
97 support: liveVideo.support, 106 support: liveVideo.support,
98 privacy: liveVideo.privacy, 107 privacy: replaySettings.privacy,
99 channelId: liveVideo.channelId 108 channelId: liveVideo.channelId
100 }) as MVideoWithAllFiles 109 }) as MVideoWithAllFiles
101 110
@@ -142,6 +151,7 @@ async function replaceLiveByReplay (options: {
142}) { 151}) {
143 const { video, liveSession, live, permanentLive, replayDirectory } = options 152 const { video, liveSession, live, permanentLive, replayDirectory } = options
144 153
154 const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId)
145 const videoWithFiles = await VideoModel.loadFull(video.id) 155 const videoWithFiles = await VideoModel.loadFull(video.id)
146 const hlsPlaylist = videoWithFiles.getHLSPlaylist() 156 const hlsPlaylist = videoWithFiles.getHLSPlaylist()
147 157
@@ -150,6 +160,7 @@ async function replaceLiveByReplay (options: {
150 await live.destroy() 160 await live.destroy()
151 161
152 videoWithFiles.isLive = false 162 videoWithFiles.isLive = false
163 videoWithFiles.privacy = replaySettings.privacy
153 videoWithFiles.waitTranscoding = true 164 videoWithFiles.waitTranscoding = true
154 videoWithFiles.state = VideoState.TO_TRANSCODE 165 videoWithFiles.state = VideoState.TO_TRANSCODE
155 166
diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts
index 1d5b8bf14..05274955d 100644
--- a/server/lib/live/live-manager.ts
+++ b/server/lib/live/live-manager.ts
@@ -19,7 +19,7 @@ import { 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 { MVideo, MVideoLiveSession, MVideoLiveVideo } from '@server/types/models' 22import { MVideo, MVideoLiveSession, MVideoLiveVideo, MVideoLiveVideoWithSetting } from '@server/types/models'
23import { pick, wait } from '@shared/core-utils' 23import { pick, wait } from '@shared/core-utils'
24import { LiveVideoError, VideoState } from '@shared/models' 24import { LiveVideoError, VideoState } from '@shared/models'
25import { federateVideoIfNeeded } from '../activitypub/videos' 25import { federateVideoIfNeeded } from '../activitypub/videos'
@@ -30,6 +30,8 @@ import { Hooks } from '../plugins/hooks'
30import { LiveQuotaStore } from './live-quota-store' 30import { LiveQuotaStore } from './live-quota-store'
31import { cleanupAndDestroyPermanentLive } from './live-utils' 31import { cleanupAndDestroyPermanentLive } from './live-utils'
32import { MuxingSession } from './shared' 32import { MuxingSession } from './shared'
33import { sequelizeTypescript } from '@server/initializers/database'
34import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting'
33 35
34const NodeRtmpSession = require('node-media-server/src/node_rtmp_session') 36const NodeRtmpSession = require('node-media-server/src/node_rtmp_session')
35const context = require('node-media-server/src/node_core_ctx') 37const context = require('node-media-server/src/node_core_ctx')
@@ -270,7 +272,7 @@ class LiveManager {
270 272
271 private async runMuxingSession (options: { 273 private async runMuxingSession (options: {
272 sessionId: string 274 sessionId: string
273 videoLive: MVideoLiveVideo 275 videoLive: MVideoLiveVideoWithSetting
274 276
275 inputUrl: string 277 inputUrl: string
276 fps: number 278 fps: number
@@ -470,15 +472,26 @@ class LiveManager {
470 return resolutionsEnabled 472 return resolutionsEnabled
471 } 473 }
472 474
473 private saveStartingSession (videoLive: MVideoLiveVideo) { 475 private async saveStartingSession (videoLive: MVideoLiveVideoWithSetting) {
474 const liveSession = new VideoLiveSessionModel({ 476 const replaySettings = videoLive.saveReplay
475 startDate: new Date(), 477 ? new VideoLiveReplaySettingModel({
476 liveVideoId: videoLive.videoId, 478 privacy: videoLive.ReplaySetting.privacy
477 saveReplay: videoLive.saveReplay, 479 })
478 endingProcessed: false 480 : null
479 })
480 481
481 return liveSession.save() 482 return sequelizeTypescript.transaction(async t => {
483 if (videoLive.saveReplay) {
484 await replaySettings.save({ transaction: t })
485 }
486
487 return VideoLiveSessionModel.create({
488 startDate: new Date(),
489 liveVideoId: videoLive.videoId,
490 saveReplay: videoLive.saveReplay,
491 replaySettingId: videoLive.saveReplay ? replaySettings.id : null,
492 endingProcessed: false
493 }, { transaction: t })
494 })
482 } 495 }
483 496
484 private async saveEndingSession (videoId: number, error: LiveVideoError | null) { 497 private async saveEndingSession (videoId: number, error: LiveVideoError | null) {