瀏覽代碼

fix(multi-stream) update screenshare display name (#11376)

master
William Liang 3 年之前
父節點
當前提交
4a375aa2a4
沒有連結到貢獻者的電子郵件帳戶。

+ 18
- 1
conference.js 查看文件

@@ -54,7 +54,11 @@ import {
54 54
     sendLocalParticipant,
55 55
     nonParticipantMessageReceived
56 56
 } from './react/features/base/conference';
57
-import { getReplaceParticipant, getMultipleVideoSupportFeatureFlag } from './react/features/base/config/functions';
57
+import {
58
+    getReplaceParticipant,
59
+    getMultipleVideoSupportFeatureFlag,
60
+    getSourceNameSignalingFeatureFlag
61
+} from './react/features/base/config/functions';
58 62
 import {
59 63
     checkAndNotifyForNewDevice,
60 64
     getAvailableDevices,
@@ -93,6 +97,7 @@ import {
93 97
     dominantSpeakerChanged,
94 98
     getLocalParticipant,
95 99
     getNormalizedDisplayName,
100
+    getScreenshareParticipantByOwnerId,
96 101
     localParticipantAudioLevelChanged,
97 102
     localParticipantConnectionStatusChanged,
98 103
     localParticipantRoleChanged,
@@ -102,6 +107,7 @@ import {
102 107
     participantPresenceChanged,
103 108
     participantRoleChanged,
104 109
     participantUpdated,
110
+    screenshareParticipantDisplayNameChanged,
105 111
     updateRemoteParticipantFeatures
106 112
 } from './react/features/base/participants';
107 113
 import {
@@ -2258,6 +2264,17 @@ export default {
2258 2264
                     id,
2259 2265
                     name: formattedDisplayName
2260 2266
                 }));
2267
+
2268
+                if (getSourceNameSignalingFeatureFlag(state)) {
2269
+                    const screenshareParticipantId = getScreenshareParticipantByOwnerId(state, id)?.id;
2270
+
2271
+                    if (screenshareParticipantId) {
2272
+                        APP.store.dispatch(
2273
+                            screenshareParticipantDisplayNameChanged(screenshareParticipantId, formattedDisplayName)
2274
+                        );
2275
+                    }
2276
+                }
2277
+
2261 2278
                 APP.API.notifyDisplayNameChanged(id, {
2262 2279
                     displayName: formattedDisplayName,
2263 2280
                     formattedDisplayName:

+ 11
- 0
react/features/base/participants/actionTypes.ts 查看文件

@@ -173,6 +173,17 @@ export const HIDDEN_PARTICIPANT_LEFT = 'HIDDEN_PARTICIPANT_LEFT';
173 173
  */
174 174
 export const SET_LOADABLE_AVATAR_URL = 'SET_LOADABLE_AVATAR_URL';
175 175
 
176
+/**
177
+ * The type of Redux action which notifies that the screenshare participant's display name has changed.
178
+ *
179
+ * {
180
+ *     type: SCREENSHARE_PARTICIPANT_NAME_CHANGED,
181
+ *     id: string,
182
+ *     name: string
183
+ * }
184
+ */
185
+ export const SCREENSHARE_PARTICIPANT_NAME_CHANGED = 'SCREENSHARE_PARTICIPANT_NAME_CHANGED';
186
+
176 187
 /**
177 188
  * Raises hand for the local participant.
178 189
  * {

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

@@ -16,6 +16,7 @@ import {
16 16
     PARTICIPANT_LEFT,
17 17
     PARTICIPANT_UPDATED,
18 18
     PIN_PARTICIPANT,
19
+    SCREENSHARE_PARTICIPANT_NAME_CHANGED,
19 20
     SET_LOADABLE_AVATAR_URL,
20 21
     RAISE_HAND_UPDATED
21 22
 } from './actionTypes';
@@ -432,6 +433,25 @@ export function participantRoleChanged(id, role) {
432 433
     });
433 434
 }
434 435
 
436
+/**
437
+ * Action to signal that a participant's display name has changed.
438
+ *
439
+ * @param {string} id - Screenshare participant's ID.
440
+ * @param {name} name - The new display name of the screenshare participant's owner.
441
+ * @returns {{
442
+ *     type: SCREENSHARE_PARTICIPANT_NAME_CHANGED,
443
+ *     id: string,
444
+ *     name: string
445
+ * }}
446
+ */
447
+export function screenshareParticipantDisplayNameChanged(id, name) {
448
+    return {
449
+        type: SCREENSHARE_PARTICIPANT_NAME_CHANGED,
450
+        id,
451
+        name
452
+    };
453
+}
454
+
435 455
 /**
436 456
  * Action to signal that some of participant properties has been changed.
437 457
  *

+ 37
- 5
react/features/base/participants/functions.js 查看文件

@@ -105,6 +105,22 @@ export function getLocalScreenShareParticipant(stateful: Object | Function) {
105 105
     return state.localScreenShare;
106 106
 }
107 107
 
108
+/**
109
+ * Returns screenshare participant.
110
+ *
111
+ * @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
112
+ * retrieve the state features/base/participants.
113
+ * @param {string} id - The owner ID of the screenshare participant to retrieve.
114
+ * @returns {(Participant|undefined)}
115
+ */
116
+export function getScreenshareParticipantByOwnerId(stateful: Object | Function, id: string) {
117
+    const track = getTrackByMediaTypeAndParticipant(
118
+        toState(stateful)['features/base/tracks'], MEDIA_TYPE.SCREENSHARE, id
119
+    );
120
+
121
+    return getParticipantById(stateful, track?.jitsiTrack.getSourceName());
122
+}
123
+
108 124
 /**
109 125
  * Normalizes a display name so then no invalid values (padding, length...etc)
110 126
  * can be set.
@@ -244,14 +260,12 @@ export function getParticipantCountWithFake(stateful: Object | Function) {
244 260
 /**
245 261
  * Returns participant's display name.
246 262
  *
247
- * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
248
- * {@code getState} function to be used to retrieve the state.
263
+ * @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
264
+ * retrieve the state.
249 265
  * @param {string} id - The ID of the participant's display name to retrieve.
250 266
  * @returns {string}
251 267
  */
252
-export function getParticipantDisplayName(
253
-        stateful: Object | Function,
254
-        id: string) {
268
+export function getParticipantDisplayName(stateful: Object | Function, id: string) {
255 269
     const participant = getParticipantById(stateful, id);
256 270
     const {
257 271
         defaultLocalDisplayName,
@@ -259,6 +273,10 @@ export function getParticipantDisplayName(
259 273
     } = toState(stateful)['features/base/config'];
260 274
 
261 275
     if (participant) {
276
+        if (participant.isFakeScreenShareParticipant) {
277
+            return getScreenshareParticipantDisplayName(stateful, id);
278
+        }
279
+
262 280
         if (participant.name) {
263 281
             return participant.name;
264 282
         }
@@ -271,6 +289,20 @@ export function getParticipantDisplayName(
271 289
     return defaultRemoteDisplayName;
272 290
 }
273 291
 
292
+/**
293
+ * Returns screenshare participant's display name.
294
+ *
295
+ * @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
296
+ * retrieve the state.
297
+ * @param {string} id - The ID of the screenshare participant's display name to retrieve.
298
+ * @returns {string}
299
+ */
300
+export function getScreenshareParticipantDisplayName(stateful: Object | Function, id: string) {
301
+    const owner = getParticipantById(stateful, getFakeScreenShareParticipantOwnerId(id));
302
+
303
+    return `${owner.name}'s screen`;
304
+}
305
+
274 306
 /**
275 307
  * Returns the presence status of a participant associated with the passed id.
276 308
  *

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

@@ -13,6 +13,7 @@ import {
13 13
     PARTICIPANT_UPDATED,
14 14
     PIN_PARTICIPANT,
15 15
     RAISE_HAND_UPDATED,
16
+    SCREENSHARE_PARTICIPANT_NAME_CHANGED,
16 17
     SET_LOADABLE_AVATAR_URL
17 18
 } from './actionTypes';
18 19
 import { LOCAL_PARTICIPANT_DEFAULT_ID, PARTICIPANT_ROLE } from './constants';
@@ -209,6 +210,23 @@ ReducerRegistry.register('features/base/participants', (state = DEFAULT_STATE, a
209 210
             ...state
210 211
         };
211 212
     }
213
+    case SCREENSHARE_PARTICIPANT_NAME_CHANGED: {
214
+        const { id, name } = action;
215
+
216
+        if (state.sortedRemoteFakeScreenShareParticipants.has(id)) {
217
+            state.sortedRemoteFakeScreenShareParticipants.delete(id);
218
+
219
+            const sortedRemoteFakeScreenShareParticipants = [ ...state.sortedRemoteFakeScreenShareParticipants ];
220
+
221
+            sortedRemoteFakeScreenShareParticipants.push([ id, name ]);
222
+            sortedRemoteFakeScreenShareParticipants.sort((a, b) => a[1].localeCompare(b[1]));
223
+
224
+            state.sortedRemoteFakeScreenShareParticipants = new Map(sortedRemoteFakeScreenShareParticipants);
225
+        }
226
+
227
+        return { ...state };
228
+    }
229
+
212 230
     case PARTICIPANT_JOINED: {
213 231
         const participant = _participantJoined(action);
214 232
         const { id, isFakeParticipant, isFakeScreenShareParticipant, isLocalScreenShare, name, pinned } = participant;

+ 1
- 1
react/features/base/tracks/middleware.js 查看文件

@@ -400,7 +400,7 @@ function createFakeScreenShareParticipant({ dispatch, getState }, { track }) {
400 400
             id: track.jitsiTrack.getSourceName(),
401 401
             isFakeScreenShareParticipant: true,
402 402
             isLocalScreenShare: track?.jitsiTrack.isLocal(),
403
-            name: `${participant.name}'s screen`
403
+            name: participant.name
404 404
         }));
405 405
     } else {
406 406
         logger.error(`Failed to create a screenshare participant for participantId: ${participantId}`);

+ 2
- 2
react/features/display-name/components/web/StageParticipantNameLabel.js 查看文件

@@ -6,7 +6,7 @@ import React from 'react';
6 6
 import { useSelector } from 'react-redux';
7 7
 
8 8
 import { isDisplayNameVisible } from '../../../base/config/functions.any';
9
-import { getLocalParticipant } from '../../../base/participants';
9
+import { getLocalParticipant, getParticipantDisplayName } from '../../../base/participants';
10 10
 import { withPixelLineHeight } from '../../../base/styles/functions.web';
11 11
 import { getLargeVideoParticipant } from '../../../large-video/functions';
12 12
 import { isToolboxVisible } from '../../../toolbox/functions.web';
@@ -44,8 +44,8 @@ const useStyles = makeStyles(theme => {
44 44
 const StageParticipantNameLabel = () => {
45 45
     const classes = useStyles();
46 46
     const largeVideoParticipant = useSelector(getLargeVideoParticipant);
47
-    const nameToDisplay = largeVideoParticipant?.name;
48 47
     const selectedId = largeVideoParticipant?.id;
48
+    const nameToDisplay = useSelector(state => getParticipantDisplayName(state, selectedId));
49 49
 
50 50
     const localParticipant = useSelector(getLocalParticipant);
51 51
     const localId = localParticipant?.id;

+ 7
- 0
react/features/filmstrip/subscriber.any.js 查看文件

@@ -12,6 +12,13 @@ StateListenerRegistry.register(
12 12
     /* selector */ state => state['features/video-layout'].remoteScreenShares,
13 13
     /* listener */ (remoteScreenShares, store) => updateRemoteParticipants(store));
14 14
 
15
+/**
16
+ * Listens for changes to the remote screenshare participants to recompute the reordered list of the remote endpoints.
17
+ */
18
+StateListenerRegistry.register(
19
+    /* selector */ state => state['features/base/participants'].sortedRemoteFakeScreenShareParticipants,
20
+    /* listener */ (sortedRemoteFakeScreenShareParticipants, store) => updateRemoteParticipants(store));
21
+
15 22
 /**
16 23
  * Listens for changes to the dominant speaker to recompute the reordered list of the remote endpoints.
17 24
  */

Loading…
取消
儲存