quickvo-sdk-js 0.6.5 → 0.6.7

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.js CHANGED
@@ -7782,7 +7782,6 @@ class RoomMedias extends RoomBase {
7782
7782
  // 麦克风
7783
7783
  case "microphoneCamera_audio":
7784
7784
  {
7785
- this.removeUserMediaStreamContext(E, "microphoneCamera_audio");
7786
7785
  const _ = J(this, bt).get("audioinput"), k = J(this, _t).get("microphoneCamera_audio"), e = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: _, ...k }, video: !1 });
7787
7786
  J(this, St).push(e), await this.initUserMediaStreamContext(E, "microphoneCamera_audio", e);
7788
7787
  }
@@ -7790,7 +7789,6 @@ class RoomMedias extends RoomBase {
7790
7789
  // 摄像头
7791
7790
  case "microphoneCamera_video":
7792
7791
  {
7793
- this.removeUserMediaStreamContext(E, "microphoneCamera_video");
7794
7792
  const _ = J(this, bt).get("videoinput"), k = J(this, _t).get("microphoneCamera_video"), e = await navigator.mediaDevices.getUserMedia({ audio: !1, video: { deviceId: _, ...k } });
7795
7793
  J(this, St).push(e), await this.initUserMediaStreamContext(E, "microphoneCamera_video", e);
7796
7794
  }
@@ -7798,15 +7796,25 @@ class RoomMedias extends RoomBase {
7798
7796
  // 麦克风 + 摄像头
7799
7797
  case "microphoneCamera":
7800
7798
  {
7801
- this.removeUserMediaStreamContext(E, "microphoneCamera_audio"), this.removeUserMediaStreamContext(E, "microphoneCamera_video");
7802
7799
  const _ = J(this, bt).get("audioinput"), k = J(this, bt).get("videoinput"), e = J(this, _t).get("microphoneCamera_audio"), n = J(this, _t).get("microphoneCamera_video"), O = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: _, ...e }, video: { deviceId: k, ...n } });
7803
- J(this, St).push(O), await this.initUserMediaStreamContext(E, "microphoneCamera_audio", O);
7800
+ J(this, St).push(O);
7801
+ const $ = O.getTracks();
7802
+ for (const N of $) {
7803
+ const { kind: D } = N;
7804
+ if (D === "audio") {
7805
+ const q = new MediaStream();
7806
+ q.addTrack(N), await this.initUserMediaStreamContext(E, "microphoneCamera_audio", q);
7807
+ }
7808
+ if (D === "video") {
7809
+ const q = new MediaStream();
7810
+ q.addTrack(N), await this.initUserMediaStreamContext(E, "microphoneCamera_video", q);
7811
+ }
7812
+ }
7804
7813
  }
7805
7814
  break;
7806
7815
  // 屏幕共享 音频
7807
7816
  case "screenSharing_audio":
