瀏覽代碼

[RN] Use participant connection status events instead of last N

They better represent if a participant has video available or not. There are
cases when even a participant in the last N set would not have video because it
disconnected momentarily, for example.
master
Saúl Ibarra Corretgé 8 年之前
父節點
當前提交
618dedc58e

+ 3
- 27
react/features/base/conference/actions.js 查看文件

@@ -1,6 +1,6 @@
1 1
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
2 2
 import {
3
-    changeParticipantLastNStatus,
3
+    changeParticipantConnectionStatus,
4 4
     dominantSpeakerChanged,
5 5
     getLocalParticipant,
6 6
     participantJoined,
@@ -54,8 +54,8 @@ function _addConferenceListeners(conference, dispatch) {
54 54
             (...args) => dispatch(dominantSpeakerChanged(...args)));
55 55
 
56 56
     conference.on(
57
-        JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
58
-        (...args) => _lastNEndpointsChanged(dispatch, ...args));
57
+        JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
58
+        (...args) => dispatch(changeParticipantConnectionStatus(...args)));
59 59
 
60 60
     conference.on(
61 61
             JitsiConferenceEvents.LOCK_STATE_CHANGED,
@@ -268,30 +268,6 @@ export function createConference() {
268 268
     };
269 269
 }
270 270
 
271
-/**
272
- * Handles the lastN status changes for participants in the current conference.
273
- * Signals that a participant's lastN status has changed, for each participant
274
- * who entered or left the last N set.
275
- *
276
- * @param {Dispatch} dispatch - Redux dispatch function.
277
- * @param {Array} leavingIds - Ids of participants who are leaving the last N
278
- * set.
279
- * @param {Array} enteringIds - Ids of participants who are entering the last N
280
- * set.
281
- * @returns {void}
282
- *
283
- * @private
284
- */
285
-function _lastNEndpointsChanged(dispatch, leavingIds = [], enteringIds = []) {
286
-    for (const id of leavingIds) {
287
-        dispatch(changeParticipantLastNStatus(id, false));
288
-    }
289
-
290
-    for (const id of enteringIds) {
291
-        dispatch(changeParticipantLastNStatus(id, true));
292
-    }
293
-}
294
-
295 271
 /**
296 272
  * Signals that the lock state of a specific JitsiConference changed.
297 273
  *

+ 2
- 0
react/features/base/lib-jitsi-meet/index.js 查看文件

@@ -10,6 +10,8 @@ export const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
10 10
 export const JitsiConferenceEvents = JitsiMeetJS.events.conference;
11 11
 export const JitsiConnectionErrors = JitsiMeetJS.errors.connection;
12 12
 export const JitsiConnectionEvents = JitsiMeetJS.events.connection;
13
+export const JitsiParticipantConnectionStatus
14
+    = JitsiMeetJS.constants.participantConnectionStatus;
13 15
 export const JitsiTrackErrors = JitsiMeetJS.errors.track;
14 16
 export const JitsiTrackEvents = JitsiMeetJS.events.track;
15 17
 

+ 6
- 6
react/features/base/participants/actions.js 查看文件

@@ -9,25 +9,25 @@ import {
9 9
 import { getLocalParticipant } from './functions';
10 10
 
11 11
 /**
12
- * Action to update a participant's lastN status.
12
+ * Action to update a participant's connection status.
13 13
  *
14 14
  * @param {string} id - Participant's ID.
15
- * @param {boolean} isInLastN - True if the participant is in the lastN
16
- * endpoints set, false otherwise.
15
+ * @param {string} connectionStatus - The new connection status for the
16
+ * participant.
17 17
  * @returns {{
18 18
  *     type: PARTICIPANT_UPDATED,
19 19
  *     participant: {
20 20
  *         id: string,
21
- *         isInLastN: boolean
21
+ *         connectionStatus: string
22 22
  *     }
23 23
  * }}
24 24
  */
