X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Flive-manager.ts;h=379f61bdf332de10b9491f2346b4631cb011bdf3;hb=9cfeb3cf989fffccdfe3e575903dc00baab255b2;hp=c2dd116a99847f34188a066af824268a196a6a03;hpb=3851e732c4b1da0bc0c40a46ed5a89d93cdc5389;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts index c2dd116a9..379f61bdf 100644 --- a/server/lib/live-manager.ts +++ b/server/lib/live-manager.ts @@ -1,7 +1,8 @@ +import * as Bluebird from 'bluebird' import * as chokidar from 'chokidar' import { FfmpegCommand } from 'fluent-ffmpeg' -import { appendFile, copy, ensureDir, readFile, stat } from 'fs-extra' +import { appendFile, ensureDir, readFile, stat } from 'fs-extra' import { basename, join } from 'path' import { isTestInstance } from '@server/helpers/core-utils' import { getLiveMuxingCommand, getLiveTranscodingCommand } from '@server/helpers/ffmpeg-utils' @@ -24,7 +25,6 @@ import { PeerTubeSocket } from './peertube-socket' import { isAbleToUploadVideo } from './user' import { getHLSDirectory } from './video-paths' import { availableEncoders } from './video-transcoding-profiles' -import * as Bluebird from 'bluebird' import memoizee = require('memoizee') @@ -287,16 +287,17 @@ class LiveManager { for (let i = 0; i < allResolutions.length; i++) { const resolution = allResolutions[i] - VideoFileModel.upsert({ + const file = new VideoFileModel({ resolution, size: -1, extname: '.ts', infoHash: null, fps, videoStreamingPlaylistId: playlist.id - }).catch(err => { - logger.error('Cannot create file for live streaming.', { err }) }) + + VideoFileModel.customUpsert(file, 'streaming-playlist', null) + .catch(err => logger.error('Cannot create file for live streaming.', { err })) } const outPath = getHLSDirectory(videoLive.Video) @@ -504,7 +505,7 @@ class LiveManager { private isDurationConstraintValid (streamingStartTime: number) { const maxDuration = CONFIG.LIVE.MAX_DURATION // No limit - if (maxDuration === null) return true + if (maxDuration < 0) return true const now = new Date().getTime() const max = streamingStartTime + maxDuration @@ -536,6 +537,8 @@ class LiveManager { await federateVideoIfNeeded(video, false) + PeerTubeSocket.Instance.sendVideoViewsUpdate(video) + // Only keep not expired watchers const newWatchers = watchers.filter(w => w > notBefore) this.watchersPerVideo.set(videoId, newWatchers)