@whereby.com/media 1.7.0 → 1.9.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
@@ -3238,7 +3238,6 @@ const PROTOCOL_REQUESTS = {
3238
3238
  STOP_URL_EMBED: "stop_url_embed",
3239
3239
  START_RECORDING: "start_recording",
3240
3240
  STOP_RECORDING: "stop_recording",
3241
- SFU_TOKEN: "sfu_token",
3242
3241
  };
3243
3242
  const PROTOCOL_RESPONSES = {
3244
3243
  AUDIO_ENABLED: "audio_enabled",
@@ -5465,14 +5464,18 @@ class VegaRtcManager {
5465
5464
  }
5466
5465
  }
5467
5466
  _internalSendWebcam() {
5467
+ var _a;
5468
5468
  return __awaiter(this, void 0, void 0, function* () {
5469
5469
  logger$1.info("_internalSendWebcam()");
5470
+ if (!this._sendTransport ||
5471
+ this._webcamProducer ||
5472
+ this._webcamProducerPromise ||
5473
+ ((_a = this._webcamTrack) === null || _a === void 0 ? void 0 : _a.readyState) !== "live") {
5474
+ return;
5475
+ }
5470
5476
  this._webcamProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
5477
+ var _b;
5471
5478
  try {
5472
- if (!this._webcamTrack || !this._sendTransport || this._webcamProducer) {
5473
- this._webcamProducerPromise = null;
5474
- return;
5475
- }
5476
5479
  const currentPaused = this._webcamPaused;
5477
5480
  const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._webcamTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", false, this._features)), { appData: {
5478
5481
  streamId: OUTBOUND_CAM_OUTBOUND_STREAM_ID,
@@ -5493,8 +5496,10 @@ class VegaRtcManager {
5493
5496
  this._webcamProducerPromise = null;
5494
5497
  this._qualityMonitor.removeProducer(this._selfId, producer.id);
5495
5498
  });
5496
- if (this._webcamTrack !== this._webcamProducer.track)
5497
- yield this._replaceWebcamTrack();
5499
+ if (this._webcamTrack && this._webcamTrack !== ((_b = this._webcamProducer) === null || _b === void 0 ? void 0 : _b.track)) {
5500
+ this._webcamProducerPromise = null;
5501
+ this._replaceWebcamTrack();
5502
+ }
5498
5503
  if (this._webcamPaused !== this._webcamProducer.paused)
5499
5504
  this._pauseResumeWebcam();
5500
5505
  }
@@ -5504,7 +5509,7 @@ class VegaRtcManager {
5504
5509
  finally {
5505
5510
  this._webcamProducerPromise = null;
5506
5511
  if (!this._webcamTrack) {
5507
- yield this._stopProducer(this._webcamProducer);
5512
+ this._stopProducer(this._webcamProducer);
5508
5513
  this._webcamProducer = null;
5509
5514
  }
5510
5515
  }
@@ -5514,8 +5519,12 @@ class VegaRtcManager {
5514
5519
  _replaceWebcamTrack() {
5515
5520
  return __awaiter(this, void 0, void 0, function* () {
5516
5521
  logger$1.info("_replaceWebcamTrack()");
5517
- if (!this._webcamTrack || !this._webcamProducer || this._webcamProducer.closed)
5522
+ if (!this._sendTransport || !this._webcamTrack || this._webcamProducerPromise)
5518
5523
  return;
5524
+ if (!this._webcamProducer && this._webcamTrack.enabled) {
5525
+ yield this._internalSendWebcam();
5526
+ return;
5527
+ }
5519
5528
  if (this._webcamProducer.track !== this._webcamTrack) {
5520
5529
  yield this._webcamProducer.replaceTrack({ track: this._webcamTrack });
5521
5530
  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;
@@ -1275,7 +1276,6 @@ declare const PROTOCOL_REQUESTS: {
1275
1276
  STOP_URL_EMBED: string;
1276
1277
  START_RECORDING: string;
1277
1278
  STOP_RECORDING: string;
1278
- SFU_TOKEN: string;
1279
1279
  };
1280
1280
  declare const PROTOCOL_RESPONSES: {
1281
1281
  AUDIO_ENABLED: string;
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;
@@ -1275,7 +1276,6 @@ declare const PROTOCOL_REQUESTS: {
1275
1276
  STOP_URL_EMBED: string;
1276
1277
  START_RECORDING: string;
1277
1278
  STOP_RECORDING: string;
1278
- SFU_TOKEN: string;
1279
1279
  };
1280
1280
  declare const PROTOCOL_RESPONSES: {
1281
1281
  AUDIO_ENABLED: string;
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;
@@ -1275,7 +1276,6 @@ declare const PROTOCOL_REQUESTS: {
1275
1276
  STOP_URL_EMBED: string;
1276
1277
  START_RECORDING: string;
1277
1278
  STOP_RECORDING: string;
1278
- SFU_TOKEN: string;
1279
1279
  };
1280
1280
  declare const PROTOCOL_RESPONSES: {
1281
1281
  AUDIO_ENABLED: string;
package/dist/index.mjs CHANGED
@@ -3217,7 +3217,6 @@ const PROTOCOL_REQUESTS = {
3217
3217
  STOP_URL_EMBED: "stop_url_embed",
3218
3218
  START_RECORDING: "start_recording",
3219
3219
  STOP_RECORDING: "stop_recording",
3220
- SFU_TOKEN: "sfu_token",
3221
3220
  };
3222
3221
  const PROTOCOL_RESPONSES = {
3223
3222
  AUDIO_ENABLED: "audio_enabled",
@@ -5444,14 +5443,18 @@ class VegaRtcManager {
5444
5443
  }
5445
5444
  }
5446
5445
  _internalSendWebcam() {
5446
+ var _a;
5447
5447
  return __awaiter(this, void 0, void 0, function* () {
5448
5448
  logger$1.info("_internalSendWebcam()");
5449
+ if (!this._sendTransport ||
5450
+ this._webcamProducer ||
5451
+ this._webcamProducerPromise ||
5452
+ ((_a = this._webcamTrack) === null || _a === void 0 ? void 0 : _a.readyState) !== "live") {
5453
+ return;
5454
+ }
5449
5455
  this._webcamProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
5456
+ var _b;
5450
5457
  try {
5451
- if (!this._webcamTrack || !this._sendTransport || this._webcamProducer) {
5452
- this._webcamProducerPromise = null;
5453
- return;
5454
- }
5455
5458
  const currentPaused = this._webcamPaused;
5456
5459
  const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._webcamTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", false, this._features)), { appData: {
5457
5460
  streamId: OUTBOUND_CAM_OUTBOUND_STREAM_ID,
@@ -5472,8 +5475,10 @@ class VegaRtcManager {
5472
5475
  this._webcamProducerPromise = null;
5473
5476
  this._qualityMonitor.removeProducer(this._selfId, producer.id);
5474
5477
  });
5475
- if (this._webcamTrack !== this._webcamProducer.track)
5476
- yield this._replaceWebcamTrack();
5478
+ if (this._webcamTrack && this._webcamTrack !== ((_b = this._webcamProducer) === null || _b === void 0 ? void 0 : _b.track)) {
5479
+ this._webcamProducerPromise = null;
5480
+ this._replaceWebcamTrack();
5481
+ }
5477
5482
  if (this._webcamPaused !== this._webcamProducer.paused)
5478
5483
  this._pauseResumeWebcam();
5479
5484
  }
@@ -5483,7 +5488,7 @@ class VegaRtcManager {
5483
5488
  finally {
5484
5489
  this._webcamProducerPromise = null;
5485
5490
  if (!this._webcamTrack) {
5486
- yield this._stopProducer(this._webcamProducer);
5491
+ this._stopProducer(this._webcamProducer);
5487
5492
  this._webcamProducer = null;
5488
5493
  }
5489
5494
  }
@@ -5493,8 +5498,12 @@ class VegaRtcManager {
5493
5498
  _replaceWebcamTrack() {
5494
5499
  return __awaiter(this, void 0, void 0, function* () {
5495
5500
  logger$1.info("_replaceWebcamTrack()");
5496
- if (!this._webcamTrack || !this._webcamProducer || this._webcamProducer.closed)
5501
+ if (!this._sendTransport || !this._webcamTrack || this._webcamProducerPromise)
5497
5502
  return;
5503
+ if (!this._webcamProducer && this._webcamTrack.enabled) {
5504
+ yield this._internalSendWebcam();
5505
+ return;
5506
+ }
5498
5507
  if (this._webcamProducer.track !== this._webcamTrack) {
5499
5508
  yield this._webcamProducer.replaceTrack({ track: this._webcamTrack });
5500
5509
  yield this._replaceWebcamTrack();
@@ -3217,7 +3217,6 @@ const PROTOCOL_REQUESTS = {
3217
3217
  STOP_URL_EMBED: "stop_url_embed",
3218
3218
  START_RECORDING: "start_recording",
3219
3219
  STOP_RECORDING: "stop_recording",
3220
- SFU_TOKEN: "sfu_token",
3221
3220
  };
3222
3221
  const PROTOCOL_RESPONSES = {
3223
3222
  AUDIO_ENABLED: "audio_enabled",
@@ -5444,14 +5443,18 @@ class VegaRtcManager {
5444
5443
  }
5445
5444
  }
5446
5445
  _internalSendWebcam() {
5446
+ var _a;
5447
5447
  return __awaiter(this, void 0, void 0, function* () {
5448
5448
  logger$1.info("_internalSendWebcam()");
5449
+ if (!this._sendTransport ||
5450
+ this._webcamProducer ||
5451
+ this._webcamProducerPromise ||
5452
+ ((_a = this._webcamTrack) === null || _a === void 0 ? void 0 : _a.readyState) !== "live") {
5453
+ return;
5454
+ }
5449
5455
  this._webcamProducerPromise = (() => __awaiter(this, void 0, void 0, function* () {
5456
+ var _b;
5450
5457
  try {
5451
- if (!this._webcamTrack || !this._sendTransport || this._webcamProducer) {
5452
- this._webcamProducerPromise = null;
5453
- return;
5454
- }
5455
5458
  const currentPaused = this._webcamPaused;
5456
5459
  const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._webcamTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", false, this._features)), { appData: {
5457
5460
  streamId: OUTBOUND_CAM_OUTBOUND_STREAM_ID,
@@ -5472,8 +5475,10 @@ class VegaRtcManager {
5472
5475
  this._webcamProducerPromise = null;
5473
5476
  this._qualityMonitor.removeProducer(this._selfId, producer.id);
5474
5477
  });
5475
- if (this._webcamTrack !== this._webcamProducer.track)
5476
- yield this._replaceWebcamTrack();
5478
+ if (this._webcamTrack && this._webcamTrack !== ((_b = this._webcamProducer) === null || _b === void 0 ? void 0 : _b.track)) {
5479
+ this._webcamProducerPromise = null;
5480
+ this._replaceWebcamTrack();
5481
+ }
5477
5482
  if (this._webcamPaused !== this._webcamProducer.paused)
5478
5483
  this._pauseResumeWebcam();
5479
5484
  }
@@ -5483,7 +5488,7 @@ class VegaRtcManager {
5483
5488
  finally {
5484
5489
  this._webcamProducerPromise = null;
5485
5490
  if (!this._webcamTrack) {
5486
- yield this._stopProducer(this._webcamProducer);
5491
+ this._stopProducer(this._webcamProducer);
5487
5492
  this._webcamProducer = null;
5488
5493
  }
5489
5494
  }
@@ -5493,8 +5498,12 @@ class VegaRtcManager {
5493
5498
  _replaceWebcamTrack() {
5494
5499
  return __awaiter(this, void 0, void 0, function* () {
5495
5500
  logger$1.info("_replaceWebcamTrack()");
5496
- if (!this._webcamTrack || !this._webcamProducer || this._webcamProducer.closed)
5501
+ if (!this._sendTransport || !this._webcamTrack || this._webcamProducerPromise)
5497
5502
  return;
5503
+ if (!this._webcamProducer && this._webcamTrack.enabled) {
5504
+ yield this._internalSendWebcam();
5505
+ return;
5506
+ }
5498
5507
  if (this._webcamProducer.track !== this._webcamTrack) {
5499
5508
  yield this._webcamProducer.replaceTrack({ track: this._webcamTrack });
5500
5509
  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.9.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {
@@ -52,7 +52,7 @@
52
52
  "events": "^3.3.0",
53
53
  "ip-address": "^9.0.5",
54
54
  "mediasoup-client": "3.7.12",
55
- "rtcstats": "github:whereby/rtcstats#5.4.0",
55
+ "rtcstats": "github:whereby/rtcstats#5.4.1",
56
56
  "sdp": "^3.2.0",
57
57
  "sdp-transform": "^2.14.2",
58
58
  "socket.io-client": "4.7.2",
@@ -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": {