1 import { HTMLServerConfig, Video, VideoPrivacy } from '@shared/models'
3 function buildVideoOrPlaylistEmbed (options: {
7 const { embedUrl, embedTitle } = options
9 const iframe = document.createElement('iframe')
11 iframe.title = embedTitle
15 iframe.frameBorder = '0'
16 iframe.allowFullscreen = true
17 iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups')
19 return iframe.outerHTML
22 function isP2PEnabled (video: Video, config: HTMLServerConfig, userP2PEnabled: boolean) {
23 if (video.isLocal && config.tracker.enabled === false) return false
24 if (isWebRTCDisabled()) return false
29 function videoRequiresAuth (video: Video) {
30 return new Set([ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]).has(video.privacy.id)
34 buildVideoOrPlaylistEmbed,
39 // ---------------------------------------------------------------------------
41 function isWebRTCDisabled () {
42 return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false