@webex/plugin-meetings 3.0.0-beta.380 → 3.0.0-beta.382

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.
Files changed (41) hide show
  1. package/dist/breakouts/breakout.js +1 -1
  2. package/dist/breakouts/index.js +1 -1
  3. package/dist/constants.js +7 -2
  4. package/dist/constants.js.map +1 -1
  5. package/dist/interpretation/index.js +16 -2
  6. package/dist/interpretation/index.js.map +1 -1
  7. package/dist/interpretation/siLanguage.js +1 -1
  8. package/dist/meeting/index.js +66 -35
  9. package/dist/meeting/index.js.map +1 -1
  10. package/dist/meetings/index.js +0 -19
  11. package/dist/meetings/index.js.map +1 -1
  12. package/dist/multistream/mediaRequestManager.js +1 -1
  13. package/dist/multistream/mediaRequestManager.js.map +1 -1
  14. package/dist/multistream/remoteMediaGroup.js +16 -2
  15. package/dist/multistream/remoteMediaGroup.js.map +1 -1
  16. package/dist/multistream/remoteMediaManager.js +177 -65
  17. package/dist/multistream/remoteMediaManager.js.map +1 -1
  18. package/dist/multistream/sendSlotManager.js +22 -0
  19. package/dist/multistream/sendSlotManager.js.map +1 -1
  20. package/dist/types/constants.d.ts +2 -0
  21. package/dist/types/meeting/index.d.ts +8 -0
  22. package/dist/types/multistream/mediaRequestManager.d.ts +2 -0
  23. package/dist/types/multistream/remoteMediaGroup.d.ts +2 -0
  24. package/dist/types/multistream/remoteMediaManager.d.ts +16 -0
  25. package/dist/types/multistream/sendSlotManager.d.ts +9 -0
  26. package/dist/webinar/index.js +1 -1
  27. package/package.json +19 -19
  28. package/src/constants.ts +4 -0
  29. package/src/interpretation/index.ts +18 -1
  30. package/src/meeting/index.ts +38 -1
  31. package/src/meetings/index.ts +0 -22
  32. package/src/multistream/mediaRequestManager.ts +4 -1
  33. package/src/multistream/remoteMediaGroup.ts +19 -0
  34. package/src/multistream/remoteMediaManager.ts +101 -15
  35. package/src/multistream/sendSlotManager.ts +29 -0
  36. package/test/unit/spec/interpretation/index.ts +36 -3
  37. package/test/unit/spec/meeting/index.js +25 -1
  38. package/test/unit/spec/multistream/mediaRequestManager.ts +20 -2
  39. package/test/unit/spec/multistream/remoteMediaGroup.ts +80 -1
  40. package/test/unit/spec/multistream/remoteMediaManager.ts +200 -1
  41. package/test/unit/spec/multistream/sendSlotManager.ts +50 -18
@@ -8,7 +8,7 @@ import sinon from 'sinon';
8
8
  import * as internalMediaModule from '@webex/internal-media-core';
9
9
  import StateMachine from 'javascript-state-machine';
10
10
  import uuid from 'uuid';
11
- import {assert} from '@webex/test-helper-chai';
11
+ import {assert, expect} from '@webex/test-helper-chai';
12
12
  import {Credentials, Token, WebexPlugin} from '@webex/webex-core';
13
13
  import Support from '@webex/internal-plugin-support';
14
14
  import MockWebex from '@webex/test-helper-mock-webex';
@@ -2722,6 +2722,7 @@ describe('plugin-meetings', () => {
2722
2722
  createSendSlot: sinon.stub().returns({
2723
2723
  publishStream: sinon.stub(),
2724
2724
  unpublishStream: sinon.stub(),
2725
+ setNamedMediaGroups: sinon.stub(),
2725
2726
  }),
2726
2727
  enableMultistreamAudio: sinon.stub(),
2727
2728
  };
@@ -6051,6 +6052,29 @@ describe('plugin-meetings', () => {
6051
6052
  });
6052
6053
  });
6053
6054
 
