ResultList,
VideoCreateResult,
VideoDetails,
+ VideoPrivacy,
VideoState
} from '@shared/models'
import { unwrapBody } from '../requests'
-import { ObjectStorageCommand } from '../server'
+import { ObjectStorageCommand, PeerTubeServer } from '../server'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
import { sendRTMPStream, testFfmpegStreamError } from './live'
return body.video
}
+ async quickCreate (options: OverrideCommandOptions & {
+ saveReplay: boolean
+ permanentLive: boolean
+ privacy?: VideoPrivacy
+ }) {
+ const { saveReplay, permanentLive, privacy } = options
+
+ const { uuid } = await this.create({
+ ...options,
+
+ fields: {
+ name: 'live',
+ permanentLive,
+ saveReplay,
+ channelId: this.server.store.channel.id,
+ privacy
+ }
+ })
+
+ const video = await this.server.videos.getWithToken({ id: uuid })
+ const live = await this.get({ videoId: uuid })
+
+ return { video, live }
+ }
+
// ---------------------------------------------------------------------------
async sendRTMPStreamInVideo (options: OverrideCommandOptions & {
return this.waitUntilState({ videoId, state: VideoState.LIVE_ENDED })
}
- waitUntilSegmentGeneration (options: OverrideCommandOptions & {
+ async waitUntilSegmentGeneration (options: OverrideCommandOptions & {
+ server: PeerTubeServer
videoUUID: string
playlistNumber: number
segment: number
- totalSessions?: number
+ objectStorage: boolean
}) {
- const { playlistNumber, segment, videoUUID, totalSessions = 1 } = options
+ const { server, objectStorage, playlistNumber, segment, videoUUID } = options
+
const segmentName = `${playlistNumber}-00000${segment}.ts`
+ const baseUrl = objectStorage
+ ? ObjectStorageCommand.getMockPlaylistBaseUrl() + 'hls'
+ : server.url + '/static/streaming-playlists/hls'
- return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, totalSessions * 2, false)
- }
+ let error = true
- waitUntilSegmentUpload (options: OverrideCommandOptions & {
- playlistNumber: number
- segment: number
- totalSessions?: number
- }) {
- const { playlistNumber, segment, totalSessions = 1 } = options
- const segmentName = `${playlistNumber}-00000${segment}.ts`
+ while (error) {
+ try {
+ await this.getRawRequest({
+ ...options,
+
+ url: `${baseUrl}/${videoUUID}/${segmentName}`,
+ implicitToken: false,
+ defaultExpectedStatus: HttpStatusCode.OK_200
+ })
+
+ const video = await server.videos.get({ id: videoUUID })
+ const hlsPlaylist = video.streamingPlaylists[0]
+
+ const shaBody = await server.streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url })
+
+ if (!shaBody[segmentName]) {
+ throw new Error('Segment SHA does not exist')
+ }
- return this.server.servers.waitUntilLog(`${segmentName} in bucket `, totalSessions * 2, false)
+ error = false
+ } catch {
+ error = true
+ await wait(100)
+ }
+ }
}
async waitUntilReplacedByReplay (options: OverrideCommandOptions & {
const segmentName = `${playlistNumber}-00000${segment}.ts`
const baseUrl = objectStorage
- ? ObjectStorageCommand.getPlaylistBaseUrl()
+ ? ObjectStorageCommand.getMockPlaylistBaseUrl()
: `${this.server.url}/static/streaming-playlists/hls`
const url = `${baseUrl}/${videoUUID}/${segmentName}`
const { playlistName, videoUUID, objectStorage = false } = options
const baseUrl = objectStorage
- ? ObjectStorageCommand.getPlaylistBaseUrl()
+ ? ObjectStorageCommand.getMockPlaylistBaseUrl()
: `${this.server.url}/static/streaming-playlists/hls`
const url = `${baseUrl}/${videoUUID}/${playlistName}`