Pārlūkot izejas kodu

Re-implements last N related code to use the library. Fixes issues with resizeThumbnails. Fixes last N related event handling.

master
yanas 9 gadus atpakaļ
vecāks
revīzija
5834fbe31a

+ 3
- 2
conference.js Parādīt failu

@@ -518,8 +518,9 @@ export default {
518 518
                 // APP.UI.markVideoMuted(true/false);
519 519
             }
520 520
         });
521
-        room.on(ConferenceEvents.LAST_N_ENDPOINTS_CHANGED, (ids) => {
522
-            APP.UI.handleLastNEndpoints(ids);
521
+        room.on(
522
+            ConferenceEvents.LAST_N_ENDPOINTS_CHANGED, (ids, enteringIds) => {
523
+            APP.UI.handleLastNEndpoints(ids, enteringIds);
523 524
         });
524 525
         room.on(ConferenceEvents.DOMINANT_SPEAKER_CHANGED, (id) => {
525 526
             APP.UI.markDominantSpeaker(id);

+ 13974
- 13719
libs/lib-jitsi-meet.js
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 3
- 3
modules/UI/UI.js Parādīt failu

@@ -194,7 +194,7 @@ UI.notifyConferenceDestroyed = function (reason) {
194 194
 /**
195 195
  * Show chat error.
196 196
  * @param err the Error
197
- * @param msg 
197
+ * @param msg
198 198
  */
199 199
 UI.showChatError = function (err, msg) {
200 200
     if (interfaceConfig.filmStripOnly) {
@@ -766,8 +766,8 @@ UI.markDominantSpeaker = function (id) {
766 766
     VideoLayout.onDominantSpeakerChanged(id);
767 767
 };
768 768
 
769
-UI.handleLastNEndpoints = function (ids) {
770
-    VideoLayout.onLastNEndpointsChanged(ids, []);
769
+UI.handleLastNEndpoints = function (ids, enteringIds) {
770
+    VideoLayout.onLastNEndpointsChanged(ids, enteringIds);
771 771
 };
772 772
 
773 773
 /**

+ 4
- 4
modules/UI/toolbars/BottomToolbar.js Parādīt failu

@@ -65,7 +65,7 @@ const BottomToolbar = {
65 65
         return this.filmStrip.width();
66 66
     },
67 67
 
68
-    resizeThumbnails (thumbWidth, thumbHeight, animate = false) {
68
+    resizeThumbnails (thumbWidth, thumbHeight, animate = false, show = false) {
69 69
         return new Promise(resolve => {
70 70
             this.filmStrip.animate({
71 71
                 // adds 2 px because of small video 1px border
@@ -75,7 +75,7 @@ const BottomToolbar = {
75 75
                 duration: animate ? 500 : 0
76 76
             });
77 77
 
78
-            this.getThumbs().animate({
78
+            this.getThumbs(!show).animate({
79 79
                 height: thumbHeight,
80 80
                 width: thumbWidth
81 81
             }, {
@@ -95,9 +95,9 @@ const BottomToolbar = {
95 95
         this.toolbar.css({bottom});
96 96
     },
97 97
 
98
-    getThumbs (visible = false) {
98
+    getThumbs (only_visible = false) {
99 99
         let selector = 'span';
100
-        if (visible) {
100
+        if (only_visible) {
101 101
             selector += ':visible';
102 102
         }
103 103
 

+ 10
- 0
modules/UI/videolayout/SmallVideo.js Parādīt failu

@@ -18,6 +18,16 @@ function setVisibility(selector, show) {
18 18
     }
19 19
 }
20 20
 
21
+/**
22
+ * Indicates if this small video is currently visible.
23
+ *
24
+ * @return <tt>true</tt> if this small video isn't currently visible and
25
+ * <tt>false</tt> - otherwise.
26
+ */
27
+SmallVideo.prototype.isVisible = function () {
28
+    return $('#' + this.videoSpanId).is(':visible');
29
+};
30
+
21 31
 SmallVideo.prototype.showDisplayName = function(isShow) {
22 32
     var nameSpan = $('#' + this.videoSpanId + '>span.displayname').get(0);
23 33
     if (isShow) {

+ 21
- 23
modules/UI/videolayout/VideoLayout.js Parādīt failu

@@ -214,7 +214,8 @@ var VideoLayout = {
214 214
 
215 215
         // We'll show user's avatar if he is the dominant speaker or if
216 216
         // his video thumbnail is pinned
217
-        if (remoteVideos[id] && (id === focusedVideoResourceJid || id === currentDominantSpeaker)) {
217
+        if (remoteVideos[id] && (id === focusedVideoResourceJid
218
+                                || id === currentDominantSpeaker)) {
218 219
             newId = id;
219 220
         } else {
220 221
             // Otherwise select last visible video
@@ -357,7 +358,7 @@ var VideoLayout = {
357 358
             BottomToolbar.getThumbs().length >= localLastNCount + 2) {
358 359
             remoteVideo.showPeerContainer('hide');
359 360
         } else {
360
-            VideoLayout.resizeThumbnails();
361
+            VideoLayout.resizeThumbnails(false, true);
361 362
         }
362 363
     },
363 364
 
@@ -441,14 +442,15 @@ var VideoLayout = {
441 442
     /**
442 443
      * Resizes thumbnails.
443 444
      */
444
-    resizeThumbnails (animate = false) {
445
+    resizeThumbnails (animate = false, show = false) {
445 446
         let {thumbWidth, thumbHeight} = this.calculateThumbnailSize();
446 447
 
447 448
         $('.userAvatar').css('left', (thumbWidth - thumbHeight) / 2);
448 449
 
449
-        BottomToolbar.resizeThumbnails(thumbWidth, thumbHeight, animate).then(function () {
450
-            BottomToolbar.resizeToolbar(thumbWidth, thumbHeight);
451
-            AudioLevels.updateCanvasSize(thumbWidth, thumbHeight);
450
+        BottomToolbar.resizeThumbnails(thumbWidth, thumbHeight, animate, show)
451
+            .then(function () {
452
+                BottomToolbar.resizeToolbar(thumbWidth, thumbHeight);
453
+                AudioLevels.updateCanvasSize(thumbWidth, thumbHeight);
452 454
         });
453 455
     },
454 456
 
@@ -616,7 +618,6 @@ var VideoLayout = {
616 618
 
617 619
         // Update the local LastN set preserving the order in which the
618 620
         // endpoints appeared in the LastN/local LastN set.
619
-
620 621
         var nextLocalLastNSet = lastNEndpoints.slice(0);
621 622
         for (var i = 0; i < localLastNSet.length; i++) {
622 623
             if (nextLocalLastNSet.length >= localLastNCount) {
@@ -635,6 +636,7 @@ var VideoLayout = {
635 636
         // Handle LastN/local LastN changes.
636 637
         BottomToolbar.getThumbs().each(( index, element ) => {
637 638
             var resourceJid = getPeerContainerResourceId(element);
639
+            var smallVideo = remoteVideos[resourceJid];
638 640
 
639 641
             // We do not want to process any logic for our own(local) video
640 642
             // because the local participant is never in the lastN set.
@@ -651,17 +653,17 @@ var VideoLayout = {
651 653
                 lastNEndpoints.indexOf(resourceJid) < 0 &&
652 654
                 localLastNSet.indexOf(resourceJid) < 0) {
653 655
                 console.log("Remove from last N", resourceJid);
654
-                if (remoteVideos[resourceJid])
655
-                    remoteVideos[resourceJid].showPeerContainer('hide');
656
+                if (smallVideo)
657
+                    smallVideo.showPeerContainer('hide');
656 658
                 else if (!APP.conference.isLocalId(resourceJid))
657 659
                     console.error("No remote video for: " + resourceJid);
658 660
                 isReceived = false;
659 661
             } else if (resourceJid &&
660
-                $('#participant_' + resourceJid).is(':visible') &&
662
+                smallVideo.isVisible() &&
661 663
                 lastNEndpoints.indexOf(resourceJid) < 0 &&
662 664
                 localLastNSet.indexOf(resourceJid) >= 0) {
663
-                if (remoteVideos[resourceJid])
664
-                    remoteVideos[resourceJid].showPeerContainer('avatar');
665
+                if (smallVideo)
666
+                    smallVideo.showPeerContainer('avatar');
665 667
                 else if (!APP.conference.isLocalId(resourceJid))
666 668
                     console.error("No remote video for: " + resourceJid);
667 669
                 isReceived = false;
@@ -685,19 +687,15 @@ var VideoLayout = {
685 687
         if (endpointsEnteringLastN && endpointsEnteringLastN.length > 0) {
686 688
             endpointsEnteringLastN.forEach(function (resourceJid) {
687 689
 
688
-                var isVisible = $('#participant_' + resourceJid).is(':visible');
689 690
                 var remoteVideo = remoteVideos[resourceJid];
690 691
                 remoteVideo.showPeerContainer('show');
691
-                if (!isVisible) {
692
+
693
+                if (!remoteVideo.isVisible()) {
692 694
                     console.log("Add to last N", resourceJid);
693 695
 
694
-                    var jid = APP.xmpp.findJidFromResource(resourceJid);
695
-                    var mediaStream =
696
-                        APP.RTC.remoteStreams[jid]['video'];
697
-                    var sel = remoteVideo.selectVideoElement();
696
+                    remoteVideo.addRemoteStreamElement(remoteVideo.stream);
698 697
 
699
-                    APP.RTC.attachMediaStream(sel, mediaStream.stream);
700
-                    if (lastNPickupId == mediaStream.peerjid) {
698
+                    if (lastNPickupId == resourceJid) {
701 699
                         // Clean up the lastN pickup id.
702 700
                         lastNPickupId = null;
703 701
 
@@ -705,12 +703,12 @@ var VideoLayout = {
705 703
                         // been fired in the contact list click handler.
706 704
                         VideoLayout.handleVideoThumbClicked(
707 705
                             false,
708
-                            Strophe.getResourceFromJid(mediaStream.peerjid));
706
+                            resourceJid);
709 707
 
710 708
                         updateLargeVideo = false;
711 709
                     }
712
-                    remoteVideos[resourceJid].
713
-                        waitForPlayback(sel, mediaStream);
710
+                    remoteVideo.waitForPlayback(
711
+                        remoteVideo.selectVideoElement(), remoteVideo.stream);
714 712
                 }
715 713
             });
716 714
         }

Notiek ielāde…
Atcelt
Saglabāt