@whereby.com/media 1.7.0 → 1.8.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 CHANGED
@@ -5465,14 +5465,18 @@ class VegaRtcManager {
5465
5465
  }
5466
5466
  }
5467
5467
  _internalSendWebcam() {
5468
+ var _a;
5468
5469
  return __awaiter(this, void 0, void 0, function* () {
5469
5470
  logger$1.info("_internalSendWebcam()");
5471
+ if (!this._sendTransport ||
5472
+ this._webcamProducer ||
5473
+ this._webcamProducerPromise ||
5474
+ ((_a = this._webcamTrack) === null || _a === void 0 ? void 0 : _a.readyState) !== "live") {
5475
+ return;
5476
+ }
5470
5477
  this._webcamProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
5478
+ var _b;
5471
5479
  try {
5472
- if (!this._webcamTrack || !this._sendTransport || this._webcamProducer) {
5473
- this._webcamProducerPromise = null;
5474
- return;
5475
- }
5476
5480
  const currentPaused = this._webcamPaused;
5477
5481
  const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._webcamTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", false, this._features)), { appData: {
5478
5482
  streamId: OUTBOUND_CAM_OUTBOUND_STREAM_ID,
@@ -5493,8 +5497,10 @@ class VegaRtcManager {
5493
5497
  this._webcamProducerPromise = null;
5494
5498
  this._qualityMonitor.removeProducer(this._selfId, producer.id);
5495
5499
  });
5496
- if (this._webcamTrack !== this._webcamProducer.track)
5497
- yield this._replaceWebcamTrack();
5500
+ if (this._webcamTrack && this._webcamTrack !== ((_b = this._webcamProducer) === null || _b === void 0 ? void 0 : _b.track)) {
5501
+ this._webcamProducerPromise = null;
5502
+ this._replaceWebcamTrack();
5503
+ }
5498
5504
  if (this._webcamPaused !== this._webcamProducer.paused)
5499
5505
  this._pauseResumeWebcam();
5500
5506
  }
@@ -5504,7 +5510,7 @@ class VegaRtcManager {
5504
5510
  finally {
5505
5511
  this._webcamProducerPromise = null;
5506
5512
  if (!this._webcamTrack) {
5507
- yield this._stopProducer(this._webcamProducer);
5513
+ this._stopProducer(this._webcamProducer);
5508
5514
  this._webcamProducer = null;
5509
5515
  }
5510
5516
  }
@@ -5514,8 +5520,12 @@ class VegaRtcManager {
5514
5520
  _replaceWebcamTrack() {
5515
5521
  return __awaiter(this, void 0, void 0, function* () {
5516
5522
  logger$1.info("_replaceWebcamTrack()");
5517
- if (!this._webcamTrack || !this._webcamProducer || this._webcamProducer.closed)
5523
+ if (!this._sendTransport || !this._webcamTrack || this._webcamProducerPromise)
5518
5524
  return;
5525
+ if (!this._webcamProducer && this._webcamTrack.enabled) {
5526
+ yield this._internalSendWebcam();
5527
+ return;
5528
+ }
5519
5529
  if (this._webcamProducer.track !== this._webcamTrack) {
5520
5530
  yield this._webcamProducer.replaceTrack({ track: this._webcamTrack });
5521
5531
  yield this._replaceWebcamTrack();
package/dist/index.d.cts CHANGED
@@ -582,6 +582,7 @@ interface SignalClient {
582
582
  role: ClientRole;
583
583
  startedCloudRecordingAt: string | null;
584
584
  externalId: string | null;
585
+ isDialIn: boolean;
585
586
  }
586
587
  interface Spotlight {
587
588
  clientId: string;
@@ -995,7 +996,7 @@ declare class VegaConnection extends EventEmitter$1 {
995
996
  _tearDown(): void;
996
997
  close(): void;
997
998
  _onOpen(): void;
998
- _onMessage(event: any): void;
999
+ _onMessage(event: MessageEvent): void;
999
1000
  _onClose(): void;
1000
1001
  _onError(error: any): void;
1001
1002
  _handleResponse(socketMessage: any): void;
package/dist/index.d.mts CHANGED
@@ -582,6 +582,7 @@ interface SignalClient {
582
582
  role: ClientRole;
583
583
  startedCloudRecordingAt: string | null;
584
584
  externalId: string | null;
585
+ isDialIn: boolean;
585
586
  }
586
587
  interface Spotlight {
587
588
  clientId: string;
@@ -995,7 +996,7 @@ declare class VegaConnection extends EventEmitter$1 {
995
996
  _tearDown(): void;
996
997
  close(): void;
997
998
  _onOpen(): void;
998
- _onMessage(event: any): void;
999
+ _onMessage(event: MessageEvent): void;
999
1000
  _onClose(): void;
1000
1001
  _onError(error: any): void;
1001
1002
  _handleResponse(socketMessage: any): void;
package/dist/index.d.ts CHANGED
@@ -582,6 +582,7 @@ interface SignalClient {
582
582
  role: ClientRole;
583
583
  startedCloudRecordingAt: string | null;
584
584
  externalId: string | null;
585
+ isDialIn: boolean;
585
586
  }
586
587
  interface Spotlight {
587
588
  clientId: string;
@@ -995,7 +996,7 @@ declare class VegaConnection extends EventEmitter$1 {
995
996
  _tearDown(): void;
996
997
  close(): void;
997
998
  _onOpen(): void;
998
- _onMessage(event: any): void;
999
+ _onMessage(event: MessageEvent): void;
999
1000
  _onClose(): void;
1000
1001
  _onError(error: any): void;
1001
1002
  _handleResponse(socketMessage: any): void;
package/dist/index.mjs CHANGED
@@ -5444,14 +5444,18 @@ class VegaRtcManager {
5444
5444
  }
5445
5445
  }
5446
5446
  _internalSendWebcam() {
5447
+ var _a;
5447
5448
  return __awaiter(this, void 0, void 0, function* () {
5448
5449
  logger$1.info("_internalSendWebcam()");
5450
+ if (!this._sendTransport ||
5451
+ this._webcamProducer ||
5452
+ this._webcamProducerPromise ||
5453
+ ((_a = this._webcamTrack) === null || _a === void 0 ? void 0 : _a.readyState) !== "live") {
5454
+ return;
5455
+ }
5449
5456
  this._webcamProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
5457
+ var _b;
5450
5458
  try {
5451
- if (!this._webcamTrack || !this._sendTransport || this._webcamProducer) {
5452
- this._webcamProducerPromise = null;
5453
- return;
5454
- }
5455
5459
  const currentPaused = this._webcamPaused;
5456
5460
  const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._webcamTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", false, this._features)), { appData: {
5457
5461
  streamId: OUTBOUND_CAM_OUTBOUND_STREAM_ID,
@@ -5472,8 +5476,10 @@ class VegaRtcManager {
5472
5476
  this._webcamProducerPromise = null;
5473
5477
  this._qualityMonitor.removeProducer(this._selfId, producer.id);
5474
5478
  });
5475
- if (this._webcamTrack !== this._webcamProducer.track)
5476
- yield this._replaceWebcamTrack();
5479
+ if (this._webcamTrack && this._webcamTrack !== ((_b = this._webcamProducer) === null || _b === void 0 ? void 0 : _b.track)) {
5480
+ this._webcamProducerPromise = null;
5481
+ this._replaceWebcamTrack();
5482
+ }
5477
5483
  if (this._webcamPaused !== this._webcamProducer.paused)
5478
5484
  this._pauseResumeWebcam();
5479
5485
  }
@@ -5483,7 +5489,7 @@ class VegaRtcManager {
5483
5489
  finally {
5484
5490
  this._webcamProducerPromise = null;
5485
5491
  if (!this._webcamTrack) {
5486
- yield this._stopProducer(this._webcamProducer);
5492
+ this._stopProducer(this._webcamProducer);
5487
5493
  this._webcamProducer = null;
5488
5494
  }
5489
5495
  }
@@ -5493,8 +5499,12 @@ class VegaRtcManager {
5493
5499
  _replaceWebcamTrack() {
5494
5500
  return __awaiter(this, void 0, void 0, function* () {
5495
5501
  logger$1.info("_replaceWebcamTrack()");
5496
- if (!this._webcamTrack || !this._webcamProducer || this._webcamProducer.closed)
5502
+ if (!this._sendTransport || !this._webcamTrack || this._webcamProducerPromise)
5497
5503
  return;
5504
+ if (!this._webcamProducer && this._webcamTrack.enabled) {
5505
+ yield this._internalSendWebcam();
5506
+ return;
5507
+ }
5498
5508
  if (this._webcamProducer.track !== this._webcamTrack) {
5499
5509
  yield this._webcamProducer.replaceTrack({ track: this._webcamTrack });
5500
5510
  yield this._replaceWebcamTrack();
@@ -5444,14 +5444,18 @@ class VegaRtcManager {
5444
5444
  }
5445
5445
  }
5446
5446
  _internalSendWebcam() {
5447
+ var _a;
5447
5448
  return __awaiter(this, void 0, void 0, function* () {
5448
5449
  logger$1.info("_internalSendWebcam()");
5450
+ if (!this._sendTransport ||
5451
+ this._webcamProducer ||
5452
+ this._webcamProducerPromise ||
5453
+ ((_a = this._webcamTrack) === null || _a === void 0 ? void 0 : _a.readyState) !== "live") {
5454
+ return;
5455
+ }
5449
5456
  this._webcamProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
5457
+ var _b;
5450
5458
  try {
5451
- if (!this._webcamTrack || !this._sendTransport || this._webcamProducer) {
5452
- this._webcamProducerPromise = null;
5453
- return;
5454
- }
5455
5459
  const currentPaused = this._webcamPaused;
5456
5460
  const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._webcamTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", false, this._features)), { appData: {
5457
5461
  streamId: OUTBOUND_CAM_OUTBOUND_STREAM_ID,
@@ -5472,8 +5476,10 @@ class VegaRtcManager {
5472
5476
  this._webcamProducerPromise = null;
5473
5477
  this._qualityMonitor.removeProducer(this._selfId, producer.id);
5474
5478
  });
5475
- if (this._webcamTrack !== this._webcamProducer.track)
5476
- yield this._replaceWebcamTrack();
5479
+ if (this._webcamTrack && this._webcamTrack !== ((_b = this._webcamProducer) === null || _b === void 0 ? void 0 : _b.track)) {
5480
+ this._webcamProducerPromise = null;
5481
+ this._replaceWebcamTrack();
5482
+ }
5477
5483
  if (this._webcamPaused !== this._webcamProducer.paused)
5478
5484
  this._pauseResumeWebcam();
5479
5485
  }
@@ -5483,7 +5489,7 @@ class VegaRtcManager {
5483
5489
  finally {
5484
5490
  this._webcamProducerPromise = null;
5485
5491
  if (!this._webcamTrack) {
5486
- yield this._stopProducer(this._webcamProducer);
5492
+ this._stopProducer(this._webcamProducer);
5487
5493
  this._webcamProducer = null;
5488
5494
  }
5489
5495
  }
@@ -5493,8 +5499,12 @@ class VegaRtcManager {
5493
5499
  _replaceWebcamTrack() {
5494
5500
  return __awaiter(this, void 0, void 0, function* () {
5495
5501
  logger$1.info("_replaceWebcamTrack()");
5496
- if (!this._webcamTrack || !this._webcamProducer || this._webcamProducer.closed)
5502
+ if (!this._sendTransport || !this._webcamTrack || this._webcamProducerPromise)
5497
5503
  return;
5504
+ if (!this._webcamProducer && this._webcamTrack.enabled) {
5505
+ yield this._internalSendWebcam();
5506
+ return;
5507
+ }
5498
5508
  if (this._webcamProducer.track !== this._webcamTrack) {
5499
5509
  yield this._webcamProducer.replaceTrack({ track: this._webcamTrack });
5500
5510
  yield this._replaceWebcamTrack();
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": "1.7.0",
4
+ "version": "1.8.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {
@@ -64,6 +64,7 @@
64
64
  "devDependencies": {
65
65
  "@babel/core": "^7.23.2",
66
66
  "@babel/preset-env": "^7.23.2",
67
+ "jest-websocket-mock": "^2.5.0",
67
68
  "process": "^0.11.10"
68
69
  },
69
70
  "engines": {