Просмотр исходного кода

Merge branch 'master' into js_errors

dev1
Lyubomir Marinov 9 лет назад
Родитель
Сommit
6b84ef78d7
5 измененных файлов: 67 добавлений и 11 удалений
  1. 7
    0
      JitsiConference.js
  2. 14
    4
      modules/RTC/DataChannels.js
  3. 7
    0
      modules/RTC/RTC.js
  4. 23
    7
      modules/xmpp/JingleSessionPC.js
  5. 16
    0
      service/xmpp/XMPPEvents.js

+ 7
- 0
JitsiConference.js Просмотреть файл

@@ -955,6 +955,13 @@ function setupListeners(conference) {
955 955
         }
956 956
     });
957 957
 
958
+    conference.room.addListener(XMPPEvents.ICE_RESTARTING, function () {
959
+        // All data channels have to be closed, before ICE restart
960
+        // otherwise Chrome will not trigger "opened" event for the channel
961
+        // established with the new bridge
962
+        conference.rtc.closeAllDataChannels();
963
+    });
964
+
958 965
     conference.room.addListener(XMPPEvents.REMOTE_TRACK_ADDED,
959 966
         function (data) {
960 967
             var track = conference.rtc.createRemoteTrack(data);

+ 14
- 4
modules/RTC/DataChannels.js Просмотреть файл

@@ -163,14 +163,24 @@ DataChannels.prototype.onDataChannel = function (event) {
163 163
     this._dataChannels.push(dataChannel);
164 164
 };
165 165
 
166
+/**
167
+ * Closes all currently opened data channels.
168
+ */
169
+DataChannels.prototype.closeAllChannels = function () {
170
+    this._dataChannels.forEach(function (dc){
171
+        // the DC will be removed from the array on 'onclose' event
172
+        dc.close();
173
+    });
174
+};
175
+
166 176
 DataChannels.prototype.handleSelectedEndpointEvent = function (userResource) {
167 177
     this.lastSelectedEndpoint = userResource;
168 178
     this._onXXXEndpointChanged("selected", userResource);
169
-}
179
+};
170 180
 
171 181
 DataChannels.prototype.handlePinnedEndpointEvent = function (userResource) {
172 182
     this._onXXXEndpointChanged("pinnned", userResource);
173
-}
183
+};
174 184
 
175 185
 /**
176 186
  * Notifies Videobridge about a change in the value of a specific
@@ -215,7 +225,7 @@ DataChannels.prototype._onXXXEndpointChanged = function (xxx, userResource) {
215 225
             return true;
216 226
         }
217 227
     });
218
-}
228
+};
219 229
 
220 230
 DataChannels.prototype._some = function (callback, thisArg) {
221 231
     var dataChannels = this._dataChannels;
@@ -228,6 +238,6 @@ DataChannels.prototype._some = function (callback, thisArg) {
228 238
     } else {
229 239
         return false;
230 240
     }
231
-}
241
+};
232 242
 
233 243
 module.exports = DataChannels;

+ 7
- 0
modules/RTC/RTC.js Просмотреть файл

@@ -387,6 +387,13 @@ RTC.isDesktopSharingEnabled = function () {
387 387
     return RTCUtils.isDesktopSharingEnabled();
388 388
 };
389 389
 
390
+/**
391
+ * Closes all currently opened data channels.
392
+ */
393
+RTC.prototype.closeAllDataChannels = function () {
394
+    this.dataChannels.closeAllChannels();
395
+};
396
+
390 397
 RTC.prototype.dispose = function() {
391 398
 };
392 399
 

+ 23
- 7
modules/xmpp/JingleSessionPC.js Просмотреть файл

@@ -498,13 +498,29 @@ JingleSessionPC._fixAnswerRFC4145Setup = function (offer, answer) {
498 498
 JingleSessionPC.prototype.replaceTransport = function (jingleOfferElem,
499 499
                                                        success,
500 500
                                                        failure) {
501
-    // Set offer as RD
502
-    this.setOfferCycle(jingleOfferElem,
503
-        function () {
504
-            // Set local description OK, now localSDP up to date
505
-            this.sendTransportAccept(this.localSDP, success, failure);
506
-        }.bind(this),
507
-        failure);
501
+    
502
+    // We need to first set an offer without the 'data' section to have the SCTP
503
+    // stack cleaned up. After that the original offer is set to have the SCTP
504
+    // connection established with the new bridge.
505
+    this.room.eventEmitter.emit(XMPPEvents.ICE_RESTARTING);
506
+    var originalOffer = jingleOfferElem.clone();
507
+    jingleOfferElem.find(">content[name='data']").remove();
508
+
509
+    var self = this;
510
+    // First set an offer without the 'data' section
511
+    this.setOfferCycle(
512
+        jingleOfferElem,
513
+        function() {
514
+            // Now set the original offer(with the 'data' section)
515
+            self.setOfferCycle(originalOffer,
516
+                function () {
517
+                    // Set local description OK, now localSDP up to date
518
+                    self.sendTransportAccept(self.localSDP, success, failure);
519
+                },
520
+                failure);
521
+        },
522
+        failure
523
+    );
508 524
 };
509 525
 
510 526
 /**

+ 16
- 0
service/xmpp/XMPPEvents.js Просмотреть файл

@@ -43,6 +43,22 @@ var XMPPEvents = {
43 43
     FOCUS_DISCONNECTED: 'xmpp.focus_disconnected',
44 44
     FOCUS_LEFT: "xmpp.focus_left",
45 45
     GRACEFUL_SHUTDOWN: "xmpp.graceful_shutdown",
46
+    /**
47
+     * Event fired when 'transport-replace' Jingle message has been received,
48
+     * before the new offer is set on the PeerConnection.
49
+     */
50
+    ICE_RESTARTING: "rtc.ice_restarting",
51
+    /* Event fired when XMPP error is returned to any request, it is meant to be
52
+     * used to report 'signaling' errors to CallStats
53
+     *
54
+     * {
55
+     *   code: {XMPP error code}
56
+     *   reason: {XMPP error condition}
57
+     *   source = request.tree()
58
+     *   session = {JingleSession instance}
59
+     * }
60
+     */
61
+    JINGLE_ERROR: 'xmpp.jingle_error',
46 62
     // Event fired when we have failed to set initial offer
47 63
     JINGLE_FATAL_ERROR: 'xmpp.jingle_fatal_error',
48 64
     // Designates an event indicating that we were kicked from the XMPP MUC.

Загрузка…
Отмена
Сохранить