Browse Source

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

j8
yanas 9 years ago
parent
commit
5834fbe31a

+ 3
- 2
conference.js View File

518
                 // APP.UI.markVideoMuted(true/false);
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
         room.on(ConferenceEvents.DOMINANT_SPEAKER_CHANGED, (id) => {
525
         room.on(ConferenceEvents.DOMINANT_SPEAKER_CHANGED, (id) => {
525
             APP.UI.markDominantSpeaker(id);
526
             APP.UI.markDominantSpeaker(id);

+ 13974
- 13719
libs/lib-jitsi-meet.js
File diff suppressed because it is too large
View File


+ 3
- 3
modules/UI/UI.js View File

194
 /**
194
 /**
195
  * Show chat error.
195
  * Show chat error.
196
  * @param err the Error
196
  * @param err the Error
197
- * @param msg 
197
+ * @param msg
198
  */
198
  */
199
 UI.showChatError = function (err, msg) {
199
 UI.showChatError = function (err, msg) {
200
     if (interfaceConfig.filmStripOnly) {
200
     if (interfaceConfig.filmStripOnly) {
766
     VideoLayout.onDominantSpeakerChanged(id);
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 View File

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

+ 10
- 0
modules/UI/videolayout/SmallVideo.js View File

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
 SmallVideo.prototype.showDisplayName = function(isShow) {
31
 SmallVideo.prototype.showDisplayName = function(isShow) {
22
     var nameSpan = $('#' + this.videoSpanId + '>span.displayname').get(0);
32
     var nameSpan = $('#' + this.videoSpanId + '>span.displayname').get(0);
23
     if (isShow) {
33
     if (isShow) {

+ 21
- 23
modules/UI/videolayout/VideoLayout.js View File

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

Loading…
Cancel
Save