-import { escapeHTML } from '@shared/core-utils/renderer'
-import { VideoFile } from '@shared/models'
+import { HTMLServerConfig, Video, VideoFile } from '@shared/models'
function toTitleCase (str: string) {
return str.charAt(0).toUpperCase() + str.slice(1)
return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false
}
+function isP2PEnabled (video: Video, config: HTMLServerConfig, userP2PEnabled: boolean) {
+ if (video.isLocal && config.tracker.enabled === false) return false
+ if (isWebRTCDisabled()) return false
+
+ return userP2PEnabled
+}
+
function isIOS () {
if (/iPad|iPhone|iPod/.test(navigator.platform)) {
return true
// Detect iPad Desktop mode
return !!(navigator.maxTouchPoints &&
navigator.maxTouchPoints > 2 &&
- /MacIntel/.test(navigator.platform))
+ navigator.platform.includes('MacIntel'))
}
function isSafari () {
// https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts
// Don't import all Angular stuff, just copy the code with shame
-const dictionaryBytes: Array<{max: number, type: string}> = [
+const dictionaryBytes: Array<{ max: number, type: string }> = [
{ max: 1024, type: 'B' },
{ max: 1048576, type: 'KB' },
{ max: 1073741824, type: 'MB' },
}
function buildVideoOrPlaylistEmbed (embedUrl: string, embedTitle: string) {
- const title = escapeHTML(embedTitle)
-
- return '<iframe width="560" height="315" ' +
- 'sandbox="allow-same-origin allow-scripts allow-popups" ' +
- 'title="' + title + '" ' +
- 'src="' + embedUrl + '" ' +
- 'frameborder="0" allowfullscreen>' +
- '</iframe>'
+ const iframe = document.createElement('iframe')
+
+ iframe.title = embedTitle
+ iframe.width = '560'
+ iframe.height = '315'
+ iframe.src = embedUrl
+ iframe.frameBorder = '0'
+ iframe.allowFullscreen = true
+ iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups')
+
+ return iframe.outerHTML
}
function videoFileMaxByResolution (files: VideoFile[]) {
getRtcConfig,
toTitleCase,
isWebRTCDisabled,
+ isP2PEnabled,
buildVideoOrPlaylistEmbed,
videoFileMaxByResolution,