Disable p2p seeding using local storage

Used by E2E testing
This commit is contained in:
Chocobozzz 2023-11-15 11:06:18 +01:00
parent d8f846c69d
commit 33c707616c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 5 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import { getRtcConfig, isSameOrigin } from '../common'
import { RedundancyUrlManager } from '../p2p-media-loader/redundancy-url-manager' import { RedundancyUrlManager } from '../p2p-media-loader/redundancy-url-manager'
import { segmentUrlBuilderFactory } from '../p2p-media-loader/segment-url-builder' import { segmentUrlBuilderFactory } from '../p2p-media-loader/segment-url-builder'
import { SegmentValidator } from '../p2p-media-loader/segment-validator' import { SegmentValidator } from '../p2p-media-loader/segment-validator'
import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
type ConstructorOptions = type ConstructorOptions =
Pick<PeerTubePlayerContructorOptions, 'pluginsManager' | 'serverUrl' | 'authorizationHeader'> & Pick<PeerTubePlayerContructorOptions, 'pluginsManager' | 'serverUrl' | 'authorizationHeader'> &
@ -82,7 +83,10 @@ export class HLSOptionsBuilder {
const { redundancyUrlManager, segmentValidator } = options const { redundancyUrlManager, segmentValidator } = options
let consumeOnly = false let consumeOnly = false
if ((navigator as any)?.connection?.type === 'cellular') { if (
(navigator as any)?.connection?.type === 'cellular' ||
peertubeLocalStorage.getItem('peertube-videojs-p2p-consume-only') === 'true' // Use for E2E testing
) {
logger.info('We are on a cellular connection: disabling seeding.') logger.info('We are on a cellular connection: disabling seeding.')
consumeOnly = true consumeOnly = true
} }