mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: fix subscription process when transcievers API not available
parent
87e9fb308c
commit
e1b6fb6179
|
@ -89,7 +89,7 @@ export class OpenViduLogger {
|
||||||
const seen = new WeakSet();
|
const seen = new WeakSet();
|
||||||
return (key, value) => {
|
return (key, value) => {
|
||||||
if (typeof value === "object" && value != null) {
|
if (typeof value === "object" && value != null) {
|
||||||
if (seen.has(value) || value instanceof HTMLElement) {
|
if (seen.has(value) || (HTMLElement && value instanceof HTMLElement)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
seen.add(value);
|
seen.add(value);
|
||||||
|
|
|
@ -259,10 +259,7 @@ export class WebRtcPeer {
|
||||||
// "offerToReceiveAudio" and "offerToReceiveVideo".
|
// "offerToReceiveAudio" and "offerToReceiveVideo".
|
||||||
|
|
||||||
if (!!this.configuration.mediaStream) {
|
if (!!this.configuration.mediaStream) {
|
||||||
for (const track of this.configuration.mediaStream.getTracks()) {
|
this.deprecatedPeerConnectionTrackApi();
|
||||||
// @ts-ignore - Compiler is too clever and thinks this branch will never execute.
|
|
||||||
this.pc.addTrack(track, this.configuration.mediaStream);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasAudio = this.configuration.mediaConstraints.audio;
|
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
|
* Creates an SDP answer from the local RTCPeerConnection to send to the other peer
|
||||||
* Only if the negotiation was initiated by the other peer
|
* Only if the negotiation was initiated by the other peer
|
||||||
|
@ -324,6 +327,29 @@ export class WebRtcPeer {
|
||||||
.createAnswer()
|
.createAnswer()
|
||||||
.then((sdpAnswer) => resolve(sdpAnswer))
|
.then((sdpAnswer) => resolve(sdpAnswer))
|
||||||
.catch((error) => reject(error));
|
.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
|
// else, there is nothing to do; the legacy createAnswer() options do
|
||||||
|
|
Loading…
Reference in New Issue