ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix live ending job that breaks new live session
Chocobozzzcdd838168d61
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.tsindex 7607267f84..feec257fca 100644--- a/server/lib/job-queue/handlers/video-live-ending.ts+++ b/server/lib/job-queue/handlers/video-live-ending.ts@@ -45,13 +45,13 @@ async function processVideoLiveEnding (job: Job) {LiveSegmentShaStore.Instance.cleanupShaSegments(liveVideo.uuid)if (live.saveReplay !== true) {- return cleanupLiveAndFederate({ live, video: liveVideo })+ return cleanupLiveAndFederate({ live, video: liveVideo, streamingPlaylistId: payload.streamingPlaylistId })}if (live.permanentLive) {await saveReplayToExternalVideo({ liveVideo, liveSession, publishedAt: payload.publishedAt, replayDirectory: payload.replayDirectory })- return cleanupLiveAndFederate({ live, video: liveVideo })+ return cleanupLiveAndFederate({ live, video: liveVideo, streamingPlaylistId: payload.streamingPlaylistId })}return replaceLiveByReplay({ liveVideo, live, liveSession, replayDirectory: payload.replayDirectory })@@ -233,15 +233,18 @@ async function assignReplayFilesToVideo (options: {async function cleanupLiveAndFederate (options: {live: MVideoLivevideo: MVideo+ streamingPlaylistId: number}) {- const { live, video } = options+ const { live, video, streamingPlaylistId } = options- const streamingPlaylist = await VideoStreamingPlaylistModel.loadHLSPlaylistByVideo(video.id)+ const streamingPlaylist = await VideoStreamingPlaylistModel.loadWithVideo(streamingPlaylistId)- if (live.permanentLive) {- await cleanupPermanentLive(video, streamingPlaylist)- } else {- await cleanupNormalLive(video, streamingPlaylist)+ if (streamingPlaylist) {+ if (live.permanentLive) {+ await cleanupPermanentLive(video, streamingPlaylist)+ } else {+ await cleanupNormalLive(video, streamingPlaylist)+ }}try {diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.tsindex 0f14a68511..f2f064b49b 100644--- a/server/lib/live/live-manager.ts+++ b/server/lib/live/live-manager.ts@@ -416,6 +416,7 @@ class LiveManager {: undefined,liveSessionId: liveSession.id,+ streamingPlaylistId: fullVideo.getHLSPlaylist()?.id,publishedAt: fullVideo.publishedAt.toISOString()}diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.tsindex 007af51e96..99d500711c 100644--- a/server/tests/api/live/live-save-replay.ts+++ b/server/tests/api/live/live-save-replay.ts@@ -12,6 +12,7 @@ import {createMultipleServers,doubleFollow,findExternalSavedVideo,+ makeRawRequest,PeerTubeServer,setAccessTokensToServers,setDefaultVideoChannel,@@ -457,6 +458,12 @@ describe('Save replay setting', function () {// Streaming session #2ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)++ await wait(5000)+ const video = await servers[0].videos.get({ id: liveVideoUUID })+ expect(video.streamingPlaylists).to.have.lengthOf(1)+ await makeRawRequest(video.streamingPlaylists[0].playlistUrl)+await stopFfmpeg(ffmpegCommand)await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID)diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.tsindex bc5ffa5709..073f158729 100644--- a/shared/models/server/job.model.ts+++ b/shared/models/server/job.model.ts@@ -161,6 +161,7 @@ export interface VideoLiveEndingPayload {videoId: numberpublishedAt: stringliveSessionId: number+ streamingPlaylistId: numberreplayDirectory?: string}