aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2022-10-11 08:37:14 +0200
committerGitHub <noreply@github.com>2022-10-11 08:37:14 +0200
commit9866921cbf3f8f0925f7ffb3a231d5dfe2d30953 (patch)
treea90e0ef79a60a739d98d3b1356039e23b7fbd9cb
parentdce2aba1e2c39535ed6af43f6aaf792ead8b0a6e (diff)
downloadPeerTube-9866921cbf3f8f0925f7ffb3a231d5dfe2d30953.tar.gz
PeerTube-9866921cbf3f8f0925f7ffb3a231d5dfe2d30953.tar.zst
PeerTube-9866921cbf3f8f0925f7ffb3a231d5dfe2d30953.zip
feat(plugins): add p2p-media-loader options filter (#5318)
* feat(plugins): add p2p-media-loader options filter closes #5317 * remove obsolete await
-rw-r--r--client/src/assets/player/shared/manager-options/hls-options-builder.ts7
-rw-r--r--client/src/assets/player/shared/manager-options/manager-options-builder.ts4
-rw-r--r--shared/models/plugins/client/client-hook.model.ts5
3 files changed, 11 insertions, 5 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 a572febc2..361c76f4b 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
@@ -19,12 +19,15 @@ export class HLSOptionsBuilder {
19 19
20 } 20 }
21 21
22 getPluginOptions () { 22 async getPluginOptions () {
23 const commonOptions = this.options.common 23 const commonOptions = this.options.common
24 24
25 const redundancyUrlManager = new RedundancyUrlManager(this.options.p2pMediaLoader.redundancyBaseUrls) 25 const redundancyUrlManager = new RedundancyUrlManager(this.options.p2pMediaLoader.redundancyBaseUrls)
26 26
27 const p2pMediaLoaderConfig = this.getP2PMediaLoaderOptions(redundancyUrlManager) 27 const p2pMediaLoaderConfig = await this.options.pluginsManager.runHook(
28 'filter:internal.player.p2p-media-loader.options.result',
29 this.getP2PMediaLoaderOptions(redundancyUrlManager)
30 )
28 const loader = new this.p2pMediaLoaderModule.Engine(p2pMediaLoaderConfig).createLoaderClass() as P2PMediaLoader 31 const loader = new this.p2pMediaLoaderModule.Engine(p2pMediaLoaderConfig).createLoaderClass() as P2PMediaLoader
29 32
30 const p2pMediaLoader: P2PMediaLoaderPluginOptions = { 33 const p2pMediaLoader: P2PMediaLoaderPluginOptions = {
diff --git a/client/src/assets/player/shared/manager-options/manager-options-builder.ts b/client/src/assets/player/shared/manager-options/manager-options-builder.ts
index 07678493d..2d96c9410 100644
--- a/client/src/assets/player/shared/manager-options/manager-options-builder.ts
+++ b/client/src/assets/player/shared/manager-options/manager-options-builder.ts
@@ -20,7 +20,7 @@ export class ManagerOptionsBuilder {
20 20
21 } 21 }
22 22
23 getVideojsOptions (alreadyPlayed: boolean): videojs.PlayerOptions { 23 async getVideojsOptions (alreadyPlayed: boolean): Promise<videojs.PlayerOptions> {
24 const commonOptions = this.options.common 24 const commonOptions = this.options.common
25 25
26 let autoplay = this.getAutoPlayValue(commonOptions.autoplay, alreadyPlayed) 26 let autoplay = this.getAutoPlayValue(commonOptions.autoplay, alreadyPlayed)
@@ -61,7 +61,7 @@ export class ManagerOptionsBuilder {
61 61
62 if (this.mode === 'p2p-media-loader') { 62 if (this.mode === 'p2p-media-loader') {
63 const hlsOptionsBuilder = new HLSOptionsBuilder(this.options, this.p2pMediaLoaderModule) 63 const hlsOptionsBuilder = new HLSOptionsBuilder(this.options, this.p2pMediaLoaderModule)
64 const options = hlsOptionsBuilder.getPluginOptions() 64 const options = await hlsOptionsBuilder.getPluginOptions()
65 65
66 Object.assign(plugins, pick(options, [ 'hlsjs', 'p2pMediaLoader' ])) 66 Object.assign(plugins, pick(options, [ 'hlsjs', 'p2pMediaLoader' ]))
67 Object.assign(html5, options.html5) 67 Object.assign(html5, options.html5)
diff --git a/shared/models/plugins/client/client-hook.model.ts b/shared/models/plugins/client/client-hook.model.ts
index e6313b60e..20e019304 100644
--- a/shared/models/plugins/client/client-hook.model.ts
+++ b/shared/models/plugins/client/client-hook.model.ts
@@ -88,7 +88,10 @@ export const clientFilterHookObject = {
88 'filter:share.video-playlist-url.build.result': true, 88 'filter:share.video-playlist-url.build.result': true,
89 89
90 // Filter videojs options built for PeerTube player 90 // Filter videojs options built for PeerTube player
91 'filter:internal.player.videojs.options.result': true 91 'filter:internal.player.videojs.options.result': true,
92
93 // Filter p2p media loader options built for PeerTube player
94 'filter:internal.player.p2p-media-loader.options.result': true
92} 95}
93 96
94export type ClientFilterHookName = keyof typeof clientFilterHookObject 97export type ClientFilterHookName = keyof typeof clientFilterHookObject