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

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