소스 검색

fix(JitsiConference): decline P2P offer if should not be in P2P

The client will reject P2P session-initiate if the conditions which
allow for P2P session to start are not met(there more or less than 2
human participants in the call).
dev1
paweldomas 5 년 전
부모
커밋
179f3b87fd
3개의 변경된 파일39개의 추가작업 그리고 9개의 파일을 삭제
  1. 26
    5
      JitsiConference.js
  2. 6
    4
      modules/xmpp/JingleSessionPC.js
  3. 7
    0
      service/statistics/AnalyticsEvents.js

+ 26
- 5
JitsiConference.js 파일 보기

@@ -46,6 +46,7 @@ import {
46 46
     ACTION_JINGLE_SI_RECEIVED,
47 47
     ACTION_JINGLE_SI_TIMEOUT,
48 48
     ACTION_JINGLE_TERMINATE,
49
+    ACTION_P2P_DECLINED,
49 50
     ACTION_P2P_ESTABLISHED,
50 51
     ACTION_P2P_FAILED,
51 52
     ACTION_P2P_SWITCH_TO_JVB,
@@ -1699,6 +1700,13 @@ JitsiConference.prototype._onIncomingCallP2P = function(
1699 1700
             reasonDescription: 'P2P already in progress',
1700 1701
             errorMsg: 'Duplicated P2P "session-initiate"'
1701 1702
         };
1703
+    } else if (!this._shouldBeInP2PMode()) {
1704
+        rejectReason = {
1705
+            reason: 'decline',
1706
+            reasonDescription: 'P2P requirements not met',
1707
+            errorMsg: 'Received P2P "session-initiate" when should not be in P2P mode'
1708
+        };
1709
+        Statistics.sendAnalytics(createJingleEvent(ACTION_P2P_DECLINED));
1702 1710
     }
1703 1711
 
1704 1712
     if (rejectReason) {
@@ -2940,13 +2948,9 @@ JitsiConference.prototype._maybeStartOrStopP2P = function(userLeftEvent) {
2940 2948
     }
2941 2949
     const peers = this.getParticipants();
2942 2950
     const peerCount = peers.length;
2943
-    const hasBotPeer
2944
-        = peers.find(p => p._botType === 'poltergeist') !== undefined;
2945 2951
 
2946 2952
     // FIXME 1 peer and it must *support* P2P switching
2947
-    const shouldBeInP2P = peerCount === 1 && !hasBotPeer;
2948
-
2949
-    logger.debug(`P2P? peerCount: ${peerCount}, hasBotPeer: ${hasBotPeer} => ${shouldBeInP2P}`);
2953
+    const shouldBeInP2P = this._shouldBeInP2PMode();
2950 2954
 
2951 2955
     // Clear deferred "start P2P" task
2952 2956
     if (!shouldBeInP2P && this.deferredStartP2PTask) {
@@ -3003,6 +3007,23 @@ JitsiConference.prototype._maybeStartOrStopP2P = function(userLeftEvent) {
3003 3007
     }
3004 3008
 };
3005 3009
 
3010
+/**
3011
+ * Tells whether or not this conference should be currently in the P2P mode.
3012
+ *
3013
+ * @private
3014
+ * @returns {boolean}
3015
+ */
3016
+JitsiConference.prototype._shouldBeInP2PMode = function() {
3017
+    const peers = this.getParticipants();
3018
+    const peerCount = peers.length;
3019
+    const hasBotPeer = peers.find(p => p._botType === 'poltergeist') !== undefined;
3020
+    const shouldBeInP2P = peerCount === 1 && !hasBotPeer;
3021
+
3022
+    logger.debug(`P2P? peerCount: ${peerCount}, hasBotPeer: ${hasBotPeer} => ${shouldBeInP2P}`);
3023
+
3024
+    return shouldBeInP2P;
3025
+};
3026
+
3006 3027
 /**
3007 3028
  * Stops the current P2P session.
3008 3029
  * @param {string} [reason="success"] one of the Jingle "reason" element

+ 6
- 4
modules/xmpp/JingleSessionPC.js 파일 보기

@@ -2211,10 +2211,12 @@ export default class JingleSessionPC extends JingleSession {
2211 2211
         this.state = JingleSessionState.ENDED;
2212 2212
         this.establishmentDuration = undefined;
2213 2213
 
2214
-        this.peerconnection.onicecandidate = null;
2215
-        this.peerconnection.oniceconnectionstatechange = null;
2216
-        this.peerconnection.onnegotiationneeded = null;
2217
-        this.peerconnection.onsignalingstatechange = null;
2214
+        if (this.peerconnection) {
2215
+            this.peerconnection.onicecandidate = null;
2216
+            this.peerconnection.oniceconnectionstatechange = null;
2217
+            this.peerconnection.onnegotiationneeded = null;
2218
+            this.peerconnection.onsignalingstatechange = null;
2219
+        }
2218 2220
 
2219 2221
         // Remove any pending tasks from the queue
2220 2222
         this.modificationQueue.clear();

+ 7
- 0
service/statistics/AnalyticsEvents.js 파일 보기

@@ -98,6 +98,13 @@ export const ACTION_JINGLE_TR_RECEIVED
98 98
 export const ACTION_JINGLE_TR_SUCCESS
99 99
     = 'transport-replace.success';
100 100
 
101
+/**
102
+ * The "action" value for P2P events which indicates that P2P session initiate message has been rejected by the client
103
+ * because the mandatory requirements were not met.
104
+ * @type {string}
105
+ */
106
+export const ACTION_P2P_DECLINED = 'decline';
107
+
101 108
 /**
102 109
  * The "action" value for P2P events which indicates that a connection was
103 110
  * established (TODO: verify/fix the documentation)

Loading…
취소
저장