quickvo-sdk-js 0.6.0 → 0.6.2
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 +150 -125
- package/dist/index.umd.cjs +2 -2
- package/dist/room/RoomBase.d.ts +1 -0
- package/dist/room/RoomPeer.d.ts +2 -2
- package/dist/types.d.ts +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var ne = (a) => {
|
|
|
4
4
|
};
|
|
5
5
|
var ce = (a, I, u) => I in a ? re(a, I, { enumerable: !0, configurable: !0, writable: !0, value: u }) : a[I] = u;
|
|
6
6
|
var Z = (a, I, u) => ce(a, typeof I != "symbol" ? I + "" : I, u), oe = (a, I, u) => I.has(a) || ne("Cannot " + u);
|
|
7
|
-
var Q = (a, I, u) => (oe(a, I, "read from private field"), u ? u.call(a) : I.get(a)),
|
|
7
|
+
var Q = (a, I, u) => (oe(a, I, "read from private field"), u ? u.call(a) : I.get(a)), at = (a, I, u) => I.has(a) ? ne("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(a) : I.set(a, u), wt = (a, I, u, E) => (oe(a, I, "write to private field"), E ? E.call(a, u) : I.set(a, u), u);
|
|
8
8
|
const L = (a, I = []) => {
|
|
9
9
|
const u = { ...a }, E = Object.keys(u);
|
|
10
10
|
for (const _ of E)
|
|
@@ -747,9 +747,16 @@ class AudioMediaContext {
|
|
|
747
747
|
* 停止
|
|
748
748
|
*/
|
|
749
749
|
Z(this, "stop", () => {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
750
|
+
{
|
|
751
|
+
const I = this.destination.stream.getTracks();
|
|
752
|
+
for (const u of I)
|
|
753
|
+
u.enabled = !1, u.stop(), this.stream.removeTrack(u);
|
|
754
|
+
}
|
|
755
|
+
{
|
|
756
|
+
const I = this.stream.getTracks();
|
|
757
|
+
for (const u of I)
|
|
758
|
+
u.enabled = !1, u.stop(), this.stream.removeTrack(u);
|
|
759
|
+
}
|
|
753
760
|
});
|
|
754
761
|
/**
|
|
755
762
|
* 替换媒体
|
|
@@ -768,7 +775,7 @@ class AudioMediaContext {
|
|
|
768
775
|
* 静音
|
|
769
776
|
*/
|
|
770
777
|
Z(this, "setMute", (I = !0) => {
|
|
771
|
-
I ? this.analyserNode.disconnect(this.
|
|
778
|
+
I ? this.analyserNode.disconnect(this.destination) : this.analyserNode.connect(this.destination);
|
|
772
779
|
});
|
|
773
780
|
/**
|
|
774
781
|
* 设置音量
|
|
@@ -810,8 +817,8 @@ class AudioMediaContext {
|
|
|
810
817
|
return u && N.connect(e), E && N.connect(n), _ && N.connect(O), N.connect($), I;
|
|
811
818
|
});
|
|
812
819
|
this.stream.addTrack(I), this.audio.srcObject = this.stream, this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.destination = this.audioContext.createMediaStreamDestination(), 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(this.gain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
|
|
813
|
-
const { gainNode: u,
|
|
814
|
-
u.connect(E),
|
|
820
|
+
const { gainNode: u, analyserNode: E, destination: _ } = this;
|
|
821
|
+
u.connect(E), E.connect(_), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
|
|
815
822
|
}
|
|
816
823
|
}
|
|
817
824
|
class VideoMediaContext {
|
|
@@ -6150,7 +6157,7 @@ var Deflate_1$1 = Deflate$1, deflate_2 = deflate$1, deflateRaw_1$1 = deflateRaw$
|
|
|
6150
6157
|
};
|
|
6151
6158
|
const BAD$1 = 16209, TYPE$1 = 16191;
|
|
6152
6159
|
var inffast = function a(I, u) {
|
|
6153
|
-
let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, lt, it,
|
|
6160
|
+
let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, lt, it, st, ct, ot;
|
|
6154
6161
|
const rt = I.state;
|
|
6155
6162
|
E = I.next_in, ct = I.input, _ = E + (I.avail_in - 5), k = I.next_out, ot = I.output, e = k - (u - I.avail_out), n = k + (I.avail_out - 257), O = rt.dmax, $ = rt.wsize, N = rt.whave, D = rt.wnext, q = rt.window, P = rt.hold, j = rt.bits, V = rt.lencode, J = rt.distcode, z = (1 << rt.lenbits) - 1, Y = (1 << rt.distbits) - 1;
|
|
6156
6163
|
t:
|
|
@@ -6174,13 +6181,13 @@ var inffast = function a(I, u) {
|
|
|
6174
6181
|
I.msg = "invalid distance too far back", rt.mode = BAD$1;
|
|
6175
6182
|
break t;
|
|
6176
6183
|
}
|
|
6177
|
-
if (it = 0,
|
|
6184
|
+
if (it = 0, st = q, D === 0) {
|
|
6178
6185
|
if (it += $ - tt, tt < nt) {
|
|
6179
6186
|
nt -= tt;
|
|
6180
6187
|
do
|
|
6181
6188
|
ot[k++] = q[it++];
|
|
6182
6189
|
while (--tt);
|
|
6183
|
-
it = k - lt,
|
|
6190
|
+
it = k - lt, st = ot;
|
|
6184
6191
|
}
|
|
6185
6192
|
} else if (D < tt) {
|
|
6186
6193
|
if (it += $ + D - tt, tt -= D, tt < nt) {
|
|
@@ -6193,7 +6200,7 @@ var inffast = function a(I, u) {
|
|
|
6193
6200
|
do
|
|
6194
6201
|
ot[k++] = q[it++];
|
|
6195
6202
|
while (--tt);
|
|
6196
|
-
it = k - lt,
|
|
6203
|
+
it = k - lt, st = ot;
|
|
6197
6204
|
}
|
|
6198
6205
|
}
|
|
6199
6206
|
} else if (it += D - tt, tt < nt) {
|
|
@@ -6201,11 +6208,11 @@ var inffast = function a(I, u) {
|
|
|
6201
6208
|
do
|
|
6202
6209
|
ot[k++] = q[it++];
|
|
6203
6210
|
while (--tt);
|
|
6204
|
-
it = k - lt,
|
|
6211
|
+
it = k - lt, st = ot;
|
|
6205
6212
|
}
|
|
6206
6213
|
for (; nt > 2; )
|
|
6207
|
-
ot[k++] =
|
|
6208
|
-
nt && (ot[k++] =
|
|
6214
|
+
ot[k++] = st[it++], ot[k++] = st[it++], ot[k++] = st[it++], nt -= 3;
|
|
6215
|
+
nt && (ot[k++] = st[it++], nt > 1 && (ot[k++] = st[it++]));
|
|
6209
6216
|
} else {
|
|
6210
6217
|
it = k - lt;
|
|
6211
6218
|
do
|
|
@@ -6373,7 +6380,7 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
6373
6380
|
64
|
|
6374
6381
|
]), inflate_table = (a, I, u, E, _, k, e, n) => {
|
|
6375
6382
|
const O = n.bits;
|
|
6376
|
-
let $ = 0, N = 0, D = 0, q = 0, P = 0, j = 0, V = 0, J = 0, z = 0, Y = 0, et, tt, nt, lt, it,
|
|
6383
|
+
let $ = 0, N = 0, D = 0, q = 0, P = 0, j = 0, V = 0, J = 0, z = 0, Y = 0, et, tt, nt, lt, it, st = null, ct;
|
|
6377
6384
|
const ot = new Uint16Array(MAXBITS + 1), rt = new Uint16Array(MAXBITS + 1);
|
|
6378
6385
|
let Ot = null, ie, Dt, Ct;
|
|
6379
6386
|
for ($ = 0; $ <= MAXBITS; $++)
|
|
@@ -6395,10 +6402,10 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
6395
6402
|
rt[$ + 1] = rt[$] + ot[$];
|
|
6396
6403
|
for (N = 0; N < E; N++)
|
|
6397
6404
|
I[u + N] !== 0 && (e[rt[I[u + N]]++] = N);
|
|
6398
|
-
if (a === CODES$1 ? (
|
|
6405
|
+
if (a === CODES$1 ? (st = Ot = e, ct = 20) : a === LENS$1 ? (st = lbase, Ot = lext, ct = 257) : (st = dbase, Ot = dext, ct = 0), Y = 0, N = 0, $ = D, it = k, j = P, V = 0, nt = -1, z = 1 << P, lt = z - 1, a === LENS$1 && z > ENOUGH_LENS$1 || a === DISTS$1 && z > ENOUGH_DISTS$1)
|
|
6399
6406
|
return 1;
|
|
6400
6407
|
for (; ; ) {
|
|
6401
|
-
ie = $ - V, e[N] + 1 < ct ? (Dt = 0, Ct = e[N]) : e[N] >= ct ? (Dt = Ot[e[N] - ct], Ct =
|
|
6408
|
+
ie = $ - V, e[N] + 1 < ct ? (Dt = 0, Ct = e[N]) : e[N] >= ct ? (Dt = Ot[e[N] - ct], Ct = st[e[N] - ct]) : (Dt = 96, Ct = 0), et = 1 << $ - V, tt = 1 << j, D = tt;
|
|
6402
6409
|
do
|
|
6403
6410
|
tt -= et, _[it + (Y >> V) + tt] = ie << 24 | Dt << 16 | Ct | 0;
|
|
6404
6411
|
while (tt !== 0);
|
|
@@ -6488,7 +6495,7 @@ const fixedtables = (a) => {
|
|
|
6488
6495
|
const k = a.state;
|
|
6489
6496
|
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(u - k.wsize, u), 0), k.wnext = 0, k.whave = k.wsize) : (_ = k.wsize - k.wnext, _ > E && (_ = E), k.window.set(I.subarray(u - E, u - E + _), k.wnext), E -= _, E ? (k.window.set(I.subarray(u - E, u), 0), k.wnext = E, k.whave = k.wsize) : (k.wnext += _, k.wnext === k.wsize && (k.wnext = 0), k.whave < k.wsize && (k.whave += _))), 0;
|
|
6490
6497
|
}, inflate$2 = (a, I) => {
|
|
6491
|
-
let u, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, lt, it,
|
|
6498
|
+
let u, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, lt, it, st;
|
|
6492
6499
|
const ct = new Uint8Array(4);
|
|
6493
6500
|
let ot, rt;
|
|
6494
6501
|
const Ot = (
|
|
@@ -6497,7 +6504,7 @@ const fixedtables = (a) => {
|
|
|
6497
6504
|
);
|
|
6498
6505
|
if (inflateStateCheck(a) || !a.output || !a.input && a.avail_in !== 0)
|
|
6499
6506
|
return Z_STREAM_ERROR$1;
|
|
6500
|
-
u = a.state, u.mode === TYPE && (u.mode = TYPEDO), e = a.next_out, _ = a.output, O = a.avail_out, k = a.next_in, E = a.input, n = a.avail_in, $ = u.hold, N = u.bits, D = n, q = O,
|
|
6507
|
+
u = a.state, u.mode === TYPE && (u.mode = TYPEDO), e = a.next_out, _ = a.output, O = a.avail_out, k = a.next_in, E = a.input, n = a.avail_in, $ = u.hold, N = u.bits, D = n, q = O, st = Z_OK$1;
|
|
6501
6508
|
t:
|
|
6502
6509
|
for (; ; )
|
|
6503
6510
|
switch (u.mode) {
|
|
@@ -6721,7 +6728,7 @@ const fixedtables = (a) => {
|
|
|
6721
6728
|
}
|
|
6722
6729
|
for (; u.have < 19; )
|
|
6723
6730
|
u.lens[Ot[u.have++]] = 0;
|
|
6724
|
-
if (u.lencode = u.lendyn, u.lenbits = 7, ot = { bits: u.lenbits },
|
|
6731
|
+
if (u.lencode = u.lendyn, u.lenbits = 7, ot = { bits: u.lenbits }, st = inftrees(CODES, u.lens, 0, 19, u.lencode, 0, u.work, ot), u.lenbits = ot.bits, st) {
|
|
6725
6732
|
a.msg = "invalid code lengths set", u.mode = BAD;
|
|
6726
6733
|
break;
|
|
6727
6734
|
}
|
|
@@ -6777,11 +6784,11 @@ const fixedtables = (a) => {
|
|
|
6777
6784
|
a.msg = "invalid code -- missing end-of-block", u.mode = BAD;
|
|
6778
6785
|
break;
|
|
6779
6786
|
}
|
|
6780
|
-
if (u.lenbits = 9, ot = { bits: u.lenbits },
|
|
6787
|
+
if (u.lenbits = 9, ot = { bits: u.lenbits }, st = inftrees(LENS, u.lens, 0, u.nlen, u.lencode, 0, u.work, ot), u.lenbits = ot.bits, st) {
|
|
6781
6788
|
a.msg = "invalid literal/lengths set", u.mode = BAD;
|
|
6782
6789
|
break;
|
|
6783
6790
|
}
|
|
6784
|
-
if (u.distbits = 6, u.distcode = u.distdyn, ot = { bits: u.distbits },
|
|
6791
|
+
if (u.distbits = 6, u.distcode = u.distdyn, ot = { bits: u.distbits }, st = inftrees(DISTS, u.lens, u.nlen, u.ndist, u.distcode, 0, u.work, ot), u.distbits = ot.bits, st) {
|
|
6785
6792
|
a.msg = "invalid distances set", u.mode = BAD;
|
|
6786
6793
|
break;
|
|
6787
6794
|
}
|
|
@@ -6923,10 +6930,10 @@ const fixedtables = (a) => {
|
|
|
6923
6930
|
u.mode = DONE;
|
|
6924
6931
|
/* falls through */
|
|
6925
6932
|
case DONE:
|
|
6926
|
-
|
|
6933
|
+
st = Z_STREAM_END$1;
|
|
6927
6934
|
break t;
|
|
6928
6935
|
case BAD:
|
|
6929
|
-
|
|
6936
|
+
st = Z_DATA_ERROR$1;
|
|
6930
6937
|
break t;
|
|
6931
6938
|
case MEM:
|
|
6932
6939
|
return Z_MEM_ERROR$1;
|
|
@@ -6936,7 +6943,7 @@ const fixedtables = (a) => {
|
|
|
6936
6943
|
return Z_STREAM_ERROR$1;
|
|
6937
6944
|
}
|
|
6938
6945
|
return a.next_out = e, a.avail_out = O, a.next_in = k, a.avail_in = n, u.hold = $, u.bits = N, (u.wsize || q !== a.avail_out && u.mode < BAD && (u.mode < CHECK || I !== Z_FINISH$1)) && updatewindow(a, a.output, a.next_out, q - a.avail_out), D -= a.avail_in, q -= a.avail_out, a.total_in += D, a.total_out += q, u.total += q, u.wrap & 4 && q && (a.adler = u.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/
|
|
6939
|
-
u.flags ? crc32_1(u.check, _, q, a.next_out - q) : adler32_1(u.check, _, q, a.next_out - q)), a.data_type = u.bits + (u.last ? 64 : 0) + (u.mode === TYPE ? 128 : 0) + (u.mode === LEN_ || u.mode === COPY_ ? 256 : 0), (D === 0 && q === 0 || I === Z_FINISH$1) &&
|
|
6946
|
+
u.flags ? crc32_1(u.check, _, q, a.next_out - q) : adler32_1(u.check, _, q, a.next_out - q)), a.data_type = u.bits + (u.last ? 64 : 0) + (u.mode === TYPE ? 128 : 0) + (u.mode === LEN_ || u.mode === COPY_ ? 256 : 0), (D === 0 && q === 0 || I === Z_FINISH$1) && st === Z_OK$1 && (st = Z_BUF_ERROR), st;
|
|
6940
6947
|
}, inflateEnd = (a) => {
|
|
6941
6948
|
if (inflateStateCheck(a))
|
|
6942
6949
|
return Z_STREAM_ERROR$1;
|
|
@@ -7170,12 +7177,12 @@ const noLogEvents = ["heartbeat", "onNetQuality", "networkQualityChange"], compr
|
|
|
7170
7177
|
}
|
|
7171
7178
|
return a;
|
|
7172
7179
|
};
|
|
7173
|
-
var vt, ut, Rt,
|
|
7180
|
+
var vt, ut, Rt, _t, yt, Ut, Mt, Pt, Lt, Et, Bt, jt, Zt;
|
|
7174
7181
|
class CallsWebSocket {
|
|
7175
7182
|
// 状态
|
|
7176
7183
|
constructor(I) {
|
|
7177
|
-
|
|
7178
|
-
|
|
7184
|
+
at(this, vt);
|
|
7185
|
+
at(this, ut, {
|
|
7179
7186
|
url: "wss://demo.putplay.cc/websocket",
|
|
7180
7187
|
// 地址
|
|
7181
7188
|
debug: !1,
|
|
@@ -7184,10 +7191,10 @@ class CallsWebSocket {
|
|
|
7184
7191
|
// 最大重连次数
|
|
7185
7192
|
timeout: 30 * 1e3
|
|
7186
7193
|
});
|
|
7187
|
-
|
|
7194
|
+
at(this, Rt, "");
|
|
7188
7195
|
// 缓存登录凭证
|
|
7189
|
-
|
|
7190
|
-
|
|
7196
|
+
at(this, _t, {});
|
|
7197
|
+
at(this, yt, {});
|
|
7191
7198
|
Z(this, "state", "closed");
|
|
7192
7199
|
// 外部 发送消息之前
|
|
7193
7200
|
Z(this, "sendMessageBefore", async () => {
|
|
@@ -7199,26 +7206,26 @@ class CallsWebSocket {
|
|
|
7199
7206
|
Z(this, "onReconnectStop", (I) => {
|
|
7200
7207
|
});
|
|
7201
7208
|
// 是否需要重连
|
|
7202
|
-
|
|
7209
|
+
at(this, Ut, (I) => {
|
|
7203
7210
|
let u = !0;
|
|
7204
7211
|
const { code: E = 1e3, reason: _ = "" } = I;
|
|
7205
7212
|
return E === 1e3 && (_ === "quit success!" || _ === "replace old connection!") && (u = !1), u;
|
|
7206
7213
|
});
|
|
7207
7214
|
// 重连成功
|
|
7208
|
-
|
|
7215
|
+
at(this, Mt, async (I) => {
|
|
7209
7216
|
Q(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重连成功", I), this.state = "connected", this.onReconnectSuccess(I);
|
|
7210
7217
|
});
|
|
7211
7218
|
// 重连停止
|
|
7212
|
-
|
|
7219
|
+
at(this, Pt, async (I) => {
|
|
7213
7220
|
Q(this, ut).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);
|
|
7214
7221
|
});
|
|
7215
7222
|
// 自定义心跳规则
|
|
7216
|
-
|
|
7223
|
+
at(this, Lt, () => {
|
|
7217
7224
|
const I = { event: "heartbeat", sn: +`${F(1e5, 999999)}` };
|
|
7218
7225
|
return com.quick.voice.proto.CommonReq.encode(I).finish();
|
|
7219
7226
|
});
|
|
7220
7227
|
// 更新日志
|
|
7221
|
-
|
|
7228
|
+
at(this, Et, (I, u = {}) => {
|
|
7222
7229
|
try {
|
|
7223
7230
|
const { time: E, event: _, data: k = {}, data_original: e = {}, data_remote: n, ...O } = u, $ = U(E, "YYYY-MM-DD hh:mm:ss", { offset: 480 });
|
|
7224
7231
|
let N = {};
|
|
@@ -7257,20 +7264,20 @@ class CallsWebSocket {
|
|
|
7257
7264
|
}
|
|
7258
7265
|
});
|
|
7259
7266
|
// 创建事件
|
|
7260
|
-
|
|
7267
|
+
at(this, Bt, (I, { resolve: u, reject: E }) => {
|
|
7261
7268
|
const { sn: _ } = I, k = () => {
|
|
7262
|
-
const n = Q(this,
|
|
7263
|
-
clearTimeout(n.destructionTimer), delete Q(this,
|
|
7269
|
+
const n = Q(this, _t)[_];
|
|
7270
|
+
clearTimeout(n.destructionTimer), delete Q(this, _t)[_];
|
|
7264
7271
|
}, e = setTimeout(() => {
|
|
7265
|
-
const n = Q(this,
|
|
7272
|
+
const n = Q(this, _t)[_];
|
|
7266
7273
|
console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo:event is timeout", n.message), k(), E("event is timeout");
|
|
7267
7274
|
}, Q(this, ut).timeout);
|
|
7268
|
-
Q(this,
|
|
7275
|
+
Q(this, _t)[_] = { message: I, resolve: u, reject: E, destruction: k, destructionTimer: e };
|
|
7269
7276
|
});
|
|
7270
7277
|
// 获取事件
|
|
7271
|
-
|
|
7278
|
+
at(this, jt, (I) => Q(this, _t)[I]);
|
|
7272
7279
|
// 接收消息
|
|
7273
|
-
|
|
7280
|
+
at(this, Zt, async (I) => {
|
|
7274
7281
|
const u = new Uint8Array(I), E = com.quick.voice.proto.CommonRsp.decode(u), { sn: _, event: k } = E, e = onMessageFormat(E);
|
|
7275
7282
|
if (Q(this, ut).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, Et).call(this, "res", e)), notifyName_keys.includes(k))
|
|
7276
7283
|
return this.emitNotify(k, L(e, ["code", "data", "desc"]));
|
|
@@ -7284,12 +7291,12 @@ class CallsWebSocket {
|
|
|
7284
7291
|
});
|
|
7285
7292
|
// 清除事件
|
|
7286
7293
|
Z(this, "clearEvents", (I = []) => {
|
|
7287
|
-
const u = Object.keys(Q(this,
|
|
7294
|
+
const u = Object.keys(Q(this, _t));
|
|
7288
7295
|
I.length === 0 && (I = u);
|
|
7289
7296
|
for (const E of u) {
|
|
7290
7297
|
if (!I.includes(E)) continue;
|
|
7291
|
-
const _ = Q(this,
|
|
7292
|
-
clearTimeout(_.destructionTimer), delete Q(this,
|
|
7298
|
+
const _ = Q(this, _t)[E];
|
|
7299
|
+
clearTimeout(_.destructionTimer), delete Q(this, _t)[E];
|
|
7293
7300
|
}
|
|
7294
7301
|
});
|
|
7295
7302
|
/**
|
|
@@ -7306,10 +7313,10 @@ class CallsWebSocket {
|
|
|
7306
7313
|
binaryType: "arraybuffer",
|
|
7307
7314
|
onMessage: Q(this, Zt),
|
|
7308
7315
|
checkReconnect: Q(this, Ut),
|
|
7309
|
-
getHeartbeatMsg: Q(this,
|
|
7316
|
+
getHeartbeatMsg: Q(this, Lt),
|
|
7310
7317
|
onReconnectSuccess: Q(this, Mt),
|
|
7311
7318
|
onReconnectStop: Q(this, Pt)
|
|
7312
|
-
})), this.state = "connecting", await Q(this, vt).connect(), this.state = "connected", Q(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", Q(this,
|
|
7319
|
+
})), this.state = "connecting", await Q(this, vt).connect(), this.state = "connected", Q(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", Q(this, yt)), u(Q(this, vt));
|
|
7313
7320
|
}));
|
|
7314
7321
|
/**
|
|
7315
7322
|
* 关闭
|
|
@@ -7317,12 +7324,12 @@ class CallsWebSocket {
|
|
|
7317
7324
|
Z(this, "close", async () => {
|
|
7318
7325
|
var u;
|
|
7319
7326
|
Q(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: cws is close.");
|
|
7320
|
-
const I = Object.keys(Q(this,
|
|
7327
|
+
const I = Object.keys(Q(this, _t));
|
|
7321
7328
|
for (const E of I) {
|
|
7322
|
-
const { destructionTimer: _ } = Q(this,
|
|
7329
|
+
const { destructionTimer: _ } = Q(this, _t)[E];
|
|
7323
7330
|
clearTimeout(_);
|
|
7324
7331
|
}
|
|
7325
|
-
wt(this,
|
|
7332
|
+
wt(this, _t, {}), await ((u = Q(this, vt)) == null ? void 0 : u.close()), wt(this, vt, void 0), this.state = "closed";
|
|
7326
7333
|
});
|
|
7327
7334
|
/**
|
|
7328
7335
|
* 发送消息
|
|
@@ -7340,7 +7347,7 @@ class CallsWebSocket {
|
|
|
7340
7347
|
compress: !1,
|
|
7341
7348
|
...e
|
|
7342
7349
|
});
|
|
7343
|
-
Q(this, ut).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, Et).call(this, "req", O)), u && Q(this,
|
|
7350
|
+
Q(this, ut).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, Et).call(this, "req", O)), u && Q(this, Bt).call(this, O, { resolve: E, reject: _ });
|
|
7344
7351
|
const $ = com.quick.voice.proto.CommonReq.encode(O).finish();
|
|
7345
7352
|
(N = Q(this, vt)) == null || N.sendMessage($);
|
|
7346
7353
|
}));
|
|
@@ -7350,7 +7357,7 @@ class CallsWebSocket {
|
|
|
7350
7357
|
* @param result 事件响应值
|
|
7351
7358
|
*/
|
|
7352
7359
|
Z(this, "emitNotify", async (I, u) => {
|
|
7353
|
-
const E = Q(this,
|
|
7360
|
+
const E = Q(this, yt)[I] || [];
|
|
7354
7361
|
for (const _ of E) {
|
|
7355
7362
|
const { callback: k = async () => {
|
|
7356
7363
|
} } = _;
|
|
@@ -7365,8 +7372,8 @@ class CallsWebSocket {
|
|
|
7365
7372
|
*/
|
|
7366
7373
|
Z(this, "addNotify", (I, u = !1) => {
|
|
7367
7374
|
const { event: E, sn: _ = ht(32) } = I;
|
|
7368
|
-
Q(this,
|
|
7369
|
-
const k = Q(this,
|
|
7375
|
+
Q(this, yt)[E] || (Q(this, yt)[E] = []);
|
|
7376
|
+
const k = Q(this, yt)[E], e = k.findIndex((n) => n.sn === _);
|
|
7370
7377
|
return e !== -1 && k.splice(e, 1), u ? k.unshift(I) : k.push(I), _;
|
|
7371
7378
|
});
|
|
7372
7379
|
/**
|
|
@@ -7374,18 +7381,18 @@ class CallsWebSocket {
|
|
|
7374
7381
|
*/
|
|
7375
7382
|
Z(this, "removeNotify", (I = []) => {
|
|
7376
7383
|
if (I.length === 0)
|
|
7377
|
-
wt(this,
|
|
7384
|
+
wt(this, yt, {});
|
|
7378
7385
|
else {
|
|
7379
|
-
const u = Object.keys(Q(this,
|
|
7386
|
+
const u = Object.keys(Q(this, yt));
|
|
7380
7387
|
for (const E of u)
|
|
7381
|
-
Q(this,
|
|
7388
|
+
Q(this, yt)[E] = Q(this, yt)[E].filter((_) => !I.includes(_.sn || ""));
|
|
7382
7389
|
}
|
|
7383
|
-
Q(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", Q(this,
|
|
7390
|
+
Q(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", Q(this, yt));
|
|
7384
7391
|
});
|
|
7385
7392
|
wt(this, ut, { ...Q(this, ut), ...I });
|
|
7386
7393
|
}
|
|
7387
7394
|
}
|
|
7388
|
-
vt = new WeakMap(), ut = new WeakMap(), Rt = new WeakMap(),
|
|
7395
|
+
vt = new WeakMap(), ut = new WeakMap(), Rt = new WeakMap(), _t = new WeakMap(), yt = new WeakMap(), Ut = new WeakMap(), Mt = new WeakMap(), Pt = new WeakMap(), Lt = new WeakMap(), Et = new WeakMap(), Bt = new WeakMap(), jt = new WeakMap(), Zt = new WeakMap();
|
|
7389
7396
|
var y = Object.defineProperty, x = (a) => {
|
|
7390
7397
|
throw TypeError(a);
|
|
7391
7398
|
}, g = (a, I, u) => I in a ? y(a, I, { enumerable: !0, configurable: !0, writable: !0, value: u }) : a[I] = u, h = (a, I, u) => g(a, typeof I != "symbol" ? I + "" : I, u), b = (a, I, u) => I.has(a) || x("Cannot " + u), o = (a, I, u) => (b(a, I, "read from private field"), u ? u.call(a) : I.get(a)), f = (a, I, u) => I.has(a) ? x("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(a) : I.set(a, u), p = (a, I, u, E) => (b(a, I, "write to private field"), I.set(a, u), u), d, c, l;
|
|
@@ -7453,6 +7460,8 @@ class RoomBase {
|
|
|
7453
7460
|
// 预连接ID
|
|
7454
7461
|
callType: 0,
|
|
7455
7462
|
debug: !1,
|
|
7463
|
+
logUrl: "https://log1.putplay.cc",
|
|
7464
|
+
// 日志上报地址
|
|
7456
7465
|
newPublishAutoSubscribe: !0
|
|
7457
7466
|
});
|
|
7458
7467
|
Z(this, "prohibitNotify", !1);
|
|
@@ -7487,14 +7496,17 @@ class RoomBase {
|
|
|
7487
7496
|
* 提交日志
|
|
7488
7497
|
*/
|
|
7489
7498
|
Z(this, "reportLogs", (I, u = "未知错误") => {
|
|
7490
|
-
const { appid: E, userId: _, earlyId: k } = this.options;
|
|
7491
|
-
|
|
7499
|
+
const { appid: E, userId: _, earlyId: k = "", logUrl: e } = this.options, n = "web";
|
|
7500
|
+
{
|
|
7501
|
+
const O = { origin: n, type: I, app_id: E, user_id: _, ins_id: k, comment: u }, $ = new URLSearchParams(O).toString(), N = `${e}/upload/log?${$}`;
|
|
7502
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: reportLogs", O), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: reportLogs", N);
|
|
7503
|
+
}
|
|
7492
7504
|
{
|
|
7493
7505
|
const O = localStorage.getItem("#quickvo.logs") || JSON.stringify([]), N = new TextEncoder().encode(O);
|
|
7494
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->
|
|
7506
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: reportLogs", N);
|
|
7495
7507
|
}
|
|
7496
7508
|
});
|
|
7497
|
-
|
|
7509
|
+
at(this, Ft, () => {
|
|
7498
7510
|
this.taskQueue.setCondition("createWs", !0), this.taskQueue.setCondition("createSession", !1), this.taskQueue.setCondition("ice", !1);
|
|
7499
7511
|
});
|
|
7500
7512
|
/**
|
|
@@ -7596,23 +7608,23 @@ class RoomMedias extends RoomBase {
|
|
|
7596
7608
|
// 媒体流上下文
|
|
7597
7609
|
constructor(u) {
|
|
7598
7610
|
super(u);
|
|
7599
|
-
|
|
7611
|
+
at(this, $t, []);
|
|
7600
7612
|
// 可用媒体设备列表
|
|
7601
|
-
|
|
7613
|
+
at(this, kt, /* @__PURE__ */ new Map());
|
|
7602
7614
|
// 媒体流设备管理
|
|
7603
|
-
|
|
7615
|
+
at(this, dt, /* @__PURE__ */ new Map());
|
|
7604
7616
|
// 媒体轨道参数管理
|
|
7605
|
-
|
|
7617
|
+
at(this, bt, /* @__PURE__ */ new Map());
|
|
7606
7618
|
/**
|
|
7607
7619
|
* 初始化媒体参数
|
|
7608
7620
|
*/
|
|
7609
|
-
|
|
7621
|
+
at(this, Ht, () => {
|
|
7610
7622
|
Q(this, dt).set("microphoneCamera_audio", {}), Q(this, dt).set("microphoneCamera_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), Q(this, dt).set("screenSharing_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), Q(this, dt).set("screenSharing_audio", {});
|
|
7611
7623
|
});
|
|
7612
7624
|
/**
|
|
7613
7625
|
* 初始化媒体设备类型
|
|
7614
7626
|
*/
|
|
7615
|
-
|
|
7627
|
+
at(this, zt, () => {
|
|
7616
7628
|
Q(this, kt).set("audioinput", "default"), Q(this, kt).set("videoinput", "default"), Q(this, kt).set("audiooutput", "default");
|
|
7617
7629
|
});
|
|
7618
7630
|
/**
|
|
@@ -7814,7 +7826,7 @@ class RoomMedias extends RoomBase {
|
|
|
7814
7826
|
/**
|
|
7815
7827
|
* 获取媒体设备列表
|
|
7816
7828
|
*/
|
|
7817
|
-
|
|
7829
|
+
at(this, Tt, 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((u) => {
|
|
7818
7830
|
wt(this, $t, u);
|
|
7819
7831
|
}).catch(function(u) {
|
|
7820
7832
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", u);
|
|
@@ -7822,7 +7834,7 @@ class RoomMedias extends RoomBase {
|
|
|
7822
7834
|
/**
|
|
7823
7835
|
* 媒体设备发生变化
|
|
7824
7836
|
*/
|
|
7825
|
-
|
|
7837
|
+
at(this, Jt, () => {
|
|
7826
7838
|
navigator.mediaDevices && (navigator.mediaDevices.ondevicechange = async () => {
|
|
7827
7839
|
await Q(this, Tt).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
|
|
7828
7840
|
}), Q(this, Tt).call(this);
|
|
@@ -8188,7 +8200,7 @@ var St, Wt, xt, Kt, Gt, Qt;
|
|
|
8188
8200
|
class RoomPeer extends RoomUsers {
|
|
8189
8201
|
constructor(u) {
|
|
8190
8202
|
super(u);
|
|
8191
|
-
|
|
8203
|
+
at(this, St, /* @__PURE__ */ new Map());
|
|
8192
8204
|
// 假媒体流 (创建轨道用)
|
|
8193
8205
|
Z(this, "getPeerStatsTimer", 0);
|
|
8194
8206
|
// 获取报告的定时器
|
|
@@ -8210,7 +8222,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8210
8222
|
this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this, Kt).call(this), Q(this, Qt).call(this);
|
|
8211
8223
|
});
|
|
8212
8224
|
// 初始化假数据流
|
|
8213
|
-
|
|
8225
|
+
at(this, Wt, () => {
|
|
8214
8226
|
for (const u of mediaType_keys)
|
|
8215
8227
|
switch (u) {
|
|
8216
8228
|
case "microphoneCamera_audio":
|
|
@@ -8228,7 +8240,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8228
8240
|
}
|
|
8229
8241
|
});
|
|
8230
8242
|
// 获取假数据流
|
|
8231
|
-
|
|
8243
|
+
at(this, xt, (u) => Q(this, St).get(u));
|
|
8232
8244
|
/**
|
|
8233
8245
|
* 替换发射器媒体流
|
|
8234
8246
|
*/
|
|
@@ -8242,14 +8254,14 @@ class RoomPeer extends RoomUsers {
|
|
|
8242
8254
|
const { sender: O } = e;
|
|
8243
8255
|
E ? n = this.getUserStream(_, k) : n = Q(this, xt).call(this, k);
|
|
8244
8256
|
const [$] = n.getTracks();
|
|
8245
|
-
O.replaceTrack($);
|
|
8257
|
+
await O.replaceTrack($);
|
|
8246
8258
|
}
|
|
8247
8259
|
}
|
|
8248
8260
|
});
|
|
8249
8261
|
/**
|
|
8250
8262
|
* 获取发射器轨道信息
|
|
8251
8263
|
*/
|
|
8252
|
-
Z(this, "getSenderTracks", (u = []) => {
|
|
8264
|
+
Z(this, "getSenderTracks", async (u = []) => {
|
|
8253
8265
|
const E = [];
|
|
8254
8266
|
for (const _ of u) {
|
|
8255
8267
|
const k = this.transceiverMap.get(_);
|
|
@@ -8354,7 +8366,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8354
8366
|
/**
|
|
8355
8367
|
* 监听webrtc ice通讯连接
|
|
8356
8368
|
*/
|
|
8357
|
-
|
|
8369
|
+
at(this, Kt, () => {
|
|
8358
8370
|
let u = 0;
|
|
8359
8371
|
const E = () => {
|
|
8360
8372
|
this.setRoomState("closed");
|
|
@@ -8393,20 +8405,21 @@ class RoomPeer extends RoomUsers {
|
|
|
8393
8405
|
const { trackName: N, msid: D } = $;
|
|
8394
8406
|
k.push(N), D && k.push(D);
|
|
8395
8407
|
}
|
|
8396
|
-
const e = ($) => k.includes($), n =
|
|
8397
|
-
|
|
8398
|
-
for (const $ of n.tracks) {
|
|
8399
|
-
const { trackName: N, msid: D, userId: q, mediaType: P } = $;
|
|
8400
|
-
!q || !P || !e(N) || (this.removeUserMediaStreamContext(q, P), D && delete $.msid);
|
|
8401
|
-
}
|
|
8402
|
-
if (_) {
|
|
8403
|
-
const $ = n.tracks.filter(({ trackName: N }) => !e(N));
|
|
8404
|
-
await this.updateUsertracks(u, $, !1);
|
|
8405
|
-
}
|
|
8406
|
-
const O = this.peerIns.getTransceivers();
|
|
8407
|
-
for (const $ of O) {
|
|
8408
|
+
const e = ($) => k.includes($), n = this.peerIns.getTransceivers();
|
|
8409
|
+
for (const $ of n) {
|
|
8408
8410
|
const { sender: N, receiver: D } = $;
|
|
8409
|
-
N.track && e(N.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: sender: ${N.track.id} is stop.`, $),
|
|
8411
|
+
N.track && e(N.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: sender: ${N.track.id} is stop.`, $), $.stop()), D.track && e(D.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: receiver: ${D.track.id} is stop.`, $), $.stop());
|
|
8412
|
+
}
|
|
8413
|
+
const O = await this.getUser(u);
|
|
8414
|
+
if (O) {
|
|
8415
|
+
for (const $ of O.tracks) {
|
|
8416
|
+
const { trackName: N, msid: D, userId: q, mediaType: P } = $;
|
|
8417
|
+
!q || !P || !e(N) || (this.removeUserMediaStreamContext(q, P), D && delete $.msid);
|
|
8418
|
+
}
|
|
8419
|
+
if (_) {
|
|
8420
|
+
const $ = O.tracks.filter(({ trackName: N }) => !e(N));
|
|
8421
|
+
await this.updateUsertracks(u, $, !1);
|
|
8422
|
+
}
|
|
8410
8423
|
}
|
|
8411
8424
|
});
|
|
8412
8425
|
Z(this, "createOffer", async () => {
|
|
@@ -8503,7 +8516,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8503
8516
|
/**
|
|
8504
8517
|
* 计算网络质量
|
|
8505
8518
|
*/
|
|
8506
|
-
|
|
8519
|
+
at(this, Gt, async () => {
|
|
8507
8520
|
try {
|
|
8508
8521
|
const u = await this.peerIns.getStats(), E = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"], k = [...u.values()].filter((nt) => E.includes(nt.type));
|
|
8509
8522
|
let e = 0, n = 0, O = 0, $ = 0, N = 0, D = 0, q = [], P = [];
|
|
@@ -8513,23 +8526,23 @@ class RoomPeer extends RoomUsers {
|
|
|
8513
8526
|
}
|
|
8514
8527
|
this.reports = k;
|
|
8515
8528
|
for (const nt of this.reports) {
|
|
8516
|
-
const { bytesReceived: lt, bytesSent: it, packetsSent:
|
|
8517
|
-
lt && (e = lt), it && (n = it),
|
|
8529
|
+
const { bytesReceived: lt, bytesSent: it, packetsSent: st, packetsLost: ct, jitter: ot, roundTripTime: rt } = nt;
|
|
8530
|
+
lt && (e = lt), it && (n = it), st && (N += st), ct && (D += ct), rt && q.push((rt * 100).toFixed(2)), ot && P.push(ot.toFixed(2));
|
|
8518
8531
|
}
|
|
8519
8532
|
P.sort().reverse(), q.sort().reverse();
|
|
8520
8533
|
const j = N - O, V = D - $, J = j === 0 ? "0.00" : (V / j).toFixed(2), [z = "0"] = q, [Y = "0"] = P, et = { inboundBytes: e, outboundBytes: n, lostRate: J, roundTripTime: z, jitter: Y };
|
|
8521
8534
|
this.peerNetwork = et;
|
|
8522
8535
|
const tt = (nt, lt, it) => {
|
|
8523
|
-
const
|
|
8536
|
+
const st = Number(nt), ct = Number(lt), ot = Number(it);
|
|
8524
8537
|
let rt = "0";
|
|
8525
|
-
return
|
|
8538
|
+
return st < 0.03 && ct < 100 && ot < 0.05 ? rt = "5" : st < 0.06 && ct < 160 && ot < 0.1 ? rt = "4" : st < 0.1 && ct < 250 && ot < 0.15 ? rt = "3" : st < 0.15 && ct < 400 && ot < 0.2 ? rt = "2" : rt = "1", Number(rt);
|
|
8526
8539
|
};
|
|
8527
8540
|
{
|
|
8528
|
-
const nt = tt(J, z, Y), lt = await this.getCaller(), { network: it } = lt,
|
|
8529
|
-
if (await this.updateUserNetwork(this.options.userId,
|
|
8541
|
+
const nt = tt(J, z, Y), lt = await this.getCaller(), { network: it } = lt, st = { egress: nt, ingress: nt }, ct = JSON.stringify(it) !== JSON.stringify(st);
|
|
8542
|
+
if (await this.updateUserNetwork(this.options.userId, st), ct) {
|
|
8530
8543
|
this.emitNotifyUpdateUsers();
|
|
8531
8544
|
const { userId: ot, roomId: rt } = this.options;
|
|
8532
|
-
this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...
|
|
8545
|
+
this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...st, userId: ot, roomId: rt } }, !1);
|
|
8533
8546
|
}
|
|
8534
8547
|
}
|
|
8535
8548
|
} catch (u) {
|
|
@@ -8539,7 +8552,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8539
8552
|
/**
|
|
8540
8553
|
* 获取连接的所有轨道分析数据
|
|
8541
8554
|
*/
|
|
8542
|
-
|
|
8555
|
+
at(this, Qt, () => {
|
|
8543
8556
|
const u = async () => {
|
|
8544
8557
|
this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this, Gt).call(this);
|
|
8545
8558
|
};
|
|
@@ -8563,7 +8576,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8563
8576
|
* 广播给房间其他人
|
|
8564
8577
|
* 只有当自己建立了发射轨道 并且 加入房间后才进行广播
|
|
8565
8578
|
*/
|
|
8566
|
-
|
|
8579
|
+
at(this, Vt, async (u) => {
|
|
8567
8580
|
const { roomId: E } = this.options;
|
|
8568
8581
|
if (!E) return;
|
|
8569
8582
|
const { id: _, tracks: k = [] } = await this.getCaller();
|
|
@@ -8574,7 +8587,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8574
8587
|
/**
|
|
8575
8588
|
* 更新自己通话状态
|
|
8576
8589
|
*/
|
|
8577
|
-
|
|
8590
|
+
at(this, It, async (u) => new Promise(async (E, _) => {
|
|
8578
8591
|
const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: u } };
|
|
8579
8592
|
await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
|
|
8580
8593
|
const { code: $ = 0 } = O;
|
|
@@ -8585,7 +8598,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8585
8598
|
/**
|
|
8586
8599
|
* 创建连接
|
|
8587
8600
|
*/
|
|
8588
|
-
|
|
8601
|
+
at(this, Nt, () => new Promise(async (u, E) => {
|
|
8589
8602
|
try {
|
|
8590
8603
|
if (["connecting", "connected"].includes(this.cwsIns.state)) return u(!0);
|
|
8591
8604
|
this.taskQueue.setCondition("createWs", !1), this.cwsIns.clearEvents(), this.initPeer();
|
|
@@ -8612,7 +8625,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8612
8625
|
/**
|
|
8613
8626
|
* 创建cf会话
|
|
8614
8627
|
*/
|
|
8615
|
-
|
|
8628
|
+
at(this, At, () => {
|
|
8616
8629
|
if (!["connecting", "connected"].includes(this.roomState))
|
|
8617
8630
|
return this.setRoomState("connecting"), new Promise((u) => {
|
|
8618
8631
|
const E = async () => {
|
|
@@ -8624,7 +8637,16 @@ class RoomCalls extends RoomPeer {
|
|
|
8624
8637
|
const { code: k = 0, desc: e, data: n } = _;
|
|
8625
8638
|
if (k !== 200) throw new Error(e);
|
|
8626
8639
|
const { remoteSdp: O } = n;
|
|
8627
|
-
this.taskQueue.setCondition("ice", !1), await this.setRemoteDescription({ type: "answer", sdp: O }), this.taskQueue.setCondition("createSession", !0)
|
|
8640
|
+
this.taskQueue.setCondition("ice", !1), await this.setRemoteDescription({ type: "answer", sdp: O }), this.taskQueue.setCondition("createSession", !0);
|
|
8641
|
+
{
|
|
8642
|
+
let $ = 0;
|
|
8643
|
+
$ = setTimeout(() => {
|
|
8644
|
+
this.reportLogs("webrtc_c_timeout", "ice连接无响应(30s)");
|
|
8645
|
+
}, 3e4);
|
|
8646
|
+
const N = () => clearTimeout($);
|
|
8647
|
+
this.taskQueue.addTask(N, ["ice"], { describe: "createSession" });
|
|
8648
|
+
}
|
|
8649
|
+
u(!0);
|
|
8628
8650
|
});
|
|
8629
8651
|
} catch (_) {
|
|
8630
8652
|
this.taskQueue.setCondition("createSession", !0), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo create session is error.", _);
|
|
@@ -8644,11 +8666,11 @@ class RoomCalls extends RoomPeer {
|
|
|
8644
8666
|
/**
|
|
8645
8667
|
* 创建媒体轨道
|
|
8646
8668
|
*/
|
|
8647
|
-
|
|
8669
|
+
at(this, qt, async (u) => new Promise((E) => {
|
|
8648
8670
|
const _ = async () => {
|
|
8649
8671
|
try {
|
|
8650
8672
|
this.taskQueue.setCondition("createTrack", !1);
|
|
8651
|
-
const k = await this.addSenders(u), e = this.getSenderTracks(k);
|
|
8673
|
+
const k = await this.addSenders(u), e = await this.getSenderTracks(k);
|
|
8652
8674
|
if (e.length === 0)
|
|
8653
8675
|
return this.taskQueue.setCondition("createTrack", !0), E(!0);
|
|
8654
8676
|
await this.cwsIns.sendMessage({
|
|
@@ -8684,6 +8706,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8684
8706
|
this.removeUserMediaStreamContext(e, O);
|
|
8685
8707
|
continue;
|
|
8686
8708
|
}
|
|
8709
|
+
if (E === !1) return;
|
|
8687
8710
|
if (u.includes("microphoneCamera_audio") && u.includes("microphoneCamera_video") && await this.initLocalStream("microphoneCamera"), u.includes("microphoneCamera_audio") && await this.initLocalStream("microphoneCamera_audio"), u.includes("microphoneCamera_video") && await this.initLocalStream("microphoneCamera_video"), u.includes("screenSharing_audio") && u.includes("screenSharing_video") && await this.initLocalStream("screenSharing"), u.includes("screenSharing_audio") && !u.includes("screenSharing_video") && await this.initLocalStream("screenSharing_audio"), u.includes("screenSharing_video") && !u.includes("screenSharing_audio") && await this.initLocalStream("screenSharing_video"), u.includes("screenSharing_audio")) {
|
|
8688
8711
|
const $ = this.getUserStream(e, "screenSharing_audio").getTracks();
|
|
8689
8712
|
for (const N of $)
|
|
@@ -8762,7 +8785,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8762
8785
|
this.isInRoom = !0, Q(this, At).call(this), await this.updateUsers(J), e();
|
|
8763
8786
|
});
|
|
8764
8787
|
} catch (O) {
|
|
8765
|
-
this.taskQueue.setCondition("joinRoom", !0), _(`加入房间失败: ${O.message || O || "服务器繁忙"}`);
|
|
8788
|
+
this.taskQueue.setCondition("joinRoom", !0), this.reportLogs("join_room_error", O.message || O), _(`加入房间失败: ${O.message || O || "服务器繁忙"}`);
|
|
8766
8789
|
}
|
|
8767
8790
|
};
|
|
8768
8791
|
k = this.taskQueue.addTask(n, ["createWs", "joinRoom"], { describe: "joinRoom", strict: !0 });
|
|
@@ -8775,8 +8798,9 @@ class RoomCalls extends RoomPeer {
|
|
|
8775
8798
|
Z(this, "quitRoom", () => new Promise(async (u) => {
|
|
8776
8799
|
const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
|
|
8777
8800
|
try {
|
|
8778
|
-
this.isInRoom = !1, this.
|
|
8779
|
-
} catch {
|
|
8801
|
+
this.isInRoom = !1, this.setLocalStream(["microphoneCamera_audio", "microphoneCamera_video", "screenSharing_audio", "screenSharing_video"], !1), this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.setRoomState("ready");
|
|
8802
|
+
} catch (e) {
|
|
8803
|
+
this.reportLogs("quit_room_error", e.message || e);
|
|
8780
8804
|
}
|
|
8781
8805
|
await new Promise((e) => setTimeout(() => e(!0), 300)), this.taskQueue.setCondition("closeTrack", !0), this.cwsIns.sendMessage({ event: "quitRoom", data: k }), u(!0);
|
|
8782
8806
|
}));
|
|
@@ -8788,8 +8812,9 @@ class RoomCalls extends RoomPeer {
|
|
|
8788
8812
|
Z(this, "quitRoomEx", () => new Promise(async (u) => {
|
|
8789
8813
|
const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
|
|
8790
8814
|
try {
|
|
8791
|
-
this.isInRoom = !1, this.
|
|
8792
|
-
} catch {
|
|
8815
|
+
this.isInRoom = !1, this.setLocalStream(["microphoneCamera_audio", "microphoneCamera_video", "screenSharing_audio", "screenSharing_video"], !1), this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams();
|
|
8816
|
+
} catch (e) {
|
|
8817
|
+
this.reportLogs("quit_room_error", e.message || e);
|
|
8793
8818
|
}
|
|
8794
8819
|
await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoomEx", data: k }), u(!0);
|
|
8795
8820
|
}));
|
|
@@ -8821,8 +8846,8 @@ class RoomCalls extends RoomPeer {
|
|
|
8821
8846
|
Z(this, "publish", (u) => new Promise(async (E, _) => {
|
|
8822
8847
|
const k = async () => {
|
|
8823
8848
|
try {
|
|
8824
|
-
await this.replaceSenderStream(u, !1);
|
|
8825
8849
|
const e = await this.getCaller();
|
|
8850
|
+
await this.replaceSenderStream(u, !1);
|
|
8826
8851
|
try {
|
|
8827
8852
|
await this.setLocalStream(u, !0);
|
|
8828
8853
|
} catch {
|
|
@@ -8832,17 +8857,17 @@ class RoomCalls extends RoomPeer {
|
|
|
8832
8857
|
this.getUserStream(e.id, q).getTracks().length === 0 && n.push(q);
|
|
8833
8858
|
const O = u.filter((q) => !n.includes(q) || ["microphoneCamera_audio", "microphoneCamera_video"].includes(q));
|
|
8834
8859
|
await Q(this, qt).call(this, O);
|
|
8835
|
-
const $ = this.getSenderTracks(O), N = [...e.tracks, ...$];
|
|
8860
|
+
const $ = await this.getSenderTracks(O), N = [...e.tracks, ...$];
|
|
8836
8861
|
await this.updateUsertracks(e.id, N, !0);
|
|
8837
8862
|
const D = await this.getCallAction(N);
|
|
8838
|
-
await Q(this, It).call(this, D),
|
|
8863
|
+
await Q(this, It).call(this, D), Q(this, Vt).call(this, u), await this.replaceSenderStream(u, !0), n.length !== 0 && await this.inactiveTracks(n, !1);
|
|
8839
8864
|
{
|
|
8840
8865
|
await this.emitNotifyUpdateUsers();
|
|
8841
8866
|
const q = await this.getCaller();
|
|
8842
8867
|
E(q);
|
|
8843
8868
|
}
|
|
8844
8869
|
} catch (e) {
|
|
8845
|
-
_(`publish is error: ${e.message || e}`);
|
|
8870
|
+
this.reportLogs("publish_error", e.message || e), _(`publish is error: ${e.message || e}`);
|
|
8846
8871
|
}
|
|
8847
8872
|
};
|
|
8848
8873
|
this.taskQueue.addTask(k, ["createWs", "createSession", "ice", "joinRoom", "createTrack", "subscribe"], { describe: "replaceSenderStream" });
|
|
@@ -8865,7 +8890,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8865
8890
|
await this.emitNotifyUpdateUsers(), E($);
|
|
8866
8891
|
};
|
|
8867
8892
|
if (n.length === 0) return O();
|
|
8868
|
-
await this.replaceSenderStream(u, !
|
|
8893
|
+
await this.replaceSenderStream(u, !1), await this.closeUserTracks(e.id, n, !0), await this.removeSenders(u);
|
|
8869
8894
|
{
|
|
8870
8895
|
const $ = await this.getCallAction(e.tracks);
|
|
8871
8896
|
await Q(this, It).call(this, $);
|
|
@@ -8878,7 +8903,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8878
8903
|
await this.setRemoteDescription({ type: "answer", sdp: N });
|
|
8879
8904
|
}), O();
|
|
8880
8905
|
} catch (e) {
|
|
8881
|
-
this.taskQueue.setCondition("closeTrack", !0), _(`stop publish is error: ${e.message || e}`);
|
|
8906
|
+
this.taskQueue.setCondition("closeTrack", !0), this.reportLogs("close_track_error", e.message || e), _(`stop publish is error: ${e.message || e}`);
|
|
8882
8907
|
}
|
|
8883
8908
|
};
|
|
8884
8909
|
this.taskQueue.addTask(k, ["createWs", "createSession", "ice", "createTrack", "subscribe"], { describe: "stopPublish" });
|
|
@@ -8932,7 +8957,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8932
8957
|
};
|
|
8933
8958
|
await D();
|
|
8934
8959
|
} catch (n) {
|
|
8935
|
-
this.taskQueue.setCondition("subscribe", !0), k(`subscribe is error: ${n.message || n}`);
|
|
8960
|
+
this.taskQueue.setCondition("subscribe", !0), this.reportLogs("subscribe_error", n.message || n), k(`subscribe is error: ${n.message || n}`);
|
|
8936
8961
|
}
|
|
8937
8962
|
};
|
|
8938
8963
|
this.taskQueue.addTask(e, ["createWs", "createSession", "ice", "createTrack", "closeTrack"], { describe: "subscribe" });
|
|
@@ -8980,7 +9005,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8980
9005
|
await this.setRemoteDescription({ type: "answer", sdp: N });
|
|
8981
9006
|
}), O();
|
|
8982
9007
|
} catch (e) {
|
|
8983
|
-
this.taskQueue.setCondition("closeTrack", !0), _(`stop subscribe is error: ${e.message || e}`);
|
|
9008
|
+
this.taskQueue.setCondition("closeTrack", !0), this.reportLogs("close_track_error", e.message || e), _(`stop subscribe is error: ${e.message || e}`);
|
|
8984
9009
|
}
|
|
8985
9010
|
};
|
|
8986
9011
|
this.taskQueue.addTask(k, ["createWs", "createSession", "ice", "createTrack", "subscribe"], { describe: "closeTrack" });
|
|
@@ -9031,11 +9056,11 @@ var gt, Yt, Xt, te, ee;
|
|
|
9031
9056
|
class QuickVO extends Room {
|
|
9032
9057
|
constructor(u) {
|
|
9033
9058
|
super(u);
|
|
9034
|
-
|
|
9059
|
+
at(this, gt, /* @__PURE__ */ new Map());
|
|
9035
9060
|
/**
|
|
9036
9061
|
* 添加内部监听事件
|
|
9037
9062
|
*/
|
|
9038
|
-
|
|
9063
|
+
at(this, Yt, () => {
|
|
9039
9064
|
{
|
|
9040
9065
|
const u = async (E) => {
|
|
9041
9066
|
const { qualities: _ = [] } = E.data, [k] = _;
|
|
@@ -9116,12 +9141,12 @@ class QuickVO extends Room {
|
|
|
9116
9141
|
/**
|
|
9117
9142
|
* cwsIns 发送消息前
|
|
9118
9143
|
*/
|
|
9119
|
-
|
|
9144
|
+
at(this, Xt, () => {
|
|
9120
9145
|
});
|
|
9121
9146
|
/**
|
|
9122
9147
|
* 重连成功
|
|
9123
9148
|
*/
|
|
9124
|
-
|
|
9149
|
+
at(this, te, () => {
|
|
9125
9150
|
this.cwsIns.onReconnectSuccess = async () => {
|
|
9126
9151
|
await this.syncRoomInfo();
|
|
9127
9152
|
};
|
|
@@ -9129,7 +9154,7 @@ class QuickVO extends Room {
|
|
|
9129
9154
|
/**
|
|
9130
9155
|
* 重连停止
|
|
9131
9156
|
*/
|
|
9132
|
-
|
|
9157
|
+
at(this, ee, async () => {
|
|
9133
9158
|
});
|
|
9134
9159
|
/**
|
|
9135
9160
|
* 添加 FrameRequestCallback
|