@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/index.cjs CHANGED
@@ -4911,6 +4911,12 @@ var TransceiverController = class extends Destroyable {
4911
4911
  scaleResolutionDownBy: Number(rid) * 6 || 1
4912
4912
  }));
4913
4913
  }
4914
+ /**
4915
+ * Resolve the current MediaTrackConstraints for an input kind, normalising
4916
+ * boolean shorthand to an empty object. Public so the surrounding
4917
+ * RTCPeerConnectionController can drive its own pipeline-aware getUserMedia
4918
+ * call with the same effective constraints the transceiver would have used.
4919
+ */
4914
4920
  getConstraintsFor(kind) {
4915
4921
  const constraints = kind === "audio" ? this.inputAudioDeviceConstraints : this.inputVideoDeviceConstraints;
4916
4922
  return typeof constraints === "boolean" ? {} : constraints;
@@ -5236,7 +5242,19 @@ var RTCPeerConnectionController = class extends Destroyable {
5236
5242
  return this._memberId;
5237
5243
  }
5238
5244
  stopTrackSender(kind, options = { updateTransceiverDirection: false }) {
5239
- this.transceiverController?.stopTrackSender(kind, options);
5245
+ const audioCovered = kind === "audio" || kind === "both";
5246
+ if (audioCovered && this._localAudioPipeline) this.stopRawAudioInputForPipeline();
5247
+ if (!audioCovered) this.transceiverController?.stopTrackSender(kind, options);
5248
+ else if (kind === "both") this.transceiverController?.stopTrackSender("video", options);
5249
+ else if (!this._localAudioPipeline) this.transceiverController?.stopTrackSender(kind, options);
5250
+ }
5251
+ stopRawAudioInputForPipeline() {
5252
+ const rawTracks = this.localStreamController.localAudioTracks;
5253
+ for (const track of rawTracks) if (track.readyState === "live") {
5254
+ track.stop();
5255
+ this.localStreamController.removeTrack(track.id);
5256
+ }
5257
+ this._localAudioPipeline?.setInputTrack(null);
5240
5258
  }
5241
5259
  get isNegotiating$() {
5242
5260
  return this._isNegotiating$.asObservable();
@@ -5741,8 +5759,27 @@ var RTCPeerConnectionController = class extends Destroyable {
5741
5759
  await this.transceiverController?.setupRemoteTransceivers(this.type);
5742
5760
  }
5743
5761
  async restoreTrackSender(kind) {
5744
- await this.transceiverController?.restoreTrackSender(kind);
5745
- if (kind !== "video" && this._localAudioPipeline) await this.applyLocalAudioPipelineToSender();
5762
+ const audioCovered = kind === "audio" || kind === "both";
5763
+ if (audioCovered && this._localAudioPipeline) await this.restoreRawAudioInputForPipeline();
5764
+ if (!audioCovered) await this.transceiverController?.restoreTrackSender(kind);
5765
+ else if (kind === "both") await this.transceiverController?.restoreTrackSender("video");
5766
+ else if (!this._localAudioPipeline) await this.transceiverController?.restoreTrackSender(kind);
5767
+ }
5768
+ async restoreRawAudioInputForPipeline() {
5769
+ if (!this._localAudioPipeline) return;
5770
+ const constraints = this.transceiverController?.getConstraintsFor("audio") ?? {};
5771
+ let stream;
5772
+ try {
5773
+ stream = await this.getUserMedia({ audio: constraints });
5774
+ } catch (error) {
5775
+ logger$16.error("[RTCPeerConnectionController] Failed to re-acquire mic for pipeline restore:", error);
5776
+ this._errors$.next(toError(error));
5777
+ return;
5778
+ }
5779
+ const newTrack = stream.getAudioTracks().at(0);
5780
+ if (!newTrack) return;
5781
+ this.localStreamController.addTrack(newTrack);
5782
+ this._localAudioPipeline.setInputTrack(newTrack);
5746
5783
  }
5747
5784
  /**
5748
5785
  * Return the lazily-created {@link LocalAudioPipeline}, constructing it on