浏览代码

Fixes the issues with resolution value when simulcast is enabled.

master
hristoterezov 11 年前
父节点
当前提交
b369e28bb0
共有 3 个文件被更改,包括 72 次插入64 次删除
  1. 2
    2
      index.html
  2. 23
    17
      rtp_sts.js
  3. 47
    45
      videolayout.js

+ 2
- 2
index.html 查看文件

45
     <script src="replacement.js?v=6"></script><!-- link and smiley replacement -->
45
     <script src="replacement.js?v=6"></script><!-- link and smiley replacement -->
46
     <script src="moderatemuc.js?v=4"></script><!-- moderator plugin -->
46
     <script src="moderatemuc.js?v=4"></script><!-- moderator plugin -->
47
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
47
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
48
-    <script src="rtp_sts.js?v=3"></script><!-- RTP stats processing -->
48
+    <script src="rtp_sts.js?v=4"></script><!-- RTP stats processing -->
49
     <script src="local_sts.js?v=2"></script><!-- Local stats processing -->
49
     <script src="local_sts.js?v=2"></script><!-- Local stats processing -->
50
-    <script src="videolayout.js?v=20"></script><!-- video ui -->
50
+    <script src="videolayout.js?v=21"></script><!-- video ui -->
51
     <script src="connectionquality.js?v=1"></script>
51
     <script src="connectionquality.js?v=1"></script>
52
     <script src="toolbar.js?v=6"></script><!-- toolbar ui -->
52
     <script src="toolbar.js?v=6"></script><!-- toolbar ui -->
53
     <script src="toolbar_toggler.js?v=2"></script>
53
     <script src="toolbar_toggler.js?v=2"></script>

+ 23
- 17
rtp_sts.js 查看文件

18
     this.ssrc2Loss = {};
18
     this.ssrc2Loss = {};
19
     this.ssrc2AudioLevel = {};
19
     this.ssrc2AudioLevel = {};
20
     this.ssrc2bitrate = {};
20
     this.ssrc2bitrate = {};
21
-    this.resolution = null;
21
+    this.ssrc2resolution = {};
22
 }
22
 }
23
 
23
 
