openvidu-browser: Unified Plan support by default

pull/623/head
pabloFuente 2021-05-04 10:14:29 +02:00
parent 36c707bfb8
commit e5b4c725be
1 changed files with 13 additions and 10 deletions

View File

@ -135,16 +135,12 @@ export class WebRtcPeer {
this.configuration.mediaConstraints.video : true;
}
const constraints: RTCOfferOptions = {
offerToReceiveAudio: (this.configuration.mode !== 'sendonly' && offerAudio),
offerToReceiveVideo: (this.configuration.mode !== 'sendonly' && offerVideo)
};
if (typeof this.pc['addTransceiver'] === 'function') {
logger.debug('RTCPeerConnection constraints: ' + JSON.stringify(constraints));
// SDP "Unified Plan" supported
logger.debug('Unified Plan supported');
if (platform.isSafariBrowser() && !platform.isIonicIos()) {
// Safari (excluding Ionic), at least on iOS just seems to support unified plan,
// whereas in other browsers is not yet ready and considered experimental
if (offerAudio) {
this.pc.addTransceiver('audio', {
direction: this.configuration.mode,
@ -163,10 +159,17 @@ export class WebRtcPeer {
resolve(offer);
})
.catch(error => reject(error));
} else {
// Rest of platforms
// SDP legacy "Plan B" support
const constraints: RTCOfferOptions = {
offerToReceiveAudio: (this.configuration.mode !== 'sendonly' && offerAudio),
offerToReceiveVideo: (this.configuration.mode !== 'sendonly' && offerVideo)
};
logger.debug('Unified Plan not supported. Using Plan B. RTCPeerConnection constraints: ' + JSON.stringify(constraints));
this.pc.createOffer(constraints)
.then(offer => {
logger.debug('Created SDP offer');