Eyevinn / webrtc-player

WebRTC (recvonly) player

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add headers to WHEP server calls

hakim89 opened this issue · comments

I have a media server serving multiple streams over whep protocol but requires Basic Auth.
Any way I can add headers to all server calls WebRTCPlayer makes?
Thank you

It sounds like something we should be able to support. We will try to look into this soon.

Thank you.
I did create my own adapter and set the authKey with the basic auth header and it worked.
I can also see how the load function in main branch has a new arg as the authKey (not in the 0.12.1 tag) so hopefully this is coming in newer versions.

 async load(channelUrl: URL, authKey: string | undefined = undefined) {
    this.channelUrl = channelUrl;
    this.authKey = authKey;
    this.connect();
  }

Thank you

Looks like you are 💯 correct. The authKey is used as the Authorization header, so this should already work for the WHEP adapter (only), but we haven't released it.

const basicAuthKey = btoa(`${user}:${passwd}`);
const authKey = `Basic ${basicAuthKey}`;
await player.load(new URL(channelUrl), authKey);

Do you want to make a release @birme or should I?

Cool, I can fix a release!

A new release including this feature is now available (v0.13.0)