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