1
0
Fork 0

feat(plugins): add p2p-media-loader options filter (#5318)

* feat(plugins): add p2p-media-loader options filter

closes #5317

* remove obsolete await
This commit is contained in:
kontrollanten 2022-10-11 08:37:14 +02:00 committed by GitHub
parent dce2aba1e2
commit 9866921cbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View file

@ -19,12 +19,15 @@ export class HLSOptionsBuilder {
}
getPluginOptions () {
async getPluginOptions () {
const commonOptions = this.options.common
const redundancyUrlManager = new RedundancyUrlManager(this.options.p2pMediaLoader.redundancyBaseUrls)
const p2pMediaLoaderConfig = this.getP2PMediaLoaderOptions(redundancyUrlManager)
const p2pMediaLoaderConfig = await this.options.pluginsManager.runHook(
'filter:internal.player.p2p-media-loader.options.result',
this.getP2PMediaLoaderOptions(redundancyUrlManager)
)
const loader = new this.p2pMediaLoaderModule.Engine(p2pMediaLoaderConfig).createLoaderClass() as P2PMediaLoader
const p2pMediaLoader: P2PMediaLoaderPluginOptions = {

View file

@ -20,7 +20,7 @@ export class ManagerOptionsBuilder {
}
getVideojsOptions (alreadyPlayed: boolean): videojs.PlayerOptions {
async getVideojsOptions (alreadyPlayed: boolean): Promise<videojs.PlayerOptions> {
const commonOptions = this.options.common
let autoplay = this.getAutoPlayValue(commonOptions.autoplay, alreadyPlayed)
@ -61,7 +61,7 @@ export class ManagerOptionsBuilder {
if (this.mode === 'p2p-media-loader') {
const hlsOptionsBuilder = new HLSOptionsBuilder(this.options, this.p2pMediaLoaderModule)
const options = hlsOptionsBuilder.getPluginOptions()
const options = await hlsOptionsBuilder.getPluginOptions()
Object.assign(plugins, pick(options, [ 'hlsjs', 'p2pMediaLoader' ]))
Object.assign(html5, options.html5)

View file

@ -88,7 +88,10 @@ export const clientFilterHookObject = {
'filter:share.video-playlist-url.build.result': true,
// Filter videojs options built for PeerTube player
'filter:internal.player.videojs.options.result': true
'filter:internal.player.videojs.options.result': true,
// Filter p2p media loader options built for PeerTube player
'filter:internal.player.p2p-media-loader.options.result': true
}
export type ClientFilterHookName = keyof typeof clientFilterHookObject