瀏覽代碼

[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
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
1
 import { JitsiConferenceEvents } from '../lib-jitsi-meet';
2
 import {
2
 import {
3
-    changeParticipantLastNStatus,
3
+    changeParticipantConnectionStatus,
4
     dominantSpeakerChanged,
4
     dominantSpeakerChanged,
5
     getLocalParticipant,
5
     getLocalParticipant,
6
     participantJoined,
6
     participantJoined,
54
             (...args) => dispatch(dominantSpeakerChanged(...args)));
54
             (...args) => dispatch(dominantSpeakerChanged(...args)));
55
 
55
 
56
     conference.on(
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
     conference.on(
60
     conference.on(
61
             JitsiConferenceEvents.LOCK_STATE_CHANGED,
61
             JitsiConferenceEvents.LOCK_STATE_CHANGED,
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
  * Signals that the lock state of a specific JitsiConference changed.
272
  * Signals that the lock state of a specific JitsiConference changed.
297
  *
273
  *

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

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

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

9
 import { getLocalParticipant } from './functions';
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
  * @param {string} id - Participant's ID.
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
  * @returns {{
17
  * @returns {{
18
  *     type: PARTICIPANT_UPDATED,
18
  *     type: PARTICIPANT_UPDATED,
19
  *     participant: {
19
  *     participant: {
20
  *         id: string,
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
     return {
26
     return {
27
         type: PARTICIPANT_UPDATED,
27
         type: PARTICIPANT_UPDATED,
28
         participant: {
28
         participant: {
29
             id,
29
             id,
30
-            isInLastN
30
+            connectionStatus
31
         }
31
         }
32
     };
32
     };
33
 }
33
 }

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

1
 import React, { Component } from 'react';
1
 import React, { Component } from 'react';
2
 import { connect } from 'react-redux';
2
 import { connect } from 'react-redux';
3
 
3
 
4
+import { JitsiParticipantConnectionStatus } from '../../lib-jitsi-meet';
4
 import {
5
 import {
5
     MEDIA_TYPE,
6
     MEDIA_TYPE,
6
     shouldRenderVideoTrack,
7
     shouldRenderVideoTrack,
35
         _avatar: React.PropTypes.string,
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
          * The video Track of the participant with {@link #participantId}.
47
          * The video Track of the participant with {@link #participantId}.
94
     render() {
96
     render() {
95
         const {
97
         const {
96
             _avatar: avatar,
98
             _avatar: avatar,
97
-            _isInLastN: isInLastN,
99
+            _connectionStatus: connectionStatus,
98
             _videoTrack: videoTrack
100
             _videoTrack: videoTrack
99
         } = this.props;
101
         } = this.props;
100
 
102
 
105
         const waitForVideoStarted = false;
107
         const waitForVideoStarted = false;
106
         const renderVideo
108
         const renderVideo
107
             = shouldRenderVideoTrack(videoTrack, waitForVideoStarted)
109
             = shouldRenderVideoTrack(videoTrack, waitForVideoStarted)
108
-                && (typeof isInLastN === 'undefined' || isInLastN);
110
+                && (typeof connectionStatus === 'undefined'
111
+                    || connectionStatus
112
+                        === JitsiParticipantConnectionStatus.ACTIVE);
109
 
113
 
110
         // Is the avatar to be rendered?
114
         // Is the avatar to be rendered?
111
         const renderAvatar = Boolean(!renderVideo && avatar);
115
         const renderAvatar = Boolean(!renderVideo && avatar);
168
  * @private
172
  * @private
169
  * @returns {{
173
  * @returns {{
170
  *     _avatar: string,
174
  *     _avatar: string,
171
- *     _isInLastN: boolean,
175
+ *     _connectionStatus: string,
172
  *     _videoTrack: Track
176
  *     _videoTrack: Track
173
  * }}
177
  * }}
174
  */
178
  */
181
 
185
 
182
     return {
186
     return {
183
         _avatar: participant && getAvatarURL(participant),
187
         _avatar: participant && getAvatarURL(participant),
184
-        _isInLastN: participant && participant.isInLastN,
188
+        _connectionStatus: participant && participant.connectionStatus,
185
         _videoTrack:
189
         _videoTrack:
186
             getTrackByMediaTypeAndParticipant(
190
             getTrackByMediaTypeAndParticipant(
187
                 state['features/base/tracks'],
191
                 state['features/base/tracks'],

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

75
             avatarURL,
75
             avatarURL,
76
             dominantSpeaker,
76
             dominantSpeaker,
77
             email,
77
             email,
78
-            isInLastN,
78
+            connectionStatus,
79
             local,
79
             local,
80
             pinned,
80
             pinned,
81
             role
81
             role
110
             dominantSpeaker: dominantSpeaker || false,
110
             dominantSpeaker: dominantSpeaker || false,
111
             email,
111
             email,
112
             id,
112
             id,
113
-            isInLastN,
113
+            connectionStatus,
114
             local: local || false,
114
             local: local || false,
115
             name,
115
             name,
116
             pinned: pinned || false,
116
             pinned: pinned || false,

Loading…
取消
儲存