浏览代码

Modifies the avatars, lastN and adaptive lastN handling so that they play nicely together.

j8
George Politis 10 年前
父节点
当前提交
a8909028c8
共有 2 个文件被更改,包括 22 次插入4 次删除
  1. 10
    1
      avatar.js
  2. 12
    3
      videolayout.js

+ 10
- 1
avatar.js 查看文件

@@ -122,7 +122,16 @@ var Avatar = (function(my) {
122 122
     }
123 123
 
124 124
     function isUserMuted(jid) {
125
-        if(!mediaStreams[jid] || !mediaStreams[jid][MediaStream.VIDEO_TYPE]) {
125
+        // XXX(gp) we may want to rename this method to something like
126
+        // isUserStreaming, for example.
127
+        if (jid && jid != connection.emuc.myroomjid) {
128
+            var resource = Strophe.getResourceFromJid(jid);
129
+            if (!VideoLayout.isInLastN(resource)) {
130
+                return true;
131
+            }
132
+        }
133
+
134
+        if (!mediaStreams[jid] || !mediaStreams[jid][MediaStream.VIDEO_TYPE]) {
126 135
             return null;
127 136
         }
128 137
         return mediaStreams[jid][MediaStream.VIDEO_TYPE].muted;

+ 12
- 3
videolayout.js 查看文件

@@ -11,6 +11,12 @@ var VideoLayout = (function (my) {
11 11
     };
12 12
     my.connectionIndicators = {};
13 13
 
14
+    my.isInLastN = function(resource) {
15
+        return lastNCount < 0 // lastN is disabled, return true
16
+            || (lastNCount > 0 && lastNEndpointsCache.length == 0) // lastNEndpoints cache not built yet, return true
17
+            || (lastNEndpointsCache && lastNEndpointsCache.indexOf(resource) !== -1);
18
+    };
19
+
14 20
     my.changeLocalAudio = function(stream) {
15 21
         connection.jingle.localAudio = stream;
16 22
 
@@ -597,14 +603,17 @@ var VideoLayout = (function (my) {
597 603
                 peerContainer.show();
598 604
             }
599 605
 
600
-            // TODO(gp) add proper avatars handling.
601 606
             if (state == 'show')
602 607
             {
603
-                peerContainer.css('-webkit-filter', '');
608
+                // peerContainer.css('-webkit-filter', '');
609
+                var jid = connection.emuc.findJidFromResource(resourceJid);
610
+                Avatar.showUserAvatar(jid, false);
604 611
             }
605 612
             else // if (state == 'avatar')
606 613
             {
607
-                peerContainer.css('-webkit-filter', 'grayscale(100%)');
614
+                // peerContainer.css('-webkit-filter', 'grayscale(100%)');
615
+                var jid = connection.emuc.findJidFromResource(resourceJid);
616
+                Avatar.showUserAvatar(jid, true);
608 617
             }
609 618
         }
610 619
         else if (peerContainer.is(':visible') && isHide)

正在加载...
取消
保存