diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-12 16:09:02 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-10-24 14:48:24 +0200 |
commit | 3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 (patch) | |
tree | e7f1d12ef5dae1e1142c3a8d0b681c1dbbb0de10 /client/src/assets/player/shared/manager-options | |
parent | 38a3ccc7f8ad0ea94362b58c732af7c387ab46be (diff) | |
download | PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.gz PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.tar.zst PeerTube-3545e72c686ff1725bbdfd8d16d693e2f4aa75a3.zip |
Put private videos under a specific subdirectory
Diffstat (limited to 'client/src/assets/player/shared/manager-options')
-rw-r--r-- | client/src/assets/player/shared/manager-options/hls-options-builder.ts | 18 | ||||
-rw-r--r-- | client/src/assets/player/shared/manager-options/webtorrent-options-builder.ts | 15 |
2 files changed, 29 insertions, 4 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, |
diff --git a/client/src/assets/player/shared/manager-options/webtorrent-options-builder.ts b/client/src/assets/player/shared/manager-options/webtorrent-options-builder.ts index 257cf1e05..b5bdcd4e6 100644 --- a/client/src/assets/player/shared/manager-options/webtorrent-options-builder.ts +++ b/client/src/assets/player/shared/manager-options/webtorrent-options-builder.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { PeertubePlayerManagerOptions } from '../../types' | 1 | import { addQueryParams } from '../../../../../../shared/core-utils' |
2 | import { PeertubePlayerManagerOptions, WebtorrentPluginOptions } from '../../types' | ||
2 | 3 | ||
3 | export class WebTorrentOptionsBuilder { | 4 | export class WebTorrentOptionsBuilder { |
4 | 5 | ||
@@ -16,13 +17,23 @@ export class WebTorrentOptionsBuilder { | |||
16 | 17 | ||
17 | const autoplay = this.autoPlayValue === 'play' | 18 | const autoplay = this.autoPlayValue === 'play' |
18 | 19 | ||
19 | const webtorrent = { | 20 | const webtorrent: WebtorrentPluginOptions = { |
20 | autoplay, | 21 | autoplay, |
21 | 22 | ||
22 | playerRefusedP2P: commonOptions.p2pEnabled === false, | 23 | playerRefusedP2P: commonOptions.p2pEnabled === false, |
23 | videoDuration: commonOptions.videoDuration, | 24 | videoDuration: commonOptions.videoDuration, |
24 | playerElement: commonOptions.playerElement, | 25 | playerElement: commonOptions.playerElement, |
25 | 26 | ||
27 | videoFileToken: commonOptions.videoFileToken, | ||
28 | |||
29 | requiresAuth: commonOptions.requiresAuth, | ||
30 | |||
31 | buildWebSeedUrls: file => { | ||
32 | if (!commonOptions.requiresAuth) return [] | ||
33 | |||
34 | return [ addQueryParams(file.fileUrl, { videoFileToken: commonOptions.videoFileToken() }) ] | ||
35 | }, | ||
36 | |||
26 | videoFiles: webtorrentOptions.videoFiles.length !== 0 | 37 | videoFiles: webtorrentOptions.videoFiles.length !== 0 |
27 | ? webtorrentOptions.videoFiles | 38 | ? webtorrentOptions.videoFiles |
28 | // The WebTorrent plugin won't be able to play these files, but it will fallback to HTTP mode | 39 | // The WebTorrent plugin won't be able to play these files, but it will fallback to HTTP mode |