瀏覽代碼

ref(stats): do not modify stats object from lib

This is more of a principle change than a necessary one.
In lib-jitsi-meet, when a getStats call finishes, the
stats are processed and first emitted (and received by
jitsi-meet) and then processed again for sending to
remote participants. Modifying the stats in place changes
the structure of stats before the second processing,
which maybe be unexpected.
master
Leonard Kim 7 年之前
父節點
當前提交
eb1a44f5ba
共有 1 個檔案被更改,包括 7 行新增8 行删除
  1. 7
    8
      react/features/connection-indicator/statsEmitter.js

+ 7
- 8
react/features/connection-indicator/statsEmitter.js 查看文件

108
      * @returns {void}
108
      * @returns {void}
109
      */
109
      */
110
     _onStatsUpdated(currentUserId, stats) {
110
     _onStatsUpdated(currentUserId, stats) {
111
-        const allUserFramerates = stats.framerate;
112
-        const allUserResolutions = stats.resolution;
113
-
114
-        const currentUserFramerate = allUserFramerates[currentUserId];
115
-        const currentUserResolution = allUserResolutions[currentUserId];
111
+        const allUserFramerates = stats.framerate || {};
112
+        const allUserResolutions = stats.resolution || {};
116
 
113
 
117
         // FIXME resolution and framerate are hashes keyed off of user ids with
114
         // FIXME resolution and framerate are hashes keyed off of user ids with
118
         // stat values. Receivers of stats expect resolution and framerate to
115
         // stat values. Receivers of stats expect resolution and framerate to
119
         // be primatives, not hashes, so overwrites the 'lib-jitsi-meet' stats
116
         // be primatives, not hashes, so overwrites the 'lib-jitsi-meet' stats
120
         // objects.
117
         // objects.
121
-        stats.framerate = currentUserFramerate;
122
-        stats.resolution = currentUserResolution;
118
+        const modifiedLocalStats = Object.assign({}, stats, {
119
+            framerate: allUserFramerates[currentUserId],
120
+            resolution: allUserResolutions[currentUserId]
121
+        });
123
 
122
 
124
-        this._emitStatsUpdate(currentUserId, stats);
123
+        this._emitStatsUpdate(currentUserId, modifiedLocalStats);
125
 
124
 
126
         // Get all the unique user ids from the framerate and resolution stats
125
         // Get all the unique user ids from the framerate and resolution stats
127
         // and update remote user stats as needed.
126
         // and update remote user stats as needed.

Loading…
取消
儲存