|
|
@@ -27,12 +27,10 @@ export default class SignalingLayerImpl extends SignalingLayer {
|
|
27
|
27
|
super();
|
|
28
|
28
|
|
|
29
|
29
|
/**
|
|
30
|
|
- * A map that stores SSRCs of remote streams. And is used only locally
|
|
31
|
|
- * We store the mapping when jingle is received, and later is used
|
|
32
|
|
- * onaddstream webrtc event where we have only the ssrc
|
|
|
30
|
+ * A map that stores SSRCs of remote streams and the corresponding jid and source name.
|
|
33
|
31
|
* FIXME: This map got filled and never cleaned and can grow during long
|
|
34
|
32
|
* conference
|
|
35
|
|
- * @type {Map<number, string>} maps SSRC number to jid
|
|
|
33
|
+ * @type {Map<number, { endpointId: string, sourceName: string }>} maps SSRC number to jid and source name.
|
|
36
|
34
|
*/
|
|
37
|
35
|
this.ssrcOwners = new Map();
|
|
38
|
36
|
|
|
|
@@ -53,16 +51,6 @@ export default class SignalingLayerImpl extends SignalingLayer {
|
|
53
|
51
|
* @private
|
|
54
|
52
|
*/
|
|
55
|
53
|
this._remoteSourceState = { };
|
|
56
|
|
-
|
|
57
|
|
- /**
|
|
58
|
|
- * A map that stores the source name of a track identified by it's ssrc.
|
|
59
|
|
- * We store the mapping when jingle is received, and later is used
|
|
60
|
|
- * onaddstream webrtc event where we have only the ssrc
|
|
61
|
|
- * FIXME: This map got filled and never cleaned and can grow during long
|
|
62
|
|
- * conference
|
|
63
|
|
- * @type {Map<number, string>} maps SSRC number to source name
|
|
64
|
|
- */
|
|
65
|
|
- this._sourceNames = new Map();
|
|
66
|
54
|
}
|
|
67
|
55
|
|
|
68
|
56
|
/**
|
|
|
@@ -199,12 +187,6 @@ export default class SignalingLayerImpl extends SignalingLayer {
|
|
199
|
187
|
const endpointId = Strophe.getResourceFromJid(jid);
|
|
200
|
188
|
|
|
201
|
189
|
delete this._remoteSourceState[endpointId];
|
|
202
|
|
-
|
|
203
|
|
- for (const [ key, value ] of this.ssrcOwners.entries()) {
|
|
204
|
|
- if (value === endpointId) {
|
|
205
|
|
- delete this._sourceNames[key];
|
|
206
|
|
- }
|
|
207
|
|
- }
|
|
208
|
190
|
};
|
|
209
|
191
|
room.addEventListener(XMPPEvents.MUC_MEMBER_LEFT, this._memberLeftHandler);
|
|
210
|
192
|
}
|
|
|
@@ -301,14 +283,14 @@ export default class SignalingLayerImpl extends SignalingLayer {
|
|
301
|
283
|
* @inheritDoc
|
|
302
|
284
|
*/
|
|
303
|
285
|
getSSRCOwner(ssrc) {
|
|
304
|
|
- return this.ssrcOwners.get(ssrc);
|
|
|
286
|
+ return this.ssrcOwners.get(ssrc)?.endpointId;
|
|
305
|
287
|
}
|
|
306
|
288
|
|
|
307
|
289
|
/**
|
|
308
|
290
|
* @inheritDoc
|
|
309
|
291
|
*/
|
|
310
|
292
|
getTrackSourceName(ssrc) {
|
|
311
|
|
- return this._sourceNames.get(ssrc);
|
|
|
293
|
+ return this.ssrcOwners.get(ssrc)?.sourceName;
|
|
312
|
294
|
}
|
|
313
|
295
|
|
|
314
|
296
|
/**
|
|
|
@@ -353,7 +335,7 @@ export default class SignalingLayerImpl extends SignalingLayer {
|
|
353
|
335
|
/**
|
|
354
|
336
|
* @inheritDoc
|
|
355
|
337
|
*/
|
|
356
|
|
- setSSRCOwner(ssrc, endpointId) {
|
|
|
338
|
+ setSSRCOwner(ssrc, newEndpointId, newSourceName) {
|
|
357
|
339
|
if (typeof ssrc !== 'number') {
|
|
358
|
340
|
throw new TypeError(`SSRC(${ssrc}) must be a number`);
|
|
359
|
341
|
}
|
|
|
@@ -362,10 +344,19 @@ export default class SignalingLayerImpl extends SignalingLayer {
|
|
362
|
344
|
// an SSRC conflict could potentially occur. Log a message to make debugging easier.
|
|
363
|
345
|
const existingOwner = this.ssrcOwners.get(ssrc);
|
|
364
|
346
|
|
|
365
|
|
- if (existingOwner && existingOwner !== endpointId) {
|
|
366
|
|
- this._logOwnerChangedMessage(`SSRC owner re-assigned from ${existingOwner} to ${endpointId}`);
|
|
|
347
|
+ if (existingOwner) {
|
|
|
348
|
+ const { endpointId, sourceName } = existingOwner;
|
|
|
349
|
+
|
|
|
350
|
+ if (endpointId !== newEndpointId || sourceName !== newSourceName) {
|
|
|
351
|
+ this._logOwnerChangedMessage(
|
|
|
352
|
+ `SSRC owner re-assigned from ${existingOwner}(source-name=${sourceName}) to ${
|
|
|
353
|
+ newEndpointId}(source-name=${newSourceName})`);
|
|
|
354
|
+ }
|
|
367
|
355
|
}
|
|
368
|
|
- this.ssrcOwners.set(ssrc, endpointId);
|
|
|
356
|
+ this.ssrcOwners.set(ssrc, {
|
|
|
357
|
+ endpointId: newEndpointId,
|
|
|
358
|
+ sourceName: newSourceName
|
|
|
359
|
+ });
|
|
369
|
360
|
}
|
|
370
|
361
|
|
|
371
|
362
|
/**
|
|
|
@@ -386,25 +377,6 @@ export default class SignalingLayerImpl extends SignalingLayer {
|
|
386
|
377
|
return false;
|
|
387
|
378
|
}
|
|
388
|
379
|
|
|
389
|
|
- /**
|
|
390
|
|
- * @inheritDoc
|
|
391
|
|
- */
|
|
392
|
|
- setTrackSourceName(ssrc, sourceName) {
|
|
393
|
|
- if (typeof ssrc !== 'number') {
|
|
394
|
|
- throw new TypeError(`SSRC(${ssrc}) must be a number`);
|
|
395
|
|
- }
|
|
396
|
|
-
|
|
397
|
|
- // Now signaling layer instance is shared between different JingleSessionPC instances, so although very unlikely
|
|
398
|
|
- // an SSRC conflict could potentially occur. Log a message to make debugging easier.
|
|
399
|
|
- const existingName = this._sourceNames.get(ssrc);
|
|
400
|
|
-
|
|
401
|
|
- if (existingName && existingName !== sourceName) {
|
|
402
|
|
- this._logOwnerChangedMessage(`SSRC(${ssrc}) sourceName re-assigned from ${existingName} to ${sourceName}`);
|
|
403
|
|
- }
|
|
404
|
|
-
|
|
405
|
|
- this._sourceNames.set(ssrc, sourceName);
|
|
406
|
|
- }
|
|
407
|
|
-
|
|
408
|
380
|
/**
|
|
409
|
381
|
* @inheritDoc
|
|
410
|
382
|
*/
|
|
|
@@ -427,9 +399,13 @@ export default class SignalingLayerImpl extends SignalingLayer {
|
|
427
|
399
|
* @inheritDoc
|
|
428
|
400
|
*/
|
|
429
|
401
|
updateSsrcOwnersOnLeave(id) {
|
|
430
|
|
- const ssrcs = Array.from(this.ssrcOwners)
|
|
431
|
|
- .filter(entry => entry[1] === id)
|
|
432
|
|
- .map(entry => entry[0]);
|
|
|
402
|
+ const ssrcs = [];
|
|
|
403
|
+
|
|
|
404
|
+ this.ssrcOwners.forEach(({ endpointId }, ssrc) => {
|
|
|
405
|
+ if (endpointId === id) {
|
|
|
406
|
+ ssrcs.push(ssrc);
|
|
|
407
|
+ }
|
|
|
408
|
+ });
|
|
433
|
409
|
|
|
434
|
410
|
if (!ssrcs?.length) {
|
|
435
|
411
|
return;
|