Explorar el Código

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.
factor2
Leonard Kim hace 8 años
padre
commit
eb1a44f5ba
Se han modificado 1 ficheros con 7 adiciones y 8 borrados
  1. 7
    8
      react/features/connection-indicator/statsEmitter.js

+ 7
- 8
react/features/connection-indicator/statsEmitter.js Ver fichero

@@ -108,20 +108,19 @@ const statsEmitter = {
108 108
      * @returns {void}
109 109
      */
110 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 114
         // FIXME resolution and framerate are hashes keyed off of user ids with
118 115
         // stat values. Receivers of stats expect resolution and framerate to
119 116
         // be primatives, not hashes, so overwrites the 'lib-jitsi-meet' stats
120 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 125
         // Get all the unique user ids from the framerate and resolution stats
127 126
         // and update remote user stats as needed.

Loading…
Cancelar
Guardar