24
 /**
24
 /**
52
     this.ssrc2Loss[ssrc] = lossRate;
52
     this.ssrc2Loss[ssrc] = lossRate;
53
 };
53
 };
54
 
54
 
55
+/**
56
+ * Sets resolution for given <tt>ssrc</tt> that belong to the peer
57
+ * represented by this instance.
58
+ * @param ssrc audio or video RTP stream SSRC.
59
+ * @param resolution new resolution value to be set.
60
+ */
61
+PeerStats.prototype.setSsrcResolution = function (ssrc, resolution)
62
+{
63
+    if(resolution == null && this.ssrc2resolution[ssrc])
64
+    {
65
+        delete this.ssrc2resolution[ssrc];
66
+    }
67
+    else if(resolution != null)
68
+        this.ssrc2resolution[ssrc] = resolution;
69
+};
70
+
55
 /**
71
 /**
56
  * Sets the bit rate for given <tt>ssrc</tt> that blong to the peer
72
  * Sets the bit rate for given <tt>ssrc</tt> that blong to the peer
57
  * represented by this instance.
73
  * represented by this instance.
318
             resolution.width = now.stat("googFrameWidthSent");
334
             resolution.width = now.stat("googFrameWidthSent");
319
         }
335
         }
320
 
336
 
321
-        if(!jidStats.resolution)
322
-            jidStats.resolution = null;
323
-
324
         if(resolution.height && resolution.width)
337
         if(resolution.height && resolution.width)
325
         {
338
         {
326
-            if(!jidStats.resolution)
327
-                jidStats.resolution = { hq: resolution, lq: resolution};
328
-            else if(jidStats.resolution.hq.width > resolution.width &&
329
-                jidStats.resolution.hq.height > resolution.height)
330
-            {
331
-                jidStats.resolution.lq = resolution;
332
-            }
333
-            else
334
-            {
335
-                jidStats.resolution.hq = resolution;
336
-            }
339
+            jidStats.setSsrcResolution(ssrc, resolution);
340
+        }
341
+        else
342
+        {
343
+            jidStats.setSsrcResolution(ssrc, null);
337
         }
344
         }
338
 
345
 
339
 
346
 
365
                     bitrateUpload += self.jid2stats[jid].ssrc2bitrate[ssrc].upload;
372
                     bitrateUpload += self.jid2stats[jid].ssrc2bitrate[ssrc].upload;
366
                 }
373
                 }
367
             );
374
             );
368
-            resolution[jid] = self.jid2stats[jid].resolution;
369
-            delete self.jid2stats[jid].resolution;
375
+            resolution[jid] = self.jid2stats[jid].ssrc2resolution;
370
         }
376
         }
371
     );
377
     );
372
 
378
 

+ 47
- 45
videolayout.js 查看文件

8
     };
8
     };
9
     my.connectionIndicators = {};
9
     my.connectionIndicators = {};
10
 
10
 
11
+    var displayedSsrcs = {};
12
+
11
     my.changeLocalAudio = function(stream) {
13
     my.changeLocalAudio = function(stream) {
12
         connection.jingle.localAudio = stream;
14
         connection.jingle.localAudio = stream;
13
 
15
 
33
 
35
 
34
         if(!VideoLayout.connectionIndicators["localVideoContainer"]) {
36
         if(!VideoLayout.connectionIndicators["localVideoContainer"]) {
35
             VideoLayout.connectionIndicators["localVideoContainer"]
37
             VideoLayout.connectionIndicators["localVideoContainer"]
36
-                = new ConnectionIndicator($("#localVideoContainer")[0]);
38
+                = new ConnectionIndicator($("#localVideoContainer")[0], null);
37
         }
39
         }
38
 
40
 
39
         AudioLevels.updateAudioLevelCanvas();
41
         AudioLevels.updateAudioLevelCanvas();
181
                     if (largeVideoState.oldJid) {
183
                     if (largeVideoState.oldJid) {
182
                         var oldResourceJid = Strophe.getResourceFromJid(largeVideoState.oldJid);
184
                         var oldResourceJid = Strophe.getResourceFromJid(largeVideoState.oldJid);
183
                         VideoLayout.enableDominantSpeaker(oldResourceJid, false);
185
                         VideoLayout.enableDominantSpeaker(oldResourceJid, false);
184
-                        if(VideoLayout.connectionIndicators) {
185
-                            var videoContainerId = null;
186
-                            if (oldResourceJid == Strophe.getResourceFromJid(connection.emuc.myroomjid)) {
187
-                                videoContainerId = 'localVideoContainer';
188
-                            }
189
-                            else {
190
-                                videoContainerId = 'participant_' + oldResourceJid;
191
-                            }
192
-                            if(VideoLayout.connectionIndicators[videoContainerId])
193
-                                VideoLayout.connectionIndicators[videoContainerId].setShowHQ(false);
194
-                        }
195
-
196
                     }
186
                     }
197
 
187
 
198
                     // Enable new dominant speaker in the remote videos section.
188
                     // Enable new dominant speaker in the remote videos section.
199
                     if (largeVideoState.userJid) {
189
                     if (largeVideoState.userJid) {
200
                         var resourceJid = Strophe.getResourceFromJid(largeVideoState.userJid);
190
                         var resourceJid = Strophe.getResourceFromJid(largeVideoState.userJid);
201
                         VideoLayout.enableDominantSpeaker(resourceJid, true);
191
                         VideoLayout.enableDominantSpeaker(resourceJid, true);
202
-                        if(VideoLayout.connectionIndicators)
203
-                        {
204
-                            var videoContainerId = null;
205
-                            if (resourceJid
206
-                                === Strophe.getResourceFromJid(connection.emuc.myroomjid)) {
207
-                                videoContainerId = 'localVideoContainer';
208
-                            }
209
-                            else {
210
-                                videoContainerId = 'participant_' + resourceJid;
211
-                            }
212
-                            if(VideoLayout.connectionIndicators[videoContainerId])
213
-                                VideoLayout.connectionIndicators[videoContainerId].setShowHQ(true);
214
-                        }
215
-
216
                     }
192
                     }
217
 
193
 
218
                     if (fade && largeVideoState.isVisible) {
194
                     if (fade && largeVideoState.isVisible) {
376
             // Set default display name.
352
             // Set default display name.
377
             setDisplayName(videoSpanId);
353
             setDisplayName(videoSpanId);
378
 
354
 
379
-            VideoLayout.connectionIndicators[videoSpanId] = new ConnectionIndicator(container);
355
+            VideoLayout.connectionIndicators[videoSpanId] = new ConnectionIndicator(container, peerJid);
380
 
356
 
381
             var nickfield = document.createElement('span');
357
             var nickfield = document.createElement('span');
382
             nickfield.className = "nick";
358
             nickfield.className = "nick";
1482
                 if (updateFocusedVideoSrc) {
1458
                 if (updateFocusedVideoSrc) {
1483
                     focusedVideoSrc = electedStreamUrl;
1459
                     focusedVideoSrc = electedStreamUrl;
1484
                 }
1460
                 }
1461
+                var ssrc = videoSrcToSsrc[selRemoteVideo.attr('src')];
1462
+                displayedSsrcs[ssrc2jid[ssrc]] = ssrc;
1463
+                var jid = ssrc2jid[ssrc];
1464
+                var videoId;
1465
+                if(jid == connection.emuc.myroomjid)
1466
+                {
1467
+                    videoId = "localVideoContainer";
1468
+                }
1469
+                else
1470
+                {
1471
+                    videoId = "participant_" + Strophe.getResourceFromJid(jid);
1472
+                }
1473
+                var connectionIndicator = VideoLayout.connectionIndicators[videoId];
1474
+                if(connectionIndicator)
1475
+                    connectionIndicator.updatePopoverData();
1485
 
1476
 
1486
             } else {
1477
             } else {
1487
                 console.error('Could not find a stream or a session.', session, electedStream);
1478
                 console.error('Could not find a stream or a session.', session, electedStream);
1494
      * @param videoContainer the video container associated with the indicator.
1485
      * @param videoContainer the video container associated with the indicator.
1495
      * @constructor
1486
      * @constructor
1496
      */
