openvidu-browser: fix subscription process when transcievers API not available

pull/648/head
pabloFuente 2021-07-07 12:53:20 +02:00
parent 87e9fb308c
commit e1b6fb6179
2 changed files with 31 additions and 5 deletions

View File

@ -89,7 +89,7 @@ export class OpenViduLogger {
const seen = new WeakSet();
return (key, value) => {
if (typeof value === "object" && value != null) {
if (seen.has(value) || value instanceof HTMLElement) {
if (seen.has(value) || (HTMLElement && value instanceof HTMLElement)) {
return;
}
seen.add(value);

View File

@ -259,10 +259,7 @@ export class WebRtcPeer {
// "offerToReceiveAudio" and "offerToReceiveVideo".
if (!!this.configuration.mediaStream) {
for (const track of this.configuration.mediaStream.getTracks()) {
// @ts-ignore - Compiler is too clever and thinks this branch will never execute.
this.pc.addTrack(track, this.configuration.mediaStream);
}
this.deprecatedPeerConnectionTrackApi();
}
const hasAudio = this.configuration.mediaConstraints.audio;
@ -286,6 +283,12 @@ export class WebRtcPeer {
});
}
deprecatedPeerConnectionTrackApi() {
for (const track of this.configuration.mediaStream!.getTracks()) {
this.pc.addTrack(track, this.configuration.mediaStream!);
}
}
/**
* Creates an SDP answer from the local RTCPeerConnection to send to the other peer
* Only if the negotiation was initiated by the other peer
@ -324,6 +327,29 @@ export class WebRtcPeer {
.createAnswer()
.then((sdpAnswer) => resolve(sdpAnswer))
.catch((error) => reject(error));
} else {
// TODO: Delete else branch when all supported browsers are
// modern enough to implement the Transceiver methods
let offerAudio, offerVideo = true;
if (!!this.configuration.mediaConstraints) {
offerAudio = (typeof this.configuration.mediaConstraints.audio === 'boolean') ?
this.configuration.mediaConstraints.audio : true;
offerVideo = (typeof this.configuration.mediaConstraints.video === 'boolean') ?
this.configuration.mediaConstraints.video : true;
const constraints: RTCOfferOptions = {
offerToReceiveAudio: offerAudio,
offerToReceiveVideo: offerVideo
};
this.pc!.createAnswer(constraints).then(sdpAnswer => {
resolve(sdpAnswer);
}).catch(error => {
reject(error);
});
}
}
// else, there is nothing to do; the legacy createAnswer() options do