From 087c26d4942e6d93f63d89c425d9fb2d88f6bbf7 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Mon, 5 Jan 2015 12:56:31 +0100 Subject: [PATCH] Fixes issue with switching desktop stream. --- libs/strophe/strophe.jingle.sdp.js | 4 +- libs/strophe/strophe.jingle.session.js | 57 +++++++++++++------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/libs/strophe/strophe.jingle.sdp.js b/libs/strophe/strophe.jingle.sdp.js index 4a6b7ed34..19f73c62f 100644 --- a/libs/strophe/strophe.jingle.sdp.js +++ b/libs/strophe/strophe.jingle.sdp.js @@ -72,8 +72,8 @@ SDP.prototype.containsSSRC = function(ssrc) { }; function SDPDiffer(mySDP, otherSDP) { - this.mySDP = new SDP(mySDP); - this.otherSDP = new SDP(otherSDP); + this.mySDP = mySDP; + this.otherSDP = otherSDP; } /** diff --git a/libs/strophe/strophe.jingle.session.js b/libs/strophe/strophe.jingle.session.js index 31eac54a7..dfb8952d4 100644 --- a/libs/strophe/strophe.jingle.session.js +++ b/libs/strophe/strophe.jingle.session.js @@ -968,43 +968,20 @@ JingleSession.prototype.switchStreams = function (new_stream, oldStream, success */ JingleSession.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) { - if (!(this.peerconnection.signalingState == 'stable' && this.peerconnection.iceConnectionState == 'connected')){ + if (!(this.peerconnection.signalingState == 'stable' && + this.peerconnection.iceConnectionState == 'connected')){ console.log("Too early to send updates"); return; } - // send source-add IQ. - var sdpDiffer = new SDPDiffer(old_sdp, new_sdp); - var add = $iq({to: self.peerjid, type: 'set'}) - .c('jingle', { - xmlns: 'urn:xmpp:jingle:1', - action: 'source-add', - initiator: self.initiator, - sid: self.sid - } - ); - var added = sdpDiffer.toJingle(add); - if (added) { - this.connection.sendIQ(add, - function (res) { - console.info('got add result', res); - }, - function (err) { - console.error('got add error', err); - } - ); - } else { - console.log('addition not necessary'); - } - // send source-remove IQ. sdpDiffer = new SDPDiffer(new_sdp, old_sdp); - var remove = $iq({to: self.peerjid, type: 'set'}) + var remove = $iq({to: this.peerjid, type: 'set'}) .c('jingle', { xmlns: 'urn:xmpp:jingle:1', action: 'source-remove', - initiator: self.initiator, - sid: self.sid + initiator: this.initiator, + sid: this.sid } ); var removed = sdpDiffer.toJingle(remove); @@ -1020,6 +997,30 @@ JingleSession.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) { } else { console.log('removal not necessary'); } + + // send source-add IQ. + var sdpDiffer = new SDPDiffer(old_sdp, new_sdp); + var add = $iq({to: this.peerjid, type: 'set'}) + .c('jingle', { + xmlns: 'urn:xmpp:jingle:1', + action: 'source-add', + initiator: this.initiator, + sid: this.sid + } + ); + var added = sdpDiffer.toJingle(add); + if (added) { + this.connection.sendIQ(add, + function (res) { + console.info('got add result', res); + }, + function (err) { + console.error('got add error', err); + } + ); + } else { + console.log('addition not necessary'); + } }; /**