@whereby.com/media 8.3.2 → 8.3.4

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
@@ -581,7 +581,7 @@ class Session {
581
581
  desc.sdp = deprioritizeH264(desc.sdp);
582
582
  this.srdComplete = this.pc.setRemoteDescription(desc);
583
583
  return this.srdComplete.then(() => {
584
- this.earlyIceCandidates.forEach((candidate) => this.pc.addIceCandidate(candidate));
584
+ this.earlyIceCandidates.forEach((candidate) => this.addIceCandidate(candidate));
585
585
  this.earlyIceCandidates = [];
586
586
  });
587
587
  }
@@ -622,6 +622,15 @@ class Session {
622
622
  });
623
623
  }
624
624
  handleAnswer(message) {
625
+ if (this.pc.signalingState !== "have-local-offer") {
626
+ logger$a.warn("Ignoring stale SDP answer for client %s (signalingState: %s)", this.clientId, this.pc.signalingState);
627
+ this._incrementAnalyticMetric("P2PStaleAnswerIgnored");
628
+ rtcStats.sendEvent("P2PStaleAnswerIgnored", {
629
+ clientId: this.clientId,
630
+ signalingState: this.pc.signalingState,
631
+ });
632
+ return Promise.resolve();
633
+ }
625
634
  const sdp = filterMsidSemantic(message.sdp);
626
635
  const desc = { type: message.type, sdp };
627
636
  return this._setRemoteDescription(desc).then(() => {
@@ -643,6 +652,14 @@ class Session {
643
652
  }
644
653
  this.pc.addIceCandidate(candidate).catch((e) => {
645
654
  logger$a.warn("Failed to add ICE candidate ('%s'): %s", candidate ? candidate.candidate : null, e);
655
+ this._incrementAnalyticMetric("P2PAddIceCandidateFailure");
656
+ rtcStats.sendEvent("P2PAddIceCandidateFailure", {
657
+ clientId: this.clientId,
658
+ errorName: e === null || e === void 0 ? void 0 : e.name,
659
+ errorMessage: e === null || e === void 0 ? void 0 : e.message,
660
+ signalingState: this.pc.signalingState,
661
+ iceConnectionState: this.pc.iceConnectionState,
662
+ });
646
663
  });
647
664
  });
648
665
  }
@@ -2535,6 +2552,7 @@ class P2pRtcManager {
2535
2552
  numPcSldFailure: 0,
2536
2553
  numPcOnAnswerFailure: 0,
2537
2554
  numPcOnOfferFailure: 0,
2555
+ P2PStaleAnswerIgnored: 0,
2538
2556
  P2PReplaceTrackNoStream: 0,
2539
2557
  P2PReplaceTrackNewTrackNotInStream: 0,
2540
2558
  P2POnTrackNoStream: 0,
@@ -2543,6 +2561,7 @@ class P2pRtcManager {
2543
2561
  P2PRelayedIceCandidate: 0,
2544
2562
  P2PSessionAddTrack: 0,
2545
2563
  P2PAddTrackToPeerConnections: 0,
2564
+ P2PAddIceCandidateFailure: 0,
2546
2565
  };
2547
2566
  }
