-import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoDetails, VideoState } from '@shared/models'
-import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs'
-import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests'
-import { ServerInfo } from '../server/servers'
-import { getVideoWithToken } from './videos'
-
-function getLive (url: string, token: string, videoId: number | string, statusCodeExpected = 200) {
- const path = '/api/v1/videos/live'
-
- return makeGetRequest({
- url,
- token,
- path: path + '/' + videoId,
- statusCodeExpected
- })
-}
-
-function updateLive (url: string, token: string, videoId: number | string, fields: LiveVideoUpdate, statusCodeExpected = 204) {
- const path = '/api/v1/videos/live'
-
- return makePutBodyRequest({
- url,
- token,
- path: path + '/' + videoId,
- fields,
- statusCodeExpected
- })
-}
-
-function createLive (url: string, token: string, fields: LiveVideoCreate, statusCodeExpected = 200) {
- const path = '/api/v1/videos/live'
-
- const attaches: any = {}
- if (fields.thumbnailfile) attaches.thumbnailfile = fields.thumbnailfile
- if (fields.previewfile) attaches.previewfile = fields.previewfile
-
- const updatedFields = omit(fields, 'thumbnailfile', 'previewfile')
-
- return makeUploadRequest({
- url,
- path,
- token,
- attaches,
- fields: updatedFields,
- statusCodeExpected
- })
-}
-
-async function sendRTMPStreamInVideo (url: string, token: string, videoId: number | string) {
- const res = await getLive(url, token, videoId)
- const videoLive = res.body as LiveVideo
-
- return sendRTMPStream(videoLive.rtmpUrl, videoLive.streamKey)
-}