Browse Source

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

j8
paweldomas 11 years ago
parent
commit
4bb8c3c48c

+ 21
- 12
app.js View File

@@ -295,8 +295,7 @@ function handleVideoThumbClicked(videoSrc) {
295 295
     updateLargeVideo(videoSrc, 1);
296 296
 
297 297
     $('audio').each(function (idx, el) {
298
-        // We no longer mix so we check for local audio now
299
-        if(el.id != 'localAudio') {
298
+        if (el.id.indexOf('mixedmslabel') !== -1) {
300 299
             el.volume = 0;
301 300
             el.volume = 1;
302 301
         }
@@ -450,8 +449,6 @@ $(document).bind('callactive.jingle', function (event, videoelem, sid) {
450 449
 
451 450
 $(document).bind('callterminated.jingle', function (event, sid, reason) {
452 451
     // FIXME
453
-    focus = null;
454
-    activecall = null;
455 452
 });
456 453
 
457 454
 $(document).bind('setLocalDescription.jingle', function (event, sid) {
@@ -575,14 +572,10 @@ $(document).bind('left.muc', function (event, jid) {
575 572
     }
576 573
     else if (focus && Object.keys(connection.emuc.members).length === 0) {
577 574
         console.log('everyone left');
578
-        if (focus !== null) {
579
-            // FIXME: closing the connection is a hack to avoid some
580
-            // problemswith reinit
581
-            if (focus.peerconnection !== null) {
582
-                focus.peerconnection.close();
583
-            }
584
-            focus = new ColibriFocus(connection, config.hosts.bridge);
585
-        }
575
+        // FIXME: closing the connection is a hack to avoid some
576
+        // problemswith reinit
577
+        disposeConference();
578
+        focus = new ColibriFocus(connection, config.hosts.bridge);
586 579
     }
587 580
     if (connection.emuc.getPrezi(jid)) {
588 581
         $(document).trigger('presentationremoved.muc', [jid, connection.emuc.getPrezi(jid)]);
@@ -967,8 +960,24 @@ $(window).bind('beforeunload', function () {
967 960
             }
968 961
         });
969 962
     }
963
+    disposeConference();
970 964
 });
971 965
 
966
+function disposeConference() {
967
+    var handler = getConferenceHandler();
968
+    if(handler) {
969
+        if(connection.jingle.localAudio) {
970
+            handler.peerconnection.removeStream(connection.jingle.localAudio);
971
+        }
972
+        if(connection.jingle.localVideo) {
973
+            handler.peerconnection.removeStream(connection.jingle.localVideo);
974
+        }
975
+        handler.peerconnection.close();
976
+    }
977
+    focus = null;
978
+    activecall = null;
979
+}
980
+
972 981
 function dump(elem, filename){
973 982
     elem = elem.parentNode;
974 983
     elem.download = filename || 'meetlog.json';

+ 9
- 4
libs/colibri/colibri.focus.js View File

@@ -75,11 +75,16 @@ ColibriFocus.prototype.makeConference = function (peers) {
75 75
         self.channels.push([]);
76 76
     });
77 77
 
78
-    if(connection.jingle.localAudio) {
79
-        this.peerconnection.addStream(connection.jingle.localAudio);
78
+    this.peerconnection
79
+        = new TraceablePeerConnection(
80
+            this.connection.jingle.ice_config,
81
+            this.connection.jingle.pc_constraints );
82
+
83
+    if(this.connection.jingle.localAudio) {
84
+        this.peerconnection.addStream(this.connection.jingle.localAudio);
80 85
     }
81
-    if(connection.jingle.localVideo) {
82
-        this.peerconnection.addStream(connection.jingle.localVideo);
86
+    if(this.connection.jingle.localVideo) {
87
+        this.peerconnection.addStream(this.connection.jingle.localVideo);
83 88
     }
84 89
     this.peerconnection.oniceconnectionstatechange = function (event) {
85 90
         console.warn('ice connection state changed to', self.peerconnection.iceConnectionState);

+ 6
- 0
libs/strophe/strophe.jingle.adapter.js View File

@@ -328,6 +328,12 @@ TraceablePeerConnection.prototype.modifySources = function(successCallback) {
328 328
     sdp.raw = sdp.session + sdp.media.join('');
329 329
     this.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp.raw}),
330 330
         function() {
331
+
332
+            if(self.signalingState == 'closed') {
333
+                console.error("createAnswer attempt on closed state");
334
+                return;
335
+            }
336
+
331 337
             self.createAnswer(
332 338
                 function(modifiedAnswer) {
333 339
                     // change video direction, see https://github.com/jitsi/jitmeet/issues/41

+ 6
- 0
libs/strophe/strophe.jingle.session.js View File

@@ -53,6 +53,12 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
53 53
     this.hadstuncandidate = false;
54 54
     this.hadturncandidate = false;
55 55
     this.lasticecandidate = false;
56
+
57
+    this.peerconnection
58
+        = new TraceablePeerConnection(
59
+            this.connection.jingle.ice_config,
60
+            this.connection.jingle.pc_constraints );
61
+
56 62
     this.peerconnection.onicecandidate = function (event) {
57 63
         self.sendIceCandidate(event.candidate);
58 64
     };

+ 10
- 13
libs/strophe/strophe.jingle.sessionbase.js View File

@@ -8,10 +8,6 @@ function SessionBase(connection, sid){
8 8
 
9 9
     this.connection = connection;
10 10
     this.sid = sid;
11
-    this.peerconnection
12
-        = new TraceablePeerConnection(
13
-            connection.jingle.ice_config,
14
-            connection.jingle.pc_constraints);
15 11
 }
16 12
 
17 13
 
@@ -48,26 +44,27 @@ SessionBase.prototype.switchStreams = function (new_stream, oldStream, success_c
48 44
 
49 45
     var self = this;
50 46
 
51
-    // Remember SDP to figure out added/removed SSRCs
52
-    var oldSdp = null;
53
-    if(self.peerconnection.localDescription) {
54
-        oldSdp = new SDP(self.peerconnection.localDescription.sdp);
55
-    }
56
-
57 47
     // Stop the stream to trigger onended event for old stream
58 48
     oldStream.stop();
59 49
 
60
-    self.peerconnection.removeStream(oldStream);
50
+    // Remember SDP to figure out added/removed SSRCs
51
+    var oldSdp = null;
52
+    if(self.peerconnection) {
53
+        if(self.peerconnection.localDescription) {
54
+            oldSdp = new SDP(self.peerconnection.localDescription.sdp);
55
+        }
56
+        self.peerconnection.removeStream(oldStream);
57
+        self.peerconnection.addStream(new_stream);
58
+    }
61 59
 
62 60
     self.connection.jingle.localVideo = new_stream;
63
-    self.peerconnection.addStream(self.connection.jingle.localVideo);
64 61
 
65 62
     self.connection.jingle.localStreams = [];
66 63
     self.connection.jingle.localStreams.push(self.connection.jingle.localAudio);
67 64
     self.connection.jingle.localStreams.push(self.connection.jingle.localVideo);
68 65
 
69 66
     // Conference is not active
70
-    if(!oldSdp) {
67
+    if(!oldSdp || !self.peerconnection) {
71 68
         success_callback();
72 69
         return;
73 70
     }

Loading…
Cancel
Save