Kaynağa Gözat

Merges changes with latest master.

master
yanas 8 yıl önce
ebeveyn
işleme
5c956de99e
2 değiştirilmiş dosya ile 60 ekleme ve 75 silme
  1. 3
    5
      interface_config.js
  2. 57
    70
      modules/UI/videolayout/FilmStrip.js

+ 3
- 5
interface_config.js Dosyayı Görüntüle

@@ -58,10 +58,6 @@ var interfaceConfig = { // eslint-disable-line no-unused-vars
58 58
     RANDOM_AVATAR_URL_PREFIX: false,
59 59
     RANDOM_AVATAR_URL_SUFFIX: false,
60 60
     FILM_STRIP_MAX_HEIGHT: 120,
61
-    LOCAL_THUMBNAIL_RATIO_WIDTH: 16,
62
-    LOCAL_THUMBNAIL_RATIO_HEIGHT: 9,
63
-    REMOTE_THUMBNAIL_RATIO_WIDTH: 1,
64
-    REMOTE_THUMBNAIL_RATIO_HEIGHT: 1,
65 61
     // Enables feedback star animation.
66 62
     ENABLE_FEEDBACK_ANIMATION: false,
67 63
     DISABLE_FOCUS_INDICATOR: false,
@@ -70,5 +66,7 @@ var interfaceConfig = { // eslint-disable-line no-unused-vars
70 66
     DISABLE_RINGING: false,
71 67
     AUDIO_LEVEL_PRIMARY_COLOR: "rgba(255,255,255,0.4)",
72 68
     AUDIO_LEVEL_SECONDARY_COLOR: "rgba(255,255,255,0.2)",
73
-    POLICY_LOGO: null
69
+    POLICY_LOGO: null,
70
+    LOCAL_THUMBNAIL_RATIO: 16/9, //16:9
71
+    REMOTE_THUMBNAIL_RATIO: 1 //1:1
74 72
 };

+ 57
- 70
modules/UI/videolayout/FilmStrip.js Dosyayı Görüntüle

@@ -160,45 +160,6 @@ const FilmStrip = {
160 160
         return this.calculateThumbnailSizeFromAvailable(width, height);
161 161
     },
162 162
 
163
-    /**
164
-     * Normalizes local and remote thumbnail ratios
165
-     */
166
-    normalizeThumbnailRatio() {
167
-        let remoteHeightRatio = interfaceConfig.REMOTE_THUMBNAIL_RATIO_HEIGHT;
168
-        let remoteWidthRatio = interfaceConfig.REMOTE_THUMBNAIL_RATIO_WIDTH;
169
-
170
-        let localHeightRatio = interfaceConfig.LOCAL_THUMBNAIL_RATIO_HEIGHT;
171
-        let localWidthRatio = interfaceConfig.LOCAL_THUMBNAIL_RATIO_WIDTH;
172
-
173
-        let commonHeightRatio = remoteHeightRatio * localHeightRatio;
174
-
175
-        let localRatioCoefficient = localWidthRatio / localHeightRatio;
176
-        let remoteRatioCoefficient = remoteWidthRatio / remoteHeightRatio;
177
-
178
-        remoteWidthRatio = commonHeightRatio * remoteRatioCoefficient;
179
-        remoteHeightRatio = commonHeightRatio;
180
-
181
-        localWidthRatio = commonHeightRatio * localRatioCoefficient;
182
-        localHeightRatio = commonHeightRatio;
183
-
184
-        let localRatio = {
185
-            widthRatio: localWidthRatio,
186
-            heightRatio: localHeightRatio
187
-        };
188
-
189
-        let remoteRatio = {
190
-            widthRatio: remoteWidthRatio,
191
-            heightRatio: remoteHeightRatio
192
-        };
193
-
194
-        return { localRatio, remoteRatio };
195
-    },
196
-
197
-    /**
198
-     * Calculates available size for one thumbnail according to
199
-     * the current window size
200
-     * @returns {{availableWidth: number, availableHeight: number}}
201
-     */
202 163
     calculateAvailableSize() {
203 164
         let availableHeight = interfaceConfig.FILM_STRIP_MAX_HEIGHT;
204 165
         let thumbs = this.getThumbs(true);
@@ -275,40 +236,66 @@ const FilmStrip = {
275 236
     },
276 237
 
277 238
     /**
278
-     * Takes the available size for thumbnail and calculates
279
-     * final size of thumbnails
280
-     * @param availableWidth
281
-     * @param availableHeight
282
-     * @returns {{localVideo, remoteVideo}}
239
+     * Calculate the thumbnail size in order to fit all the thumnails in passed
240
+     * dimensions.
241
+     * NOTE: Here we assume that the remote and local thumbnails are with the
242
+     * same height.
243
+     * @param {int} availableWidth the maximum width for all thumbnails
244
+     * @param {int} availableHeight the maximum height for all thumbnails
283 245
      */
284 246
     calculateThumbnailSizeFromAvailable(availableWidth, availableHeight) {
285
-        let { localRatio, remoteRatio } = this.normalizeThumbnailRatio();
286
-        let { remoteThumbs } = this.getThumbs(true);
287
-        let remoteProportion = remoteRatio.widthRatio * remoteThumbs.length;
288
-        let widthProportion = remoteProportion + localRatio.widthRatio;
289
-
290
-        let heightUnit = availableHeight / localRatio.heightRatio;
291
-        let widthUnit = availableWidth / widthProportion;
247
+        /**
248
+         * Let:
249
+         * lW - width of the local thumbnail
250
+         * rW - width of the remote thumbnail
251
+         * h - the height of the thumbnails
252
+         * remoteRatio - width:height for the remote thumbnail
253
+         * localRatio - width:height for the local thumbnail
254
+         * numberRemoteThumbs - number of remote thumbnails (we have only one
255
+         * local thumbnail)
256
+         *
257
+         * Since the height for local thumbnail = height for remote thumbnail
258
+         * and we know the ratio (width:height) for the local and for the
259
+         * remote thumbnail we can find rW/lW:
260
+         * rW / remoteRatio = lW / localRatio then -
261
+         * remoteLocalWidthRatio = rW / lW = remoteRatio / localRatio
262
+         * and rW = lW * remoteRatio / localRatio = lW * remoteLocalWidthRatio
263
+         * And the total width for the thumbnails is:
264
+         * totalWidth = rW * numberRemoteThumbs + lW
265
+         * = lW * remoteLocalWidthRatio * numberRemoteThumbs + lW =
266
+         * lW * (remoteLocalWidthRatio * numberRemoteThumbs + 1)
267
+         * and the h = lW/localRatio
268
+         *
269
+         * In order to fit all the thumbails in the area defined by
270
+         * availableWidth * availableHeight we should check one of the
271
+         * following options:
272
+         * 1) if availableHeight == h - totalWidth should be less than
273
+         * availableWidth
274
+         * 2) if availableWidth ==  totalWidth - h should be less than
275
+         * availableHeight
276
+         *
277
+         * 1) or 2) will be true and we are going to use it to calculate all
278
+         * sizes.
279
+         *
280
+         * if 1) is true that means that
281
+         * availableHeight/h > availableWidth/totalWidth otherwise 2) is true
282
+         */
292 283
 
293
-        if (heightUnit < widthUnit) {
294
-            widthUnit = heightUnit;
295
-        }
296
-        else
297
-            heightUnit = widthUnit;
298
-
299
-        let localVideo = {
300
-            thumbWidth: widthUnit * localRatio.widthRatio,
301
-            thumbHeight: heightUnit * localRatio.heightRatio
302
-        };
303
-        let remoteVideo = {
304
-            thumbWidth: widthUnit * remoteRatio.widthRatio,
305
-            thumbHeight: widthUnit * remoteRatio.heightRatio
306
-        };
307
-
308
-        return {
309
-            localVideo,
310
-            remoteVideo
311
-        };
284
+        const numberRemoteThumbs = this.getThumbs(true).remoteThumbs.length;
285
+        const remoteLocalWidthRatio = interfaceConfig.REMOTE_THUMBNAIL_RATIO /
286
+            interfaceConfig.LOCAL_THUMBNAIL_RATIO;
287
+        const lW = Math.min(availableWidth /
288
+            (remoteLocalWidthRatio * numberRemoteThumbs + 1), availableHeight *
289
+            interfaceConfig.LOCAL_THUMBNAIL_RATIO);
290
+        const h = lW / interfaceConfig.LOCAL_THUMBNAIL_RATIO;
291
+        return { localVideo:{
292
+                        thumbWidth: lW,
293
+                        thumbHeight: h
294
+                    }, remoteVideo: {
295
+                        thumbWidth: lW * remoteLocalWidthRatio,
296
+                        thumbHeight: h
297
+                    }
298
+                };
312 299
     },
313 300
 
314 301
     /**

Loading…
İptal
Kaydet