quickvo-sdk-js 0.6.4 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -737,8 +737,6 @@ class AudioMediaContext {
|
|
|
737
737
|
Z(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
|
|
738
738
|
// 媒体流音频源节点
|
|
739
739
|
Z(this, "mediaStreamAudioSourceNode");
|
|
740
|
-
// 媒体流音频源节点
|
|
741
|
-
Z(this, "destination");
|
|
742
740
|
// 增益节点 (自动增益)
|
|
743
741
|
Z(this, "autoGainNode");
|
|
744
742
|
// 滤波器节点 (噪声抑制)
|
|
@@ -755,11 +753,6 @@ class AudioMediaContext {
|
|
|
755
753
|
* 停止
|
|
756
754
|
*/
|
|
757
755
|
Z(this, "stop", () => {
|
|
758
|
-
{
|
|
759
|
-
const I = this.destination.stream.getTracks();
|
|
760
|
-
for (const u of I)
|
|
761
|
-
u.enabled = !1, u.stop(), this.stream.removeTrack(u);
|
|
762
|
-
}
|
|
763
756
|
{
|
|
764
757
|
const I = this.stream.getTracks();
|
|
765
758
|
for (const u of I)
|
|
@@ -777,13 +770,12 @@ class AudioMediaContext {
|
|
|
777
770
|
/**
|
|
778
771
|
* 获取数据流
|
|
779
772
|
*/
|
|
780
|
-
Z(this, "getStream", () => this.
|
|
781
|
-
// getStream = () => this.mediaStreamAudioSourceNode.mediaStream
|
|
773
|
+
Z(this, "getStream", () => this.mediaStreamAudioSourceNode.mediaStream);
|
|
782
774
|
/**
|
|
783
775
|
* 静音
|
|
784
776
|
*/
|
|
785
777
|
Z(this, "setMute", (I = !0) => {
|
|
786
|
-
I ? this.
|
|
778
|
+
I ? this.gainNode.disconnect(this.audioContext.destination) : this.gainNode.connect(this.audioContext.destination);
|
|
787
779
|
});
|
|
788
780
|
/**
|
|
789
781
|
* 设置音量
|
|
@@ -821,12 +813,13 @@ class AudioMediaContext {
|
|
|
821
813
|
*/
|
|
822
814
|
Z(this, "setFilter", (I = {}) => {
|
|
823
815
|
this.options = { ...this.options, ...I };
|
|
824
|
-
const { autoGainControl: u, noiseSuppression: E, echoCancellation: _ } = this.options, { mediaStreamAudioSourceNode: k, autoGainNode: e, biquadFilterNode: n, delayNode: O, gainNode: $ } = this
|
|
816
|
+
const { autoGainControl: u, noiseSuppression: E, echoCancellation: _ } = this.options, { mediaStreamAudioSourceNode: k, autoGainNode: e, biquadFilterNode: n, delayNode: O, gainNode: $ } = this;
|
|
817
|
+
let N = k;
|
|
825
818
|
return u && N.connect(e), E && N.connect(n), _ && N.connect(O), N.connect($), I;
|
|
826
819
|
});
|
|
827
|
-
this.stream.addTrack(I), this.audio.srcObject = this.stream, this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.mediaStreamAudioSourceNode = this.audioContext.createMediaStreamSource(this.stream), this.
|
|
828
|
-
const { gainNode: u, analyserNode: E
|
|
829
|
-
u.connect(E),
|
|
820
|
+
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(this.gain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
|
|
821
|
+
const { gainNode: u, analyserNode: E } = this;
|
|
822
|
+
u.connect(E), this.audioContext.state === "suspended" && (this.audioContext.resume(), document.addEventListener("click", () => this.audioContext.resume(), { once: !0 })), this.setFilter();
|
|
830
823
|
}
|
|
831
824
|
}
|
|
832
825
|
class VideoMediaContext {
|
|
@@ -7185,7 +7178,7 @@ const noLogEvents = ["heartbeat", "onNetQuality", "networkQualityChange"], compr
|
|
|
7185
7178
|
}
|
|
7186
7179
|
return a;
|
|
7187
7180
|
};
|
|
7188
|
-
var wt, dt, xt, yt, kt, Pt,
|
|
7181
|
+
var wt, dt, xt, yt, kt, Pt, Lt, Bt, jt, Nt, Zt, Ft, Ht;
|
|
7189
7182
|
class CallsWebSocket {
|
|
7190
7183
|
// 状态
|
|
7191
7184
|
constructor(I) {
|
|
@@ -7220,11 +7213,11 @@ class CallsWebSocket {
|
|
|
7220
7213
|
return E === 1e3 && (_ === "quit success!" || _ === "replace old connection!") && (u = !1), u;
|
|
7221
7214
|
});
|
|
7222
7215
|
// 重连成功
|
|
7223
|
-
at(this,
|
|
7216
|
+
at(this, Lt, async (I) => {
|
|
7224
7217
|
J(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重连成功", I), this.state = "connected", this.onReconnectSuccess(I);
|
|
7225
7218
|
});
|
|
7226
7219
|
// 重连停止
|
|
7227
|
-
at(this,
|
|
7220
|
+
at(this, Bt, async (I) => {
|
|
7228
7221
|
J(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重连停止", I), this.close(), this.state = "closed", this.onReconnectStop(I);
|
|
7229
7222
|
});
|
|
7230
7223
|
// 自定义心跳规则
|
|
@@ -7322,8 +7315,8 @@ class CallsWebSocket {
|
|
|
7322
7315
|
onMessage: J(this, Ht),
|
|
7323
7316
|
checkReconnect: J(this, Pt),
|
|
7324
7317
|
getHeartbeatMsg: J(this, jt),
|
|
7325
|
-
onReconnectSuccess: J(this,
|
|
7326
|
-
onReconnectStop: J(this,
|
|
7318
|
+
onReconnectSuccess: J(this, Lt),
|
|
7319
|
+
onReconnectStop: J(this, Bt)
|
|
7327
7320
|
})), this.state = "connecting", await J(this, wt).connect(), this.state = "connected", J(this, dt).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", J(this, kt)), u(J(this, wt));
|
|
7328
7321
|
}));
|
|
7329
7322
|
/**
|
|
@@ -7400,7 +7393,7 @@ class CallsWebSocket {
|
|
|
7400
7393
|
Ot(this, dt, { ...J(this, dt), ...I });
|
|
7401
7394
|
}
|
|
7402
7395
|
}
|
|
7403
|
-
wt = new WeakMap(), dt = new WeakMap(), xt = new WeakMap(), yt = new WeakMap(), kt = new WeakMap(), Pt = new WeakMap(),
|
|
7396
|
+
wt = new WeakMap(), dt = new WeakMap(), xt = new WeakMap(), yt = new WeakMap(), kt = new WeakMap(), Pt = new WeakMap(), Lt = new WeakMap(), Bt = new WeakMap(), jt = new WeakMap(), Nt = new WeakMap(), Zt = new WeakMap(), Ft = new WeakMap(), Ht = new WeakMap();
|
|
7404
7397
|
var y = Object.defineProperty, x = (a) => {
|
|
7405
7398
|
throw TypeError(a);
|
|
7406
7399
|
}, 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;
|
|
@@ -7528,7 +7521,7 @@ class RoomBase {
|
|
|
7528
7521
|
const $ = O(I), N = { origin: n, type: $, app_id: E, user_id: _, ins_id: k, desc: u }, D = btoa(encodeURI(JSON.stringify(N))), q = `${e}/upload/log?log_key=${D}`;
|
|
7529
7522
|
{
|
|
7530
7523
|
const P = localStorage.getItem("#quickvo.logs") || JSON.stringify([]), V = new TextEncoder().encode(P), Q = pako.deflate(V, { gzip: !0 });
|
|
7531
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: reportLogs", { obj: N, url: q, size: ot(Q.byteLength) }), fetch(q, { headers: { "Content-Type": "multipart/form-data" }, method: "POST", body: Q });
|
|
7524
|
+
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: reportLogs", { obj: N, url: q, size: ot(Q.byteLength) }), fetch(q, { headers: { "Content-Type": "multipart/form-data" }, method: "POST", body: Q });
|
|
7532
7525
|
}
|
|
7533
7526
|
}
|
|
7534
7527
|
});
|
|
@@ -7565,7 +7558,7 @@ class RoomBase {
|
|
|
7565
7558
|
const I = await navigator.mediaDevices.enumerateDevices();
|
|
7566
7559
|
I.find((E) => E.kind === "audioinput") || (this.mediaDevicesErrInfo.microphoneCamera_audio = "audioinput is not available."), I.find((E) => E.kind === "videoinput") || (this.mediaDevicesErrInfo.microphoneCamera_video = "videoinput is not available.");
|
|
7567
7560
|
} catch (I) {
|
|
7568
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->
|
|
7561
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getMediaDevicesErrInfo is error.", I);
|
|
7569
7562
|
}
|
|
7570
7563
|
return this.mediaDevicesErrInfo;
|
|
7571
7564
|
});
|
|
@@ -8268,7 +8261,13 @@ class RoomPeer extends RoomUsers {
|
|
|
8268
8261
|
});
|
|
8269
8262
|
// 初始化假数据流
|
|
8270
8263
|
at(this, Gt, () => {
|
|
8271
|
-
for (const u of mediaType_keys)
|
|
8264
|
+
for (const u of mediaType_keys) {
|
|
8265
|
+
const E = J(this, gt).get(u);
|
|
8266
|
+
if (E) {
|
|
8267
|
+
const _ = E.getTracks();
|
|
8268
|
+
for (const k of _)
|
|
8269
|
+
k.stop();
|
|
8270
|
+
}
|
|
8272
8271
|
switch (u) {
|
|
8273
8272
|
case "microphoneCamera_audio":
|
|
8274
8273
|
J(this, gt).set("microphoneCamera_audio", createMutedAudioStream());
|
|
@@ -8283,6 +8282,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8283
8282
|
J(this, gt).set("screenSharing_video", createFakeVideoStream());
|
|
8284
8283
|
break;
|
|
8285
8284
|
}
|
|
8285
|
+
}
|
|
8286
8286
|
});
|
|
8287
8287
|
// 获取假数据流
|
|
8288
8288
|
at(this, At, (u) => J(this, gt).get(u));
|
|
@@ -8325,11 +8325,11 @@ class RoomPeer extends RoomUsers {
|
|
|
8325
8325
|
u.length === 0 && (this.peerIns.addTransceiver("audio", { direction: "sendonly" }), this.peerIns.addTransceiver("video", { direction: "sendonly" }));
|
|
8326
8326
|
const E = [];
|
|
8327
8327
|
for (const _ of u) {
|
|
8328
|
-
if (this.transceiverMap.
|
|
8329
|
-
const
|
|
8330
|
-
this.transceiverMap.set(_,
|
|
8328
|
+
if (this.transceiverMap.get(_)) continue;
|
|
8329
|
+
const e = J(this, At).call(this, _), [n] = e.getTracks(), O = this.peerIns.addTransceiver(n, { direction: "sendonly" });
|
|
8330
|
+
this.transceiverMap.set(_, O), E.push(_);
|
|
8331
8331
|
}
|
|
8332
|
-
if (u.length === 0 || E.length) {
|
|
8332
|
+
if (u.length === 0 || E.length !== 0) {
|
|
8333
8333
|
const _ = await this.peerIns.createOffer();
|
|
8334
8334
|
if (this.options.debug) {
|
|
8335
8335
|
const k = libExports.parse(_.sdp), e = ft(k.media, ["mid", "msid", "type"]);
|
|
@@ -8448,13 +8448,13 @@ class RoomPeer extends RoomUsers {
|
|
|
8448
8448
|
Z(this, "closeUserTracks", async (u, E = [], _ = !1) => {
|
|
8449
8449
|
const k = [];
|
|
8450
8450
|
for (const $ of E) {
|
|
8451
|
-
const {
|
|
8452
|
-
k.push(N),
|
|
8451
|
+
const { mid: N, trackName: D, msid: q } = $;
|
|
8452
|
+
k.push(D), N && k.push(N), q && k.push(q);
|
|
8453
8453
|
}
|
|
8454
8454
|
const e = ($) => k.includes($), n = this.peerIns.getTransceivers();
|
|
8455
8455
|
for (const $ of n) {
|
|
8456
|
-
const {
|
|
8457
|
-
N
|
|
8456
|
+
const { mid: N } = $;
|
|
8457
|
+
N && e(N) && ($.stop(), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: transceiver: ${N} is stop.`, $));
|
|
8458
8458
|
}
|
|
8459
8459
|
const O = await this.getUser(u);
|
|
8460
8460
|
if (O) {
|
|
@@ -8716,7 +8716,9 @@ class RoomCalls extends RoomPeer {
|
|
|
8716
8716
|
const _ = async () => {
|
|
8717
8717
|
try {
|
|
8718
8718
|
this.taskQueue.setCondition("createTrack", !1);
|
|
8719
|
-
const k = await this.addSenders(u)
|
|
8719
|
+
const k = await this.addSenders(u);
|
|
8720
|
+
await this.replaceSenderStream(u, !1);
|
|
8721
|
+
const e = await this.getSenderTracks(k);
|
|
8720
8722
|
if (e.length === 0)
|
|
8721
8723
|
return this.taskQueue.setCondition("createTrack", !0), E(!0);
|
|
8722
8724
|
await this.cwsIns.sendMessage({
|
|
@@ -8747,20 +8749,17 @@ class RoomCalls extends RoomPeer {
|
|
|
8747
8749
|
typeof u == "string" && (u = [u]);
|
|
8748
8750
|
const { userId: e = "" } = this.options;
|
|
8749
8751
|
for (const O of u)
|
|
8750
|
-
|
|
8751
|
-
this.removeUserMediaStreamContext(e, O);
|
|
8752
|
-
continue;
|
|
8753
|
-
}
|
|
8752
|
+
this.removeUserMediaStreamContext(e, O), this.setLocalStreamActiveMap.set(O, E);
|
|
8754
8753
|
if (E) {
|
|
8755
|
-
if (u.includes("microphoneCamera_audio") && u.includes("microphoneCamera_video")
|
|
8754
|
+
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")) {
|
|
8756
8755
|
const $ = this.getUserStream(e, "screenSharing_audio").getTracks();
|
|
8757
8756
|
for (const N of $)
|
|
8758
|
-
N.onended = () => this.stopPublish(["screenSharing_audio"]);
|
|
8757
|
+
N.onended = () => this.stopPublish(["screenSharing_audio", "screenSharing_video"]);
|
|
8759
8758
|
}
|
|
8760
8759
|
if (u.includes("screenSharing_video")) {
|
|
8761
8760
|
const $ = this.getUserStream(e, "screenSharing_video").getTracks();
|
|
8762
8761
|
for (const N of $)
|
|
8763
|
-
N.onended = () => this.stopPublish(["screenSharing_video"]);
|
|
8762
|
+
N.onended = () => this.stopPublish(["screenSharing_audio", "screenSharing_video"]);
|
|
8764
8763
|
}
|
|
8765
8764
|
}
|
|
8766
8765
|
const n = this.getUserStreams(e);
|
|
@@ -8796,7 +8795,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8796
8795
|
Z(this, "changeScreenSharing", async (u) => {
|
|
8797
8796
|
const E = await this.getCaller(), { tracks: _ = [], callActionMap: k } = E;
|
|
8798
8797
|
try {
|
|
8799
|
-
await this.setLocalStream(u, !0)
|
|
8798
|
+
await this.setLocalStream(u, !0);
|
|
8800
8799
|
for (const e of u)
|
|
8801
8800
|
_.find((O) => O.mediaType === e && k[e]) && await this.replaceSenderStream([e], !0);
|
|
8802
8801
|
} catch (e) {
|
|
@@ -8895,7 +8894,8 @@ class RoomCalls extends RoomPeer {
|
|
|
8895
8894
|
const e = await this.getCaller();
|
|
8896
8895
|
try {
|
|
8897
8896
|
await this.setLocalStream(u, !0);
|
|
8898
|
-
} catch {
|
|
8897
|
+
} catch (q) {
|
|
8898
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setLocalStream is error.", q);
|
|
8899
8899
|
}
|
|
8900
8900
|
const n = [];
|
|
8901
8901
|
for (const q of u)
|
|
@@ -8905,7 +8905,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8905
8905
|
const $ = await this.getSenderTracks(O), N = [...e.tracks, ...$];
|
|
8906
8906
|
await this.updateUsertracks(e.id, N, !0);
|
|
8907
8907
|
const D = await this.getCallAction(N);
|
|
8908
|
-
await J(this, Et).call(this, D),
|
|
8908
|
+
await J(this, Et).call(this, D), n.length !== 0 && await this.inactiveTracks(n, !1), O.length !== 0 && await this.replaceSenderStream(O, !0), J(this, Xt).call(this, u);
|
|
8909
8909
|
{
|
|
8910
8910
|
await this.emitNotifyUpdateUsers();
|
|
8911
8911
|
const q = await this.getCaller();
|
|
@@ -8935,7 +8935,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8935
8935
|
await this.emitNotifyUpdateUsers(), E($);
|
|
8936
8936
|
};
|
|
8937
8937
|
if (n.length === 0) return O();
|
|
8938
|
-
await this.replaceSenderStream(u, !
|
|
8938
|
+
await this.replaceSenderStream(u, !0), await this.closeUserTracks(e.id, n, !0), await this.removeSenders(u);
|
|
8939
8939
|
{
|
|
8940
8940
|
const $ = await this.getCallAction(e.tracks);
|
|
8941
8941
|
await J(this, Et).call(this, $);
|
|
@@ -9065,6 +9065,7 @@ class RoomCalls extends RoomPeer {
|
|
|
9065
9065
|
const k = await this.getCaller();
|
|
9066
9066
|
if (!k) return;
|
|
9067
9067
|
const { tracks: e = [] } = k, n = [...e];
|
|
9068
|
+
await this.replaceSenderStream(u, !0);
|
|
9068
9069
|
for (let $ of n) {
|
|
9069
9070
|
const { mediaType: N } = $;
|
|
9070
9071
|
if (N && u.includes(N)) {
|
|
@@ -9075,7 +9076,7 @@ class RoomCalls extends RoomPeer {
|
|
|
9075
9076
|
}
|
|
9076
9077
|
}
|
|
9077
9078
|
const O = await this.getCallAction(n);
|
|
9078
|
-
await J(this, Et).call(this, O), await this.emitNotifyUpdateUsers(), _(!0);
|
|
9079
|
+
await J(this, Et).call(this, O), E === !1 && await this.replaceSenderStream(u, !1), await this.emitNotifyUpdateUsers(), _(!0);
|
|
9079
9080
|
}));
|
|
9080
9081
|
/**
|
|
9081
9082
|
* 远端调试
|