@webex/plugin-meetings 3.0.0-beta.1 → 3.0.0-beta.2
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/dist/common/errors/webex-errors.js +5 -29
- package/dist/common/errors/webex-errors.js.map +1 -1
- package/dist/constants.js +15 -74
- package/dist/constants.js.map +1 -1
- package/dist/media/index.js +68 -213
- package/dist/media/index.js.map +1 -1
- package/dist/media/internal-media-core-wrapper.js +22 -0
- package/dist/media/internal-media-core-wrapper.js.map +1 -0
- package/dist/media/properties.js +20 -25
- package/dist/media/properties.js.map +1 -1
- package/dist/media/util.js +0 -27
- package/dist/media/util.js.map +1 -1
- package/dist/meeting/index.js +694 -432
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/request.js +1 -0
- package/dist/meeting/request.js.map +1 -1
- package/dist/meeting/util.js +3 -44
- package/dist/meeting/util.js.map +1 -1
- package/dist/meetings/index.js +64 -5
- package/dist/meetings/index.js.map +1 -1
- package/dist/meetings/util.js +24 -1
- package/dist/meetings/util.js.map +1 -1
- package/dist/members/index.js +68 -0
- package/dist/members/index.js.map +1 -1
- package/dist/multistream/mediaRequestManager.js +132 -0
- package/dist/multistream/mediaRequestManager.js.map +1 -0
- package/dist/multistream/multistreamMedia.js +116 -0
- package/dist/multistream/multistreamMedia.js.map +1 -0
- package/dist/multistream/receiveSlot.js +209 -0
- package/dist/multistream/receiveSlot.js.map +1 -0
- package/dist/multistream/receiveSlotManager.js +195 -0
- package/dist/multistream/receiveSlotManager.js.map +1 -0
- package/dist/multistream/remoteMedia.js +284 -0
- package/dist/multistream/remoteMedia.js.map +1 -0
- package/dist/multistream/remoteMediaGroup.js +243 -0
- package/dist/multistream/remoteMediaGroup.js.map +1 -0
- package/dist/multistream/remoteMediaManager.js +1113 -0
- package/dist/multistream/remoteMediaManager.js.map +1 -0
- package/dist/reconnection-manager/index.js +109 -130
- package/dist/reconnection-manager/index.js.map +1 -1
- package/dist/roap/index.js +57 -240
- package/dist/roap/index.js.map +1 -1
- package/dist/roap/request.js +2 -114
- package/dist/roap/request.js.map +1 -1
- package/dist/roap/turnDiscovery.js +11 -5
- package/dist/roap/turnDiscovery.js.map +1 -1
- package/dist/statsAnalyzer/global.js +2 -0
- package/dist/statsAnalyzer/global.js.map +1 -1
- package/dist/statsAnalyzer/index.js +39 -36
- package/dist/statsAnalyzer/index.js.map +1 -1
- package/package.json +20 -19
- package/src/common/errors/webex-errors.js +0 -18
- package/src/constants.ts +139 -180
- package/src/media/index.js +60 -194
- package/src/media/internal-media-core-wrapper.ts +9 -0
- package/src/media/properties.js +19 -25
- package/src/media/util.js +0 -22
- package/src/meeting/index.js +565 -320
- package/src/meeting/request.js +1 -0
- package/src/meeting/util.js +3 -46
- package/src/meetings/index.js +30 -1
- package/src/meetings/util.js +23 -2
- package/src/members/index.js +48 -0
- package/src/multistream/mediaRequestManager.ts +164 -0
- package/src/multistream/multistreamMedia.ts +92 -0
- package/src/multistream/receiveSlot.ts +141 -0
- package/src/multistream/receiveSlotManager.ts +142 -0
- package/src/multistream/remoteMedia.ts +219 -0
- package/src/multistream/remoteMediaGroup.ts +224 -0
- package/src/multistream/remoteMediaManager.ts +911 -0
- package/src/reconnection-manager/index.js +40 -53
- package/src/roap/index.js +47 -207
- package/src/roap/request.js +1 -72
- package/src/roap/turnDiscovery.ts +12 -6
- package/src/statsAnalyzer/global.js +2 -0
- package/src/statsAnalyzer/index.js +32 -46
- package/test/integration/spec/journey.js +1 -1
- package/test/unit/spec/media/index.ts +223 -0
- package/test/unit/spec/media/properties.ts +73 -82
- package/test/unit/spec/meeting/effectsState.js +1 -3
- package/test/unit/spec/meeting/index.js +420 -228
- package/test/unit/spec/meeting/muteState.js +7 -0
- package/test/unit/spec/meeting/utils.js +61 -2
- package/test/unit/spec/meetings/index.js +0 -4
- package/test/unit/spec/members/index.js +164 -2
- package/test/unit/spec/multistream/mediaRequestManager.ts +511 -0
- package/test/unit/spec/multistream/receiveSlot.ts +104 -0
- package/test/unit/spec/multistream/receiveSlotManager.ts +173 -0
- package/test/unit/spec/multistream/remoteMedia.ts +217 -0
- package/test/unit/spec/multistream/remoteMediaGroup.ts +396 -0
- package/test/unit/spec/multistream/remoteMediaManager.ts +1251 -0
- package/test/unit/spec/roap/index.ts +63 -35
- package/test/unit/spec/stats-analyzer/index.js +19 -22
- package/dist/peer-connection-manager/index.js +0 -794
- package/dist/peer-connection-manager/index.js.map +0 -1
- package/dist/roap/collection.js +0 -73
- package/dist/roap/collection.js.map +0 -1
- package/dist/roap/handler.js +0 -337
- package/dist/roap/handler.js.map +0 -1
- package/dist/roap/state.js +0 -164
- package/dist/roap/state.js.map +0 -1
- package/dist/roap/util.js +0 -102
- package/dist/roap/util.js.map +0 -1
- package/src/peer-connection-manager/index.js +0 -723
- package/src/roap/collection.js +0 -63
- package/src/roap/handler.js +0 -252
- package/src/roap/state.js +0 -149
- package/src/roap/util.js +0 -93
- package/test/unit/spec/peerconnection-manager/index.js +0 -188
- package/test/unit/spec/peerconnection-manager/utils.js +0 -48
- package/test/unit/spec/roap/util.js +0 -30
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import {assert} from '@webex/test-helper-chai';
|
|
3
|
+
import {MediaConnection as MC} from '@webex/internal-media-core';
|
|
4
|
+
import {ReceiveSlotManager} from '@webex/plugin-meetings/src/multistream/receiveSlotManager';
|
|
5
|
+
import * as ReceiveSlotModule from '@webex/plugin-meetings/src/multistream/receiveSlot';
|
|
6
|
+
|
|
7
|
+
describe('ReceiveSlotManager', () => {
|
|
8
|
+
let fakeMeeting;
|
|
9
|
+
let fakeWcmeSlot;
|
|
10
|
+
let fakeReceiveSlots;
|
|
11
|
+
let mockReceiveSlotCtor;
|
|
12
|
+
let receiveSlotManager;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
fakeWcmeSlot = {
|
|
16
|
+
id: 'fake wcme slot',
|
|
17
|
+
};
|
|
18
|
+
fakeMeeting = {
|
|
19
|
+
mediaProperties: {
|
|
20
|
+
webrtcMediaConnection: {
|
|
21
|
+
createReceiveSlot: sinon.stub().resolves(fakeWcmeSlot),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
members: {
|
|
25
|
+
findMemberByCsi: sinon.stub(),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
fakeReceiveSlots = [];
|
|
29
|
+
mockReceiveSlotCtor = sinon.stub(ReceiveSlotModule, 'ReceiveSlot').callsFake((mediaType) => {
|
|
30
|
+
const fakeReceiveSlot = {
|
|
31
|
+
id: `fake sdk receive slot ${fakeReceiveSlots.length + 1}`,
|
|
32
|
+
mediaType,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
fakeReceiveSlots.push(fakeReceiveSlot);
|
|
36
|
+
|
|
37
|
+
return fakeReceiveSlot;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
receiveSlotManager = new ReceiveSlotManager(fakeMeeting);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
sinon.restore();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('rejects if there is no media connection', async () => {
|
|
48
|
+
fakeMeeting.mediaProperties.webrtcMediaConnection = null;
|
|
49
|
+
|
|
50
|
+
assert.isRejected(
|
|
51
|
+
receiveSlotManager.allocateSlot(MC.MediaType.VideoMain),
|
|
52
|
+
'Webrtc media connection is missing'
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('allocates a slot when allocateSlot() is called and there are no free slots', async () => {
|
|
57
|
+
assert.deepEqual(receiveSlotManager.getStats(), {numAllocatedSlots: {}, numFreeSlots: {}});
|
|
58
|
+
|
|
59
|
+
const slot = await receiveSlotManager.allocateSlot(MC.MediaType.VideoMain);
|
|
60
|
+
|
|
61
|
+
assert.calledOnce(fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot);
|
|
62
|
+
assert.calledWith(
|
|
63
|
+
fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot,
|
|
64
|
+
MC.MediaType.VideoMain
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
assert.calledOnce(mockReceiveSlotCtor);
|
|
68
|
+
assert.calledWith(mockReceiveSlotCtor, MC.MediaType.VideoMain, fakeWcmeSlot, sinon.match.func);
|
|
69
|
+
assert.strictEqual(slot, fakeReceiveSlots[0]);
|
|
70
|
+
|
|
71
|
+
assert.deepEqual(receiveSlotManager.getStats(), {
|
|
72
|
+
numAllocatedSlots: {'VIDEO-MAIN': 1},
|
|
73
|
+
numFreeSlots: {},
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('reuses previously freed slot when allocateSlot() is called and a free slot is available', async () => {
|
|
78
|
+
const slot1 = await receiveSlotManager.allocateSlot(MC.MediaType.VideoMain);
|
|
79
|
+
|
|
80
|
+
assert.calledOnce(fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot);
|
|
81
|
+
assert.calledOnce(mockReceiveSlotCtor);
|
|
82
|
+
assert.strictEqual(slot1, fakeReceiveSlots[0]);
|
|
83
|
+
|
|
84
|
+
// release the allocated slot
|
|
85
|
+
receiveSlotManager.releaseSlot(slot1);
|
|
86
|
+
|
|
87
|
+
assert.deepEqual(receiveSlotManager.getStats(), {
|
|
88
|
+
numAllocatedSlots: {},
|
|
89
|
+
numFreeSlots: {'VIDEO-MAIN': 1},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot.resetHistory();
|
|
93
|
+
mockReceiveSlotCtor.resetHistory();
|
|
94
|
+
|
|
95
|
+
// allocate another slot, this time the previous one should be returned instead of allocating any new ones
|
|
96
|
+
const slot2 = await receiveSlotManager.allocateSlot(MC.MediaType.VideoMain);
|
|
97
|
+
|
|
98
|
+
assert.notCalled(fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot);
|
|
99
|
+
assert.notCalled(mockReceiveSlotCtor);
|
|
100
|
+
|
|
101
|
+
// verify that in fact we got the same slot again
|
|
102
|
+
assert.strictEqual(slot1, slot2);
|
|
103
|
+
|
|
104
|
+
assert.deepEqual(receiveSlotManager.getStats(), {
|
|
105
|
+
numAllocatedSlots: {'VIDEO-MAIN': 1},
|
|
106
|
+
numFreeSlots: {},
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('does not reuse any slots after reset() is called', async () => {
|
|
111
|
+
const slot1 = await receiveSlotManager.allocateSlot(MC.MediaType.VideoMain);
|
|
112
|
+
|
|
113
|
+
assert.calledOnce(fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot);
|
|
114
|
+
assert.calledOnce(mockReceiveSlotCtor);
|
|
115
|
+
assert.strictEqual(slot1, fakeReceiveSlots[0]);
|
|
116
|
+
|
|
117
|
+
// release the slot so we have 1 free slot, but also call reset() which should clear everything
|
|
118
|
+
receiveSlotManager.releaseSlot(slot1);
|
|
119
|
+
receiveSlotManager.reset();
|
|
120
|
+
|
|
121
|
+
// reset the mocks and set the ReceiveSlot constructor to return a different slot
|
|
122
|
+
fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot.resetHistory();
|
|
123
|
+
mockReceiveSlotCtor.resetHistory();
|
|
124
|
+
|
|
125
|
+
assert.deepEqual(receiveSlotManager.getStats(), {numAllocatedSlots: {}, numFreeSlots: {}});
|
|
126
|
+
|
|
127
|
+
// allocate another slot, because we called reset(), the old free slot should not be reused
|
|
128
|
+
const slot2 = await receiveSlotManager.allocateSlot(MC.MediaType.VideoMain);
|
|
129
|
+
|
|
130
|
+
assert.calledOnce(fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot);
|
|
131
|
+
assert.calledOnce(mockReceiveSlotCtor);
|
|
132
|
+
|
|
133
|
+
// verify that in fact we got a brand new slot
|
|
134
|
+
assert.strictEqual(slot2, fakeReceiveSlots[1]);
|
|
135
|
+
|
|
136
|
+
assert.deepEqual(receiveSlotManager.getStats(), {
|
|
137
|
+
numAllocatedSlots: {'VIDEO-MAIN': 1},
|
|
138
|
+
numFreeSlots: {},
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('does not reuse slots if they have different media type', async () => {
|
|
143
|
+
const slot1 = await receiveSlotManager.allocateSlot(MC.MediaType.VideoMain);
|
|
144
|
+
|
|
145
|
+
assert.calledOnce(fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot);
|
|
146
|
+
assert.calledOnce(mockReceiveSlotCtor);
|
|
147
|
+
|
|
148
|
+
receiveSlotManager.releaseSlot(slot1);
|
|
149
|
+
|
|
150
|
+
fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot.resetHistory();
|
|
151
|
+
mockReceiveSlotCtor.resetHistory();
|
|
152
|
+
|
|
153
|
+
// allocate another slot, this time for main audio, so it should be a completely new slot
|
|
154
|
+
const slot2 = await receiveSlotManager.allocateSlot(MC.MediaType.AudioMain);
|
|
155
|
+
|
|
156
|
+
assert.calledOnce(fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot);
|
|
157
|
+
assert.calledWith(
|
|
158
|
+
fakeMeeting.mediaProperties.webrtcMediaConnection.createReceiveSlot,
|
|
159
|
+
MC.MediaType.AudioMain
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
assert.calledOnce(mockReceiveSlotCtor);
|
|
163
|
+
assert.calledWith(mockReceiveSlotCtor, MC.MediaType.AudioMain, fakeWcmeSlot, sinon.match.func);
|
|
164
|
+
|
|
165
|
+
// verify that in fact we got a brand new slot
|
|
166
|
+
assert.strictEqual(slot2, fakeReceiveSlots[1]);
|
|
167
|
+
|
|
168
|
+
assert.deepEqual(receiveSlotManager.getStats(), {
|
|
169
|
+
numAllocatedSlots: {'AUDIO-MAIN': 1},
|
|
170
|
+
numFreeSlots: {'VIDEO-MAIN': 1},
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/* eslint-disable require-jsdoc */
|
|
2
|
+
import EventEmitter from 'events';
|
|
3
|
+
|
|
4
|
+
import {MediaConnection as MC} from '@webex/internal-media-core';
|
|
5
|
+
import {RemoteMedia, RemoteMediaEvents} from '@webex/plugin-meetings/src/multistream/remoteMedia';
|
|
6
|
+
import {ReceiveSlotEvents} from '@webex/plugin-meetings/src/multistream/receiveSlot';
|
|
7
|
+
import sinon from 'sinon';
|
|
8
|
+
import {assert} from '@webex/test-helper-chai';
|
|
9
|
+
|
|
10
|
+
describe('RemoteMedia', () => {
|
|
11
|
+
let remoteMedia;
|
|
12
|
+
let fakeReceiveSlot;
|
|
13
|
+
let fakeStream;
|
|
14
|
+
let fakeMediaRequestManager;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fakeStream = {id: 'fake stream'};
|
|
18
|
+
fakeReceiveSlot = new EventEmitter();
|
|
19
|
+
fakeReceiveSlot.mediaType = MC.MediaType.AudioMain;
|
|
20
|
+
fakeReceiveSlot.memberId = '12345678';
|
|
21
|
+
fakeReceiveSlot.csi = 999;
|
|
22
|
+
fakeReceiveSlot.sourceState = 'avatar';
|
|
23
|
+
fakeReceiveSlot.stream = fakeStream;
|
|
24
|
+
|
|
25
|
+
fakeMediaRequestManager = {
|
|
26
|
+
addRequest: sinon.stub(),
|
|
27
|
+
cancelRequest: sinon.stub(),
|
|
28
|
+
};
|
|
29
|
+
remoteMedia = new RemoteMedia(fakeReceiveSlot, fakeMediaRequestManager, {resolution: 'medium'});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('forwards events from the underlying receive slot', () => {
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
receiveSlotEvent: ReceiveSlotEvents.SourceUpdate,
|
|
36
|
+
expectedEvent: RemoteMediaEvents.SourceUpdate,
|
|
37
|
+
title: 'SourceUpdate',
|
|
38
|
+
},
|
|
39
|
+
].forEach(({receiveSlotEvent, expectedEvent, title}) =>
|
|
40
|
+
it(`forwards ${title}`, () => {
|
|
41
|
+
let eventEmittedCount = 0;
|
|
42
|
+
let eventData;
|
|
43
|
+
const fakeData = {something: 'some value'};
|
|
44
|
+
|
|
45
|
+
remoteMedia.on(expectedEvent, (data) => {
|
|
46
|
+
eventEmittedCount += 1;
|
|
47
|
+
eventData = data;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
fakeReceiveSlot.emit(receiveSlotEvent, fakeData);
|
|
51
|
+
|
|
52
|
+
assert.strictEqual(eventEmittedCount, 1);
|
|
53
|
+
assert.strictEqual(eventData, fakeData);
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("exposes underlying receive slot's properties", () => {
|
|
59
|
+
assert.strictEqual(remoteMedia.mediaType, fakeReceiveSlot.mediaType);
|
|
60
|
+
assert.strictEqual(remoteMedia.memberId, fakeReceiveSlot.memberId);
|
|
61
|
+
assert.strictEqual(remoteMedia.csi, fakeReceiveSlot.csi);
|
|
62
|
+
assert.strictEqual(remoteMedia.sourceState, fakeReceiveSlot.sourceState);
|
|
63
|
+
assert.strictEqual(remoteMedia.stream, fakeReceiveSlot.stream);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('sendMediaRequest', () => {
|
|
67
|
+
it('sends correct media request', () => {
|
|
68
|
+
const csi = 987654321;
|
|
69
|
+
const csi2 = 12345;
|
|
70
|
+
|
|
71
|
+
remoteMedia.sendMediaRequest(csi, true);
|
|
72
|
+
|
|
73
|
+
assert.calledOnce(fakeMediaRequestManager.addRequest);
|
|
74
|
+
assert.calledWith(
|
|
75
|
+
fakeMediaRequestManager.addRequest,
|
|
76
|
+
sinon.match({
|
|
77
|
+
policyInfo: sinon.match({
|
|
78
|
+
policy: 'receiver-selected',
|
|
79
|
+
csi,
|
|
80
|
+
}),
|
|
81
|
+
receiveSlots: [fakeReceiveSlot],
|
|
82
|
+
codecInfo: sinon.match({
|
|
83
|
+
codec: 'h264',
|
|
84
|
+
maxFs: 3600,
|
|
85
|
+
}),
|
|
86
|
+
}),
|
|
87
|
+
true
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
fakeMediaRequestManager.addRequest.resetHistory();
|
|
91
|
+
|
|
92
|
+
// now call again, with different csi and commit=false
|
|
93
|
+
remoteMedia.sendMediaRequest(csi2, false);
|
|
94
|
+
|
|
95
|
+
assert.calledOnce(fakeMediaRequestManager.addRequest);
|
|
96
|
+
assert.calledWith(
|
|
97
|
+
fakeMediaRequestManager.addRequest,
|
|
98
|
+
sinon.match({
|
|
99
|
+
policyInfo: sinon.match({
|
|
100
|
+
policy: 'receiver-selected',
|
|
101
|
+
csi: csi2,
|
|
102
|
+
}),
|
|
103
|
+
receiveSlots: [fakeReceiveSlot],
|
|
104
|
+
codecInfo: sinon.match({
|
|
105
|
+
codec: 'h264',
|
|
106
|
+
maxFs: 3600,
|
|
107
|
+
}),
|
|
108
|
+
}),
|
|
109
|
+
false
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('cancels previous request', () => {
|
|
114
|
+
const fakeRequestId = 111;
|
|
115
|
+
|
|
116
|
+
fakeMediaRequestManager.addRequest.returns(fakeRequestId);
|
|
117
|
+
|
|
118
|
+
// send the 1st media request
|
|
119
|
+
remoteMedia.sendMediaRequest(1234, true);
|
|
120
|
+
|
|
121
|
+
fakeMediaRequestManager.addRequest.resetHistory();
|
|
122
|
+
|
|
123
|
+
// send a 2nd one (the 1st one should get cancelled)
|
|
124
|
+
remoteMedia.sendMediaRequest(5678, false);
|
|
125
|
+
|
|
126
|
+
assert.calledOnce(fakeMediaRequestManager.cancelRequest);
|
|
127
|
+
assert.calledWith(fakeMediaRequestManager.cancelRequest, fakeRequestId);
|
|
128
|
+
|
|
129
|
+
assert.calledOnce(fakeMediaRequestManager.addRequest);
|
|
130
|
+
assert.calledWith(
|
|
131
|
+
fakeMediaRequestManager.addRequest,
|
|
132
|
+
sinon.match({
|
|
133
|
+
policyInfo: sinon.match({
|
|
134
|
+
policy: 'receiver-selected',
|
|
135
|
+
csi: 5678,
|
|
136
|
+
}),
|
|
137
|
+
receiveSlots: [fakeReceiveSlot],
|
|
138
|
+
codecInfo: sinon.match({
|
|
139
|
+
codec: 'h264',
|
|
140
|
+
maxFs: 3600,
|
|
141
|
+
}),
|
|
142
|
+
}),
|
|
143
|
+
false
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('throws when called on a stopped RemoteMedia instance', () => {
|
|
148
|
+
remoteMedia.stop();
|
|
149
|
+
assert.throws(
|
|
150
|
+
() => remoteMedia.sendMediaRequest(1234, true),
|
|
151
|
+
'sendMediaRequest() called on an invalidated RemoteMedia instance'
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('cancelMediaRequest', () => {
|
|
157
|
+
it('cancels the media request', () => {
|
|
158
|
+
const fakeRequestId = 11;
|
|
159
|
+
|
|
160
|
+
fakeMediaRequestManager.addRequest.returns(fakeRequestId);
|
|
161
|
+
|
|
162
|
+
// send a media request
|
|
163
|
+
remoteMedia.sendMediaRequest(1234, true);
|
|
164
|
+
|
|
165
|
+
fakeMediaRequestManager.addRequest.resetHistory();
|
|
166
|
+
|
|
167
|
+
// cancel it
|
|
168
|
+
remoteMedia.cancelMediaRequest();
|
|
169
|
+
|
|
170
|
+
assert.calledOnce(fakeMediaRequestManager.cancelRequest);
|
|
171
|
+
assert.calledWith(fakeMediaRequestManager.cancelRequest, fakeRequestId);
|
|
172
|
+
|
|
173
|
+
assert.notCalled(fakeMediaRequestManager.addRequest);
|
|
174
|
+
});
|
|
175
|
+
it('does not do anything if there was no request sent', () => {
|
|
176
|
+
remoteMedia.cancelMediaRequest();
|
|
177
|
+
|
|
178
|
+
assert.notCalled(fakeMediaRequestManager.cancelRequest);
|
|
179
|
+
assert.notCalled(fakeMediaRequestManager.addRequest);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe('stop()', () => {
|
|
184
|
+
it('cancels media request, unsets the receive slot and removes all the listeners from it', () => {
|
|
185
|
+
const cancelMediaRequestSpy = sinon.spy(remoteMedia, 'cancelMediaRequest');
|
|
186
|
+
|
|
187
|
+
remoteMedia.stop(true);
|
|
188
|
+
|
|
189
|
+
assert.calledOnce(cancelMediaRequestSpy);
|
|
190
|
+
assert.calledWith(cancelMediaRequestSpy, true);
|
|
191
|
+
|
|
192
|
+
assert.strictEqual(remoteMedia.mediaType, undefined);
|
|
193
|
+
assert.strictEqual(remoteMedia.memberId, undefined);
|
|
194
|
+
assert.strictEqual(remoteMedia.csi, undefined);
|
|
195
|
+
assert.strictEqual(remoteMedia.sourceState, undefined);
|
|
196
|
+
assert.strictEqual(remoteMedia.stream, undefined);
|
|
197
|
+
|
|
198
|
+
// check that events emitted from receive slot don't get forwarded anymore
|
|
199
|
+
[
|
|
200
|
+
{
|
|
201
|
+
receiveSlotEvent: ReceiveSlotEvents.SourceUpdate,
|
|
202
|
+
remoteMediaEvent: RemoteMediaEvents.SourceUpdate,
|
|
203
|
+
},
|
|
204
|
+
].forEach(({receiveSlotEvent, remoteMediaEvent}) => {
|
|
205
|
+
let eventEmitted = false;
|
|
206
|
+
|
|
207
|
+
remoteMedia.on(remoteMediaEvent, () => {
|
|
208
|
+
eventEmitted = true;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
fakeReceiveSlot.emit(receiveSlotEvent);
|
|
212
|
+
|
|
213
|
+
assert.strictEqual(eventEmitted, false);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
});
|