aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-04 13:40:02 +0100
committerChocobozzz <chocobozzz@cpy.re>2022-03-09 09:23:10 +0100
commitf443a74649174b2f9347c158e30f8ac7aa3e958a (patch)
treee423bc4e2307477bda4341037b7fa04ad10adae6 /server/controllers/api
parent01dd04cd5ab7b55d2a9af7d0ebf405bee9579b09 (diff)
downloadPeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.tar.gz
PeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.tar.zst
PeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.zip
Add latency setting support
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/config.ts3
-rw-r--r--server/controllers/api/videos/live.ts9
2 files changed, 9 insertions, 3 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index 821ed4ad3..376143cb8 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -237,6 +237,9 @@ function customConfig (): CustomConfig {
237 live: { 237 live: {
238 enabled: CONFIG.LIVE.ENABLED, 238 enabled: CONFIG.LIVE.ENABLED,
239 allowReplay: CONFIG.LIVE.ALLOW_REPLAY, 239 allowReplay: CONFIG.LIVE.ALLOW_REPLAY,
240 latencySetting: {
241 enabled: CONFIG.LIVE.LATENCY_SETTING.ENABLED
242 },
240 maxDuration: CONFIG.LIVE.MAX_DURATION, 243 maxDuration: CONFIG.LIVE.MAX_DURATION,
241 maxInstanceLives: CONFIG.LIVE.MAX_INSTANCE_LIVES, 244 maxInstanceLives: CONFIG.LIVE.MAX_INSTANCE_LIVES,
242 maxUserLives: CONFIG.LIVE.MAX_USER_LIVES, 245 maxUserLives: CONFIG.LIVE.MAX_USER_LIVES,
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index 49cabb6f3..c6f038079 100644
--- a/server/controllers/api/videos/live.ts
+++ b/server/controllers/api/videos/live.ts
@@ -1,4 +1,5 @@
1import express from 'express' 1import express from 'express'
2import { exists } from '@server/helpers/custom-validators/misc'
2import { createReqFiles } from '@server/helpers/express-utils' 3import { createReqFiles } from '@server/helpers/express-utils'
3import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants' 4import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants'
4import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' 5import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
@@ -9,7 +10,7 @@ import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator
9import { VideoLiveModel } from '@server/models/video/video-live' 10import { VideoLiveModel } from '@server/models/video/video-live'
10import { MVideoDetails, MVideoFullLight } from '@server/types/models' 11import { MVideoDetails, MVideoFullLight } from '@server/types/models'
11import { buildUUID, uuidToShort } from '@shared/extra-utils' 12import { buildUUID, uuidToShort } from '@shared/extra-utils'
12import { HttpStatusCode, LiveVideoCreate, LiveVideoUpdate, VideoState } from '@shared/models' 13import { HttpStatusCode, LiveVideoCreate, LiveVideoLatencyMode, LiveVideoUpdate, VideoState } from '@shared/models'
13import { logger } from '../../../helpers/logger' 14import { logger } from '../../../helpers/logger'
14import { sequelizeTypescript } from '../../../initializers/database' 15import { sequelizeTypescript } from '../../../initializers/database'
15import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail' 16import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail'
@@ -60,8 +61,9 @@ async function updateLiveVideo (req: express.Request, res: express.Response) {
60 const video = res.locals.videoAll 61 const video = res.locals.videoAll
61 const videoLive = res.locals.videoLive 62 const videoLive = res.locals.videoLive
62 63
63 videoLive.saveReplay = body.saveReplay || false 64 if (exists(body.saveReplay)) videoLive.saveReplay = body.saveReplay
64 videoLive.permanentLive = body.permanentLive || false 65 if (exists(body.permanentLive)) videoLive.permanentLive = body.permanentLive
66 if (exists(body.latencyMode)) videoLive.latencyMode = body.latencyMode
65 67
66 video.VideoLive = await videoLive.save() 68 video.VideoLive = await videoLive.save()
67 69
@@ -87,6 +89,7 @@ async function addLiveVideo (req: express.Request, res: express.Response) {
87 const videoLive = new VideoLiveModel() 89 const videoLive = new VideoLiveModel()
88 videoLive.saveReplay = videoInfo.saveReplay || false 90 videoLive.saveReplay = videoInfo.saveReplay || false
89 videoLive.permanentLive = videoInfo.permanentLive || false 91 videoLive.permanentLive = videoInfo.permanentLive || false
92 videoLive.latencyMode = videoInfo.latencyMode || LiveVideoLatencyMode.DEFAULT
90 videoLive.streamKey = buildUUID() 93 videoLive.streamKey = buildUUID()
91 94
92 const [ thumbnailModel, previewModel ] = await buildVideoThumbnailsFromReq({ 95 const [ thumbnailModel, previewModel ] = await buildVideoThumbnailsFromReq({