1487
      */
1497
-    function ConnectionIndicator(videoContainer)
1488
+    function ConnectionIndicator(videoContainer, jid)
1498
     {
1489
     {
1499
         this.videoContainer = videoContainer;
1490
         this.videoContainer = videoContainer;
1500
         this.bandwidth = null;
1491
         this.bandwidth = null;
1504
         this.resolution = null;
1495
         this.resolution = null;
1505
         this.transport = [];
1496
         this.transport = [];
1506
         this.popover = null;
1497
         this.popover = null;
1507
-        this.showHQ = false;
1498
+        this.jid = jid;
1508
         this.create();
1499
         this.create();
1509
     }
1500
     }
1510
 
1501
 
1521
         0: "0px"//empty
1512
         0: "0px"//empty
1522
     };
1513
     };
1523
 
1514
 
1524
-    /**
1525
-     * Sets the value of the property that indicates whether the displayed resolution si the
1526
-     * resolution of High Quality stream or Low Quality
1527
-     * @param value boolean.
1528
-     */
1529
-    ConnectionIndicator.prototype.setShowHQ = function (value) {
1530
-        this.showHQ = value;
1531
-        this.updatePopoverData();
1532
-    };
1533
-
1534
     ConnectionIndicator.getIP = function(value)
1515
     ConnectionIndicator.getIP = function(value)
1535
     {
1516
     {
1536
         return value.substring(0, value.indexOf(":"));
1517
         return value.substring(0, value.indexOf(":"));
1583
         var resolutionValue = null;
1564
         var resolutionValue = null;
1584
         if(this.resolution)
1565
         if(this.resolution)
1585
         {
1566
         {
1586
-            if(this.showHQ && this.resolution.hq)
1567
+            var keys = Object.keys(this.resolution);
1568
+            if(keys.length == 1)
1587
             {
1569
             {
1588
-                resolutionValue = this.resolution.hq;
1570
+                for(var ssrc in this.resolution)
1571
+                {
1572
+                    resolutionValue = this.resolution[ssrc];
1573
+                }
1589
             }
1574
             }
1590
-            else if(!this.showHQ && this.resolution.lq)
1575
+            else if(keys.length > 1)
1591
             {
1576
             {
1592
-                resolutionValue = this.resolution.lq;
1577
+                resolutionValue = this.resolution[displayedSsrcs[this.jid]];
1593
             }
1578
             }
1594
         }
1579
         }
1595
 
1580
 
1596
-        if(!resolutionValue ||
1581
+        if(this.jid==null)
1582
+        {
1583
+            resolution = "";
1584
+            for(var i in this.resolution)
1585
+            {
1586
+                resolutionValue = this.resolution[i];
1587
+                if(resolutionValue)
1588
+                {
1589
+                    if(resolutionValue.height &&
1590
+                        resolutionValue.width)
1591
+                    {
1592
+                        resolution += (resolution == ""? "" : ", ")
1593
+                            + resolutionValue.width + "x" + resolutionValue.height;
1594
+                    }
1595
+                }
1596
+            }
1597
+        }
1598
+        else if(!resolutionValue ||
1597
             !resolutionValue.height ||
1599
             !resolutionValue.height ||
1598
             !resolutionValue.width)
1600
             !resolutionValue.width)
1599
         {
1601
         {

正在加载...
取消
保存