1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
4 import { buildAbsoluteFixturePath } from '@shared/core-utils'
5 import { VideoPrivacy } from '@shared/models'
11 setAccessTokensToServers,
12 setDefaultVideoChannel,
14 testFfmpegStreamError,
15 waitUntilLivePublishedOnAllServers
16 } from '@shared/server-commands'
18 describe('Test live RTMPS', function () {
19 let server: PeerTubeServer
23 async function createLiveWrapper () {
24 const liveAttributes = {
26 channelId: server.store.channel.id,
27 privacy: VideoPrivacy.PUBLIC,
31 const { uuid } = await server.live.create({ fields: liveAttributes })
33 const live = await server.live.get({ videoId: uuid })
34 const video = await server.videos.get({ id: uuid })
36 return Object.assign(video, live)
39 before(async function () {
42 server = await createSingleServer(1)
44 // Get the access tokens
45 await setAccessTokensToServers([ server ])
46 await setDefaultVideoChannel([ server ])
48 await server.config.updateCustomSubConfig({
60 rtmpUrl = 'rtmp://' + server.hostname + ':' + server.rtmpPort + '/live'
61 rtmpsUrl = 'rtmps://' + server.hostname + ':' + server.rtmpsPort + '/live'
64 it('Should enable RTMPS endpoint only', async function () {
75 port: server.rtmpsPort,
76 key_file: buildAbsoluteFixturePath('rtmps.key'),
77 cert_file: buildAbsoluteFixturePath('rtmps.cert')
83 const liveVideo = await createLiveWrapper()
85 expect(liveVideo.rtmpUrl).to.not.exist
86 expect(liveVideo.rtmpsUrl).to.equal(rtmpsUrl)
88 const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl, streamKey: liveVideo.streamKey })
89 await testFfmpegStreamError(command, true)
93 const liveVideo = await createLiveWrapper()
95 const command = sendRTMPStream({ rtmpBaseUrl: rtmpsUrl, streamKey: liveVideo.streamKey })
96 await waitUntilLivePublishedOnAllServers([ server ], liveVideo.uuid)
97 await stopFfmpeg(command)
101 it('Should enable both RTMP and RTMPS', async function () {
109 port: server.rtmpPort
113 port: server.rtmpsPort,
114 key_file: buildAbsoluteFixturePath('rtmps.key'),
115 cert_file: buildAbsoluteFixturePath('rtmps.cert')
121 const liveVideo = await createLiveWrapper()
123 expect(liveVideo.rtmpUrl).to.equal(rtmpUrl)
124 expect(liveVideo.rtmpsUrl).to.equal(rtmpsUrl)
126 const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl, streamKey: liveVideo.streamKey })
127 await waitUntilLivePublishedOnAllServers([ server ], liveVideo.uuid)
128 await stopFfmpeg(command)
132 const liveVideo = await createLiveWrapper()
134 const command = sendRTMPStream({ rtmpBaseUrl: rtmpsUrl, streamKey: liveVideo.streamKey })
135 await waitUntilLivePublishedOnAllServers([ server ], liveVideo.uuid)
136 await stopFfmpeg(command)
140 after(async function () {
141 await cleanupTests([ server ])