7808
7817
  {
7809
- this.removeUserMediaStreamContext(E, "screenSharing_audio");
7810
7818
  const _ = J(this, _t).get("screenSharing_audio"), k = await navigator.mediaDevices.getDisplayMedia({ audio: !0, video: !0, ..._ });
7811
7819
  J(this, St).push(k);
7812
7820
  const e = k.getTracks();
@@ -7822,7 +7830,6 @@ class RoomMedias extends RoomBase {
7822
7830
  // 屏幕共享 视频
7823
7831
  case "screenSharing_video":
7824
7832
  {
7825
- this.removeUserMediaStreamContext(E, u);
7826
7833
  const _ = J(this, _t).get(u), k = await navigator.mediaDevices.getDisplayMedia({ audio: !1, video: !0, ..._ });
7827
7834
  J(this, St).push(k);
7828
7835
  const e = k.getTracks();
@@ -7838,7 +7845,6 @@ class RoomMedias extends RoomBase {
7838
7845
  // 屏幕共享 音频+视频
7839
7846
  case "screenSharing":
7840
7847
  {
7841
- this.removeUserMediaStreamContext(E, "screenSharing_audio"), this.removeUserMediaStreamContext(E, "screenSharing_video");
7842
7848
  const _ = J(this, _t).get("screenSharing_audio"), k = J(this, _t).get("screenSharing_video"), e = await navigator.mediaDevices.getDisplayMedia({ audio: !0, video: !0, ..._, ...k });
7843
7849
  J(this, St).push(e);
7844
7850
  const n = e.getTracks();
@@ -8448,13 +8454,13 @@ class RoomPeer extends RoomUsers {
8448
8454
  Z(this, "closeUserTracks", async (u, E = [], _ = !1) => {
8449
8455
  const k = [];
8450
8456
  for (const $ of E) {
8451
- const { trackName: N, msid: D } = $;
8452
- k.push(N), D && k.push(D);
8457
+ const { mid: N, trackName: D, msid: q } = $;
8458
+ k.push(D), N && k.push(N), q && k.push(q);
8453
8459
  }
8454
8460
  const e = ($) => k.includes($), n = this.peerIns.getTransceivers();
8455
8461
  for (const $ of n) {
8456
- const { sender: N, receiver: D } = $;
8457
- N.track && e(N.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: sender: ${N.track.id} is stop.`, $), $.stop()), D.track && e(D.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: receiver: ${D.track.id} is stop.`, $), $.stop());
8462
+ const { mid: N } = $;
8463
+ N && e(N) && ($.stop(), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: transceiver: ${N} is stop.`, $));
8458
8464
  }
8459
8465
  const O = await this.getUser(u);
8460
8466
  if (O) {
@@ -8747,7 +8753,7 @@ class RoomCalls extends RoomPeer {
8747
8753
  typeof u == "string" && (u = [u]);
8748
8754
  const { userId: e = "" } = this.options;
8749
8755
  for (const O of u)
8750
- this.removeUserMediaStreamContext(e, O), this.setLocalStreamActiveMap.set(O, E);
8756
+ this.setLocalStreamActiveMap.set(O, !1), E === !1 && this.removeUserMediaStreamContext(e, O);
8751
8757
  if (E) {
8752
8758
  if (u.includes("microphoneCamera_audio") && u.includes("microphoneCamera_video") ? await this.initLocalStream("microphoneCamera") : u.includes("microphoneCamera_audio") ? await this.initLocalStream("microphoneCamera_audio") : u.includes("microphoneCamera_video") ? await this.initLocalStream("microphoneCamera_video") : u.includes("screenSharing_audio") && u.includes("screenSharing_video") ? await this.initLocalStream("screenSharing") : u.includes("screenSharing_audio") && !u.includes("screenSharing_video") ? await this.initLocalStream("screenSharing_audio") : u.includes("screenSharing_video") && !u.includes("screenSharing_audio") && await this.initLocalStream("screenSharing_video"), u.includes("screenSharing_audio")) {
8753
8759
  const $ = this.getUserStream(e, "screenSharing_audio").getTracks();
@@ -8899,7 +8905,7 @@ class RoomCalls extends RoomPeer {
8899
8905
  for (const q of u)
8900
8906
  this.getUserStream(e.id, q).getTracks().length === 0 && n.push(q);
8901
8907
  const O = u.filter((q) => !n.includes(q) || ["microphoneCamera_audio", "microphoneCamera_video"].includes(q));
8902
- await J(this, Ct).call(this, O);
8908
+ await this.replaceSenderStream(u, !1), await J(this, Ct).call(this, O);
8903
8909
  const $ = await this.getSenderTracks(O), N = [...e.tracks, ...$];
8904
8910
  await this.updateUsertracks(e.id, N, !0);
8905
8911
  const D = await this.getCallAction(N);
@@ -8933,7 +8939,7 @@ class RoomCalls extends RoomPeer {
8933
8939
  await this.emitNotifyUpdateUsers(), E($);
8934
8940
  };
8935
8941
  if (n.length === 0) return O();
8936
- await this.closeUserTracks(e.id, n, !0), await this.removeSenders(u);
8942
+ await this.replaceSenderStream(u, !0), await this.closeUserTracks(e.id, n, !0), await this.removeSenders(u);
8937
8943
  {
8938
8944
  const $ = await this.getCallAction(e.tracks);
8939
8945
  await J(this, Et).call(this, $);