6055
+ describe('#setSendNamedMediaGroup', () => {
6056
+ beforeEach(() => {
6057
+ meeting.sendSlotManager.setNamedMediaGroups = sinon.stub().returns(undefined);
6058
+ });
6059
+ it('should throw error if not audio type', () => {
6060
+ expect(() => meeting.setSendNamedMediaGroup(MediaType.VideoMain, 20)).to.throw(`cannot set send named media group which media type is ${MediaType.VideoMain}`)
6061
+
6062
+ });
6063
+ it('fails if there is no media connection', () => {
6064
+
6065
+ meeting.mediaProperties.webrtcMediaConnection = undefined;
6066
+ meeting.setSendNamedMediaGroup('AUDIO-MAIN', 20);
6067
+ assert.notCalled(meeting.sendSlotManager.setNamedMediaGroups);
6068
+ });
6069
+
6070
+ it('success if there is media connection', () => {
6071
+ meeting.isMultistream = true;
6072
+ meeting.mediaProperties.webrtcMediaConnection = true;
6073
+ meeting.setSendNamedMediaGroup("AUDIO-MAIN", 20);
6074
+ assert.calledOnceWithExactly(meeting.sendSlotManager.setNamedMediaGroups, "AUDIO-MAIN", [{type: 1, value: 20}]);
6075
+ });
6076
+ });
6077
+
6054
6078
  describe('#enableMusicMode', () => {
6055
6079
  beforeEach(() => {
6056
6080
  meeting.isMultistream = true;
@@ -14,6 +14,7 @@ type ExpectedActiveSpeaker = {
14
14
  receiveSlots: Array<ReceiveSlot>;
15
15
  maxFs?: number;
16
16
  maxMbps?: number;
17
+ namedMediaGroups?:[{type: number, value: number}];
17
18
  };
18
19
  type ExpectedReceiverSelected = {
19
20
  policy: 'receiver-selected';
@@ -80,7 +81,7 @@ describe('MediaRequestManager', () => {
80
81
  });
81
82
 
82
83
  // helper function for adding an active speaker request
83
- const addActiveSpeakerRequest = (priority, receiveSlots, maxFs, commit = false, preferLiveVideo = true) =>
84
+ const addActiveSpeakerRequest = (priority, receiveSlots, maxFs, commit = false, preferLiveVideo = true, namedMediaGroups = undefined) =>
84
85
  mediaRequestManager.addRequest(
85
86
  {
86
87
  policyInfo: {
@@ -89,6 +90,7 @@ describe('MediaRequestManager', () => {
89
90
  crossPriorityDuplication: CROSS_PRIORITY_DUPLICATION,
90
91
  crossPolicyDuplication: CROSS_POLICY_DUPLICATION,
91
92
  preferLiveVideo,
93
+ namedMediaGroups,
92
94
  },
93
95
  receiveSlots,
94
96
  codecInfo: {
@@ -590,7 +592,14 @@ describe('MediaRequestManager', () => {
590
592
  MAX_FS_720p,
591
593
  false
592
594
  );
593
-
595
+ addActiveSpeakerRequest(
596
+ 254,
597
+ [fakeReceiveSlots[8], fakeReceiveSlots[9], fakeReceiveSlots[10]],
598
+ MAX_FS_720p,
599
+ false,
600
+ true,
601
+ [{type: 1, value: 20}],
602
+ );
594
603
  // nothing should be sent out as we didn't commit the requests
595
604
  assert.notCalled(sendMediaRequestsCallback);
596
605
 
@@ -631,6 +640,15 @@ describe('MediaRequestManager', () => {
631
640
  maxFs: MAX_FS_720p,
632
641
  maxMbps: MAX_MBPS_720p,
633
642
  },
643
+ {
644
+ policy: 'active-speaker',
645
+ priority: 254,
646
+ receiveSlots: [fakeWcmeSlots[8], fakeWcmeSlots[9], fakeWcmeSlots[10]],
647
+ maxPayloadBitsPerSecond: MAX_PAYLOADBITSPS_720p,
648
+ maxFs: MAX_FS_720p,
649
+ maxMbps: MAX_MBPS_720p,
650
+ namedMediaGroups: [{type: 1, value: 20}],
651
+ },
634
652
  ]);
635
653
  });
636
654
 
@@ -6,6 +6,7 @@ import {RemoteMedia} from '@webex/plugin-meetings/src/multistream/remoteMedia';
6
6
  import {ReceiveSlot} from '@webex/plugin-meetings/src/multistream/receiveSlot';
7
7
  import sinon from 'sinon';
8
8
  import {assert} from '@webex/test-helper-chai';
9
+ import { NamedMediaGroup } from "@webex/json-multistream";
9
10
 
10
11
  class FakeSlot extends EventEmitter {
11
12
  public mediaType: MediaType;
@@ -24,6 +25,7 @@ describe('RemoteMediaGroup', () => {
24
25
 
25
26
  let fakeMediaRequestManager;
26
27
  let fakeReceiveSlots;
28
+ let fakeNamedMediaSlots;
27
29
 
28
30
  let activeSpeakerRequestCounter;
29
31
  let receiverSelectedRequestCounter;
@@ -50,6 +52,10 @@ describe('RemoteMediaGroup', () => {
50
52
  fakeReceiveSlots = Array(NUM_SLOTS)
51
53
  .fill(null)
52
54
  .map((_, index) => new FakeSlot(MediaType.VideoMain, `fake receive slot ${index}`));
55
+
56
+ fakeNamedMediaSlots = Array(1)
57
+ .fill(null)
58
+ .map((_, index) => new FakeSlot(MediaType.AudioMain, `fake named media receive slot ${index}`));
53
59
  });
54
60
 
55
61
  const getLastActiveSpeakerRequestId = () =>
@@ -144,6 +150,79 @@ describe('RemoteMediaGroup', () => {
144
150
 
145
151
  });
146
152
 
153
+ describe('setNamedMediaGroup', () => {
154
+ it('updates named media group', () => {
155
+
156
+ const nameGroup1 = { type: 1, value: 20 };
157
+ const nameGroup2 = { type: 1, value: 24 };
158
+ const group = new RemoteMediaGroup(fakeMediaRequestManager, fakeNamedMediaSlots, 255, true, {
159
+ namedMediaGroup: nameGroup1,
160
+ });
161
+ fakeMediaRequestManager.addRequest.resetHistory();
162
+ group.setNamedMediaGroup(nameGroup2, false);
163
+
164
+ assert.calledOnce(fakeMediaRequestManager.cancelRequest);
165
+
166
+ assert.calledOnce(fakeMediaRequestManager.addRequest);
167
+
168
+ assert.calledWith(
169
+ fakeMediaRequestManager.addRequest,
170
+ sinon.match({
171
+ policyInfo: sinon.match({
172
+ policy: 'active-speaker',
173
+ priority: 255,
174
+ namedMediaGroups: sinon.match([{type: 1, value: 24}]),
175
+ }),
176
+ receiveSlots: fakeNamedMediaSlots,
177
+ codecInfo: undefined,
178
+ }),
179
+ false,
180
+ );
181
+ });
182
+
183
+ it('does not call add request when named media group has not changed', () => {
184
+ const group = new RemoteMediaGroup(fakeMediaRequestManager, fakeNamedMediaSlots, 255, true, {
185
+ namedMediaGroup: { type: 1, value: 20 },
186
+ });
187
+ fakeMediaRequestManager.addRequest.resetHistory();
188
+ group.setNamedMediaGroup({ type: 1, value: 20 }, false);
189
+
190
+ assert.notCalled(fakeMediaRequestManager.cancelRequest);
191
+
192
+ assert.notCalled(fakeMediaRequestManager.addRequest);
193
+ });
194
+
195
+ it('remove named media group', () => {
196
+
197
+ const nameGroup1 = { type: 1, value: 20 };
198
+ const nameGroup2 = { type: 1, value: 0 };
199
+ const group = new RemoteMediaGroup(fakeMediaRequestManager, fakeNamedMediaSlots, 255, true, {
200
+ namedMediaGroup: nameGroup1,
201
+ });
202
+ fakeMediaRequestManager.addRequest.resetHistory();
203
+ group.setNamedMediaGroup(nameGroup2, true);
204
+
205
+ assert.calledOnce(fakeMediaRequestManager.cancelRequest);
206
+
207
+ assert.calledOnce(fakeMediaRequestManager.addRequest);
208
+
209
+ assert.calledWith(
210
+ fakeMediaRequestManager.addRequest,
211
+ sinon.match({
212
+ policyInfo: sinon.match({
213
+ policy: 'active-speaker',
214
+ priority: 255,
215
+ nameMediaGroups: undefined,
216
+ }),
217
+ receiveSlots: fakeNamedMediaSlots,
218
+ codecInfo: undefined,
219
+ }),
220
+ true,
221
+ );
222
+ });
223
+
224
+ });
225
+
147
226
  describe('setActiveSpeakerCsis', () => {
148
227
  it('checks when there is a csi and remote media is not in pinned array', () => {
149
228
  const PINNED_INDEX = 2;
@@ -251,7 +330,7 @@ describe('RemoteMediaGroup', () => {
251
330
  assert.strictEqual(group.getRemoteMedia('pinned').length, 1);
252
331
 
253
332
  assert.strictEqual(group.isPinned(remoteMedia), true);
254
-
333
+
255
334
  assert.calledTwice(fakeMediaRequestManager.cancelRequest);
256
335
  assert.calledWith(fakeMediaRequestManager.cancelRequest, 'fake receiver selected request 1');
257
336
 
@@ -18,6 +18,7 @@ import testUtils from '../../../utils/testUtils';
18
18
  import LoggerProxy from '@webex/plugin-meetings/src/common/logs/logger-proxy';
19
19
  import LoggerConfig from '@webex/plugin-meetings/src/common/logs/logger-config';
20
20
  import { expect } from 'chai';
21
+ import { NamedMediaGroup } from "@webex/json-multistream";
21
22
 
22
23
  class FakeSlot extends EventEmitter {
23
24
  public mediaType: MediaType;
@@ -299,6 +300,204 @@ describe('RemoteMediaManager', () => {
299
300
  );
300
301
  });
301
302
 
303
+ it('creates a RemoteMediaGroup for named media group audio correctly', async () => {
304
+ let createdInterpretationAudioGroup: RemoteMediaGroup | null = null;
305
+ // create a config with just audio, no video at all and no screen share
306
+ const config: Configuration = {
307
+ audio: {
308
+ numOfActiveSpeakerStreams: 3,
309
+ numOfScreenShareStreams: 0,
310
+ },
311
+ video: {
312
+ preferLiveVideo: false,
313
+ initialLayoutId: 'empty',
314
+ layouts: {
315
+ empty: {},
316
+ },
317
+ },
318
+ namedMediaGroup: {type: 1, value: 20},
319
+ };
320
+
321
+ remoteMediaManager = new RemoteMediaManager(
322
+ fakeReceiveSlotManager,
323
+ fakeMediaRequestManagers,
324
+ config
325
+ );
326
+
327
+ remoteMediaManager.on(Event.InterpretationAudioCreated, (audio: RemoteMediaGroup) => {
328
+ createdInterpretationAudioGroup = audio;
329
+ });
330
+
331
+ remoteMediaManager.start();
332
+
333
+ await testUtils.flushPromises();
334
+
335
+ assert.callCount(fakeReceiveSlotManager.allocateSlot, 4);
336
+ assert.alwaysCalledWith(fakeReceiveSlotManager.allocateSlot, MediaType.AudioMain);
337
+
338
+ assert.isNotNull(createdInterpretationAudioGroup);
339
+ if (createdInterpretationAudioGroup) {
340
+ assert.strictEqual(createdInterpretationAudioGroup.getRemoteMedia().length, 1);
341
+ assert.isTrue(
342
+ createdInterpretationAudioGroup
343
+ .getRemoteMedia()
344
+ .every((remoteMedia) => remoteMedia.mediaType === MediaType.AudioMain)
345
+ );
346
+ assert.strictEqual(createdInterpretationAudioGroup.getRemoteMedia('pinned').length, 0);
347
+ assert.calledTwice(fakeMediaRequestManagers.audio.addRequest);
348
+ assert.calledWith(
349
+ fakeMediaRequestManagers.audio.addRequest,
350
+ sinon.match({
351
+ policyInfo: sinon.match({
352
+ policy: 'active-speaker',
353
+ priority: 255,
354
+ namedMediaGroups: sinon.match([{type: 1, value: 20}]),
355
+ }),
356
+ receiveSlots: Array(1).fill(fakeAudioSlot),
357
+ codecInfo: undefined,
358
+ }),
359
+ false,
360
+ );
361
+ }
362
+ });
363
+
364
+ it('creates new media request when call setReceiveNamedMediaGroup', async () => {
365
+ let createdInterpretationAudioGroup: RemoteMediaGroup | null = null;
366
+ // create a config with just audio, no video at all and no screen share
367
+ const config: Configuration = {
368
+ audio: {
369
+ numOfActiveSpeakerStreams: 3,
370
+ numOfScreenShareStreams: 0,
371
+ },
372
+ video: {
373
+ preferLiveVideo: false,
374
+ initialLayoutId: 'empty',
375
+ layouts: {
376
+ empty: {},
377
+ },
378
+ },
379
+ namedMediaGroup: {type: 1, value: 24},
380
+ };
381
+
382
+ remoteMediaManager = new RemoteMediaManager(
383
+ fakeReceiveSlotManager,
384
+ fakeMediaRequestManagers,
385
+ config
386
+ );
387
+
388
+ remoteMediaManager.on(Event.InterpretationAudioCreated, (audio: RemoteMediaGroup) => {
389
+ createdInterpretationAudioGroup = audio;
390
+ createdInterpretationAudioGroup.setNamedMediaGroup = sinon.stub();
391
+ });
392
+
393
+ await remoteMediaManager.start();
394
+
395
+ // requires 3 main audio slots and one interpretation audio slot
396
+ assert.callCount(fakeReceiveSlotManager.allocateSlot, 4);
397
+
398
+
399
+ resetHistory();
400
+
401
+
402
+ remoteMediaManager.setReceiveNamedMediaGroup(MediaType.AudioMain, 28);
403
+
404
+ // check that setNamedMediaGroup has been called
405
+ assert.calledOnce(createdInterpretationAudioGroup.setNamedMediaGroup);
406
+ assert.calledWith(
407
+ createdInterpretationAudioGroup.setNamedMediaGroup,
408
+ {type: 1, value: 28},
409
+ true,
410
+ );
411
+
412
+ });
413
+
414
+ it('ignore duplicated group when call setReceiveNamedMediaGroup', async () => {
415
+ let createdAudioGroup: RemoteMediaGroup | null = null;
416
+ let audioStopStub;
417
+ // create a config with just audio, no video at all and no screen share
418
+ const config: Configuration = {
419
+ audio: {
420
+ numOfActiveSpeakerStreams: 3,
421
+ numOfScreenShareStreams: 0,
422
+ },
423
+ video: {
424
+ preferLiveVideo: false,
425
+ initialLayoutId: 'empty',
426
+ layouts: {
427
+ empty: {},
428
+ },
429
+ },
430
+ namedMediaGroup: {type: 1, value: 24},
431
+ };
432
+
433
+ remoteMediaManager = new RemoteMediaManager(
434
+ fakeReceiveSlotManager,
435
+ fakeMediaRequestManagers,
436
+ config
437
+ );
438
+
439
+ remoteMediaManager.on(Event.AudioCreated, (audio: RemoteMediaGroup) => {
440
+ audioStopStub = sinon.stub(audio, 'stop');
441
+ });
442
+
443
+ await remoteMediaManager.start();
444
+
445
+ // we're using the default config that requires 3 main audio slots
446
+ assert.callCount(fakeReceiveSlotManager.allocateSlot, 4);
447
+
448
+
449
+ resetHistory();
450
+
451
+ remoteMediaManager.setReceiveNamedMediaGroup(MediaType.AudioMain, 24);
452
+
453
+ assert.notCalled(audioStopStub);
454
+ assert.callCount(fakeReceiveSlotManager.releaseSlot, 0);
455
+
456
+ await testUtils.flushPromises();
457
+ assert.callCount(fakeReceiveSlotManager.allocateSlot, 0);
458
+ assert.notCalled(fakeReceiveSlotManager.allocateSlot);
459
+
460
+ });
461
+
462
+
463
+ it('should throw error if set receive named media group which type is not audio', async () => {
464
+ let createdAudioGroup: RemoteMediaGroup | null = null;
465
+ let audioStopStub;
466
+ // create a config with just audio, no video at all and no screen share
467
+ const config: Configuration = {
468
+ audio: {
469
+ numOfActiveSpeakerStreams: 3,
470
+ numOfScreenShareStreams: 0,
471
+ },
472
+ video: {
473
+ preferLiveVideo: false,
474
+ initialLayoutId: 'empty',
475
+ layouts: {
476
+ empty: {},
477
+ },
478
+ },
479
+ namedMediaGroup: {type: 1, value: 24},
480
+ };
481
+
482
+ remoteMediaManager = new RemoteMediaManager(
483
+ fakeReceiveSlotManager,
484
+ fakeMediaRequestManagers,
485
+ config
486
+ );
487
+
488
+ // Assuming setReceiveNamedMediaGroup returns a promise
489
+ it('should throw error when media type is not audio-main', async () => {
490
+ try {
491
+ await remoteMediaManager.setReceiveNamedMediaGroup(MediaType.VideoMain, 0);
492
+ // If the promise resolves successfully, we should fail the test
493
+ throw new Error('Expected an error but none was thrown');
494
+ } catch (error) {
495
+ // Check if the error message matches the expected one
496
+ expect(error.message).to.equal('cannot set receive named media group which media type is not audio-main');
497
+ }
498
+ });
499
+ });
500
+
302
501
  it('pre-allocates receive slots based on the biggest layout', async () => {
303
502
  const config = cloneDeep(DefaultTestConfiguration);
304
503
 
@@ -693,7 +892,7 @@ describe('RemoteMediaManager', () => {
693
892
  });
694
893
 
695
894
  expect(config.video.preferLiveVideo).to.equal(true);
696
-
895
+
697
896
  assert.calledOnce(fakeMediaRequestManagers.video.commit);
698
897
  });
699
898
  });
@@ -10,11 +10,11 @@ describe('SendSlotsManager', () => {
10
10
  info: sinon.stub(),
11
11
  },
12
12
  };
13
-
13
+
14
14
  beforeEach(() => {
15
15
  sendSlotsManager = new SendSlotManager(LoggerProxy);
16
16
  });
17
-
17
+
18
18
  describe('createSlot', () => {
19
19
  let mediaConnection;
20
20
  const mediaType = MediaType.AudioMain;
@@ -27,19 +27,19 @@ describe('SendSlotsManager', () => {
27
27
 
28
28
  it('should create a slot for the given mediaType', () => {
29
29
  sendSlotsManager.createSlot(mediaConnection, mediaType);
30
-
30
+
31
31
  expect(mediaConnection.createSendSlot.calledWith(mediaType, true));
32
32
  });
33
33
 
34
34
  it('should create a slot for the given mediaType & active state', () => {
35
35
  sendSlotsManager.createSlot(mediaConnection, mediaType, false);
36
-
36
+
37
37
  expect(mediaConnection.createSendSlot.calledWith(mediaType, false));
38
38
  });
39
-
39
+
40
40
  it('should throw an error if a slot for the given mediaType already exists', () => {
41
41
  sendSlotsManager.createSlot(mediaConnection, mediaType);
42
-
42
+
43
43
  expect(() => sendSlotsManager.createSlot(mediaConnection, mediaType)).to.throw(`Slot for ${mediaType} already exists`);
44
44
  });
45
45
  });
@@ -56,7 +56,7 @@ describe('SendSlotsManager', () => {
56
56
 
57
57
  it('should return the slot for the given mediaType', () => {
58
58
  const slot = sendSlotsManager.createSlot(mediaConnection,mediaType);
59
-
59
+
60
60
  expect(sendSlotsManager.getSlot(mediaType)).to.equal(slot);
61
61
  });
62
62
 
@@ -64,7 +64,7 @@ describe('SendSlotsManager', () => {
64
64
  expect(() => sendSlotsManager.getSlot(mediaType)).to.throw(`Slot for ${mediaType} does not exist`);
65
65
  });
66
66
  });
67
-
67
+
68
68
  describe('publishStream', () => {
69
69
  let mediaConnection;
70
70
  const mediaType = MediaType.AudioMain;
@@ -82,9 +82,9 @@ describe('SendSlotsManager', () => {
82
82
  };
83
83
  mediaConnection.createSendSlot.returns(slot);
84
84
  sendSlotsManager.createSlot(mediaConnection, mediaType);
85
-
85
+
86
86
  await sendSlotsManager.publishStream(mediaType, stream);
87
-
87
+
88
88
  expect(slot.publishStream.calledWith(stream));
89
89
  });
90
90
 
@@ -112,9 +112,9 @@ describe('SendSlotsManager', () => {
112
112
  };
113
113
  mediaConnection.createSendSlot.returns(slot);
114
114
  sendSlotsManager.createSlot(mediaConnection, mediaType);
115
-
115
+
116
116
  await sendSlotsManager.unpublishStream(mediaType);
117
-
117
+
118
118
  expect(slot.unpublishStream.called);
119
119
  });
120
120
 
@@ -126,6 +126,38 @@ describe('SendSlotsManager', () => {
126
126
  });
127
127
  });
128
128
 
129
+ describe('setNamedMediaGroups', () => {
130
+ let mediaConnection;
131
+ const mediaType = MediaType.AudioMain;
132
+ const groups = [{type: 1, value: 20}];
133
+
134
+ beforeEach(() => {
135
+ mediaConnection = {
136
+ createSendSlot: sinon.stub(),
137
+ } as MultistreamRoapMediaConnection;
138
+ });
139
+
140
+ it('should publish the given stream to the sendSlot for the given mediaType', async () => {
141
+ const slot = {
142
+ setNamedMediaGroups: sinon.stub().resolves(),
143
+ };
144
+ mediaConnection.createSendSlot.returns(slot);
145
+ sendSlotsManager.createSlot(mediaConnection, mediaType);
146
+
147
+ await sendSlotsManager.setNamedMediaGroups(mediaType, groups);
148
+
149
+ expect(slot.setNamedMediaGroups.calledWith(groups));
150
+ });
151
+
152
+ it('should throw an error if the given mediaType is not audio', () => {
153
+ expect(() => sendSlotsManager.setNamedMediaGroups(MediaType.VideoMain, groups)).to.throw(`sendSlotManager cannot set named media group which media type is ${MediaType.VideoMain}`)
154
+ });
155
+
156
+ it('should throw an error if a slot for the given mediaType does not exist', () => {
157
+ expect(() => sendSlotsManager.setNamedMediaGroups(mediaType, groups)).to.throw(`Slot for ${mediaType} does not exist`)
158
+ });
159
+ });
160
+
129
161
  describe('setActive', () => {
130
162
  let mediaConnection;
131
163
  const mediaType = MediaType.AudioMain;
@@ -142,9 +174,9 @@ describe('SendSlotsManager', () => {
142
174
  };
143
175
  mediaConnection.createSendSlot.returns(slot);
144
176
  sendSlotsManager.createSlot(mediaConnection, mediaType);
145
-
177
+
146
178
  await sendSlotsManager.setActive(mediaType,true);
147
-
179
+
148
180
  expect(slot.setActive.called);
149
181
  });
150
182
 
@@ -170,9 +202,9 @@ describe('SendSlotsManager', () => {
170
202
  };
171
203
  mediaConnection.createSendSlot.returns(slot);
172
204
  sendSlotsManager.createSlot(mediaConnection, mediaType);
173
-
205
+
174
206
  await sendSlotsManager.setCodecParameters(mediaType, codecParameters);
175
-
207
+
176
208
  expect(slot.setCodecParameters.calledWith(codecParameters));
177
209
  });
178
210
 
@@ -200,9 +232,9 @@ describe('SendSlotsManager', () => {
200
232
  };
201
233
  mediaConnection.createSendSlot.returns(slot);
202
234
  sendSlotsManager.createSlot(mediaConnection, mediaType);
203
-
235
+
204
236
  await sendSlotsManager.deleteCodecParameters(mediaType,[]);
205
-
237
+
206
238
  expect(slot.deleteCodecParameters.called);
207
239
  });
208
240