mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Add ability to configure stun servers
This commit is contained in:
@@ -696,6 +696,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||
authorizationHeader: () => this.authService.getRequestHeaderValue(),
|
||||
|
||||
serverUrl: environment.originServerUrl || window.location.origin,
|
||||
stunServers: this.serverConfig.webrtc.stunServers,
|
||||
|
||||
errorNotifier: (message: string) => this.notifier.error(message),
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ export class PeerTubePlayer {
|
||||
|
||||
private async loadP2PMediaLoader () {
|
||||
const hlsOptionsBuilder = new HLSOptionsBuilder({
|
||||
...pick(this.options, [ 'pluginsManager', 'serverUrl', 'authorizationHeader' ]),
|
||||
...pick(this.options, [ 'pluginsManager', 'serverUrl', 'authorizationHeader', 'stunServers' ]),
|
||||
...pick(this.currentLoadOptions, [
|
||||
'videoPassword',
|
||||
'requiresUserAuth',
|
||||
|
||||
@@ -15,16 +15,9 @@ export function bytes (value: number) {
|
||||
return [ calc, format.type ]
|
||||
}
|
||||
|
||||
export function getRtcConfig () {
|
||||
export function getRtcConfig (stunServers: string[]) {
|
||||
return {
|
||||
iceServers: [
|
||||
{
|
||||
urls: 'stun:stun.stunprotocol.org'
|
||||
},
|
||||
{
|
||||
urls: 'stun:stun.framasoft.org'
|
||||
}
|
||||
]
|
||||
iceServers: stunServers.map(s => ({ urls: s }))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,12 @@ import { getRtcConfig, isSameOrigin } from '../common'
|
||||
import { RedundancyUrlManager } from '../p2p-media-loader/redundancy-url-manager'
|
||||
import { segmentUrlBuilderFactory } from '../p2p-media-loader/segment-url-builder'
|
||||
import { SegmentValidator } from '../p2p-media-loader/segment-validator'
|
||||
import debug from 'debug'
|
||||
|
||||
const debugLogger = debug('peertube:player:hls')
|
||||
|
||||
type ConstructorOptions =
|
||||
Pick<PeerTubePlayerContructorOptions, 'pluginsManager' | 'serverUrl' | 'authorizationHeader'> &
|
||||
Pick<PeerTubePlayerContructorOptions, 'pluginsManager' | 'serverUrl' | 'authorizationHeader' | 'stunServers'> &
|
||||
Pick<PeerTubePlayerLoadOptions, 'videoPassword' | 'requiresUserAuth' | 'videoFileToken' | 'requiresPassword' |
|
||||
'isLive' | 'liveOptions' | 'p2pEnabled' | 'hls'>
|
||||
|
||||
@@ -86,6 +89,8 @@ export class HLSOptionsBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
debugLogger('Creating HLS player options', { hlsjs, p2pMediaLoader, loaderOptions: p2pMediaLoaderConfig })
|
||||
|
||||
return { p2pMediaLoader, hlsjs }
|
||||
}
|
||||
|
||||
@@ -116,7 +121,7 @@ export class HLSOptionsBuilder {
|
||||
return {
|
||||
loader: {
|
||||
trackerAnnounce,
|
||||
rtcConfig: getRtcConfig(),
|
||||
rtcConfig: getRtcConfig(this.options.stunServers),
|
||||
|
||||
simultaneousHttpDownloads: 1,
|
||||
httpFailedSegmentTimeout: 1000,
|
||||
|
||||
@@ -41,6 +41,8 @@ export type PeerTubePlayerContructorOptions = {
|
||||
|
||||
pluginsManager: PluginsManager
|
||||
|
||||
stunServers: string[]
|
||||
|
||||
autoPlayerRatio?: {
|
||||
cssRatioVariable: string
|
||||
cssPlayerPortraitModeVariable: string
|
||||
|
||||
@@ -206,6 +206,7 @@ export class PlayerOptionsBuilder {
|
||||
theaterButton: false,
|
||||
|
||||
serverUrl: getBackendUrl(),
|
||||
stunServers: serverConfig.webrtc.stunServers,
|
||||
language: navigator.language,
|
||||
|
||||
pluginsManager: this.peertubePlugin.getPluginsManager(),
|
||||
|
||||
Reference in New Issue
Block a user