Pārlūkot izejas kodu

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

master
William Liang 3 gadus atpakaļ
vecāks
revīzija
4a375aa2a4
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam

+ 18
- 1
conference.js Parādīt failu

54
     sendLocalParticipant,
54
     sendLocalParticipant,
55
     nonParticipantMessageReceived
55
     nonParticipantMessageReceived
56
 } from './react/features/base/conference';
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
 import {
62
 import {
59
     checkAndNotifyForNewDevice,
63
     checkAndNotifyForNewDevice,
60
     getAvailableDevices,
64
     getAvailableDevices,
93
     dominantSpeakerChanged,
97
     dominantSpeakerChanged,
94
     getLocalParticipant,
98
     getLocalParticipant,
95
     getNormalizedDisplayName,
99
     getNormalizedDisplayName,
100
+    getScreenshareParticipantByOwnerId,
96
     localParticipantAudioLevelChanged,
101
     localParticipantAudioLevelChanged,
97
     localParticipantConnectionStatusChanged,
102
     localParticipantConnectionStatusChanged,
98
     localParticipantRoleChanged,
103
     localParticipantRoleChanged,
102
     participantPresenceChanged,
107
     participantPresenceChanged,
103
     participantRoleChanged,
108
     participantRoleChanged,
104
     participantUpdated,
109
     participantUpdated,
110
+    screenshareParticipantDisplayNameChanged,
105
     updateRemoteParticipantFeatures
111
     updateRemoteParticipantFeatures
106
 } from './react/features/base/participants';
112
 } from './react/features/base/participants';
107
 import {
113
 import {
2258
                     id,
2264
                     id,
2259
                     name: formattedDisplayName
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
                 APP.API.notifyDisplayNameChanged(id, {
2278
                 APP.API.notifyDisplayNameChanged(id, {
2262
                     displayName: formattedDisplayName,
2279
                     displayName: formattedDisplayName,
2263
                     formattedDisplayName:
2280
                     formattedDisplayName:

+ 11
- 0
react/features/base/participants/actionTypes.ts Parādīt failu

173
  */
173
  */
174
 export const SET_LOADABLE_AVATAR_URL = 'SET_LOADABLE_AVATAR_URL';
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
  * Raises hand for the local participant.
188
  * Raises hand for the local participant.
178
  * {
189
  * {

+ 20
- 0
react/features/base/participants/actions.js Parādīt failu

16
     PARTICIPANT_LEFT,
16
     PARTICIPANT_LEFT,
17
     PARTICIPANT_UPDATED,
17
     PARTICIPANT_UPDATED,
18
     PIN_PARTICIPANT,
18
     PIN_PARTICIPANT,
19
+    SCREENSHARE_PARTICIPANT_NAME_CHANGED,
19
     SET_LOADABLE_AVATAR_URL,
20
     SET_LOADABLE_AVATAR_URL,
20
     RAISE_HAND_UPDATED
21
     RAISE_HAND_UPDATED
21
 } from './actionTypes';
22
 } from './actionTypes';
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
  * Action to signal that some of participant properties has been changed.
456
  * Action to signal that some of participant properties has been changed.
437
  *
457
  *

+ 37
- 5
react/features/base/participants/functions.js Parādīt failu

105
     return state.localScreenShare;
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
  * Normalizes a display name so then no invalid values (padding, length...etc)
125
  * Normalizes a display name so then no invalid values (padding, length...etc)
110
  * can be set.
126
  * can be set.
244
 /**
260
 /**
245
  * Returns participant's display name.
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
  * @param {string} id - The ID of the participant's display name to retrieve.
265
  * @param {string} id - The ID of the participant's display name to retrieve.
250
  * @returns {string}
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
     const participant = getParticipantById(stateful, id);
269
     const participant = getParticipantById(stateful, id);
256
     const {
270
     const {
257
         defaultLocalDisplayName,
271
         defaultLocalDisplayName,
259
     } = toState(stateful)['features/base/config'];
273
     } = toState(stateful)['features/base/config'];
260
 
274
 
261
     if (participant) {
275
     if (participant) {
276
+        if (participant.isFakeScreenShareParticipant) {
277
+            return getScreenshareParticipantDisplayName(stateful, id);
278
+        }
279
+
262
         if (participant.name) {
280
         if (participant.name) {
263
             return participant.name;
281
             return participant.name;
264
         }
282
         }
271
     return defaultRemoteDisplayName;
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
  * Returns the presence status of a participant associated with the passed id.
307
  * Returns the presence status of a participant associated with the passed id.
276
  *
308
  *

+ 18
- 0
react/features/base/participants/reducer.js Parādīt failu

13
     PARTICIPANT_UPDATED,
13
     PARTICIPANT_UPDATED,
14
     PIN_PARTICIPANT,
14
     PIN_PARTICIPANT,
15
     RAISE_HAND_UPDATED,
15
     RAISE_HAND_UPDATED,
16
+    SCREENSHARE_PARTICIPANT_NAME_CHANGED,
16
     SET_LOADABLE_AVATAR_URL
17
     SET_LOADABLE_AVATAR_URL
17
 } from './actionTypes';
18
 } from './actionTypes';
18
 import { LOCAL_PARTICIPANT_DEFAULT_ID, PARTICIPANT_ROLE } from './constants';
19
 import { LOCAL_PARTICIPANT_DEFAULT_ID, PARTICIPANT_ROLE } from './constants';
209
             ...state
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
     case PARTICIPANT_JOINED: {
230
     case PARTICIPANT_JOINED: {
213
         const participant = _participantJoined(action);
231
         const participant = _participantJoined(action);
214
         const { id, isFakeParticipant, isFakeScreenShareParticipant, isLocalScreenShare, name, pinned } = participant;
232
         const { id, isFakeParticipant, isFakeScreenShareParticipant, isLocalScreenShare, name, pinned } = participant;

+ 1
- 1
react/features/base/tracks/middleware.js Parādīt failu

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

+ 2
- 2
react/features/display-name/components/web/StageParticipantNameLabel.js Parādīt failu

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

+ 7
- 0
react/features/filmstrip/subscriber.any.js Parādīt failu

12
     /* selector */ state => state['features/video-layout'].remoteScreenShares,
12
     /* selector */ state => state['features/video-layout'].remoteScreenShares,
13
     /* listener */ (remoteScreenShares, store) => updateRemoteParticipants(store));
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
  * Listens for changes to the dominant speaker to recompute the reordered list of the remote endpoints.
23
  * Listens for changes to the dominant speaker to recompute the reordered list of the remote endpoints.
17
  */
24
  */

Notiek ielāde…
Atcelt
Saglabāt