From fb7194043d0486ce0a6a40b2ffbdf32878c33a6f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 25 Sep 2020 16:19:35 +0200 Subject: Check live duration and size --- server/initializers/checker-after-init.ts | 7 +++++++ server/initializers/checker-before-init.ts | 7 ++++++- server/initializers/config.ts | 3 +++ server/initializers/constants.ts | 7 +++++-- server/initializers/migrations/0535-video-live.ts | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) (limited to 'server/initializers') diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index b49ab6bca..979c97a8b 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts @@ -135,6 +135,13 @@ function checkConfig () { } } + // Live + if (CONFIG.LIVE.ENABLED === true) { + if (CONFIG.LIVE.ALLOW_REPLAY === true && CONFIG.TRANSCODING.ENABLED === false) { + return 'Live allow replay cannot be enabled if transcoding is not enabled.' + } + } + return null } diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index e0819c4aa..d4140e3fa 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts @@ -37,8 +37,13 @@ function checkMissedConfig () { 'remote_redundancy.videos.accept_from', 'federation.videos.federate_unlisted', 'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url', - 'search.search_index.disable_local_search', 'search.search_index.is_default_search' + 'search.search_index.disable_local_search', 'search.search_index.is_default_search', + 'live.enabled', 'live.allow_replay', 'live.max_duration', + 'live.transcoding.enabled', 'live.transcoding.threads', + 'live.transcoding.resolutions.240p', 'live.transcoding.resolutions.360p', 'live.transcoding.resolutions.480p', + 'live.transcoding.resolutions.720p', 'live.transcoding.resolutions.1080p', 'live.transcoding.resolutions.2160p' ] + const requiredAlternatives = [ [ // set [ 'redis.hostname', 'redis.port' ], // alternative diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 7a8200ed9..9e8927350 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -201,6 +201,9 @@ const CONFIG = { LIVE: { get ENABLED () { return config.get('live.enabled') }, + get MAX_DURATION () { return parseDurationToMs(config.get('live.max_duration')) }, + get ALLOW_REPLAY () { return config.get('live.allow_replay') }, + RTMP: { get PORT () { return config.get('live.rtmp.port') } }, diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 82d04a94e..065012b32 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -608,7 +608,9 @@ const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') const VIDEO_LIVE = { EXTENSION: '.ts', - CLEANUP_DELAY: 1000 * 60 * 5, // 5 mintues + CLEANUP_DELAY: 1000 * 60 * 5, // 5 minutes + SEGMENT_TIME: 4, // 4 seconds + SEGMENTS_LIST_SIZE: 15, // 15 maximum segments in live playlist RTMP: { CHUNK_SIZE: 60000, GOP_CACHE: true, @@ -620,7 +622,8 @@ const VIDEO_LIVE = { const MEMOIZE_TTL = { OVERVIEWS_SAMPLE: 1000 * 3600 * 4, // 4 hours - INFO_HASH_EXISTS: 1000 * 3600 * 12 // 12 hours + INFO_HASH_EXISTS: 1000 * 3600 * 12, // 12 hours + LIVE_ABLE_TO_UPLOAD: 1000 * 60 // 1 minute } const MEMOIZE_LENGTH = { diff --git a/server/initializers/migrations/0535-video-live.ts b/server/initializers/migrations/0535-video-live.ts index 35523efc4..7501e080b 100644 --- a/server/initializers/migrations/0535-video-live.ts +++ b/server/initializers/migrations/0535-video-live.ts @@ -9,7 +9,7 @@ async function up (utils: { const query = ` CREATE TABLE IF NOT EXISTS "videoLive" ( "id" SERIAL , - "streamKey" VARCHAR(255) NOT NULL, + "streamKey" VARCHAR(255), "videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, -- cgit v1.2.3