|
@@ -53,16 +53,6 @@ function onLocalFlipXChanged(val) {
|
53
|
53
|
}
|
54
|
54
|
}
|
55
|
55
|
|
56
|
|
-/**
|
57
|
|
- * Returns the redux representation of all known users.
|
58
|
|
- *
|
59
|
|
- * @private
|
60
|
|
- * @returns {Array}
|
61
|
|
- */
|
62
|
|
-function getAllParticipants() {
|
63
|
|
- return APP.store.getState()['features/base/participants'];
|
64
|
|
-}
|
65
|
|
-
|
66
|
56
|
/**
|
67
|
57
|
* Returns an array of all thumbnails in the filmstrip.
|
68
|
58
|
*
|
|
@@ -86,43 +76,6 @@ function getLocalParticipant() {
|
86
|
76
|
return getLocalParticipantFromStore(APP.store.getState());
|
87
|
77
|
}
|
88
|
78
|
|
89
|
|
-/**
|
90
|
|
- * Returns the user ID of the remote participant that is current the dominant
|
91
|
|
- * speaker.
|
92
|
|
- *
|
93
|
|
- * @private
|
94
|
|
- * @returns {string|null}
|
95
|
|
- */
|
96
|
|
-function getCurrentRemoteDominantSpeakerID() {
|
97
|
|
- const dominantSpeaker = getAllParticipants()
|
98
|
|
- .find(participant => participant.dominantSpeaker);
|
99
|
|
-
|
100
|
|
- if (dominantSpeaker) {
|
101
|
|
- return dominantSpeaker.local ? null : dominantSpeaker.id;
|
102
|
|
- }
|
103
|
|
-
|
104
|
|
- return null;
|
105
|
|
-}
|
106
|
|
-
|
107
|
|
-/**
|
108
|
|
- * Returns the corresponding resource id to the given peer container
|
109
|
|
- * DOM element.
|
110
|
|
- *
|
111
|
|
- * @return the corresponding resource id to the given peer container
|
112
|
|
- * DOM element
|
113
|
|
- */
|
114
|
|
-function getPeerContainerResourceId(containerElement) {
|
115
|
|
- if (localVideoThumbnail.container === containerElement) {
|
116
|
|
- return localVideoThumbnail.id;
|
117
|
|
- }
|
118
|
|
-
|
119
|
|
- const i = containerElement.id.indexOf('participant_');
|
120
|
|
-
|
121
|
|
- if (i >= 0) {
|
122
|
|
- return containerElement.id.substring(i + 12);
|
123
|
|
- }
|
124
|
|
-}
|
125
|
|
-
|
126
|
79
|
const VideoLayout = {
|
127
|
80
|
init(emitter) {
|
128
|
81
|
eventEmitter = emitter;
|
|
@@ -208,10 +161,6 @@ const VideoLayout = {
|
208
|
161
|
* and setting them assume the id is already set.
|
209
|
162
|
*/
|
210
|
163
|
mucJoined() {
|
211
|
|
- if (largeVideo && !largeVideo.id) {
|
212
|
|
- this.updateLargeVideo(getLocalParticipant().id, true);
|
213
|
|
- }
|
214
|
|
-
|
215
|
164
|
// FIXME: replace this call with a generic update call once SmallVideo
|
216
|
165
|
// only contains a ReactElement. Then remove this call once the
|
217
|
166
|
// Filmstrip is fully in React.
|
|
@@ -247,79 +196,6 @@ const VideoLayout = {
|
247
|
196
|
localVideoThumbnail.setVisible(visible);
|
248
|
197
|
},
|
249
|
198
|
|
250
|
|
- /**
|
251
|
|
- * Checks if removed video is currently displayed and tries to display
|
252
|
|
- * another one instead.
|
253
|
|
- * Uses focusedID if any or dominantSpeakerID if any,
|
254
|
|
- * otherwise elects new video, in this order.
|
255
|
|
- */
|
256
|
|
- _updateAfterThumbRemoved(id) {
|
257
|
|
- // Always trigger an update if large video is empty.
|
258
|
|
- if (!largeVideo
|
259
|
|
- || (this.getLargeVideoID() && !this.isCurrentlyOnLarge(id))) {
|
260
|
|
- return;
|
261
|
|
- }
|
262
|
|
-
|
263
|
|
- const pinnedId = this.getPinnedId();
|
264
|
|
- let newId;
|
265
|
|
-
|
266
|
|
- if (pinnedId) {
|
267
|
|
- newId = pinnedId;
|
268
|
|
- } else if (getCurrentRemoteDominantSpeakerID()) {
|
269
|
|
- newId = getCurrentRemoteDominantSpeakerID();
|
270
|
|
- } else { // Otherwise select last visible video
|
271
|
|
- newId = this.electLastVisibleVideo();
|
272
|
|
- }
|
273
|
|
-
|
274
|
|
- this.updateLargeVideo(newId);
|
275
|
|
- },
|
276
|
|
-
|
277
|
|
- electLastVisibleVideo() {
|
278
|
|
- // pick the last visible video in the row
|
279
|
|
- // if nobody else is left, this picks the local video
|
280
|
|
- const remoteThumbs = Filmstrip.getThumbs(true).remoteThumbs;
|
281
|
|
- let thumbs = remoteThumbs.filter('[id!="mixedstream"]');
|
282
|
|
-
|
283
|
|
- const lastVisible = thumbs.filter(':visible:last');
|
284
|
|
-
|
285
|
|
- if (lastVisible.length) {
|
286
|
|
- const id = getPeerContainerResourceId(lastVisible[0]);
|
287
|
|
-
|
288
|
|
- if (remoteVideos[id]) {
|
289
|
|
- logger.info(`electLastVisibleVideo: ${id}`);
|
290
|
|
-
|
291
|
|
- return id;
|
292
|
|
- }
|
293
|
|
-
|
294
|
|
- // The RemoteVideo was removed (but the DOM elements may still
|
295
|
|
- // exist).
|
296
|
|
- }
|
297
|
|
-
|
298
|
|
- logger.info('Last visible video no longer exists');
|
299
|
|
- thumbs = Filmstrip.getThumbs().remoteThumbs;
|
300
|
|
- if (thumbs.length) {
|
301
|
|
- const id = getPeerContainerResourceId(thumbs[0]);
|
302
|
|
-
|
303
|
|
- if (remoteVideos[id]) {
|
304
|
|
- logger.info(`electLastVisibleVideo: ${id}`);
|
305
|
|
-
|
306
|
|
- return id;
|
307
|
|
- }
|
308
|
|
-
|
309
|
|
- // The RemoteVideo was removed (but the DOM elements may
|
310
|
|
- // still exist).
|
311
|
|
- }
|
312
|
|
-
|
313
|
|
- // Go with local video
|
314
|
|
- logger.info('Fallback to local video...');
|
315
|
|
-
|
316
|
|
- const { id } = getLocalParticipant();
|
317
|
|
-
|
318
|
|
- logger.info(`electLastVisibleVideo: ${id}`);
|
319
|
|
-
|
320
|
|
- return id;
|
321
|
|
- },
|
322
|
|
-
|
323
|
199
|
onRemoteStreamAdded(stream) {
|
324
|
200
|
const id = stream.getParticipantId();
|
325
|
201
|
const remoteVideo = remoteVideos[id];
|
|
@@ -423,23 +299,6 @@ const VideoLayout = {
|
423
|
299
|
|
424
|
300
|
getAllThumbnails().forEach(thumbnail =>
|
425
|
301
|
thumbnail.focus(pinnedParticipantID === thumbnail.getId()));
|
426
|
|
-
|
427
|
|
- if (pinnedParticipantID) {
|
428
|
|
- this.updateLargeVideo(pinnedParticipantID);
|
429
|
|
- } else {
|
430
|
|
- const currentDominantSpeakerID
|
431
|
|
- = getCurrentRemoteDominantSpeakerID();
|
432
|
|
-
|
433
|
|
- if (currentDominantSpeakerID) {
|
434
|
|
- this.updateLargeVideo(currentDominantSpeakerID);
|
435
|
|
- } else {
|
436
|
|
- // if there is no currentDominantSpeakerID, it can also be
|
437
|
|
- // that local participant is the dominant speaker
|
438
|
|
- // we should act as a participant has left and was on large
|
439
|
|
- // and we should choose somebody (electLastVisibleVideo)
|
440
|
|
- this.updateLargeVideo(this.electLastVisibleVideo());
|
441
|
|
- }
|
442
|
|
- }
|
443
|
302
|
},
|
444
|
303
|
|
445
|
304
|
/**
|
|
@@ -473,19 +332,6 @@ const VideoLayout = {
|
473
|
332
|
|
474
|
333
|
this.updateMutedForNoTracks(id, 'audio');
|
475
|
334
|
this.updateMutedForNoTracks(id, 'video');
|
476
|
|
-
|
477
|
|
- const remoteVideosCount = Object.keys(remoteVideos).length;
|
478
|
|
-
|
479
|
|
- if (remoteVideosCount === 1) {
|
480
|
|
- window.setTimeout(() => {
|
481
|
|
- const updatedRemoteVideosCount
|
482
|
|
- = Object.keys(remoteVideos).length;
|
483
|
|
-
|
484
|
|
- if (updatedRemoteVideosCount === 1 && remoteVideos[id]) {
|
485
|
|
- this._maybePlaceParticipantOnLargeVideo(id);
|
486
|
|
- }
|
487
|
|
- }, 3000);
|
488
|
|
- }
|
489
|
335
|
},
|
490
|
336
|
|
491
|
337
|
/**
|
|
@@ -512,43 +358,14 @@ const VideoLayout = {
|
512
|
358
|
|
513
|
359
|
// FIXME: what does this do???
|
514
|
360
|
remoteVideoActive(videoElement, resourceJid) {
|
515
|
|
-
|
516
|
361
|
logger.info(`${resourceJid} video is now active`, videoElement);
|
517
|
|
-
|
518
|
362
|
VideoLayout.resizeThumbnails(
|
519
|
363
|
false, () => {
|
520
|
364
|
if (videoElement) {
|
521
|
365
|
$(videoElement).show();
|
522
|
366
|
}
|
523
|
367
|
});
|
524
|
|
-
|
525
|
|
- this._maybePlaceParticipantOnLargeVideo(resourceJid);
|
526
|
|
- },
|
527
|
|
-
|
528
|
|
- /**
|
529
|
|
- * Update the large video to the last added video only if there's no current
|
530
|
|
- * dominant, focused speaker or update it to the current dominant speaker.
|
531
|
|
- *
|
532
|
|
- * @params {string} resourceJid - The id of the user to maybe display on
|
533
|
|
- * large video.
|
534
|
|
- * @returns {void}
|
535
|
|
- */
|
536
|
|
- _maybePlaceParticipantOnLargeVideo(resourceJid) {
|
537
|
|
- const pinnedId = this.getPinnedId();
|
538
|
|
-
|
539
|
|
- if ((!pinnedId
|
540
|
|
- && !getCurrentRemoteDominantSpeakerID()
|
541
|
|
- && this.isLargeContainerTypeVisible(VIDEO_CONTAINER_TYPE))
|
542
|
|
- || pinnedId === resourceJid
|
543
|
|
- || (!pinnedId && resourceJid
|
544
|
|
- && getCurrentRemoteDominantSpeakerID() === resourceJid)
|
545
|
|
-
|
546
|
|
- /* Playback started while we're on the stage - may need to update
|
547
|
|
- video source with the new stream */
|
548
|
|
- || this.isCurrentlyOnLarge(resourceJid)) {
|
549
|
|
-
|
550
|
|
- this.updateLargeVideo(resourceJid, true);
|
551
|
|
- }
|
|
368
|
+ this._updateLargeVideoIfDisplayed(resourceJid, true);
|
552
|
369
|
},
|
553
|
370
|
|
554
|
371
|
/**
|
|
@@ -646,10 +463,8 @@ const VideoLayout = {
|
646
|
463
|
}
|
647
|
464
|
}
|
648
|
465
|
|
649
|
|
- if (this.isCurrentlyOnLarge(id)) {
|
650
|
|
- // large video will show avatar instead of muted stream
|
651
|
|
- this.updateLargeVideo(id, true);
|
652
|
|
- }
|
|
466
|
+ // large video will show avatar instead of muted stream
|
|
467
|
+ this._updateLargeVideoIfDisplayed(id, true);
|
653
|
468
|
},
|
654
|
469
|
|
655
|
470
|
/**
|
|
@@ -677,18 +492,6 @@ const VideoLayout = {
|
677
|
492
|
onDominantSpeakerChanged(id) {
|
678
|
493
|
getAllThumbnails().forEach(thumbnail =>
|
679
|
494
|
thumbnail.showDominantSpeakerIndicator(id === thumbnail.getId()));
|
680
|
|
-
|
681
|
|
-
|
682
|
|
- if (!remoteVideos[id]) {
|
683
|
|
- return;
|
684
|
|
- }
|
685
|
|
-
|
686
|
|
- // Local video will not have container found, but that's ok
|
687
|
|
- // since we don't want to switch to local video.
|
688
|
|
- if (!interfaceConfig.filmStripOnly && !this.getPinnedId()
|
689
|
|
- && !this.getCurrentlyOnLargeContainer().stayOnStage()) {
|
690
|
|
- this.updateLargeVideo(id);
|
691
|
|
- }
|
692
|
495
|
},
|
693
|
496
|
|
694
|
497
|
/**
|
|
@@ -758,9 +561,7 @@ const VideoLayout = {
|
758
|
561
|
|
759
|
562
|
if (remoteVideo) {
|
760
|
563
|
remoteVideo.updateView();
|
761
|
|
- if (remoteVideo.isCurrentlyOnLargeVideo()) {
|
762
|
|
- this.updateLargeVideo(id);
|
763
|
|
- }
|
|
564
|
+ this._updateLargeVideoIfDisplayed(id);
|
764
|
565
|
}
|
765
|
566
|
},
|
766
|
567
|
|
|
@@ -809,7 +610,6 @@ const VideoLayout = {
|
809
|
610
|
}
|
810
|
611
|
|
811
|
612
|
VideoLayout.resizeThumbnails();
|
812
|
|
- VideoLayout._updateAfterThumbRemoved(id);
|
813
|
613
|
},
|
814
|
614
|
|
815
|
615
|
onVideoTypeChanged(id, newVideoType) {
|
|
@@ -835,9 +635,7 @@ const VideoLayout = {
|
835
|
635
|
}
|
836
|
636
|
smallVideo.setVideoType(newVideoType);
|
837
|
637
|
|
838
|
|
- if (this.isCurrentlyOnLarge(id)) {
|
839
|
|
- this.updateLargeVideo(id, true);
|
840
|
|
- }
|
|
638
|
+ this._updateLargeVideoIfDisplayed(id, true);
|
841
|
639
|
},
|
842
|
640
|
|
843
|
641
|
/**
|