@whereby.com/media 1.25.1 → 1.26.0
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/index.cjs +218 -248
- package/dist/index.d.cts +0 -2
- package/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.mjs +218 -248
- package/dist/legacy-esm.js +218 -248
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4227,215 +4227,6 @@ class P2pRtcManager {
|
|
|
4227
4227
|
}
|
|
4228
4228
|
}
|
|
4229
4229
|
|
|
4230
|
-
class SfuV2Parser {
|
|
4231
|
-
static parse(raw) {
|
|
4232
|
-
let object;
|
|
4233
|
-
try {
|
|
4234
|
-
object = JSON.parse(raw);
|
|
4235
|
-
}
|
|
4236
|
-
catch (error) {
|
|
4237
|
-
return;
|
|
4238
|
-
}
|
|
4239
|
-
if (typeof object !== "object" || Array.isArray(object)) {
|
|
4240
|
-
return;
|
|
4241
|
-
}
|
|
4242
|
-
if (object.request) {
|
|
4243
|
-
return SfuV2Parser._handleRequest(object);
|
|
4244
|
-
}
|
|
4245
|
-
else if (object.response) {
|
|
4246
|
-
return SfuV2Parser._handleResponse(object);
|
|
4247
|
-
}
|
|
4248
|
-
else if (object.message) {
|
|
4249
|
-
return SfuV2Parser._handleMessage(object);
|
|
4250
|
-
}
|
|
4251
|
-
else {
|
|
4252
|
-
return;
|
|
4253
|
-
}
|
|
4254
|
-
}
|
|
4255
|
-
static _handleRequest(rawMessage) {
|
|
4256
|
-
const message = {};
|
|
4257
|
-
message.request = true;
|
|
4258
|
-
if (typeof rawMessage.method !== "string") {
|
|
4259
|
-
return;
|
|
4260
|
-
}
|
|
4261
|
-
if (typeof rawMessage.id !== "number") {
|
|
4262
|
-
return;
|
|
4263
|
-
}
|
|
4264
|
-
message.id = rawMessage.id;
|
|
4265
|
-
message.method = rawMessage.method;
|
|
4266
|
-
message.data = rawMessage.data || {};
|
|
4267
|
-
return message;
|
|
4268
|
-
}
|
|
4269
|
-
static _handleResponse(rawMessage) {
|
|
4270
|
-
const message = {};
|
|
4271
|
-
message.response = true;
|
|
4272
|
-
if (typeof rawMessage.id !== "number") {
|
|
4273
|
-
return;
|
|
4274
|
-
}
|
|
4275
|
-
message.id = rawMessage.id;
|
|
4276
|
-
if (rawMessage.ok) {
|
|
4277
|
-
message.ok = true;
|
|
4278
|
-
message.data = rawMessage.data || {};
|
|
4279
|
-
}
|
|
4280
|
-
else {
|
|
4281
|
-
message.ok = false;
|
|
4282
|
-
message.errorCode = rawMessage.errorCode;
|
|
4283
|
-
message.errorReason = rawMessage.errorReason;
|
|
4284
|
-
}
|
|
4285
|
-
return message;
|
|
4286
|
-
}
|
|
4287
|
-
static _handleMessage(rawMessage) {
|
|
4288
|
-
const message = {};
|
|
4289
|
-
message.message = true;
|
|
4290
|
-
if (typeof rawMessage.method !== "string") {
|
|
4291
|
-
return;
|
|
4292
|
-
}
|
|
4293
|
-
message.method = rawMessage.method;
|
|
4294
|
-
message.data = rawMessage.data || {};
|
|
4295
|
-
return message;
|
|
4296
|
-
}
|
|
4297
|
-
static createRequest(method, data) {
|
|
4298
|
-
return {
|
|
4299
|
-
request: true,
|
|
4300
|
-
id: Math.round(Math.random() * 10000000),
|
|
4301
|
-
method,
|
|
4302
|
-
data: data || {},
|
|
4303
|
-
};
|
|
4304
|
-
}
|
|
4305
|
-
static createSuccessResponse(request, data) {
|
|
4306
|
-
return {
|
|
4307
|
-
response: true,
|
|
4308
|
-
id: request.id,
|
|
4309
|
-
ok: true,
|
|
4310
|
-
data: data || {},
|
|
4311
|
-
};
|
|
4312
|
-
}
|
|
4313
|
-
static createErrorResponse(request, errorCode, errorReason) {
|
|
4314
|
-
return {
|
|
4315
|
-
response: true,
|
|
4316
|
-
id: request.id,
|
|
4317
|
-
errorCode,
|
|
4318
|
-
errorReason,
|
|
4319
|
-
};
|
|
4320
|
-
}
|
|
4321
|
-
static createMessage(method, data) {
|
|
4322
|
-
return {
|
|
4323
|
-
message: true,
|
|
4324
|
-
method,
|
|
4325
|
-
data: data || {},
|
|
4326
|
-
};
|
|
4327
|
-
}
|
|
4328
|
-
}
|
|
4329
|
-
|
|
4330
|
-
const logger$6 = new Logger();
|
|
4331
|
-
class VegaConnection extends EventEmitter.EventEmitter {
|
|
4332
|
-
constructor(wsUrl, protocol = "whereby-sfu#v4") {
|
|
4333
|
-
super();
|
|
4334
|
-
this.socket = null;
|
|
4335
|
-
this.wsUrl = wsUrl;
|
|
4336
|
-
this.protocol = protocol;
|
|
4337
|
-
this.sents = new Map();
|
|
4338
|
-
this._setupSocket();
|
|
4339
|
-
}
|
|
4340
|
-
_setupSocket() {
|
|
4341
|
-
this.socket = new WebSocket(this.wsUrl, this.protocol);
|
|
4342
|
-
this.socket.onopen = this._onOpen.bind(this);
|
|
4343
|
-
this.socket.onmessage = this._onMessage.bind(this);
|
|
4344
|
-
this.socket.onclose = this._onClose.bind(this);
|
|
4345
|
-
this.socket.onerror = this._onError.bind(this);
|
|
4346
|
-
}
|
|
4347
|
-
_tearDown() {
|
|
4348
|
-
if (this.socket === null)
|
|
4349
|
-
return;
|
|
4350
|
-
this.socket.onopen = null;
|
|
4351
|
-
this.socket.onmessage = null;
|
|
4352
|
-
this.socket.onclose = null;
|
|
4353
|
-
this.socket.onerror = null;
|
|
4354
|
-
this.socket = null;
|
|
4355
|
-
this.sents.forEach((sent) => sent.close());
|
|
4356
|
-
this.emit("close");
|
|
4357
|
-
}
|
|
4358
|
-
close() {
|
|
4359
|
-
var _a;
|
|
4360
|
-
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
|
|
4361
|
-
}
|
|
4362
|
-
_onOpen() {
|
|
4363
|
-
logger$6.info("Connected");
|
|
4364
|
-
this.emit("open");
|
|
4365
|
-
}
|
|
4366
|
-
_onMessage(event) {
|
|
4367
|
-
const socketMessage = SfuV2Parser.parse(event.data);
|
|
4368
|
-
logger$6.info("Received message", socketMessage);
|
|
4369
|
-
if (socketMessage === null || socketMessage === void 0 ? void 0 : socketMessage.response) {
|
|
4370
|
-
this._handleResponse(socketMessage);
|
|
4371
|
-
}
|
|
4372
|
-
else if (socketMessage === null || socketMessage === void 0 ? void 0 : socketMessage.message) {
|
|
4373
|
-
this.emit("message", socketMessage);
|
|
4374
|
-
}
|
|
4375
|
-
}
|
|
4376
|
-
_onClose() {
|
|
4377
|
-
logger$6.info("Disconnected");
|
|
4378
|
-
this._tearDown();
|
|
4379
|
-
}
|
|
4380
|
-
_onError(error) {
|
|
4381
|
-
logger$6.info("Error", error);
|
|
4382
|
-
}
|
|
4383
|
-
_handleResponse(socketMessage) {
|
|
4384
|
-
const sent = this.sents.get(socketMessage.id);
|
|
4385
|
-
if (socketMessage.ok) {
|
|
4386
|
-
sent.resolve(socketMessage.data);
|
|
4387
|
-
}
|
|
4388
|
-
else {
|
|
4389
|
-
const error = new Error(socketMessage.errorReason);
|
|
4390
|
-
sent.reject(error);
|
|
4391
|
-
}
|
|
4392
|
-
}
|
|
4393
|
-
send(message) {
|
|
4394
|
-
try {
|
|
4395
|
-
if (this.socket) {
|
|
4396
|
-
this.socket.send(JSON.stringify(message));
|
|
4397
|
-
}
|
|
4398
|
-
}
|
|
4399
|
-
catch (error) { }
|
|
4400
|
-
}
|
|
4401
|
-
message(method, data = {}) {
|
|
4402
|
-
const message = SfuV2Parser.createMessage(method, data);
|
|
4403
|
-
this.send(message);
|
|
4404
|
-
}
|
|
4405
|
-
request(method, data = {}, timeout = 1500 * (15 + 0.1 * this.sents.size)) {
|
|
4406
|
-
const request = SfuV2Parser.createRequest(method, data);
|
|
4407
|
-
this.send(request);
|
|
4408
|
-
return new Promise((pResolve, pReject) => {
|
|
4409
|
-
const sent = {
|
|
4410
|
-
id: request.id,
|
|
4411
|
-
method: request.method,
|
|
4412
|
-
resolve: (data2) => {
|
|
4413
|
-
if (!this.sents.delete(request.id))
|
|
4414
|
-
return;
|
|
4415
|
-
clearTimeout(sent.timer);
|
|
4416
|
-
pResolve(data2);
|
|
4417
|
-
},
|
|
4418
|
-
reject: (error) => {
|
|
4419
|
-
if (!this.sents.delete(request.id))
|
|
4420
|
-
return;
|
|
4421
|
-
clearTimeout(sent.timer);
|
|
4422
|
-
pReject(error);
|
|
4423
|
-
},
|
|
4424
|
-
timer: setTimeout(() => {
|
|
4425
|
-
if (!this.sents.delete(request.id))
|
|
4426
|
-
return;
|
|
4427
|
-
pReject(new Error("request timeout"));
|
|
4428
|
-
}, timeout),
|
|
4429
|
-
close: () => {
|
|
4430
|
-
clearTimeout(sent.timer);
|
|
4431
|
-
pReject(new Error("transport closed"));
|
|
4432
|
-
},
|
|
4433
|
-
};
|
|
4434
|
-
this.sents.set(request.id, sent);
|
|
4435
|
-
});
|
|
4436
|
-
}
|
|
4437
|
-
}
|
|
4438
|
-
|
|
4439
4230
|
class KalmanFilter {
|
|
4440
4231
|
constructor({ R = 0.01, Q = 2, A = 1.1, B = 1, C = 1.2 } = { R: 0.01, Q: 2, A: 1.1, B: 1, C: 1.2 }) {
|
|
4441
4232
|
this.R = R;
|
|
@@ -4544,7 +4335,7 @@ const defaultParams = {
|
|
|
4544
4335
|
scoreFormula: "300 * bands[1].avg / Math.max(bands[1].avg + bands[0].avg, 0.01)",
|
|
4545
4336
|
outFormula: "score",
|
|
4546
4337
|
};
|
|
4547
|
-
const logger$
|
|
4338
|
+
const logger$6 = new Logger();
|
|
4548
4339
|
function createMicAnalyser({ micTrack, params, onScoreUpdated, }) {
|
|
4549
4340
|
const audioCtx = new AudioContext();
|
|
4550
4341
|
let analyser = null;
|
|
@@ -4566,7 +4357,7 @@ function createMicAnalyser({ micTrack, params, onScoreUpdated, }) {
|
|
|
4566
4357
|
lastTrackWasOurs = true;
|
|
4567
4358
|
}
|
|
4568
4359
|
catch (ex) {
|
|
4569
|
-
logger$
|
|
4360
|
+
logger$6.warn("unable to fetch new track for colocation speaker analysis, using current", ex);
|
|
4570
4361
|
}
|
|
4571
4362
|
}
|
|
4572
4363
|
lastTrack = track;
|
|
@@ -4653,7 +4444,7 @@ function createMicAnalyser({ micTrack, params, onScoreUpdated, }) {
|
|
|
4653
4444
|
};
|
|
4654
4445
|
}
|
|
4655
4446
|
|
|
4656
|
-
const logger$
|
|
4447
|
+
const logger$5 = new Logger();
|
|
4657
4448
|
const MEDIA_QUALITY = Object.freeze({
|
|
4658
4449
|
ok: "ok",
|
|
4659
4450
|
warning: "warning",
|
|
@@ -4723,7 +4514,7 @@ class VegaMediaQualityMonitor extends EventEmitter {
|
|
|
4723
4514
|
}
|
|
4724
4515
|
addProducer(clientId, producerId) {
|
|
4725
4516
|
if (!clientId || !producerId || !(typeof clientId === "string" && typeof producerId === "string")) {
|
|
4726
|
-
logger$
|
|
4517
|
+
logger$5.warn("Missing clientId or producerId");
|
|
4727
4518
|
return;
|
|
4728
4519
|
}
|
|
4729
4520
|
if (!this._producers[clientId]) {
|
|
@@ -4739,7 +4530,7 @@ class VegaMediaQualityMonitor extends EventEmitter {
|
|
|
4739
4530
|
}
|
|
4740
4531
|
addConsumer(clientId, consumerId) {
|
|
4741
4532
|
if (!clientId || !consumerId) {
|
|
4742
|
-
logger$
|
|
4533
|
+
logger$5.warn("Missing clientId or consumerId");
|
|
4743
4534
|
return;
|
|
4744
4535
|
}
|
|
4745
4536
|
if (!this._producers[clientId]) {
|
|
@@ -4757,14 +4548,14 @@ class VegaMediaQualityMonitor extends EventEmitter {
|
|
|
4757
4548
|
if (!Array.isArray(score) ||
|
|
4758
4549
|
score.length === 0 ||
|
|
4759
4550
|
score.some((s) => !s || !s.hasOwnProperty("score") || typeof s.score !== "number" || isNaN(s.score))) {
|
|
4760
|
-
logger$
|
|
4551
|
+
logger$5.warn("Unexpected producer score format");
|
|
4761
4552
|
return;
|
|
4762
4553
|
}
|
|
4763
4554
|
this._producers[clientId][producerId] = { kind, score: this._calcAvgProducerScore(score.map((s) => s.score)) };
|
|
4764
4555
|
}
|
|
4765
4556
|
addConsumerScore(clientId, consumerId, kind, score) {
|
|
4766
4557
|
if (!score || !score.hasOwnProperty("producerScores") || !Array.isArray(score.producerScores)) {
|
|
4767
|
-
logger$
|
|
4558
|
+
logger$5.warn("Unexpected consumer score format");
|
|
4768
4559
|
return;
|
|
4769
4560
|
}
|
|
4770
4561
|
this._producers[clientId][consumerId] = { kind, score: this._calcAvgProducerScore(score.producerScores) };
|
|
@@ -4801,7 +4592,7 @@ class VegaMediaQualityMonitor extends EventEmitter {
|
|
|
4801
4592
|
}
|
|
4802
4593
|
}
|
|
4803
4594
|
catch (error) {
|
|
4804
|
-
logger$
|
|
4595
|
+
logger$5.error(error);
|
|
4805
4596
|
return 0;
|
|
4806
4597
|
}
|
|
4807
4598
|
}
|
|
@@ -4842,6 +4633,215 @@ function getNumberOfTemporalLayers(consumer) {
|
|
|
4842
4633
|
return /T3/.test(((_c = (_b = (_a = consumer._rtpParameters) === null || _a === void 0 ? void 0 : _a.encodings) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.scalabilityMode) || "") ? 3 : 2;
|
|
4843
4634
|
}
|
|
4844
4635
|
|
|
4636
|
+
class SfuV2Parser {
|
|
4637
|
+
static parse(raw) {
|
|
4638
|
+
let object;
|
|
4639
|
+
try {
|
|
4640
|
+
object = JSON.parse(raw);
|
|
4641
|
+
}
|
|
4642
|
+
catch (error) {
|
|
4643
|
+
return;
|
|
4644
|
+
}
|
|
4645
|
+
if (typeof object !== "object" || Array.isArray(object)) {
|
|
4646
|
+
return;
|
|
4647
|
+
}
|
|
4648
|
+
if (object.request) {
|
|
4649
|
+
return SfuV2Parser._handleRequest(object);
|
|
4650
|
+
}
|
|
4651
|
+
else if (object.response) {
|
|
4652
|
+
return SfuV2Parser._handleResponse(object);
|
|
4653
|
+
}
|
|
4654
|
+
else if (object.message) {
|
|
4655
|
+
return SfuV2Parser._handleMessage(object);
|
|
4656
|
+
}
|
|
4657
|
+
else {
|
|
4658
|
+
return;
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4661
|
+
static _handleRequest(rawMessage) {
|
|
4662
|
+
const message = {};
|
|
4663
|
+
message.request = true;
|
|
4664
|
+
if (typeof rawMessage.method !== "string") {
|
|
4665
|
+
return;
|
|
4666
|
+
}
|
|
4667
|
+
if (typeof rawMessage.id !== "number") {
|
|
4668
|
+
return;
|
|
4669
|
+
}
|
|
4670
|
+
message.id = rawMessage.id;
|
|
4671
|
+
message.method = rawMessage.method;
|
|
4672
|
+
message.data = rawMessage.data || {};
|
|
4673
|
+
return message;
|
|
4674
|
+
}
|
|
4675
|
+
static _handleResponse(rawMessage) {
|
|
4676
|
+
const message = {};
|
|
4677
|
+
message.response = true;
|
|
4678
|
+
if (typeof rawMessage.id !== "number") {
|
|
4679
|
+
return;
|
|
4680
|
+
}
|
|
4681
|
+
message.id = rawMessage.id;
|
|
4682
|
+
if (rawMessage.ok) {
|
|
4683
|
+
message.ok = true;
|
|
4684
|
+
message.data = rawMessage.data || {};
|
|
4685
|
+
}
|
|
4686
|
+
else {
|
|
4687
|
+
message.ok = false;
|
|
4688
|
+
message.errorCode = rawMessage.errorCode;
|
|
4689
|
+
message.errorReason = rawMessage.errorReason;
|
|
4690
|
+
}
|
|
4691
|
+
return message;
|
|
4692
|
+
}
|
|
4693
|
+
static _handleMessage(rawMessage) {
|
|
4694
|
+
const message = {};
|
|
4695
|
+
message.message = true;
|
|
4696
|
+
if (typeof rawMessage.method !== "string") {
|
|
4697
|
+
return;
|
|
4698
|
+
}
|
|
4699
|
+
message.method = rawMessage.method;
|
|
4700
|
+
message.data = rawMessage.data || {};
|
|
4701
|
+
return message;
|
|
4702
|
+
}
|
|
4703
|
+
static createRequest(method, data) {
|
|
4704
|
+
return {
|
|
4705
|
+
request: true,
|
|
4706
|
+
id: Math.round(Math.random() * 10000000),
|
|
4707
|
+
method,
|
|
4708
|
+
data: data || {},
|
|
4709
|
+
};
|
|
4710
|
+
}
|
|
4711
|
+
static createSuccessResponse(request, data) {
|
|
4712
|
+
return {
|
|
4713
|
+
response: true,
|
|
4714
|
+
id: request.id,
|
|
4715
|
+
ok: true,
|
|
4716
|
+
data: data || {},
|
|
4717
|
+
};
|
|
4718
|
+
}
|
|
4719
|
+
static createErrorResponse(request, errorCode, errorReason) {
|
|
4720
|
+
return {
|
|
4721
|
+
response: true,
|
|
4722
|
+
id: request.id,
|
|
4723
|
+
errorCode,
|
|
4724
|
+
errorReason,
|
|
4725
|
+
};
|
|
4726
|
+
}
|
|
4727
|
+
static createMessage(method, data) {
|
|
4728
|
+
return {
|
|
4729
|
+
message: true,
|
|
4730
|
+
method,
|
|
4731
|
+
data: data || {},
|
|
4732
|
+
};
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4735
|
+
|
|
4736
|
+
const logger$4 = new Logger();
|
|
4737
|
+
class VegaConnection extends EventEmitter.EventEmitter {
|
|
4738
|
+
constructor(wsUrl, protocol = "whereby-sfu#v4") {
|
|
4739
|
+
super();
|
|
4740
|
+
this.socket = null;
|
|
4741
|
+
this.wsUrl = wsUrl;
|
|
4742
|
+
this.protocol = protocol;
|
|
4743
|
+
this.sents = new Map();
|
|
4744
|
+
this._setupSocket();
|
|
4745
|
+
}
|
|
4746
|
+
_setupSocket() {
|
|
4747
|
+
this.socket = new WebSocket(this.wsUrl, this.protocol);
|
|
4748
|
+
this.socket.onopen = this._onOpen.bind(this);
|
|
4749
|
+
this.socket.onmessage = this._onMessage.bind(this);
|
|
4750
|
+
this.socket.onclose = this._onClose.bind(this);
|
|
4751
|
+
this.socket.onerror = this._onError.bind(this);
|
|
4752
|
+
}
|
|
4753
|
+
_tearDown() {
|
|
4754
|
+
if (this.socket === null)
|
|
4755
|
+
return;
|
|
4756
|
+
this.socket.onopen = null;
|
|
4757
|
+
this.socket.onmessage = null;
|
|
4758
|
+
this.socket.onclose = null;
|
|
4759
|
+
this.socket.onerror = null;
|
|
4760
|
+
this.socket = null;
|
|
4761
|
+
this.sents.forEach((sent) => sent.close());
|
|
4762
|
+
this.emit("close");
|
|
4763
|
+
}
|
|
4764
|
+
close() {
|
|
4765
|
+
var _a;
|
|
4766
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
|
|
4767
|
+
}
|
|
4768
|
+
_onOpen() {
|
|
4769
|
+
logger$4.info("Connected");
|
|
4770
|
+
this.emit("open");
|
|
4771
|
+
}
|
|
4772
|
+
_onMessage(event) {
|
|
4773
|
+
const socketMessage = SfuV2Parser.parse(event.data);
|
|
4774
|
+
logger$4.info("Received message", socketMessage);
|
|
4775
|
+
if (socketMessage === null || socketMessage === void 0 ? void 0 : socketMessage.response) {
|
|
4776
|
+
this._handleResponse(socketMessage);
|
|
4777
|
+
}
|
|
4778
|
+
else if (socketMessage === null || socketMessage === void 0 ? void 0 : socketMessage.message) {
|
|
4779
|
+
this.emit("message", socketMessage);
|
|
4780
|
+
}
|
|
4781
|
+
}
|
|
4782
|
+
_onClose() {
|
|
4783
|
+
logger$4.info("Disconnected");
|
|
4784
|
+
this._tearDown();
|
|
4785
|
+
}
|
|
4786
|
+
_onError(error) {
|
|
4787
|
+
logger$4.info("Error", error);
|
|
4788
|
+
}
|
|
4789
|
+
_handleResponse(socketMessage) {
|
|
4790
|
+
const sent = this.sents.get(socketMessage.id);
|
|
4791
|
+
if (socketMessage.ok) {
|
|
4792
|
+
sent.resolve(socketMessage.data);
|
|
4793
|
+
}
|
|
4794
|
+
else {
|
|
4795
|
+
const error = new Error(socketMessage.errorReason);
|
|
4796
|
+
sent.reject(error);
|
|
4797
|
+
}
|
|
4798
|
+
}
|
|
4799
|
+
send(message) {
|
|
4800
|
+
try {
|
|
4801
|
+
if (this.socket) {
|
|
4802
|
+
this.socket.send(JSON.stringify(message));
|
|
4803
|
+
}
|
|
4804
|
+
}
|
|
4805
|
+
catch (error) { }
|
|
4806
|
+
}
|
|
4807
|
+
message(method, data = {}) {
|
|
4808
|
+
const message = SfuV2Parser.createMessage(method, data);
|
|
4809
|
+
this.send(message);
|
|
4810
|
+
}
|
|
4811
|
+
request(method, data = {}, timeout = 1500 * (15 + 0.1 * this.sents.size)) {
|
|
4812
|
+
const request = SfuV2Parser.createRequest(method, data);
|
|
4813
|
+
this.send(request);
|
|
4814
|
+
return new Promise((pResolve, pReject) => {
|
|
4815
|
+
const sent = {
|
|
4816
|
+
id: request.id,
|
|
4817
|
+
method: request.method,
|
|
4818
|
+
resolve: (data2) => {
|
|
4819
|
+
if (!this.sents.delete(request.id))
|
|
4820
|
+
return;
|
|
4821
|
+
clearTimeout(sent.timer);
|
|
4822
|
+
pResolve(data2);
|
|
4823
|
+
},
|
|
4824
|
+
reject: (error) => {
|
|
4825
|
+
if (!this.sents.delete(request.id))
|
|
4826
|
+
return;
|
|
4827
|
+
clearTimeout(sent.timer);
|
|
4828
|
+
pReject(error);
|
|
4829
|
+
},
|
|
4830
|
+
timer: setTimeout(() => {
|
|
4831
|
+
if (!this.sents.delete(request.id))
|
|
4832
|
+
return;
|
|
4833
|
+
pReject(new Error("request timeout"));
|
|
4834
|
+
}, timeout),
|
|
4835
|
+
close: () => {
|
|
4836
|
+
clearTimeout(sent.timer);
|
|
4837
|
+
pReject(new Error("transport closed"));
|
|
4838
|
+
},
|
|
4839
|
+
};
|
|
4840
|
+
this.sents.set(request.id, sent);
|
|
4841
|
+
});
|
|
4842
|
+
}
|
|
4843
|
+
}
|
|
4844
|
+
|
|
4845
4845
|
const timeNextServer = 500;
|
|
4846
4846
|
const minTimeNextServerSameDC = 2000;
|
|
4847
4847
|
const timeToWaitForEarlyServerClose = 100;
|
|
@@ -5091,7 +5091,6 @@ class VegaRtcManager {
|
|
|
5091
5091
|
this._socketListenerDeregisterFunctions = [];
|
|
5092
5092
|
this._reconnect = true;
|
|
5093
5093
|
this._reconnectTimeOut = null;
|
|
5094
|
-
this._hasVegaConnection = false;
|
|
5095
5094
|
this._isConnectingOrConnected = false;
|
|
5096
5095
|
this._qualityMonitor = new VegaMediaQualityMonitor();
|
|
5097
5096
|
this._qualityMonitor.on(PROTOCOL_EVENTS.MEDIA_QUALITY_CHANGED, (payload) => {
|
|
@@ -5161,7 +5160,7 @@ class VegaRtcManager {
|
|
|
5161
5160
|
}
|
|
5162
5161
|
if (this._screenVideoTrack)
|
|
5163
5162
|
this._emitScreenshareStarted();
|
|
5164
|
-
if (this._features.sfuReconnectV2On &&
|
|
5163
|
+
if (this._features.sfuReconnectV2On && this._reconnect) {
|
|
5165
5164
|
this._connect();
|
|
5166
5165
|
}
|
|
5167
5166
|
}), this._serverSocket.on("connect", () => this._onNetworkIsDetectedUpBySignal()), this._serverSocket.onEngineEvent("packet", () => this._onNetworkIsDetectedUpBySignal()), this._serverSocket.on("disconnect", () => this._onNetworkIsDetectedPossiblyDownBySignal()));
|
|
@@ -5174,34 +5173,6 @@ class VegaRtcManager {
|
|
|
5174
5173
|
});
|
|
5175
5174
|
}
|
|
5176
5175
|
_connect() {
|
|
5177
|
-
if (this._features.sfuConnectionManagerOn)
|
|
5178
|
-
return this._connect_v2();
|
|
5179
|
-
if (this._features.sfuReconnectV2On) {
|
|
5180
|
-
if (this._hasVegaConnection)
|
|
5181
|
-
return;
|
|
5182
|
-
if (!this._serverSocket.isConnected()) {
|
|
5183
|
-
const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
|
|
5184
|
-
if (!reconnectThresholdInMs)
|
|
5185
|
-
return;
|
|
5186
|
-
if (Date.now() > (this._serverSocket.disconnectTimestamp || 0) + reconnectThresholdInMs)
|
|
5187
|
-
return;
|
|
5188
|
-
}
|
|
5189
|
-
if (this._reconnectTimeOut)
|
|
5190
|
-
clearTimeout(this._reconnectTimeOut);
|
|
5191
|
-
}
|
|
5192
|
-
const host = this._features.sfuServerOverrideHost || [this._sfuServer.url];
|
|
5193
|
-
const searchParams = new URLSearchParams(Object.assign({ clientId: this._selfId, organizationId: this._room.organizationId, roomName: this._room.name, eventClaim: this._room.isClaimed ? this._eventClaim : null, lowBw: "true" }, Object.keys(this._features || {})
|
|
5194
|
-
.filter((featureKey) => this._features[featureKey] && /^sfu/.test(featureKey))
|
|
5195
|
-
.reduce((prev, current) => (Object.assign(Object.assign({}, prev), { [current]: this._features[current] })), {})));
|
|
5196
|
-
const queryString = searchParams.toString();
|
|
5197
|
-
const wsUrl = `wss://${host}?${queryString}`;
|
|
5198
|
-
this._vegaConnection = new VegaConnection(wsUrl);
|
|
5199
|
-
this._hasVegaConnection = true;
|
|
5200
|
-
this._vegaConnection.on("open", () => this._join());
|
|
5201
|
-
this._vegaConnection.on("close", () => this._onClose());
|
|
5202
|
-
this._vegaConnection.on("message", (message) => this._onMessage(message));
|
|
5203
|
-
}
|
|
5204
|
-
_connect_v2() {
|
|
5205
5176
|
if (this._features.sfuReconnectV2On) {
|
|
5206
5177
|
if (this._isConnectingOrConnected)
|
|
5207
5178
|
return;
|
|
@@ -5254,7 +5225,6 @@ class VegaRtcManager {
|
|
|
5254
5225
|
_onClose() {
|
|
5255
5226
|
var _a, _b;
|
|
5256
5227
|
logger$3.info("_onClose()");
|
|
5257
|
-
this._hasVegaConnection = false;
|
|
5258
5228
|
(_a = this._sendTransport) === null || _a === void 0 ? void 0 : _a.close();
|
|
5259
5229
|
(_b = this._receiveTransport) === null || _b === void 0 ? void 0 : _b.close();
|
|
5260
5230
|
this._sendTransport = null;
|
package/dist/index.d.cts
CHANGED
|
@@ -1427,7 +1427,6 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1427
1427
|
_mediaserverConfigTtlSeconds: any;
|
|
1428
1428
|
_videoTrackBeingMonitored?: CustomMediaStreamTrack;
|
|
1429
1429
|
_audioTrackBeingMonitored?: CustomMediaStreamTrack;
|
|
1430
|
-
_hasVegaConnection: boolean;
|
|
1431
1430
|
_isConnectingOrConnected: boolean;
|
|
1432
1431
|
_vegaConnectionManager?: ReturnType<typeof createVegaConnectionManager>;
|
|
1433
1432
|
_networkIsDetectedUpBySignal: boolean;
|
|
@@ -1453,7 +1452,6 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1453
1452
|
setupSocketListeners(): void;
|
|
1454
1453
|
_emitScreenshareStarted(): void;
|
|
1455
1454
|
_connect(): void;
|
|
1456
|
-
_connect_v2(): void;
|
|
1457
1455
|
_onClose(): void;
|
|
1458
1456
|
_join(): Promise<void>;
|
|
1459
1457
|
_createTransport(send: any): Promise<void>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1427,7 +1427,6 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1427
1427
|
_mediaserverConfigTtlSeconds: any;
|
|
1428
1428
|
_videoTrackBeingMonitored?: CustomMediaStreamTrack;
|
|
1429
1429
|
_audioTrackBeingMonitored?: CustomMediaStreamTrack;
|
|
1430
|
-
_hasVegaConnection: boolean;
|
|
1431
1430
|
_isConnectingOrConnected: boolean;
|
|
1432
1431
|
_vegaConnectionManager?: ReturnType<typeof createVegaConnectionManager>;
|
|
1433
1432
|
_networkIsDetectedUpBySignal: boolean;
|
|
@@ -1453,7 +1452,6 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1453
1452
|
setupSocketListeners(): void;
|
|
1454
1453
|
_emitScreenshareStarted(): void;
|
|
1455
1454
|
_connect(): void;
|
|
1456
|
-
_connect_v2(): void;
|
|
1457
1455
|
_onClose(): void;
|
|
1458
1456
|
_join(): Promise<void>;
|
|
1459
1457
|
_createTransport(send: any): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1427,7 +1427,6 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1427
1427
|
_mediaserverConfigTtlSeconds: any;
|
|
1428
1428
|
_videoTrackBeingMonitored?: CustomMediaStreamTrack;
|
|
1429
1429
|
_audioTrackBeingMonitored?: CustomMediaStreamTrack;
|
|
1430
|
-
_hasVegaConnection: boolean;
|
|
1431
1430
|
_isConnectingOrConnected: boolean;
|
|
1432
1431
|
_vegaConnectionManager?: ReturnType<typeof createVegaConnectionManager>;
|
|
1433
1432
|
_networkIsDetectedUpBySignal: boolean;
|
|
@@ -1453,7 +1452,6 @@ declare class VegaRtcManager implements RtcManager {
|
|
|
1453
1452
|
setupSocketListeners(): void;
|
|
1454
1453
|
_emitScreenshareStarted(): void;
|
|
1455
1454
|
_connect(): void;
|
|
1456
|
-
_connect_v2(): void;
|
|
1457
1455
|
_onClose(): void;
|
|
1458
1456
|
_join(): Promise<void>;
|
|
1459
1457
|
_createTransport(send: any): Promise<void>;
|