瀏覽代碼

ref: open WebRTC DataChannel

Changes the behavior to actively open new WebRTC Data Channel instead
of waiting for the JVB to do it.

Adds ICE_RESTART_SUCCESS event used to re-initialize the data channel in
case of ICE restart where the conference could have been moved to
another bridge.
dev1
paweldomas 6 年之前
父節點
當前提交
bbfe2eaea0
共有 4 個檔案被更改,包括 31 行新增10 行删除
  1. 11
    0
      JitsiConferenceEventManager.js
  2. 9
    10
      modules/RTC/BridgeChannel.js
  3. 5
    0
      modules/xmpp/JingleSessionPC.js
  4. 6
    0
      service/xmpp/XMPPEvents.js

+ 11
- 0
JitsiConferenceEventManager.js 查看文件

74
         // else: there are no DataChannels in P2P session (at least for now)
74
         // else: there are no DataChannels in P2P session (at least for now)
75
     });
75
     });
76
 
76
 
77
+    chatRoom.addListener(
78
+        XMPPEvents.ICE_RESTART_SUCCESS,
79
+        (jingleSession, offerIq) => {
80
+            // The JVB data chanel needs to be reopened in case the conference
81
+            // has been moved to a new bridge.
82
+            !jingleSession.isP2P
83
+                && conference._setBridgeChannel(
84
+                    offerIq, jingleSession.peerconnection);
85
+        });
86
+
87
+
77
     chatRoom.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
88
     chatRoom.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
78
         () => {
89
         () => {
79
             // TODO: Add a way to differentiate between commands which caused
90
             // TODO: Add a way to differentiate between commands which caused

+ 9
- 10
modules/RTC/BridgeChannel.js 查看文件

49
         // If a RTCPeerConnection is given, listen for new RTCDataChannel
49
         // If a RTCPeerConnection is given, listen for new RTCDataChannel
50
         // event.
50
         // event.
51
         if (peerconnection) {
51
         if (peerconnection) {
52
-            peerconnection.ondatachannel = event => {
53
-                // NOTE: We assume that the "onDataChannel" event just fires
54
-                // once.
55
-
56
-                const datachannel = event.channel;
57
-
58
-                // Handle the RTCDataChannel.
59
-                this._handleChannel(datachannel);
60
-                this._mode = 'datachannel';
61
-            };
52
+            const datachannel
53
+                = peerconnection.createDataChannel(
54
+                    'JVB data channel', {
55
+                        protocol: 'http://jitsi.org/protocols/colibri'
56
+                    });
57
+
58
+            // Handle the RTCDataChannel.
59
+            this._handleChannel(datachannel);
60
+            this._mode = 'datachannel';
62
 
61
 
63
         // Otherwise create a WebSocket connection.
62
         // Otherwise create a WebSocket connection.
64
         } else if (wsUrl) {
63
         } else if (wsUrl) {

+ 5
- 0
modules/xmpp/JingleSessionPC.js 查看文件

1000
                             = new SDP(this.peerconnection.localDescription.sdp);
1000
                             = new SDP(this.peerconnection.localDescription.sdp);
1001
 
1001
 
1002
                         this.sendTransportAccept(localSDP, success, failure);
1002
                         this.sendTransportAccept(localSDP, success, failure);
1003
+
1004
+                        this.room.eventEmitter.emit(
1005
+                            XMPPEvents.ICE_RESTART_SUCCESS,
1006
+                            this,
1007
+                            originalOffer);
1003
                     },
1008
                     },
1004
                     failure);
1009
                     failure);
1005
             },
1010
             },

+ 6
- 0
service/xmpp/XMPPEvents.js 查看文件

76
      */
76
      */
77
     ICE_RESTARTING: 'rtc.ice_restarting',
77
     ICE_RESTARTING: 'rtc.ice_restarting',
78
 
78
 
79
+    /**
80
+     * Event fired after the 'transport-replace' message has been processed
81
+     * and the new offer has been set successfully.
82
+     */
83
+    ICE_RESTART_SUCCESS: 'rtc.ice_restart_success',
84
+
79
     /* Event fired when XMPP error is returned to any request, it is meant to be
85
     /* Event fired when XMPP error is returned to any request, it is meant to be
80
      * used to report 'signaling' errors to CallStats
86
      * used to report 'signaling' errors to CallStats
81
      *
87
      *

Loading…
取消
儲存