]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/assets/player/utils.ts
Better display redundancy pies
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / utils.ts
index 18380d9501033ee03baa243916f26e4e3890287d..7e25e3067d3ef9ba37357ff2daa59b0cd51d9187 100644 (file)
@@ -1,4 +1,4 @@
-import { VideoFile } from '@shared/models'
+import { HTMLServerConfig, Video, VideoFile } from '@shared/models'
 
 function toTitleCase (str: string) {
   return str.charAt(0).toUpperCase() + str.slice(1)
@@ -8,6 +8,13 @@ function isWebRTCDisabled () {
   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
@@ -97,6 +104,7 @@ export {
   getRtcConfig,
   toTitleCase,
   isWebRTCDisabled,
+  isP2PEnabled,
 
   buildVideoOrPlaylistEmbed,
   videoFileMaxByResolution,