@whereby.com/media 9.2.1 → 9.2.3

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 CHANGED
@@ -2473,9 +2473,11 @@ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, pre
2473
2473
  function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2474
2474
  const audioDevices = devices.filter((d) => d.kind === "audioinput");
2475
2475
  const videoDevices = devices.filter((d) => d.kind === "videoinput");
2476
+ const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2477
+ const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2476
2478
  const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2477
- audioId: typeof audioId === "string" ? { [type]: audioId } : null,
2478
- videoId: typeof videoId === "string" ? { [type]: videoId } : null,
2479
+ audioId: useDefaultAudio ? null : { [type]: audioId },
2480
+ videoId: useDefaultVideo ? null : { [type]: videoId },
2479
2481
  } }, options));
2480
2482
  if (audioId === false || !audioDevices.length) {
2481
2483
  delete constraints.audio;
@@ -4345,7 +4347,7 @@ function createVegaConnectionManager(config) {
4345
4347
  }, timeToWaitForEarlyServerClose);
4346
4348
  });
4347
4349
  vegaConnection.on("close", () => {
4348
- var _a;
4350
+ var _a, _b;
4349
4351
  wasClosed = true;
4350
4352
  if (vegaConnection === nominatedConnection) {
4351
4353
  nominatedConnection = undefined;
@@ -4353,6 +4355,9 @@ function createVegaConnectionManager(config) {
4353
4355
  hasNotifiedDisconnect = true;
4354
4356
  (_a = config.onDisconnected) === null || _a === void 0 ? void 0 : _a.call(config);
4355
4357
  }
4358
+ else {
4359
+ (_b = config.onAttemptFailed) === null || _b === void 0 ? void 0 : _b.call(config, { host, dc });
4360
+ }
4356
4361
  handleFailedOrAbortedConnection();
4357
4362
  });
4358
4363
  }, timeBeforeConnect));
@@ -4558,9 +4563,14 @@ class VegaRtcManager {
4558
4563
  });
4559
4564
  }
