diff options
Diffstat (limited to 'client/src/assets/player/shared/manager-options/hls-options-builder.ts')
-rw-r--r-- | client/src/assets/player/shared/manager-options/hls-options-builder.ts | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/client/src/assets/player/shared/manager-options/hls-options-builder.ts b/client/src/assets/player/shared/manager-options/hls-options-builder.ts index 361c76f4b..933c0d595 100644 --- a/client/src/assets/player/shared/manager-options/hls-options-builder.ts +++ b/client/src/assets/player/shared/manager-options/hls-options-builder.ts | |||
@@ -5,7 +5,7 @@ import { LiveVideoLatencyMode } from '@shared/models' | |||
5 | import { getAverageBandwidthInStore } from '../../peertube-player-local-storage' | 5 | import { getAverageBandwidthInStore } from '../../peertube-player-local-storage' |
6 | import { P2PMediaLoader, P2PMediaLoaderPluginOptions } from '../../types' | 6 | import { P2PMediaLoader, P2PMediaLoaderPluginOptions } from '../../types' |
7 | import { PeertubePlayerManagerOptions } from '../../types/manager-options' | 7 | import { PeertubePlayerManagerOptions } from '../../types/manager-options' |
8 | import { getRtcConfig } from '../common' | 8 | import { getRtcConfig, isSameOrigin } from '../common' |
9 | import { RedundancyUrlManager } from '../p2p-media-loader/redundancy-url-manager' | 9 | import { RedundancyUrlManager } from '../p2p-media-loader/redundancy-url-manager' |
10 | import { segmentUrlBuilderFactory } from '../p2p-media-loader/segment-url-builder' | 10 | import { segmentUrlBuilderFactory } from '../p2p-media-loader/segment-url-builder' |
11 | import { segmentValidatorFactory } from '../p2p-media-loader/segment-validator' | 11 | import { segmentValidatorFactory } from '../p2p-media-loader/segment-validator' |
@@ -84,7 +84,21 @@ export class HLSOptionsBuilder { | |||
84 | simultaneousHttpDownloads: 1, | 84 | simultaneousHttpDownloads: 1, |
85 | httpFailedSegmentTimeout: 1000, | 85 | httpFailedSegmentTimeout: 1000, |
86 | 86 | ||
87 | segmentValidator: segmentValidatorFactory(this.options.p2pMediaLoader.segmentsSha256Url, this.options.common.isLive), | 87 | xhrSetup: (xhr, url) => { |
88 | if (!this.options.common.requiresAuth) return | ||
89 | if (!isSameOrigin(this.options.common.serverUrl, url)) return | ||
90 | |||
91 | xhr.setRequestHeader('Authorization', this.options.common.authorizationHeader()) | ||
92 | }, | ||
93 | |||
94 | segmentValidator: segmentValidatorFactory({ | ||
95 | segmentsSha256Url: this.options.p2pMediaLoader.segmentsSha256Url, | ||
96 | isLive: this.options.common.isLive, | ||
97 | authorizationHeader: this.options.common.authorizationHeader, | ||
98 | requiresAuth: this.options.common.requiresAuth, | ||
99 | serverUrl: this.options.common.serverUrl | ||
100 | }), | ||
101 | |||
88 | segmentUrlBuilder: segmentUrlBuilderFactory(redundancyUrlManager), | 102 | segmentUrlBuilder: segmentUrlBuilderFactory(redundancyUrlManager), |
89 | 103 | ||
90 | useP2P: this.options.common.p2pEnabled, | 104 | useP2P: this.options.common.p2pEnabled, |