|
@@ -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
|
/**
|