4560
4565
  _connect() {
4561
- var _a;
4562
- if (this._isConnectingOrConnected)
4566
+ var _a, _b, _c, _d, _e;
4567
+ if (this._isConnectingOrConnected) {
4568
+ rtcStats.sendEvent("SfuConnectEarlyBail", {
4569
+ readyState: (_b = (_a = this._vegaConnection) === null || _a === void 0 ? void 0 : _a.socket) === null || _b === void 0 ? void 0 : _b.readyState,
4570
+ bufferedAmount: (_d = (_c = this._vegaConnection) === null || _c === void 0 ? void 0 : _c.socket) === null || _d === void 0 ? void 0 : _d.bufferedAmount,
4571
+ });
4563
4572
  return;
4573
+ }
4564
4574
  if (!this._serverSocket.isConnected()) {
4565
4575
  const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
4566
4576
  if (!reconnectThresholdInMs)
@@ -4574,7 +4584,7 @@ class VegaRtcManager {
4574
4584
  const hostList = this._features.sfuServersOverride ||
4575
4585
  this._sfuServers ||
4576
4586
  this._features.sfuServerOverrideHost ||
4577
- ((_a = this._sfuServer) === null || _a === void 0 ? void 0 : _a.url);
4587
+ ((_e = this._sfuServer) === null || _e === void 0 ? void 0 : _e.url);
4578
4588
  this._vegaConnectionManager = createVegaConnectionManager({
4579
4589
  initialHostList: hostList,
4580
4590
  getUrlForHost: (host) => {
@@ -4601,6 +4611,9 @@ class VegaRtcManager {
4601
4611
  this._isConnectingOrConnected = false;
4602
4612
  this._onClose();
4603
4613
  },
4614
+ onAttemptFailed: ({ host, dc }) => {
4615
+ rtcStats.sendEvent("SfuConnectAttemptFailed", { host, dc });
4616
+ },
4604
4617
  });
4605
4618
  }
4606
4619
  this._vegaConnectionManager.connect((metric) => this.analytics[metric]++);
@@ -4620,12 +4633,14 @@ class VegaRtcManager {
4620
4633
  }
4621
4634
  this._qualityMonitor.close();
4622
4635
  this._emitToPWA(rtcManagerEvents.SFU_CONNECTION_CLOSED);
4636
+ rtcStats.sendEvent("SfuConnectionClosed", {});
4623
4637
  }
4624
4638
  _join() {
4625
4639
  return __awaiter(this, void 0, void 0, function* () {
4626
4640
  var _a, _b;
4627
4641
  logger$2.info("_join()");
4628
4642
  this._emitToPWA(rtcManagerEvents.SFU_CONNECTION_OPEN);
4643
+ rtcStats.sendEvent("SfuConnectionOpened", {});
4629
4644
  try {
4630
4645
  if (!this._vegaConnection) {
4631
4646
  logger$2.error("_join() No VegaConnection found");
package/dist/index.d.cts CHANGED
@@ -1853,6 +1853,10 @@ declare function createVegaConnectionManager(config: {
1853
1853
  onConnected?: (vegaConnection: VegaConnection, info: ConnectionInfo) => void;
1854
1854
  onDisconnected?: () => void;
1855
1855
  onFailed?: () => void;
1856
+ onAttemptFailed?: (info: {
1857
+ host: string;
1858
+ dc: string;
1859
+ }) => void;
1856
1860
  }): {
1857
1861
  connect: (incrementAnalyticMetric?: VegaIncrementAnalyticMetric) => void;
1858
1862
  updateHostList: (updatedHostList: string | HostListEntryOptionalDC[]) => void;
package/dist/index.d.mts CHANGED
@@ -1853,6 +1853,10 @@ declare function createVegaConnectionManager(config: {
1853
1853
  onConnected?: (vegaConnection: VegaConnection, info: ConnectionInfo) => void;
1854
1854
  onDisconnected?: () => void;
1855
1855
  onFailed?: () => void;
1856
+ onAttemptFailed?: (info: {
1857
+ host: string;
1858
+ dc: string;
1859
+ }) => void;
1856
1860
  }): {
1857
1861
  connect: (incrementAnalyticMetric?: VegaIncrementAnalyticMetric) => void;
1858
1862
  updateHostList: (updatedHostList: string | HostListEntryOptionalDC[]) => void;
package/dist/index.d.ts CHANGED
@@ -1853,6 +1853,10 @@ declare function createVegaConnectionManager(config: {
1853
1853
  onConnected?: (vegaConnection: VegaConnection, info: ConnectionInfo) => void;
1854
1854
  onDisconnected?: () => void;
1855
1855
  onFailed?: () => void;
1856
+ onAttemptFailed?: (info: {
1857
+ host: string;
1858
+ dc: string;
1859
+ }) => void;
1856
1860
  }): {
1857
1861
  connect: (incrementAnalyticMetric?: VegaIncrementAnalyticMetric) => void;
1858
1862
  updateHostList: (updatedHostList: string | HostListEntryOptionalDC[]) => void;
package/dist/index.mjs CHANGED
@@ -2452,9 +2452,11 @@ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, pre
2452
2452
  function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2453
2453
  const audioDevices = devices.filter((d) => d.kind === "audioinput");
2454
2454
  const videoDevices = devices.filter((d) => d.kind === "videoinput");
2455
+ const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2456
+ const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2455
2457
  const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2456
- audioId: typeof audioId === "string" ? { [type]: audioId } : null,
2457
- videoId: typeof videoId === "string" ? { [type]: videoId } : null,
2458
+ audioId: useDefaultAudio ? null : { [type]: audioId },
2459
+ videoId: useDefaultVideo ? null : { [type]: videoId },
2458
2460
  } }, options));
2459
2461
  if (audioId === false || !audioDevices.length) {
2460
2462
  delete constraints.audio;
@@ -4324,7 +4326,7 @@ function createVegaConnectionManager(config) {
4324
4326
  }, timeToWaitForEarlyServerClose);
4325
4327
  });
4326
4328
  vegaConnection.on("close", () => {
4327
- var _a;
4329
+ var _a, _b;
4328
4330
  wasClosed = true;
4329
4331
  if (vegaConnection === nominatedConnection) {
4330
4332
  nominatedConnection = undefined;
@@ -4332,6 +4334,9 @@ function createVegaConnectionManager(config) {
4332
4334
  hasNotifiedDisconnect = true;
4333
4335
  (_a = config.onDisconnected) === null || _a === void 0 ? void 0 : _a.call(config);
4334
4336
  }
4337
+ else {
4338
+ (_b = config.onAttemptFailed) === null || _b === void 0 ? void 0 : _b.call(config, { host, dc });
4339
+ }
4335
4340
  handleFailedOrAbortedConnection();
4336
4341
  });
4337
4342
  }, timeBeforeConnect));
@@ -4537,9 +4542,14 @@ class VegaRtcManager {
4537
4542
  });
4538
4543
  }
