|
|
@@ -1,4 +1,4 @@
|
|
1
|
|
-/* global config, APP, $, interfaceConfig */
|
|
|
1
|
+/* global APP, $, interfaceConfig */
|
|
2
|
2
|
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
|
3
|
3
|
|
|
4
|
4
|
import FilmStrip from "./FilmStrip";
|
|
|
@@ -14,10 +14,6 @@ var remoteVideos = {};
|
|
14
|
14
|
var localVideoThumbnail = null;
|
|
15
|
15
|
|
|
16
|
16
|
var currentDominantSpeaker = null;
|
|
17
|
|
-var localLastNCount = config.channelLastN;
|
|
18
|
|
-var localLastNSet = [];
|
|
19
|
|
-var lastNEndpointsCache = [];
|
|
20
|
|
-var lastNPickupId = null;
|
|
21
|
17
|
|
|
22
|
18
|
var eventEmitter = null;
|
|
23
|
19
|
|
|
|
@@ -60,8 +56,6 @@ function onContactClicked (id) {
|
|
60
|
56
|
// let the bridge adjust its lastN set for myjid and store
|
|
61
|
57
|
// the pinned user in the lastNPickupId variable to be
|
|
62
|
58
|
// picked up later by the lastN changed event handler.
|
|
63
|
|
-
|
|
64
|
|
- lastNPickupId = id;
|
|
65
|
59
|
eventEmitter.emit(UIEvents.PINNED_ENDPOINT, remoteVideo, true);
|
|
66
|
60
|
}
|
|
67
|
61
|
}
|
|
|
@@ -114,8 +108,6 @@ var VideoLayout = {
|
|
114
|
108
|
// the local video thumb maybe one pixel
|
|
115
|
109
|
this.resizeThumbnails(false, true);
|
|
116
|
110
|
|
|
117
|
|
- this.lastNCount = config.channelLastN;
|
|
118
|
|
-
|
|
119
|
111
|
this.registerListeners();
|
|
120
|
112
|
},
|
|
121
|
113
|
|
|
|
@@ -162,14 +154,6 @@ var VideoLayout = {
|
|
162
|
154
|
largeVideo.updateLargeVideoAudioLevel(lvl);
|
|
163
|
155
|
},
|
|
164
|
156
|
|
|
165
|
|
- isInLastN (resource) {
|
|
166
|
|
- return this.lastNCount < 0 || // lastN is disabled
|
|
167
|
|
- // lastNEndpoints cache not built yet
|
|
168
|
|
- (this.lastNCount > 0 && !lastNEndpointsCache.length) ||
|
|
169
|
|
- (lastNEndpointsCache &&
|
|
170
|
|
- lastNEndpointsCache.indexOf(resource) !== -1);
|
|
171
|
|
- },
|
|
172
|
|
-
|
|
173
|
157
|
changeLocalAudio (stream) {
|
|
174
|
158
|
let localAudio = document.getElementById('localAudio');
|
|
175
|
159
|
localAudio = stream.attach(localAudio);
|
|
|
@@ -457,13 +441,8 @@ var VideoLayout = {
|
|
457
|
441
|
remoteVideo.setVideoType(VIDEO_CONTAINER_TYPE);
|
|
458
|
442
|
}
|
|
459
|
443
|
|
|
460
|
|
- // In case this is not currently in the last n we don't show it.
|
|
461
|
|
- if (localLastNCount && localLastNCount > 0 &&
|
|
462
|
|
- FilmStrip.getThumbs().remoteThumbs.length >= localLastNCount + 2) {
|
|
463
|
|
- remoteVideo.showPeerContainer('hide');
|
|
464
|
|
- } else {
|
|
465
|
|
- VideoLayout.resizeThumbnails(false, true);
|
|
466
|
|
- }
|
|
|
444
|
+ VideoLayout.resizeThumbnails(false, true);
|
|
|
445
|
+
|
|
467
|
446
|
// Initialize the view
|
|
468
|
447
|
remoteVideo.updateView();
|
|
469
|
448
|
},
|
|
|
@@ -713,142 +692,22 @@ var VideoLayout = {
|
|
713
|
692
|
* endpoints
|
|
714
|
693
|
*/
|
|
715
|
694
|
onLastNEndpointsChanged (lastNEndpoints, endpointsEnteringLastN) {
|
|
716
|
|
- if (this.lastNCount !== lastNEndpoints.length)
|
|
717
|
|
- this.lastNCount = lastNEndpoints.length;
|
|
718
|
|
-
|
|
719
|
|
- lastNEndpointsCache = lastNEndpoints;
|
|
720
|
|
-
|
|
721
|
|
- // Say A, B, C, D, E, and F are in a conference and LastN = 3.
|
|
722
|
|
- //
|
|
723
|
|
- // If LastN drops to, say, 2, because of adaptivity, then E should see
|
|
724
|
|
- // thumbnails for A, B and C. A and B are in E's server side LastN set,
|
|
725
|
|
- // so E sees them. C is only in E's local LastN set.
|
|
726
|
|
- //
|
|
727
|
|
- // If F starts talking and LastN = 3, then E should see thumbnails for
|
|
728
|
|
- // F, A, B. B gets "ejected" from E's server side LastN set, but it
|
|
729
|
|
- // enters E's local LastN ejecting C.
|
|
730
|
|
-
|
|
731
|
|
- // Increase the local LastN set size, if necessary.
|
|
732
|
|
- if (this.lastNCount > localLastNCount) {
|
|
733
|
|
- localLastNCount = this.lastNCount;
|
|
734
|
|
- }
|
|
735
|
|
-
|
|
736
|
|
- // Update the local LastN set preserving the order in which the
|
|
737
|
|
- // endpoints appeared in the LastN/local LastN set.
|
|
738
|
|
- var nextLocalLastNSet = lastNEndpoints.slice(0);
|
|
739
|
|
- for (var i = 0; i < localLastNSet.length; i++) {
|
|
740
|
|
- if (nextLocalLastNSet.length >= localLastNCount) {
|
|
741
|
|
- break;
|
|
742
|
|
- }
|
|
743
|
|
-
|
|
744
|
|
- var resourceJid = localLastNSet[i];
|
|
745
|
|
- if (nextLocalLastNSet.indexOf(resourceJid) === -1) {
|
|
746
|
|
- nextLocalLastNSet.push(resourceJid);
|
|
747
|
|
- }
|
|
748
|
|
- }
|
|
749
|
|
-
|
|
750
|
|
- localLastNSet = nextLocalLastNSet;
|
|
751
|
|
- var updateLargeVideo = false;
|
|
752
|
|
-
|
|
753
|
|
- // Handle LastN/local LastN changes.
|
|
754
|
|
- FilmStrip.getThumbs().remoteThumbs.each(( index, element ) => {
|
|
755
|
|
- var resourceJid = getPeerContainerResourceId(element);
|
|
756
|
|
- var smallVideo = remoteVideos[resourceJid];
|
|
757
|
|
-
|
|
758
|
|
- // We do not want to process any logic for our own(local) video
|
|
759
|
|
- // because the local participant is never in the lastN set.
|
|
760
|
|
- // The code of this function might detect that the local participant
|
|
761
|
|
- // has been dropped out of the lastN set and will update the large
|
|
762
|
|
- // video
|
|
763
|
|
- // Detected from avatar tests, where lastN event override
|
|
764
|
|
- // local video pinning
|
|
765
|
|
- if(APP.conference.isLocalId(resourceJid))
|
|
766
|
|
- return;
|
|
767
|
|
-
|
|
768
|
|
- var isReceived = true;
|
|
769
|
|
- if (resourceJid &&
|
|
770
|
|
- lastNEndpoints.indexOf(resourceJid) < 0 &&
|
|
771
|
|
- localLastNSet.indexOf(resourceJid) < 0) {
|
|
772
|
|
- logger.log("Remove from last N", resourceJid);
|
|
773
|
|
- if (smallVideo)
|
|
774
|
|
- smallVideo.showPeerContainer('hide');
|
|
775
|
|
- else if (!APP.conference.isLocalId(resourceJid))
|
|
776
|
|
- logger.error("No remote video for: " + resourceJid);
|
|
777
|
|
- isReceived = false;
|
|
778
|
|
- } else if (resourceJid &&
|
|
779
|
|
- //TOFIX: smallVideo may be undefined
|
|
780
|
|
- smallVideo.isVisible() &&
|
|
781
|
|
- lastNEndpoints.indexOf(resourceJid) < 0 &&
|
|
782
|
|
- localLastNSet.indexOf(resourceJid) >= 0) {
|
|
783
|
|
-
|
|
784
|
|
- // TOFIX: if we're here we already know that the smallVideo
|
|
785
|
|
- // exists. Look at the previous FIX above.
|
|
786
|
|
- if (smallVideo)
|
|
787
|
|
- smallVideo.showPeerContainer('avatar');
|
|
788
|
|
- else if (!APP.conference.isLocalId(resourceJid))
|
|
789
|
|
- logger.error("No remote video for: " + resourceJid);
|
|
790
|
|
- isReceived = false;
|
|
791
|
|
- }
|
|
792
|
|
-
|
|
793
|
|
- if (!isReceived) {
|
|
794
|
|
- // resourceJid has dropped out of the server side lastN set, so
|
|
795
|
|
- // it is no longer being received. If resourceJid was being
|
|
796
|
|
- // displayed in the large video we have to switch to another
|
|
797
|
|
- // user.
|
|
798
|
|
- if (!updateLargeVideo &&
|
|
799
|
|
- this.isCurrentlyOnLarge(resourceJid)) {
|
|
800
|
|
- updateLargeVideo = true;
|
|
801
|
|
- }
|
|
802
|
|
- }
|
|
803
|
|
- });
|
|
804
|
|
-
|
|
805
|
|
- if (!endpointsEnteringLastN || endpointsEnteringLastN.length < 0)
|
|
806
|
|
- endpointsEnteringLastN = lastNEndpoints;
|
|
807
|
|
-
|
|
808
|
|
- if (endpointsEnteringLastN && endpointsEnteringLastN.length > 0) {
|
|
809
|
|
- endpointsEnteringLastN.forEach(function (resourceJid) {
|
|
810
|
|
-
|
|
811
|
|
- var remoteVideo = remoteVideos[resourceJid];
|
|
812
|
|
- if (remoteVideo)
|
|
813
|
|
- remoteVideo.showPeerContainer('show');
|
|
814
|
695
|
|
|
815
|
|
- if (!remoteVideo.isVisible()) {
|
|
816
|
|
- logger.log("Add to last N", resourceJid);
|
|
817
|
|
-
|
|
818
|
|
- remoteVideo.addRemoteStreamElement(remoteVideo.videoStream);
|
|
819
|
|
-
|
|
820
|
|
- if (lastNPickupId == resourceJid) {
|
|
821
|
|
- // Clean up the lastN pickup id.
|
|
822
|
|
- lastNPickupId = null;
|
|
823
|
|
-
|
|
824
|
|
- VideoLayout.handleVideoThumbClicked(resourceJid);
|
|
825
|
|
-
|
|
826
|
|
- updateLargeVideo = false;
|
|
|
696
|
+ Object.keys(remoteVideos).forEach(
|
|
|
697
|
+ id => {
|
|
|
698
|
+ if (lastNEndpoints.length > 0
|
|
|
699
|
+ && lastNEndpoints.indexOf(id) < 0
|
|
|
700
|
+ || endpointsEnteringLastN.length > 0
|
|
|
701
|
+ && endpointsEnteringLastN.indexOf(id) > 0) {
|
|
|
702
|
+
|
|
|
703
|
+ let remoteVideo = (id) ? remoteVideos[id] : null;
|
|
|
704
|
+ if (remoteVideo) {
|
|
|
705
|
+ remoteVideo.updateView();
|
|
|
706
|
+ if (remoteVideo.isCurrentlyOnLargeVideo())
|
|
|
707
|
+ this.updateLargeVideo(id);
|
|
827
|
708
|
}
|
|
828
|
|
- remoteVideo.waitForPlayback(
|
|
829
|
|
- remoteVideo.selectVideoElement()[0],
|
|
830
|
|
- remoteVideo.videoStream);
|
|
831
|
709
|
}
|
|
832
|
710
|
});
|
|
833
|
|
- }
|
|
834
|
|
-
|
|
835
|
|
- // The endpoint that was being shown in the large video has dropped out
|
|
836
|
|
- // of the lastN set and there was no lastN pickup jid. We need to update
|
|
837
|
|
- // the large video now.
|
|
838
|
|
-
|
|
839
|
|
- if (updateLargeVideo) {
|
|
840
|
|
- var resource;
|
|
841
|
|
- // Find out which endpoint to show in the large video.
|
|
842
|
|
- for (i = 0; i < lastNEndpoints.length; i++) {
|
|
843
|
|
- resource = lastNEndpoints[i];
|
|
844
|
|
- if (!resource || APP.conference.isLocalId(resource))
|
|
845
|
|
- continue;
|
|
846
|
|
-
|
|
847
|
|
- // videoSrcToSsrc needs to be update for this call to succeed.
|
|
848
|
|
- this.updateLargeVideo(resource);
|
|
849
|
|
- break;
|
|
850
|
|
- }
|
|
851
|
|
- }
|
|
852
|
711
|
},
|
|
853
|
712
|
|
|
854
|
713
|
/**
|