Fix live ending job that breaks new live session

pull/5067/head
Chocobozzz 2022-06-16 13:39:57 +02:00
parent bffee1d538
commit cdd838168d
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 20 additions and 8 deletions

View File

@ -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: MVideoLive
video: 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 {

View File

@ -416,6 +416,7 @@ class LiveManager {
: undefined,
liveSessionId: liveSession.id,
streamingPlaylistId: fullVideo.getHLSPlaylist()?.id,
publishedAt: fullVideo.publishedAt.toISOString()
}

View File

@ -12,6 +12,7 @@ import {
createMultipleServers,
doubleFollow,
findExternalSavedVideo,
makeRawRequest,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
@ -457,6 +458,12 @@ describe('Save replay setting', function () {
// Streaming session #2
ffmpegCommand = 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)

View File

@ -161,6 +161,7 @@ export interface VideoLiveEndingPayload {
videoId: number
publishedAt: string
liveSessionId: number
streamingPlaylistId: number
replayDirectory?: string
}