import { ActorModel } from '../../../models/activitypub/actor'
import { VideoModel } from '../../../models/video/video'
import { VideoCommentModel } from '../../../models/video/video-comment'
-import { markCommentAsDeleted } from '../../video-comment'
-import { forwardVideoRelatedActivity } from '../send/utils'
import { VideoPlaylistModel } from '../../../models/video/video-playlist'
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
-import { MAccountActor, MActor, MActorSignature, MChannelActor, MChannelActorAccountActor } from '../../../types/models'
+import { MAccountActor, MActor, MActorSignature, MChannelActor, MChannelActorAccountActor, MCommentOwnerVideo } from '../../../types/models'
+import { markCommentAsDeleted } from '../../video-comment'
+import { forwardVideoRelatedActivity } from '../send/utils'
async function processDeleteActivity (options: APProcessorOptions<ActivityDelete>) {
const { activity, byActor } = options
logger.info('Remote video channel %s removed.', videoChannelToRemove.Actor.url)
}
-function processDeleteVideoComment (byActor: MActorSignature, videoComment: VideoCommentModel, activity: ActivityDelete) {
+function processDeleteVideoComment (byActor: MActorSignature, videoComment: MCommentOwnerVideo, activity: ActivityDelete) {
+ // Already deleted
+ if (videoComment.isDeleted()) return
+
logger.debug('Removing remote video comment "%s".', videoComment.url)
return sequelizeTypescript.transaction(async t => {
for (let i = 0; i < allResolutions.length; i++) {
const resolution = allResolutions[i]
- VideoFileModel.upsert({
+ const file = new VideoFileModel({
resolution,
size: -1,
extname: '.ts',
infoHash: null,
fps,
videoStreamingPlaylistId: playlist.id
- }).catch(err => {
- logger.error('Cannot create file for live streaming.', { err })
})
+
+ VideoFileModel.customUpsert(file, 'streaming-playlist', null)
+ .catch(err => logger.error('Cannot create file for live streaming.', { err }))
}
const outPath = getHLSDirectory(videoLive.Video)
updateLive,
uploadVideoAndGetId,
userLogin,
- waitUntilLiveStarts
+ waitUntilLivePublished
} from '../../../../shared/extra-utils'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
- await waitUntilLiveStarts(server.url, server.accessToken, videoId)
+ await waitUntilLivePublished(server.url, server.accessToken, videoId)
await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400)
await stopFfmpeg(command)
const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
- await waitUntilLiveStarts(server.url, server.accessToken, videoId)
+ await waitUntilLivePublished(server.url, server.accessToken, videoId)
await runAndTestFfmpegStreamError(server.url, server.accessToken, videoId, true)
updateLive,
wait,
waitJobs,
- waitUntilLiveStarts
+ waitUntilLivePublished
} from '../../../../shared/extra-utils'
const expect = chai.expect
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
for (const server of servers) {
- await waitUntilLiveStarts(server.url, server.accessToken, videoUUID)
+ await waitUntilLivePublished(server.url, server.accessToken, videoUUID)
}
await checkVideoState(videoUUID, VideoState.PUBLISHED)
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
for (const server of servers) {
- await waitUntilLiveStarts(server.url, server.accessToken, videoUUID)
+ await waitUntilLivePublished(server.url, server.accessToken, videoUUID)
}
await checkVideoState(videoUUID, VideoState.PUBLISHED)
updateCustomSubConfig,
updateVideo,
waitJobs,
- waitUntilLiveStarts
+ waitUntilLivePublished
} from '../../../../shared/extra-utils'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
this.timeout(20000)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitJobs(servers)
liveVideoUUID = await createLiveWrapper(false)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
liveVideoUUID = await createLiveWrapper(false)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
this.timeout(20000)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitJobs(servers)
liveVideoUUID = await createLiveWrapper(true)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
liveVideoUUID = await createLiveWrapper(true)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io'
import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
addVideoToBlacklist,
buildServerDirectory,
waitJobs,
waitUntilLiveEnded,
waitUntilLivePublished,
- waitUntilLiveStarts,
+ waitUntilLiveSegmentGeneration,
waitUntilLog
} from '../../../../shared/extra-utils'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const expect = chai.expect
await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions)
for (let i = 0; i < resolutions.length; i++) {
- const segmentName = `${i}-000001.ts`
- await waitUntilLog(servers[0], `${video.uuid}/${segmentName}`, 2, false)
+ const segmentNum = 1
+ const segmentName = `${i}-00000${segmentNum}.ts`
+ await waitUntilLiveSegmentGeneration(servers[0], video.uuid, i, segmentNum)
const res = await getPlaylist(`${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8`)
const subPlaylist = res.text
liveVideoId = await createLiveWrapper(false)
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitJobs(servers)
await testVideoResolutions(liveVideoId, [ 720 ])
liveVideoId = await createLiveWrapper(false)
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitJobs(servers)
await testVideoResolutions(liveVideoId, resolutions)
liveVideoId = await createLiveWrapper(true)
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm')
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitJobs(servers)
await testVideoResolutions(liveVideoId, resolutions)
liveVideoId = res.body.video.uuid
command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitJobs(servers)
})
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
for (const server of servers) {
- await waitUntilLiveStarts(server.url, server.accessToken, liveVideoUUID)
+ await waitUntilLivePublished(server.url, server.accessToken, liveVideoUUID)
}
await waitJobs(servers)
socket.emit('subscribe', { videoId })
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
- await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
+ await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitJobs(servers)
expect(stateChanges).to.have.lengthOf(1)
}
before(async function () {
- this.timeout(60000)
+ this.timeout(120000)
liveVideoId = await createLiveWrapper(false)
liveVideoReplayId = await createLiveWrapper(true)
])
await Promise.all([
- waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId),
- waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoReplayId)
+ waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId),
+ waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoReplayId)
])
+ await waitUntilLiveSegmentGeneration(servers[0], liveVideoId, 0, 2)
+ await waitUntilLiveSegmentGeneration(servers[0], liveVideoReplayId, 0, 2)
+
await killallServers([ servers[0] ])
await reRunServer(servers[0])
it('Should cleanup lives', async function () {
this.timeout(60000)
- const res = await getVideo(servers[0].url, liveVideoId)
- const video: VideoDetails = res.body
-
- expect(video.state.id).to.equal(VideoState.LIVE_ENDED)
+ await waitUntilLiveEnded(servers[0].url, servers[0].accessToken, liveVideoId)
})
it('Should save a live replay', async function () {
- this.timeout(60000)
+ this.timeout(120000)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoReplayId)
})
import { omit } from 'lodash'
import { join } from 'path'
import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models'
+import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs'
import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests'
-import { ServerInfo } from '../server/servers'
+import { ServerInfo, waitUntilLog } from '../server/servers'
import { getVideoWithToken } from './videos'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
function getLive (url: string, token: string, videoId: number | string, statusCodeExpected = HttpStatusCode.OK_200) {
const path = '/api/v1/videos/live'
await wait(500)
}
-function waitUntilLiveStarts (url: string, token: string, videoId: number | string) {
- return waitWhileLiveState(url, token, videoId, VideoState.WAITING_FOR_LIVE)
-}
-
function waitUntilLivePublished (url: string, token: string, videoId: number | string) {
- return waitWhileLiveState(url, token, videoId, VideoState.PUBLISHED)
+ return waitUntilLiveState(url, token, videoId, VideoState.PUBLISHED)
}
function waitUntilLiveEnded (url: string, token: string, videoId: number | string) {
- return waitWhileLiveState(url, token, videoId, VideoState.LIVE_ENDED)
+ return waitUntilLiveState(url, token, videoId, VideoState.LIVE_ENDED)
+}
+
+function waitUntilLiveSegmentGeneration (server: ServerInfo, videoUUID: string, resolutionNum: number, segmentNum: number) {
+ const segmentName = `${resolutionNum}-00000${segmentNum}.ts`
+ return waitUntilLog(server, `${videoUUID}/${segmentName}`, 2, false)
}
-async function waitWhileLiveState (url: string, token: string, videoId: number | string, state: VideoState) {
+async function waitUntilLiveState (url: string, token: string, videoId: number | string, state: VideoState) {
let video: VideoDetails
do {
video = res.body
await wait(500)
- } while (video.state.id === state)
+ } while (video.state.id !== state)
}
async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
getPlaylistsCount,
waitUntilLivePublished,
updateLive,
- waitUntilLiveStarts,
createLive,
runAndTestFfmpegStreamError,
checkLiveCleanup,
+ waitUntilLiveSegmentGeneration,
stopFfmpeg,
sendRTMPStreamInVideo,
waitUntilLiveEnded,