quickvo-sdk-js 0.2.2 → 0.2.4

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
@@ -1,10 +1,10 @@
1
- var Ht = Object.defineProperty;
2
- var Ft = (_) => {
1
+ var Xt = Object.defineProperty;
2
+ var Vt = (_) => {
3
3
  throw TypeError(_);
4
4
  };
5
- var zt = (_, D, $) => D in _ ? Ht(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $;
6
- var W = (_, D, $) => zt(_, typeof D != "symbol" ? D + "" : D, $), jt = (_, D, $) => D.has(_) || Ft("Cannot " + $);
7
- var X = (_, D, $) => (jt(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), lt = (_, D, $) => D.has(_) ? Ft("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), yt = (_, D, $, U) => (jt(_, D, "write to private field"), U ? U.call(_, $) : D.set(_, $), $);
5
+ var Qt = (_, D, $) => D in _ ? Xt(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $;
6
+ var K = (_, D, $) => Qt(_, typeof D != "symbol" ? D + "" : D, $), Yt = (_, D, $) => D.has(_) || Vt("Cannot " + $);
7
+ var G = (_, D, $) => (Yt(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), st = (_, D, $) => D.has(_) ? Vt("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), _t = (_, D, $, U) => (Yt(_, D, "write to private field"), U ? U.call(_, $) : D.set(_, $), $);
8
8
  const v$1 = (_, D = []) => {
9
9
  const $ = { ..._ }, U = Object.keys($);
10
10
  for (const R of U)
@@ -704,9 +704,9 @@ function requireLib() {
704
704
  return lib.grammar = $, lib.write = D, lib.parse = _.parse, lib.parseParams = _.parseParams, lib.parseFmtpConfig = _.parseFmtpConfig, lib.parsePayloads = _.parsePayloads, lib.parseRemoteCandidates = _.parseRemoteCandidates, lib.parseImageAttributes = _.parseImageAttributes, lib.parseSimulcastStreamList = _.parseSimulcastStreamList, lib;
705
705
  }
706
706
  var libExports = requireLib();
707
- class AudioMediaStreamContext {
707
+ class AudioMediaContext {
708
708
  constructor(D) {
709
- W(this, "options", {
709
+ K(this, "options", {
710
710
  autoGainControl: !1,
711
711
  // 自动增益
712
712
  noiseSuppression: !1,
@@ -714,28 +714,29 @@ class AudioMediaStreamContext {
714
714
  echoCancellation: !1
715
715
  // 回声消除
716
716
  });
717
- W(this, "stream", new MediaStream());
718
- W(this, "audio", new Audio());
717
+ K(this, "kind", "audio");
718
+ K(this, "stream", new MediaStream());
719
+ K(this, "audio", new Audio());
719
720
  // @ts-ignore 音频上下文
720
- W(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
721
+ K(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
721
722
  // 媒体流音频源节点
722
- W(this, "mediaStreamAudioSourceNode");
723
+ K(this, "mediaStreamAudioSourceNode");
723
724
  // 增益节点 (自动增益)
724
- W(this, "autoGainNode");
725
+ K(this, "autoGainNode");
725
726
  // 滤波器节点 (噪声抑制)
726
- W(this, "biquadFilterNode");
727
+ K(this, "biquadFilterNode");
727
728
  // 延迟节点 (回声消除)
728
- W(this, "delayNode");
729
+ K(this, "delayNode");
729
730
  // 增益节点 (音量控制)
730
- W(this, "gainNode");
731
+ K(this, "gainNode");
731
732
  // 音频分析节点
732
- W(this, "analyserNode");
733
+ K(this, "analyserNode");
733
734
  // 缓冲区 存储分析节点的时域数据
734
- W(this, "analyserArrayData");
735
+ K(this, "analyserArrayData");
735
736
  /**
736
737
  * 停止
737
738
  */
738
- W(this, "stop", () => {
739
+ K(this, "stop", () => {
739
740
  const D = this.stream.getTracks();
740
741
  for (const $ of D)
741
742
  $.enabled = !1, $.stop(), this.stream.removeTrack($);
@@ -743,7 +744,7 @@ class AudioMediaStreamContext {
743
744
  /**
744
745
  * 替换媒体
745
746
  */
746
- W(this, "replaceStream", (D) => {
747
+ K(this, "replaceStream", (D) => {
747
748
  this.stop();
748
749
  const [$] = D.getAudioTracks();
749
750
  this.stream.addTrack($);
@@ -751,23 +752,23 @@ class AudioMediaStreamContext {
751
752
  /**
752
753
  * 获取数据流
753
754
  */
754
- W(this, "getStream", () => this.mediaStreamAudioSourceNode.mediaStream);
755
+ K(this, "getStream", () => this.mediaStreamAudioSourceNode.mediaStream);
755
756
  /**
756
757
  * 静音
757
758
  */
758
- W(this, "setMute", (D = !0) => {
759
+ K(this, "setMute", (D = !0) => {
759
760
  D ? this.analyserNode.disconnect(this.audioContext.destination) : this.analyserNode.connect(this.audioContext.destination);
760
761
  });
761
762
  /**
762
763
  * 设置音量
763
764
  */
764
- W(this, "setVolumeGain", (D) => {
765
+ K(this, "setVolumeGain", (D) => {
765
766
  this.gainNode.gain.setValueAtTime(D, this.audioContext.currentTime);
766
767
  });
767
768
  /**
768
769
  * 获取音量
769
770
  */
770
- W(this, "getVolume", () => {
771
+ K(this, "getVolume", () => {
771
772
  const { analyserNode: D, analyserArrayData: $ } = this;
772
773
  D.getByteFrequencyData($);
773
774
  let U = 0;
@@ -778,12 +779,12 @@ class AudioMediaStreamContext {
778
779
  /**
779
780
  * 设置音频过滤
780
781
  */
781
- W(this, "setFilter", (D = {}) => {
782
+ K(this, "setFilter", (D = {}) => {
782
783
  this.options = { ...this.options, ...D };
783
784
  const { autoGainControl: $, noiseSuppression: U, echoCancellation: R } = this.options, { mediaStreamAudioSourceNode: N, autoGainNode: e, biquadFilterNode: o, delayNode: A, gainNode: M } = this, L = N;
784
785
  return $ && L.connect(e), U && L.connect(o), R && L.connect(A), L.connect(M), D;
785
786
  });
786
- this.stream = D, this.audio.srcObject = this.stream, this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.autoGainNode = this.audioContext.createGain(), this.autoGainNode.gain.setValueAtTime(0.8, this.audioContext.currentTime), this.biquadFilterNode = this.audioContext.createBiquadFilter(), this.biquadFilterNode.type = "lowpass", this.biquadFilterNode.frequency.value = 1e3, this.delayNode = this.audioContext.createDelay(), this.delayNode.delayTime.value = 0.5, this.gainNode = this.audioContext.createGain(), this.gainNode.gain.setValueAtTime(0.5, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 1024, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
787
+ this.stream.addTrack(D), this.audio.srcObject = this.stream, this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.autoGainNode = this.audioContext.createGain(), this.autoGainNode.gain.setValueAtTime(0.8, this.audioContext.currentTime), this.biquadFilterNode = this.audioContext.createBiquadFilter(), this.biquadFilterNode.type = "lowpass", this.biquadFilterNode.frequency.value = 1e3, this.delayNode = this.audioContext.createDelay(), this.delayNode.delayTime.value = 0.5, this.gainNode = this.audioContext.createGain(), this.gainNode.gain.setValueAtTime(0.5, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 1024, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
787
788
  const { gainNode: $, analyserNode: U } = this;
788
789
  $.connect(U), this.audioContext.state === "suspended" ? document.addEventListener(
789
790
  "touchend",
@@ -794,13 +795,14 @@ class AudioMediaStreamContext {
794
795
  ) : this.setFilter();
795
796
  }
796
797
  }
797
- class VideoMediaStreamContext {
798
+ class VideoMediaContext {
798
799
  constructor(D) {
799
- W(this, "stream");
800
+ K(this, "kind", "video");
801
+ K(this, "stream", new MediaStream());
800
802
  /**
801
803
  * 停止
802
804
  */
803
- W(this, "stop", () => {
805
+ K(this, "stop", () => {
804
806
  const D = this.stream.getTracks();
805
807
  for (const $ of D)
806
808
  $.enabled = !1, $.stop(), this.stream.removeTrack($);
@@ -808,7 +810,7 @@ class VideoMediaStreamContext {
808
810
  /**
809
811
  * 替换媒体
810
812
  */
811
- W(this, "replaceStream", (D) => {
813
+ K(this, "replaceStream", (D) => {
812
814
  this.stop();
813
815
  const [$] = D.getVideoTracks();
814
816
  this.stream.addTrack($);
@@ -816,8 +818,8 @@ class VideoMediaStreamContext {
816
818
  /**
817
819
  * 获取数据流
818
820
  */
819
- W(this, "getStream", () => this.stream);
820
- this.stream = D;
821
+ K(this, "getStream", () => this.stream);
822
+ this.stream.addTrack(D);
821
823
  }
822
824
  }
823
825
  const enum_roomState = {
@@ -1109,15 +1111,15 @@ function requireFloat() {
1109
1111
  if (F < 22250738585072014e-324)
1110
1112
  V = F / 5e-324, A(V >>> 0, Z, H + M), A((z << 31 | V / 4294967296) >>> 0, Z, H + L);
1111
1113
  else {
1112
- var K = Math.floor(Math.log(F) / Math.LN2);
1113
- K === 1024 && (K = 1023), V = F * Math.pow(2, -K), A(V * 4503599627370496 >>> 0, Z, H + M), A((z << 31 | K + 1023 << 20 | V * 1048576 & 1048575) >>> 0, Z, H + L);
1114
+ var W = Math.floor(Math.log(F) / Math.LN2);
1115
+ W === 1024 && (W = 1023), V = F * Math.pow(2, -W), A(V * 4503599627370496 >>> 0, Z, H + M), A((z << 31 | W + 1023 << 20 | V * 1048576 & 1048575) >>> 0, Z, H + L);
1114
1116
  }
1115
1117
  }
1116
1118
  }
1117
1119
  N.writeDoubleLE = e.bind(null, D, 0, 4), N.writeDoubleBE = e.bind(null, $, 4, 0);
1118
1120
  function o(A, M, L, F, Z) {
1119
- var H = A(F, Z + M), z = A(F, Z + L), V = (z >> 31) * 2 + 1, K = z >>> 20 & 2047, J = 4294967296 * (z & 1048575) + H;
1120
- return K === 2047 ? J ? NaN : V * (1 / 0) : K === 0 ? V * 5e-324 * J : V * Math.pow(2, K - 1075) * (J + 4503599627370496);
1121
+ var H = A(F, Z + M), z = A(F, Z + L), V = (z >> 31) * 2 + 1, W = z >>> 20 & 2047, J = 4294967296 * (z & 1048575) + H;
1122
+ return W === 2047 ? J ? NaN : V * (1 / 0) : W === 0 ? V * 5e-324 * J : V * Math.pow(2, W - 1075) * (J + 4503599627370496);
1121
1123
  }
1122
1124
  N.readDoubleLE = o.bind(null, U, 0, 4), N.readDoubleBE = o.bind(null, R, 4, 0);
1123
1125
  }(), N;
@@ -1390,13 +1392,13 @@ function requireWriter() {
1390
1392
  if (hasRequiredWriter) return writer;
1391
1393
  hasRequiredWriter = 1, writer = A;
1392
1394
  var _ = requireMinimal$1(), D, $ = _.LongBits, U = _.base64, R = _.utf8;
1393
- function N(K, J, G) {
1394
- this.fn = K, this.len = J, this.next = void 0, this.val = G;
1395
+ function N(W, J, Y) {
1396
+ this.fn = W, this.len = J, this.next = void 0, this.val = Y;
1395
1397
  }
1396
1398
  function e() {
1397
1399
  }
1398
- function o(K) {
1399
- this.head = K.head, this.tail = K.tail, this.len = K.len, this.next = K.states;
1400
+ function o(W) {
1401
+ this.head = W.head, this.tail = W.tail, this.len = W.len, this.next = W.states;
1400
1402
  }
1401
1403
  function A() {
1402
1404
  this.len = 0, this.head = new N(e, 0, 0), this.tail = this.head, this.states = null;
@@ -1412,19 +1414,19 @@ function requireWriter() {
1412
1414
  };
1413
1415
  A.create = M(), A.alloc = function(J) {
1414
1416
  return new _.Array(J);
1415
- }, _.Array !== Array && (A.alloc = _.pool(A.alloc, _.Array.prototype.subarray)), A.prototype._push = function(J, G, tt) {
1416
- return this.tail = this.tail.next = new N(J, G, tt), this.len += G, this;
1417
+ }, _.Array !== Array && (A.alloc = _.pool(A.alloc, _.Array.prototype.subarray)), A.prototype._push = function(J, Y, tt) {
1418
+ return this.tail = this.tail.next = new N(J, Y, tt), this.len += Y, this;
1417
1419
  };
1418
- function L(K, J, G) {
1419
- J[G] = K & 255;
1420
+ function L(W, J, Y) {
1421
+ J[Y] = W & 255;
1420
1422
  }
1421
- function F(K, J, G) {
1422
- for (; K > 127; )
1423
- J[G++] = K & 127 | 128, K >>>= 7;
1424
- J[G] = K;
1423
+ function F(W, J, Y) {
1424
+ for (; W > 127; )
1425
+ J[Y++] = W & 127 | 128, W >>>= 7;
1426
+ J[Y] = W;
1425
1427
  }
1426
- function Z(K, J) {
1427
- this.len = K, this.next = void 0, this.val = J;
1428
+ function Z(W, J) {
1429
+ this.len = W, this.next = void 0, this.val = J;
1428
1430
  }
1429
1431
  Z.prototype = Object.create(N.prototype), Z.prototype.fn = F, A.prototype.uint32 = function(J) {
1430
1432
  return this.len += (this.tail = this.tail.next = new Z(
@@ -1436,66 +1438,66 @@ function requireWriter() {
1436
1438
  }, A.prototype.sint32 = function(J) {
1437
1439
  return this.uint32((J << 1 ^ J >> 31) >>> 0);
1438
1440
  };
1439
- function H(K, J, G) {
1440
- for (; K.hi; )
1441
- J[G++] = K.lo & 127 | 128, K.lo = (K.lo >>> 7 | K.hi << 25) >>> 0, K.hi >>>= 7;
1442
- for (; K.lo > 127; )
1443
- J[G++] = K.lo & 127 | 128, K.lo = K.lo >>> 7;
1444
- J[G++] = K.lo;
1441
+ function H(W, J, Y) {
1442
+ for (; W.hi; )
1443
+ J[Y++] = W.lo & 127 | 128, W.lo = (W.lo >>> 7 | W.hi << 25) >>> 0, W.hi >>>= 7;
1444
+ for (; W.lo > 127; )
1445
+ J[Y++] = W.lo & 127 | 128, W.lo = W.lo >>> 7;
1446
+ J[Y++] = W.lo;
1445
1447
  }
1446
1448
  A.prototype.uint64 = function(J) {
1447
- var G = $.from(J);
1448
- return this._push(H, G.length(), G);
1449
+ var Y = $.from(J);
1450
+ return this._push(H, Y.length(), Y);
1449
1451
  }, A.prototype.int64 = A.prototype.uint64, A.prototype.sint64 = function(J) {
1450
- var G = $.from(J).zzEncode();
1451
- return this._push(H, G.length(), G);
1452
+ var Y = $.from(J).zzEncode();
1453
+ return this._push(H, Y.length(), Y);
1452
1454
  }, A.prototype.bool = function(J) {
1453
1455
  return this._push(L, 1, J ? 1 : 0);
1454
1456
  };
1455
- function z(K, J, G) {
1456
- J[G] = K & 255, J[G + 1] = K >>> 8 & 255, J[G + 2] = K >>> 16 & 255, J[G + 3] = K >>> 24;
1457
+ function z(W, J, Y) {
1458
+ J[Y] = W & 255, J[Y + 1] = W >>> 8 & 255, J[Y + 2] = W >>> 16 & 255, J[Y + 3] = W >>> 24;
1457
1459
  }
1458
1460
  A.prototype.fixed32 = function(J) {
1459
1461
  return this._push(z, 4, J >>> 0);
1460
1462
  }, A.prototype.sfixed32 = A.prototype.fixed32, A.prototype.fixed64 = function(J) {
1461
- var G = $.from(J);
1462
- return this._push(z, 4, G.lo)._push(z, 4, G.hi);
1463
+ var Y = $.from(J);
1464
+ return this._push(z, 4, Y.lo)._push(z, 4, Y.hi);
1463
1465
  }, A.prototype.sfixed64 = A.prototype.fixed64, A.prototype.float = function(J) {
1464
1466
  return this._push(_.float.writeFloatLE, 4, J);
1465
1467
  }, A.prototype.double = function(J) {
1466
1468
  return this._push(_.float.writeDoubleLE, 8, J);
1467
1469
  };
1468
- var V = _.Array.prototype.set ? function(J, G, tt) {
1469
- G.set(J, tt);
1470
- } : function(J, G, tt) {
1471
- for (var Y = 0; Y < J.length; ++Y)
1472
- G[tt + Y] = J[Y];
1470
+ var V = _.Array.prototype.set ? function(J, Y, tt) {
1471
+ Y.set(J, tt);
1472
+ } : function(J, Y, tt) {
1473
+ for (var X = 0; X < J.length; ++X)
1474
+ Y[tt + X] = J[X];
1473
1475
  };
1474
1476
  return A.prototype.bytes = function(J) {
1475
- var G = J.length >>> 0;
1476
- if (!G)
1477
+ var Y = J.length >>> 0;
1478
+ if (!Y)
1477
1479
  return this._push(L, 1, 0);
1478
1480
  if (_.isString(J)) {
1479
- var tt = A.alloc(G = U.length(J));
1481
+ var tt = A.alloc(Y = U.length(J));
1480
1482
  U.decode(J, tt, 0), J = tt;
1481
1483
  }
1482
- return this.uint32(G)._push(V, G, J);
1484
+ return this.uint32(Y)._push(V, Y, J);
1483
1485
  }, A.prototype.string = function(J) {
1484
- var G = R.length(J);
1485
- return G ? this.uint32(G)._push(R.write, G, J) : this._push(L, 1, 0);
1486
+ var Y = R.length(J);
1487
+ return Y ? this.uint32(Y)._push(R.write, Y, J) : this._push(L, 1, 0);
1486
1488
  }, A.prototype.fork = function() {
1487
1489
  return this.states = new o(this), this.head = this.tail = new N(e, 0, 0), this.len = 0, this;
1488
1490
  }, A.prototype.reset = function() {
1489
1491
  return this.states ? (this.head = this.states.head, this.tail = this.states.tail, this.len = this.states.len, this.states = this.states.next) : (this.head = this.tail = new N(e, 0, 0), this.len = 0), this;
1490
1492
  }, A.prototype.ldelim = function() {
1491
- var J = this.head, G = this.tail, tt = this.len;
1492
- return this.reset().uint32(tt), tt && (this.tail.next = J.next, this.tail = G, this.len += tt), this;
1493
+ var J = this.head, Y = this.tail, tt = this.len;
1494
+ return this.reset().uint32(tt), tt && (this.tail.next = J.next, this.tail = Y, this.len += tt), this;
1493
1495
  }, A.prototype.finish = function() {
1494
- for (var J = this.head.next, G = this.constructor.alloc(this.len), tt = 0; J; )
1495
- J.fn(J.val, G, tt), tt += J.len, J = J.next;
1496
- return G;
1497
- }, A._configure = function(K) {
1498
- D = K, A.create = M(), D._configure();
1496
+ for (var J = this.head.next, Y = this.constructor.alloc(this.len), tt = 0; J; )
1497
+ J.fn(J.val, Y, tt), tt += J.len, J = J.next;
1498
+ return Y;
1499
+ }, A._configure = function(W) {
1500
+ D = W, A.create = M(), D._configure();
1499
1501
  }, writer;
1500
1502
  }
1501
1503
  var writer_buffer, hasRequiredWriter_buffer;
@@ -4370,6 +4372,69 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
4370
4372
  }, R.getTypeUrl = function(e) {
4371
4373
  return e === void 0 && (e = "type.googleapis.com"), e + "/com.quick.voice.proto.ToggleLiveRoomRsq";
4372
4374
  }, R;
4375
+ }(), U.CDNPlayAddressNotify = function() {
4376
+ function R(N) {
4377
+ if (N)
4378
+ for (let e = Object.keys(N), o = 0; o < e.length; ++o)
4379
+ N[e[o]] != null && (this[e[o]] = N[e[o]]);
4380
+ }
4381
+ return R.prototype.roomId = "", R.prototype.m3u8 = "", R.prototype.rtmp = "", R.create = function(e) {
4382
+ return new R(e);
4383
+ }, R.encode = function(e, o) {
4384
+ return o || (o = $Writer.create()), e.roomId != null && Object.hasOwnProperty.call(e, "roomId") && o.uint32(
4385
+ /* id 1, wireType 2 =*/
4386
+ 10
4387
+ ).string(e.roomId), e.m3u8 != null && Object.hasOwnProperty.call(e, "m3u8") && o.uint32(
4388
+ /* id 2, wireType 2 =*/
4389
+ 18
4390
+ ).string(e.m3u8), e.rtmp != null && Object.hasOwnProperty.call(e, "rtmp") && o.uint32(
4391
+ /* id 3, wireType 2 =*/
4392
+ 26
4393
+ ).string(e.rtmp), o;
4394
+ }, R.encodeDelimited = function(e, o) {
4395
+ return this.encode(e, o).ldelim();
4396
+ }, R.decode = function(e, o) {
4397
+ e instanceof $Reader || (e = $Reader.create(e));
4398
+ let A = o === void 0 ? e.len : e.pos + o, M = new $root.com.quick.voice.proto.CDNPlayAddressNotify();
4399
+ for (; e.pos < A; ) {
4400
+ let L = e.uint32();
4401
+ switch (L >>> 3) {
4402
+ case 1: {
4403
+ M.roomId = e.string();
4404
+ break;
4405
+ }
4406
+ case 2: {
4407
+ M.m3u8 = e.string();
4408
+ break;
4409
+ }
4410
+ case 3: {
4411
+ M.rtmp = e.string();
4412
+ break;
4413
+ }
4414
+ default:
4415
+ e.skipType(L & 7);
4416
+ break;
4417
+ }
4418
+ }
4419
+ return M;
4420
+ }, R.decodeDelimited = function(e) {
4421
+ return e instanceof $Reader || (e = new $Reader(e)), this.decode(e, e.uint32());
4422
+ }, R.verify = function(e) {
4423
+ return typeof e != "object" || e === null ? "object expected" : e.roomId != null && e.hasOwnProperty("roomId") && !$util.isString(e.roomId) ? "roomId: string expected" : e.m3u8 != null && e.hasOwnProperty("m3u8") && !$util.isString(e.m3u8) ? "m3u8: string expected" : e.rtmp != null && e.hasOwnProperty("rtmp") && !$util.isString(e.rtmp) ? "rtmp: string expected" : null;
4424
+ }, R.fromObject = function(e) {
4425
+ if (e instanceof $root.com.quick.voice.proto.CDNPlayAddressNotify)
4426
+ return e;
4427
+ let o = new $root.com.quick.voice.proto.CDNPlayAddressNotify();
4428
+ return e.roomId != null && (o.roomId = String(e.roomId)), e.m3u8 != null && (o.m3u8 = String(e.m3u8)), e.rtmp != null && (o.rtmp = String(e.rtmp)), o;
4429
+ }, R.toObject = function(e, o) {
4430
+ o || (o = {});
4431
+ let A = {};
4432
+ return o.defaults && (A.roomId = "", A.m3u8 = "", A.rtmp = ""), e.roomId != null && e.hasOwnProperty("roomId") && (A.roomId = e.roomId), e.m3u8 != null && e.hasOwnProperty("m3u8") && (A.m3u8 = e.m3u8), e.rtmp != null && e.hasOwnProperty("rtmp") && (A.rtmp = e.rtmp), A;
4433
+ }, R.prototype.toJSON = function() {
4434
+ return this.constructor.toObject(this, minimalExports.util.toJSONOptions);
4435
+ }, R.getTypeUrl = function(e) {
4436
+ return e === void 0 && (e = "type.googleapis.com"), e + "/com.quick.voice.proto.CDNPlayAddressNotify";
4437
+ }, R;
4373
4438
  }(), U.TrackType = function() {
4374
4439
  const R = {}, N = Object.create(R);
4375
4440
  return N[R[0] = "Microphone"] = 0, N[R[1] = "Camera"] = 1, N[R[2] = "Screen"] = 2, N[R[3] = "SystemVoice"] = 3, N;
@@ -4544,14 +4609,18 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
4544
4609
  healthCheck: "心跳检测",
4545
4610
  onNetQuality: "网络质量回调",
4546
4611
  onLogin: "登录回调",
4547
- onLocalStream: "更新本地媒体流",
4548
- onRoomUsers: "房间用户变化",
4612
+ onLocalStream: "本地媒体流发生变化",
4613
+ onDevicechange: "媒体设备发生变化",
4614
+ onRoomUser: "房间用户变化",
4615
+ onRoomUsers: "房间所有用户所有变化",
4616
+ onRoomUsersStreams: "房间某些用户媒体流变化",
4549
4617
  onRoomState: "房间状态变化",
4550
4618
  onJoinRoom: "加入房间回调",
4551
4619
  onQuitRoom: "退出房间回调",
4552
4620
  onPublish: "监听到流发布",
4553
4621
  onCloseTrack: "关闭轨道",
4554
4622
  onUpdateCall: "更新通讯状态",
4623
+ onUpdateStreams: "更新媒体流",
4555
4624
  onUpdatePermissions: "更新推流权限通知",
4556
4625
  onTokenExpired: "Token已过期",
4557
4626
  onDestroyRoom: "直播模式房间销毁",
@@ -5411,71 +5480,71 @@ var Deflate_1$1 = Deflate$1, deflate_2 = deflate$1, deflateRaw_1$1 = deflateRaw$
5411
5480
  };
5412
5481
  const BAD$1 = 16209, TYPE$1 = 16191;
5413
5482
  var inffast = function _(D, $) {
5414
- let U, R, N, e, o, A, M, L, F, Z, H, z, V, K, J, G, tt, Y, nt, st, et, at, ct, ot;
5483
+ let U, R, N, e, o, A, M, L, F, Z, H, z, V, W, J, Y, tt, X, nt, lt, et, at, ct, ot;
5415
5484
  const rt = D.state;
5416
- U = D.next_in, ct = D.input, R = U + (D.avail_in - 5), N = D.next_out, ot = D.output, e = N - ($ - D.avail_out), o = N + (D.avail_out - 257), A = rt.dmax, M = rt.wsize, L = rt.whave, F = rt.wnext, Z = rt.window, H = rt.hold, z = rt.bits, V = rt.lencode, K = rt.distcode, J = (1 << rt.lenbits) - 1, G = (1 << rt.distbits) - 1;
5485
+ U = D.next_in, ct = D.input, R = U + (D.avail_in - 5), N = D.next_out, ot = D.output, e = N - ($ - D.avail_out), o = N + (D.avail_out - 257), A = rt.dmax, M = rt.wsize, L = rt.whave, F = rt.wnext, Z = rt.window, H = rt.hold, z = rt.bits, V = rt.lencode, W = rt.distcode, J = (1 << rt.lenbits) - 1, Y = (1 << rt.distbits) - 1;
5417
5486
  t:
5418
5487
  do {
5419
5488
  z < 15 && (H += ct[U++] << z, z += 8, H += ct[U++] << z, z += 8), tt = V[H & J];
5420
5489
  e:
5421
5490
  for (; ; ) {
5422
- if (Y = tt >>> 24, H >>>= Y, z -= Y, Y = tt >>> 16 & 255, Y === 0)
5491
+ if (X = tt >>> 24, H >>>= X, z -= X, X = tt >>> 16 & 255, X === 0)
5423
5492
  ot[N++] = tt & 65535;
5424
- else if (Y & 16) {
5425
- nt = tt & 65535, Y &= 15, Y && (z < Y && (H += ct[U++] << z, z += 8), nt += H & (1 << Y) - 1, H >>>= Y, z -= Y), z < 15 && (H += ct[U++] << z, z += 8, H += ct[U++] << z, z += 8), tt = K[H & G];
5493
+ else if (X & 16) {
5494
+ nt = tt & 65535, X &= 15, X && (z < X && (H += ct[U++] << z, z += 8), nt += H & (1 << X) - 1, H >>>= X, z -= X), z < 15 && (H += ct[U++] << z, z += 8, H += ct[U++] << z, z += 8), tt = W[H & Y];
5426
5495
  i:
5427
5496
  for (; ; ) {
5428
- if (Y = tt >>> 24, H >>>= Y, z -= Y, Y = tt >>> 16 & 255, Y & 16) {
5429
- if (st = tt & 65535, Y &= 15, z < Y && (H += ct[U++] << z, z += 8, z < Y && (H += ct[U++] << z, z += 8)), st += H & (1 << Y) - 1, st > A) {
5497
+ if (X = tt >>> 24, H >>>= X, z -= X, X = tt >>> 16 & 255, X & 16) {
5498
+ if (lt = tt & 65535, X &= 15, z < X && (H += ct[U++] << z, z += 8, z < X && (H += ct[U++] << z, z += 8)), lt += H & (1 << X) - 1, lt > A) {
5430
5499
  D.msg = "invalid distance too far back", rt.mode = BAD$1;
5431
5500
  break t;
5432
5501
  }
5433
- if (H >>>= Y, z -= Y, Y = N - e, st > Y) {
5434
- if (Y = st - Y, Y > L && rt.sane) {
5502
+ if (H >>>= X, z -= X, X = N - e, lt > X) {
5503
+ if (X = lt - X, X > L && rt.sane) {
5435
5504
  D.msg = "invalid distance too far back", rt.mode = BAD$1;
5436
5505
  break t;
5437
5506
  }
5438
5507
  if (et = 0, at = Z, F === 0) {
5439
- if (et += M - Y, Y < nt) {
5440
- nt -= Y;
5508
+ if (et += M - X, X < nt) {
5509
+ nt -= X;
5441
5510
  do
5442
5511
  ot[N++] = Z[et++];
5443
- while (--Y);
5444
- et = N - st, at = ot;
5512
+ while (--X);
5513
+ et = N - lt, at = ot;
5445
5514
  }
5446
- } else if (F < Y) {
5447
- if (et += M + F - Y, Y -= F, Y < nt) {
5448
- nt -= Y;
5515
+ } else if (F < X) {
5516
+ if (et += M + F - X, X -= F, X < nt) {
5517
+ nt -= X;
5449
5518
  do
5450
5519
  ot[N++] = Z[et++];
5451
- while (--Y);
5520
+ while (--X);
5452
5521
  if (et = 0, F < nt) {
5453
- Y = F, nt -= Y;
5522
+ X = F, nt -= X;
5454
5523
  do
5455
5524
  ot[N++] = Z[et++];
5456
- while (--Y);
5457
- et = N - st, at = ot;
5525
+ while (--X);
5526
+ et = N - lt, at = ot;
5458
5527
  }
5459
5528
  }
5460
- } else if (et += F - Y, Y < nt) {
5461
- nt -= Y;
5529
+ } else if (et += F - X, X < nt) {
5530
+ nt -= X;
5462
5531
  do
5463
5532
  ot[N++] = Z[et++];
5464
- while (--Y);
5465
- et = N - st, at = ot;
5533
+ while (--X);
5534
+ et = N - lt, at = ot;
5466
5535
  }
5467
5536
  for (; nt > 2; )
5468
5537
  ot[N++] = at[et++], ot[N++] = at[et++], ot[N++] = at[et++], nt -= 3;
5469
5538
  nt && (ot[N++] = at[et++], nt > 1 && (ot[N++] = at[et++]));
5470
5539
  } else {
5471
- et = N - st;
5540
+ et = N - lt;
5472
5541
  do
5473
5542
  ot[N++] = ot[et++], ot[N++] = ot[et++], ot[N++] = ot[et++], nt -= 3;
5474
5543
  while (nt > 2);
5475
5544
  nt && (ot[N++] = ot[et++], nt > 1 && (ot[N++] = ot[et++]));
5476
5545
  }
5477
- } else if ((Y & 64) === 0) {
5478
- tt = K[(tt & 65535) + (H & (1 << Y) - 1)];
5546
+ } else if ((X & 64) === 0) {
5547
+ tt = W[(tt & 65535) + (H & (1 << X) - 1)];
5479
5548
  continue i;
5480
5549
  } else {
5481
5550
  D.msg = "invalid distance code", rt.mode = BAD$1;
@@ -5483,10 +5552,10 @@ var inffast = function _(D, $) {
5483
5552
  }
5484
5553
  break;
5485
5554
  }
5486
- } else if ((Y & 64) === 0) {
5487
- tt = V[(tt & 65535) + (H & (1 << Y) - 1)];
5555
+ } else if ((X & 64) === 0) {
5556
+ tt = V[(tt & 65535) + (H & (1 << X) - 1)];
5488
5557
  continue e;
5489
- } else if (Y & 32) {
5558
+ } else if (X & 32) {
5490
5559
  rt.mode = TYPE$1;
5491
5560
  break t;
5492
5561
  } else {
@@ -5634,9 +5703,9 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
5634
5703
  64
5635
5704
  ]), inflate_table = (_, D, $, U, R, N, e, o) => {
5636
5705
  const A = o.bits;
5637
- let M = 0, L = 0, F = 0, Z = 0, H = 0, z = 0, V = 0, K = 0, J = 0, G = 0, tt, Y, nt, st, et, at = null, ct;
5706
+ let M = 0, L = 0, F = 0, Z = 0, H = 0, z = 0, V = 0, W = 0, J = 0, Y = 0, tt, X, nt, lt, et, at = null, ct;
5638
5707
  const ot = new Uint16Array(MAXBITS + 1), rt = new Uint16Array(MAXBITS + 1);
5639
- let bt = null, Zt, It, Rt;
5708
+ let St = null, Gt, Nt, At;
5640
5709
  for (M = 0; M <= MAXBITS; M++)
5641
5710
  ot[M] = 0;
5642
5711
  for (L = 0; L < U; L++)
@@ -5647,38 +5716,38 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
5647
5716
  return R[N++] = 1 << 24 | 64 << 16 | 0, R[N++] = 1 << 24 | 64 << 16 | 0, o.bits = 1, 0;
5648
5717
  for (F = 1; F < Z && ot[F] === 0; F++)
5649
5718
  ;
5650
- for (H < F && (H = F), K = 1, M = 1; M <= MAXBITS; M++)
5651
- if (K <<= 1, K -= ot[M], K < 0)
5719
+ for (H < F && (H = F), W = 1, M = 1; M <= MAXBITS; M++)
5720
+ if (W <<= 1, W -= ot[M], W < 0)
5652
5721
  return -1;
5653
- if (K > 0 && (_ === CODES$1 || Z !== 1))
5722
+ if (W > 0 && (_ === CODES$1 || Z !== 1))
5654
5723
  return -1;
5655
5724
  for (rt[1] = 0, M = 1; M < MAXBITS; M++)
5656
5725
  rt[M + 1] = rt[M] + ot[M];
5657
5726
  for (L = 0; L < U; L++)
5658
5727
  D[$ + L] !== 0 && (e[rt[D[$ + L]]++] = L);
5659
- if (_ === CODES$1 ? (at = bt = e, ct = 20) : _ === LENS$1 ? (at = lbase, bt = lext, ct = 257) : (at = dbase, bt = dext, ct = 0), G = 0, L = 0, M = F, et = N, z = H, V = 0, nt = -1, J = 1 << H, st = J - 1, _ === LENS$1 && J > ENOUGH_LENS$1 || _ === DISTS$1 && J > ENOUGH_DISTS$1)
5728
+ if (_ === CODES$1 ? (at = St = e, ct = 20) : _ === LENS$1 ? (at = lbase, St = lext, ct = 257) : (at = dbase, St = dext, ct = 0), Y = 0, L = 0, M = F, et = N, z = H, V = 0, nt = -1, J = 1 << H, lt = J - 1, _ === LENS$1 && J > ENOUGH_LENS$1 || _ === DISTS$1 && J > ENOUGH_DISTS$1)
5660
5729
  return 1;
5661
5730
  for (; ; ) {
5662
- Zt = M - V, e[L] + 1 < ct ? (It = 0, Rt = e[L]) : e[L] >= ct ? (It = bt[e[L] - ct], Rt = at[e[L] - ct]) : (It = 96, Rt = 0), tt = 1 << M - V, Y = 1 << z, F = Y;
5731
+ Gt = M - V, e[L] + 1 < ct ? (Nt = 0, At = e[L]) : e[L] >= ct ? (Nt = St[e[L] - ct], At = at[e[L] - ct]) : (Nt = 96, At = 0), tt = 1 << M - V, X = 1 << z, F = X;
5663
5732
  do
5664
- Y -= tt, R[et + (G >> V) + Y] = Zt << 24 | It << 16 | Rt | 0;
5665
- while (Y !== 0);
5666
- for (tt = 1 << M - 1; G & tt; )
5733
+ X -= tt, R[et + (Y >> V) + X] = Gt << 24 | Nt << 16 | At | 0;
5734
+ while (X !== 0);
5735
+ for (tt = 1 << M - 1; Y & tt; )
5667
5736
  tt >>= 1;
5668
- if (tt !== 0 ? (G &= tt - 1, G += tt) : G = 0, L++, --ot[M] === 0) {
5737
+ if (tt !== 0 ? (Y &= tt - 1, Y += tt) : Y = 0, L++, --ot[M] === 0) {
5669
5738
  if (M === Z)
5670
5739
  break;
5671
5740
  M = D[$ + e[L]];
5672
5741
  }
5673
- if (M > H && (G & st) !== nt) {
5674
- for (V === 0 && (V = H), et += F, z = M - V, K = 1 << z; z + V < Z && (K -= ot[z + V], !(K <= 0)); )
5675
- z++, K <<= 1;
5742
+ if (M > H && (Y & lt) !== nt) {
5743
+ for (V === 0 && (V = H), et += F, z = M - V, W = 1 << z; z + V < Z && (W -= ot[z + V], !(W <= 0)); )
5744
+ z++, W <<= 1;
5676
5745
  if (J += 1 << z, _ === LENS$1 && J > ENOUGH_LENS$1 || _ === DISTS$1 && J > ENOUGH_DISTS$1)
5677
5746
  return 1;
5678
- nt = G & st, R[nt] = H << 24 | z << 16 | et - N | 0;
5747
+ nt = Y & lt, R[nt] = H << 24 | z << 16 | et - N | 0;
5679
5748
  }
5680
5749
  }
5681
- return G !== 0 && (R[et + G] = M - V << 24 | 64 << 16 | 0), o.bits = H, 0;
5750
+ return Y !== 0 && (R[et + Y] = M - V << 24 | 64 << 16 | 0), o.bits = H, 0;
5682
5751
  };
5683
5752
  var inftrees = inflate_table;
5684
5753
  const CODES = 0, LENS = 1, DISTS = 2, {
@@ -5749,10 +5818,10 @@ const fixedtables = (_) => {
5749
5818
  const N = _.state;
5750
5819
  return N.window === null && (N.wsize = 1 << N.wbits, N.wnext = 0, N.whave = 0, N.window = new Uint8Array(N.wsize)), U >= N.wsize ? (N.window.set(D.subarray($ - N.wsize, $), 0), N.wnext = 0, N.whave = N.wsize) : (R = N.wsize - N.wnext, R > U && (R = U), N.window.set(D.subarray($ - U, $ - U + R), N.wnext), U -= R, U ? (N.window.set(D.subarray($ - U, $), 0), N.wnext = U, N.whave = N.wsize) : (N.wnext += R, N.wnext === N.wsize && (N.wnext = 0), N.whave < N.wsize && (N.whave += R))), 0;
5751
5820
  }, inflate$2 = (_, D) => {
5752
- let $, U, R, N, e, o, A, M, L, F, Z, H, z, V, K = 0, J, G, tt, Y, nt, st, et, at;
5821
+ let $, U, R, N, e, o, A, M, L, F, Z, H, z, V, W = 0, J, Y, tt, X, nt, lt, et, at;
5753
5822
  const ct = new Uint8Array(4);
5754
5823
  let ot, rt;
5755
- const bt = (
5824
+ const St = (
5756
5825
  /* permutation of code lengths */
5757
5826
  new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])
5758
5827
  );
@@ -5978,10 +6047,10 @@ const fixedtables = (_) => {
5978
6047
  break t;
5979
6048
  o--, M += U[N++] << L, L += 8;
5980
6049
  }
5981
- $.lens[bt[$.have++]] = M & 7, M >>>= 3, L -= 3;
6050
+ $.lens[St[$.have++]] = M & 7, M >>>= 3, L -= 3;
5982
6051
  }
5983
6052
  for (; $.have < 19; )
5984
- $.lens[bt[$.have++]] = 0;
6053
+ $.lens[St[$.have++]] = 0;
5985
6054
  if ($.lencode = $.lendyn, $.lenbits = 7, ot = { bits: $.lenbits }, at = inftrees(CODES, $.lens, 0, 19, $.lencode, 0, $.work, ot), $.lenbits = ot.bits, at) {
5986
6055
  _.msg = "invalid code lengths set", $.mode = BAD;
5987
6056
  break;
@@ -5990,7 +6059,7 @@ const fixedtables = (_) => {
5990
6059
  /* falls through */
5991
6060
  case CODELENS:
5992
6061
  for (; $.have < $.nlen + $.ndist; ) {
5993
- for (; K = $.lencode[M & (1 << $.lenbits) - 1], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(J <= L); ) {
6062
+ for (; W = $.lencode[M & (1 << $.lenbits) - 1], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(J <= L); ) {
5994
6063
  if (o === 0)
5995
6064
  break t;
5996
6065
  o--, M += U[N++] << L, L += 8;
@@ -6057,32 +6126,32 @@ const fixedtables = (_) => {
6057
6126
  _.next_out = e, _.avail_out = A, _.next_in = N, _.avail_in = o, $.hold = M, $.bits = L, inffast(_, Z), e = _.next_out, R = _.output, A = _.avail_out, N = _.next_in, U = _.input, o = _.avail_in, M = $.hold, L = $.bits, $.mode === TYPE && ($.back = -1);
6058
6127
  break;
6059
6128
  }
6060
- for ($.back = 0; K = $.lencode[M & (1 << $.lenbits) - 1], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(J <= L); ) {
6129
+ for ($.back = 0; W = $.lencode[M & (1 << $.lenbits) - 1], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(J <= L); ) {
6061
6130
  if (o === 0)
6062
6131
  break t;
6063
6132
  o--, M += U[N++] << L, L += 8;
6064
6133
  }
6065
- if (G && (G & 240) === 0) {
6066
- for (Y = J, nt = G, st = tt; K = $.lencode[st + ((M & (1 << Y + nt) - 1) >> Y)], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(Y + J <= L); ) {
6134
+ if (Y && (Y & 240) === 0) {
6135
+ for (X = J, nt = Y, lt = tt; W = $.lencode[lt + ((M & (1 << X + nt) - 1) >> X)], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(X + J <= L); ) {
6067
6136
  if (o === 0)
6068
6137
  break t;
6069
6138
  o--, M += U[N++] << L, L += 8;
6070
6139
  }
6071
- M >>>= Y, L -= Y, $.back += Y;
6140
+ M >>>= X, L -= X, $.back += X;
6072
6141
  }
6073
- if (M >>>= J, L -= J, $.back += J, $.length = tt, G === 0) {
6142
+ if (M >>>= J, L -= J, $.back += J, $.length = tt, Y === 0) {
6074
6143
  $.mode = LIT;
6075
6144
  break;
6076
6145
  }
6077
- if (G & 32) {
6146
+ if (Y & 32) {
6078
6147
  $.back = -1, $.mode = TYPE;
6079
6148
  break;
6080
6149
  }
6081
- if (G & 64) {
6150
+ if (Y & 64) {
6082
6151
  _.msg = "invalid literal/length code", $.mode = BAD;
6083
6152
  break;
6084
6153
  }
6085
- $.extra = G & 15, $.mode = LENEXT;
6154
+ $.extra = Y & 15, $.mode = LENEXT;
6086
6155
  /* falls through */
6087
6156
  case LENEXT:
6088
6157
  if ($.extra) {
@@ -6096,24 +6165,24 @@ const fixedtables = (_) => {
6096
6165
  $.was = $.length, $.mode = DIST;
6097
6166
  /* falls through */
6098
6167
  case DIST:
6099
- for (; K = $.distcode[M & (1 << $.distbits) - 1], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(J <= L); ) {
6168
+ for (; W = $.distcode[M & (1 << $.distbits) - 1], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(J <= L); ) {
6100
6169
  if (o === 0)
6101
6170
  break t;
6102
6171
  o--, M += U[N++] << L, L += 8;
6103
6172
  }
6104
- if ((G & 240) === 0) {
6105
- for (Y = J, nt = G, st = tt; K = $.distcode[st + ((M & (1 << Y + nt) - 1) >> Y)], J = K >>> 24, G = K >>> 16 & 255, tt = K & 65535, !(Y + J <= L); ) {
6173
+ if ((Y & 240) === 0) {
6174
+ for (X = J, nt = Y, lt = tt; W = $.distcode[lt + ((M & (1 << X + nt) - 1) >> X)], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(X + J <= L); ) {
6106
6175
  if (o === 0)
6107
6176
  break t;
6108
6177
  o--, M += U[N++] << L, L += 8;
6109
6178
  }
6110
- M >>>= Y, L -= Y, $.back += Y;
6179
+ M >>>= X, L -= X, $.back += X;
6111
6180
  }
6112
- if (M >>>= J, L -= J, $.back += J, G & 64) {
6181
+ if (M >>>= J, L -= J, $.back += J, Y & 64) {
6113
6182
  _.msg = "invalid distance code", $.mode = BAD;
6114
6183
  break;
6115
6184
  }
6116
- $.offset = tt, $.extra = G & 15, $.mode = DISTEXT;
6185
+ $.offset = tt, $.extra = Y & 15, $.mode = DISTEXT;
6117
6186
  /* falls through */
6118
6187
  case DISTEXT:
6119
6188
  if ($.extra) {
@@ -6423,12 +6492,12 @@ const compressArrayBuffer = (_) => {
6423
6492
  }
6424
6493
  return _;
6425
6494
  }, checkReconnect = (_) => !0;
6426
- var _t, ft, gt, St, kt, dt, ht, Et, $t, Tt, xt, Nt, At, qt;
6495
+ var yt, ft, Rt, $t, bt, dt, ht, qt, Et, xt, Dt, Ct, Ut, Mt;
6427
6496
  class CallsWebSocket {
6428
6497
  // 重连停止的回调
6429
6498
  constructor(D) {
6430
- lt(this, _t);
6431
- lt(this, ft, {
6499
+ st(this, yt);
6500
+ st(this, ft, {
6432
6501
  url: "wss://demo.putplay.cc/websocket",
6433
6502
  // 地址
6434
6503
  debug: !1,
@@ -6437,29 +6506,29 @@ class CallsWebSocket {
6437
6506
  // 最大重连次数
6438
6507
  timeout: 30 * 1e3
6439
6508
  });
6440
- lt(this, gt, "");
6509
+ st(this, Rt, "");
6441
6510
  // 缓存登录凭证
6442
- lt(this, St, !1);
6511
+ st(this, $t, !1);
6443
6512
  // 是否在房间内
6444
- lt(this, kt, 0);
6513
+ st(this, bt, 0);
6445
6514
  // 活性时间戳 根据服务端的响应来更新当前连接活性 活性为0 说明连接已经存在异常进行重连
6446
- lt(this, dt, {});
6447
- lt(this, ht, {});
6448
- W(this, "onReconnectSuccess", async (D) => {
6515
+ st(this, dt, {});
6516
+ st(this, ht, {});
6517
+ K(this, "onReconnectSuccess", async (D) => {
6449
6518
  });
6450
6519
  // 重连成功的回调
6451
- W(this, "onReconnectStop", async (D) => {
6520
+ K(this, "onReconnectStop", async (D) => {
6452
6521
  });
6453
6522
  // 自定义心跳规则
6454
- lt(this, Et, () => X(this, St) ? com.quick.voice.proto.CommonReq.encode({ event: "heartbeat", sn: +`${O(1e5, 999999)}` }).finish() : "");
6523
+ st(this, qt, () => G(this, $t) ? com.quick.voice.proto.CommonReq.encode({ event: "heartbeat", sn: +`${O(1e5, 999999)}` }).finish() : "");
6455
6524
  // 更新日志
6456
- lt(this, $t, (D, $ = {}) => {
6525
+ st(this, Et, (D, $ = {}) => {
6457
6526
  try {
6458
6527
  const { time: U, event: R, data: N = {}, data_original: e = {}, data_remote: o, ...A } = $, M = E(U, "YYYY-MM-DD hh:mm:ss", { offset: 480 });
6459
6528
  let L = {};
6460
- const F = (G = {}) => {
6461
- const tt = JSON.parse(JSON.stringify(G)), Y = Object.keys(tt);
6462
- for (const nt of Y)
6529
+ const F = (Y = {}) => {
6530
+ const tt = JSON.parse(JSON.stringify(Y)), X = Object.keys(tt);
6531
+ for (const nt of X)
6463
6532
  (nt.includes("sdp") || nt.includes("Sdp")) && (tt[nt] = "");
6464
6533
  return tt;
6465
6534
  };
@@ -6474,105 +6543,105 @@ class CallsWebSocket {
6474
6543
  }
6475
6544
  let H = "#quickvo.logs";
6476
6545
  ignoreEvent.includes(R) && (H = "#quickvo.ignoreEvents");
6477
- const z = { "#action": Z, timeStr: M, event: R, data: L, time: U, ...A }, V = localStorage.getItem(H) || JSON.stringify([]), K = JSON.parse(V), J = [z, ...K].slice(0, 500);
6546
+ const z = { "#action": Z, timeStr: M, event: R, data: L, time: U, ...A }, V = localStorage.getItem(H) || JSON.stringify([]), W = JSON.parse(V), J = [z, ...W].slice(0, 500);
6478
6547
  localStorage.setItem(H, JSON.stringify(J));
6479
6548
  } catch (U) {
6480
6549
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: updataLogs is error", U);
6481
6550
  }
6482
6551
  });
6483
6552
  // 活性检查器 每次发送消息前 、 接收消息后 都会调用进行检查
6484
- lt(this, Tt, (D) => new Promise(async ($) => {
6553
+ st(this, xt, (D) => new Promise(async ($) => {
6485
6554
  const { event: U } = D, R = Date.now();
6486
- U === "healthCheck" && (yt(this, kt, R), X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 刷新活性", { activetimeStamp: X(this, kt), activetimeStampStr: E(X(this, kt)) }));
6487
- const N = 30 * 1e3 + X(this, ft).timeout;
6488
- R - X(this, kt) >= N && X(this, _t) && (X(this, ft).debug && console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 活性超时, 尝试重新建立连接", X(this, _t)), await this.connect()), $(X(this, _t));
6555
+ U === "healthCheck" && (_t(this, bt, R), G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 刷新活性", { activetimeStamp: G(this, bt), activetimeStampStr: E(G(this, bt)) }));
6556
+ const N = 30 * 1e3 + G(this, ft).timeout;
6557
+ R - G(this, bt) >= N && G(this, yt) && (G(this, ft).debug && console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 活性超时, 尝试重新建立连接", G(this, yt)), await this.connect()), $(G(this, yt));
6489
6558
  }));
6490
6559
  // 清除事件
6491
- W(this, "clearEvents", (D = []) => {
6492
- const $ = Object.keys(X(this, dt));
6560
+ K(this, "clearEvents", (D = []) => {
6561
+ const $ = Object.keys(G(this, dt));
6493
6562
  D.length === 0 && (D = $);
6494
6563
  for (const U of $) {
6495
6564
  if (!D.includes(U)) continue;
6496
- const R = X(this, dt)[U];
6497
- clearTimeout(R.destructionTimer), delete X(this, dt)[U];
6565
+ const R = G(this, dt)[U];
6566
+ clearTimeout(R.destructionTimer), delete G(this, dt)[U];
6498
6567
  }
6499
6568
  });
6500
6569
  // 创建事件
6501
- lt(this, xt, (D, { resolve: $, reject: U }) => {
6570
+ st(this, Dt, (D, { resolve: $, reject: U }) => {
6502
6571
  const { sn: R } = D, N = () => {
6503
- const o = X(this, dt)[R];
6504
- clearTimeout(o.destructionTimer), delete X(this, dt)[R];
6572
+ const o = G(this, dt)[R];
6573
+ clearTimeout(o.destructionTimer), delete G(this, dt)[R];
6505
6574
  }, e = setTimeout(() => {
6506
- const o = X(this, dt)[R];
6575
+ const o = G(this, dt)[R];
6507
6576
  console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo:event is timeout", o.message), N(), U("event is timeout");
6508
- }, X(this, ft).timeout);
6509
- X(this, dt)[R] = { message: D, resolve: $, reject: U, destruction: N, destructionTimer: e };
6577
+ }, G(this, ft).timeout);
6578
+ G(this, dt)[R] = { message: D, resolve: $, reject: U, destruction: N, destructionTimer: e };
6510
6579
  });
6511
6580
  // 获取事件
6512
- lt(this, Nt, (D) => X(this, dt)[D]);
6581
+ st(this, Ct, (D) => G(this, dt)[D]);
6513
6582
  // 重连成功
6514
- lt(this, At, async (D) => {
6583
+ st(this, Ut, async (D) => {
6515
6584
  const $ = Date.now();
6516
- yt(this, kt, $), X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重置活性", { activetimeStamp: X(this, kt), activetimeStampStr: E(X(this, kt)) }), await this.onReconnectSuccess(D);
6585
+ _t(this, bt, $), G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重置活性", { activetimeStamp: G(this, bt), activetimeStampStr: E(G(this, bt)) }), await this.onReconnectSuccess(D);
6517
6586
  });
6518
6587
  /**
6519
6588
  * 连接
6520
6589
  * @param session
6521
6590
  * @returns
6522
6591
  */
6523
- W(this, "connect", async (D = "") => {
6524
- D && yt(this, gt, D), X(this, _t) && await X(this, _t).close();
6525
- const $ = `${X(this, ft).url}?s=${X(this, gt)}&t=${Date.now()}`;
6526
- return yt(this, _t, new k$1({
6527
- ...X(this, ft),
6592
+ K(this, "connect", async (D = "") => {
6593
+ D && _t(this, Rt, D), G(this, yt) && await G(this, yt).close();
6594
+ const $ = `${G(this, ft).url}?s=${G(this, Rt)}&t=${Date.now()}`;
6595
+ return _t(this, yt, new k$1({
6596
+ ...G(this, ft),
6528
6597
  url: $,
6529
6598
  binaryType: "arraybuffer",
6530
- onMessage: X(this, qt),
6599
+ onMessage: G(this, Mt),
6531
6600
  checkReconnect,
6532
- getHeartbeatMsg: X(this, Et),
6533
- onReconnectSuccess: X(this, At),
6601
+ getHeartbeatMsg: G(this, qt),
6602
+ onReconnectSuccess: G(this, Ut),
6534
6603
  onReconnectStop: (U) => this.onReconnectStop(U)
6535
- })), await X(this, _t).connect(), yt(this, kt, Date.now()), X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", X(this, ht)), X(this, _t);
6604
+ })), await G(this, yt).connect(), _t(this, bt, Date.now()), G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", G(this, ht)), G(this, yt);
6536
6605
  });
6537
6606
  /**
6538
6607
  * 关闭
6539
6608
  */
6540
- W(this, "close", async () => {
6609
+ K(this, "close", async () => {
6541
6610
  var $;
6542
- X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: cws is close.");
6543
- const D = Object.keys(X(this, dt));
6611
+ G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: cws is close.");
6612
+ const D = Object.keys(G(this, dt));
6544
6613
  for (const U of D) {
6545
- const { destructionTimer: R } = X(this, dt)[U];
6614
+ const { destructionTimer: R } = G(this, dt)[U];
6546
6615
  clearTimeout(R);
6547
6616
  }
6548
- yt(this, dt, {}), yt(this, ht, {}), await (($ = X(this, _t)) == null ? void 0 : $.close());
6617
+ _t(this, dt, {}), _t(this, ht, {}), await (($ = G(this, yt)) == null ? void 0 : $.close());
6549
6618
  });
6550
6619
  /**
6551
6620
  * 发送消息
6552
6621
  * @param message Message
6553
6622
  */
6554
- W(this, "sendMessage", (D, $ = !0) => new Promise(async (U, R) => {
6623
+ K(this, "sendMessage", (D, $ = !0) => new Promise(async (U, R) => {
6555
6624
  var L;
6556
6625
  const { event: N, ...e } = D, o = Date.now(), A = sendMessageFormat({
6557
6626
  event: N,
6558
6627
  sn: +`${o}${O(1e3, 9999)}`,
6559
6628
  time: o,
6560
- valid: X(this, ft).timeout,
6629
+ valid: G(this, ft).timeout,
6561
6630
  version: 1,
6562
6631
  compress: !1,
6563
6632
  ...e
6564
6633
  });
6565
- X(this, ft).debug && (X(this, $t).call(this, "req", A), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", A)), await X(this, Tt).call(this, A), N === "joinRoom" && yt(this, St, !1), $ && X(this, xt).call(this, A, { resolve: U, reject: R });
6634
+ G(this, ft).debug && (G(this, Et).call(this, "req", A), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", A)), await G(this, xt).call(this, A), N === "joinRoom" && _t(this, $t, !1), $ && G(this, Dt).call(this, A, { resolve: U, reject: R });
6566
6635
  const M = com.quick.voice.proto.CommonReq.encode(A).finish();
6567
- (L = X(this, _t)) == null || L.sendMessage(M);
6636
+ (L = G(this, yt)) == null || L.sendMessage(M);
6568
6637
  }));
6569
6638
  // 接收消息
6570
- lt(this, qt, async (D) => {
6639
+ st(this, Mt, async (D) => {
6571
6640
  const $ = new Uint8Array(D), U = com.quick.voice.proto.CommonRsp.decode($), { sn: R, event: N } = U, e = onMessageFormat(U);
6572
- if (X(this, ft).debug && (X(this, $t).call(this, "res", e), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e)), await X(this, Tt).call(this, e), N === "joinRoom" && yt(this, St, !0), ignoreEvent.includes(N)) return;
6641
+ if (G(this, ft).debug && (G(this, Et).call(this, "res", e), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e)), await G(this, xt).call(this, e), N === "joinRoom" && _t(this, $t, !0), ignoreEvent.includes(N)) return;
6573
6642
  if (notifyName_keys.includes(N))
6574
6643
  return this.emitNotify(N, v$1(e, ["code", "data", "desc"]));
6575
- const A = X(this, Nt).call(this, R);
6644
+ const A = G(this, Ct).call(this, R);
6576
6645
  if (A) {
6577
6646
  const { resolve: M = (F) => {
6578
6647
  }, destruction: L = () => {
@@ -6583,10 +6652,10 @@ class CallsWebSocket {
6583
6652
  /**
6584
6653
  * 触发广播事件
6585
6654
  * @param event 事件名称
6586
- * @param data 事件响应值
6655
+ * @param result 事件响应值
6587
6656
  */
6588
- W(this, "emitNotify", async (D, $) => {
6589
- const U = X(this, ht)[D] || [];
6657
+ K(this, "emitNotify", async (D, $) => {
6658
+ const U = G(this, ht)[D] || [];
6590
6659
  for (const R of U) {
6591
6660
  const { callback: N = async () => {
6592
6661
  } } = R;
@@ -6599,64 +6668,29 @@ class CallsWebSocket {
6599
6668
  * @param _private
6600
6669
  * @returns sn
6601
6670
  */
6602
- W(this, "addNotify", (D, $ = !1) => {
6671
+ K(this, "addNotify", (D, $ = !1) => {
6603
6672
  const { event: U, sn: R = pt(32) } = D;
6604
- X(this, ht)[U] || (X(this, ht)[U] = []);
6605
- const N = X(this, ht)[U], e = N.findIndex((o) => o.sn === R);
6673
+ G(this, ht)[U] || (G(this, ht)[U] = []);
6674
+ const N = G(this, ht)[U], e = N.findIndex((o) => o.sn === R);
6606
6675
  return e !== -1 && N.splice(e, 1), $ ? N.unshift(D) : N.push(D), R;
6607
6676
  });
6608
6677
  /**
6609
6678
  * 移除广播
6610
6679
  */
6611
- W(this, "removeNotify", (D = []) => {
6680
+ K(this, "removeNotify", (D = []) => {
6612
6681
  if (D.length === 0)
6613
- yt(this, ht, {});
6682
+ _t(this, ht, {});
6614
6683
  else {
6615
- const $ = Object.keys(X(this, ht));
6684
+ const $ = Object.keys(G(this, ht));
6616
6685
  for (const U of $)
6617
- X(this, ht)[U] = X(this, ht)[U].filter((R) => !D.includes(R.sn || ""));
6686
+ G(this, ht)[U] = G(this, ht)[U].filter((R) => !D.includes(R.sn || ""));
6618
6687
  }
6619
- X(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", X(this, ht));
6688
+ G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", G(this, ht));
6620
6689
  });
6621
- yt(this, ft, { ...X(this, ft), ...D });
6690
+ _t(this, ft, { ...G(this, ft), ...D });
6622
6691
  }
6623
6692
  }
6624
- _t = new WeakMap(), ft = new WeakMap(), gt = new WeakMap(), St = new WeakMap(), kt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), Et = new WeakMap(), $t = new WeakMap(), Tt = new WeakMap(), xt = new WeakMap(), Nt = new WeakMap(), At = new WeakMap(), qt = new WeakMap();
6625
- const getTrackNamesFormTracks = (_, D = [], $ = "trackName") => {
6626
- const U = [];
6627
- for (const R of _) {
6628
- const { type: N } = R;
6629
- if (D.length === 0 || D.includes(N)) {
6630
- const e = R[$];
6631
- e && U.push(`${e}`);
6632
- }
6633
- }
6634
- return U;
6635
- }, getAverageVolume = (_, D) => {
6636
- _.getByteFrequencyData(D);
6637
- let $ = 0;
6638
- for (let R = 0; R < D.length; R++)
6639
- $ += D[R];
6640
- return Math.ceil($ / D.length);
6641
- }, getCallAction = async (_) => {
6642
- let D = "";
6643
- const $ = (R) => _.findIndex(({ type: e, enabled: o = !0 }) => e === R && o) === -1 ? "0" : "1";
6644
- return D = `${$(0)}${D}`, D = `${$(1)}${D}`, D = `${$(2)}${D}`, D = `${$(3)}${D}`, parseInt(D, 2);
6645
- }, getCallActionMap = (_ = 0) => {
6646
- const $ = Number(_).toString(2).padStart(4, "0").split(""), [U, R, N, e] = $;
6647
- return {
6648
- microphoneCamera_audio: !!Number(e),
6649
- microphoneCamera_video: !!Number(N),
6650
- screenSharing_video: !!Number(R),
6651
- screenSharing_audio: !!Number(U)
6652
- };
6653
- }, tools = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6654
- __proto__: null,
6655
- getAverageVolume,
6656
- getCallAction,
6657
- getCallActionMap,
6658
- getTrackNamesFormTracks
6659
- }, Symbol.toStringTag, { value: "Module" }));
6693
+ yt = new WeakMap(), ft = new WeakMap(), Rt = new WeakMap(), $t = new WeakMap(), bt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), qt = new WeakMap(), Et = new WeakMap(), xt = new WeakMap(), Dt = new WeakMap(), Ct = new WeakMap(), Ut = new WeakMap(), Mt = new WeakMap();
6660
6694
  var l = Object.defineProperty, y = (_) => {
6661
6695
  throw TypeError(_);
6662
6696
  }, q = (_, D, $) => D in _ ? l(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $, s = (_, D, $) => q(_, typeof D != "symbol" ? D + "" : D, $), P = (_, D, $) => D.has(_) || y("Cannot " + $), n = (_, D, $) => (P(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), m = (_, D, $) => D.has(_) ? y("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), a, d, u;
@@ -6691,7 +6725,7 @@ class k {
6691
6725
  a = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap();
6692
6726
  class RoomBase {
6693
6727
  constructor() {
6694
- W(this, "options", {
6728
+ K(this, "options", {
6695
6729
  appid: "",
6696
6730
  sdkToken: "",
6697
6731
  roomId: "",
@@ -6700,18 +6734,21 @@ class RoomBase {
6700
6734
  debug: !1,
6701
6735
  newPublishAutoSubscribe: !0
6702
6736
  });
6703
- W(this, "tools", tools);
6704
- W(this, "asyncQueue", new k());
6705
- W(this, "state", "ready");
6737
+ K(this, "prohibitNotify", !1);
6738
+ // 是否禁止通知
6739
+ K(this, "asyncQueue", new k());
6740
+ // 异步队列
6741
+ K(this, "state", "ready");
6706
6742
  // 房间状态
6707
- W(this, "createAt", Date.now());
6743
+ K(this, "createAt", Date.now());
6708
6744
  // 创建时间
6709
- W(this, "cwsIns", new CallsWebSocket());
6745
+ K(this, "cwsIns", new CallsWebSocket());
6710
6746
  // SDK通讯实例 // SDK通讯实例
6711
- W(this, "audioOutput", "default");
6712
- // 音频默认播放设备
6747
+ K(this, "peerIns", new RTCPeerConnection({ bundlePolicy: "max-bundle" }));
6748
+ K(this, "userMap", /* @__PURE__ */ new Map());
6749
+ // 用户
6713
6750
  // 设备错误信息
6714
- W(this, "mediaDevicesErrInfo", {
6751
+ K(this, "mediaDevicesErrInfo", {
6715
6752
  microphoneCamera_audio: "",
6716
6753
  microphoneCamera_video: "",
6717
6754
  screenSharing_video: "",
@@ -6720,35 +6757,35 @@ class RoomBase {
6720
6757
  /**
6721
6758
  * 获取房间信息
6722
6759
  */
6723
- W(this, "getRoomInfo", () => {
6760
+ K(this, "getRoomInfo", () => {
6724
6761
  const { options: D, state: $, createAt: U } = this;
6725
6762
  return { ...D, state: $, createAt: U };
6726
6763
  });
6727
6764
  /**
6728
6765
  * 设置房间状态
6729
6766
  */
6730
- W(this, "setRoomState", (D) => {
6767
+ K(this, "setRoomState", (D) => {
6731
6768
  this.state = D;
6732
6769
  const $ = enum_roomState[D], U = { state: D, stateStr: $ };
6733
- this.cwsIns.emitNotify("onRoomState", { code: 200, data: U });
6770
+ this.cwsIns.emitNotify("onRoomState", { code: 200, data: U, desc: "room state is change." });
6734
6771
  });
6735
6772
  /**
6736
6773
  * 设置属性
6737
6774
  */
6738
- W(this, "setOptions", async (D) => {
6775
+ K(this, "setOptions", async (D) => {
6739
6776
  const $ = { ...this.options, ...D };
6740
6777
  this.options = $;
6741
6778
  });
6742
6779
  /**
6743
6780
  * 初始化通讯实例
6744
6781
  */
6745
- W(this, "initCwsCall", () => {
6782
+ K(this, "initCwsCall", () => {
6746
6783
  this.cwsIns = new CallsWebSocket({ ...this.options });
6747
6784
  });
6748
6785
  /**
6749
6786
  * 获取媒体设备错误信息
6750
6787
  */
6751
- W(this, "getMediaDevicesErrInfo", async () => {
6788
+ K(this, "getMediaDevicesErrInfo", async () => {
6752
6789
  try {
6753
6790
  const D = await navigator.mediaDevices.enumerateDevices();
6754
6791
  D.find((U) => U.kind === "audioinput") || (this.mediaDevicesErrInfo.microphoneCamera_audio = "audioinput is not available."), D.find((U) => U.kind === "videoinput") || (this.mediaDevicesErrInfo.microphoneCamera_video = "videoinput is not available.");
@@ -6757,207 +6794,352 @@ class RoomBase {
6757
6794
  }
6758
6795
  return this.mediaDevicesErrInfo;
6759
6796
  });
6797
+ /**
6798
+ * 获取MediaKey
6799
+ */
6800
+ K(this, "getUserMediaKey", (D, $) => `${D}-${$}`);
6801
+ /**
6802
+ * 获取 CallAction map
6803
+ */
6804
+ K(this, "getCallActionMap", (D = 0) => {
6805
+ const U = Number(D).toString(2).padStart(4, "0").split(""), [R, N, e, o] = U;
6806
+ return {
6807
+ microphoneCamera_audio: !!Number(o),
6808
+ microphoneCamera_video: !!Number(e),
6809
+ screenSharing_video: !!Number(N),
6810
+ screenSharing_audio: !!Number(R)
6811
+ };
6812
+ });
6813
+ /**
6814
+ * 获取音量
6815
+ */
6816
+ K(this, "getAverageVolume", (D, $) => {
6817
+ D.getByteFrequencyData($);
6818
+ let U = 0;
6819
+ for (let N = 0; N < $.length; N++)
6820
+ U += $[N];
6821
+ return Math.ceil(U / $.length);
6822
+ });
6823
+ /**
6824
+ * 通过轨道计算当前用户的通话状态
6825
+ */
6826
+ K(this, "getCallAction", async (D) => {
6827
+ let $ = "";
6828
+ const U = (N) => D.findIndex(({ type: o, enabled: A = !0 }) => o === N && A) === -1 ? "0" : "1";
6829
+ return $ = `${U(0)}${$}`, $ = `${U(1)}${$}`, $ = `${U(2)}${$}`, $ = `${U(3)}${$}`, parseInt($, 2);
6830
+ });
6831
+ /**
6832
+ * 获取指定轨道的名称数组
6833
+ * @param tracks 轨道
6834
+ * @param types number[] = []
6835
+ * @param keyName
6836
+ * @returns string[]
6837
+ */
6838
+ K(this, "getTrackNamesFormTracks", (D, $ = [], U = "trackName") => {
6839
+ const R = [];
6840
+ for (const N of D) {
6841
+ const { type: e } = N;
6842
+ if ($.length === 0 || $.includes(e)) {
6843
+ const o = N[U];
6844
+ o && R.push(`${o}`);
6845
+ }
6846
+ }
6847
+ return R;
6848
+ });
6849
+ /**
6850
+ * 处理为应用层数据
6851
+ */
6852
+ K(this, "usersFilter", (D) => mt(D, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "updateStreams", "permissions", "isPublished"]).sort((R, N) => R.id.localeCompare(N.id, "en")));
6760
6853
  }
6761
6854
  }
6762
- class MediaStreams extends RoomBase {
6855
+ var wt, vt, kt, Pt, Bt, It, Lt;
6856
+ class RoomMedias extends RoomBase {
6857
+ // 媒体流上下文
6763
6858
  constructor() {
6764
6859
  super();
6765
- W(this, "audioMediaStreamContextMap", /* @__PURE__ */ new Map());
6766
- // 音频媒体流上下文
6767
- W(this, "videoMediaStreamContextMap", /* @__PURE__ */ new Map());
6768
- // 视频媒体流上下文
6769
- W(this, "mediaDevices", []);
6860
+ K(this, "mediaDevices", []);
6861
+ // 可用媒体设备列表
6862
+ st(this, wt, /* @__PURE__ */ new Map());
6863
+ // 媒体流设备管理
6864
+ st(this, vt, /* @__PURE__ */ new Map());
6865
+ // 媒体轨道参数管理
6866
+ st(this, kt, /* @__PURE__ */ new Map());
6770
6867
  /**
6771
- * 获取key
6868
+ * 初始化媒体参数
6772
6869
  */
6773
- W(this, "getUserMediaKey", ($, U) => `${$}-${U}`);
6870
+ st(this, Pt, () => {
6871
+ G(this, vt).set("microphoneCamera_audio", {}), G(this, vt).set("microphoneCamera_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), G(this, vt).set("screenSharing_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), G(this, vt).set("screenSharing_audio", {});
6872
+ });
6774
6873
  /**
6775
- * 判断用户媒体类型
6874
+ * 初始化媒体设备类型
6776
6875
  */
6777
- W(this, "getUserMediaKind", ($) => {
6778
- let U = "";
6779
- switch ($) {
6780
- // 音频媒体处理
6781
- case "microphoneCamera_audio":
6782
- case "screenSharing_audio":
6783
- U = "audio";
6784
- break;
6785
- // 视频媒体处理
6786
- case "microphoneCamera_video":
6787
- case "screenSharing_video":
6788
- U = "video";
6789
- break;
6790
- }
6791
- return U;
6876
+ st(this, Bt, () => {
6877
+ G(this, wt).set("audioinput", "default"), G(this, wt).set("videoinput", "default"), G(this, wt).set("audiooutput", "default");
6792
6878
  });
6793
6879
  /**
6794
- * 设置媒体参数
6880
+ * 房间所有用户所有媒体流变化
6795
6881
  */
6796
- W(this, "setConstraints", async ($, U, R) => {
6797
- const N = await this.getUserStream($, U), e = N.getTracks();
6798
- if (e.length !== 0) {
6799
- for (const o of e) {
6800
- const M = { ...o.getConstraints(), ...R };
6801
- await o.applyConstraints(M);
6802
- }
6803
- await this.initUserMediaStreamContext($, U, N);
6804
- }
6882
+ K(this, "emitNotifyUpdateUsersStreams", async ($) => {
6883
+ this.prohibitNotify || this.cwsIns.emitNotify("onRoomUsersStreams", { code: 200, data: $, desc: "users streams is change." });
6805
6884
  });
6806
6885
  /**
6807
6886
  * 初始化用户媒体上下文
6808
6887
  */
6809
- W(this, "initUserMediaStreamContext", async ($, U, R) => {
6888
+ K(this, "initUserMediaStreamContext", async ($, U, R) => {
6810
6889
  var A;
6811
- const N = this.getUserMediaKey($, U);
6812
- if (R.getTracks().length === 0) {
6890
+ const [N] = R.getTracks();
6891
+ if (!N) {
6813
6892
  console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: tracks.length is 0.", { userId: $, mediaType: U, stream: R });
6814
6893
  return;
6815
6894
  }
6816
- switch (this.getUserMediaKind(U)) {
6895
+ this.removeUserMediaStreamContext($, U);
6896
+ const e = this.getUserMediaKey($, U), { kind: o } = N;
6897
+ switch (o) {
6817
6898
  // 音频媒体处理
6818
6899
  case "audio":
6819
6900
  {
6820
- const M = new AudioMediaStreamContext(R);
6821
- try {
6822
- (A = M.audioContext) == null || A.setSinkId(this.audioOutput);
6823
- } catch (L) {
6824
- console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error", L);
6825
- }
6826
- this.audioMediaStreamContextMap.set(N, M);
6901
+ const M = new AudioMediaContext(N);
6902
+ G(this, kt).set(e, M);
6827
6903
  }
6828
6904
  break;
6829
6905
  // 视频媒体处理
6830
6906
  case "video":
6831
6907
  {
6832
- const M = new VideoMediaStreamContext(R);
6833
- this.videoMediaStreamContextMap.set(N, M);
6908
+ const M = new VideoMediaContext(N);
6909
+ G(this, kt).set(e, M);
6834
6910
  }
6835
6911
  break;
6836
6912
  }
6913
+ {
6914
+ const M = this.getUserMediaStreamContext($, U);
6915
+ if (M && M.kind === "audio")
6916
+ try {
6917
+ const L = G(this, wt).get("audiooutput");
6918
+ (A = M.audioContext) == null || A.setSinkId(L);
6919
+ } catch (L) {
6920
+ console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error", L);
6921
+ }
6922
+ }
6923
+ });
6924
+ /**
6925
+ * 获取用户媒体流上下文
6926
+ */
6927
+ K(this, "getUserMediaStreamContext", ($, U) => {
6928
+ const R = this.getUserMediaKey($, U);
6929
+ return G(this, kt).get(R);
6930
+ });
6931
+ /**
6932
+ * 获取用户音频媒体流上下文
6933
+ */
6934
+ K(this, "getUserAudioMediaStreamContext", ($, U) => {
6935
+ const R = this.getUserMediaKey($, U);
6936
+ return G(this, kt).get(R);
6937
+ });
6938
+ /**
6939
+ * 删除用户媒体流上下文
6940
+ */
6941
+ K(this, "removeUserMediaStreamContext", ($, U) => {
6942
+ const R = this.getUserMediaKey($, U), N = G(this, kt).get(R);
6943
+ N == null || N.stop(), G(this, kt).delete(R);
6837
6944
  });
6838
6945
  /**
6839
6946
  * 获取某个用户的某个数据流
6840
6947
  */
6841
- W(this, "getUserStream", async ($, U) => {
6842
- const R = this.getUserMediaKey($, U), N = this.getUserMediaKind(U);
6843
- let e;
6844
- switch (N) {
6845
- // 音频媒体处理
6846
- case "audio":
6948
+ K(this, "getUserStream", ($, U) => {
6949
+ const R = this.getUserMediaStreamContext($, U);
6950
+ return (R == null ? void 0 : R.getStream()) || new MediaStream();
6951
+ });
6952
+ /**
6953
+ * 获取某个用户的某些数据流
6954
+ */
6955
+ K(this, "getUserStreams", ($, U = []) => {
6956
+ U.length === 0 && (U = mediaType_keys);
6957
+ const R = {};
6958
+ for (const N of U) {
6959
+ const e = this.getUserStream($, N);
6960
+ R[N] = e;
6961
+ }
6962
+ return R;
6963
+ });
6964
+ /**
6965
+ * 删除某个用户的某些数据流
6966
+ */
6967
+ K(this, "removeUserStreams", async ($, U = []) => {
6968
+ U.length === 0 && (U = mediaType_keys);
6969
+ for (const R of U)
6970
+ this.removeUserMediaStreamContext($, R);
6971
+ });
6972
+ /**
6973
+ * 清除所有媒体流使用
6974
+ */
6975
+ K(this, "clearUserStreams", async () => {
6976
+ const $ = G(this, kt).values();
6977
+ for (const U of $)
6978
+ U.stop();
6979
+ _t(this, kt, /* @__PURE__ */ new Map());
6980
+ });
6981
+ /**
6982
+ * 设置轨道媒体参数
6983
+ */
6984
+ K(this, "setMediaTrackConstraints", async ($, U) => {
6985
+ G(this, vt).set($, U);
6986
+ const N = this.getUserStream(this.options.userId, $).getTracks();
6987
+ if (N.length !== 0)
6988
+ for (const e of N) {
6989
+ const A = { ...e.getConstraints(), ...U };
6990
+ await e.applyConstraints(A);
6991
+ }
6992
+ });
6993
+ /**
6994
+ * 改变本地流
6995
+ * @param mediaType MediaType
6996
+ * @param active 激活状态
6997
+ * @example quickvo.setLocalStream('microphoneCamera_audio', false)
6998
+ * @returns Promise<Streams>
6999
+ */
7000
+ K(this, "changeLocalStream", async ($) => {
7001
+ const { userId: U } = this.options, R = G(this, vt).get($);
7002
+ switch ($) {
7003
+ // 麦克风
7004
+ case "microphoneCamera_audio":
6847
7005
  {
6848
- const o = this.audioMediaStreamContextMap.get(R);
6849
- e = o == null ? void 0 : o.getStream();
7006
+ const N = G(this, wt).get("audioinput"), e = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: N, ...R }, video: !1 });
7007
+ await this.initUserMediaStreamContext(U, "microphoneCamera_audio", e);
6850
7008
  }
6851
7009
  break;
6852
- // 视频媒体处理
6853
- case "video":
7010
+ // 摄像头
7011
+ case "microphoneCamera_video":
7012
+ {
7013
+ const N = G(this, wt).get("videoinput"), e = await navigator.mediaDevices.getUserMedia({ audio: !1, video: { deviceId: N, ...R } });
7014
+ await this.initUserMediaStreamContext(U, "microphoneCamera_video", e);
7015
+ }
7016
+ break;
7017
+ // 屏幕共享 音频
7018
+ case "screenSharing_audio":
6854
7019
  {
6855
- const o = this.videoMediaStreamContextMap.get(R);
6856
- e = o == null ? void 0 : o.getStream();
7020
+ const N = await navigator.mediaDevices.getDisplayMedia({ audio: !0, video: !0, ...R }), e = N.getTracks();
7021
+ for (const o of e) {
7022
+ const { kind: A } = o, M = new MediaStream();
7023
+ M.addTrack(o), N.removeTrack(o), A === "audio" && await this.initUserMediaStreamContext(U, "screenSharing_audio", M), A === "video" && await this.initUserMediaStreamContext(U, "screenSharing_video", M);
7024
+ }
7025
+ }
7026
+ break;
7027
+ // 屏幕共享 视频
7028
+ case "screenSharing_video":
7029
+ {
7030
+ const N = await navigator.mediaDevices.getDisplayMedia({ audio: !1, video: !0, ...R });
7031
+ await this.initUserMediaStreamContext(U, "screenSharing_video", N);
6857
7032
  }
6858
7033
  break;
6859
7034
  }
6860
- return e || new MediaStream();
7035
+ this.emitNotifyUpdateUsersStreams([{ userId: U, updateStreams: { [$]: !0 } }]);
6861
7036
  });
6862
7037
  /**
6863
- * 获取某个用户的全部数据流
7038
+ * 获取媒体设备列表
6864
7039
  */
6865
- W(this, "getUserStreams", async ($) => {
6866
- const U = {};
6867
- for (const R of mediaType_keys) {
6868
- const N = await this.getUserStream($, R);
6869
- U[R] = N;
6870
- }
6871
- return U;
6872
- });
7040
+ st(this, It, async () => !navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices ? (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 不支持 enumerateDevices"), []) : (await navigator.mediaDevices.enumerateDevices().then(($) => {
7041
+ this.mediaDevices = $;
7042
+ }).catch(function($) {
7043
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", $);
7044
+ }), this.mediaDevices));
6873
7045
  /**
6874
- * 删除用户媒体流上下文
7046
+ * 媒体设备发生变化
6875
7047
  */
6876
- W(this, "removeUserMediaStreamContext", ($, U) => {
6877
- const R = this.getUserMediaKey($, U);
6878
- this.audioMediaStreamContextMap.delete(R), this.videoMediaStreamContextMap.delete(R);
7048
+ st(this, Lt, () => {
7049
+ navigator.mediaDevices.ondevicechange = async () => {
7050
+ await G(this, It).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
7051
+ }, G(this, It).call(this);
6879
7052
  });
6880
7053
  /**
6881
- * 删除某个用户的某个数据流
7054
+ * 获取正在使用的媒体设备ID
7055
+ * @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
7056
+ * @returns deviceId 设备ID
6882
7057
  */
6883
- W(this, "removeUserStreams", async ($, U = []) => {
6884
- U.length === 0 && (U = mediaType_keys);
6885
- for (const R of U) {
6886
- const N = await this.getUserStream($, R);
6887
- await this.stopStream(N), this.removeUserMediaStreamContext($, R);
7058
+ K(this, "getMediaDeviceKind", ($) => G(this, wt).get($));
7059
+ /**
7060
+ * 替换发射器媒体流
7061
+ */
7062
+ K(this, "replaceSenderStream", async ($, U) => {
7063
+ var A;
7064
+ const R = this.userMap.get(this.options.userId);
7065
+ if (!R) return;
7066
+ const { mid: N } = R.tracks.find((M) => M.mediaType === $) || {};
7067
+ if (!N) return;
7068
+ const [e] = U.getTracks(), o = this.peerIns.getTransceivers();
7069
+ for (const M of o) {
7070
+ const { sender: L } = M;
7071
+ M.mid === N && ((A = L.track) == null || A.stop(), L.replaceTrack(e));
6888
7072
  }
6889
7073
  });
6890
7074
  /**
6891
- * 清除所有媒体流使用
7075
+ * 设置正在使用的媒体设备
7076
+ * @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
7077
+ * @param deviceId 设备ID
6892
7078
  */
6893
- W(this, "clearUserStreams", async () => {
6894
- {
6895
- const $ = this.audioMediaStreamContextMap.values();
6896
- for (const U of $)
6897
- U.stop();
6898
- this.audioMediaStreamContextMap = /* @__PURE__ */ new Map();
7079
+ K(this, "setMediaDeviceKind", async ($, U) => {
7080
+ var N;
7081
+ G(this, wt).set($, U);
7082
+ const { userId: R } = this.options;
7083
+ if ($ === "audioinput" && this.getUserMediaStreamContext(R, "microphoneCamera_audio")) {
7084
+ await this.changeLocalStream("microphoneCamera_audio");
7085
+ const o = this.getUserStream(this.options.userId, "microphoneCamera_audio");
7086
+ await this.replaceSenderStream("microphoneCamera_audio", o);
6899
7087
  }
6900
- {
6901
- const $ = this.videoMediaStreamContextMap.values();
6902
- for (const U of $)
6903
- U.stop();
6904
- this.videoMediaStreamContextMap = /* @__PURE__ */ new Map();
7088
+ if ($ === "videoinput" && this.getUserMediaStreamContext(R, "microphoneCamera_video")) {
7089
+ await this.changeLocalStream("microphoneCamera_video");
7090
+ const o = this.getUserStream(this.options.userId, "microphoneCamera_video");
7091
+ await this.replaceSenderStream("microphoneCamera_video", o);
7092
+ }
7093
+ if ($ === "audiooutput") {
7094
+ const e = G(this, kt).values();
7095
+ for (const o of e)
7096
+ (N = o.audioContext) == null || N.setSinkId(U);
6905
7097
  }
6906
7098
  });
6907
7099
  /**
6908
- * 停止媒体流
7100
+ * 设置音频输出设备
7101
+ * @param deviceId 设备ID
7102
+ * @returns
6909
7103
  */
6910
- W(this, "stopStream", async ($) => {
6911
- const U = $.getTracks();
6912
- for (const R of U)
6913
- R.enabled = !1, R.stop(), $.removeTrack(R);
6914
- $ = new MediaStream();
6915
- });
7104
+ K(this, "setAudioOutputDevice", ($) => this.setMediaDeviceKind("audiooutput", $));
6916
7105
  /**
6917
- * 获取可用音频输出媒体设备
7106
+ * 获取可用设备
7107
+ * @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
7108
+ * @returns MediaDeviceInfo[]
6918
7109
  */
6919
- W(this, "getEnumerateAudioOutputDevices", async () => !navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices ? (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 不支持 enumerateDevices"), []) : (await navigator.mediaDevices.enumerateDevices().then(($) => {
6920
- this.mediaDevices = $.filter((U) => U.kind === "audiooutput");
6921
- }).catch(function($) {
6922
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: err", $);
6923
- }), this.mediaDevices));
7110
+ K(this, "getEnumerateDevices", async ($) => (await G(this, It).call(this), this.mediaDevices.filter((R) => R.kind === $)));
6924
7111
  /**
6925
- * 设置音频输出设备
7112
+ * 获取可用音频输入设备
7113
+ * @returns MediaDeviceInfo[]
6926
7114
  */
6927
- W(this, "setAudioOutputDevice", ($) => {
6928
- var R;
6929
- const U = this.audioMediaStreamContextMap.values();
6930
- for (const N of U)
6931
- (R = N.audioContext) == null || R.setSinkId($);
6932
- });
6933
- // 获取当前音频输出设备
6934
- W(this, "getAudioOutputDevice", () => this.audioOutput);
7115
+ K(this, "getEnumerateAudioinputDevices", () => this.getEnumerateDevices("audioinput"));
7116
+ /**
7117
+ * 获取可用音频输出设备
7118
+ * @returns MediaDeviceInfo[]
7119
+ */
7120
+ K(this, "getEnumerateAudioOutputDevices", () => this.getEnumerateDevices("audiooutput"));
7121
+ /**
7122
+ * 获取可用视频输入设备
7123
+ * @returns MediaDeviceInfo[]
7124
+ */
7125
+ K(this, "getEnumerateVideoinputDevices", () => this.getEnumerateDevices("videoinput"));
7126
+ G(this, Lt).call(this), G(this, Bt).call(this), G(this, Pt).call(this);
6935
7127
  }
6936
7128
  }
6937
- class RoomUsers extends MediaStreams {
6938
- // 是否禁止通知
7129
+ wt = new WeakMap(), vt = new WeakMap(), kt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), It = new WeakMap(), Lt = new WeakMap();
7130
+ class RoomUsers extends RoomMedias {
6939
7131
  constructor() {
6940
7132
  super();
6941
- W(this, "userMap", /* @__PURE__ */ new Map());
6942
- // 用户
6943
- W(this, "prohibitNotify", !1);
6944
- /**
6945
- * 获取用户音频处理上下文
6946
- */
6947
- W(this, "getUserAudioMediaStreamContext", ($, U) => {
6948
- const R = this.getUserMediaKey($, U);
6949
- return this.audioMediaStreamContextMap.get(R);
6950
- });
6951
7133
  /**
6952
7134
  * 获取最大音量用户
6953
7135
  */
6954
- W(this, "getMaxVolumeUser", () => {
7136
+ K(this, "getMaxVolumeUser", () => {
6955
7137
  const $ = Array.from(this.userMap.values(), ({ id: R }) => R);
6956
7138
  if ($.length === 0) return;
6957
7139
  let U = [];
6958
7140
  for (const R of $) {
6959
- const N = this.getUserAudioMediaStreamContext(R, "microphoneCamera_audio");
6960
- if (!N) continue;
7141
+ const N = this.getUserMediaStreamContext(R, "microphoneCamera_audio");
7142
+ if (!N || N.kind !== "audio") continue;
6961
7143
  const e = N.getVolume();
6962
7144
  U.push({ id: R, volume: e });
6963
7145
  }
@@ -6966,16 +7148,16 @@ class RoomUsers extends MediaStreams {
6966
7148
  /**
6967
7149
  * 设置音频过滤
6968
7150
  */
6969
- W(this, "setAudioFilter", async ($ = {}) => {
7151
+ K(this, "setAudioFilter", async ($ = {}) => {
6970
7152
  const U = await this.getUsersId();
6971
7153
  for (const R of U) {
6972
7154
  {
6973
- const N = this.getUserAudioMediaStreamContext(R, "microphoneCamera_audio");
6974
- N == null || N.setFilter($);
7155
+ const N = this.getUserMediaStreamContext(R, "microphoneCamera_audio");
7156
+ (N == null ? void 0 : N.kind) === "audio" && (N == null || N.setFilter($));
6975
7157
  }
6976
7158
  {
6977
- const N = this.getUserAudioMediaStreamContext(R, "screenSharing_audio");
6978
- N == null || N.setFilter($);
7159
+ const N = this.getUserMediaStreamContext(R, "screenSharing_audio");
7160
+ (N == null ? void 0 : N.kind) === "audio" && (N == null || N.setFilter($));
6979
7161
  }
6980
7162
  }
6981
7163
  });
@@ -6984,9 +7166,9 @@ class RoomUsers extends MediaStreams {
6984
7166
  * @param userId
6985
7167
  * @param mediaType
6986
7168
  */
6987
- W(this, "setVolume", ($, U, R) => {
6988
- const N = this.getUserAudioMediaStreamContext($, U);
6989
- N == null || N.setVolumeGain(R);
7169
+ K(this, "setVolume", ($, U, R) => {
7170
+ const N = this.getUserMediaStreamContext($, U);
7171
+ (N == null ? void 0 : N.kind) === "audio" && (N == null || N.setVolumeGain(R));
6990
7172
  });
6991
7173
  /**
6992
7174
  * 获取声音大小
@@ -6994,27 +7176,28 @@ class RoomUsers extends MediaStreams {
6994
7176
  * @param mediaType
6995
7177
  * @returns volume
6996
7178
  */
6997
- W(this, "getVolume", ($, U) => {
6998
- const R = this.getUserAudioMediaStreamContext($, U);
6999
- return (R == null ? void 0 : R.getVolume()) || 0;
7179
+ K(this, "getVolume", ($, U) => {
7180
+ const R = this.getUserMediaStreamContext($, U);
7181
+ let N = 0;
7182
+ return (R == null ? void 0 : R.kind) === "audio" && (N = R == null ? void 0 : R.getVolume()), N;
7000
7183
  });
7001
7184
  /**
7002
7185
  * 清除房间所有用户
7003
7186
  */
7004
- W(this, "clearUsers", () => {
7187
+ K(this, "clearUsers", () => {
7005
7188
  this.userMap = /* @__PURE__ */ new Map();
7006
7189
  });
7007
7190
  /**
7008
7191
  * 删除用户
7009
7192
  */
7010
- W(this, "removeUsers", async ($) => {
7193
+ K(this, "removeUsers", async ($) => {
7011
7194
  for (const U of $)
7012
7195
  this.userMap.delete(U), await this.removeUserStreams(U);
7013
7196
  });
7014
7197
  /**
7015
7198
  * 创建一个用户
7016
7199
  */
7017
- W(this, "createUser", async ($) => {
7200
+ K(this, "createUser", async ($) => {
7018
7201
  const U = Date.now(), R = {
7019
7202
  id: $,
7020
7203
  permissions: 0,
@@ -7045,11 +7228,11 @@ class RoomUsers extends MediaStreams {
7045
7228
  /**
7046
7229
  * 获取某个用户
7047
7230
  */
7048
- W(this, "getUser", async ($) => (this.userMap.has($) || await this.createUser($), this.userMap.get($)));
7231
+ K(this, "getUser", async ($) => (this.userMap.has($) || await this.createUser($), this.userMap.get($)));
7049
7232
  /**
7050
7233
  * 获取某些用户
7051
7234
  */
7052
- W(this, "getUsers", async ($ = []) => {
7235
+ K(this, "getUsers", async ($ = []) => {
7053
7236
  $.length === 0 && ($ = [...this.userMap.keys()]);
7054
7237
  const U = [];
7055
7238
  for (const R of $) {
@@ -7061,7 +7244,7 @@ class RoomUsers extends MediaStreams {
7061
7244
  /**
7062
7245
  * 获取当前用户轨道所有mid
7063
7246
  */
7064
- W(this, "getAllUserTrackMids", async () => {
7247
+ K(this, "getAllUserTrackMids", async () => {
7065
7248
  const $ = await this.getUsers(), U = [];
7066
7249
  for (const R of $) {
7067
7250
  const { tracks: N = [] } = R;
@@ -7073,7 +7256,7 @@ class RoomUsers extends MediaStreams {
7073
7256
  /**
7074
7257
  * 通过 trackName 查询所属 UserTrack
7075
7258
  */
7076
- W(this, "getUserTrackByTrackName", async ($) => {
7259
+ K(this, "getUserTrackByTrackName", async ($) => {
7077
7260
  const U = await this.getUsers(), R = [];
7078
7261
  for (const N of U) {
7079
7262
  const { tracks: e = [] } = N;
@@ -7087,7 +7270,7 @@ class RoomUsers extends MediaStreams {
7087
7270
  /**
7088
7271
  * 通过 mid 查询所属 UserTrack
7089
7272
  */
7090
- W(this, "getUserTrackFromMid", async ($) => {
7273
+ K(this, "getUserTrackFromMid", async ($) => {
7091
7274
  const U = await this.getUsers();
7092
7275
  let R;
7093
7276
  for (const N of U) {
@@ -7103,36 +7286,36 @@ class RoomUsers extends MediaStreams {
7103
7286
  /**
7104
7287
  * 检查用户是否存在房间内
7105
7288
  */
7106
- W(this, "checkUserInRoom", ($) => this.userMap.has($));
7289
+ K(this, "checkUserInRoom", ($) => this.userMap.has($));
7107
7290
  /**
7108
7291
  * 获取房间全部用户id
7109
7292
  */
7110
- W(this, "getUsersId", async () => [...this.userMap.keys()]);
7293
+ K(this, "getUsersId", async () => [...this.userMap.keys()]);
7111
7294
  /**
7112
7295
  * 获取房间的访问者
7113
7296
  */
7114
- W(this, "getCaller", async () => await this.getUser(this.options.userId));
7297
+ K(this, "getCaller", async () => await this.getUser(this.options.userId));
7115
7298
  // 更新用户 isPublished 只有self 用户会用到
7116
- W(this, "updateIsPublished", async ($, U = !1) => {
7299
+ K(this, "updateIsPublished", async ($, U = !1) => {
7117
7300
  const R = await this.getUser($);
7118
7301
  R.isPublished = U;
7119
7302
  });
7120
7303
  /**
7121
7304
  * 设置用户流是否更新
7122
7305
  */
7123
- W(this, "setUserUpdateStreams", async ($, U, R = !0) => {
7306
+ K(this, "setUserUpdateStreams", async ($, U, R = !0) => {
7124
7307
  const N = await this.getUser($), e = {
7125
7308
  microphoneCamera_audio: !1,
7126
7309
  microphoneCamera_video: !1,
7127
7310
  screenSharing_video: !1,
7128
7311
  screenSharing_audio: !1
7129
7312
  };
7130
- e[U] = R, N.updateStreams = e, console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->Breathe: user.${U}`, R, N.updateStreams);
7313
+ e[U] = R, N.updateStreams = e;
7131
7314
  });
7132
7315
  /**
7133
7316
  * 更新用户轨道
7134
7317
  */
7135
- W(this, "updateUsertracks", async ($, U = [], R) => {
7318
+ K(this, "updateUsertracks", async ($, U = [], R) => {
7136
7319
  const N = await this.getUser($);
7137
7320
  R && (U = [...N.tracks, ...U]), U = U.filter(({ mid: A = "" }) => A !== ""), U = it(U, ["type"]), U = U.sort((A, M) => A.type - M.type < 0 ? -1 : 1);
7138
7321
  for (const A of U)
@@ -7165,21 +7348,21 @@ class RoomUsers extends MediaStreams {
7165
7348
  /**
7166
7349
  * 更新用户会话状态
7167
7350
  */
7168
- W(this, "updateUserCallAction", async ($, U = 0) => {
7351
+ K(this, "updateUserCallAction", async ($, U = 0) => {
7169
7352
  const R = await this.getUser($);
7170
- R.callAction = U, R.callActionStr = U.toString(2).padStart(4, "0"), R.callActionMap = this.tools.getCallActionMap(U);
7353
+ R.callAction = U, R.callActionStr = U.toString(2).padStart(4, "0"), R.callActionMap = this.getCallActionMap(U);
7171
7354
  });
7172
7355
  /**
7173
7356
  * 更新用户网络信息
7174
7357
  */
7175
- W(this, "updateUserNetwork", async ($, U = { egress: 5, ingress: 5 }) => {
7358
+ K(this, "updateUserNetwork", async ($, U = { egress: 5, ingress: 5 }) => {
7176
7359
  const R = await this.getUser($);
7177
7360
  R.network = U;
7178
7361
  });
7179
7362
  /**
7180
7363
  * 更新用户权限
7181
7364
  */
7182
- W(this, "updateUserPermissions", async ($, U) => {
7365
+ K(this, "updateUserPermissions", async ($, U) => {
7183
7366
  if (U) {
7184
7367
  const R = await this.getUser($);
7185
7368
  R.permissions = U;
@@ -7188,39 +7371,48 @@ class RoomUsers extends MediaStreams {
7188
7371
  /**
7189
7372
  * 更新用户基本信息
7190
7373
  */
7191
- W(this, "updateUserBase", async ($) => {
7374
+ K(this, "updateUserBase", async ($) => {
7192
7375
  const U = await this.getUser($);
7193
7376
  U.isSelf = $ === this.options.userId, U.updateAt = Date.now();
7194
7377
  });
7195
7378
  /**
7196
7379
  * 更新多个用户信息
7197
7380
  */
7198
- W(this, "updateUsers", async ($) => {
7381
+ K(this, "updateUsers", async ($) => {
7199
7382
  for (const U of $) {
7200
7383
  const { id: R, tracks: N, callAction: e, permissions: o, isPublished: A } = U;
7201
7384
  await this.updateUserBase(R), await this.updateIsPublished(R, A), await this.updateUserPermissions(R, o), await this.updateUsertracks(R, N, !0), await this.updateUserCallAction(R, e), await this.updateUserNetwork(R);
7202
7385
  }
7203
7386
  });
7204
7387
  /**
7205
- * 广播用户变化
7388
+ * 广播用户状态变化
7389
+ * 当某个用户发送了变化则通过该回调进行通知
7390
+ */
7391
+ K(this, "emitNotifyUpdateUser", async ($) => {
7392
+ if (this.prohibitNotify) return;
7393
+ const U = await this.getUsers([$]), [R] = this.usersFilter(U);
7394
+ this.cwsIns.emitNotify("onRoomUser", { code: 200, data: R, desc: "user info is change." });
7395
+ });
7396
+ /**
7397
+ * 广播全部用户状态变变化
7398
+ * 只要房间任意一个用户变化 都会通过该回调返回一个完整的用户列表
7206
7399
  */
7207
- W(this, "emitNotifyUpdateUsers", async () => {
7400
+ K(this, "emitNotifyUpdateUsers", async () => {
7208
7401
  if (this.prohibitNotify) return;
7209
- const $ = await this.getUsers(), R = mt($, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "updateStreams", "permissions", "isPublished"]).sort((N, e) => N.id.localeCompare(e.id, "en"));
7210
- this.cwsIns.emitNotify("onRoomUsers", { code: 200, data: R });
7402
+ const $ = await this.getUsers(), U = this.usersFilter($);
7403
+ this.cwsIns.emitNotify("onRoomUsers", { code: 200, data: U, desc: "all users info is change." });
7211
7404
  });
7212
7405
  }
7213
7406
  }
7214
- var Dt, Ct, Ut;
7407
+ var Zt, Ft, jt, Ht;
7215
7408
  class RoomPeer extends RoomUsers {
7216
7409
  constructor() {
7217
7410
  super();
7218
- W(this, "peerIns");
7219
- W(this, "getPeerStatsTimer", 0);
7411
+ K(this, "getPeerStatsTimer", 0);
7220
7412
  // 获取报告的定时器
7221
- W(this, "reports", []);
7413
+ K(this, "reports", []);
7222
7414
  // 通信网络质量
7223
- W(this, "peerNetwork", {
7415
+ K(this, "peerNetwork", {
7224
7416
  lostRate: "0",
7225
7417
  // 丢包率
7226
7418
  roundTripTime: "0",
@@ -7228,14 +7420,16 @@ class RoomPeer extends RoomUsers {
7228
7420
  jitter: "0"
7229
7421
  // 网络抖动
7230
7422
  });
7231
- W(this, "connectedResolveMap", /* @__PURE__ */ new Map());
7232
- W(this, "initPeer", () => {
7233
- this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), X(this, Dt).call(this), X(this, Ut).call(this);
7423
+ K(this, "connectedResolveMap", /* @__PURE__ */ new Map());
7424
+ K(this, "initPeer", () => {
7425
+ this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.peerIns.ontrack = async ($) => {
7426
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: e", $);
7427
+ }, G(this, Zt).call(this), G(this, Ht).call(this);
7234
7428
  });
7235
7429
  /**
7236
7430
  * 初始化发射器
7237
7431
  */
7238
- W(this, "initSender", async () => {
7432
+ K(this, "initSender", async () => {
7239
7433
  this.peerIns.addTransceiver("audio", { direction: "sendonly" });
7240
7434
  const $ = await this.peerIns.createOffer();
7241
7435
  if (this.options.debug) {
@@ -7247,18 +7441,18 @@ class RoomPeer extends RoomUsers {
7247
7441
  /**
7248
7442
  * 添加发射器
7249
7443
  */
7250
- W(this, "addSender", async ($, U) => {
7251
- const R = this.peerIns.addTransceiver(U, { direction: "sendonly" }), N = await this.peerIns.createOffer();
7252
- await this.peerIns.setLocalDescription(N);
7253
- const { mid: e, sender: o } = R, { track: A } = o;
7254
- if (!A) return;
7255
- const { id: M, enabled: L } = A;
7256
- return { type: mediaType_keys.findIndex((H) => H === $), enabled: L, trackName: M, location: "local", mid: e, userId: this.options.userId };
7444
+ K(this, "addSender", async ($, U) => {
7445
+ const { userId: R } = this.options, N = this.peerIns.addTransceiver(U, { direction: "sendonly" }), e = await this.peerIns.createOffer();
7446
+ await this.peerIns.setLocalDescription(e);
7447
+ const { mid: o, sender: A } = N, { track: M } = A;
7448
+ if (!M) return;
7449
+ const { enabled: L } = M, F = mediaType_keys.findIndex((H) => H === $);
7450
+ return { type: F, enabled: L, trackName: `${R}_${F}`, location: "local", mid: o, userId: this.options.userId };
7257
7451
  });
7258
7452
  /**
7259
7453
  * 清理收发器
7260
7454
  */
7261
- W(this, "clearTransceivers", async () => {
7455
+ K(this, "clearTransceivers", async () => {
7262
7456
  const $ = await this.getAllUserTrackMids(), U = this.peerIns.getTransceivers();
7263
7457
  for (const R of U) {
7264
7458
  const { mid: N } = R;
@@ -7266,7 +7460,7 @@ class RoomPeer extends RoomUsers {
7266
7460
  }
7267
7461
  });
7268
7462
  // 等待ice连接
7269
- W(this, "connectionICE", () => new Promise(async ($) => {
7463
+ K(this, "connectionICE", () => new Promise(async ($) => {
7270
7464
  if (this.peerIns.connectionState === "connected") return $(!0);
7271
7465
  const U = pt();
7272
7466
  this.connectedResolveMap.set(U, $);
@@ -7274,7 +7468,7 @@ class RoomPeer extends RoomUsers {
7274
7468
  /**
7275
7469
  * 监听订阅轨道结果
7276
7470
  */
7277
- W(this, "onSubscribeUserTracks", ($) => {
7471
+ K(this, "onSubscribeUserTracks", ($) => {
7278
7472
  let U = 0;
7279
7473
  return new Promise(async (R) => {
7280
7474
  const N = [];
@@ -7288,41 +7482,49 @@ class RoomPeer extends RoomUsers {
7288
7482
  {
7289
7483
  let e = [];
7290
7484
  const o = async () => {
7291
- clearTimeout(U);
7292
- const A = Object.groupBy(e, ({ userId: L = "" }) => L), M = Object.keys(A);
7293
- for (const L of M) {
7294
- const F = A[L];
7295
- await this.updateUsertracks(L, F, !0);
7485
+ clearTimeout(U), this.prohibitNotify = !1;
7486
+ const M = /* @__PURE__ */ new Map();
7487
+ for (const F of e) {
7488
+ const { userId: Z, mediaType: H } = F;
7489
+ if (!Z || !H) continue;
7490
+ M.has(Z) || M.set(Z, { userId: Z, tracks: [], updateStreams: {} });
7491
+ const V = M.get(Z);
7492
+ V.tracks.push(F), V.updateStreams[H] = !0;
7296
7493
  }
7297
- this.peerIns.ontrack = null, R(!0);
7298
- };
7299
- this.peerIns.ontrack = async (A) => {
7494
+ const L = [...M.values()];
7495
+ for (const F of L) {
7496
+ const { userId: Z, tracks: H } = F;
7497
+ await this.updateUsertracks(Z, H, !0);
7498
+ }
7499
+ await this.emitNotifyUpdateUsersStreams(L), this.peerIns.removeEventListener("track", A), R(!0);
7500
+ }, A = async (M) => {
7300
7501
  await this.connectionICE();
7301
- const { streams: M, transceiver: L } = A, [F] = M, { mid: Z, receiver: H } = L, { track: z } = H, { id: V, kind: K } = z, J = N.find((Y) => Y.mid === `${Z}`);
7302
- if (!J) return;
7303
- const { userId: G, mediaType: tt } = J;
7304
- if (!(!G || !tt)) {
7305
- if (await this.initUserMediaStreamContext(G, tt, F), K === "audio") {
7306
- const Y = this.getUserAudioMediaStreamContext(G, tt);
7307
- Y && Y.setMute(!1);
7502
+ const { streams: L, transceiver: F } = M, [Z] = L, { mid: H, receiver: z } = F, { track: V } = z, { id: W, kind: J } = V, Y = N.find((nt) => nt.mid === `${H}`);
7503
+ if (!Y) return;
7504
+ const { userId: tt, mediaType: X } = Y;
7505
+ if (!(!tt || !X)) {
7506
+ if (await this.initUserMediaStreamContext(tt, X, Z), J === "audio") {
7507
+ const nt = this.getUserMediaStreamContext(tt, X);
7508
+ (nt == null ? void 0 : nt.kind) === "audio" && nt.setMute(!1);
7308
7509
  }
7309
7510
  {
7310
- const Y = { ...J, mid: Z, msid: V };
7311
- e.push(Y);
7511
+ const nt = { ...Y, mid: H, msid: W };
7512
+ e.push(nt);
7312
7513
  }
7313
- this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->Breathe: await subscribe ${e.length}/${N.length}`, { mediaType: tt, mid: Z, userTrack: J }), N.length === e.length && o();
7514
+ this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->Breathe: await subscribe ${e.length}/${N.length}`, { mediaType: X, mid: H, userTrack: Y, e: M }), N.length === e.length && o();
7314
7515
  }
7315
- }, U = setTimeout(() => o(), 5 * 1e3);
7516
+ };
7517
+ this.peerIns.addEventListener("track", A), U = setTimeout(() => o(), 5 * 1e3);
7316
7518
  }
7317
7519
  });
7318
7520
  });
7319
7521
  /**
7320
7522
  * 监听webrtc ice通讯连接
7321
7523
  */
7322
- lt(this, Dt, async () => {
7524
+ st(this, Zt, async () => {
7323
7525
  let $ = 0;
7324
7526
  const U = () => {
7325
- this.setRoomState("disconnected"), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} });
7527
+ this.setRoomState("disconnected"), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {}, desc: "sdk is destroy." });
7326
7528
  };
7327
7529
  this.peerIns.onconnectionstatechange = async () => {
7328
7530
  const R = this.peerIns.connectionState;
@@ -7357,7 +7559,7 @@ class RoomPeer extends RoomUsers {
7357
7559
  /**
7358
7560
  * 关闭某个用户的某些轨道
7359
7561
  */
7360
- W(this, "closeUserTracks", async ($, U = [], R = !1) => {
7562
+ K(this, "closeUserTracks", async ($, U = [], R = !1) => {
7361
7563
  const N = [];
7362
7564
  for (const M of U) {
7363
7565
  const { trackName: L, msid: F } = M;
@@ -7367,7 +7569,7 @@ class RoomPeer extends RoomUsers {
7367
7569
  if (!o) return;
7368
7570
  for (const M of o.tracks) {
7369
7571
  const { trackName: L, msid: F, userId: Z, mediaType: H } = M;
7370
- !Z || !H || !e(F || L) || (await this.removeUserStreams(Z, [H]), F && delete M.msid);
7572
+ !Z || !H || !e(F || L) || (this.removeUserMediaStreamContext(Z, H), F && delete M.msid);
7371
7573
  }
7372
7574
  if (R) {
7373
7575
  const M = o.tracks.filter(({ trackName: L }) => !e(L));
@@ -7379,7 +7581,7 @@ class RoomPeer extends RoomUsers {
7379
7581
  L.track && e(L.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->Breathe: sender: ${L.track.id} is stop.`, M), L.track.enabled = !1, L.track.stop(), L.replaceTrack(null), this.peerIns.removeTrack(L), M.stop()), F.track && e(F.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->Breathe: receiver: ${F.track.id} is stop.`, M), F.track.enabled = !1, F.track.stop(), M.stop());
7380
7582
  }
7381
7583
  });
7382
- W(this, "createOffer", async () => {
7584
+ K(this, "createOffer", async () => {
7383
7585
  const $ = await this.peerIns.createOffer();
7384
7586
  if (this.options.debug) {
7385
7587
  const U = libExports.parse($.sdp), R = mt(U.media, ["mid", "msid", "type"]);
@@ -7387,7 +7589,7 @@ class RoomPeer extends RoomUsers {
7387
7589
  }
7388
7590
  await this.peerIns.setLocalDescription($);
7389
7591
  });
7390
- W(this, "createAnswer", async () => {
7592
+ K(this, "createAnswer", async () => {
7391
7593
  const $ = await this.peerIns.createAnswer();
7392
7594
  if (this.options.debug) {
7393
7595
  const U = libExports.parse($.sdp), R = mt(U.media, ["mid", "msid", "type"]);
@@ -7398,14 +7600,14 @@ class RoomPeer extends RoomUsers {
7398
7600
  /**
7399
7601
  * 生成本地sdp
7400
7602
  */
7401
- W(this, "getSdp", () => {
7603
+ K(this, "getSdp", () => {
7402
7604
  var $;
7403
7605
  return ($ = this.peerIns.localDescription) == null ? void 0 : $.sdp;
7404
7606
  });
7405
7607
  /**
7406
7608
  * 设置远程描述协议
7407
7609
  */
7408
- W(this, "setRemoteDescription", async ($) => {
7610
+ K(this, "setRemoteDescription", async ($) => {
7409
7611
  if (this.options.debug) {
7410
7612
  const U = libExports.parse($.sdp), R = mt(U.media, ["mid", "msid", "type"]);
7411
7613
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->Breathe: setRemoteDescription", { msidArr: R, sdpJson: U, description: $ });
@@ -7415,14 +7617,14 @@ class RoomPeer extends RoomUsers {
7415
7617
  /**
7416
7618
  * 获取peer网络情况
7417
7619
  */
7418
- W(this, "getPeerNetwork", () => this.peerNetwork);
7620
+ K(this, "getPeerNetwork", () => this.peerNetwork);
7419
7621
  /**
7420
7622
  * 设置通讯策略
7421
7623
  * @param callStrategy "fixedPictureQuality" | "qualityPriority" | "fluencyPriority" | "balancedDowngrade"
7422
7624
  * @param mediaTypes mediaType[] "microphoneCamera_audio" | "microphoneCamera_video" | "screenSharing_video" | "screenSharing_audio"
7423
7625
  * @example quickvo.setCallStrategy('fixedPictureQuality')
7424
7626
  */
7425
- W(this, "setCallStrategy", async ($, U = []) => {
7627
+ K(this, "setCallStrategy", async ($, U = []) => {
7426
7628
  U.length === 0 && (U = mediaType_keys);
7427
7629
  let R = "balanced";
7428
7630
  switch ($) {
@@ -7451,7 +7653,7 @@ class RoomPeer extends RoomUsers {
7451
7653
  * 设置 RTCRtpSender 参数
7452
7654
  * @param parameters RTCRtpSendParameters
7453
7655
  */
7454
- W(this, "setRTCRtpSenderParameters", ($) => {
7656
+ K(this, "setRTCRtpSenderParameters", ($) => {
7455
7657
  try {
7456
7658
  const U = this.peerIns.getSenders();
7457
7659
  for (const R of U) {
@@ -7465,33 +7667,33 @@ class RoomPeer extends RoomUsers {
7465
7667
  /**
7466
7668
  * 设置并分析报告
7467
7669
  */
7468
- lt(this, Ct, async ($) => {
7670
+ st(this, Ft, async ($) => {
7469
7671
  try {
7470
7672
  let U = 0, R = 0, N = 0, e = 0, o = [], A = [];
7471
7673
  for (const J of this.reports) {
7472
- const { packetsSent: G, packetsLost: tt } = J;
7473
- G && (U += G), tt && (R += tt);
7674
+ const { packetsSent: Y, packetsLost: tt } = J;
7675
+ Y && (U += Y), tt && (R += tt);
7474
7676
  }
7475
7677
  for (const J of $) {
7476
- const { packetsSent: G, packetsLost: tt, jitter: Y, roundTripTime: nt } = J;
7477
- G && (N += G), tt && (e += tt), Y && A.push(Y.toFixed(2)), nt && o.push((nt * 100).toFixed(2));
7678
+ const { packetsSent: Y, packetsLost: tt, jitter: X, roundTripTime: nt } = J;
7679
+ Y && (N += Y), tt && (e += tt), X && A.push(X.toFixed(2)), nt && o.push((nt * 100).toFixed(2));
7478
7680
  }
7479
7681
  this.reports = $, A.sort().reverse(), o.sort().reverse();
7480
7682
  const M = N - U, L = e - R;
7481
7683
  if (M === 0) return;
7482
7684
  const F = (L / M).toFixed(2), [Z = "0"] = o, [H = "0"] = A, z = { lostRate: F, roundTripTime: Z, jitter: H };
7483
- JSON.stringify(z) !== JSON.stringify(this.peerNetwork) && this.cwsIns.emitNotify("onRoomNetwork", { code: 200, data: z }), this.peerNetwork = z;
7484
- const K = (J, G, tt) => {
7485
- const Y = Number(J), nt = Number(G), st = Number(tt);
7685
+ JSON.stringify(z) !== JSON.stringify(this.peerNetwork) && this.cwsIns.emitNotify("onRoomNetwork", { code: 200, data: z, desc: "room network is change." }), this.peerNetwork = z;
7686
+ const W = (J, Y, tt) => {
7687
+ const X = Number(J), nt = Number(Y), lt = Number(tt);
7486
7688
  let et = "0";
7487
- return Y < 0.03 && nt < 100 && st < 0.05 ? et = "5" : Y < 0.06 && nt < 160 && st < 0.1 ? et = "4" : Y < 0.1 && nt < 250 && st < 0.15 ? et = "3" : Y < 0.15 && nt < 400 && st < 0.2 ? et = "2" : et = "1", Number(et);
7689
+ return X < 0.03 && nt < 100 && lt < 0.05 ? et = "5" : X < 0.06 && nt < 160 && lt < 0.1 ? et = "4" : X < 0.1 && nt < 250 && lt < 0.15 ? et = "3" : X < 0.15 && nt < 400 && lt < 0.2 ? et = "2" : et = "1", Number(et);
7488
7690
  };
7489
7691
  {
7490
- const J = K(F, Z, H), G = await this.getCaller(), { network: tt } = G, Y = { egress: J, ingress: J }, nt = JSON.stringify(tt) !== JSON.stringify(Y);
7491
- if (await this.updateUserNetwork(this.options.userId, Y), nt) {
7692
+ const J = W(F, Z, H), Y = await this.getCaller(), { network: tt } = Y, X = { egress: J, ingress: J }, nt = JSON.stringify(tt) !== JSON.stringify(X);
7693
+ if (await this.updateUserNetwork(this.options.userId, X), nt) {
7492
7694
  this.emitNotifyUpdateUsers();
7493
- const { userId: st, roomId: et } = this.options;
7494
- this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...Y, userId: st, roomId: et } }, !1);
7695
+ const { userId: lt, roomId: et } = this.options;
7696
+ this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...X, userId: lt, roomId: et } }, !1);
7495
7697
  }
7496
7698
  }
7497
7699
  } catch (U) {
@@ -7499,55 +7701,50 @@ class RoomPeer extends RoomUsers {
7499
7701
  }
7500
7702
  });
7501
7703
  /**
7502
- * 获取连接的所有状态数据
7704
+ * 获取分析报告
7503
7705
  */
7504
- lt(this, Ut, () => {
7505
- const $ = (R) => {
7506
- const N = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"];
7507
- return new Promise(async (e) => {
7508
- let o = [];
7509
- try {
7510
- await this.peerIns.getStats(R).then((A) => {
7511
- o = [...A.values()].filter((L) => N.includes(L.type));
7512
- });
7513
- } catch {
7514
- }
7515
- e(o);
7516
- });
7517
- }, U = async () => {
7518
- if (this.peerIns.connectionState !== "connected") return;
7519
- const R = this.peerIns.getSenders();
7706
+ K(this, "getReportsByMid", async ($ = []) => $.length === 0 ? this.reports : this.reports.filter((U) => $.includes(U.mid)));
7707
+ /**
7708
+ * 获取轨道分析数据
7709
+ */
7710
+ st(this, jt, async ($) => {
7711
+ const U = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"];
7712
+ return new Promise(async (R) => {
7520
7713
  let N = [];
7521
- for (const e of R) {
7522
- const { track: o } = e;
7523
- if (!o) continue;
7524
- const A = await $(o);
7525
- N = [...N, ...A];
7714
+ try {
7715
+ await this.peerIns.getStats($).then((e) => {
7716
+ N = [...e.values()].filter((A) => U.includes(A.type));
7717
+ });
7718
+ } catch {
7526
7719
  }
7527
- X(this, Ct).call(this, N);
7720
+ R(N);
7721
+ });
7722
+ });
7723
+ /**
7724
+ * 获取连接的所有轨道分析数据
7725
+ */
7726
+ st(this, Ht, () => {
7727
+ const $ = async () => {
7728
+ if (this.peerIns.connectionState !== "connected") return;
7729
+ const U = await G(this, jt).call(this);
7730
+ G(this, Ft).call(this, U);
7528
7731
  };
7529
- this.getPeerStatsTimer = setInterval(U, 1 * 1e3);
7732
+ this.getPeerStatsTimer = setInterval($, 1 * 1e3);
7530
7733
  });
7531
7734
  /**
7532
7735
  * 停止网络报告分析
7533
7736
  */
7534
- W(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
7737
+ K(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
7535
7738
  }
7536
7739
  }
7537
- Dt = new WeakMap(), Ct = new WeakMap(), Ut = new WeakMap();
7538
- var wt, Ot, Mt;
7740
+ Zt = new WeakMap(), Ft = new WeakMap(), jt = new WeakMap(), Ht = new WeakMap();
7741
+ var Ot, Tt, zt;
7539
7742
  class RoomCalls extends RoomPeer {
7540
7743
  constructor() {
7541
7744
  super();
7542
7745
  // sdk服务版本
7543
- W(this, "sdk_service_version", "1.0.3");
7544
- lt(this, wt, !0);
7545
- /**
7546
- * 添加广播事件
7547
- * @param notify Notify
7548
- * @returns sn
7549
- */
7550
- W(this, "addNotify", ($) => this.cwsIns.addNotify($));
7746
+ K(this, "sdk_service_version", "1.0.3");
7747
+ st(this, Ot, !0);
7551
7748
  /**
7552
7749
  * 设置本地流
7553
7750
  * @param mediaType MediaType
@@ -7555,64 +7752,35 @@ class RoomCalls extends RoomPeer {
7555
7752
  * @example quickvo.setLocalStream('microphoneCamera_audio', false)
7556
7753
  * @returns Promise<Streams>
7557
7754
  */
7558
- W(this, "setLocalStream", ($, U) => new Promise(async (R, N) => {
7755
+ K(this, "setLocalStream", ($, U) => new Promise(async (R, N) => {
7559
7756
  try {
7560
- const { userId: e } = this.options, o = {
7561
- autoGainControl: !1,
7562
- noiseSuppression: !1,
7563
- echoCancellation: !1
7564
- };
7565
- if (U)
7566
- switch ($) {
7567
- // 麦克风
7568
- case "microphoneCamera_audio":
7569
- {
7570
- const M = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1, ...o });
7571
- await this.initUserMediaStreamContext(e, "microphoneCamera_audio", M);
7572
- }
7573
- break;
7574
- // 摄像头
7575
- case "microphoneCamera_video":
7576
- {
7577
- const M = await navigator.mediaDevices.getUserMedia({ audio: !1, video: { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }, ...o });
7578
- await this.initUserMediaStreamContext(e, "microphoneCamera_video", M);
7579
- }
7580
- break;
7581
- // 屏幕共享 音频
7582
- case "screenSharing_audio":
7583
- {
7584
- const M = await navigator.mediaDevices.getDisplayMedia({ audio: !0, video: !0, ...o }), L = M.getTracks();
7585
- for (const F of L) {
7586
- const { kind: Z } = F, H = new MediaStream();
7587
- H.addTrack(F), M.removeTrack(F), Z === "audio" && await this.initUserMediaStreamContext(e, "screenSharing_audio", H), Z === "video" && await this.initUserMediaStreamContext(e, "screenSharing_video", H), F.onended = () => this.stopPublish(["screenSharing_audio", "screenSharing_video"]);
7588
- }
7589
- }
7590
- break;
7591
- // 屏幕共享 视频
7592
- case "screenSharing_video":
7593
- {
7594
- const M = await navigator.mediaDevices.getDisplayMedia({ audio: !1, video: !0, ...o });
7595
- await this.initUserMediaStreamContext(e, "screenSharing_video", M);
7596
- }
7597
- break;
7598
- }
7599
- else
7600
- await this.removeUserStreams(e, [$]);
7601
- const A = await this.getUserStreams(e);
7602
- this.cwsIns.emitNotify("onLocalStream", { code: 200, data: A }), R(A);
7757
+ const { userId: e } = this.options;
7758
+ if (U ? await this.changeLocalStream($) : this.removeUserMediaStreamContext(e, $), $ === "screenSharing_audio" || $ === "screenSharing_video") {
7759
+ const M = this.getUserStream(e, $).getTracks();
7760
+ for (const L of M)
7761
+ L.onended = () => this.stopPublish(["screenSharing_audio", "screenSharing_video"]);
7762
+ }
7763
+ const o = this.getUserStreams(e);
7764
+ this.cwsIns.emitNotify("onLocalStream", { code: 200, data: o, desc: "local stream is change." }), R(o);
7603
7765
  } catch (e) {
7604
7766
  N(e);
7605
7767
  }
7606
7768
  }));
7769
+ /**
7770
+ * 添加广播事件
7771
+ * @param notify Notify
7772
+ * @returns sn
7773
+ */
7774
+ K(this, "addNotify", ($) => this.cwsIns.addNotify($));
7607
7775
  /**
7608
7776
  * 加入房间
7609
7777
  * @param roomOptions RoomOptions
7610
7778
  * @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' , newPublishAutoSubscribe: true })
7611
7779
  * @returns Promise<boolean>
7612
7780
  */
7613
- W(this, "joinRoom", async ($) => new Promise(async (U, R) => {
7781
+ K(this, "joinRoom", async ($) => new Promise(async (U, R) => {
7614
7782
  try {
7615
- this.setOptions($), this.clearUsers(), this.clearUserStreams(), this.initPeer(), this.cwsIns.clearEvents(), await X(this, Mt).call(this), this.setRoomState("connect");
7783
+ this.setOptions($), this.clearUsers(), this.clearUserStreams(), this.initPeer(), this.cwsIns.clearEvents(), await G(this, zt).call(this), this.setRoomState("connect");
7616
7784
  const { roomId: N, userId: e, callType: o } = this.options;
7617
7785
  await this.cwsIns.sendMessage({
7618
7786
  event: "joinRoom",
@@ -7622,7 +7790,7 @@ class RoomCalls extends RoomPeer {
7622
7790
  if (M !== 200) return R(L);
7623
7791
  const { roomId: Z = "", roomUsers: H = [] } = F;
7624
7792
  if (Z !== N) return R("加入的房间不匹配");
7625
- X(this, wt) && this.createSession(), await this.updateUsers(H), this.setRoomState("connected"), await this.emitNotifyUpdateUsers();
7793
+ G(this, Ot) && this.createSession(), await this.updateUsers(H), this.setRoomState("connected"), await this.emitNotifyUpdateUsers();
7626
7794
  const z = await this.getUsers();
7627
7795
  U(z);
7628
7796
  });
@@ -7635,25 +7803,20 @@ class RoomCalls extends RoomPeer {
7635
7803
  * @example quickvo.quitRoom()
7636
7804
  * @returns Promise<boolean>
7637
7805
  */
7638
- W(this, "quitRoom", async () => new Promise(async ($) => {
7639
- try {
7640
- this.stopPublish();
7641
- } catch (e) {
7642
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", e);
7643
- }
7806
+ K(this, "quitRoom", async () => new Promise(async ($) => {
7644
7807
  const { roomId: U, userId: R } = this.options, N = { roomId: U, user: { id: R } };
7645
- await this.cwsIns.sendMessage({ event: "quitRoom", data: N }), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} }), $(!0);
7808
+ this.cwsIns.sendMessage({ event: "quitRoom", data: N }), await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {}, desc: "sdk is destroy." }), $(!0);
7646
7809
  }));
7647
7810
  /**
7648
7811
  * 同步房间信息
7649
7812
  * @example quickvo.syncRoomInfo()
7650
7813
  */
7651
- W(this, "syncRoomInfo", async () => new Promise(async ($, U) => {
7814
+ K(this, "syncRoomInfo", async () => new Promise(async ($, U) => {
7652
7815
  const { userId: R } = this.options, N = await this.getUser(R), { id: e = R, callAction: o = 0 } = N;
7653
7816
  await this.cwsIns.sendMessage({ event: "syncRoomInfo", data: { user: { id: e, callAction: o } } }).then(async (A) => {
7654
7817
  if (A.code !== 200) return U(A.desc);
7655
7818
  const M = A.data.users;
7656
- this.clearUsers(), this.clearUserStreams(), await this.updateUsers(M), await this.updateUsertracks(N.id, N.tracks, !1), await this.subscribe();
7819
+ this.clearUsers(), await this.updateUsers(M), await this.updateUsertracks(N.id, N.tracks, !1), await this.subscribe();
7657
7820
  {
7658
7821
  const L = await this.getUsers();
7659
7822
  $(L);
@@ -7667,22 +7830,22 @@ class RoomCalls extends RoomPeer {
7667
7830
  * @example quickvo.publish(['microphoneCamera_audio', 'microphoneCamera_video'], 3)
7668
7831
  * @returns Promise<RoomUser>
7669
7832
  */
7670
- W(this, "publish", async ($, U = 3) => {
7671
- X(this, wt) && await this.connectionICE();
7833
+ K(this, "publish", async ($, U = 3) => {
7834
+ G(this, Ot) && await this.connectionICE();
7672
7835
  const R = () => new Promise(async (N, e) => {
7673
7836
  try {
7674
7837
  $.includes("screenSharing_audio") && !$.includes("screenSharing_video") && ($ = [...$, "screenSharing_video"]);
7675
7838
  const o = await this.getCaller(), A = [];
7676
7839
  for (const Z of $) {
7677
- (await this.getUserStream(o.id, Z)).getTracks().length === 0 && await this.setLocalStream(Z, !0);
7840
+ this.getUserStream(o.id, Z).getTracks().length === 0 && await this.setLocalStream(Z, !0);
7678
7841
  {
7679
- const V = await this.getUserStream(o.id, Z), [K] = V.getTracks();
7680
- if (!K) continue;
7681
- const J = await this.addSender(Z, K);
7842
+ const V = this.getUserStream(o.id, Z), [W] = V.getTracks();
7843
+ if (!W) continue;
7844
+ const J = await this.addSender(Z, W);
7682
7845
  J && A.push(J);
7683
7846
  }
7684
7847
  }
7685
- const M = [...o.tracks, ...A], L = await this.tools.getCallAction(M), F = async () => {
7848
+ const M = [...o.tracks, ...A], L = await this.getCallAction(M), F = async () => {
7686
7849
  this.options.debug && console.info("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: surplus publish count is ${U}`), await this.cwsIns.sendMessage({
7687
7850
  event: "publish",
7688
7851
  data: { sdp: this.getSdp(), tracks: A, callAction: L }
@@ -7693,8 +7856,8 @@ class RoomCalls extends RoomPeer {
7693
7856
  return await new Promise((J) => setTimeout(() => J(!0), 300)), U = U - 1, F();
7694
7857
  throw this.options.debug && console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: publish is error. count 0", { mediaTypes: $ }), new Error(z);
7695
7858
  }
7696
- const { remoteSdp: K } = V;
7697
- await this.setRemoteDescription({ type: "answer", sdp: K }), await this.connectionICE(), await this.updateUsertracks(o.id, M, !0), await X(this, Ot).call(this, L), X(this, wt) || this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: "", user: { id: o.id, tracks: A } } });
7859
+ const { remoteSdp: W } = V;
7860
+ await this.setRemoteDescription({ type: "answer", sdp: W }), await this.connectionICE(), await this.updateUsertracks(o.id, M, !0), await G(this, Tt).call(this, L), G(this, Ot) || this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: "", user: { id: o.id, tracks: A } } });
7698
7861
  {
7699
7862
  await this.emitNotifyUpdateUsers();
7700
7863
  const J = await this.getCaller();
@@ -7715,7 +7878,7 @@ class RoomCalls extends RoomPeer {
7715
7878
  * @example quickvo.stopPublish(['microphoneCamera_audio'])
7716
7879
  * @returns Promise<RoomUser>
7717
7880
  */
7718
- W(this, "stopPublish", async ($ = []) => {
7881
+ K(this, "stopPublish", async ($ = []) => {
7719
7882
  const U = () => new Promise(async (R, N) => {
7720
7883
  try {
7721
7884
  const e = await this.getCaller();
@@ -7727,8 +7890,8 @@ class RoomCalls extends RoomPeer {
7727
7890
  if (o.length === 0) return A();
7728
7891
  await this.closeUserTracks(e.id, o, !0);
7729
7892
  {
7730
- const M = await this.tools.getCallAction(e.tracks);
7731
- await X(this, Ot).call(this, M);
7893
+ const M = await this.getCallAction(e.tracks);
7894
+ await G(this, Tt).call(this, M);
7732
7895
  }
7733
7896
  await this.createOffer(), await this.cwsIns.sendMessage({
7734
7897
  event: "closeTrack",
@@ -7750,8 +7913,8 @@ class RoomCalls extends RoomPeer {
7750
7913
  * @example quickvo.subscribe(['trackName1','trackName2'])
7751
7914
  * @returns Promise<RoomUser[]>
7752
7915
  */
7753
- W(this, "subscribe", async ($ = [], U = 3) => {
7754
- X(this, wt) && await this.connectionICE();
7916
+ K(this, "subscribe", async ($ = [], U = 3) => {
7917
+ G(this, Ot) && await this.connectionICE();
7755
7918
  const R = () => new Promise(async (N, e) => {
7756
7919
  try {
7757
7920
  this.prohibitNotify = !0;
@@ -7760,20 +7923,19 @@ class RoomCalls extends RoomPeer {
7760
7923
  for (const Z of o) {
7761
7924
  const { isSelf: H, tracks: z = [] } = Z;
7762
7925
  if (!H) {
7763
- const V = z.filter(({ trackName: K, mid: J = "" }) => J !== "" && ($.includes(K) || $.length === 0));
7926
+ const V = z.filter(({ trackName: W, mid: J = "" }) => J !== "" && ($.includes(W) || $.length === 0));
7764
7927
  V.length !== 0 && A.push({ ...Z, tracks: V });
7765
7928
  }
7766
7929
  }
7767
7930
  const M = async () => {
7768
- this.prohibitNotify = !1;
7769
7931
  const Z = Array.from(A, ({ id: z }) => z), H = await this.getUsers(Z);
7770
7932
  await this.emitNotifyUpdateUsers(), N(H);
7771
7933
  };
7772
7934
  if (A.length === 0) return M();
7773
7935
  const L = [];
7774
7936
  for (const Z of A) {
7775
- const { id: H, tracks: z } = Z, V = mt(z, ["type", "trackName"]), K = { id: H, tracks: V };
7776
- L.push(K);
7937
+ const { id: H, tracks: z } = Z, V = mt(z, ["type", "trackName"]), W = { id: H, tracks: V };
7938
+ L.push(W);
7777
7939
  }
7778
7940
  const F = async () => {
7779
7941
  this.options.debug && console.info("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: surplus subscribe count is ${U}`), await this.cwsIns.sendMessage({
@@ -7783,11 +7945,11 @@ class RoomCalls extends RoomPeer {
7783
7945
  const { code: H = 0, data: z, desc: V } = Z;
7784
7946
  if (H !== 200) {
7785
7947
  if (U > 0)
7786
- return await new Promise((G) => setTimeout(() => G(!0), 300)), U = U - 1, F();
7948
+ return await new Promise((Y) => setTimeout(() => Y(!0), 300)), U = U - 1, F();
7787
7949
  throw this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: subscribe is error. count 0", { trackNames: $ }), new Error(V);
7788
7950
  }
7789
- const { remoteSdp: K, users: J = [] } = z;
7790
- this.onSubscribeUserTracks(J).then(() => M()), await this.setRemoteDescription({ type: "offer", sdp: K }), await this.renegotiate();
7951
+ const { remoteSdp: W, users: J = [] } = z;
7952
+ this.onSubscribeUserTracks(J).then(() => M()), await this.setRemoteDescription({ type: "offer", sdp: W }), await this.renegotiate();
7791
7953
  });
7792
7954
  };
7793
7955
  await F();
@@ -7802,7 +7964,7 @@ class RoomCalls extends RoomPeer {
7802
7964
  * @param trackNames string[] = []
7803
7965
  * @example quickvo.subscribe(['trackName1'])
7804
7966
  */
7805
- W(this, "stopSubscribe", async ($ = []) => {
7967
+ K(this, "stopSubscribe", async ($ = []) => {
7806
7968
  const U = () => new Promise(async (R, N) => {
7807
7969
  try {
7808
7970
  const e = await this.getUsers(), o = [];
@@ -7811,8 +7973,8 @@ class RoomCalls extends RoomPeer {
7811
7973
  for (const L of M) {
7812
7974
  const { type: F, mid: Z, trackName: H, mediaType: z, msid: V } = L;
7813
7975
  if (!(!z || !V) && ($.length === 0 || $.includes(H))) {
7814
- const K = { type: F, mid: Z, trackName: V };
7815
- o.push(K), await this.closeUserTracks(A.id, [L]);
7976
+ const W = { type: F, mid: Z, trackName: V };
7977
+ o.push(W), await this.closeUserTracks(A.id, [L]);
7816
7978
  }
7817
7979
  }
7818
7980
  }
@@ -7836,7 +7998,7 @@ class RoomCalls extends RoomPeer {
7836
7998
  * @param enabled 是否冻结
7837
7999
  * @example quickvo.inactiveTracks(['microphoneCamera_audio'], false)
7838
8000
  */
7839
- W(this, "inactiveTracks", async ($, U) => {
8001
+ K(this, "inactiveTracks", async ($, U) => {
7840
8002
  const R = async () => {
7841
8003
  const N = await this.getCaller();
7842
8004
  if (!N) return;
@@ -7850,15 +8012,15 @@ class RoomCalls extends RoomPeer {
7850
8012
  H.enabled = U;
7851
8013
  }
7852
8014
  }
7853
- const A = await this.tools.getCallAction(o);
7854
- await X(this, Ot).call(this, A), await this.emitNotifyUpdateUsers();
8015
+ const A = await this.getCallAction(o);
8016
+ await G(this, Tt).call(this, A), await this.emitNotifyUpdateUsers();
7855
8017
  };
7856
8018
  return this.asyncQueue.add(R, { key: "inactiveTracks" });
7857
8019
  });
7858
8020
  /**
7859
8021
  * 远端调试
7860
8022
  */
7861
- W(this, "debugger", () => new Promise(async ($, U) => {
8023
+ K(this, "debugger", () => new Promise(async ($, U) => {
7862
8024
  await this.cwsIns.sendMessage({ event: "debugger" }, !1).then(async (R) => {
7863
8025
  if (R.code !== 200) return U(R.desc);
7864
8026
  $(!0);
@@ -7869,7 +8031,7 @@ class RoomCalls extends RoomPeer {
7869
8031
  /**
7870
8032
  * 更新自己通话状态
7871
8033
  */
7872
- lt(this, Ot, async ($) => new Promise(async (U, R) => {
8034
+ st(this, Tt, async ($) => new Promise(async (U, R) => {
7873
8035
  const { roomId: N, userId: e } = this.options, o = { roomId: N, user: { id: e, callAction: $ } };
7874
8036
  await this.cwsIns.sendMessage({ event: "updateCall", data: o }).then(async (A) => {
7875
8037
  const { code: M = 0 } = A;
@@ -7880,7 +8042,7 @@ class RoomCalls extends RoomPeer {
7880
8042
  /**
7881
8043
  * 创建cf会话
7882
8044
  */
7883
- W(this, "createSession", async () => (await this.initSender(), new Promise(async ($, U) => await this.cwsIns.sendMessage({
8045
+ K(this, "createSession", async () => (await this.initSender(), new Promise(async ($, U) => await this.cwsIns.sendMessage({
7884
8046
  event: "connectCF",
7885
8047
  data: { sdp: this.getSdp() }
7886
8048
  }).then(async (R) => {
@@ -7892,7 +8054,7 @@ class RoomCalls extends RoomPeer {
7892
8054
  /**
7893
8055
  * 协商流
7894
8056
  */
7895
- W(this, "renegotiate", async () => new Promise(async ($, U) => {
8057
+ K(this, "renegotiate", async () => new Promise(async ($, U) => {
7896
8058
  await this.createAnswer(), await this.cwsIns.sendMessage({ event: "renegotiate", data: { sdp: this.getSdp() } }).then(async (R) => {
7897
8059
  if (R.code !== 200) return U("协商流错误");
7898
8060
  $(!0);
@@ -7903,16 +8065,17 @@ class RoomCalls extends RoomPeer {
7903
8065
  /**
7904
8066
  * 登录
7905
8067
  */
7906
- lt(this, Mt, async () => new Promise(async ($, U) => {
8068
+ st(this, zt, async () => new Promise(async ($, U) => {
7907
8069
  try {
7908
8070
  this.setRoomState("checkAuth");
7909
- const { appid: R } = this.options, { userId: N, sdkToken: e } = this.options, o = {
8071
+ const { appid: R } = this.options, { userId: N, sdkToken: e, roomId: o } = this.options, A = {
8072
+ a: e,
7910
8073
  b: N,
7911
8074
  c: R,
7912
- a: e,
8075
+ r: o,
7913
8076
  v: this.sdk_service_version
7914
- }, A = btoa(encodeURI(JSON.stringify(o)));
7915
- await this.cwsIns.connect(A), $(!0);
8077
+ }, M = btoa(encodeURI(JSON.stringify(A)));
8078
+ await this.cwsIns.connect(M), $(!0);
7916
8079
  } catch (R) {
7917
8080
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe:error", R), U(R);
7918
8081
  }
@@ -7920,39 +8083,21 @@ class RoomCalls extends RoomPeer {
7920
8083
  this.setRoomState("ready");
7921
8084
  }
7922
8085
  }
7923
- wt = new WeakMap(), Ot = new WeakMap(), Mt = new WeakMap();
8086
+ Ot = new WeakMap(), Tt = new WeakMap(), zt = new WeakMap();
7924
8087
  class Room extends RoomCalls {
7925
8088
  constructor() {
7926
8089
  super();
7927
- /**
7928
- * 获取指定轨道的名称数组
7929
- * @param tracks 轨道
7930
- * @param types number[] = []
7931
- * @param keyName
7932
- * @returns string[]
7933
- */
7934
- W(this, "getTrackNamesFormTracks", ($, U = [], R = "trackName") => {
7935
- const N = [];
7936
- for (const e of $) {
7937
- const { type: o } = e;
7938
- if (U.length === 0 || U.includes(o)) {
7939
- const A = e[R];
7940
- A && N.push(`${A}`);
7941
- }
7942
- }
7943
- return N;
7944
- });
7945
8090
  }
7946
8091
  }
7947
- var vt, Pt, Bt, Lt;
8092
+ var gt, Jt, Kt, Wt;
7948
8093
  class QuickVO extends Room {
7949
8094
  constructor($) {
7950
8095
  super();
7951
- lt(this, vt, /* @__PURE__ */ new Map());
8096
+ st(this, gt, /* @__PURE__ */ new Map());
7952
8097
  /**
7953
8098
  * 添加内部监听事件
7954
8099
  */
7955
- lt(this, Pt, () => {
8100
+ st(this, Jt, () => {
7956
8101
  {
7957
8102
  const $ = async (U) => {
7958
8103
  const { qualities: R } = U.data;
@@ -7986,7 +8131,7 @@ class QuickVO extends Room {
7986
8131
  await this.updateUsertracks(N, e, !0);
7987
8132
  }
7988
8133
  if (this.options.newPublishAutoSubscribe) {
7989
- const R = this.tools.getTrackNamesFormTracks(U.data.user.tracks);
8134
+ const R = this.getTrackNamesFormTracks(U.data.user.tracks);
7990
8135
  await this.subscribe(R);
7991
8136
  } else
7992
8137
  await this.emitNotifyUpdateUsers();
@@ -8004,28 +8149,28 @@ class QuickVO extends Room {
8004
8149
  const $ = async (U) => {
8005
8150
  const { id: R, callAction: N } = U.data.user;
8006
8151
  if (!this.checkUserInRoom(R)) return;
8007
- const e = await this.getUser(R), { tracks: o = [] } = e, A = await this.getUserStreams(R), M = this.tools.getCallActionMap(N), L = [];
8152
+ const e = await this.getUser(R), { tracks: o = [] } = e, A = this.getUserStreams(R), M = this.getCallActionMap(N), L = [];
8008
8153
  for (const F of o) {
8009
8154
  const { type: Z } = F, H = mediaType_keys[Z], z = M[H];
8010
8155
  if (Z === 0) {
8011
- const { microphoneCamera_audio: K } = A, J = K.getTracks();
8012
- for (const G of J)
8013
- G.enabled = z;
8156
+ const { microphoneCamera_audio: W } = A, J = W.getTracks();
8157
+ for (const Y of J)
8158
+ Y.enabled = z;
8014
8159
  }
8015
8160
  if (Z === 1) {
8016
- const { microphoneCamera_video: K } = A, J = K.getTracks();
8017
- for (const G of J)
8018
- G.enabled = z;
8161
+ const { microphoneCamera_video: W } = A, J = W.getTracks();
8162
+ for (const Y of J)
8163
+ Y.enabled = z;
8019
8164
  }
8020
8165
  if (Z === 2) {
8021
- const { screenSharing_video: K } = A, J = K.getTracks();
8022
- for (const G of J)
8023
- G.enabled = z;
8166
+ const { screenSharing_video: W } = A, J = W.getTracks();
8167
+ for (const Y of J)
8168
+ Y.enabled = z;
8024
8169
  }
8025
8170
  if (Z === 3) {
8026
- const { screenSharing_audio: K } = A, J = K.getTracks();
8027
- for (const G of J)
8028
- G.enabled = z;
8171
+ const { screenSharing_audio: W } = A, J = W.getTracks();
8172
+ for (const Y of J)
8173
+ Y.enabled = z;
8029
8174
  }
8030
8175
  const V = { ...F, enabled: z };
8031
8176
  L.push(V);
@@ -8046,7 +8191,7 @@ class QuickVO extends Room {
8046
8191
  /**
8047
8192
  * 重连成功
8048
8193
  */
8049
- lt(this, Bt, () => {
8194
+ st(this, Kt, () => {
8050
8195
  this.cwsIns.onReconnectSuccess = async () => {
8051
8196
  this.syncRoomInfo();
8052
8197
  };
@@ -8054,7 +8199,7 @@ class QuickVO extends Room {
8054
8199
  /**
8055
8200
  * 重连停止
8056
8201
  */
8057
- lt(this, Lt, async () => {
8202
+ st(this, Wt, async () => {
8058
8203
  this.cwsIns.onReconnectStop = async () => {
8059
8204
  this.destroy();
8060
8205
  };
@@ -8064,15 +8209,15 @@ class QuickVO extends Room {
8064
8209
  * @param key string
8065
8210
  * @param func FrameRequestCallback
8066
8211
  */
8067
- W(this, "addRequestAnimationFrame", async ($, U) => {
8212
+ K(this, "addRequestAnimationFrame", async ($, U) => {
8068
8213
  {
8069
- const N = X(this, vt).get($);
8214
+ const N = G(this, gt).get($);
8070
8215
  N && cancelAnimationFrame(N);
8071
8216
  }
8072
8217
  const R = (N = Date.now()) => {
8073
8218
  U(N);
8074
8219
  const e = requestAnimationFrame(R);
8075
- X(this, vt).set($, e);
8220
+ G(this, gt).set($, e);
8076
8221
  };
8077
8222
  R();
8078
8223
  });
@@ -8080,11 +8225,11 @@ class QuickVO extends Room {
8080
8225
  * 清理 FrameRequestCallback
8081
8226
  * @param keys string[] = []
8082
8227
  */
8083
- W(this, "clearRequestAnimationFrame", async ($ = []) => {
8084
- $.length === 0 && ($ = [...X(this, vt).keys()]);
8228
+ K(this, "clearRequestAnimationFrame", async ($ = []) => {
8229
+ $.length === 0 && ($ = [...G(this, gt).keys()]);
8085
8230
  const U = [];
8086
8231
  for (const R of $) {
8087
- const N = X(this, vt).get(R);
8232
+ const N = G(this, gt).get(R);
8088
8233
  N && (cancelAnimationFrame(N), U.push(N));
8089
8234
  }
8090
8235
  return U;
@@ -8093,18 +8238,14 @@ class QuickVO extends Room {
8093
8238
  * 销毁
8094
8239
  * @example quickvo.destroy()
8095
8240
  */
8096
- W(this, "destroy", async () => {
8241
+ K(this, "destroy", async () => {
8097
8242
  this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 销毁SDK"), this.stopGetPeerStats(), this.asyncQueue.clear(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), await this.cwsIns.close();
8098
8243
  });
8099
- this.setOptions($), this.initCwsCall(), X(this, Bt).call(this), X(this, Lt).call(this), X(this, Pt).call(this);
8244
+ this.setOptions($), this.initCwsCall(), G(this, Kt).call(this), G(this, Wt).call(this), G(this, Jt).call(this);
8100
8245
  }
8101
8246
  }
8102
- vt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), Lt = new WeakMap();
8247
+ gt = new WeakMap(), Jt = new WeakMap(), Kt = new WeakMap(), Wt = new WeakMap();
8103
8248
  export {
8104
8249
  QuickVO,
8105
- getAverageVolume,
8106
- getCallAction,
8107
- getCallActionMap,
8108
- getTrackNamesFormTracks,
8109
8250
  ignoreEvent
8110
8251
  };