|
@@ -4,9 +4,16 @@ import {
|
4
|
4
|
VIDEO_QUALITY_LEVELS,
|
5
|
5
|
setMaxReceiverVideoQuality
|
6
|
6
|
} from '../base/conference';
|
7
|
|
-import { StateListenerRegistry } from '../base/redux';
|
|
7
|
+import {
|
|
8
|
+ getPinnedParticipant,
|
|
9
|
+ pinParticipant
|
|
10
|
+} from '../base/participants';
|
|
11
|
+import { StateListenerRegistry, equals } from '../base/redux';
|
8
|
12
|
import { selectParticipant } from '../large-video';
|
9
|
13
|
import { shouldDisplayTileView } from './functions';
|
|
14
|
+import { setParticipantsWithScreenShare } from './actions';
|
|
15
|
+
|
|
16
|
+declare var interfaceConfig: Object;
|
10
|
17
|
|
11
|
18
|
/**
|
12
|
19
|
* StateListenerRegistry provides a reliable way of detecting changes to
|
|
@@ -14,11 +21,89 @@ import { shouldDisplayTileView } from './functions';
|
14
|
21
|
*/
|
15
|
22
|
StateListenerRegistry.register(
|
16
|
23
|
/* selector */ state => shouldDisplayTileView(state),
|
17
|
|
- /* listener */ (displayTileView, { dispatch }) => {
|
|
24
|
+ /* listener */ (displayTileView, store) => {
|
|
25
|
+ const { dispatch } = store;
|
|
26
|
+
|
18
|
27
|
dispatch(selectParticipant());
|
19
|
28
|
|
20
|
29
|
if (!displayTileView) {
|
21
|
|
- dispatch(setMaxReceiverVideoQuality(VIDEO_QUALITY_LEVELS.HIGH));
|
|
30
|
+ dispatch(
|
|
31
|
+ setMaxReceiverVideoQuality(VIDEO_QUALITY_LEVELS.HIGH));
|
|
32
|
+
|
|
33
|
+ if (typeof interfaceConfig === 'object'
|
|
34
|
+ && interfaceConfig.AUTO_PIN_LATEST_SCREEN_SHARE) {
|
|
35
|
+ _updateAutoPinnedParticipant(store);
|
|
36
|
+ }
|
|
37
|
+ }
|
|
38
|
+ }
|
|
39
|
+);
|
|
40
|
+
|
|
41
|
+/**
|
|
42
|
+ * For auto-pin mode, listen for changes to the known media tracks and look
|
|
43
|
+ * for updates to screen shares.
|
|
44
|
+ */
|
|
45
|
+StateListenerRegistry.register(
|
|
46
|
+ /* selector */ state => state['features/base/tracks'],
|
|
47
|
+ /* listener */ (tracks, store) => {
|
|
48
|
+ if (typeof interfaceConfig !== 'object'
|
|
49
|
+ && !interfaceConfig.AUTO_PIN_LATEST_SCREEN_SHARE) {
|
|
50
|
+ return;
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ const oldScreenSharesOrder
|
|
54
|
+ = store.getState()['features/video-layout'].screenShares || [];
|
|
55
|
+ const knownSharingParticipantIds = tracks.reduce((acc, track) => {
|
|
56
|
+ if (track.mediaType === 'video' && track.videoType === 'desktop') {
|
|
57
|
+ acc.push(track.participantId);
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+ return acc;
|
|
61
|
+ }, []);
|
|
62
|
+
|
|
63
|
+ // Filter out any participants which are no longer screen sharing
|
|
64
|
+ // by looping through the known sharing participants and removing any
|
|
65
|
+ // participant IDs which are no longer sharing.
|
|
66
|
+ const newScreenSharesOrder = oldScreenSharesOrder.filter(
|
|
67
|
+ participantId => knownSharingParticipantIds.includes(participantId));
|
|
68
|
+
|
|
69
|
+ // Make sure all new sharing participant get added to the end of the
|
|
70
|
+ // known screen shares.
|
|
71
|
+ knownSharingParticipantIds.forEach(participantId => {
|
|
72
|
+ if (!newScreenSharesOrder.includes(participantId)) {
|
|
73
|
+ newScreenSharesOrder.push(participantId);
|
|
74
|
+ }
|
|
75
|
+ });
|
|
76
|
+
|
|
77
|
+ if (!equals(oldScreenSharesOrder, newScreenSharesOrder)) {
|
|
78
|
+ store.dispatch(
|
|
79
|
+ setParticipantsWithScreenShare(newScreenSharesOrder));
|
|
80
|
+
|
|
81
|
+ _updateAutoPinnedParticipant(store);
|
22
|
82
|
}
|
23
|
83
|
}
|
24
|
84
|
);
|
|
85
|
+
|
|
86
|
+/**
|
|
87
|
+ * Private helper to automatically pin the latest screen share stream or unpin
|
|
88
|
+ * if there are no more screen share streams.
|
|
89
|
+ *
|
|
90
|
+ * @param {Store} store - The redux store.
|
|
91
|
+ * @returns {void}
|
|
92
|
+ */
|
|
93
|
+function _updateAutoPinnedParticipant({ dispatch, getState }) {
|
|
94
|
+ const state = getState();
|
|
95
|
+ const screenShares = state['features/video-layout'].screenShares;
|
|
96
|
+
|
|
97
|
+ if (!screenShares) {
|
|
98
|
+ return;
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ const latestScreenshareParticipantId
|
|
102
|
+ = screenShares[screenShares.length - 1];
|
|
103
|
+
|
|
104
|
+ if (latestScreenshareParticipantId) {
|
|
105
|
+ dispatch(pinParticipant(latestScreenshareParticipantId));
|
|
106
|
+ } else if (getPinnedParticipant(state['features/base/participants'])) {
|
|
107
|
+ dispatch(pinParticipant(null));
|
|
108
|
+ }
|
|
109
|
+}
|