Eyevinn / webrtc-player

WebRTC (recvonly) player
MIT License
92 stars 20 forks source link

add headers to WHEP server calls #66

Closed hakim89 closed 6 months ago

hakim89 commented 6 months ago

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

friday commented 6 months ago

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

hakim89 commented 6 months ago

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

friday commented 6 months ago

Looks like you are :100: 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?

birme commented 6 months ago

Cool, I can fix a release!

birme commented 6 months ago

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