@signalwire/js 4.0.0-dev-20260429174756 → 4.0.0-dev-20260430003639

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/browser.mjs CHANGED
@@ -15423,6 +15423,12 @@ var TransceiverController = class extends Destroyable {
15423
15423
  scaleResolutionDownBy: Number(rid) * 6 || 1
15424
15424
  }));
15425
15425
  }
15426
+ /**
15427
+ * Resolve the current MediaTrackConstraints for an input kind, normalising
15428
+ * boolean shorthand to an empty object. Public so the surrounding
15429
+ * RTCPeerConnectionController can drive its own pipeline-aware getUserMedia
15430
+ * call with the same effective constraints the transceiver would have used.
15431
+ */
15426
15432
  getConstraintsFor(kind) {
15427
15433
  const constraints = kind === "audio" ? this.inputAudioDeviceConstraints : this.inputVideoDeviceConstraints;
15428
15434
  return typeof constraints === "boolean" ? {} : constraints;
@@ -15749,7 +15755,19 @@ var RTCPeerConnectionController = class extends Destroyable {
15749
15755
  return this._memberId;
15750
15756
  }
15751
15757
  stopTrackSender(kind, options = { updateTransceiverDirection: false }) {
15752
- this.transceiverController?.stopTrackSender(kind, options);
15758
+ const audioCovered = kind === "audio" || kind === "both";
15759
+ if (audioCovered && this._localAudioPipeline) this.stopRawAudioInputForPipeline();
15760
+ if (!audioCovered) this.transceiverController?.stopTrackSender(kind, options);
15761
+ else if (kind === "both") this.transceiverController?.stopTrackSender("video", options);
15762
+ else if (!this._localAudioPipeline) this.transceiverController?.stopTrackSender(kind, options);
15763
+ }
15764
+ stopRawAudioInputForPipeline() {
15765
+ const rawTracks = this.localStreamController.localAudioTracks;
15766
+ for (const track of rawTracks) if (track.readyState === "live") {
15767
+ track.stop();
15768
+ this.localStreamController.removeTrack(track.id);
15769
+ }
15770
+ this._localAudioPipeline?.setInputTrack(null);
15753
15771
  }
15754
15772
  get isNegotiating$() {
15755
15773
  return this._isNegotiating$.asObservable();
@@ -16254,8 +16272,27 @@ var RTCPeerConnectionController = class extends Destroyable {
16254
16272
  await this.transceiverController?.setupRemoteTransceivers(this.type);
16255
16273
  }
16256
16274
  async restoreTrackSender(kind) {
16257
- await this.transceiverController?.restoreTrackSender(kind);
16258
- if (kind !== "video" && this._localAudioPipeline) await this.applyLocalAudioPipelineToSender();
16275
+ const audioCovered = kind === "audio" || kind === "both";
16276
+ if (audioCovered && this._localAudioPipeline) await this.restoreRawAudioInputForPipeline();
16277
+ if (!audioCovered) await this.transceiverController?.restoreTrackSender(kind);
16278
+ else if (kind === "both") await this.transceiverController?.restoreTrackSender("video");
16279
+ else if (!this._localAudioPipeline) await this.transceiverController?.restoreTrackSender(kind);
16280
+ }
16281
+ async restoreRawAudioInputForPipeline() {
16282
+ if (!this._localAudioPipeline) return;
16283
+ const constraints = this.transceiverController?.getConstraintsFor("audio") ?? {};
16284
+ let stream;
16285
+ try {
16286
+ stream = await this.getUserMedia({ audio: constraints });
16287
+ } catch (error) {
16288
+ logger$16.error("[RTCPeerConnectionController] Failed to re-acquire mic for pipeline restore:", error);
16289
+ this._errors$.next(toError(error));
16290
+ return;
16291
+ }
16292
+ const newTrack = stream.getAudioTracks().at(0);
16293
+ if (!newTrack) return;
16294
+ this.localStreamController.addTrack(newTrack);
16295
+ this._localAudioPipeline.setInputTrack(newTrack);
16259
16296
  }
16260
16297
  /**
16261
16298
  * Return the lazily-created {@link LocalAudioPipeline}, constructing it on