Procházet zdrojové kódy

Reopen data channels on ice restart

dev1
paweldomas před 9 roky
rodič
revize
c90d758fdf

+ 7
- 0
JitsiConference.js Zobrazit soubor

@@ -931,6 +931,13 @@ function setupListeners(conference) {
931 931
         }
932 932
     });
933 933
 
934
+    conference.room.addListener(XMPPEvents.ICE_RESTARTING, function () {
935
+        // All data channels have to be closed, before ICE restart
936
+        // otherwise Chrome will not trigger "opened" event for the channel
937
+        // established with the new bridge
938
+        conference.rtc.closeAllDataChannels();
939
+    });
940
+
934 941
     conference.room.addListener(XMPPEvents.REMOTE_TRACK_ADDED,
935 942
         function (data) {
936 943
             var track = conference.rtc.createRemoteTrack(data);

+ 14
- 4
modules/RTC/DataChannels.js Zobrazit soubor

@@ -158,14 +158,24 @@ DataChannels.prototype.onDataChannel = function (event) {
158 158
     this._dataChannels.push(dataChannel);
159 159
 };
160 160
 
161
+/**
162
+ * Closes all currently opened data channels.
163
+ */
164
+DataChannels.prototype.closeAllChannels = function () {
165
+    this._dataChannels.forEach(function (dc){
166
+        // the DC will be removed from the array on 'onclose' event
167
+        dc.close();
168
+    });
169
+};
170
+
161 171
 DataChannels.prototype.handleSelectedEndpointEvent = function (userResource) {
162 172
     this.lastSelectedEndpoint = userResource;
163 173
     this._onXXXEndpointChanged("selected", userResource);
164
-}
174
+};
165 175
 
166 176
 DataChannels.prototype.handlePinnedEndpointEvent = function (userResource) {
167 177
     this._onXXXEndpointChanged("pinnned", userResource);
168
-}
178
+};
169 179
 
170 180
 /**
171 181
  * Notifies Videobridge about a change in the value of a specific
@@ -210,7 +220,7 @@ DataChannels.prototype._onXXXEndpointChanged = function (xxx, userResource) {
210 220
             return true;
211 221
         }
212 222
     });
213
-}
223
+};
214 224
 
215 225
 DataChannels.prototype._some = function (callback, thisArg) {
216 226
     var dataChannels = this._dataChannels;
@@ -223,6 +233,6 @@ DataChannels.prototype._some = function (callback, thisArg) {
223 233
     } else {
224 234
         return false;
225 235
     }
226
-}
236
+};
227 237
 
228 238
 module.exports = DataChannels;

+ 7
- 0
modules/RTC/RTC.js Zobrazit soubor

@@ -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 Zobrazit soubor

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

+ 5
- 0
service/xmpp/XMPPEvents.js Zobrazit soubor

@@ -43,6 +43,11 @@ 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",
46 51
     /* Event fired when XMPP error is returned to any request, it is meant to be
47 52
      * used to report 'signaling' errors to CallStats
48 53
      *

Načítá se…
Zrušit
Uložit