Procházet zdrojové kódy

Logs resolution changes to callstats.

j8
Boris Grozev před 8 roky
rodič
revize
de41977c77

+ 6
- 0
conference.js Zobrazit soubor

@@ -1231,6 +1231,12 @@ export default {
1231 1231
             room.dial(sipNumber);
1232 1232
         });
1233 1233
 
1234
+        APP.UI.addListener(UIEvents.RESOLUTION_CHANGED,
1235
+            (id, oldResolution, newResolution, delay) => {
1236
+            room.sendApplicationLog("Resolution change id=" + id
1237
+                + " old=" + oldResolution + " new=" + newResolution
1238
+                + " delay=" + delay);
1239
+        });
1234 1240
 
1235 1241
         // Starts or stops the recording for the conference.
1236 1242
         APP.UI.addListener(UIEvents.RECORDING_TOGGLED, (options) => {

+ 34
- 0
modules/UI/videolayout/SmallVideo.js Zobrazit soubor

@@ -2,6 +2,7 @@
2 2
 /* jshint -W101 */
3 3
 import Avatar from "../avatar/Avatar";
4 4
 import UIUtil from "../util/UIUtil";
5
+import UIEvents from "../../../service/UI/UIEvents";
5 6
 
6 7
 const RTCUIHelper = JitsiMeetJS.util.RTCUIHelper;
7 8
 
@@ -487,4 +488,37 @@ SmallVideo.prototype.getIndicatorSpan = function(id) {
487 488
     return indicatorSpan;
488 489
 };
489 490
 
491
+/**
492
+ * Adds a listener for onresize events for this video, which will monitor for
493
+ * resolution changes, will calculate the delay since the moment the listened
494
+ * is added, and will fire a RESOLUTION_CHANGED event.
495
+ */
496
+SmallVideo.prototype.waitForResolutionChange = function() {
497
+    let self = this;
498
+    let beforeChange = window.performance.now();
499
+    let videos = this.selectVideoElement();
500
+    if (!videos || !videos.length || videos.length <= 0)
501
+        return;
502
+    let video = videos[0];
503
+    let oldWidth = video.videoWidth;
504
+    let oldHeight = video.videoHeight;
505
+    video.onresize = (event) => {
506
+        if (video.videoWidth != oldWidth || video.videoHeight != oldHeight) {
507
+            // Only run once.
508
+            video.onresize = null;
509
+
510
+            let delay = window.performance.now() - beforeChange;
511
+            let emitter = self.VideoLayout.getEventEmitter();
512
+            if (emitter) {
513
+                emitter.emit(
514
+                        UIEvents.RESOLUTION_CHANGED,
515
+                        self.getId(),
516
+                        oldWidth + "x" + oldHeight,
517
+                        video.videoWidth + "x" + video.videoHeight,
518
+                        delay);
519
+            }
520
+        }
521
+    };
522
+};
523
+
490 524
 export default SmallVideo;

+ 10
- 3
modules/UI/videolayout/VideoLayout.js Zobrazit soubor

@@ -1010,11 +1010,16 @@ var VideoLayout = {
1010 1010
             if (id !== currentId && videoType === VIDEO_CONTAINER_TYPE) {
1011 1011
                 eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
1012 1012
             }
1013
+
1014
+            let smallVideo = this.getSmallVideo(id);
1015
+            let oldSmallVideo;
1013 1016
             if (currentId) {
1014
-                var oldSmallVideo = this.getSmallVideo(currentId);
1017
+                oldSmallVideo = this.getSmallVideo(currentId);
1015 1018
             }
1016 1019
 
1017
-            let smallVideo = this.getSmallVideo(id);
1020
+            smallVideo.waitForResolutionChange();
1021
+            if (oldSmallVideo)
1022
+                oldSmallVideo.waitForResolutionChange();
1018 1023
 
1019 1024
             largeVideo.updateLargeVideo(
1020 1025
                 id,
@@ -1118,7 +1123,9 @@ var VideoLayout = {
1118 1123
     setLocalFlipX: function (val) {
1119 1124
         this.localFlipX = val;
1120 1125
 
1121
-    }
1126
+    },
1127
+
1128
+    getEventEmitter: () => {return eventEmitter;}
1122 1129
 };
1123 1130
 
1124 1131
 export default VideoLayout;

+ 4
- 1
service/UI/UIEvents.js Zobrazit soubor

@@ -80,5 +80,8 @@ export default {
80 80
     /**
81 81
      * Notifies that flipX property of the local video is changed.
82 82
      */
83
-    LOCAL_FLIPX_CHANGED: "UI.local_flipx_changed"
83
+    LOCAL_FLIPX_CHANGED: "UI.local_flipx_changed",
84
+    // An event which indicates that the resolution of a remote video has
85
+    // changed.
86
+    RESOLUTION_CHANGED: "UI.resolution_changed"
84 87
 };

Načítá se…
Zrušit
Uložit