1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Live supports object storage

* Sync live files (segments, master playlist, resolution playlist,
   segment sha file) into object storage
 * Automatically delete them when the live ends
 * Segment sha file is now a file on disk, and not stored in memory
   anymore
This commit is contained in:
Chocobozzz 2022-10-04 10:03:17 +02:00
parent 9c0cdc5047
commit cfd57d2ca0
No known key found for this signature in database
GPG key ID: 583A612D890159BE
21 changed files with 615 additions and 307 deletions

View file

@ -15,6 +15,7 @@ import {
VideoState
} from '@shared/models'
import { unwrapBody } from '../requests'
import { ObjectStorageCommand } from '../server'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
import { sendRTMPStream, testFfmpegStreamError } from './live'
@ -34,6 +35,8 @@ export class LiveCommand extends AbstractCommand {
})
}
// ---------------------------------------------------------------------------
listSessions (options: OverrideCommandOptions & {
videoId: number | string
}) {
@ -70,6 +73,8 @@ export class LiveCommand extends AbstractCommand {
})
}
// ---------------------------------------------------------------------------
update (options: OverrideCommandOptions & {
videoId: number | string
fields: LiveVideoUpdate
@ -110,6 +115,8 @@ export class LiveCommand extends AbstractCommand {
return body.video
}
// ---------------------------------------------------------------------------
async sendRTMPStreamInVideo (options: OverrideCommandOptions & {
videoId: number | string
fixtureName?: string
@ -130,6 +137,8 @@ export class LiveCommand extends AbstractCommand {
return testFfmpegStreamError(command, options.shouldHaveError)
}
// ---------------------------------------------------------------------------
waitUntilPublished (options: OverrideCommandOptions & {
videoId: number | string
}) {
@ -163,25 +172,6 @@ export class LiveCommand extends AbstractCommand {
return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, totalSessions * 2, false)
}
getSegment (options: OverrideCommandOptions & {
videoUUID: string
playlistNumber: number
segment: number
}) {
const { playlistNumber, segment, videoUUID } = options
const segmentName = `${playlistNumber}-00000${segment}.ts`
const url = `${this.server.url}/static/streaming-playlists/hls/${videoUUID}/${segmentName}`
return this.getRawRequest({
...options,
url,
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
async waitUntilReplacedByReplay (options: OverrideCommandOptions & {
videoId: number | string
}) {
@ -194,6 +184,56 @@ export class LiveCommand extends AbstractCommand {
} while (video.isLive === true || video.state.id !== VideoState.PUBLISHED)
}
// ---------------------------------------------------------------------------
getSegmentFile (options: OverrideCommandOptions & {
videoUUID: string
playlistNumber: number
segment: number
objectStorage?: boolean // default false
}) {
const { playlistNumber, segment, videoUUID, objectStorage = false } = options
const segmentName = `${playlistNumber}-00000${segment}.ts`
const baseUrl = objectStorage
? ObjectStorageCommand.getPlaylistBaseUrl()
: `${this.server.url}/static/streaming-playlists/hls`
const url = `${baseUrl}/${videoUUID}/${segmentName}`
return this.getRawRequest({
...options,
url,
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
getPlaylistFile (options: OverrideCommandOptions & {
videoUUID: string
playlistName: string
objectStorage?: boolean // default false
}) {
const { playlistName, videoUUID, objectStorage = false } = options
const baseUrl = objectStorage
? ObjectStorageCommand.getPlaylistBaseUrl()
: `${this.server.url}/static/streaming-playlists/hls`
const url = `${baseUrl}/${videoUUID}/${playlistName}`
return this.getRawRequest({
...options,
url,
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
// ---------------------------------------------------------------------------
async countPlaylists (options: OverrideCommandOptions & {
videoUUID: string
}) {