4539
4544
  _connect() {
4540
- var _a;
4541
- if (this._isConnectingOrConnected)
4545
+ var _a, _b, _c, _d, _e;
4546
+ if (this._isConnectingOrConnected) {
4547
+ rtcStats.sendEvent("SfuConnectEarlyBail", {
4548
+ readyState: (_b = (_a = this._vegaConnection) === null || _a === void 0 ? void 0 : _a.socket) === null || _b === void 0 ? void 0 : _b.readyState,
4549
+ bufferedAmount: (_d = (_c = this._vegaConnection) === null || _c === void 0 ? void 0 : _c.socket) === null || _d === void 0 ? void 0 : _d.bufferedAmount,
4550
+ });
4542
4551
  return;
4552
+ }
4543
4553
  if (!this._serverSocket.isConnected()) {
4544
4554
  const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
4545
4555
  if (!reconnectThresholdInMs)
@@ -4553,7 +4563,7 @@ class VegaRtcManager {
4553
4563
  const hostList = this._features.sfuServersOverride ||
4554
4564
  this._sfuServers ||
4555
4565
  this._features.sfuServerOverrideHost ||
4556
- ((_a = this._sfuServer) === null || _a === void 0 ? void 0 : _a.url);
4566
+ ((_e = this._sfuServer) === null || _e === void 0 ? void 0 : _e.url);
4557
4567
  this._vegaConnectionManager = createVegaConnectionManager({
4558
4568
  initialHostList: hostList,
4559
4569
  getUrlForHost: (host) => {
@@ -4580,6 +4590,9 @@ class VegaRtcManager {
4580
4590
  this._isConnectingOrConnected = false;
4581
4591
  this._onClose();
4582
4592
  },
4593
+ onAttemptFailed: ({ host, dc }) => {
4594
+ rtcStats.sendEvent("SfuConnectAttemptFailed", { host, dc });
4595
+ },
4583
4596
  });
4584
4597
  }
4585
4598
  this._vegaConnectionManager.connect((metric) => this.analytics[metric]++);
@@ -4599,12 +4612,14 @@ class VegaRtcManager {
4599
4612
  }
4600
4613
  this._qualityMonitor.close();
4601
4614
  this._emitToPWA(rtcManagerEvents.SFU_CONNECTION_CLOSED);
4615
+ rtcStats.sendEvent("SfuConnectionClosed", {});
4602
4616
  }
4603
4617
  _join() {
4604
4618
  return __awaiter(this, void 0, void 0, function* () {
4605
4619
  var _a, _b;
4606
4620
  logger$2.info("_join()");
4607
4621
  this._emitToPWA(rtcManagerEvents.SFU_CONNECTION_OPEN);
4622
+ rtcStats.sendEvent("SfuConnectionOpened", {});
4608
4623
  try {
4609
4624
  if (!this._vegaConnection) {
4610
4625
  logger$2.error("_join() No VegaConnection found");
@@ -2452,9 +2452,11 @@ function getMediaConstraints({ disableAEC, disableAGC, hd, lax, lowDataMode, pre
2452
2452
  function getConstraints({ devices, videoId, audioId, options, type = "ideal" }) {
2453
2453
  const audioDevices = devices.filter((d) => d.kind === "audioinput");
2454
2454
  const videoDevices = devices.filter((d) => d.kind === "videoinput");
2455
+ const useDefaultAudio = !audioId || !audioDevices.some((d) => d.deviceId === audioId);
2456
+ const useDefaultVideo = !videoId || !videoDevices.some((d) => d.deviceId === videoId);
2455
2457
  const constraints = getMediaConstraints(Object.assign({ preferredDeviceIds: {
2456
- audioId: typeof audioId === "string" ? { [type]: audioId } : null,
2457
- videoId: typeof videoId === "string" ? { [type]: videoId } : null,
2458
+ audioId: useDefaultAudio ? null : { [type]: audioId },
2459
+ videoId: useDefaultVideo ? null : { [type]: videoId },
2458
2460
  } }, options));
2459
2461
  if (audioId === false || !audioDevices.length) {
2460
2462
  delete constraints.audio;
@@ -4324,7 +4326,7 @@ function createVegaConnectionManager(config) {
4324
4326
  }, timeToWaitForEarlyServerClose);
4325
4327
  });
4326
4328
  vegaConnection.on("close", () => {
4327
- var _a;
4329
+ var _a, _b;
4328
4330
  wasClosed = true;
4329
4331
  if (vegaConnection === nominatedConnection) {
4330
4332
  nominatedConnection = undefined;
@@ -4332,6 +4334,9 @@ function createVegaConnectionManager(config) {
4332
4334
  hasNotifiedDisconnect = true;
4333
4335
  (_a = config.onDisconnected) === null || _a === void 0 ? void 0 : _a.call(config);
4334
4336
  }
4337
+ else {
4338
+ (_b = config.onAttemptFailed) === null || _b === void 0 ? void 0 : _b.call(config, { host, dc });
4339
+ }
4335
4340
  handleFailedOrAbortedConnection();
4336
4341
  });
4337
4342
  }, timeBeforeConnect));
@@ -4537,9 +4542,14 @@ class VegaRtcManager {
4537
4542
  });
4538
4543
  }
4539
4544
  _connect() {
4540
- var _a;
4541
- if (this._isConnectingOrConnected)
4545
+ var _a, _b, _c, _d, _e;
4546
+ if (this._isConnectingOrConnected) {
4547
+ rtcStats.sendEvent("SfuConnectEarlyBail", {
4548
+ readyState: (_b = (_a = this._vegaConnection) === null || _a === void 0 ? void 0 : _a.socket) === null || _b === void 0 ? void 0 : _b.readyState,
4549
+ bufferedAmount: (_d = (_c = this._vegaConnection) === null || _c === void 0 ? void 0 : _c.socket) === null || _d === void 0 ? void 0 : _d.bufferedAmount,
4550
+ });
4542
4551
  return;
4552
+ }
4543
4553
  if (!this._serverSocket.isConnected()) {
4544
4554
  const reconnectThresholdInMs = this._serverSocket.getReconnectThreshold();
4545
4555
  if (!reconnectThresholdInMs)
@@ -4553,7 +4563,7 @@ class VegaRtcManager {
4553
4563
  const hostList = this._features.sfuServersOverride ||
4554
4564
  this._sfuServers ||
4555
4565
  this._features.sfuServerOverrideHost ||
4556
- ((_a = this._sfuServer) === null || _a === void 0 ? void 0 : _a.url);
4566
+ ((_e = this._sfuServer) === null || _e === void 0 ? void 0 : _e.url);
4557
4567
  this._vegaConnectionManager = createVegaConnectionManager({
4558
4568
  initialHostList: hostList,
4559
4569
  getUrlForHost: (host) => {
@@ -4580,6 +4590,9 @@ class VegaRtcManager {
4580
4590
  this._isConnectingOrConnected = false;
4581
4591
  this._onClose();
4582
4592
  },
4593
+ onAttemptFailed: ({ host, dc }) => {
4594
+ rtcStats.sendEvent("SfuConnectAttemptFailed", { host, dc });
4595
+ },
4583
4596
  });
4584
4597
  }
4585
4598
  this._vegaConnectionManager.connect((metric) => this.analytics[metric]++);
@@ -4599,12 +4612,14 @@ class VegaRtcManager {
4599
4612
  }
4600
4613
  this._qualityMonitor.close();
4601
4614
  this._emitToPWA(rtcManagerEvents.SFU_CONNECTION_CLOSED);
4615
+ rtcStats.sendEvent("SfuConnectionClosed", {});
4602
4616
  }
4603
4617
  _join() {
4604
4618
  return __awaiter(this, void 0, void 0, function* () {
4605
4619
  var _a, _b;
4606
4620
  logger$2.info("_join()");
4607
4621
  this._emitToPWA(rtcManagerEvents.SFU_CONNECTION_OPEN);
4622
+ rtcStats.sendEvent("SfuConnectionOpened", {});
4608
4623
  try {
4609
4624
  if (!this._vegaConnection) {
4610
4625
  logger$2.error("_join() No VegaConnection found");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "9.2.1",
4
+ "version": "9.2.3",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {