aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/live
diff options
context:
space:
mode:
authorWicklow <123956049+wickloww@users.noreply.github.com>2023-03-31 07:12:21 +0000
committerGitHub <noreply@github.com>2023-03-31 09:12:21 +0200
commit05a60d85997c108d39bcfb14f1ffd4c74f8b1e93 (patch)
tree5041a95ef945620a17f25ba934064b41f6bb00b7 /server/lib/live
parentebd61437c1ec92bea9772924c7051cb00d71f778 (diff)
downloadPeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.tar.gz
PeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.tar.zst
PeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.zip
Feature/Add replay privacy (#5692)
* Add replay settings feature * Fix replay settings behaviour * Fix tests * Fix tests * Fix tests * Update openapi doc and fix tests * Add tests and fix code * Models correction * Add migration and update controller and middleware * Add check params tests * Fix video live middleware * Updated code based on review comments
Diffstat (limited to 'server/lib/live')
-rw-r--r--server/lib/live/live-manager.ts33
1 files changed, 23 insertions, 10 deletions
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) {