25
-export function changeParticipantLastNStatus(id, isInLastN) {
25
+export function changeParticipantConnectionStatus(id, connectionStatus) {
26 26
     return {
27 27
         type: PARTICIPANT_UPDATED,
28 28
         participant: {
29 29
             id,
30
-            isInLastN
30
+            connectionStatus
31 31
         }
32 32
     };
33 33
 }

+ 12
- 8
react/features/base/participants/components/ParticipantView.native.js 查看文件

@@ -1,6 +1,7 @@
1 1
 import React, { Component } from 'react';
2 2
 import { connect } from 'react-redux';
3 3
 
4
+import { JitsiParticipantConnectionStatus } from '../../lib-jitsi-meet';
4 5
 import {
5 6
     MEDIA_TYPE,
6 7
     shouldRenderVideoTrack,
@@ -35,11 +36,12 @@ class ParticipantView extends Component {
35 36
         _avatar: React.PropTypes.string,
36 37
 
37 38
         /**
38
-         * True if the participant is in the last N endpoints set, false if he
39
-         * isn't. If undefined, we have no indication, so the same course of
40
-         * action as true is taken.
39
+         * The connection status for the participant. Its video will only be
40
+         * rendered if the connection status is 'active', otherwise the avatar
41
+         * will be rendered. If undefined, we have no indication, so the same
42
+         * course of action as 'active' is taken.
41 43
          */
42
-        _isInLastN: React.PropTypes.bool,
44
+        _connectionStatus: React.PropTypes.string,
43 45
 
44 46
         /**
45 47
          * The video Track of the participant with {@link #participantId}.
@@ -94,7 +96,7 @@ class ParticipantView extends Component {
94 96
     render() {
95 97
         const {
96 98
             _avatar: avatar,
97
-            _isInLastN: isInLastN,
99
+            _connectionStatus: connectionStatus,
98 100
             _videoTrack: videoTrack
99 101
         } = this.props;
100 102
 
@@ -105,7 +107,9 @@ class ParticipantView extends Component {
105 107
         const waitForVideoStarted = false;
106 108
         const renderVideo
107 109
             = shouldRenderVideoTrack(videoTrack, waitForVideoStarted)
108
-                && (typeof isInLastN === 'undefined' || isInLastN);
110
+                && (typeof connectionStatus === 'undefined'
111
+                    || connectionStatus
112
+                        === JitsiParticipantConnectionStatus.ACTIVE);
109 113
 
110 114
         // Is the avatar to be rendered?
111 115
         const renderAvatar = Boolean(!renderVideo && avatar);
@@ -168,7 +172,7 @@ function _toBoolean(value, undefinedValue) {
168 172
  * @private
169 173
  * @returns {{
170 174
  *     _avatar: string,
171
- *     _isInLastN: boolean,
175
+ *     _connectionStatus: string,
172 176
  *     _videoTrack: Track
173 177
  * }}
174 178
  */
@@ -181,7 +185,7 @@ function _mapStateToProps(state, ownProps) {
181 185
 
182 186
     return {
183 187
         _avatar: participant && getAvatarURL(participant),
184
-        _isInLastN: participant && participant.isInLastN,
188
+        _connectionStatus: participant && participant.connectionStatus,
185 189
         _videoTrack:
186 190
             getTrackByMediaTypeAndParticipant(
187 191
                 state['features/base/tracks'],

+ 2
- 2
react/features/base/participants/reducer.js 查看文件

@@ -75,7 +75,7 @@ function _participant(state, action) {
75 75
             avatarURL,
76 76
             dominantSpeaker,
77 77
             email,
78
-            isInLastN,
78
+            connectionStatus,
79 79
             local,
80 80
             pinned,
81 81
             role
@@ -110,7 +110,7 @@ function _participant(state, action) {
110 110
             dominantSpeaker: dominantSpeaker || false,
111 111
             email,
112 112
             id,
113
-            isInLastN,
113
+            connectionStatus,
114 114
             local: local || false,
115 115
             name,
116 116
             pinned: pinned || false,

Loading…
取消
儲存