1
0
Fork 0

Fix live ending job that breaks new live session

This commit is contained in:
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) LiveSegmentShaStore.Instance.cleanupShaSegments(liveVideo.uuid)
if (live.saveReplay !== true) { if (live.saveReplay !== true) {
return cleanupLiveAndFederate({ live, video: liveVideo }) return cleanupLiveAndFederate({ live, video: liveVideo, streamingPlaylistId: payload.streamingPlaylistId })
} }
if (live.permanentLive) { if (live.permanentLive) {
await saveReplayToExternalVideo({ liveVideo, liveSession, publishedAt: payload.publishedAt, replayDirectory: payload.replayDirectory }) 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 }) return replaceLiveByReplay({ liveVideo, live, liveSession, replayDirectory: payload.replayDirectory })
@ -233,15 +233,18 @@ async function assignReplayFilesToVideo (options: {
async function cleanupLiveAndFederate (options: { async function cleanupLiveAndFederate (options: {
live: MVideoLive live: MVideoLive
video: MVideo 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) { if (streamingPlaylist) {
await cleanupPermanentLive(video, streamingPlaylist) if (live.permanentLive) {
} else { await cleanupPermanentLive(video, streamingPlaylist)
await cleanupNormalLive(video, streamingPlaylist) } else {
await cleanupNormalLive(video, streamingPlaylist)
}
} }
try { try {

View file

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

View file

@ -12,6 +12,7 @@ import {
createMultipleServers, createMultipleServers,
doubleFollow, doubleFollow,
findExternalSavedVideo, findExternalSavedVideo,
makeRawRequest,
PeerTubeServer, PeerTubeServer,
setAccessTokensToServers, setAccessTokensToServers,
setDefaultVideoChannel, setDefaultVideoChannel,
@ -457,6 +458,12 @@ describe('Save replay setting', function () {
// Streaming session #2 // Streaming session #2
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(servers, 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 stopFfmpeg(ffmpegCommand)
await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID) await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID)

View file

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