diff options
-rw-r--r-- | client/src/assets/player/p2p-media-loader/segment-validator.ts | 4 | ||||
-rw-r--r-- | server/initializers/constants.ts | 2 | ||||
-rw-r--r-- | server/lib/live-manager.ts | 10 |
3 files changed, 11 insertions, 5 deletions
diff --git a/client/src/assets/player/p2p-media-loader/segment-validator.ts b/client/src/assets/player/p2p-media-loader/segment-validator.ts index 844956d6a..4a0caec5e 100644 --- a/client/src/assets/player/p2p-media-loader/segment-validator.ts +++ b/client/src/assets/player/p2p-media-loader/segment-validator.ts | |||
@@ -10,7 +10,7 @@ function segmentValidatorFactory (segmentsSha256Url: string, isLive: boolean) { | |||
10 | let segmentsJSON = fetchSha256Segments(segmentsSha256Url) | 10 | let segmentsJSON = fetchSha256Segments(segmentsSha256Url) |
11 | const regex = /bytes=(\d+)-(\d+)/ | 11 | const regex = /bytes=(\d+)-(\d+)/ |
12 | 12 | ||
13 | return async function segmentValidator (segment: Segment, retry = 1) { | 13 | return async function segmentValidator (segment: Segment, _method: string, _peerId: string, retry = 1) { |
14 | // Wait for hash generation from the server | 14 | // Wait for hash generation from the server |
15 | if (isLive) await wait(1000) | 15 | if (isLive) await wait(1000) |
16 | 16 | ||
@@ -28,7 +28,7 @@ function segmentValidatorFactory (segmentsSha256Url: string, isLive: boolean) { | |||
28 | await wait(1000) | 28 | await wait(1000) |
29 | 29 | ||
30 | segmentsJSON = fetchSha256Segments(segmentsSha256Url) | 30 | segmentsJSON = fetchSha256Segments(segmentsSha256Url) |
31 | await segmentValidator(segment, retry + 1) | 31 | await segmentValidator(segment, _method, _peerId, retry + 1) |
32 | 32 | ||
33 | return | 33 | return |
34 | } | 34 | } |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 679503731..02e42a594 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -620,6 +620,7 @@ const VIDEO_LIVE = { | |||
620 | CLEANUP_DELAY: 1000 * 60 * 5, // 5 minutes | 620 | CLEANUP_DELAY: 1000 * 60 * 5, // 5 minutes |
621 | SEGMENT_TIME_SECONDS: 4, // 4 seconds | 621 | SEGMENT_TIME_SECONDS: 4, // 4 seconds |
622 | SEGMENTS_LIST_SIZE: 15, // 15 maximum segments in live playlist | 622 | SEGMENTS_LIST_SIZE: 15, // 15 maximum segments in live playlist |
623 | EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION: 3, | ||
623 | RTMP: { | 624 | RTMP: { |
624 | CHUNK_SIZE: 60000, | 625 | CHUNK_SIZE: 60000, |
625 | GOP_CACHE: true, | 626 | GOP_CACHE: true, |
@@ -750,6 +751,7 @@ if (isTestInstance() === true) { | |||
750 | 751 | ||
751 | VIDEO_LIVE.CLEANUP_DELAY = 5000 | 752 | VIDEO_LIVE.CLEANUP_DELAY = 5000 |
752 | VIDEO_LIVE.SEGMENT_TIME_SECONDS = 2 | 753 | VIDEO_LIVE.SEGMENT_TIME_SECONDS = 2 |
754 | VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION = 1 | ||
753 | } | 755 | } |
754 | 756 | ||
755 | updateWebserverUrls() | 757 | updateWebserverUrls() |
diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts index 60ef30d15..d1a0cee91 100644 --- a/server/lib/live-manager.ts +++ b/server/lib/live-manager.ts | |||
@@ -323,11 +323,15 @@ class LiveManager { | |||
323 | await video.save() | 323 | await video.save() |
324 | videoLive.Video = video | 324 | videoLive.Video = video |
325 | 325 | ||
326 | await federateVideoIfNeeded(video, false) | 326 | setTimeout(() => { |
327 | federateVideoIfNeeded(video, false) | ||
328 | .catch(err => logger.error('Cannot federate live video %s.', video.url, { err })) | ||
329 | |||
330 | PeerTubeSocket.Instance.sendVideoLiveNewState(video) | ||
331 | }, VIDEO_LIVE.SEGMENT_TIME_SECONDS * 1000 * VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION) | ||
327 | 332 | ||
328 | PeerTubeSocket.Instance.sendVideoLiveNewState(video) | ||
329 | } catch (err) { | 333 | } catch (err) { |
330 | logger.error('Cannot federate video %d.', videoLive.videoId, { err }) | 334 | logger.error('Cannot save/federate live video %d.', videoLive.videoId, { err }) |
331 | } finally { | 335 | } finally { |
332 | masterWatcher.close() | 336 | masterWatcher.close() |
333 | .catch(err => logger.error('Cannot close master watcher of %s.', outPath, { err })) | 337 | .catch(err => logger.error('Cannot close master watcher of %s.', outPath, { err })) |