import { createServer as createServerTLS, Server as ServerTLS } from 'tls'
import { logger, loggerTagsFactory } from '@server/helpers/logger'
import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config'
-import { VIDEO_LIVE } from '@server/initializers/constants'
+import { VIDEO_LIVE, WEBSERVER } from '@server/initializers/constants'
import { sequelizeTypescript } from '@server/initializers/database'
import { RunnerJobModel } from '@server/models/runner/runner-job'
import { UserModel } from '@server/models/user/user'
}
const session = this.getContext().sessions.get(sessionId)
+ const inputLocalUrl = session.inputOriginLocalUrl + streamPath
+ const inputPublicUrl = session.inputOriginPublicUrl + streamPath
- this.handleSession(sessionId, session.inputOriginUrl + streamPath, splittedPath[2])
+ this.handleSession({ sessionId, inputPublicUrl, inputLocalUrl, streamKey: splittedPath[2] })
.catch(err => logger.error('Cannot handle sessions.', { err, ...lTags(sessionId) }))
})
this.rtmpServer = createServer(socket => {
const session = new NodeRtmpSession(config, socket)
- session.inputOriginUrl = 'rtmp://127.0.0.1:' + CONFIG.LIVE.RTMP.PORT
+ session.inputOriginLocalUrl = 'rtmp://127.0.0.1:' + CONFIG.LIVE.RTMP.PORT
+ session.inputOriginPublicUrl = WEBSERVER.RTMP_URL
session.run()
})
this.rtmpsServer = createServerTLS(serverOptions, socket => {
const session = new NodeRtmpSession(config, socket)
- session.inputOriginUrl = 'rtmps://127.0.0.1:' + CONFIG.LIVE.RTMPS.PORT
+ session.inputOriginLocalUrl = 'rtmps://127.0.0.1:' + CONFIG.LIVE.RTMPS.PORT
+ session.inputOriginPublicUrl = WEBSERVER.RTMPS_URL
session.run()
})
}
}
- private async handleSession (sessionId: string, inputUrl: string, streamKey: string) {
+ private async handleSession (options: {
+ sessionId: string
+ inputLocalUrl: string
+ inputPublicUrl: string
+ streamKey: string
+ }) {
+ const { inputLocalUrl, inputPublicUrl, sessionId, streamKey } = options
+
const videoLive = await VideoLiveModel.loadByStreamKey(streamKey)
if (!videoLive) {
logger.warn('Unknown live video with stream key %s.', streamKey, lTags(sessionId))
this.videoSessions.set(video.uuid, sessionId)
const now = Date.now()
- const probe = await ffprobePromise(inputUrl)
+ const probe = await ffprobePromise(inputLocalUrl)
const [ { resolution, ratio }, fps, bitrate, hasAudio ] = await Promise.all([
- getVideoStreamDimensionsInfo(inputUrl, probe),
- getVideoStreamFPS(inputUrl, probe),
- getVideoStreamBitrate(inputUrl, probe),
- hasAudioStream(inputUrl, probe)
+ getVideoStreamDimensionsInfo(inputLocalUrl, probe),
+ getVideoStreamFPS(inputLocalUrl, probe),
+ getVideoStreamBitrate(inputLocalUrl, probe),
+ hasAudioStream(inputLocalUrl, probe)
])
logger.info(
'%s probing took %d ms (bitrate: %d, fps: %d, resolution: %d)',
- inputUrl, Date.now() - now, bitrate, fps, resolution, lTags(sessionId, video.uuid)
+ inputLocalUrl, Date.now() - now, bitrate, fps, resolution, lTags(sessionId, video.uuid)
)
const allResolutions = await Hooks.wrapObject(
sessionId,
videoLive,
- inputUrl,
+ inputLocalUrl,
+ inputPublicUrl,
fps,
bitrate,
ratio,
sessionId: string
videoLive: MVideoLiveVideoWithSetting
- inputUrl: string
+ inputLocalUrl: string
+ inputPublicUrl: string
+
fps: number
bitrate: number
ratio: number
videoLive,
user,
- ...pick(options, [ 'inputUrl', 'bitrate', 'ratio', 'fps', 'allResolutions', 'hasAudio' ])
+ ...pick(options, [ 'inputLocalUrl', 'inputPublicUrl', 'bitrate', 'ratio', 'fps', 'allResolutions', 'hasAudio' ])
})
muxingSession.on('live-ready', () => this.publishAndFederateLive(videoLive, localLTags))
private readonly user: MUserId
private readonly sessionId: string
private readonly videoLive: MVideoLiveVideo
- private readonly inputUrl: string
+
+ private readonly inputLocalUrl: string
+ private readonly inputPublicUrl: string
+
private readonly fps: number
private readonly allResolutions: number[]
user: MUserId
sessionId: string
videoLive: MVideoLiveVideo
- inputUrl: string
+
+ inputLocalUrl: string
+ inputPublicUrl: string
+
fps: number
bitrate: number
ratio: number
this.user = options.user
this.sessionId = options.sessionId
this.videoLive = options.videoLive
- this.inputUrl = options.inputUrl
+
+ this.inputLocalUrl = options.inputLocalUrl
+ this.inputPublicUrl = options.inputPublicUrl
+
this.fps = options.fps
this.bitrate = options.bitrate
private onTranscodedEnded () {
this.emit('transcoding-end', ({ videoUUID: this.videoUUID }))
- logger.info('RTMP transmuxing for video %s ended. Scheduling cleanup', this.inputUrl, this.lTags())
+ logger.info('RTMP transmuxing for video %s ended. Scheduling cleanup', this.inputLocalUrl, this.lTags())
setTimeout(() => {
// Wait latest segments generation, and close watchers
lTags: this.lTags,
- inputUrl: this.inputUrl,
+ inputLocalUrl: this.inputLocalUrl,
+ inputPublicUrl: this.inputPublicUrl,
toTranscode: this.allResolutions.map(resolution => ({
resolution,