quickvo-sdk-js 0.8.2 → 0.8.3
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 +177 -176
- package/dist/index.umd.cjs +2 -2
- package/dist/room/RoomBase.d.ts +3 -0
- package/dist/room/RoomPeer.d.ts +0 -1
- package/dist/room/mediaStreams/AudioMediaContext.d.ts +2 -1
- package/dist/tools.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var re = Object.defineProperty;
|
|
2
|
+
var ne = (u) => {
|
|
3
3
|
throw TypeError(u);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var Z = (u, I, a) =>
|
|
7
|
-
var Q = (u, I, a) => (
|
|
5
|
+
var ce = (u, I, a) => I in u ? re(u, I, { enumerable: !0, configurable: !0, writable: !0, value: a }) : u[I] = a;
|
|
6
|
+
var Z = (u, I, a) => ce(u, typeof I != "symbol" ? I + "" : I, a), oe = (u, I, a) => I.has(u) || ne("Cannot " + a);
|
|
7
|
+
var Q = (u, I, a) => (oe(u, I, "read from private field"), a ? a.call(u) : I.get(u)), lt = (u, I, a) => I.has(u) ? ne("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(u) : I.set(u, a), St = (u, I, a, E) => (oe(u, I, "write to private field"), E ? E.call(u, a) : I.set(u, a), a);
|
|
8
8
|
const ot = (u, I = {}) => {
|
|
9
9
|
const a = { unit: "B", splitStr: " ", ...I };
|
|
10
10
|
let { unit: E, splitStr: _ } = a;
|
|
@@ -717,6 +717,12 @@ function requireLib() {
|
|
|
717
717
|
}
|
|
718
718
|
var libExports = requireLib();
|
|
719
719
|
class AudioMediaContext {
|
|
720
|
+
// 增益节点 (自动增益)
|
|
721
|
+
// autoGainNode!: GainNode
|
|
722
|
+
// 滤波器节点 (噪声抑制)
|
|
723
|
+
// biquadFilterNode!: BiquadFilterNode
|
|
724
|
+
// 延迟节点 (回声消除)
|
|
725
|
+
// delayNode!: DelayNode
|
|
720
726
|
constructor(I, a) {
|
|
721
727
|
Z(this, "options", {
|
|
722
728
|
autoGainControl: !1,
|
|
@@ -741,20 +747,16 @@ class AudioMediaContext {
|
|
|
741
747
|
Z(this, "sourceNode");
|
|
742
748
|
// 音量输入控制节点
|
|
743
749
|
Z(this, "inputGainNode");
|
|
744
|
-
// 音量输出控制节点
|
|
745
|
-
Z(this, "outputGainNode");
|
|
746
|
-
// 增益节点 (自动增益)
|
|
747
|
-
// autoGainNode!: GainNode
|
|
748
|
-
// 滤波器节点 (噪声抑制)
|
|
749
|
-
// biquadFilterNode!: BiquadFilterNode
|
|
750
|
-
// 延迟节点 (回声消除)
|
|
751
|
-
// delayNode!: DelayNode
|
|
752
750
|
// 音频分析节点
|
|
753
751
|
Z(this, "analyserNode");
|
|
754
752
|
// 缓冲区 存储分析节点的时域数据
|
|
755
753
|
Z(this, "analyserArrayData");
|
|
754
|
+
// 音量输出控制节点
|
|
755
|
+
Z(this, "outputGainNode");
|
|
756
|
+
// 输出节点
|
|
757
|
+
Z(this, "destinationNode");
|
|
756
758
|
Z(this, "initNodes", () => {
|
|
757
|
-
this.audio.srcObject = this.stream, this.sourceNode = this.audioContext.createMediaStreamSource(this.stream), this.inputGainNode = this.audioContext.createGain(), this.inputGainNode.gain.setValueAtTime(this.inputGain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount), this.outputGainNode = this.audioContext.createGain(), this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
|
|
759
|
+
this.audio.srcObject = this.stream, this.sourceNode = this.audioContext.createMediaStreamSource(this.stream), this.inputGainNode = this.audioContext.createGain(), this.inputGainNode.gain.setValueAtTime(this.inputGain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount), this.outputGainNode = this.audioContext.createGain(), this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime), this.destinationNode = this.audioContext.createMediaStreamDestination();
|
|
758
760
|
{
|
|
759
761
|
const { sourceNode: I, inputGainNode: a, analyserNode: E, outputGainNode: _ } = this;
|
|
760
762
|
I.connect(a), a.connect(E), E.connect(_), _.connect(this.audioContext.destination);
|
|
@@ -6163,7 +6165,7 @@ var Deflate_1$1 = Deflate$1, deflate_2 = deflate$1, deflateRaw_1$1 = deflateRaw$
|
|
|
6163
6165
|
};
|
|
6164
6166
|
const BAD$1 = 16209, TYPE$1 = 16191;
|
|
6165
6167
|
var inffast = function u(I, a) {
|
|
6166
|
-
let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, ut, it,
|
|
6168
|
+
let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, ut, it, at, st, rt;
|
|
6167
6169
|
const ct = I.state;
|
|
6168
6170
|
E = I.next_in, st = I.input, _ = E + (I.avail_in - 5), k = I.next_out, rt = I.output, e = k - (a - I.avail_out), n = k + (I.avail_out - 257), O = ct.dmax, $ = ct.wsize, N = ct.whave, D = ct.wnext, q = ct.window, P = ct.hold, j = ct.bits, V = ct.lencode, J = ct.distcode, z = (1 << ct.lenbits) - 1, Y = (1 << ct.distbits) - 1;
|
|
6169
6171
|
t:
|
|
@@ -6187,13 +6189,13 @@ var inffast = function u(I, a) {
|
|
|
6187
6189
|
I.msg = "invalid distance too far back", ct.mode = BAD$1;
|
|
6188
6190
|
break t;
|
|
6189
6191
|
}
|
|
6190
|
-
if (it = 0,
|
|
6192
|
+
if (it = 0, at = q, D === 0) {
|
|
6191
6193
|
if (it += $ - tt, tt < nt) {
|
|
6192
6194
|
nt -= tt;
|
|
6193
6195
|
do
|
|
6194
6196
|
rt[k++] = q[it++];
|
|
6195
6197
|
while (--tt);
|
|
6196
|
-
it = k - ut,
|
|
6198
|
+
it = k - ut, at = rt;
|
|
6197
6199
|
}
|
|
6198
6200
|
} else if (D < tt) {
|
|
6199
6201
|
if (it += $ + D - tt, tt -= D, tt < nt) {
|
|
@@ -6206,7 +6208,7 @@ var inffast = function u(I, a) {
|
|
|
6206
6208
|
do
|
|
6207
6209
|
rt[k++] = q[it++];
|
|
6208
6210
|
while (--tt);
|
|
6209
|
-
it = k - ut,
|
|
6211
|
+
it = k - ut, at = rt;
|
|
6210
6212
|
}
|
|
6211
6213
|
}
|
|
6212
6214
|
} else if (it += D - tt, tt < nt) {
|
|
@@ -6214,11 +6216,11 @@ var inffast = function u(I, a) {
|
|
|
6214
6216
|
do
|
|
6215
6217
|
rt[k++] = q[it++];
|
|
6216
6218
|
while (--tt);
|
|
6217
|
-
it = k - ut,
|
|
6219
|
+
it = k - ut, at = rt;
|
|
6218
6220
|
}
|
|
6219
6221
|
for (; nt > 2; )
|
|
6220
|
-
rt[k++] =
|
|
6221
|
-
nt && (rt[k++] =
|
|
6222
|
+
rt[k++] = at[it++], rt[k++] = at[it++], rt[k++] = at[it++], nt -= 3;
|
|
6223
|
+
nt && (rt[k++] = at[it++], nt > 1 && (rt[k++] = at[it++]));
|
|
6222
6224
|
} else {
|
|
6223
6225
|
it = k - ut;
|
|
6224
6226
|
do
|
|
@@ -6386,9 +6388,9 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
6386
6388
|
64
|
|
6387
6389
|
]), inflate_table = (u, I, a, E, _, k, e, n) => {
|
|
6388
6390
|
const O = n.bits;
|
|
6389
|
-
let $ = 0, N = 0, D = 0, q = 0, P = 0, j = 0, V = 0, J = 0, z = 0, Y = 0, et, tt, nt, ut, it,
|
|
6391
|
+
let $ = 0, N = 0, D = 0, q = 0, P = 0, j = 0, V = 0, J = 0, z = 0, Y = 0, et, tt, nt, ut, it, at = null, st;
|
|
6390
6392
|
const rt = new Uint16Array(MAXBITS + 1), ct = new Uint16Array(MAXBITS + 1);
|
|
6391
|
-
let $t = null,
|
|
6393
|
+
let $t = null, ie, Ct, Ut;
|
|
6392
6394
|
for ($ = 0; $ <= MAXBITS; $++)
|
|
6393
6395
|
rt[$] = 0;
|
|
6394
6396
|
for (N = 0; N < E; N++)
|
|
@@ -6408,12 +6410,12 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
6408
6410
|
ct[$ + 1] = ct[$] + rt[$];
|
|
6409
6411
|
for (N = 0; N < E; N++)
|
|
6410
6412
|
I[a + N] !== 0 && (e[ct[I[a + N]]++] = N);
|
|
6411
|
-
if (u === CODES$1 ? (
|
|
6413
|
+
if (u === CODES$1 ? (at = $t = e, st = 20) : u === LENS$1 ? (at = lbase, $t = lext, st = 257) : (at = dbase, $t = dext, st = 0), Y = 0, N = 0, $ = D, it = k, j = P, V = 0, nt = -1, z = 1 << P, ut = z - 1, u === LENS$1 && z > ENOUGH_LENS$1 || u === DISTS$1 && z > ENOUGH_DISTS$1)
|
|
6412
6414
|
return 1;
|
|
6413
6415
|
for (; ; ) {
|
|
6414
|
-
|
|
6416
|
+
ie = $ - V, e[N] + 1 < st ? (Ct = 0, Ut = e[N]) : e[N] >= st ? (Ct = $t[e[N] - st], Ut = at[e[N] - st]) : (Ct = 96, Ut = 0), et = 1 << $ - V, tt = 1 << j, D = tt;
|
|
6415
6417
|
do
|
|
6416
|
-
tt -= et, _[it + (Y >> V) + tt] =
|
|
6418
|
+
tt -= et, _[it + (Y >> V) + tt] = ie << 24 | Ct << 16 | Ut | 0;
|
|
6417
6419
|
while (tt !== 0);
|
|
6418
6420
|
for (et = 1 << $ - 1; Y & et; )
|
|
6419
6421
|
et >>= 1;
|
|
@@ -6501,7 +6503,7 @@ const fixedtables = (u) => {
|
|
|
6501
6503
|
const k = u.state;
|
|
6502
6504
|
return k.window === null && (k.wsize = 1 << k.wbits, k.wnext = 0, k.whave = 0, k.window = new Uint8Array(k.wsize)), E >= k.wsize ? (k.window.set(I.subarray(a - k.wsize, a), 0), k.wnext = 0, k.whave = k.wsize) : (_ = k.wsize - k.wnext, _ > E && (_ = E), k.window.set(I.subarray(a - E, a - E + _), k.wnext), E -= _, E ? (k.window.set(I.subarray(a - E, a), 0), k.wnext = E, k.whave = k.wsize) : (k.wnext += _, k.wnext === k.wsize && (k.wnext = 0), k.whave < k.wsize && (k.whave += _))), 0;
|
|
6503
6505
|
}, inflate$2 = (u, I) => {
|
|
6504
|
-
let a, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, ut, it,
|
|
6506
|
+
let a, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, ut, it, at;
|
|
6505
6507
|
const st = new Uint8Array(4);
|
|
6506
6508
|
let rt, ct;
|
|
6507
6509
|
const $t = (
|
|
@@ -6510,7 +6512,7 @@ const fixedtables = (u) => {
|
|
|
6510
6512
|
);
|
|
6511
6513
|
if (inflateStateCheck(u) || !u.output || !u.input && u.avail_in !== 0)
|
|
6512
6514
|
return Z_STREAM_ERROR$1;
|
|
6513
|
-
a = u.state, a.mode === TYPE && (a.mode = TYPEDO), e = u.next_out, _ = u.output, O = u.avail_out, k = u.next_in, E = u.input, n = u.avail_in, $ = a.hold, N = a.bits, D = n, q = O,
|
|
6515
|
+
a = u.state, a.mode === TYPE && (a.mode = TYPEDO), e = u.next_out, _ = u.output, O = u.avail_out, k = u.next_in, E = u.input, n = u.avail_in, $ = a.hold, N = a.bits, D = n, q = O, at = Z_OK$1;
|
|
6514
6516
|
t:
|
|
6515
6517
|
for (; ; )
|
|
6516
6518
|
switch (a.mode) {
|
|
@@ -6734,7 +6736,7 @@ const fixedtables = (u) => {
|
|
|
6734
6736
|
}
|
|
6735
6737
|
for (; a.have < 19; )
|
|
6736
6738
|
a.lens[$t[a.have++]] = 0;
|
|
6737
|
-
if (a.lencode = a.lendyn, a.lenbits = 7, rt = { bits: a.lenbits },
|
|
6739
|
+
if (a.lencode = a.lendyn, a.lenbits = 7, rt = { bits: a.lenbits }, at = inftrees(CODES, a.lens, 0, 19, a.lencode, 0, a.work, rt), a.lenbits = rt.bits, at) {
|
|
6738
6740
|
u.msg = "invalid code lengths set", a.mode = BAD;
|
|
6739
6741
|
break;
|
|
6740
6742
|
}
|
|
@@ -6790,11 +6792,11 @@ const fixedtables = (u) => {
|
|
|
6790
6792
|
u.msg = "invalid code -- missing end-of-block", a.mode = BAD;
|
|
6791
6793
|
break;
|
|
6792
6794
|
}
|
|
6793
|
-
if (a.lenbits = 9, rt = { bits: a.lenbits },
|
|
6795
|
+
if (a.lenbits = 9, rt = { bits: a.lenbits }, at = inftrees(LENS, a.lens, 0, a.nlen, a.lencode, 0, a.work, rt), a.lenbits = rt.bits, at) {
|
|
6794
6796
|
u.msg = "invalid literal/lengths set", a.mode = BAD;
|
|
6795
6797
|
break;
|
|
6796
6798
|
}
|
|
6797
|
-
if (a.distbits = 6, a.distcode = a.distdyn, rt = { bits: a.distbits },
|
|
6799
|
+
if (a.distbits = 6, a.distcode = a.distdyn, rt = { bits: a.distbits }, at = inftrees(DISTS, a.lens, a.nlen, a.ndist, a.distcode, 0, a.work, rt), a.distbits = rt.bits, at) {
|
|
6798
6800
|
u.msg = "invalid distances set", a.mode = BAD;
|
|
6799
6801
|
break;
|
|
6800
6802
|
}
|
|
@@ -6936,10 +6938,10 @@ const fixedtables = (u) => {
|
|
|
6936
6938
|
a.mode = DONE;
|
|
6937
6939
|
/* falls through */
|
|
6938
6940
|
case DONE:
|
|
6939
|
-
|
|
6941
|
+
at = Z_STREAM_END$1;
|
|
6940
6942
|
break t;
|
|
6941
6943
|
case BAD:
|
|
6942
|
-
|
|
6944
|
+
at = Z_DATA_ERROR$1;
|
|
6943
6945
|
break t;
|
|
6944
6946
|
case MEM:
|
|
6945
6947
|
return Z_MEM_ERROR$1;
|
|
@@ -6949,7 +6951,7 @@ const fixedtables = (u) => {
|
|
|
6949
6951
|
return Z_STREAM_ERROR$1;
|
|
6950
6952
|
}
|
|
6951
6953
|
return u.next_out = e, u.avail_out = O, u.next_in = k, u.avail_in = n, a.hold = $, a.bits = N, (a.wsize || q !== u.avail_out && a.mode < BAD && (a.mode < CHECK || I !== Z_FINISH$1)) && updatewindow(u, u.output, u.next_out, q - u.avail_out), D -= u.avail_in, q -= u.avail_out, u.total_in += D, u.total_out += q, a.total += q, a.wrap & 4 && q && (u.adler = a.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/
|
|
6952
|
-
a.flags ? crc32_1(a.check, _, q, u.next_out - q) : adler32_1(a.check, _, q, u.next_out - q)), u.data_type = a.bits + (a.last ? 64 : 0) + (a.mode === TYPE ? 128 : 0) + (a.mode === LEN_ || a.mode === COPY_ ? 256 : 0), (D === 0 && q === 0 || I === Z_FINISH$1) &&
|
|
6954
|
+
a.flags ? crc32_1(a.check, _, q, u.next_out - q) : adler32_1(a.check, _, q, u.next_out - q)), u.data_type = a.bits + (a.last ? 64 : 0) + (a.mode === TYPE ? 128 : 0) + (a.mode === LEN_ || a.mode === COPY_ ? 256 : 0), (D === 0 && q === 0 || I === Z_FINISH$1) && at === Z_OK$1 && (at = Z_BUF_ERROR), at;
|
|
6953
6955
|
}, inflateEnd = (u) => {
|
|
6954
6956
|
if (inflateStateCheck(u))
|
|
6955
6957
|
return Z_STREAM_ERROR$1;
|
|
@@ -7183,12 +7185,12 @@ const noLogEvents = ["heartbeat", "onNetQuality", "networkQualityChange"], compr
|
|
|
7183
7185
|
}
|
|
7184
7186
|
return u;
|
|
7185
7187
|
};
|
|
7186
|
-
var wt, dt,
|
|
7188
|
+
var wt, dt, xt, yt, bt, Mt, Pt, Lt, Bt, Nt, jt, Zt, Ft;
|
|
7187
7189
|
class CallsWebSocket {
|
|
7188
7190
|
// 状态
|
|
7189
7191
|
constructor(I) {
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
+
lt(this, wt);
|
|
7193
|
+
lt(this, dt, {
|
|
7192
7194
|
url: "wss://demo.putplay.cc/websocket",
|
|
7193
7195
|
// 地址
|
|
7194
7196
|
debug: !1,
|
|
@@ -7197,10 +7199,10 @@ class CallsWebSocket {
|
|
|
7197
7199
|
// 最大重连次数
|
|
7198
7200
|
timeout: 20 * 1e3
|
|
7199
7201
|
});
|
|
7200
|
-
|
|
7202
|
+
lt(this, xt, "");
|
|
7201
7203
|
// 缓存登录凭证
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
+
lt(this, yt, {});
|
|
7205
|
+
lt(this, bt, {});
|
|
7204
7206
|
Z(this, "state", "closed");
|
|
7205
7207
|
// 外部 发送消息之前
|
|
7206
7208
|
Z(this, "sendMessageBefore", async () => {
|
|
@@ -7212,26 +7214,26 @@ class CallsWebSocket {
|
|
|
7212
7214
|
Z(this, "onReconnectStop", (I) => {
|
|
7213
7215
|
});
|
|
7214
7216
|
// 是否需要重连
|
|
7215
|
-
|
|
7217
|
+
lt(this, Mt, (I) => {
|
|
7216
7218
|
let a = !0;
|
|
7217
7219
|
const { code: E = 1e3 } = I;
|
|
7218
7220
|
return E === 1e3 && (a = !1), a;
|
|
7219
7221
|
});
|
|
7220
7222
|
// 重连成功
|
|
7221
|
-
|
|
7223
|
+
lt(this, Pt, async (I) => {
|
|
7222
7224
|
Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重连成功", I), this.state = "connected", this.onReconnectSuccess(I);
|
|
7223
7225
|
});
|
|
7224
7226
|
// 重连停止
|
|
7225
|
-
|
|
7227
|
+
lt(this, Lt, async (I) => {
|
|
7226
7228
|
Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重连停止", I), this.close(), this.state = "closed", this.onReconnectStop(I);
|
|
7227
7229
|
});
|
|
7228
7230
|
// 自定义心跳规则
|
|
7229
|
-
|
|
7231
|
+
lt(this, Bt, () => {
|
|
7230
7232
|
const I = { event: "heartbeat", sn: +`${F(1e5, 999999)}` };
|
|
7231
7233
|
return com.quick.voice.proto.CommonReq.encode(I).finish();
|
|
7232
7234
|
});
|
|
7233
7235
|
// 更新日志
|
|
7234
|
-
|
|
7236
|
+
lt(this, Nt, (I, a = {}) => {
|
|
7235
7237
|
try {
|
|
7236
7238
|
const { time: E, event: _, data: k = {}, data_original: e = {}, data_remote: n, ...O } = a, $ = U(E, "YYYY-MM-DD hh:mm:ss", { offset: 480 });
|
|
7237
7239
|
let N = {};
|
|
@@ -7270,7 +7272,7 @@ class CallsWebSocket {
|
|
|
7270
7272
|
}
|
|
7271
7273
|
});
|
|
7272
7274
|
// 创建事件
|
|
7273
|
-
|
|
7275
|
+
lt(this, jt, (I, { resolve: a, reject: E }) => {
|
|
7274
7276
|
const { sn: _ } = I, k = () => {
|
|
7275
7277
|
const n = Q(this, yt)[_];
|
|
7276
7278
|
clearTimeout(n.destructionTimer), delete Q(this, yt)[_];
|
|
@@ -7281,13 +7283,13 @@ class CallsWebSocket {
|
|
|
7281
7283
|
Q(this, yt)[_] = { message: I, resolve: a, reject: E, destruction: k, destructionTimer: e };
|
|
7282
7284
|
});
|
|
7283
7285
|
// 获取事件
|
|
7284
|
-
|
|
7286
|
+
lt(this, Zt, (I) => Q(this, yt)[I]);
|
|
7285
7287
|
// 接收消息
|
|
7286
|
-
|
|
7288
|
+
lt(this, Ft, async (I) => {
|
|
7287
7289
|
const a = new Uint8Array(I), E = com.quick.voice.proto.CommonRsp.decode(a), { sn: _, event: k } = E, e = onMessageFormat(E);
|
|
7288
|
-
if (Q(this, dt).debug && (noLogEvents.includes(k) || console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e), ignoreEvent.includes(k) || Q(this,
|
|
7290
|
+
if (Q(this, dt).debug && (noLogEvents.includes(k) || console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e), ignoreEvent.includes(k) || Q(this, Nt).call(this, "res", e)), notifyName_keys.includes(k))
|
|
7289
7291
|
return this.emitNotify(k, L(e, ["code", "data", "desc"]));
|
|
7290
|
-
const O = Q(this,
|
|
7292
|
+
const O = Q(this, Zt).call(this, _);
|
|
7291
7293
|
if (O) {
|
|
7292
7294
|
const { resolve: $ = (D) => {
|
|
7293
7295
|
}, destruction: N = () => {
|
|
@@ -7311,17 +7313,17 @@ class CallsWebSocket {
|
|
|
7311
7313
|
* @returns
|
|
7312
7314
|
*/
|
|
7313
7315
|
Z(this, "connect", async (I = "") => new Promise(async (a) => {
|
|
7314
|
-
I && St(this,
|
|
7315
|
-
const E = `${Q(this, dt).url}?s=${Q(this,
|
|
7316
|
+
I && St(this, xt, I), Q(this, wt) && (await Q(this, wt).close(), this.state = "closed");
|
|
7317
|
+
const E = `${Q(this, dt).url}?s=${Q(this, xt)}&t=${Date.now()}`;
|
|
7316
7318
|
St(this, wt, new M({
|
|
7317
7319
|
...Q(this, dt),
|
|
7318
7320
|
url: E,
|
|
7319
7321
|
binaryType: "arraybuffer",
|
|
7320
|
-
onMessage: Q(this,
|
|
7321
|
-
checkReconnect: Q(this,
|
|
7322
|
-
getHeartbeatMsg: Q(this,
|
|
7323
|
-
onReconnectSuccess: Q(this,
|
|
7324
|
-
onReconnectStop: Q(this,
|
|
7322
|
+
onMessage: Q(this, Ft),
|
|
7323
|
+
checkReconnect: Q(this, Mt),
|
|
7324
|
+
getHeartbeatMsg: Q(this, Bt),
|
|
7325
|
+
onReconnectSuccess: Q(this, Pt),
|
|
7326
|
+
onReconnectStop: Q(this, Lt)
|
|
7325
7327
|
})), this.state = "connecting", await Q(this, wt).connect(), this.state = "connected", Q(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", Q(this, bt)), a(Q(this, wt));
|
|
7326
7328
|
}));
|
|
7327
7329
|
/**
|
|
@@ -7353,7 +7355,7 @@ class CallsWebSocket {
|
|
|
7353
7355
|
compress: !1,
|
|
7354
7356
|
...e
|
|
7355
7357
|
});
|
|
7356
|
-
Q(this, dt).debug && (noLogEvents.includes(k) || console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", O), ignoreEvent.includes(k) || Q(this,
|
|
7358
|
+
Q(this, dt).debug && (noLogEvents.includes(k) || console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", O), ignoreEvent.includes(k) || Q(this, Nt).call(this, "req", O)), a && Q(this, jt).call(this, O, { resolve: E, reject: _ });
|
|
7357
7359
|
const $ = com.quick.voice.proto.CommonReq.encode(O).finish();
|
|
7358
7360
|
(N = Q(this, wt)) == null || N.sendMessage($);
|
|
7359
7361
|
}));
|
|
@@ -7398,7 +7400,7 @@ class CallsWebSocket {
|
|
|
7398
7400
|
St(this, dt, { ...Q(this, dt), ...I });
|
|
7399
7401
|
}
|
|
7400
7402
|
}
|
|
7401
|
-
wt = new WeakMap(), dt = new WeakMap(),
|
|
7403
|
+
wt = new WeakMap(), dt = new WeakMap(), xt = new WeakMap(), yt = new WeakMap(), bt = new WeakMap(), Mt = new WeakMap(), Pt = new WeakMap(), Lt = new WeakMap(), Bt = new WeakMap(), Nt = new WeakMap(), jt = new WeakMap(), Zt = new WeakMap(), Ft = new WeakMap();
|
|
7402
7404
|
var y = Object.defineProperty, x = (u) => {
|
|
7403
7405
|
throw TypeError(u);
|
|
7404
7406
|
}, g = (u, I, a) => I in u ? y(u, I, { enumerable: !0, configurable: !0, writable: !0, value: a }) : u[I] = a, h = (u, I, a) => g(u, typeof I != "symbol" ? I + "" : I, a), b = (u, I, a) => I.has(u) || x("Cannot " + a), o = (u, I, a) => (b(u, I, "read from private field"), a ? a.call(u) : I.get(u)), f = (u, I, a) => I.has(u) ? x("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(u) : I.set(u, a), p = (u, I, a, E) => (b(u, I, "write to private field"), I.set(u, a), a), d, c, l;
|
|
@@ -7454,7 +7456,24 @@ class K {
|
|
|
7454
7456
|
}
|
|
7455
7457
|
}
|
|
7456
7458
|
d = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
|
|
7457
|
-
|
|
7459
|
+
const createMutedAudioStream = (u) => {
|
|
7460
|
+
const I = u.createOscillator();
|
|
7461
|
+
I.type = "sine", I.frequency.setValueAtTime(0, u.currentTime);
|
|
7462
|
+
const a = u.createGain();
|
|
7463
|
+
a.gain.value = 0, I.connect(a), a.connect(u.destination), I.start();
|
|
7464
|
+
const E = u.createMediaStreamDestination();
|
|
7465
|
+
return a.disconnect(), I.connect(E), E.stream;
|
|
7466
|
+
}, createFakeVideoStream = (u = 10, I = 10, a = 30) => {
|
|
7467
|
+
const E = document.createElement("canvas"), _ = E.getContext("2d");
|
|
7468
|
+
E.width = u, E.height = I;
|
|
7469
|
+
let k = 0;
|
|
7470
|
+
return setInterval(() => {
|
|
7471
|
+
_.clearRect(0, 0, E.width, E.height);
|
|
7472
|
+
const O = _.createLinearGradient(0, 0, E.width, E.height);
|
|
7473
|
+
O.addColorStop(0, `hsla(${k}, 100%, 50%, 0)`), O.addColorStop(1, `hsla(${k + 120}, 100%, 50%, 0)`), _.fillStyle = O, _.fillRect(0, 0, E.width, E.height), k = (k + 1) % 360;
|
|
7474
|
+
}, 100), E.captureStream(a);
|
|
7475
|
+
};
|
|
7476
|
+
var Ht;
|
|
7458
7477
|
class RoomBase {
|
|
7459
7478
|
constructor(I) {
|
|
7460
7479
|
Z(this, "options", {
|
|
@@ -7491,6 +7510,8 @@ class RoomBase {
|
|
|
7491
7510
|
// 用户
|
|
7492
7511
|
Z(this, "setLocalStreamActiveMap", /* @__PURE__ */ new Map());
|
|
7493
7512
|
// 本地数据是否已开启调用
|
|
7513
|
+
Z(this, "phoneyStreams", /* @__PURE__ */ new Map());
|
|
7514
|
+
// 假媒体流 (创建轨道用)
|
|
7494
7515
|
// 设备错误信息
|
|
7495
7516
|
Z(this, "mediaDevicesErrInfo", {
|
|
7496
7517
|
microphoneCamera_audio: "",
|
|
@@ -7530,7 +7551,34 @@ class RoomBase {
|
|
|
7530
7551
|
}
|
|
7531
7552
|
}
|
|
7532
7553
|
});
|
|
7533
|
-
|
|
7554
|
+
// 初始化假数据流
|
|
7555
|
+
Z(this, "initPhoneyStreams", (I) => {
|
|
7556
|
+
for (const a of mediaType_keys) {
|
|
7557
|
+
const E = this.phoneyStreams.get(a);
|
|
7558
|
+
if (E) {
|
|
7559
|
+
const _ = E.getTracks();
|
|
7560
|
+
for (const k of _)
|
|
7561
|
+
k.stop();
|
|
7562
|
+
}
|
|
7563
|
+
switch (a) {
|
|
7564
|
+
case "microphoneCamera_audio":
|
|
7565
|
+
this.phoneyStreams.set("microphoneCamera_audio", createMutedAudioStream(I));
|
|
7566
|
+
break;
|
|
7567
|
+
case "microphoneCamera_video":
|
|
7568
|
+
this.phoneyStreams.set("microphoneCamera_video", createFakeVideoStream());
|
|
7569
|
+
break;
|
|
7570
|
+
case "screenSharing_audio":
|
|
7571
|
+
this.phoneyStreams.set("screenSharing_audio", createMutedAudioStream(I));
|
|
7572
|
+
break;
|
|
7573
|
+
case "screenSharing_video":
|
|
7574
|
+
this.phoneyStreams.set("screenSharing_video", createFakeVideoStream());
|
|
7575
|
+
break;
|
|
7576
|
+
}
|
|
7577
|
+
}
|
|
7578
|
+
});
|
|
7579
|
+
// 获取假数据流
|
|
7580
|
+
Z(this, "getPhoneyStreams", (I) => this.phoneyStreams.get(I));
|
|
7581
|
+
lt(this, Ht, () => {
|
|
7534
7582
|
this.taskQueue.setCondition("createWs", !0), this.taskQueue.setCondition("createSession", !1), this.taskQueue.setCondition("ice", !1);
|
|
7535
7583
|
});
|
|
7536
7584
|
/**
|
|
@@ -7631,44 +7679,44 @@ class RoomBase {
|
|
|
7631
7679
|
* 处理为应用层数据
|
|
7632
7680
|
*/
|
|
7633
7681
|
Z(this, "usersFilter", (I) => ft(I, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "permissions", "isPublished", "updateStreams"]).sort((_, k) => _.id.localeCompare(k.id, "en")));
|
|
7634
|
-
this.setOptions(I), this.cwsIns = new CallsWebSocket({ ...I }), Q(this,
|
|
7682
|
+
this.setOptions(I), this.cwsIns = new CallsWebSocket({ ...I }), Q(this, Ht).call(this);
|
|
7635
7683
|
}
|
|
7636
7684
|
}
|
|
7637
|
-
|
|
7638
|
-
var
|
|
7685
|
+
Ht = new WeakMap();
|
|
7686
|
+
var It, kt, _t, vt, Ot, gt, zt, Jt, Rt, Wt;
|
|
7639
7687
|
class RoomMedias extends RoomBase {
|
|
7640
7688
|
constructor(a) {
|
|
7641
7689
|
super(a);
|
|
7642
|
-
|
|
7690
|
+
lt(this, It, []);
|
|
7643
7691
|
// 可用媒体设备列表
|
|
7644
|
-
|
|
7692
|
+
lt(this, kt, /* @__PURE__ */ new Map());
|
|
7645
7693
|
// 媒体流设备管理
|
|
7646
|
-
|
|
7694
|
+
lt(this, _t, /* @__PURE__ */ new Map());
|
|
7647
7695
|
// 媒体轨道参数管理
|
|
7648
|
-
|
|
7696
|
+
lt(this, vt, /* @__PURE__ */ new Map());
|
|
7649
7697
|
// 媒体流上下文
|
|
7650
|
-
|
|
7698
|
+
lt(this, Ot, /* @__PURE__ */ new Map());
|
|
7651
7699
|
// 本地流管理
|
|
7652
7700
|
Z(this, "localStreamsActionMap", /* @__PURE__ */ new Map());
|
|
7653
7701
|
// 本地流活动状态管理
|
|
7654
7702
|
// @ts-ignore 音频上下文
|
|
7655
|
-
|
|
7703
|
+
lt(this, gt, new (window.AudioContext || window.webkitAudioContext)());
|
|
7656
7704
|
/**
|
|
7657
7705
|
* 播放所有音频
|
|
7658
7706
|
*/
|
|
7659
7707
|
Z(this, "resume", () => {
|
|
7660
|
-
Q(this,
|
|
7708
|
+
Q(this, gt).resume();
|
|
7661
7709
|
});
|
|
7662
7710
|
/**
|
|
7663
7711
|
* 初始化媒体参数
|
|
7664
7712
|
*/
|
|
7665
|
-
|
|
7713
|
+
lt(this, zt, () => {
|
|
7666
7714
|
Q(this, _t).set("microphoneCamera_audio", { autoGainControl: !1, echoCancellation: !1, noiseSuppression: !1 }), Q(this, _t).set("microphoneCamera_video", { frameRate: { min: 10, ideal: 30 } }), Q(this, _t).set("screenSharing_video", { frameRate: { min: 10, ideal: 30 } }), Q(this, _t).set("screenSharing_audio", { autoGainControl: !1, echoCancellation: !1, noiseSuppression: !1 });
|
|
7667
7715
|
});
|
|
7668
7716
|
/**
|
|
7669
7717
|
* 初始化媒体设备类型
|
|
7670
7718
|
*/
|
|
7671
|
-
|
|
7719
|
+
lt(this, Jt, () => {
|
|
7672
7720
|
Q(this, kt).set("audioinput", "default"), Q(this, kt).set("videoinput", "default"), Q(this, kt).set("audiooutput", "default");
|
|
7673
7721
|
});
|
|
7674
7722
|
/**
|
|
@@ -7693,7 +7741,7 @@ class RoomMedias extends RoomBase {
|
|
|
7693
7741
|
// 音频媒体处理
|
|
7694
7742
|
case "audio":
|
|
7695
7743
|
{
|
|
7696
|
-
const $ = new AudioMediaContext(k, Q(this,
|
|
7744
|
+
const $ = new AudioMediaContext(k, Q(this, gt));
|
|
7697
7745
|
Q(this, vt).set(e, $);
|
|
7698
7746
|
}
|
|
7699
7747
|
break;
|
|
@@ -7791,14 +7839,14 @@ class RoomMedias extends RoomBase {
|
|
|
7791
7839
|
Z(this, "stopLocalStreams", async (a = []) => {
|
|
7792
7840
|
a.length === 0 && (a = mediaType_keys);
|
|
7793
7841
|
for (const E of a) {
|
|
7794
|
-
const _ = Q(this,
|
|
7795
|
-
_ && await this.stopStream(_), Q(this,
|
|
7842
|
+
const _ = Q(this, Ot).get(E);
|
|
7843
|
+
_ && await this.stopStream(_), Q(this, Ot).delete(E);
|
|
7796
7844
|
}
|
|
7797
7845
|
});
|
|
7798
7846
|
// 添加本地流
|
|
7799
7847
|
Z(this, "addLocalStream", (a, E) => {
|
|
7800
|
-
const _ = Q(this,
|
|
7801
|
-
_ && this.stopStream(_), Q(this,
|
|
7848
|
+
const _ = Q(this, Ot).get(a);
|
|
7849
|
+
_ && this.stopStream(_), Q(this, Ot).set(a, E);
|
|
7802
7850
|
});
|
|
7803
7851
|
/**
|
|
7804
7852
|
* 初始化本地流
|
|
@@ -7884,7 +7932,7 @@ class RoomMedias extends RoomBase {
|
|
|
7884
7932
|
/**
|
|
7885
7933
|
* 获取本地的数据流
|
|
7886
7934
|
*/
|
|
7887
|
-
Z(this, "getLocalStream", (a) => Q(this,
|
|
7935
|
+
Z(this, "getLocalStream", (a) => Q(this, Ot).get(a));
|
|
7888
7936
|
/**
|
|
7889
7937
|
* 获取本地的某些数据流
|
|
7890
7938
|
*/
|
|
@@ -7898,18 +7946,18 @@ class RoomMedias extends RoomBase {
|
|
|
7898
7946
|
/**
|
|
7899
7947
|
* 获取媒体设备列表
|
|
7900
7948
|
*/
|
|
7901
|
-
|
|
7902
|
-
St(this,
|
|
7949
|
+
lt(this, Rt, 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((a) => {
|
|
7950
|
+
St(this, It, a.sort((E, _) => E.label.localeCompare(_.label, "zh-Hans-CN", { sensitivity: "accent" })));
|
|
7903
7951
|
}).catch(function(a) {
|
|
7904
7952
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", a);
|
|
7905
|
-
}), Q(this,
|
|
7953
|
+
}), Q(this, It)));
|
|
7906
7954
|
/**
|
|
7907
7955
|
* 媒体设备发生变化
|
|
7908
7956
|
*/
|
|
7909
|
-
|
|
7957
|
+
lt(this, Wt, () => {
|
|
7910
7958
|
navigator.mediaDevices && (navigator.mediaDevices.ondevicechange = async () => {
|
|
7911
|
-
await Q(this,
|
|
7912
|
-
}), Q(this,
|
|
7959
|
+
await Q(this, Rt).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
|
|
7960
|
+
}), Q(this, Rt).call(this);
|
|
7913
7961
|
});
|
|
7914
7962
|
/**
|
|
7915
7963
|
* 获取正在使用的媒体设备ID
|
|
@@ -7949,7 +7997,7 @@ class RoomMedias extends RoomBase {
|
|
|
7949
7997
|
* @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
|
|
7950
7998
|
* @returns MediaDeviceInfo[]
|
|
7951
7999
|
*/
|
|
7952
|
-
Z(this, "getEnumerateDevices", async (a) => (await Q(this,
|
|
8000
|
+
Z(this, "getEnumerateDevices", async (a) => (await Q(this, Rt).call(this), Q(this, It).filter((_) => _.kind === a)));
|
|
7953
8001
|
/**
|
|
7954
8002
|
* 获取可用音频输入设备
|
|
7955
8003
|
* @returns MediaDeviceInfo[]
|
|
@@ -7965,13 +8013,13 @@ class RoomMedias extends RoomBase {
|
|
|
7965
8013
|
* @returns MediaDeviceInfo[]
|
|
7966
8014
|
*/
|
|
7967
8015
|
Z(this, "getEnumerateVideoinputDevices", () => this.getEnumerateDevices("videoinput"));
|
|
7968
|
-
Q(this,
|
|
8016
|
+
Q(this, Wt).call(this), Q(this, Jt).call(this), Q(this, zt).call(this), this.initPhoneyStreams(Q(this, gt)), document.addEventListener("click", () => {
|
|
7969
8017
|
var E;
|
|
7970
|
-
((E = Q(this,
|
|
8018
|
+
((E = Q(this, gt)) == null ? void 0 : E.state) === "suspended" && Q(this, gt).resume();
|
|
7971
8019
|
});
|
|
7972
8020
|
}
|
|
7973
8021
|
}
|
|
7974
|
-
|
|
8022
|
+
It = new WeakMap(), kt = new WeakMap(), _t = new WeakMap(), vt = new WeakMap(), Ot = new WeakMap(), gt = new WeakMap(), zt = new WeakMap(), Jt = new WeakMap(), Rt = new WeakMap(), Wt = new WeakMap();
|
|
7975
8023
|
class RoomUsers extends RoomMedias {
|
|
7976
8024
|
constructor(a) {
|
|
7977
8025
|
super(a);
|
|
@@ -8258,29 +8306,10 @@ class RoomUsers extends RoomMedias {
|
|
|
8258
8306
|
});
|
|
8259
8307
|
}
|
|
8260
8308
|
}
|
|
8261
|
-
|
|
8262
|
-
const u = new AudioContext(), I = u.createOscillator();
|
|
8263
|
-
I.type = "sine", I.frequency.setValueAtTime(0, u.currentTime);
|
|
8264
|
-
const a = u.createGain();
|
|
8265
|
-
a.gain.value = 0, I.connect(a), a.connect(u.destination), I.start();
|
|
8266
|
-
const E = u.createMediaStreamDestination();
|
|
8267
|
-
return a.disconnect(), I.connect(E), E.stream;
|
|
8268
|
-
}, createFakeVideoStream = (u = 10, I = 10, a = 30) => {
|
|
8269
|
-
const E = document.createElement("canvas"), _ = E.getContext("2d");
|
|
8270
|
-
E.width = u, E.height = I;
|
|
8271
|
-
let k = 0;
|
|
8272
|
-
return setInterval(() => {
|
|
8273
|
-
_.clearRect(0, 0, E.width, E.height);
|
|
8274
|
-
const O = _.createLinearGradient(0, 0, E.width, E.height);
|
|
8275
|
-
O.addColorStop(0, `hsla(${k}, 100%, 50%, 0)`), O.addColorStop(1, `hsla(${k + 120}, 100%, 50%, 0)`), _.fillStyle = O, _.fillRect(0, 0, E.width, E.height), k = (k + 1) % 360;
|
|
8276
|
-
}, 100), E.captureStream(a);
|
|
8277
|
-
};
|
|
8278
|
-
var Ot, Kt, Qt, Vt, Yt;
|
|
8309
|
+
var Gt, Kt, Qt;
|
|
8279
8310
|
class RoomPeer extends RoomUsers {
|
|
8280
8311
|
constructor(a) {
|
|
8281
8312
|
super(a);
|
|
8282
|
-
at(this, Ot, /* @__PURE__ */ new Map());
|
|
8283
|
-
// 假媒体流 (创建轨道用)
|
|
8284
8313
|
Z(this, "getPeerStatsTimer", 0);
|
|
8285
8314
|
// 获取报告的定时器
|
|
8286
8315
|
Z(this, "reports", []);
|
|
@@ -8298,35 +8327,8 @@ class RoomPeer extends RoomUsers {
|
|
|
8298
8327
|
// 网络抖动
|
|
8299
8328
|
});
|
|
8300
8329
|
Z(this, "initPeer", () => {
|
|
8301
|
-
this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this,
|
|
8302
|
-
});
|
|
8303
|
-
// 初始化假数据流
|
|
8304
|
-
at(this, Kt, () => {
|
|
8305
|
-
for (const a of mediaType_keys) {
|
|
8306
|
-
const E = Q(this, Ot).get(a);
|
|
8307
|
-
if (E) {
|
|
8308
|
-
const _ = E.getTracks();
|
|
8309
|
-
for (const k of _)
|
|
8310
|
-
k.stop();
|
|
8311
|
-
}
|
|
8312
|
-
switch (a) {
|
|
8313
|
-
case "microphoneCamera_audio":
|
|
8314
|
-
Q(this, Ot).set("microphoneCamera_audio", createMutedAudioStream());
|
|
8315
|
-
break;
|
|
8316
|
-
case "microphoneCamera_video":
|
|
8317
|
-
Q(this, Ot).set("microphoneCamera_video", createFakeVideoStream());
|
|
8318
|
-
break;
|
|
8319
|
-
case "screenSharing_audio":
|
|
8320
|
-
Q(this, Ot).set("screenSharing_audio", createMutedAudioStream());
|
|
8321
|
-
break;
|
|
8322
|
-
case "screenSharing_video":
|
|
8323
|
-
Q(this, Ot).set("screenSharing_video", createFakeVideoStream());
|
|
8324
|
-
break;
|
|
8325
|
-
}
|
|
8326
|
-
}
|
|
8330
|
+
this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this, Gt).call(this), Q(this, Qt).call(this);
|
|
8327
8331
|
});
|
|
8328
|
-
// 获取假数据流
|
|
8329
|
-
Z(this, "getPhoneyStreams", (a) => Q(this, Ot).get(a));
|
|
8330
8332
|
/**
|
|
8331
8333
|
* 替换发射器媒体流
|
|
8332
8334
|
*/
|
|
@@ -8445,7 +8447,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8445
8447
|
/**
|
|
8446
8448
|
* 监听webrtc ice通讯连接
|
|
8447
8449
|
*/
|
|
8448
|
-
|
|
8450
|
+
lt(this, Gt, () => {
|
|
8449
8451
|
let a = 0;
|
|
8450
8452
|
const E = () => {
|
|
8451
8453
|
this.setRoomState("closed");
|
|
@@ -8595,7 +8597,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8595
8597
|
/**
|
|
8596
8598
|
* 计算网络质量
|
|
8597
8599
|
*/
|
|
8598
|
-
|
|
8600
|
+
lt(this, Kt, async () => {
|
|
8599
8601
|
try {
|
|
8600
8602
|
const a = await this.peerIns.getStats(), E = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp", "transport"], k = [...a.values()].filter((nt) => E.includes(nt.type));
|
|
8601
8603
|
let e = 0, n = 0, O = 0, $ = 0, N = 0, D = 0, q = [], P = [];
|
|
@@ -8605,23 +8607,23 @@ class RoomPeer extends RoomUsers {
|
|
|
8605
8607
|
}
|
|
8606
8608
|
this.reports = k;
|
|
8607
8609
|
for (const nt of this.reports) {
|
|
8608
|
-
const { bytesSent: ut, bytesReceived: it, packetsSent:
|
|
8609
|
-
ut && (n = ut), it && (e = it),
|
|
8610
|
+
const { bytesSent: ut, bytesReceived: it, packetsSent: at, packetsLost: st, roundTripTime: rt, jitter: ct } = nt;
|
|
8611
|
+
ut && (n = ut), it && (e = it), at && (N += at), st && (D += st), rt && q.push((rt * 100).toFixed(2)), ct && P.push(ct.toFixed(2));
|
|
8610
8612
|
}
|
|
8611
8613
|
P.sort().reverse(), q.sort().reverse();
|
|
8612
8614
|
const j = N - O, V = D - $, J = j === 0 ? "0.00" : (V / j).toFixed(2), [z = "0"] = q, [Y = "0"] = P, et = { outboundBytes: n, inboundBytes: e, lostRate: J, roundTripTime: z, jitter: Y };
|
|
8613
8615
|
this.peerNetwork = et;
|
|
8614
8616
|
const tt = (nt, ut, it) => {
|
|
8615
|
-
const
|
|
8617
|
+
const at = Number(nt), st = Number(ut), rt = Number(it);
|
|
8616
8618
|
let ct = "0";
|
|
8617
|
-
return
|
|
8619
|
+
return at < 0.03 && st < 100 && rt < 0.05 ? ct = "5" : at < 0.06 && st < 160 && rt < 0.1 ? ct = "4" : at < 0.1 && st < 250 && rt < 0.15 ? ct = "3" : at < 0.15 && st < 400 && rt < 0.2 ? ct = "2" : ct = "1", Number(ct);
|
|
8618
8620
|
};
|
|
8619
8621
|
{
|
|
8620
|
-
const nt = tt(J, z, Y), ut = await this.getCaller(), { network: it } = ut,
|
|
8621
|
-
if (await this.updateUserNetwork(this.options.userId,
|
|
8622
|
+
const nt = tt(J, z, Y), ut = await this.getCaller(), { network: it } = ut, at = { egress: nt, ingress: nt }, st = JSON.stringify(it) !== JSON.stringify(at);
|
|
8623
|
+
if (await this.updateUserNetwork(this.options.userId, at), st) {
|
|
8622
8624
|
this.emitNotifyUpdateUsers();
|
|
8623
8625
|
const { userId: rt, roomId: ct } = this.options;
|
|
8624
|
-
this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...
|
|
8626
|
+
this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...at, userId: rt, roomId: ct } }, !1);
|
|
8625
8627
|
}
|
|
8626
8628
|
}
|
|
8627
8629
|
} catch (a) {
|
|
@@ -8631,9 +8633,9 @@ class RoomPeer extends RoomUsers {
|
|
|
8631
8633
|
/**
|
|
8632
8634
|
* 获取连接的所有轨道分析数据
|
|
8633
8635
|
*/
|
|
8634
|
-
|
|
8636
|
+
lt(this, Qt, () => {
|
|
8635
8637
|
const a = async () => {
|
|
8636
|
-
this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this,
|
|
8638
|
+
this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this, Kt).call(this);
|
|
8637
8639
|
};
|
|
8638
8640
|
this.getPeerStatsTimer = setInterval(a, 1 * 1e3);
|
|
8639
8641
|
});
|
|
@@ -8641,11 +8643,10 @@ class RoomPeer extends RoomUsers {
|
|
|
8641
8643
|
* 停止网络报告分析
|
|
8642
8644
|
*/
|
|
8643
8645
|
Z(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
|
|
8644
|
-
Q(this, Kt).call(this);
|
|
8645
8646
|
}
|
|
8646
8647
|
}
|
|
8647
|
-
|
|
8648
|
-
var
|
|
8648
|
+
Gt = new WeakMap(), Kt = new WeakMap(), Qt = new WeakMap();
|
|
8649
|
+
var Vt, Et, At, qt, Dt;
|
|
8649
8650
|
class RoomCalls extends RoomPeer {
|
|
8650
8651
|
constructor(a) {
|
|
8651
8652
|
super(a);
|
|
@@ -8655,7 +8656,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8655
8656
|
* 广播给房间其他人
|
|
8656
8657
|
* 只有当自己建立了发射轨道 并且 加入房间后才进行广播
|
|
8657
8658
|
*/
|
|
8658
|
-
|
|
8659
|
+
lt(this, Vt, async (a) => {
|
|
8659
8660
|
const { roomId: E } = this.options;
|
|
8660
8661
|
if (!E) return;
|
|
8661
8662
|
const { id: _, tracks: k = [] } = await this.getCaller(), e = k.filter((n) => n.mediaType && a.includes(n.mediaType));
|
|
@@ -8664,7 +8665,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8664
8665
|
/**
|
|
8665
8666
|
* 更新自己通话状态
|
|
8666
8667
|
*/
|
|
8667
|
-
|
|
8668
|
+
lt(this, Et, async (a) => new Promise(async (E, _) => {
|
|
8668
8669
|
const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: a } };
|
|
8669
8670
|
await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
|
|
8670
8671
|
const { code: $ = 0 } = O;
|
|
@@ -8675,7 +8676,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8675
8676
|
/**
|
|
8676
8677
|
* 创建连接
|
|
8677
8678
|
*/
|
|
8678
|
-
|
|
8679
|
+
lt(this, At, () => new Promise(async (a, E) => {
|
|
8679
8680
|
try {
|
|
8680
8681
|
if (["connecting", "connected"].includes(this.cwsIns.state)) return a(!0);
|
|
8681
8682
|
this.taskQueue.setCondition("createWs", !1), this.cwsIns.clearEvents(), this.initPeer();
|
|
@@ -8702,7 +8703,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8702
8703
|
/**
|
|
8703
8704
|
* 创建cf会话
|
|
8704
8705
|
*/
|
|
8705
|
-
|
|
8706
|
+
lt(this, qt, () => {
|
|
8706
8707
|
if (!["connecting", "connected"].includes(this.roomState))
|
|
8707
8708
|
return this.setRoomState("connecting"), new Promise((a) => {
|
|
8708
8709
|
const E = async () => {
|
|
@@ -8738,12 +8739,12 @@ class RoomCalls extends RoomPeer {
|
|
|
8738
8739
|
* @example quickvo.earlyConnect(['microphoneCamera_audio', 'microphoneCamera_video'])
|
|
8739
8740
|
*/
|
|
8740
8741
|
Z(this, "earlyConnect", (a = []) => {
|
|
8741
|
-
this.isEarly = !0, Q(this,
|
|
8742
|
+
this.isEarly = !0, Q(this, At).call(this), Q(this, qt).call(this), a.length === 0 && (a = ["microphoneCamera_audio", "microphoneCamera_video"]), Q(this, Dt).call(this, a);
|
|
8742
8743
|
});
|
|
8743
8744
|
/**
|
|
8744
8745
|
* 创建媒体轨道
|
|
8745
8746
|
*/
|
|
8746
|
-
|
|
8747
|
+
lt(this, Dt, async (a) => new Promise((E) => {
|
|
8747
8748
|
const _ = async () => {
|
|
8748
8749
|
try {
|
|
8749
8750
|
this.taskQueue.setCondition("createTrack", !1);
|
|
@@ -8855,7 +8856,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8855
8856
|
* @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' , newPublishAutoSubscribe: true })
|
|
8856
8857
|
* @returns Promise<boolean>
|
|
8857
8858
|
*/
|
|
8858
|
-
Z(this, "joinRoom", async (a) => (this.setOptions(a), await Q(this,
|
|
8859
|
+
Z(this, "joinRoom", async (a) => (this.setOptions(a), await Q(this, At).call(this), new Promise((E, _) => {
|
|
8859
8860
|
this.clearUsers();
|
|
8860
8861
|
let k = "";
|
|
8861
8862
|
const e = async () => {
|
|
@@ -8875,7 +8876,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8875
8876
|
if (q !== 200) return _(P);
|
|
8876
8877
|
const { roomId: V = "", roomUsers: J = [] } = j;
|
|
8877
8878
|
if (V !== O) return _("加入的房间不匹配");
|
|
8878
|
-
this.isInRoom = !0, Q(this,
|
|
8879
|
+
this.isInRoom = !0, Q(this, qt).call(this), await this.updateUsers(J), e();
|
|
8879
8880
|
});
|
|
8880
8881
|
} catch (O) {
|
|
8881
8882
|
this.taskQueue.setCondition("joinRoom", !0), this.reportLogs("join_room_error", O.message || O), _(`加入房间失败: ${O.message || O || "服务器繁忙"}`);
|
|
@@ -8960,11 +8961,11 @@ class RoomCalls extends RoomPeer {
|
|
|
8960
8961
|
}
|
|
8961
8962
|
}
|
|
8962
8963
|
const O = a.filter((q) => !n.includes(q) || ["microphoneCamera_audio", "microphoneCamera_video"].includes(q));
|
|
8963
|
-
await this.replaceSenderStream(a, !1), await Q(this,
|
|
8964
|
+
await this.replaceSenderStream(a, !1), await Q(this, Dt).call(this, O);
|
|
8964
8965
|
const $ = await this.getSenderTracks(O), N = [...e.tracks, ...$];
|
|
8965
8966
|
await this.updateUsertracks(e.id, N, !0);
|
|
8966
8967
|
const D = await this.getCallAction(N);
|
|
8967
|
-
await Q(this,
|
|
8968
|
+
await Q(this, Et).call(this, D), n.length !== 0 && await this.inactiveTracks(n, !1), O.length !== 0 && await this.replaceSenderStream(O, !0), Q(this, Vt).call(this, a);
|
|
8968
8969
|
{
|
|
8969
8970
|
await this.emitNotifyUpdateUsers();
|
|
8970
8971
|
const q = await this.getCaller();
|
|
@@ -8997,7 +8998,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8997
8998
|
await this.replaceSenderStream(a, !0), await this.closeUserTracks(e.id, n, !0), await this.removeSenders(a);
|
|
8998
8999
|
{
|
|
8999
9000
|
const $ = await this.getCallAction(e.tracks);
|
|
9000
|
-
await Q(this,
|
|
9001
|
+
await Q(this, Et).call(this, $);
|
|
9001
9002
|
}
|
|
9002
9003
|
await this.createOffer(), await this.cwsIns.sendMessage({
|
|
9003
9004
|
event: "closeTrack",
|
|
@@ -9138,7 +9139,7 @@ class RoomCalls extends RoomPeer {
|
|
|
9138
9139
|
}
|
|
9139
9140
|
}
|
|
9140
9141
|
const O = await this.getCallAction(n);
|
|
9141
|
-
await Q(this,
|
|
9142
|
+
await Q(this, Et).call(this, O), await this.replaceSenderStream(a, E), await this.emitNotifyUpdateUsers(), _(!0);
|
|
9142
9143
|
}));
|
|
9143
9144
|
/**
|
|
9144
9145
|
* 远端调试
|
|
@@ -9164,21 +9165,21 @@ class RoomCalls extends RoomPeer {
|
|
|
9164
9165
|
}));
|
|
9165
9166
|
}
|
|
9166
9167
|
}
|
|
9167
|
-
|
|
9168
|
+
Vt = new WeakMap(), Et = new WeakMap(), At = new WeakMap(), qt = new WeakMap(), Dt = new WeakMap();
|
|
9168
9169
|
class Room extends RoomCalls {
|
|
9169
9170
|
constructor(I) {
|
|
9170
9171
|
super(I);
|
|
9171
9172
|
}
|
|
9172
9173
|
}
|
|
9173
|
-
var
|
|
9174
|
+
var Tt, Yt, Xt, te, ee;
|
|
9174
9175
|
class QuickVO extends Room {
|
|
9175
9176
|
constructor(a) {
|
|
9176
9177
|
super(a);
|
|
9177
|
-
|
|
9178
|
+
lt(this, Tt, /* @__PURE__ */ new Map());
|
|
9178
9179
|
/**
|
|
9179
9180
|
* 添加内部监听事件
|
|
9180
9181
|
*/
|
|
9181
|
-
|
|
9182
|
+
lt(this, Yt, () => {
|
|
9182
9183
|
{
|
|
9183
9184
|
const a = async (E) => {
|
|
9184
9185
|
const { state: _ } = E.data;
|
|
@@ -9269,12 +9270,12 @@ class QuickVO extends Room {
|
|
|
9269
9270
|
/**
|
|
9270
9271
|
* cwsIns 发送消息前
|
|
9271
9272
|
*/
|
|
9272
|
-
|
|
9273
|
+
lt(this, Xt, () => {
|
|
9273
9274
|
});
|
|
9274
9275
|
/**
|
|
9275
9276
|
* 重连成功
|
|
9276
9277
|
*/
|
|
9277
|
-
|
|
9278
|
+
lt(this, te, () => {
|
|
9278
9279
|
this.cwsIns.onReconnectSuccess = async () => {
|
|
9279
9280
|
await this.syncRoomInfo();
|
|
9280
9281
|
};
|
|
@@ -9282,7 +9283,7 @@ class QuickVO extends Room {
|
|
|
9282
9283
|
/**
|
|
9283
9284
|
* 重连停止
|
|
9284
9285
|
*/
|
|
9285
|
-
|
|
9286
|
+
lt(this, ee, async () => {
|
|
9286
9287
|
this.setRoomState("closed");
|
|
9287
9288
|
});
|
|
9288
9289
|
/**
|
|
@@ -9292,13 +9293,13 @@ class QuickVO extends Room {
|
|
|
9292
9293
|
*/
|
|
9293
9294
|
Z(this, "addRequestAnimationFrame", async (a, E) => {
|
|
9294
9295
|
{
|
|
9295
|
-
const k = Q(this,
|
|
9296
|
+
const k = Q(this, Tt).get(a);
|
|
9296
9297
|
k && cancelAnimationFrame(k);
|
|
9297
9298
|
}
|
|
9298
9299
|
const _ = (k = Date.now()) => {
|
|
9299
9300
|
E(k);
|
|
9300
9301
|
const e = requestAnimationFrame(_);
|
|
9301
|
-
Q(this,
|
|
9302
|
+
Q(this, Tt).set(a, e);
|
|
9302
9303
|
};
|
|
9303
9304
|
_();
|
|
9304
9305
|
});
|
|
@@ -9307,10 +9308,10 @@ class QuickVO extends Room {
|
|
|
9307
9308
|
* @param keys string[] = []
|
|
9308
9309
|
*/
|
|
9309
9310
|
Z(this, "clearRequestAnimationFrame", async (a = []) => {
|
|
9310
|
-
a.length === 0 && (a = [...Q(this,
|
|
9311
|
+
a.length === 0 && (a = [...Q(this, Tt).keys()]);
|
|
9311
9312
|
const E = [];
|
|
9312
9313
|
for (const _ of a) {
|
|
9313
|
-
const k = Q(this,
|
|
9314
|
+
const k = Q(this, Tt).get(_);
|
|
9314
9315
|
k && (cancelAnimationFrame(k), E.push(k));
|
|
9315
9316
|
}
|
|
9316
9317
|
return E;
|
|
@@ -9322,10 +9323,10 @@ class QuickVO extends Room {
|
|
|
9322
9323
|
Z(this, "destroy", async () => {
|
|
9323
9324
|
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 销毁SDK"), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {}, desc: "sdk is destroy." }), this.stopLocalStreams(), await new Promise((a) => setTimeout(() => a(!0), 300)), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.cwsIns.close();
|
|
9324
9325
|
});
|
|
9325
|
-
Q(this,
|
|
9326
|
+
Q(this, Xt).call(this), Q(this, te).call(this), Q(this, ee).call(this), Q(this, Yt).call(this);
|
|
9326
9327
|
}
|
|
9327
9328
|
}
|
|
9328
|
-
|
|
9329
|
+
Tt = new WeakMap(), Yt = new WeakMap(), Xt = new WeakMap(), te = new WeakMap(), ee = new WeakMap();
|
|
9329
9330
|
export {
|
|
9330
9331
|
QuickVO,
|
|
9331
9332
|
ignoreEvent
|