@webex/plugin-meetings 3.8.1-next.29 → 3.8.1-next.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/constants.ts CHANGED
@@ -1189,6 +1189,7 @@ export const QUALITY_LEVELS = {
1189
1189
  HIGH: 'HIGH',
1190
1190
  '360p': '360p',
1191
1191
  '480p': '480p',
1192
+ '540p': '540p',
1192
1193
  '720p': '720p',
1193
1194
  '1080p': '1080p',
1194
1195
  };
@@ -1218,6 +1219,18 @@ export const AVAILABLE_RESOLUTIONS = {
1218
1219
  },
1219
1220
  },
1220
1221
  },
1222
+ '540p': {
1223
+ video: {
1224
+ width: {
1225
+ max: 960,
1226
+ ideal: 960,
1227
+ },
1228
+ height: {
1229
+ max: 540,
1230
+ ideal: 540,
1231
+ },
1232
+ },
1233
+ },
1221
1234
  '720p': {
1222
1235
  video: {
1223
1236
  width: {
@@ -15,7 +15,7 @@ import {cloneDeepWith, debounce, isEmpty} from 'lodash';
15
15
  import LoggerProxy from '../common/logs/logger-proxy';
16
16
 
17
17
  import {ReceiveSlot, ReceiveSlotEvents} from './receiveSlot';
18
- import {getMaxFs} from './remoteMedia';
18
+ import {MAX_FS_VALUES} from './remoteMedia';
19
19
 
20
20
  export interface ActiveSpeakerPolicyInfo {
21
21
  policy: 'active-speaker';
@@ -123,12 +123,12 @@ export class MediaRequestManager {
123
123
 
124
124
  private getDegradedClientRequests(clientRequests: ClientRequestsMap) {
125
125
  const maxFsLimits = [
126
- getMaxFs('best'),
127
- getMaxFs('large'),
128
- getMaxFs('medium'),
129
- getMaxFs('small'),
130
- getMaxFs('very small'),
131
- getMaxFs('thumbnail'),
126
+ MAX_FS_VALUES['1080p'],
127
+ MAX_FS_VALUES['720p'],
128
+ MAX_FS_VALUES['540p'],
129
+ MAX_FS_VALUES['360p'],
130
+ MAX_FS_VALUES['180p'],
131
+ MAX_FS_VALUES['90p'],
132
132
  ];
133
133
 
134
134
  // reduce max-fs until total macroblocks is below limit
@@ -19,17 +19,18 @@ export type RemoteVideoResolution =
19
19
  | 'large' // 1080p or less
20
20
  | 'best'; // highest possible resolution
21
21
 
22
- const MAX_FS_VALUES = {
22
+ export const MAX_FS_VALUES = {
23
23
  '90p': 60,
24
24
  '180p': 240,
25
25
  '360p': 920,
26
+ '540p': 2040,
26
27
  '720p': 3600,
27
28
  '1080p': 8192,
28
29
  };
29
30
 
30
31
  /**
31
32
  * Converts pane size into h264 maxFs
32
- * @param {PaneSize} paneSize
33
+ * @param {RemoteVideoResolution} paneSize
33
34
  * @returns {number}
34
35
  */
35
36
  export function getMaxFs(paneSize: RemoteVideoResolution): number {
@@ -89,6 +90,13 @@ export class RemoteMedia extends EventsScope {
89
90
 
90
91
  public readonly id: RemoteMediaId;
91
92
 
93
+ /**
94
+ * The max frame size of the media request, used for logging and media requests.
95
+ * Set by setSizeHint() based on video element dimensions.
96
+ * When > 0, this value takes precedence over options.resolution in sendMediaRequest().
97
+ */
98
+ private maxFrameSize = 0;
99
+
92
100
  /**
93
101
  * Constructs RemoteMedia instance
94
102
  *
@@ -136,15 +144,34 @@ export class RemoteMedia extends EventsScope {
136
144
  fs = MAX_FS_VALUES['180p'];
137
145
  } else if (height < getThresholdHeight(360)) {
138
146
  fs = MAX_FS_VALUES['360p'];
147
+ } else if (height < getThresholdHeight(540)) {
148
+ fs = MAX_FS_VALUES['540p'];
139
149
  } else if (height <= 720) {
140
150
  fs = MAX_FS_VALUES['720p'];
141
151
  } else {
142
152
  fs = MAX_FS_VALUES['1080p'];
143
153
  }
144
154
 
155
+ this.maxFrameSize = fs;
145
156
  this.receiveSlot?.setMaxFs(fs);
146
157
  }
147
158
 
159
+ /**
160
+ * Get the current effective maxFs value that would be used in media requests
161
+ * @returns {number | undefined} The maxFs value, or undefined if no constraints
162
+ */
163
+ public getEffectiveMaxFs(): number | undefined {
164
+ if (this.maxFrameSize > 0) {
165
+ return this.maxFrameSize;
166
+ }
167
+
168
+ if (this.options.resolution) {
169
+ return getMaxFs(this.options.resolution);
170
+ }
171
+
172
+ return undefined;
173
+ }
174
+
148
175
  /**
149
176
  * Invalidates the remote media by clearing the reference to a receive slot and
150
177
  * cancelling the media request.
@@ -185,6 +212,9 @@ export class RemoteMedia extends EventsScope {
185
212
  throw new Error('sendMediaRequest() called on an invalidated RemoteMedia instance');
186
213
  }
187
214
 
215
+ // Use maxFrameSize from setSizeHint if available, otherwise fallback to options.resolution
216
+ const maxFs = this.getEffectiveMaxFs();
217
+
188
218
  this.mediaRequestId = this.mediaRequestManager.addRequest(
189
219
  {
190
220
  policyInfo: {
@@ -192,9 +222,9 @@ export class RemoteMedia extends EventsScope {
192
222
  csi,
193
223
  },
194
224
  receiveSlots: [this.receiveSlot],
195
- codecInfo: this.options.resolution && {
225
+ codecInfo: maxFs && {
196
226
  codec: 'h264',
197
- maxFs: getMaxFs(this.options.resolution),
227
+ maxFs,
198
228
  },
199
229
  },
200
230
  commit
@@ -215,6 +215,9 @@ export class RemoteMediaGroup {
215
215
  private sendActiveSpeakerMediaRequest(commit: boolean) {
216
216
  this.cancelActiveSpeakerMediaRequest(false);
217
217
 
218
+ // Calculate the effective maxFs based on all unpinned RemoteMedia instances
219
+ const effectiveMaxFs = this.getEffectiveMaxFsForActiveSpeaker();
220
+
218
221
  this.mediaRequestId = this.mediaRequestManager.addRequest(
219
222
  {
220
223
  policyInfo: {
@@ -230,9 +233,9 @@ export class RemoteMediaGroup {
230
233
  receiveSlots: this.unpinnedRemoteMedia.map((remoteMedia) =>
231
234
  remoteMedia.getUnderlyingReceiveSlot()
232
235
  ) as ReceiveSlot[],
233
- codecInfo: this.options.resolution && {
236
+ codecInfo: effectiveMaxFs && {
234
237
  codec: 'h264',
235
- maxFs: getMaxFs(this.options.resolution),
238
+ maxFs: effectiveMaxFs,
236
239
  },
237
240
  },
238
241
  commit
@@ -300,4 +303,36 @@ export class RemoteMediaGroup {
300
303
  this.unpinnedRemoteMedia.includes(remoteMedia) || this.pinnedRemoteMedia.includes(remoteMedia)
301
304
  );
302
305
  }
306
+
307
+ /**
308
+ * Calculate the effective maxFs for the active speaker media request based on unpinned RemoteMedia instances
309
+ * @returns {number | undefined} The calculated maxFs value, or undefined if no constraints
310
+ * @private
311
+ */
312
+ private getEffectiveMaxFsForActiveSpeaker(): number | undefined {
313
+ // Get all effective maxFs values from unpinned RemoteMedia instances
314
+ const maxFsValues = this.unpinnedRemoteMedia
315
+ .map((remoteMedia) => remoteMedia.getEffectiveMaxFs())
316
+ .filter((maxFs) => maxFs !== undefined);
317
+
318
+ // Use the highest maxFs value to ensure we don't under-request resolution for any instance
319
+ if (maxFsValues.length > 0) {
320
+ return Math.max(...maxFsValues);
321
+ }
322
+
323
+ // Fall back to group's resolution option
324
+ if (this.options.resolution) {
325
+ return getMaxFs(this.options.resolution);
326
+ }
327
+
328
+ return undefined;
329
+ }
330
+
331
+ /**
332
+ * Get the current effective maxFs that would be used for the active speaker media request
333
+ * @returns {number | undefined} The effective maxFs value
334
+ */
335
+ public getEffectiveMaxFs(): number | undefined {
336
+ return this.getEffectiveMaxFsForActiveSpeaker();
337
+ }
303
338
  }
@@ -3,7 +3,7 @@ import {MediaRequestManager} from '@webex/plugin-meetings/src/multistream/mediaR
3
3
  import {ReceiveSlot} from '@webex/plugin-meetings/src/multistream/receiveSlot';
4
4
  import sinon from 'sinon';
5
5
  import {assert} from '@webex/test-helper-chai';
6
- import {getMaxFs} from '@webex/plugin-meetings/src/multistream/remoteMedia';
6
+ import {getMaxFs, MAX_FS_VALUES} from '@webex/plugin-meetings/src/multistream/remoteMedia';
7
7
  import FakeTimers from '@sinonjs/fake-timers';
8
8
  import * as InternalMediaCoreModule from '@webex/internal-media-core';
9
9
  import { expect } from 'chai';
@@ -36,12 +36,15 @@ describe('MediaRequestManager', () => {
36
36
  const CROSS_POLICY_DUPLICATION = true;
37
37
  const MAX_FPS = 3000;
38
38
  const MAX_FS_360p = 920;
39
+ const MAX_FS_540p = 2040;
39
40
  const MAX_FS_720p = 3600;
40
41
  const MAX_FS_1080p = 8192;
41
42
  const MAX_MBPS_360p = 27600;
43
+ const MAX_MBPS_540p = 61200;
42
44
  const MAX_MBPS_720p = 108000;
43
45
  const MAX_MBPS_1080p = 245760;
44
46
  const MAX_PAYLOADBITSPS_360p = 640000;
47
+ const MAX_PAYLOADBITSPS_540p = 880000;
45
48
  const MAX_PAYLOADBITSPS_720p = 2500000;
46
49
  const MAX_PAYLOADBITSPS_1080p = 4000000;
47
50
 
@@ -82,7 +85,14 @@ describe('MediaRequestManager', () => {
82
85
  });
83
86
 
84
87
  // helper function for adding an active speaker request
85
- const addActiveSpeakerRequest = (priority, receiveSlots, maxFs, commit = false, preferLiveVideo = true, namedMediaGroups = undefined) =>
88
+ const addActiveSpeakerRequest = (
89
+ priority,
90
+ receiveSlots,
91
+ maxFs,
92
+ commit = false,
93
+ preferLiveVideo = true,
94
+ namedMediaGroups = undefined
95
+ ) =>
86
96
  mediaRequestManager.addRequest(
87
97
  {
88
98
  policyInfo: {
@@ -216,6 +226,9 @@ describe('MediaRequestManager', () => {
216
226
  },
217
227
  false
218
228
  );
229
+
230
+
231
+
219
232
  mediaRequestManager.addRequest(
220
233
  {
221
234
  policyInfo: {
@@ -892,15 +905,15 @@ describe('MediaRequestManager', () => {
892
905
  // request 10 "large" 1080p streams
893
906
  addActiveSpeakerRequest(255, fakeReceiveSlots.slice(0, 10), getMaxFs('large'), true);
894
907
 
895
- // check that resulting requests are 10 "small" 360p streams
908
+ // check that resulting requests are 10 540p streams
896
909
  checkMediaRequestsSent([
897
910
  {
898
911
  policy: 'active-speaker',
899
912
  priority: 255,
900
913
  receiveSlots: fakeWcmeSlots.slice(0, 10),
901
- maxPayloadBitsPerSecond: MAX_PAYLOADBITSPS_360p,
902
- maxFs: getMaxFs('small'),
903
- maxMbps: MAX_MBPS_360p,
914
+ maxPayloadBitsPerSecond: MAX_PAYLOADBITSPS_540p,
915
+ maxFs: MAX_FS_VALUES['540p'],
916
+ maxMbps: MAX_MBPS_540p,
904
917
  },
905
918
  ]);
906
919
  });
@@ -3,7 +3,7 @@ import 'jsdom-global/register';
3
3
  import EventEmitter from 'events';
4
4
 
5
5
  import {MediaType} from '@webex/internal-media-core';
6
- import {RemoteMedia, RemoteMediaEvents} from '@webex/plugin-meetings/src/multistream/remoteMedia';
6
+ import {RemoteMedia, RemoteMediaEvents, RemoteVideoResolution} from '@webex/plugin-meetings/src/multistream/remoteMedia';
7
7
  import {ReceiveSlotEvents} from '@webex/plugin-meetings/src/multistream/receiveSlot';
8
8
  import sinon from 'sinon';
9
9
  import {assert} from '@webex/test-helper-chai';
@@ -257,7 +257,9 @@ describe('RemoteMedia', () => {
257
257
  {height: 198, fs: 920}, // 360p
258
258
  {height: 360, fs: 920},
259
259
  {height: 395, fs: 920},
260
- {height: 396, fs: 3600}, // 720p
260
+ {height: 396, fs: 2040}, // 540p
261
+ {height: 540, fs: 2040},
262
+ {height: 610, fs: 3600}, // 720p
261
263
  {height: 720, fs: 3600},
262
264
  {height: 721, fs: 8192}, // 1080p
263
265
  {height: 1080, fs: 8192},
@@ -271,4 +273,66 @@ describe('RemoteMedia', () => {
271
273
  }
272
274
  );
273
275
  });
276
+
277
+ describe('getEffectiveMaxFs()', () => {
278
+ it('returns maxFrameSize when it is greater than 0', () => {
279
+ remoteMedia.setSizeHint(960, 540);
280
+
281
+ const result = remoteMedia.getEffectiveMaxFs();
282
+
283
+ assert.strictEqual(result, 2040);
284
+ });
285
+
286
+ it('returns getMaxFs result when maxFrameSize is 0 and resolution is provided', () => {
287
+ remoteMedia.setSizeHint(0, 0);
288
+
289
+ // remoteMedia was created with {resolution: 'medium'} in beforeEach
290
+
291
+ const result = remoteMedia.getEffectiveMaxFs();
292
+
293
+ // 'medium' resolution should map to 720p which is 3600
294
+ assert.strictEqual(result, 3600);
295
+ });
296
+
297
+ it('returns undefined when maxFrameSize is 0 and no resolution is provided', () => {
298
+ remoteMedia.setSizeHint(0, 0);
299
+
300
+ // Create a new RemoteMedia without resolution option
301
+ const remoteMediaWithoutResolution = new RemoteMedia(fakeReceiveSlot, fakeMediaRequestManager);
302
+
303
+ const result = remoteMediaWithoutResolution.getEffectiveMaxFs();
304
+
305
+ assert.strictEqual(result, undefined);
306
+ });
307
+
308
+ it('prioritizes maxFrameSize over resolution option', () => {
309
+ remoteMedia.setSizeHint(640, 360);
310
+ // remoteMedia was created with {resolution: 'medium'} in beforeEach
311
+
312
+ const result = remoteMedia.getEffectiveMaxFs();
313
+
314
+ // Should return maxFrameSize (500) instead of resolution-based value (3600)
315
+ assert.strictEqual(result, 920);
316
+ });
317
+
318
+ it('works correctly with different resolution options', () => {
319
+ const testCases: Array<{ resolution: RemoteVideoResolution; expected: number }> = [
320
+ { resolution: 'thumbnail', expected: 60 },
321
+ { resolution: 'very small', expected: 240 },
322
+ { resolution: 'small', expected: 920 },
323
+ { resolution: 'medium', expected: 3600 },
324
+ { resolution: 'large', expected: 8192 },
325
+ { resolution: 'best', expected: 8192 },
326
+ ];
327
+
328
+ testCases.forEach(({ resolution, expected }) => {
329
+ const testRemoteMedia = new RemoteMedia(fakeReceiveSlot, fakeMediaRequestManager, { resolution });
330
+ testRemoteMedia.setSizeHint(0, 0); // Ensure maxFrameSize doesn't interfere
331
+
332
+ const result = testRemoteMedia.getEffectiveMaxFs();
333
+
334
+ assert.strictEqual(result, expected, `Failed for resolution: ${resolution}`);
335
+ });
336
+ });
337
+ });
274
338
  });