|
@@ -26,14 +26,18 @@ export function selectParticipant() {
|
26
|
26
|
const largeVideo = state['features/largeVideo'];
|
27
|
27
|
const tracks = state['features/base/tracks'];
|
28
|
28
|
|
29
|
|
- const videoTrack = getTrackByMediaTypeAndParticipant(
|
30
|
|
- tracks, MEDIA_TYPE.VIDEO, largeVideo.participantId);
|
|
29
|
+ const id = largeVideo.participantId;
|
|
30
|
+ const videoTrack
|
|
31
|
+ = getTrackByMediaTypeAndParticipant(
|
|
32
|
+ tracks,
|
|
33
|
+ MEDIA_TYPE.VIDEO,
|
|
34
|
+ id);
|
31
|
35
|
|
32
|
36
|
try {
|
33
|
37
|
conference.selectParticipant(
|
34
|
|
- videoTrack && videoTrack.videoType === VIDEO_TYPE.CAMERA
|
35
|
|
- ? largeVideo.participantId
|
36
|
|
- : null);
|
|
38
|
+ videoTrack && videoTrack.videoType === VIDEO_TYPE.CAMERA
|
|
39
|
+ ? id
|
|
40
|
+ : null);
|
37
|
41
|
} catch (err) {
|
38
|
42
|
_handleParticipantError(err);
|
39
|
43
|
}
|
|
@@ -51,11 +55,8 @@ export function selectParticipant() {
|
51
|
55
|
export function selectParticipantInLargeVideo() {
|
52
|
56
|
return (dispatch, getState) => {
|
53
|
57
|
const state = getState();
|
54
|
|
- const participants = state['features/base/participants'];
|
55
|
|
- const tracks = state['features/base/tracks'];
|
|
58
|
+ const participantId = _electParticipantInLargeVideo(state);
|
56
|
59
|
const largeVideo = state['features/largeVideo'];
|
57
|
|
- const participantId
|
58
|
|
- = _electParticipantInLargeVideo(participants, tracks);
|
59
|
60
|
|
60
|
61
|
if (participantId !== largeVideo.participantId) {
|
61
|
62
|
dispatch({
|
|
@@ -77,56 +78,53 @@ export function selectParticipantInLargeVideo() {
|
77
|
78
|
* @returns {(Track|undefined)}
|
78
|
79
|
*/
|
79
|
80
|
function _electLastVisibleVideo(tracks) {
|
80
|
|
- let videoTrack;
|
81
|
|
-
|
82
|
81
|
// First we try to get most recent remote video track.
|
83
|
|
- for (let i = tracks.length - 1; i >= 0; i--) {
|
84
|
|
- if (tracks[i].mediaType === MEDIA_TYPE.VIDEO && !tracks[i].local) {
|
85
|
|
- videoTrack = tracks[i];
|
86
|
|
- break;
|
|
82
|
+ for (let i = tracks.length - 1; i >= 0; --i) {
|
|
83
|
+ const track = tracks[i];
|
|
84
|
+
|
|
85
|
+ if (!track.local && track.mediaType === MEDIA_TYPE.VIDEO) {
|
|
86
|
+ return track;
|
87
|
87
|
}
|
88
|
88
|
}
|
89
|
89
|
|
90
|
90
|
// And if no remote video tracks are available, we select the local one.
|
91
|
|
- if (!videoTrack) {
|
92
|
|
- videoTrack = getLocalVideoTrack(tracks);
|
93
|
|
- }
|
94
|
|
-
|
95
|
|
- return videoTrack;
|
|
91
|
+ return getLocalVideoTrack(tracks);
|
96
|
92
|
}
|
97
|
93
|
|
98
|
94
|
/**
|
99
|
|
- * Returns the participant ID who is to be on the stage i.e. should be displayed
|
100
|
|
- * in LargeVideo.
|
|
95
|
+ * Returns the identifier of the participant who is to be on the stage i.e.
|
|
96
|
+ * should be displayed in <tt>LargeVideo</tt>.
|
101
|
97
|
*
|
102
|
|
- * @param {Participant[]} participants - All participants.
|
103
|
|
- * @param {Track[]} tracks - All tracks.
|
|
98
|
+ * @param {Object} state - The Redux state from which the participant to be
|
|
99
|
+ * displayed in <tt>LargeVideo</tt> is to be elected.
|
104
|
100
|
* @private
|
105
|
101
|
* @returns {(string|undefined)}
|
106
|
102
|
*/
|
107
|
|
-function _electParticipantInLargeVideo(participants, tracks) {
|
108
|
|
- // First get the pinned participant. If local participant is pinned, he will
|
109
|
|
- // be shown in LargeVideo.
|
|
103
|
+function _electParticipantInLargeVideo(state) {
|
|
104
|
+ // First get the pinned participant. If the local participant is pinned,
|
|
105
|
+ // he/she will be shown in LargeVideo.
|
|
106
|
+ const participants = state['features/base/participants'];
|
110
|
107
|
let participant = participants.find(p => p.pinned);
|
111
|
108
|
let id = participant ? participant.id : undefined;
|
112
|
109
|
|
113
|
|
- // If no participant is pinned, get the dominant speaker. But local
|
114
|
|
- // participant won't be displayed in LargeVideo even if he is the dominant
|
115
|
|
- // speaker.
|
116
|
110
|
if (!id) {
|
117
|
|
- participant = participants.find(p => p.speaking && !p.local);
|
|
111
|
+ // No participant is pinned so get the dominant speaker. But the local
|
|
112
|
+ // participant won't be displayed in LargeVideo even if he/she is the
|
|
113
|
+ // dominant speaker.
|
|
114
|
+ participant = participants.find(p => p.dominantSpeaker && !p.local);
|
118
|
115
|
if (participant) {
|
119
|
116
|
id = participant.id;
|
120
|
117
|
}
|
121
|
|
- }
|
122
|
118
|
|
123
|
|
- // If no participant is pinned and no dominant speaker, just get the
|
124
|
|
- // participant with last visible video track. This may turn out to be local
|
125
|
|
- // participant.
|
126
|
|
- if (!id) {
|
127
|
|
- const videoTrack = _electLastVisibleVideo(tracks);
|
|
119
|
+ if (!id) {
|
|
120
|
+ // There is no dominant speaker so get the participant with the last
|
|
121
|
+ // visible video track. This may turn out to be the local
|
|
122
|
+ // participant.
|
|
123
|
+ const tracks = state['features/base/tracks'];
|
|
124
|
+ const videoTrack = _electLastVisibleVideo(tracks);
|
128
|
125
|
|
129
|
|
- id = videoTrack && videoTrack.participantId;
|
|
126
|
+ id = videoTrack && videoTrack.participantId;
|
|
127
|
+ }
|
130
|
128
|
}
|
131
|
129
|
|
132
|
130
|
return id;
|