Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Fixes bug with allocation of new PeerConnection, before the conference has started. Closes PeerConnection for non focus participant on beforeunload.

paweldomas4bb8c3c48c46
diff --git a/app.js b/app.js
index effe0fd80c..f0a73f9212 100644
--- a/app.js
+++ b/app.js
@@ -295,8 +295,7 @@ function handleVideoThumbClicked(videoSrc) {
updateLargeVideo(videoSrc, 1);
$('audio').each(function (idx, el) {
- // We no longer mix so we check for local audio now
- if(el.id != 'localAudio') {
+ if (el.id.indexOf('mixedmslabel') !== -1) {
el.volume = 0;
el.volume = 1;
}
@@ -450,8 +449,6 @@ $(document).bind('callactive.jingle', function (event, videoelem, sid) {
$(document).bind('callterminated.jingle', function (event, sid, reason) {
// FIXME
- focus = null;
- activecall = null;
});
$(document).bind('setLocalDescription.jingle', function (event, sid) {
@@ -575,14 +572,10 @@ $(document).bind('left.muc', function (event, jid) {
}
else if (focus && Object.keys(connection.emuc.members).length === 0) {
console.log('everyone left');
- if (focus !== null) {
- // FIXME: closing the connection is a hack to avoid some
- // problemswith reinit
- if (focus.peerconnection !== null) {
- focus.peerconnection.close();
- }
- focus = new ColibriFocus(connection, config.hosts.bridge);
- }
+ // FIXME: closing the connection is a hack to avoid some
+ // problemswith reinit
+ disposeConference();
+ focus = new ColibriFocus(connection, config.hosts.bridge);
}
if (connection.emuc.getPrezi(jid)) {
$(document).trigger('presentationremoved.muc', [jid, connection.emuc.getPrezi(jid)]);
@@ -967,8 +960,24 @@ $(window).bind('beforeunload', function () {
}
});
}
+ disposeConference();
});
+function disposeConference() {
+ var handler = getConferenceHandler();
+ if(handler) {
+ if(connection.jingle.localAudio) {
+ handler.peerconnection.removeStream(connection.jingle.localAudio);
+ }
+ if(connection.jingle.localVideo) {
+ handler.peerconnection.removeStream(connection.jingle.localVideo);
+ }
+ handler.peerconnection.close();
+ }
+ focus = null;
+ activecall = null;
+}
+
function dump(elem, filename){
elem = elem.parentNode;
elem.download = filename || 'meetlog.json';
diff --git a/libs/colibri/colibri.focus.js b/libs/colibri/colibri.focus.js
index 1195fbbe78..1b8c9e2237 100644
--- a/libs/colibri/colibri.focus.js
+++ b/libs/colibri/colibri.focus.js
@@ -75,11 +75,16 @@ ColibriFocus.prototype.makeConference = function (peers) {
self.channels.push([]);
});
- if(connection.jingle.localAudio) {
- this.peerconnection.addStream(connection.jingle.localAudio);
+ this.peerconnection
+ = new TraceablePeerConnection(
+ this.connection.jingle.ice_config,
+ this.connection.jingle.pc_constraints );
+
+ if(this.connection.jingle.localAudio) {
+ this.peerconnection.addStream(this.connection.jingle.localAudio);
}
- if(connection.jingle.localVideo) {
- this.peerconnection.addStream(connection.jingle.localVideo);
+ if(this.connection.jingle.localVideo) {
+ this.peerconnection.addStream(this.connection.jingle.localVideo);
}
this.peerconnection.oniceconnectionstatechange = function (event) {
console.warn('ice connection state changed to', self.peerconnection.iceConnectionState);
diff --git a/libs/strophe/strophe.jingle.adapter.js b/libs/strophe/strophe.jingle.adapter.js
index a9e1ac55a8..ae5b3d013e 100644
--- a/libs/strophe/strophe.jingle.adapter.js
+++ b/libs/strophe/strophe.jingle.adapter.js
@@ -328,6 +328,12 @@ TraceablePeerConnection.prototype.modifySources = function(successCallback) {
sdp.raw = sdp.session + sdp.media.join('');
this.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp.raw}),
function() {
+
+ if(self.signalingState == 'closed') {
+ console.error("createAnswer attempt on closed state");
+ return;
+ }
+
self.createAnswer(
function(modifiedAnswer) {
// change video direction, see https://github.com/jitsi/jitmeet/issues/41
diff --git a/libs/strophe/strophe.jingle.session.js b/libs/strophe/strophe.jingle.session.js
index 96631ebbf4..cb92e2329b 100644
--- a/libs/strophe/strophe.jingle.session.js
+++ b/libs/strophe/strophe.jingle.session.js
@@ -53,6 +53,12 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
this.hadstuncandidate = false;
this.hadturncandidate = false;
this.lasticecandidate = false;
+
+ this.peerconnection
+ = new TraceablePeerConnection(
+ this.connection.jingle.ice_config,
+ this.connection.jingle.pc_constraints );
+
this.peerconnection.onicecandidate = function (event) {
self.sendIceCandidate(event.candidate);
};
diff --git a/libs/strophe/strophe.jingle.sessionbase.js b/libs/strophe/strophe.jingle.sessionbase.js
index 6a2ebf2de7..c0519a0d6d 100644
--- a/libs/strophe/strophe.jingle.sessionbase.js
+++ b/libs/strophe/strophe.jingle.sessionbase.js
@@ -8,10 +8,6 @@ function SessionBase(connection, sid){
this.connection = connection;
this.sid = sid;
- this.peerconnection
- = new TraceablePeerConnection(
- connection.jingle.ice_config,
- connection.jingle.pc_constraints);
}
@@ -48,26 +44,27 @@ SessionBase.prototype.switchStreams = function (new_stream, oldStream, success_c
var self = this;
- // Remember SDP to figure out added/removed SSRCs
- var oldSdp = null;
- if(self.peerconnection.localDescription) {
- oldSdp = new SDP(self.peerconnection.localDescription.sdp);
- }
-
// Stop the stream to trigger onended event for old stream
oldStream.stop();
- self.peerconnection.removeStream(oldStream);
+ // Remember SDP to figure out added/removed SSRCs
+ var oldSdp = null;
+ if(self.peerconnection) {
+ if(self.peerconnection.localDescription) {
+ oldSdp = new SDP(self.peerconnection.localDescription.sdp);
+ }
+ self.peerconnection.removeStream(oldStream);
+ self.peerconnection.addStream(new_stream);
+ }
self.connection.jingle.localVideo = new_stream;
- self.peerconnection.addStream(self.connection.jingle.localVideo);
self.connection.jingle.localStreams = [];
self.connection.jingle.localStreams.push(self.connection.jingle.localAudio);
self.connection.jingle.localStreams.push(self.connection.jingle.localVideo);
// Conference is not active
- if(!oldSdp) {
+ if(!oldSdp || !self.peerconnection) {
success_callback();
return;
}