quickvo-sdk-js 0.5.7 → 0.5.9
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/README.md +16 -2
- package/dist/QuickVO.d.ts +7 -1
- package/dist/index.js +327 -280
- package/dist/index.umd.cjs +2 -2
- package/dist/room/Room.d.ts +2 -1
- package/dist/room/RoomBase.d.ts +11 -7
- package/dist/room/RoomCalls.d.ts +15 -30
- package/dist/room/RoomMedias.d.ts +2 -2
- package/dist/room/RoomPeer.d.ts +2 -2
- package/dist/room/RoomUsers.d.ts +4 -4
- package/dist/room/mediaStreams/AudioMediaContext.d.ts +8 -1
- package/dist/types.d.ts +1 -0
- 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 = (a) => {
|
|
3
3
|
throw TypeError(a);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var Z = (a, I, u) =>
|
|
7
|
-
var Q = (a, I, u) => (
|
|
5
|
+
var ce = (a, I, u) => I in a ? re(a, I, { enumerable: !0, configurable: !0, writable: !0, value: u }) : a[I] = u;
|
|
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)), st = (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)
|
|
@@ -720,11 +720,17 @@ class AudioMediaContext {
|
|
|
720
720
|
});
|
|
721
721
|
Z(this, "kind", "audio");
|
|
722
722
|
Z(this, "stream", new MediaStream());
|
|
723
|
+
Z(this, "gain", 1);
|
|
724
|
+
// 音量
|
|
725
|
+
Z(this, "enhanceGain", 0);
|
|
726
|
+
// 音量增强
|
|
723
727
|
Z(this, "audio", new Audio());
|
|
724
728
|
// @ts-ignore 音频上下文
|
|
725
729
|
Z(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
|
|
726
730
|
// 媒体流音频源节点
|
|
727
731
|
Z(this, "mediaStreamAudioSourceNode");
|
|
732
|
+
// 媒体流音频源节点
|
|
733
|
+
Z(this, "destination");
|
|
728
734
|
// 增益节点 (自动增益)
|
|
729
735
|
Z(this, "autoGainNode");
|
|
730
736
|
// 滤波器节点 (噪声抑制)
|
|
@@ -756,23 +762,33 @@ class AudioMediaContext {
|
|
|
756
762
|
/**
|
|
757
763
|
* 获取数据流
|
|
758
764
|
*/
|
|
759
|
-
Z(this, "getStream", () => this.
|
|
765
|
+
Z(this, "getStream", () => this.destination.stream);
|
|
766
|
+
// getStream = () => this.mediaStreamAudioSourceNode.mediaStream
|
|
760
767
|
/**
|
|
761
768
|
* 静音
|
|
762
769
|
*/
|
|
763
770
|
Z(this, "setMute", (I = !0) => {
|
|
764
771
|
I ? this.analyserNode.disconnect(this.audioContext.destination) : this.analyserNode.connect(this.audioContext.destination);
|
|
765
772
|
});
|
|
773
|
+
/**
|
|
774
|
+
* 设置音量
|
|
775
|
+
*/
|
|
776
|
+
Z(this, "setGain", () => {
|
|
777
|
+
const I = (1 + this.enhanceGain) * this.gain;
|
|
778
|
+
this.gainNode.gain.setValueAtTime(I, this.audioContext.currentTime);
|
|
779
|
+
});
|
|
766
780
|
/**
|
|
767
781
|
* 设置增强音量
|
|
768
782
|
*/
|
|
769
783
|
Z(this, "setEnhanceGain", async (I) => {
|
|
784
|
+
let u = Math.max(0, I);
|
|
785
|
+
u = Math.min(u, 1), this.enhanceGain = u, this.setGain();
|
|
770
786
|
});
|
|
771
787
|
/**
|
|
772
|
-
*
|
|
788
|
+
* 设置基础音量
|
|
773
789
|
*/
|
|
774
790
|
Z(this, "setVolumeGain", (I) => {
|
|
775
|
-
this.
|
|
791
|
+
this.gain = I, this.setGain();
|
|
776
792
|
});
|
|
777
793
|
/**
|
|
778
794
|
* 获取音量
|
|
@@ -793,9 +809,9 @@ class AudioMediaContext {
|
|
|
793
809
|
const { autoGainControl: u, noiseSuppression: E, echoCancellation: _ } = this.options, { mediaStreamAudioSourceNode: k, autoGainNode: e, biquadFilterNode: n, delayNode: O, gainNode: $ } = this, N = k;
|
|
794
810
|
return u && N.connect(e), E && N.connect(n), _ && N.connect(O), N.connect($), I;
|
|
795
811
|
});
|
|
796
|
-
this.stream.addTrack(I), 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(
|
|
797
|
-
const { gainNode: u,
|
|
798
|
-
u.connect(E), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
|
|
812
|
+
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, destination: E, analyserNode: _ } = this;
|
|
814
|
+
u.connect(E), u.connect(_), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
|
|
799
815
|
}
|
|
800
816
|
}
|
|
801
817
|
class VideoMediaContext {
|
|
@@ -6134,7 +6150,7 @@ var Deflate_1$1 = Deflate$1, deflate_2 = deflate$1, deflateRaw_1$1 = deflateRaw$
|
|
|
6134
6150
|
};
|
|
6135
6151
|
const BAD$1 = 16209, TYPE$1 = 16191;
|
|
6136
6152
|
var inffast = function a(I, u) {
|
|
6137
|
-
let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, lt, it,
|
|
6153
|
+
let E, _, k, e, n, O, $, N, D, q, P, j, V, J, z, Y, et, tt, nt, lt, it, at, ct, ot;
|
|
6138
6154
|
const rt = I.state;
|
|
6139
6155
|
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;
|
|
6140
6156
|
t:
|
|
@@ -6158,13 +6174,13 @@ var inffast = function a(I, u) {
|
|
|
6158
6174
|
I.msg = "invalid distance too far back", rt.mode = BAD$1;
|
|
6159
6175
|
break t;
|
|
6160
6176
|
}
|
|
6161
|
-
if (it = 0,
|
|
6177
|
+
if (it = 0, at = q, D === 0) {
|
|
6162
6178
|
if (it += $ - tt, tt < nt) {
|
|
6163
6179
|
nt -= tt;
|
|
6164
6180
|
do
|
|
6165
6181
|
ot[k++] = q[it++];
|
|
6166
6182
|
while (--tt);
|
|
6167
|
-
it = k - lt,
|
|
6183
|
+
it = k - lt, at = ot;
|
|
6168
6184
|
}
|
|
6169
6185
|
} else if (D < tt) {
|
|
6170
6186
|
if (it += $ + D - tt, tt -= D, tt < nt) {
|
|
@@ -6177,7 +6193,7 @@ var inffast = function a(I, u) {
|
|
|
6177
6193
|
do
|
|
6178
6194
|
ot[k++] = q[it++];
|
|
6179
6195
|
while (--tt);
|
|
6180
|
-
it = k - lt,
|
|
6196
|
+
it = k - lt, at = ot;
|
|
6181
6197
|
}
|
|
6182
6198
|
}
|
|
6183
6199
|
} else if (it += D - tt, tt < nt) {
|
|
@@ -6185,11 +6201,11 @@ var inffast = function a(I, u) {
|
|
|
6185
6201
|
do
|
|
6186
6202
|
ot[k++] = q[it++];
|
|
6187
6203
|
while (--tt);
|
|
6188
|
-
it = k - lt,
|
|
6204
|
+
it = k - lt, at = ot;
|
|
6189
6205
|
}
|
|
6190
6206
|
for (; nt > 2; )
|
|
6191
|
-
ot[k++] =
|
|
6192
|
-
nt && (ot[k++] =
|
|
6207
|
+
ot[k++] = at[it++], ot[k++] = at[it++], ot[k++] = at[it++], nt -= 3;
|
|
6208
|
+
nt && (ot[k++] = at[it++], nt > 1 && (ot[k++] = at[it++]));
|
|
6193
6209
|
} else {
|
|
6194
6210
|
it = k - lt;
|
|
6195
6211
|
do
|
|
@@ -6357,9 +6373,9 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
6357
6373
|
64
|
|
6358
6374
|
]), inflate_table = (a, I, u, E, _, k, e, n) => {
|
|
6359
6375
|
const O = n.bits;
|
|
6360
|
-
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,
|
|
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, at = null, ct;
|
|
6361
6377
|
const ot = new Uint16Array(MAXBITS + 1), rt = new Uint16Array(MAXBITS + 1);
|
|
6362
|
-
let Ot = null,
|
|
6378
|
+
let Ot = null, ie, Dt, Ct;
|
|
6363
6379
|
for ($ = 0; $ <= MAXBITS; $++)
|
|
6364
6380
|
ot[$] = 0;
|
|
6365
6381
|
for (N = 0; N < E; N++)
|
|
@@ -6379,12 +6395,12 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
6379
6395
|
rt[$ + 1] = rt[$] + ot[$];
|
|
6380
6396
|
for (N = 0; N < E; N++)
|
|
6381
6397
|
I[u + N] !== 0 && (e[rt[I[u + N]]++] = N);
|
|
6382
|
-
if (a === CODES$1 ? (
|
|
6398
|
+
if (a === CODES$1 ? (at = Ot = e, ct = 20) : a === LENS$1 ? (at = lbase, Ot = lext, ct = 257) : (at = 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)
|
|
6383
6399
|
return 1;
|
|
6384
6400
|
for (; ; ) {
|
|
6385
|
-
|
|
6401
|
+
ie = $ - V, e[N] + 1 < ct ? (Dt = 0, Ct = e[N]) : e[N] >= ct ? (Dt = Ot[e[N] - ct], Ct = at[e[N] - ct]) : (Dt = 96, Ct = 0), et = 1 << $ - V, tt = 1 << j, D = tt;
|
|
6386
6402
|
do
|
|
6387
|
-
tt -= et, _[it + (Y >> V) + tt] =
|
|
6403
|
+
tt -= et, _[it + (Y >> V) + tt] = ie << 24 | Dt << 16 | Ct | 0;
|
|
6388
6404
|
while (tt !== 0);
|
|
6389
6405
|
for (et = 1 << $ - 1; Y & et; )
|
|
6390
6406
|
et >>= 1;
|
|
@@ -6472,7 +6488,7 @@ const fixedtables = (a) => {
|
|
|
6472
6488
|
const k = a.state;
|
|
6473
6489
|
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;
|
|
6474
6490
|
}, inflate$2 = (a, I) => {
|
|
6475
|
-
let u, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, lt, it,
|
|
6491
|
+
let u, E, _, k, e, n, O, $, N, D, q, P, j, V, J = 0, z, Y, et, tt, nt, lt, it, at;
|
|
6476
6492
|
const ct = new Uint8Array(4);
|
|
6477
6493
|
let ot, rt;
|
|
6478
6494
|
const Ot = (
|
|
@@ -6481,7 +6497,7 @@ const fixedtables = (a) => {
|
|
|
6481
6497
|
);
|
|
6482
6498
|
if (inflateStateCheck(a) || !a.output || !a.input && a.avail_in !== 0)
|
|
6483
6499
|
return Z_STREAM_ERROR$1;
|
|
6484
|
-
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,
|
|
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, at = Z_OK$1;
|
|
6485
6501
|
t:
|
|
6486
6502
|
for (; ; )
|
|
6487
6503
|
switch (u.mode) {
|
|
@@ -6705,7 +6721,7 @@ const fixedtables = (a) => {
|
|
|
6705
6721
|
}
|
|
6706
6722
|
for (; u.have < 19; )
|
|
6707
6723
|
u.lens[Ot[u.have++]] = 0;
|
|
6708
|
-
if (u.lencode = u.lendyn, u.lenbits = 7, ot = { bits: u.lenbits },
|
|
6724
|
+
if (u.lencode = u.lendyn, u.lenbits = 7, ot = { bits: u.lenbits }, at = inftrees(CODES, u.lens, 0, 19, u.lencode, 0, u.work, ot), u.lenbits = ot.bits, at) {
|
|
6709
6725
|
a.msg = "invalid code lengths set", u.mode = BAD;
|
|
6710
6726
|
break;
|
|
6711
6727
|
}
|
|
@@ -6761,11 +6777,11 @@ const fixedtables = (a) => {
|
|
|
6761
6777
|
a.msg = "invalid code -- missing end-of-block", u.mode = BAD;
|
|
6762
6778
|
break;
|
|
6763
6779
|
}
|
|
6764
|
-
if (u.lenbits = 9, ot = { bits: u.lenbits },
|
|
6780
|
+
if (u.lenbits = 9, ot = { bits: u.lenbits }, at = inftrees(LENS, u.lens, 0, u.nlen, u.lencode, 0, u.work, ot), u.lenbits = ot.bits, at) {
|
|
6765
6781
|
a.msg = "invalid literal/lengths set", u.mode = BAD;
|
|
6766
6782
|
break;
|
|
6767
6783
|
}
|
|
6768
|
-
if (u.distbits = 6, u.distcode = u.distdyn, ot = { bits: u.distbits },
|
|
6784
|
+
if (u.distbits = 6, u.distcode = u.distdyn, ot = { bits: u.distbits }, at = inftrees(DISTS, u.lens, u.nlen, u.ndist, u.distcode, 0, u.work, ot), u.distbits = ot.bits, at) {
|
|
6769
6785
|
a.msg = "invalid distances set", u.mode = BAD;
|
|
6770
6786
|
break;
|
|
6771
6787
|
}
|
|
@@ -6907,10 +6923,10 @@ const fixedtables = (a) => {
|
|
|
6907
6923
|
u.mode = DONE;
|
|
6908
6924
|
/* falls through */
|
|
6909
6925
|
case DONE:
|
|
6910
|
-
|
|
6926
|
+
at = Z_STREAM_END$1;
|
|
6911
6927
|
break t;
|
|
6912
6928
|
case BAD:
|
|
6913
|
-
|
|
6929
|
+
at = Z_DATA_ERROR$1;
|
|
6914
6930
|
break t;
|
|
6915
6931
|
case MEM:
|
|
6916
6932
|
return Z_MEM_ERROR$1;
|
|
@@ -6920,7 +6936,7 @@ const fixedtables = (a) => {
|
|
|
6920
6936
|
return Z_STREAM_ERROR$1;
|
|
6921
6937
|
}
|
|
6922
6938
|
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);*/
|
|
6923
|
-
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) &&
|
|
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) && at === Z_OK$1 && (at = Z_BUF_ERROR), at;
|
|
6924
6940
|
}, inflateEnd = (a) => {
|
|
6925
6941
|
if (inflateStateCheck(a))
|
|
6926
6942
|
return Z_STREAM_ERROR$1;
|
|
@@ -7154,12 +7170,12 @@ const noLogEvents = ["heartbeat", "onNetQuality", "networkQualityChange"], compr
|
|
|
7154
7170
|
}
|
|
7155
7171
|
return a;
|
|
7156
7172
|
};
|
|
7157
|
-
var vt, ut, Rt, yt, _t,
|
|
7173
|
+
var vt, ut, Rt, yt, _t, Ut, Mt, Pt, Bt, Et, Lt, jt, Zt;
|
|
7158
7174
|
class CallsWebSocket {
|
|
7159
7175
|
// 状态
|
|
7160
7176
|
constructor(I) {
|
|
7161
|
-
|
|
7162
|
-
|
|
7177
|
+
st(this, vt);
|
|
7178
|
+
st(this, ut, {
|
|
7163
7179
|
url: "wss://demo.putplay.cc/websocket",
|
|
7164
7180
|
// 地址
|
|
7165
7181
|
debug: !1,
|
|
@@ -7168,10 +7184,10 @@ class CallsWebSocket {
|
|
|
7168
7184
|
// 最大重连次数
|
|
7169
7185
|
timeout: 30 * 1e3
|
|
7170
7186
|
});
|
|
7171
|
-
|
|
7187
|
+
st(this, Rt, "");
|
|
7172
7188
|
// 缓存登录凭证
|
|
7173
|
-
|
|
7174
|
-
|
|
7189
|
+
st(this, yt, {});
|
|
7190
|
+
st(this, _t, {});
|
|
7175
7191
|
Z(this, "state", "closed");
|
|
7176
7192
|
// 外部 发送消息之前
|
|
7177
7193
|
Z(this, "sendMessageBefore", async () => {
|
|
@@ -7183,34 +7199,34 @@ class CallsWebSocket {
|
|
|
7183
7199
|
Z(this, "onReconnectStop", (I) => {
|
|
7184
7200
|
});
|
|
7185
7201
|
// 是否需要重连
|
|
7186
|
-
|
|
7202
|
+
st(this, Ut, (I) => {
|
|
7187
7203
|
let u = !0;
|
|
7188
7204
|
const { code: E = 1e3, reason: _ = "" } = I;
|
|
7189
7205
|
return E === 1e3 && (_ === "quit success!" || _ === "replace old connection!") && (u = !1), u;
|
|
7190
7206
|
});
|
|
7191
7207
|
// 重连成功
|
|
7192
|
-
|
|
7208
|
+
st(this, Mt, async (I) => {
|
|
7193
7209
|
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);
|
|
7194
7210
|
});
|
|
7195
7211
|
// 重连停止
|
|
7196
|
-
|
|
7212
|
+
st(this, Pt, async (I) => {
|
|
7197
7213
|
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);
|
|
7198
7214
|
});
|
|
7199
7215
|
// 自定义心跳规则
|
|
7200
|
-
|
|
7216
|
+
st(this, Bt, () => {
|
|
7201
7217
|
const I = { event: "heartbeat", sn: +`${F(1e5, 999999)}` };
|
|
7202
7218
|
return com.quick.voice.proto.CommonReq.encode(I).finish();
|
|
7203
7219
|
});
|
|
7204
7220
|
// 更新日志
|
|
7205
|
-
|
|
7221
|
+
st(this, Et, (I, u = {}) => {
|
|
7206
7222
|
try {
|
|
7207
7223
|
const { time: E, event: _, data: k = {}, data_original: e = {}, data_remote: n, ...O } = u, $ = U(E, "YYYY-MM-DD hh:mm:ss", { offset: 480 });
|
|
7208
7224
|
let N = {};
|
|
7209
|
-
const D = (
|
|
7210
|
-
const
|
|
7211
|
-
for (const
|
|
7212
|
-
(
|
|
7213
|
-
return
|
|
7225
|
+
const D = (et = {}) => {
|
|
7226
|
+
const tt = JSON.parse(JSON.stringify(et)), nt = Object.keys(tt);
|
|
7227
|
+
for (const lt of nt)
|
|
7228
|
+
(lt.includes("sdp") || lt.includes("Sdp")) && (tt[lt] = "");
|
|
7229
|
+
return tt;
|
|
7214
7230
|
};
|
|
7215
7231
|
let q = "res ↓";
|
|
7216
7232
|
switch (I) {
|
|
@@ -7223,14 +7239,25 @@ class CallsWebSocket {
|
|
|
7223
7239
|
}
|
|
7224
7240
|
let P = "#quickvo.logs";
|
|
7225
7241
|
ignoreEvent.includes(_) && (P = "#quickvo.ignoreEvents");
|
|
7226
|
-
const j = { "#action": q, timeStr: $, event: _, data: N, time: E, ...O }, V = localStorage.getItem(P) || JSON.stringify([]), J = JSON.parse(V)
|
|
7227
|
-
|
|
7242
|
+
const j = { "#action": q, timeStr: $, event: _, data: N, time: E, ...O }, V = localStorage.getItem(P) || JSON.stringify([]), J = JSON.parse(V);
|
|
7243
|
+
let z = _ === "heartbeat";
|
|
7244
|
+
const Y = [j];
|
|
7245
|
+
for (const et of J) {
|
|
7246
|
+
const { event: tt } = et;
|
|
7247
|
+
if (tt === "heartbeat") {
|
|
7248
|
+
if (z) continue;
|
|
7249
|
+
z = !0;
|
|
7250
|
+
}
|
|
7251
|
+
if (Y.length === 200) break;
|
|
7252
|
+
Y.push(et);
|
|
7253
|
+
}
|
|
7254
|
+
localStorage.setItem(P, JSON.stringify(Y));
|
|
7228
7255
|
} catch (E) {
|
|
7229
7256
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: updataLogs is error", E);
|
|
7230
7257
|
}
|
|
7231
7258
|
});
|
|
7232
7259
|
// 创建事件
|
|
7233
|
-
|
|
7260
|
+
st(this, Lt, (I, { resolve: u, reject: E }) => {
|
|
7234
7261
|
const { sn: _ } = I, k = () => {
|
|
7235
7262
|
const n = Q(this, yt)[_];
|
|
7236
7263
|
clearTimeout(n.destructionTimer), delete Q(this, yt)[_];
|
|
@@ -7241,13 +7268,13 @@ class CallsWebSocket {
|
|
|
7241
7268
|
Q(this, yt)[_] = { message: I, resolve: u, reject: E, destruction: k, destructionTimer: e };
|
|
7242
7269
|
});
|
|
7243
7270
|
// 获取事件
|
|
7244
|
-
|
|
7271
|
+
st(this, jt, (I) => Q(this, yt)[I]);
|
|
7245
7272
|
// 接收消息
|
|
7246
|
-
|
|
7273
|
+
st(this, Zt, async (I) => {
|
|
7247
7274
|
const u = new Uint8Array(I), E = com.quick.voice.proto.CommonRsp.decode(u), { sn: _, event: k } = E, e = onMessageFormat(E);
|
|
7248
7275
|
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))
|
|
7249
7276
|
return this.emitNotify(k, L(e, ["code", "data", "desc"]));
|
|
7250
|
-
const O = Q(this,
|
|
7277
|
+
const O = Q(this, jt).call(this, _);
|
|
7251
7278
|
if (O) {
|
|
7252
7279
|
const { resolve: $ = (D) => {
|
|
7253
7280
|
}, destruction: N = () => {
|
|
@@ -7277,11 +7304,11 @@ class CallsWebSocket {
|
|
|
7277
7304
|
...Q(this, ut),
|
|
7278
7305
|
url: E,
|
|
7279
7306
|
binaryType: "arraybuffer",
|
|
7280
|
-
onMessage: Q(this,
|
|
7281
|
-
checkReconnect: Q(this,
|
|
7282
|
-
getHeartbeatMsg: Q(this,
|
|
7283
|
-
onReconnectSuccess: Q(this,
|
|
7284
|
-
onReconnectStop: Q(this,
|
|
7307
|
+
onMessage: Q(this, Zt),
|
|
7308
|
+
checkReconnect: Q(this, Ut),
|
|
7309
|
+
getHeartbeatMsg: Q(this, Bt),
|
|
7310
|
+
onReconnectSuccess: Q(this, Mt),
|
|
7311
|
+
onReconnectStop: Q(this, Pt)
|
|
7285
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, _t)), u(Q(this, vt));
|
|
7286
7313
|
}));
|
|
7287
7314
|
/**
|
|
@@ -7313,7 +7340,7 @@ class CallsWebSocket {
|
|
|
7313
7340
|
compress: !1,
|
|
7314
7341
|
...e
|
|
7315
7342
|
});
|
|
7316
|
-
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,
|
|
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, Lt).call(this, O, { resolve: E, reject: _ });
|
|
7317
7344
|
const $ = com.quick.voice.proto.CommonReq.encode(O).finish();
|
|
7318
7345
|
(N = Q(this, vt)) == null || N.sendMessage($);
|
|
7319
7346
|
}));
|
|
@@ -7358,7 +7385,7 @@ class CallsWebSocket {
|
|
|
7358
7385
|
wt(this, ut, { ...Q(this, ut), ...I });
|
|
7359
7386
|
}
|
|
7360
7387
|
}
|
|
7361
|
-
vt = new WeakMap(), ut = new WeakMap(), Rt = new WeakMap(), yt = new WeakMap(), _t = new WeakMap(),
|
|
7388
|
+
vt = new WeakMap(), ut = new WeakMap(), Rt = new WeakMap(), yt = new WeakMap(), _t = new WeakMap(), Ut = new WeakMap(), Mt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), Et = new WeakMap(), Lt = new WeakMap(), jt = new WeakMap(), Zt = new WeakMap();
|
|
7362
7389
|
var y = Object.defineProperty, x = (a) => {
|
|
7363
7390
|
throw TypeError(a);
|
|
7364
7391
|
}, 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;
|
|
@@ -7414,14 +7441,16 @@ class K {
|
|
|
7414
7441
|
}
|
|
7415
7442
|
}
|
|
7416
7443
|
d = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
|
|
7417
|
-
var
|
|
7444
|
+
var Ft;
|
|
7418
7445
|
class RoomBase {
|
|
7419
|
-
constructor() {
|
|
7446
|
+
constructor(I) {
|
|
7420
7447
|
Z(this, "options", {
|
|
7421
7448
|
appid: "",
|
|
7422
7449
|
sdkToken: "",
|
|
7423
7450
|
roomId: "",
|
|
7424
7451
|
userId: "",
|
|
7452
|
+
earlyId: "",
|
|
7453
|
+
// 预连接ID
|
|
7425
7454
|
callType: 0,
|
|
7426
7455
|
debug: !1,
|
|
7427
7456
|
newPublishAutoSubscribe: !0
|
|
@@ -7429,14 +7458,16 @@ class RoomBase {
|
|
|
7429
7458
|
Z(this, "prohibitNotify", !1);
|
|
7430
7459
|
// 是否禁止通知
|
|
7431
7460
|
Z(this, "isEarly", !1);
|
|
7432
|
-
//
|
|
7461
|
+
// 是否 预连接
|
|
7462
|
+
Z(this, "isInRoom", !1);
|
|
7463
|
+
// 是否在房间内
|
|
7433
7464
|
Z(this, "taskQueue", new K(["createWs", "createSession", "ice", "joinRoom", "createTrack", "subscribe", "closeTrack"]));
|
|
7434
7465
|
// 条件队列
|
|
7435
7466
|
Z(this, "roomState", "ready");
|
|
7436
7467
|
// 房间状态
|
|
7437
7468
|
Z(this, "createAt", Date.now());
|
|
7438
7469
|
// 创建时间
|
|
7439
|
-
Z(this, "cwsIns"
|
|
7470
|
+
Z(this, "cwsIns");
|
|
7440
7471
|
// SDK通讯实例 // SDK通讯实例
|
|
7441
7472
|
Z(this, "peerIns", new RTCPeerConnection({ bundlePolicy: "max-bundle" }));
|
|
7442
7473
|
Z(this, "transceiverMap", /* @__PURE__ */ new Map());
|
|
@@ -7452,7 +7483,18 @@ class RoomBase {
|
|
|
7452
7483
|
screenSharing_video: "",
|
|
7453
7484
|
screenSharing_audio: ""
|
|
7454
7485
|
});
|
|
7455
|
-
|
|
7486
|
+
/**
|
|
7487
|
+
* 提交日志
|
|
7488
|
+
*/
|
|
7489
|
+
Z(this, "reportLogs", (I, u = "未知错误") => {
|
|
7490
|
+
const { appid: E, userId: _, earlyId: k } = this.options;
|
|
7491
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: obj", { origin: "web", type: I, app_id: E, user_id: _, ins_id: k, comment: u });
|
|
7492
|
+
{
|
|
7493
|
+
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;", "------->Breathe: binaryStream", N);
|
|
7495
|
+
}
|
|
7496
|
+
});
|
|
7497
|
+
st(this, Ft, () => {
|
|
7456
7498
|
this.taskQueue.setCondition("createWs", !0), this.taskQueue.setCondition("createSession", !1), this.taskQueue.setCondition("ice", !1);
|
|
7457
7499
|
});
|
|
7458
7500
|
/**
|
|
@@ -7477,12 +7519,6 @@ class RoomBase {
|
|
|
7477
7519
|
const u = { ...this.options, ...I };
|
|
7478
7520
|
this.options = u;
|
|
7479
7521
|
});
|
|
7480
|
-
/**
|
|
7481
|
-
* 初始化通讯实例
|
|
7482
|
-
*/
|
|
7483
|
-
Z(this, "initCwsCall", () => {
|
|
7484
|
-
this.cwsIns = new CallsWebSocket({ ...this.options });
|
|
7485
|
-
});
|
|
7486
7522
|
/**
|
|
7487
7523
|
* 获取媒体设备错误信息
|
|
7488
7524
|
*/
|
|
@@ -7551,32 +7587,32 @@ class RoomBase {
|
|
|
7551
7587
|
* 处理为应用层数据
|
|
7552
7588
|
*/
|
|
7553
7589
|
Z(this, "usersFilter", (I) => ft(I, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "permissions", "isPublished", "updateStreams"]).sort((_, k) => _.id.localeCompare(k.id, "en")));
|
|
7554
|
-
Q(this,
|
|
7590
|
+
this.setOptions(I), this.cwsIns = new CallsWebSocket({ ...I }), Q(this, Ft).call(this);
|
|
7555
7591
|
}
|
|
7556
7592
|
}
|
|
7557
|
-
|
|
7558
|
-
var $t, kt, dt, bt,
|
|
7593
|
+
Ft = new WeakMap();
|
|
7594
|
+
var $t, kt, dt, bt, Ht, zt, Tt, Jt;
|
|
7559
7595
|
class RoomMedias extends RoomBase {
|
|
7560
7596
|
// 媒体流上下文
|
|
7561
|
-
constructor() {
|
|
7562
|
-
super();
|
|
7563
|
-
|
|
7597
|
+
constructor(u) {
|
|
7598
|
+
super(u);
|
|
7599
|
+
st(this, $t, []);
|
|
7564
7600
|
// 可用媒体设备列表
|
|
7565
|
-
|
|
7601
|
+
st(this, kt, /* @__PURE__ */ new Map());
|
|
7566
7602
|
// 媒体流设备管理
|
|
7567
|
-
|
|
7603
|
+
st(this, dt, /* @__PURE__ */ new Map());
|
|
7568
7604
|
// 媒体轨道参数管理
|
|
7569
|
-
|
|
7605
|
+
st(this, bt, /* @__PURE__ */ new Map());
|
|
7570
7606
|
/**
|
|
7571
7607
|
* 初始化媒体参数
|
|
7572
7608
|
*/
|
|
7573
|
-
|
|
7609
|
+
st(this, Ht, () => {
|
|
7574
7610
|
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", {});
|
|
7575
7611
|
});
|
|
7576
7612
|
/**
|
|
7577
7613
|
* 初始化媒体设备类型
|
|
7578
7614
|
*/
|
|
7579
|
-
|
|
7615
|
+
st(this, zt, () => {
|
|
7580
7616
|
Q(this, kt).set("audioinput", "default"), Q(this, kt).set("videoinput", "default"), Q(this, kt).set("audiooutput", "default");
|
|
7581
7617
|
});
|
|
7582
7618
|
/**
|
|
@@ -7778,7 +7814,7 @@ class RoomMedias extends RoomBase {
|
|
|
7778
7814
|
/**
|
|
7779
7815
|
* 获取媒体设备列表
|
|
7780
7816
|
*/
|
|
7781
|
-
|
|
7817
|
+
st(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) => {
|
|
7782
7818
|
wt(this, $t, u);
|
|
7783
7819
|
}).catch(function(u) {
|
|
7784
7820
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", u);
|
|
@@ -7786,7 +7822,7 @@ class RoomMedias extends RoomBase {
|
|
|
7786
7822
|
/**
|
|
7787
7823
|
* 媒体设备发生变化
|
|
7788
7824
|
*/
|
|
7789
|
-
|
|
7825
|
+
st(this, Jt, () => {
|
|
7790
7826
|
navigator.mediaDevices && (navigator.mediaDevices.ondevicechange = async () => {
|
|
7791
7827
|
await Q(this, Tt).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
|
|
7792
7828
|
}), Q(this, Tt).call(this);
|
|
@@ -7806,7 +7842,12 @@ class RoomMedias extends RoomBase {
|
|
|
7806
7842
|
if (Q(this, kt).set(u, E), u === "audiooutput") {
|
|
7807
7843
|
const _ = Q(this, bt).values();
|
|
7808
7844
|
for (const k of _)
|
|
7809
|
-
k.kind === "audio" && "setSinkId" in HTMLMediaElement.prototype
|
|
7845
|
+
if (k.kind === "audio" && "setSinkId" in HTMLMediaElement.prototype)
|
|
7846
|
+
try {
|
|
7847
|
+
k.audioContext.setSinkId(E);
|
|
7848
|
+
} catch (e) {
|
|
7849
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error.", e);
|
|
7850
|
+
}
|
|
7810
7851
|
}
|
|
7811
7852
|
});
|
|
7812
7853
|
/**
|
|
@@ -7836,13 +7877,13 @@ class RoomMedias extends RoomBase {
|
|
|
7836
7877
|
* @returns MediaDeviceInfo[]
|
|
7837
7878
|
*/
|
|
7838
7879
|
Z(this, "getEnumerateVideoinputDevices", () => this.getEnumerateDevices("videoinput"));
|
|
7839
|
-
Q(this,
|
|
7880
|
+
Q(this, Jt).call(this), Q(this, zt).call(this), Q(this, Ht).call(this);
|
|
7840
7881
|
}
|
|
7841
7882
|
}
|
|
7842
|
-
$t = new WeakMap(), kt = new WeakMap(), dt = new WeakMap(), bt = new WeakMap(),
|
|
7883
|
+
$t = new WeakMap(), kt = new WeakMap(), dt = new WeakMap(), bt = new WeakMap(), Ht = new WeakMap(), zt = new WeakMap(), Tt = new WeakMap(), Jt = new WeakMap();
|
|
7843
7884
|
class RoomUsers extends RoomMedias {
|
|
7844
|
-
constructor() {
|
|
7845
|
-
super();
|
|
7885
|
+
constructor(u) {
|
|
7886
|
+
super(u);
|
|
7846
7887
|
/**
|
|
7847
7888
|
* 获取最大音量用户
|
|
7848
7889
|
*/
|
|
@@ -7878,7 +7919,7 @@ class RoomUsers extends RoomMedias {
|
|
|
7878
7919
|
* 设置增强音量
|
|
7879
7920
|
* @param userId
|
|
7880
7921
|
* @param mediaType
|
|
7881
|
-
* @param gain
|
|
7922
|
+
* @param gain 0-100
|
|
7882
7923
|
*/
|
|
7883
7924
|
Z(this, "setEnhanceGain", async (u, E, _) => {
|
|
7884
7925
|
const k = this.getUserMediaStreamContext(u, E);
|
|
@@ -7888,7 +7929,7 @@ class RoomUsers extends RoomMedias {
|
|
|
7888
7929
|
* 设置音量
|
|
7889
7930
|
* @param userId
|
|
7890
7931
|
* @param mediaType
|
|
7891
|
-
* @param gain
|
|
7932
|
+
* @param gain 0-1
|
|
7892
7933
|
*/
|
|
7893
7934
|
Z(this, "setVolume", (u, E, _) => {
|
|
7894
7935
|
const k = this.getUserMediaStreamContext(u, E);
|
|
@@ -8143,11 +8184,11 @@ const createMutedAudioStream = () => {
|
|
|
8143
8184
|
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;
|
|
8144
8185
|
}, 100), E.captureStream(u);
|
|
8145
8186
|
};
|
|
8146
|
-
var St,
|
|
8187
|
+
var St, Wt, xt, Kt, Gt, Qt;
|
|
8147
8188
|
class RoomPeer extends RoomUsers {
|
|
8148
|
-
constructor() {
|
|
8149
|
-
super();
|
|
8150
|
-
|
|
8189
|
+
constructor(u) {
|
|
8190
|
+
super(u);
|
|
8191
|
+
st(this, St, /* @__PURE__ */ new Map());
|
|
8151
8192
|
// 假媒体流 (创建轨道用)
|
|
8152
8193
|
Z(this, "getPeerStatsTimer", 0);
|
|
8153
8194
|
// 获取报告的定时器
|
|
@@ -8166,10 +8207,10 @@ class RoomPeer extends RoomUsers {
|
|
|
8166
8207
|
// 网络抖动
|
|
8167
8208
|
});
|
|
8168
8209
|
Z(this, "initPeer", () => {
|
|
8169
|
-
this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this,
|
|
8210
|
+
this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), Q(this, Kt).call(this), Q(this, Qt).call(this);
|
|
8170
8211
|
});
|
|
8171
8212
|
// 初始化假数据流
|
|
8172
|
-
|
|
8213
|
+
st(this, Wt, () => {
|
|
8173
8214
|
for (const u of mediaType_keys)
|
|
8174
8215
|
switch (u) {
|
|
8175
8216
|
case "microphoneCamera_audio":
|
|
@@ -8187,7 +8228,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8187
8228
|
}
|
|
8188
8229
|
});
|
|
8189
8230
|
// 获取假数据流
|
|
8190
|
-
|
|
8231
|
+
st(this, xt, (u) => Q(this, St).get(u));
|
|
8191
8232
|
/**
|
|
8192
8233
|
* 替换发射器媒体流
|
|
8193
8234
|
*/
|
|
@@ -8313,14 +8354,14 @@ class RoomPeer extends RoomUsers {
|
|
|
8313
8354
|
/**
|
|
8314
8355
|
* 监听webrtc ice通讯连接
|
|
8315
8356
|
*/
|
|
8316
|
-
|
|
8357
|
+
st(this, Kt, () => {
|
|
8317
8358
|
let u = 0;
|
|
8318
8359
|
const E = () => {
|
|
8319
8360
|
this.setRoomState("closed");
|
|
8320
8361
|
};
|
|
8321
|
-
this.peerIns.
|
|
8322
|
-
const _ = this.peerIns.
|
|
8323
|
-
switch (clearTimeout(u), _) {
|
|
8362
|
+
this.peerIns.oniceconnectionstatechange = () => {
|
|
8363
|
+
const _ = this.peerIns.iceConnectionState;
|
|
8364
|
+
switch (this.taskQueue.setCondition("ice", !1), clearTimeout(u), _) {
|
|
8324
8365
|
// 连接完成
|
|
8325
8366
|
case "connected":
|
|
8326
8367
|
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->quickvo: connectionState:${_}`), this.taskQueue.setCondition("ice", !0);
|
|
@@ -8462,7 +8503,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8462
8503
|
/**
|
|
8463
8504
|
* 计算网络质量
|
|
8464
8505
|
*/
|
|
8465
|
-
|
|
8506
|
+
st(this, Gt, async () => {
|
|
8466
8507
|
try {
|
|
8467
8508
|
const u = await this.peerIns.getStats(), E = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"], k = [...u.values()].filter((nt) => E.includes(nt.type));
|
|
8468
8509
|
let e = 0, n = 0, O = 0, $ = 0, N = 0, D = 0, q = [], P = [];
|
|
@@ -8472,23 +8513,23 @@ class RoomPeer extends RoomUsers {
|
|
|
8472
8513
|
}
|
|
8473
8514
|
this.reports = k;
|
|
8474
8515
|
for (const nt of this.reports) {
|
|
8475
|
-
const { bytesReceived: lt, bytesSent: it, packetsSent:
|
|
8476
|
-
lt && (e = lt), it && (n = it),
|
|
8516
|
+
const { bytesReceived: lt, bytesSent: it, packetsSent: at, packetsLost: ct, jitter: ot, roundTripTime: rt } = nt;
|
|
8517
|
+
lt && (e = lt), it && (n = it), at && (N += at), ct && (D += ct), rt && q.push((rt * 100).toFixed(2)), ot && P.push(ot.toFixed(2));
|
|
8477
8518
|
}
|
|
8478
8519
|
P.sort().reverse(), q.sort().reverse();
|
|
8479
8520
|
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 };
|
|
8480
8521
|
this.peerNetwork = et;
|
|
8481
8522
|
const tt = (nt, lt, it) => {
|
|
8482
|
-
const
|
|
8523
|
+
const at = Number(nt), ct = Number(lt), ot = Number(it);
|
|
8483
8524
|
let rt = "0";
|
|
8484
|
-
return
|
|
8525
|
+
return at < 0.03 && ct < 100 && ot < 0.05 ? rt = "5" : at < 0.06 && ct < 160 && ot < 0.1 ? rt = "4" : at < 0.1 && ct < 250 && ot < 0.15 ? rt = "3" : at < 0.15 && ct < 400 && ot < 0.2 ? rt = "2" : rt = "1", Number(rt);
|
|
8485
8526
|
};
|
|
8486
8527
|
{
|
|
8487
|
-
const nt = tt(J, z, Y), lt = await this.getCaller(), { network: it } = lt,
|
|
8488
|
-
if (await this.updateUserNetwork(this.options.userId,
|
|
8528
|
+
const nt = tt(J, z, Y), lt = await this.getCaller(), { network: it } = lt, at = { egress: nt, ingress: nt }, ct = JSON.stringify(it) !== JSON.stringify(at);
|
|
8529
|
+
if (await this.updateUserNetwork(this.options.userId, at), ct) {
|
|
8489
8530
|
this.emitNotifyUpdateUsers();
|
|
8490
8531
|
const { userId: ot, roomId: rt } = this.options;
|
|
8491
|
-
this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...
|
|
8532
|
+
this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...at, userId: ot, roomId: rt } }, !1);
|
|
8492
8533
|
}
|
|
8493
8534
|
}
|
|
8494
8535
|
} catch (u) {
|
|
@@ -8498,9 +8539,9 @@ class RoomPeer extends RoomUsers {
|
|
|
8498
8539
|
/**
|
|
8499
8540
|
* 获取连接的所有轨道分析数据
|
|
8500
8541
|
*/
|
|
8501
|
-
|
|
8542
|
+
st(this, Qt, () => {
|
|
8502
8543
|
const u = async () => {
|
|
8503
|
-
this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this,
|
|
8544
|
+
this.peerIns.connectionState !== "connected" || !this.options.roomId || Q(this, Gt).call(this);
|
|
8504
8545
|
};
|
|
8505
8546
|
this.getPeerStatsTimer = setInterval(u, 1 * 1e3);
|
|
8506
8547
|
});
|
|
@@ -8508,25 +8549,135 @@ class RoomPeer extends RoomUsers {
|
|
|
8508
8549
|
* 停止网络报告分析
|
|
8509
8550
|
*/
|
|
8510
8551
|
Z(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
|
|
8511
|
-
Q(this,
|
|
8552
|
+
Q(this, Wt).call(this);
|
|
8512
8553
|
}
|
|
8513
8554
|
}
|
|
8514
|
-
St = new WeakMap(),
|
|
8515
|
-
var
|
|
8555
|
+
St = new WeakMap(), Wt = new WeakMap(), xt = new WeakMap(), Kt = new WeakMap(), Gt = new WeakMap(), Qt = new WeakMap();
|
|
8556
|
+
var Vt, It, Nt, At, qt;
|
|
8516
8557
|
class RoomCalls extends RoomPeer {
|
|
8517
|
-
constructor() {
|
|
8518
|
-
super();
|
|
8558
|
+
constructor(u) {
|
|
8559
|
+
super(u);
|
|
8519
8560
|
// sdk服务版本
|
|
8520
8561
|
Z(this, "sdk_service_version", "1.0.5");
|
|
8562
|
+
/**
|
|
8563
|
+
* 广播给房间其他人
|
|
8564
|
+
* 只有当自己建立了发射轨道 并且 加入房间后才进行广播
|
|
8565
|
+
*/
|
|
8566
|
+
st(this, Vt, async (u) => {
|
|
8567
|
+
const { roomId: E } = this.options;
|
|
8568
|
+
if (!E) return;
|
|
8569
|
+
const { id: _, tracks: k = [] } = await this.getCaller();
|
|
8570
|
+
if (k.length === 0) return;
|
|
8571
|
+
const e = k.filter((n) => n.mediaType && u.includes(n.mediaType));
|
|
8572
|
+
this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: E, user: { id: _, tracks: e } } });
|
|
8573
|
+
});
|
|
8574
|
+
/**
|
|
8575
|
+
* 更新自己通话状态
|
|
8576
|
+
*/
|
|
8577
|
+
st(this, It, async (u) => new Promise(async (E, _) => {
|
|
8578
|
+
const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: u } };
|
|
8579
|
+
await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
|
|
8580
|
+
const { code: $ = 0 } = O;
|
|
8581
|
+
if ($ !== 200) return _(O);
|
|
8582
|
+
await this.updateUserCallAction(e, u), E(u);
|
|
8583
|
+
}).catch((O) => _(O));
|
|
8584
|
+
}));
|
|
8585
|
+
/**
|
|
8586
|
+
* 创建连接
|
|
8587
|
+
*/
|
|
8588
|
+
st(this, Nt, () => new Promise(async (u, E) => {
|
|
8589
|
+
try {
|
|
8590
|
+
if (["connecting", "connected"].includes(this.cwsIns.state)) return u(!0);
|
|
8591
|
+
this.taskQueue.setCondition("createWs", !1), this.cwsIns.clearEvents(), this.initPeer();
|
|
8592
|
+
const { appid: _ } = this.options, { userId: k = "", sdkToken: e, roomId: n } = this.options;
|
|
8593
|
+
if (!_) return E("quickvo: createWs is error. You must first use QuickVO.setOptions to set the appid.");
|
|
8594
|
+
const O = {
|
|
8595
|
+
a: e,
|
|
8596
|
+
b: k,
|
|
8597
|
+
c: _,
|
|
8598
|
+
r: n,
|
|
8599
|
+
v: this.sdk_service_version
|
|
8600
|
+
};
|
|
8601
|
+
if (this.isEarly) {
|
|
8602
|
+
const N = ht();
|
|
8603
|
+
O.i = N;
|
|
8604
|
+
}
|
|
8605
|
+
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createWs", O);
|
|
8606
|
+
const $ = btoa(encodeURI(JSON.stringify(O)));
|
|
8607
|
+
await this.cwsIns.connect($), this.taskQueue.setCondition("createWs", !0), u(!0);
|
|
8608
|
+
} catch (_) {
|
|
8609
|
+
console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createWs is error.", _), E(_);
|
|
8610
|
+
}
|
|
8611
|
+
}));
|
|
8612
|
+
/**
|
|
8613
|
+
* 创建cf会话
|
|
8614
|
+
*/
|
|
8615
|
+
st(this, At, () => {
|
|
8616
|
+
if (!["connecting", "connected"].includes(this.roomState))
|
|
8617
|
+
return this.setRoomState("connecting"), new Promise((u) => {
|
|
8618
|
+
const E = async () => {
|
|
8619
|
+
try {
|
|
8620
|
+
this.taskQueue.setCondition("createSession", !1), await this.addSenders(), await this.cwsIns.sendMessage({
|
|
8621
|
+
event: "connectCF",
|
|
8622
|
+
data: { sdp: this.getSdp() }
|
|
8623
|
+
}).then(async (_) => {
|
|
8624
|
+
const { code: k = 0, desc: e, data: n } = _;
|
|
8625
|
+
if (k !== 200) throw new Error(e);
|
|
8626
|
+
const { remoteSdp: O } = n;
|
|
8627
|
+
this.taskQueue.setCondition("ice", !1), await this.setRemoteDescription({ type: "answer", sdp: O }), this.taskQueue.setCondition("createSession", !0), u(!0);
|
|
8628
|
+
});
|
|
8629
|
+
} catch (_) {
|
|
8630
|
+
this.taskQueue.setCondition("createSession", !0), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo create session is error.", _);
|
|
8631
|
+
}
|
|
8632
|
+
};
|
|
8633
|
+
this.taskQueue.addTask(E, ["createWs"], { key: "createSession", describe: "createSession" });
|
|
8634
|
+
});
|
|
8635
|
+
});
|
|
8636
|
+
/**
|
|
8637
|
+
* 预连接
|
|
8638
|
+
* @param mediaTypes MediaType[]
|
|
8639
|
+
* @example quickvo.earlyConnect(['microphoneCamera_audio', 'microphoneCamera_video'])
|
|
8640
|
+
*/
|
|
8641
|
+
Z(this, "earlyConnect", (u = []) => {
|
|
8642
|
+
this.isEarly = !0, Q(this, Nt).call(this), Q(this, At).call(this), u.length === 0 && (u = ["microphoneCamera_audio", "microphoneCamera_video"]), Q(this, qt).call(this, u);
|
|
8643
|
+
});
|
|
8644
|
+
/**
|
|
8645
|
+
* 创建媒体轨道
|
|
8646
|
+
*/
|
|
8647
|
+
st(this, qt, async (u) => new Promise((E) => {
|
|
8648
|
+
const _ = async () => {
|
|
8649
|
+
try {
|
|
8650
|
+
this.taskQueue.setCondition("createTrack", !1);
|
|
8651
|
+
const k = await this.addSenders(u), e = this.getSenderTracks(k);
|
|
8652
|
+
if (e.length === 0)
|
|
8653
|
+
return this.taskQueue.setCondition("createTrack", !0), E(!0);
|
|
8654
|
+
await this.cwsIns.sendMessage({
|
|
8655
|
+
event: "publish",
|
|
8656
|
+
data: { sdp: this.getSdp(), tracks: e, callAction: 0 }
|
|
8657
|
+
}).then(async (n) => {
|
|
8658
|
+
const { code: O = 0, desc: $, data: N } = n;
|
|
8659
|
+
if (O !== 200)
|
|
8660
|
+
throw this.options.debug && console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createTrack is error.", { mediaTypes: u }), new Error($);
|
|
8661
|
+
const { remoteSdp: D } = N;
|
|
8662
|
+
await this.setRemoteDescription({ type: "answer", sdp: D }), this.taskQueue.setCondition("createTrack", !0), E(!0);
|
|
8663
|
+
});
|
|
8664
|
+
} catch {
|
|
8665
|
+
await this.removeSenders(u), this.taskQueue.setCondition("createTrack", !0), E(!0);
|
|
8666
|
+
}
|
|
8667
|
+
};
|
|
8668
|
+
this.taskQueue.addTask(_, ["createWs", "createSession", "ice", "subscribe", "createTrack", "closeTrack"], { describe: "createTrack" });
|
|
8669
|
+
}));
|
|
8521
8670
|
/**
|
|
8522
8671
|
* 设置本地流
|
|
8523
8672
|
* @param mediaType MediaType
|
|
8524
8673
|
* @param active 激活状态
|
|
8525
8674
|
* @example quickvo.setLocalStream('microphoneCamera_audio', false)
|
|
8675
|
+
* @example quickvo.setLocalStream(['microphoneCamera_audio', 'microphoneCamera_video'], false)
|
|
8526
8676
|
* @returns Promise<Streams>
|
|
8527
8677
|
*/
|
|
8528
8678
|
Z(this, "setLocalStream", (u, E) => new Promise(async (_, k) => {
|
|
8529
8679
|
try {
|
|
8680
|
+
typeof u == "string" && (u = [u]);
|
|
8530
8681
|
const { userId: e } = this.options;
|
|
8531
8682
|
for (const O of u)
|
|
8532
8683
|
if (this.setLocalStreamActiveMap.set(O, E), E === !1) {
|
|
@@ -8569,7 +8720,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8569
8720
|
u === "audioinput" && await n("microphoneCamera_audio"), u === "videoinput" && await n("microphoneCamera_video");
|
|
8570
8721
|
});
|
|
8571
8722
|
/**
|
|
8572
|
-
*
|
|
8723
|
+
* 改变屏幕共享流
|
|
8573
8724
|
* @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
|
|
8574
8725
|
* @param deviceId 设备ID
|
|
8575
8726
|
*/
|
|
@@ -8583,31 +8734,13 @@ class RoomCalls extends RoomPeer {
|
|
|
8583
8734
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: changeScreenSharing is error.", e);
|
|
8584
8735
|
}
|
|
8585
8736
|
});
|
|
8586
|
-
/**
|
|
8587
|
-
* 添加广播事件
|
|
8588
|
-
* @param notify Notify
|
|
8589
|
-
* @returns sn
|
|
8590
|
-
*/
|
|
8591
|
-
Z(this, "addNotify", (u) => this.cwsIns.addNotify(u));
|
|
8592
|
-
/**
|
|
8593
|
-
* 广播给房间其他人
|
|
8594
|
-
* 只有当自己建立了发射轨道 并且 加入房间后才进行广播
|
|
8595
|
-
*/
|
|
8596
|
-
at(this, Kt, async (u) => {
|
|
8597
|
-
const { roomId: E } = this.options;
|
|
8598
|
-
if (!E) return;
|
|
8599
|
-
const { id: _, tracks: k = [] } = await this.getCaller();
|
|
8600
|
-
if (k.length === 0) return;
|
|
8601
|
-
const e = k.filter((n) => n.mediaType && u.includes(n.mediaType));
|
|
8602
|
-
this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: E, user: { id: _, tracks: e } } });
|
|
8603
|
-
});
|
|
8604
8737
|
/**
|
|
8605
8738
|
* 加入房间
|
|
8606
8739
|
* @param roomOptions RoomOptions
|
|
8607
8740
|
* @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' , newPublishAutoSubscribe: true })
|
|
8608
8741
|
* @returns Promise<boolean>
|
|
8609
8742
|
*/
|
|
8610
|
-
Z(this, "joinRoom", async (u) => (this.setOptions(u), await this.
|
|
8743
|
+
Z(this, "joinRoom", async (u) => (this.setOptions(u), await Q(this, Nt).call(this), new Promise((E, _) => {
|
|
8611
8744
|
this.clearUsers();
|
|
8612
8745
|
let k = "";
|
|
8613
8746
|
const e = async () => {
|
|
@@ -8626,7 +8759,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8626
8759
|
if (q !== 200) return _(P);
|
|
8627
8760
|
const { roomId: V = "", roomUsers: J = [] } = j;
|
|
8628
8761
|
if (V !== O) return _("加入的房间不匹配");
|
|
8629
|
-
this.
|
|
8762
|
+
this.isInRoom = !0, Q(this, At).call(this), await this.updateUsers(J), e();
|
|
8630
8763
|
});
|
|
8631
8764
|
} catch (O) {
|
|
8632
8765
|
this.taskQueue.setCondition("joinRoom", !0), _(`加入房间失败: ${O.message || O || "服务器繁忙"}`);
|
|
@@ -8642,10 +8775,10 @@ class RoomCalls extends RoomPeer {
|
|
|
8642
8775
|
Z(this, "quitRoom", () => new Promise(async (u) => {
|
|
8643
8776
|
const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
|
|
8644
8777
|
try {
|
|
8645
|
-
this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.setRoomState("ready");
|
|
8778
|
+
this.isInRoom = !1, this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.setRoomState("ready");
|
|
8646
8779
|
} catch {
|
|
8647
8780
|
}
|
|
8648
|
-
await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoom", data: k }), u(!0);
|
|
8781
|
+
await new Promise((e) => setTimeout(() => e(!0), 300)), this.taskQueue.setCondition("closeTrack", !0), this.cwsIns.sendMessage({ event: "quitRoom", data: k }), u(!0);
|
|
8649
8782
|
}));
|
|
8650
8783
|
/**
|
|
8651
8784
|
* 退出房间 不断开连接
|
|
@@ -8655,7 +8788,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8655
8788
|
Z(this, "quitRoomEx", () => new Promise(async (u) => {
|
|
8656
8789
|
const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
|
|
8657
8790
|
try {
|
|
8658
|
-
this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), await this.replaceSenderStream([], !1);
|
|
8791
|
+
this.isInRoom = !1, this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), await this.replaceSenderStream([], !1);
|
|
8659
8792
|
} catch {
|
|
8660
8793
|
}
|
|
8661
8794
|
await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoomEx", data: k }), u(!0);
|
|
@@ -8688,23 +8821,25 @@ class RoomCalls extends RoomPeer {
|
|
|
8688
8821
|
Z(this, "publish", (u) => new Promise(async (E, _) => {
|
|
8689
8822
|
const k = async () => {
|
|
8690
8823
|
try {
|
|
8691
|
-
await this.replaceSenderStream(u, !1)
|
|
8824
|
+
await this.replaceSenderStream(u, !1);
|
|
8692
8825
|
const e = await this.getCaller();
|
|
8693
8826
|
try {
|
|
8694
8827
|
await this.setLocalStream(u, !0);
|
|
8695
8828
|
} catch {
|
|
8696
8829
|
}
|
|
8697
8830
|
const n = [];
|
|
8698
|
-
for (const
|
|
8699
|
-
this.getUserStream(e.id,
|
|
8700
|
-
const O =
|
|
8701
|
-
await this.
|
|
8702
|
-
const
|
|
8703
|
-
await
|
|
8831
|
+
for (const q of u)
|
|
8832
|
+
this.getUserStream(e.id, q).getTracks().length === 0 && n.push(q);
|
|
8833
|
+
const O = u.filter((q) => !n.includes(q) || ["microphoneCamera_audio", "microphoneCamera_video"].includes(q));
|
|
8834
|
+
await Q(this, qt).call(this, O);
|
|
8835
|
+
const $ = this.getSenderTracks(O), N = [...e.tracks, ...$];
|
|
8836
|
+
await this.updateUsertracks(e.id, N, !0);
|
|
8837
|
+
const D = await this.getCallAction(N);
|
|
8838
|
+
await Q(this, It).call(this, D), await this.replaceSenderStream(u, !0), Q(this, Vt).call(this, u), n.length !== 0 && await this.inactiveTracks(n, !1);
|
|
8704
8839
|
{
|
|
8705
8840
|
await this.emitNotifyUpdateUsers();
|
|
8706
|
-
const
|
|
8707
|
-
E(
|
|
8841
|
+
const q = await this.getCaller();
|
|
8842
|
+
E(q);
|
|
8708
8843
|
}
|
|
8709
8844
|
} catch (e) {
|
|
8710
8845
|
_(`publish is error: ${e.message || e}`);
|
|
@@ -8802,6 +8937,17 @@ class RoomCalls extends RoomPeer {
|
|
|
8802
8937
|
};
|
|
8803
8938
|
this.taskQueue.addTask(e, ["createWs", "createSession", "ice", "createTrack", "closeTrack"], { describe: "subscribe" });
|
|
8804
8939
|
}));
|
|
8940
|
+
/**
|
|
8941
|
+
* 协商流
|
|
8942
|
+
*/
|
|
8943
|
+
Z(this, "renegotiate", () => new Promise(async (u, E) => {
|
|
8944
|
+
await this.createAnswer(), await this.cwsIns.sendMessage({ event: "renegotiate", data: { sdp: this.getSdp() } }).then((_) => {
|
|
8945
|
+
if (_.code !== 200) return E("协商流错误");
|
|
8946
|
+
u(!0);
|
|
8947
|
+
}).catch((_) => {
|
|
8948
|
+
console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe:error", _), E(`协商流错误: ${_.message || _}`);
|
|
8949
|
+
});
|
|
8950
|
+
}));
|
|
8805
8951
|
/**
|
|
8806
8952
|
* 停止订阅流
|
|
8807
8953
|
* @param trackNames string[] = []
|
|
@@ -8873,126 +9019,23 @@ class RoomCalls extends RoomPeer {
|
|
|
8873
9019
|
E(_);
|
|
8874
9020
|
});
|
|
8875
9021
|
}));
|
|
8876
|
-
/**
|
|
8877
|
-
* 更新自己通话状态
|
|
8878
|
-
*/
|
|
8879
|
-
at(this, It, async (u) => new Promise(async (E, _) => {
|
|
8880
|
-
const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: u } };
|
|
8881
|
-
await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
|
|
8882
|
-
const { code: $ = 0 } = O;
|
|
8883
|
-
if ($ !== 200) return _(O);
|
|
8884
|
-
await this.updateUserCallAction(e, u), E(u);
|
|
8885
|
-
}).catch((O) => _(O));
|
|
8886
|
-
}));
|
|
8887
|
-
/**
|
|
8888
|
-
* 协商流
|
|
8889
|
-
*/
|
|
8890
|
-
Z(this, "renegotiate", () => new Promise(async (u, E) => {
|
|
8891
|
-
await this.createAnswer(), await this.cwsIns.sendMessage({ event: "renegotiate", data: { sdp: this.getSdp() } }).then((_) => {
|
|
8892
|
-
if (_.code !== 200) return E("协商流错误");
|
|
8893
|
-
u(!0);
|
|
8894
|
-
}).catch((_) => {
|
|
8895
|
-
console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe:error", _), E(`协商流错误: ${_.message || _}`);
|
|
8896
|
-
});
|
|
8897
|
-
}));
|
|
8898
|
-
/**
|
|
8899
|
-
* 创建连接
|
|
8900
|
-
*/
|
|
8901
|
-
Z(this, "createWs", () => new Promise(async (u, E) => {
|
|
8902
|
-
try {
|
|
8903
|
-
if (["connecting", "connected"].includes(this.cwsIns.state)) return u(!0);
|
|
8904
|
-
this.taskQueue.setCondition("createWs", !1), this.cwsIns.clearEvents(), this.initPeer();
|
|
8905
|
-
const { appid: _ } = this.options, { userId: k, sdkToken: e, roomId: n } = this.options;
|
|
8906
|
-
if (!_) return E("quickvo: createWs is error. You must first use QuickVO.setOptions to set the appid.");
|
|
8907
|
-
if (!k) return E("quickvo: createWs is error. You must first use QuickVO.setOptions to set the userId.");
|
|
8908
|
-
const O = {
|
|
8909
|
-
a: e,
|
|
8910
|
-
b: k,
|
|
8911
|
-
c: _,
|
|
8912
|
-
r: n,
|
|
8913
|
-
v: this.sdk_service_version
|
|
8914
|
-
};
|
|
8915
|
-
this.isEarly && (O.i = ht()), this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createWs", O);
|
|
8916
|
-
const $ = btoa(encodeURI(JSON.stringify(O)));
|
|
8917
|
-
await this.cwsIns.connect($), this.taskQueue.setCondition("createWs", !0), u(!0);
|
|
8918
|
-
} catch (_) {
|
|
8919
|
-
console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createWs is error.", _), E(_);
|
|
8920
|
-
}
|
|
8921
|
-
}));
|
|
8922
|
-
/**
|
|
8923
|
-
* 创建cf会话
|
|
8924
|
-
*/
|
|
8925
|
-
Z(this, "createSession", () => {
|
|
8926
|
-
if (!["connecting", "connected"].includes(this.roomState))
|
|
8927
|
-
return this.setRoomState("connecting"), new Promise((u) => {
|
|
8928
|
-
const E = async () => {
|
|
8929
|
-
try {
|
|
8930
|
-
this.taskQueue.setCondition("createSession", !1), await this.addSenders(), await this.cwsIns.sendMessage({
|
|
8931
|
-
event: "connectCF",
|
|
8932
|
-
data: { sdp: this.getSdp() }
|
|
8933
|
-
}).then(async (_) => {
|
|
8934
|
-
const { code: k = 0, desc: e, data: n } = _;
|
|
8935
|
-
if (k !== 200) throw new Error(e);
|
|
8936
|
-
const { remoteSdp: O } = n;
|
|
8937
|
-
this.taskQueue.setCondition("ice", !1), await this.setRemoteDescription({ type: "answer", sdp: O }), this.taskQueue.setCondition("createSession", !0), u(!0);
|
|
8938
|
-
});
|
|
8939
|
-
} catch (_) {
|
|
8940
|
-
this.taskQueue.setCondition("createSession", !0), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo create session is error.", _);
|
|
8941
|
-
}
|
|
8942
|
-
};
|
|
8943
|
-
this.taskQueue.addTask(E, ["createWs"], { key: "createSession", describe: "createSession" });
|
|
8944
|
-
});
|
|
8945
|
-
});
|
|
8946
|
-
/**
|
|
8947
|
-
* 创建媒体轨道
|
|
8948
|
-
*/
|
|
8949
|
-
Z(this, "createTrack", async (u) => new Promise((E) => {
|
|
8950
|
-
const _ = async () => {
|
|
8951
|
-
try {
|
|
8952
|
-
this.taskQueue.setCondition("createTrack", !1);
|
|
8953
|
-
const k = await this.addSenders(u), e = this.getSenderTracks(k);
|
|
8954
|
-
if (e.length === 0)
|
|
8955
|
-
return this.taskQueue.setCondition("createTrack", !0), E(!0);
|
|
8956
|
-
await this.cwsIns.sendMessage({
|
|
8957
|
-
event: "publish",
|
|
8958
|
-
data: { sdp: this.getSdp(), tracks: e, callAction: 0 }
|
|
8959
|
-
}).then(async (n) => {
|
|
8960
|
-
const { code: O = 0, desc: $, data: N } = n;
|
|
8961
|
-
if (O !== 200)
|
|
8962
|
-
throw this.options.debug && console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: createTrack is error.", { mediaTypes: u }), new Error($);
|
|
8963
|
-
const { remoteSdp: D } = N;
|
|
8964
|
-
await this.setRemoteDescription({ type: "answer", sdp: D }), this.taskQueue.setCondition("createTrack", !0), E(!0);
|
|
8965
|
-
});
|
|
8966
|
-
} catch {
|
|
8967
|
-
await this.removeSenders(u), this.taskQueue.setCondition("createTrack", !0), E(!0);
|
|
8968
|
-
}
|
|
8969
|
-
};
|
|
8970
|
-
this.taskQueue.addTask(_, ["createWs", "createSession", "ice", "subscribe", "createTrack", "closeTrack"], { describe: "createTrack" });
|
|
8971
|
-
}));
|
|
8972
|
-
/**
|
|
8973
|
-
* 提前建连
|
|
8974
|
-
*/
|
|
8975
|
-
Z(this, "earlyConnect", (u = []) => {
|
|
8976
|
-
this.isEarly = !0, this.createWs(), this.createSession(), u.length === 0 && (u = ["microphoneCamera_audio", "microphoneCamera_video"]), this.createTrack(u);
|
|
8977
|
-
});
|
|
8978
|
-
this.setRoomState("ready");
|
|
8979
9022
|
}
|
|
8980
9023
|
}
|
|
8981
|
-
|
|
9024
|
+
Vt = new WeakMap(), It = new WeakMap(), Nt = new WeakMap(), At = new WeakMap(), qt = new WeakMap();
|
|
8982
9025
|
class Room extends RoomCalls {
|
|
8983
|
-
constructor() {
|
|
8984
|
-
super();
|
|
9026
|
+
constructor(I) {
|
|
9027
|
+
super(I);
|
|
8985
9028
|
}
|
|
8986
9029
|
}
|
|
8987
|
-
var gt,
|
|
9030
|
+
var gt, Yt, Xt, te, ee;
|
|
8988
9031
|
class QuickVO extends Room {
|
|
8989
9032
|
constructor(u) {
|
|
8990
|
-
super();
|
|
8991
|
-
|
|
9033
|
+
super(u);
|
|
9034
|
+
st(this, gt, /* @__PURE__ */ new Map());
|
|
8992
9035
|
/**
|
|
8993
9036
|
* 添加内部监听事件
|
|
8994
9037
|
*/
|
|
8995
|
-
|
|
9038
|
+
st(this, Yt, () => {
|
|
8996
9039
|
{
|
|
8997
9040
|
const u = async (E) => {
|
|
8998
9041
|
const { qualities: _ = [] } = E.data, [k] = _;
|
|
@@ -9021,21 +9064,21 @@ class QuickVO extends Room {
|
|
|
9021
9064
|
}
|
|
9022
9065
|
{
|
|
9023
9066
|
const u = async (E) => {
|
|
9024
|
-
const { user: _ } = E.data, { id: k, tracks: e = [] } = _;
|
|
9025
|
-
await this.updateUserPermissions(k, 3);
|
|
9026
|
-
const
|
|
9067
|
+
const { user: _ } = E.data, { id: k, tracks: e = [], callAction: n = 0 } = _;
|
|
9068
|
+
await this.updateUserCallAction(k, n), await this.updateUserPermissions(k, 3);
|
|
9069
|
+
const O = [];
|
|
9027
9070
|
{
|
|
9028
|
-
const { tracks:
|
|
9029
|
-
for (const
|
|
9030
|
-
const { mid:
|
|
9031
|
-
if (
|
|
9032
|
-
|
|
9071
|
+
const { tracks: $ } = await this.getUser(k);
|
|
9072
|
+
for (const N of e) {
|
|
9073
|
+
const { mid: D, trackName: q } = N;
|
|
9074
|
+
if ($.find((j) => j.mid === D && j.trackName === q)) continue;
|
|
9075
|
+
O.push(N);
|
|
9033
9076
|
}
|
|
9034
9077
|
}
|
|
9035
|
-
if (
|
|
9036
|
-
if (await this.updateUsertracks(k,
|
|
9037
|
-
const
|
|
9038
|
-
await this.subscribe(
|
|
9078
|
+
if (O.length !== 0)
|
|
9079
|
+
if (await this.updateUsertracks(k, O, !0), this.options.newPublishAutoSubscribe) {
|
|
9080
|
+
const $ = this.getTrackNamesFormTracks(O);
|
|
9081
|
+
await this.subscribe($);
|
|
9039
9082
|
} else
|
|
9040
9083
|
await this.emitNotifyUpdateUsers();
|
|
9041
9084
|
};
|
|
@@ -9064,25 +9107,29 @@ class QuickVO extends Room {
|
|
|
9064
9107
|
}
|
|
9065
9108
|
this.cwsIns.addNotify({ event: "onTokenExpired", callback: async (u) => this.destroy() }, !0), this.cwsIns.addNotify({ event: "destroyRoom", callback: this.destroy }, !0);
|
|
9066
9109
|
});
|
|
9110
|
+
/**
|
|
9111
|
+
* 外部添加广播事件
|
|
9112
|
+
* @param notify Notify
|
|
9113
|
+
* @returns sn
|
|
9114
|
+
*/
|
|
9115
|
+
Z(this, "addNotify", (u) => this.cwsIns.addNotify(u));
|
|
9067
9116
|
/**
|
|
9068
9117
|
* cwsIns 发送消息前
|
|
9069
9118
|
*/
|
|
9070
|
-
|
|
9071
|
-
this.cwsIns.sendMessageBefore = async () => {
|
|
9072
|
-
};
|
|
9119
|
+
st(this, Xt, () => {
|
|
9073
9120
|
});
|
|
9074
9121
|
/**
|
|
9075
9122
|
* 重连成功
|
|
9076
9123
|
*/
|
|
9077
|
-
|
|
9124
|
+
st(this, te, () => {
|
|
9078
9125
|
this.cwsIns.onReconnectSuccess = async () => {
|
|
9079
|
-
this.syncRoomInfo();
|
|
9126
|
+
await this.syncRoomInfo();
|
|
9080
9127
|
};
|
|
9081
9128
|
});
|
|
9082
9129
|
/**
|
|
9083
9130
|
* 重连停止
|
|
9084
9131
|
*/
|
|
9085
|
-
|
|
9132
|
+
st(this, ee, async () => {
|
|
9086
9133
|
});
|
|
9087
9134
|
/**
|
|
9088
9135
|
* 添加 FrameRequestCallback
|
|
@@ -9121,10 +9168,10 @@ class QuickVO extends Room {
|
|
|
9121
9168
|
Z(this, "destroy", async () => {
|
|
9122
9169
|
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 销毁SDK"), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {}, desc: "sdk is destroy." }), await this.cwsIns.close();
|
|
9123
9170
|
});
|
|
9124
|
-
|
|
9171
|
+
Q(this, Xt).call(this), Q(this, te).call(this), Q(this, ee).call(this), Q(this, Yt).call(this);
|
|
9125
9172
|
}
|
|
9126
9173
|
}
|
|
9127
|
-
gt = new WeakMap(),
|
|
9174
|
+
gt = new WeakMap(), Yt = new WeakMap(), Xt = new WeakMap(), te = new WeakMap(), ee = new WeakMap();
|
|
9128
9175
|
export {
|
|
9129
9176
|
QuickVO,
|
|
9130
9177
|
ignoreEvent
|