aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
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/initializers
parent01dd04cd5ab7b55d2a9af7d0ebf405bee9579b09 (diff)
downloadPeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.tar.gz
PeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.tar.zst
PeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.zip
Add latency setting support
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/checker-before-init.ts4
-rw-r--r--server/initializers/config.ts6
-rw-r--r--server/initializers/constants.ts10
-rw-r--r--server/initializers/migrations/0690-live-latency-mode.ts35
4 files changed, 49 insertions, 6 deletions
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 10dd98f43..fa311f708 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -49,8 +49,8 @@ function checkMissedConfig () {
49 'peertube.check_latest_version.enabled', 'peertube.check_latest_version.url', 49 'peertube.check_latest_version.enabled', 'peertube.check_latest_version.url',
50 'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url', 50 'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url',
51 'search.search_index.disable_local_search', 'search.search_index.is_default_search', 51 'search.search_index.disable_local_search', 'search.search_index.is_default_search',
52 'live.enabled', 'live.allow_replay', 'live.max_duration', 'live.max_user_lives', 'live.max_instance_lives', 52 'live.enabled', 'live.allow_replay', 'live.latency_setting.enabled', 'live.max_duration',
53 'live.rtmp.enabled', 'live.rtmp.port', 'live.rtmp.hostname', 53 'live.max_user_lives', 'live.max_instance_lives', 'live.rtmp.enabled', 'live.rtmp.port', 'live.rtmp.hostname',
54 'live.rtmps.enabled', 'live.rtmps.port', 'live.rtmps.hostname', 'live.rtmps.key_file', 'live.rtmps.cert_file', 54 'live.rtmps.enabled', 'live.rtmps.port', 'live.rtmps.hostname', 'live.rtmps.key_file', 'live.rtmps.cert_file',
55 'live.transcoding.enabled', 'live.transcoding.threads', 'live.transcoding.profile', 55 'live.transcoding.enabled', 'live.transcoding.threads', 'live.transcoding.profile',
56 'live.transcoding.resolutions.144p', 'live.transcoding.resolutions.240p', 'live.transcoding.resolutions.360p', 56 'live.transcoding.resolutions.144p', 'live.transcoding.resolutions.240p', 'live.transcoding.resolutions.360p',
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 7a13a1368..6dcca9b67 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -4,9 +4,9 @@ import { dirname, join } from 'path'
4import { decacheModule } from '@server/helpers/decache' 4import { decacheModule } from '@server/helpers/decache'
5import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' 5import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
6import { BroadcastMessageLevel } from '@shared/models/server' 6import { BroadcastMessageLevel } from '@shared/models/server'
7import { buildPath, root } from '../../shared/core-utils'
7import { VideoPrivacy, VideosRedundancyStrategy } from '../../shared/models' 8import { VideoPrivacy, VideosRedundancyStrategy } from '../../shared/models'
8import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' 9import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
9import { buildPath, root } from '../../shared/core-utils'
10import { parseBytes, parseDurationToMs } from '../helpers/core-utils' 10import { parseBytes, parseDurationToMs } from '../helpers/core-utils'
11 11
12// Use a variable to reload the configuration if we need 12// Use a variable to reload the configuration if we need
@@ -296,6 +296,10 @@ const CONFIG = {
296 296
297 get ALLOW_REPLAY () { return config.get<boolean>('live.allow_replay') }, 297 get ALLOW_REPLAY () { return config.get<boolean>('live.allow_replay') },
298 298
299 LATENCY_SETTING: {
300 get ENABLED () { return config.get<boolean>('live.latency_setting.enabled') }
301 },
302
299 RTMP: { 303 RTMP: {
300 get ENABLED () { return config.get<boolean>('live.rtmp.enabled') }, 304 get ENABLED () { return config.get<boolean>('live.rtmp.enabled') },
301 get PORT () { return config.get<number>('live.rtmp.port') }, 305 get PORT () { return config.get<number>('live.rtmp.port') },
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 7bc2877aa..1c849b561 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
24 24
25// --------------------------------------------------------------------------- 25// ---------------------------------------------------------------------------
26 26
27const LAST_MIGRATION_VERSION = 685 27const LAST_MIGRATION_VERSION = 690
28 28
29// --------------------------------------------------------------------------- 29// ---------------------------------------------------------------------------
30 30
@@ -700,7 +700,10 @@ const RESUMABLE_UPLOAD_SESSION_LIFETIME = SCHEDULER_INTERVALS_MS.REMOVE_DANGLING
700const VIDEO_LIVE = { 700const VIDEO_LIVE = {
701 EXTENSION: '.ts', 701 EXTENSION: '.ts',
702 CLEANUP_DELAY: 1000 * 60 * 5, // 5 minutes 702 CLEANUP_DELAY: 1000 * 60 * 5, // 5 minutes
703 SEGMENT_TIME_SECONDS: 4, // 4 seconds 703 SEGMENT_TIME_SECONDS: {
704 DEFAULT_LATENCY: 4, // 4 seconds
705 SMALL_LATENCY: 2 // 2 seconds
706 },
704 SEGMENTS_LIST_SIZE: 15, // 15 maximum segments in live playlist 707 SEGMENTS_LIST_SIZE: 15, // 15 maximum segments in live playlist
705 REPLAY_DIRECTORY: 'replay', 708 REPLAY_DIRECTORY: 'replay',
706 EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION: 4, 709 EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION: 4,
@@ -842,7 +845,8 @@ if (isTestInstance() === true) {
842 PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 5000 845 PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 5000
843 846
844 VIDEO_LIVE.CLEANUP_DELAY = 5000 847 VIDEO_LIVE.CLEANUP_DELAY = 5000
845 VIDEO_LIVE.SEGMENT_TIME_SECONDS = 2 848 VIDEO_LIVE.SEGMENT_TIME_SECONDS.DEFAULT_LATENCY = 2
849 VIDEO_LIVE.SEGMENT_TIME_SECONDS.SMALL_LATENCY = 1
846 VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION = 1 850 VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION = 1
847} 851}
848 852
diff --git a/server/initializers/migrations/0690-live-latency-mode.ts b/server/initializers/migrations/0690-live-latency-mode.ts
new file mode 100644
index 000000000..c31a61364
--- /dev/null
+++ b/server/initializers/migrations/0690-live-latency-mode.ts
@@ -0,0 +1,35 @@
1import { LiveVideoLatencyMode } from '@shared/models'
2import * as Sequelize from 'sequelize'
3
4async function up (utils: {
5 transaction: Sequelize.Transaction
6 queryInterface: Sequelize.QueryInterface
7 sequelize: Sequelize.Sequelize
8 db: any
9}): Promise<void> {
10 await utils.queryInterface.addColumn('videoLive', 'latencyMode', {
11 type: Sequelize.INTEGER,
12 defaultValue: null,
13 allowNull: true
14 }, { transaction: utils.transaction })
15
16 {
17 const query = `UPDATE "videoLive" SET "latencyMode" = ${LiveVideoLatencyMode.DEFAULT}`
18 await utils.sequelize.query(query, { type: Sequelize.QueryTypes.UPDATE, transaction: utils.transaction })
19 }
20
21 await utils.queryInterface.changeColumn('videoLive', 'latencyMode', {
22 type: Sequelize.INTEGER,
23 defaultValue: null,
24 allowNull: false
25 }, { transaction: utils.transaction })
26}
27
28function down () {
29 throw new Error('Not implemented.')
30}
31
32export {
33 up,
34 down
35}