2548
2567
  numberOfPeerconnections() {
package/dist/index.d.cts CHANGED
@@ -1368,6 +1368,7 @@ type P2PAnalytics = {
1368
1368
  numPcOnAnswerFailure: number;
1369
1369
  numPcOnOfferFailure: number;
1370
1370
  numPcSldFailure: number;
1371
+ P2PStaleAnswerIgnored: number;
1371
1372
  P2PReplaceTrackNoStream: number;
1372
1373
  P2PReplaceTrackNewTrackNotInStream: number;
1373
1374
  P2POnTrackNoStream: number;
@@ -1376,6 +1377,7 @@ type P2PAnalytics = {
1376
1377
  P2PRelayedIceCandidate: number;
1377
1378
  P2PSessionAddTrack: number;
1378
1379
  P2PAddTrackToPeerConnections: number;
1380
+ P2PAddIceCandidateFailure: number;
1379
1381
  };
1380
1382
  type P2PAnalyticMetric = keyof P2PAnalytics;
1381
1383
  type P2PIncrementAnalyticMetric = (metric: P2PAnalyticMetric) => void;
package/dist/index.d.mts CHANGED
@@ -1368,6 +1368,7 @@ type P2PAnalytics = {
1368
1368
  numPcOnAnswerFailure: number;
1369
1369
  numPcOnOfferFailure: number;
1370
1370
  numPcSldFailure: number;
1371
+ P2PStaleAnswerIgnored: number;
1371
1372
  P2PReplaceTrackNoStream: number;
1372
1373
  P2PReplaceTrackNewTrackNotInStream: number;
1373
1374
  P2POnTrackNoStream: number;
@@ -1376,6 +1377,7 @@ type P2PAnalytics = {
1376
1377
  P2PRelayedIceCandidate: number;
1377
1378
  P2PSessionAddTrack: number;
1378
1379
  P2PAddTrackToPeerConnections: number;
1380
+ P2PAddIceCandidateFailure: number;
1379
1381
  };
1380
1382
  type P2PAnalyticMetric = keyof P2PAnalytics;
1381
1383
  type P2PIncrementAnalyticMetric = (metric: P2PAnalyticMetric) => void;
package/dist/index.d.ts CHANGED
@@ -1368,6 +1368,7 @@ type P2PAnalytics = {
1368
1368
  numPcOnAnswerFailure: number;
1369
1369
  numPcOnOfferFailure: number;
1370
1370
  numPcSldFailure: number;
1371
+ P2PStaleAnswerIgnored: number;
1371
1372
  P2PReplaceTrackNoStream: number;
1372
1373
  P2PReplaceTrackNewTrackNotInStream: number;
1373
1374
  P2POnTrackNoStream: number;
@@ -1376,6 +1377,7 @@ type P2PAnalytics = {
1376
1377
  P2PRelayedIceCandidate: number;
1377
1378
  P2PSessionAddTrack: number;
1378
1379
  P2PAddTrackToPeerConnections: number;
1380
+ P2PAddIceCandidateFailure: number;
1379
1381
  };
1380
1382
  type P2PAnalyticMetric = keyof P2PAnalytics;
1381
1383
  type P2PIncrementAnalyticMetric = (metric: P2PAnalyticMetric) => void;
package/dist/index.mjs CHANGED
@@ -560,7 +560,7 @@ class Session {
560
560
  desc.sdp = deprioritizeH264(desc.sdp);
561
561
  this.srdComplete = this.pc.setRemoteDescription(desc);
562
562
  return this.srdComplete.then(() => {
563
- this.earlyIceCandidates.forEach((candidate) => this.pc.addIceCandidate(candidate));
563
+ this.earlyIceCandidates.forEach((candidate) => this.addIceCandidate(candidate));
564
564
  this.earlyIceCandidates = [];
565
565
  });
566
566
  }
@@ -601,6 +601,15 @@ class Session {
601
601
  });
602
602
  }
603
603
  handleAnswer(message) {
604
+ if (this.pc.signalingState !== "have-local-offer") {
605
+ logger$a.warn("Ignoring stale SDP answer for client %s (signalingState: %s)", this.clientId, this.pc.signalingState);
606
+ this._incrementAnalyticMetric("P2PStaleAnswerIgnored");
607
+ rtcStats.sendEvent("P2PStaleAnswerIgnored", {
608
+ clientId: this.clientId,
609
+ signalingState: this.pc.signalingState,
610
+ });
611
+ return Promise.resolve();
612
+ }
604
613
  const sdp = filterMsidSemantic(message.sdp);
605
614
  const desc = { type: message.type, sdp };
606
615
  return this._setRemoteDescription(desc).then(() => {
@@ -622,6 +631,14 @@ class Session {
622
631
  }
623
632
  this.pc.addIceCandidate(candidate).catch((e) => {
624
633
  logger$a.warn("Failed to add ICE candidate ('%s'): %s", candidate ? candidate.candidate : null, e);
634
+ this._incrementAnalyticMetric("P2PAddIceCandidateFailure");
635
+ rtcStats.sendEvent("P2PAddIceCandidateFailure", {
636
+ clientId: this.clientId,
637
+ errorName: e === null || e === void 0 ? void 0 : e.name,
638
+ errorMessage: e === null || e === void 0 ? void 0 : e.message,
639
+ signalingState: this.pc.signalingState,
640
+ iceConnectionState: this.pc.iceConnectionState,
641
+ });
625
642
  });
626
643
  });
627
644
  }
@@ -2514,6 +2531,7 @@ class P2pRtcManager {
2514
2531
  numPcSldFailure: 0,
2515
2532
  numPcOnAnswerFailure: 0,
2516
2533
  numPcOnOfferFailure: 0,
2534
+ P2PStaleAnswerIgnored: 0,
2517
2535
  P2PReplaceTrackNoStream: 0,
2518
2536
  P2PReplaceTrackNewTrackNotInStream: 0,
2519
2537
  P2POnTrackNoStream: 0,
@@ -2522,6 +2540,7 @@ class P2pRtcManager {
2522
2540
  P2PRelayedIceCandidate: 0,
2523
2541
  P2PSessionAddTrack: 0,
2524
2542
  P2PAddTrackToPeerConnections: 0,
2543
+ P2PAddIceCandidateFailure: 0,
2525
2544
  };
2526
2545
  }
2527
2546
  numberOfPeerconnections() {
@@ -560,7 +560,7 @@ class Session {
560
560
  desc.sdp = deprioritizeH264(desc.sdp);
561
561
  this.srdComplete = this.pc.setRemoteDescription(desc);
562
562
  return this.srdComplete.then(() => {
563
- this.earlyIceCandidates.forEach((candidate) => this.pc.addIceCandidate(candidate));
563
+ this.earlyIceCandidates.forEach((candidate) => this.addIceCandidate(candidate));
564
564
  this.earlyIceCandidates = [];
565
565
  });
566
566
  }
@@ -601,6 +601,15 @@ class Session {
601
601
  });
602
602
  }
603
603
  handleAnswer(message) {
604
+ if (this.pc.signalingState !== "have-local-offer") {
605
+ logger$a.warn("Ignoring stale SDP answer for client %s (signalingState: %s)", this.clientId, this.pc.signalingState);
606
+ this._incrementAnalyticMetric("P2PStaleAnswerIgnored");
607
+ rtcStats.sendEvent("P2PStaleAnswerIgnored", {
608
+ clientId: this.clientId,
609
+ signalingState: this.pc.signalingState,
610
+ });
611
+ return Promise.resolve();
612
+ }
604
613
  const sdp = filterMsidSemantic(message.sdp);
605
614
  const desc = { type: message.type, sdp };
606
615
  return this._setRemoteDescription(desc).then(() => {
@@ -622,6 +631,14 @@ class Session {
622
631
  }
623
632
  this.pc.addIceCandidate(candidate).catch((e) => {
624
633
  logger$a.warn("Failed to add ICE candidate ('%s'): %s", candidate ? candidate.candidate : null, e);
634
+ this._incrementAnalyticMetric("P2PAddIceCandidateFailure");
635
+ rtcStats.sendEvent("P2PAddIceCandidateFailure", {
636
+ clientId: this.clientId,
637
+ errorName: e === null || e === void 0 ? void 0 : e.name,
638
+ errorMessage: e === null || e === void 0 ? void 0 : e.message,
639
+ signalingState: this.pc.signalingState,
640
+ iceConnectionState: this.pc.iceConnectionState,
641
+ });
625
642
  });
626
643
  });
627
644
  }
@@ -2514,6 +2531,7 @@ class P2pRtcManager {
2514
2531
  numPcSldFailure: 0,
2515
2532
  numPcOnAnswerFailure: 0,
2516
2533
  numPcOnOfferFailure: 0,
2534
+ P2PStaleAnswerIgnored: 0,
2517
2535
  P2PReplaceTrackNoStream: 0,
2518
2536
  P2PReplaceTrackNewTrackNotInStream: 0,
2519
2537
  P2POnTrackNoStream: 0,
@@ -2522,6 +2540,7 @@ class P2pRtcManager {
2522
2540
  P2PRelayedIceCandidate: 0,
2523
2541
  P2PSessionAddTrack: 0,
2524
2542
  P2PAddTrackToPeerConnections: 0,
2543
+ P2PAddIceCandidateFailure: 0,
2525
2544
  };
2526
2545
  }
2527
2546
  numberOfPeerconnections() {
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": "8.3.2",
4
+ "version": "8.3.4",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {