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