From 6fc335fd281fa61c48a43ae20269666ac872a0fb Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Tue, 4 Nov 2014 12:52:26 +0100 Subject: [PATCH] Implement workaround for FF not supporting onnegotiationneeded. --- static/js/mediastream/peerconnection.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/static/js/mediastream/peerconnection.js b/static/js/mediastream/peerconnection.js index 1db75f2f..f91d2b57 100644 --- a/static/js/mediastream/peerconnection.js +++ b/static/js/mediastream/peerconnection.js @@ -70,7 +70,16 @@ define(['jquery', 'underscore', 'webrtc.adapter'], function($, _) { // for example https://bugzilla.mozilla.org/show_bug.cgi?id=998546. pc.onaddstream = _.bind(this.onRemoteStreamAdded, this); pc.onremovestream = _.bind(this.onRemoteStreamRemoved, this); - pc.onnegotiationneeded = _.bind(this.onNegotiationNeeded, this); + // NOTE(longsleep): onnegotiationneeded is not supported by Firefox + // https://bugzilla.mozilla.org/show_bug.cgi?id=840728 + if (webrtcDetectedBrowser === "firefox") { + window.setTimeout(_.bind(function() { + // Trigger onNegotiationNeeded once for Firefox. + this.onNegotiationNeeded({target: pc}); + }, this), 0); + } else { + pc.onnegotiationneeded = _.bind(this.onNegotiationNeeded, this); + } pc.ondatachannel = _.bind(this.onDatachannel, this); pc.onsignalingstatechange = function(event) { // XXX(longsleep): Remove this or handle it in a real function.