From 2a8fc4719b4d3fca9f5be53509bb107d9a14f510 Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Wed, 27 May 2015 17:35:14 +0200 Subject: [PATCH] Fixed problem where Chrome thought it already has an offer because the SDP is empty string instead of returning null for remoteOffer. --- static/js/mediastream/peerconnection.js | 10 ++++++++++ static/js/mediastream/webrtc.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/static/js/mediastream/peerconnection.js b/static/js/mediastream/peerconnection.js index 56defc76..24b36580 100644 --- a/static/js/mediastream/peerconnection.js +++ b/static/js/mediastream/peerconnection.js @@ -268,6 +268,16 @@ define(['jquery', 'underscore', 'webrtc.adapter'], function($, _) { }; + PeerConnection.prototype.hasRemoteDescription = function() { + + // NOTE(longsleep): Chrome seems to return empty sdp even if no remoteDescription was set. + if (!this.pc || !this.pc.remoteDescription || !this.pc.remoteDescription.sdp) { + return false + } + return true; + + }; + PeerConnection.prototype.setRemoteDescription = function() { return this.pc.setRemoteDescription.apply(this.pc, arguments); diff --git a/static/js/mediastream/webrtc.js b/static/js/mediastream/webrtc.js index 01923a48..946bbae0 100644 --- a/static/js/mediastream/webrtc.js +++ b/static/js/mediastream/webrtc.js @@ -237,7 +237,7 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u console.log("Offer process."); targetcall = this.findTargetCall(from); if (targetcall) { - if (!this.settings.renegotiation && targetcall.peerconnection && targetcall.peerconnection.pc && targetcall.peerconnection.pc.remoteDescription) { + if (!this.settings.renegotiation && targetcall.peerconnection && targetcall.peerconnection.hasRemoteDescription()) { // Call replace support without renegotiation. this.doHangup("unsupported", from); console.error("Processing new offers is not implemented without renegotiation.");