quickvo-sdk-js 0.5.4 → 0.5.5
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 +162 -153
- package/dist/index.umd.cjs +2 -2
- package/dist/room/RoomBase.d.ts +3 -2
- package/dist/room/RoomCalls.d.ts +6 -0
- package/dist/room/RoomMedias.d.ts +0 -2
- package/dist/room/RoomPeer.d.ts +0 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var ie = Object.defineProperty;
|
|
2
|
+
var te = (a) => {
|
|
3
3
|
throw TypeError(a);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var Z = (a, I, u) =>
|
|
7
|
-
var V = (a, I, u) => (
|
|
5
|
+
var ne = (a, I, u) => I in a ? ie(a, I, { enumerable: !0, configurable: !0, writable: !0, value: u }) : a[I] = u;
|
|
6
|
+
var Z = (a, I, u) => ne(a, typeof I != "symbol" ? I + "" : I, u), ee = (a, I, u) => I.has(a) || te("Cannot " + u);
|
|
7
|
+
var V = (a, I, u) => (ee(a, I, "read from private field"), u ? u.call(a) : I.get(a)), at = (a, I, u) => I.has(a) ? te("Cannot add the same private member more than once") : I instanceof WeakSet ? I.add(a) : I.set(a, u), vt = (a, I, u, E) => (ee(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)
|
|
@@ -6359,7 +6359,7 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
6359
6359
|
const O = n.bits;
|
|
6360
6360
|
let $ = 0, N = 0, D = 0, q = 0, P = 0, j = 0, Q = 0, J = 0, z = 0, Y = 0, et, tt, nt, lt, it, st = null, ct;
|
|
6361
6361
|
const ot = new Uint16Array(MAXBITS + 1), rt = new Uint16Array(MAXBITS + 1);
|
|
6362
|
-
let Ot = null,
|
|
6362
|
+
let Ot = null, Xt, Nt, At;
|
|
6363
6363
|
for ($ = 0; $ <= MAXBITS; $++)
|
|
6364
6364
|
ot[$] = 0;
|
|
6365
6365
|
for (N = 0; N < E; N++)
|
|
@@ -6382,9 +6382,9 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
6382
6382
|
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, Q = 0, nt = -1, z = 1 << P, lt = z - 1, a === LENS$1 && z > ENOUGH_LENS$1 || a === DISTS$1 && z > ENOUGH_DISTS$1)
|
|
6383
6383
|
return 1;
|
|
6384
6384
|
for (; ; ) {
|
|
6385
|
-
|
|
6385
|
+
Xt = $ - Q, e[N] + 1 < ct ? (Nt = 0, At = e[N]) : e[N] >= ct ? (Nt = Ot[e[N] - ct], At = st[e[N] - ct]) : (Nt = 96, At = 0), et = 1 << $ - Q, tt = 1 << j, D = tt;
|
|
6386
6386
|
do
|
|
6387
|
-
tt -= et, _[it + (Y >> Q) + tt] =
|
|
6387
|
+
tt -= et, _[it + (Y >> Q) + tt] = Xt << 24 | Nt << 16 | At | 0;
|
|
6388
6388
|
while (tt !== 0);
|
|
6389
6389
|
for (et = 1 << $ - 1; Y & et; )
|
|
6390
6390
|
et >>= 1;
|
|
@@ -7154,7 +7154,7 @@ const noLogEvents = ["heartbeat", "onNetQuality", "networkQualityChange"], compr
|
|
|
7154
7154
|
}
|
|
7155
7155
|
return a;
|
|
7156
7156
|
};
|
|
7157
|
-
var kt, ut,
|
|
7157
|
+
var kt, ut, Rt, dt, yt, qt, Dt, Ct, Ut, Et, Mt, Pt, Bt;
|
|
7158
7158
|
class CallsWebSocket {
|
|
7159
7159
|
// 状态
|
|
7160
7160
|
constructor(I) {
|
|
@@ -7168,7 +7168,7 @@ class CallsWebSocket {
|
|
|
7168
7168
|
// 最大重连次数
|
|
7169
7169
|
timeout: 30 * 1e3
|
|
7170
7170
|
});
|
|
7171
|
-
at(this,
|
|
7171
|
+
at(this, Rt, "");
|
|
7172
7172
|
// 缓存登录凭证
|
|
7173
7173
|
at(this, dt, {});
|
|
7174
7174
|
at(this, yt, {});
|
|
@@ -7183,26 +7183,26 @@ class CallsWebSocket {
|
|
|
7183
7183
|
Z(this, "onReconnectStop", (I) => {
|
|
7184
7184
|
});
|
|
7185
7185
|
// 是否需要重连
|
|
7186
|
-
at(this,
|
|
7186
|
+
at(this, qt, (I) => {
|
|
7187
7187
|
let u = !0;
|
|
7188
7188
|
const { code: E = 1e3, reason: _ = "" } = I;
|
|
7189
7189
|
return E === 1e3 && (_ === "quit success!" || _ === "replace old connection!") && (u = !1), u;
|
|
7190
7190
|
});
|
|
7191
7191
|
// 重连成功
|
|
7192
|
-
at(this,
|
|
7192
|
+
at(this, Dt, async (I) => {
|
|
7193
7193
|
V(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
7194
|
});
|
|
7195
7195
|
// 重连停止
|
|
7196
|
-
at(this,
|
|
7196
|
+
at(this, Ct, async (I) => {
|
|
7197
7197
|
V(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
7198
|
});
|
|
7199
7199
|
// 自定义心跳规则
|
|
7200
|
-
at(this,
|
|
7200
|
+
at(this, Ut, () => {
|
|
7201
7201
|
const I = { event: "heartbeat", sn: +`${F(1e5, 999999)}` };
|
|
7202
7202
|
return com.quick.voice.proto.CommonReq.encode(I).finish();
|
|
7203
7203
|
});
|
|
7204
7204
|
// 更新日志
|
|
7205
|
-
at(this,
|
|
7205
|
+
at(this, Et, (I, u = {}) => {
|
|
7206
7206
|
try {
|
|
7207
7207
|
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
7208
|
let N = {};
|
|
@@ -7230,7 +7230,7 @@ class CallsWebSocket {
|
|
|
7230
7230
|
}
|
|
7231
7231
|
});
|
|
7232
7232
|
// 创建事件
|
|
7233
|
-
at(this,
|
|
7233
|
+
at(this, Mt, (I, { resolve: u, reject: E }) => {
|
|
7234
7234
|
const { sn: _ } = I, k = () => {
|
|
7235
7235
|
const n = V(this, dt)[_];
|
|
7236
7236
|
clearTimeout(n.destructionTimer), delete V(this, dt)[_];
|
|
@@ -7241,13 +7241,13 @@ class CallsWebSocket {
|
|
|
7241
7241
|
V(this, dt)[_] = { message: I, resolve: u, reject: E, destruction: k, destructionTimer: e };
|
|
7242
7242
|
});
|
|
7243
7243
|
// 获取事件
|
|
7244
|
-
at(this,
|
|
7244
|
+
at(this, Pt, (I) => V(this, dt)[I]);
|
|
7245
7245
|
// 接收消息
|
|
7246
|
-
at(this,
|
|
7246
|
+
at(this, Bt, async (I) => {
|
|
7247
7247
|
const u = new Uint8Array(I), E = com.quick.voice.proto.CommonRsp.decode(u), { sn: _, event: k } = E, e = onMessageFormat(E);
|
|
7248
|
-
if (V(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) || V(this,
|
|
7248
|
+
if (V(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) || V(this, Et).call(this, "res", e)), notifyName_keys.includes(k))
|
|
7249
7249
|
return this.emitNotify(k, L(e, ["code", "data", "desc"]));
|
|
7250
|
-
const O = V(this,
|
|
7250
|
+
const O = V(this, Pt).call(this, _);
|
|
7251
7251
|
if (O) {
|
|
7252
7252
|
const { resolve: $ = (D) => {
|
|
7253
7253
|
}, destruction: N = () => {
|
|
@@ -7271,17 +7271,17 @@ class CallsWebSocket {
|
|
|
7271
7271
|
* @returns
|
|
7272
7272
|
*/
|
|
7273
7273
|
Z(this, "connect", async (I = "") => new Promise(async (u) => {
|
|
7274
|
-
I &&
|
|
7275
|
-
const E = `${V(this, ut).url}?s=${V(this,
|
|
7276
|
-
|
|
7274
|
+
I && vt(this, Rt, I), V(this, kt) && (await V(this, kt).close(), this.state = "closed");
|
|
7275
|
+
const E = `${V(this, ut).url}?s=${V(this, Rt)}&t=${Date.now()}`;
|
|
7276
|
+
vt(this, kt, new M({
|
|
7277
7277
|
...V(this, ut),
|
|
7278
7278
|
url: E,
|
|
7279
7279
|
binaryType: "arraybuffer",
|
|
7280
|
-
onMessage: V(this,
|
|
7281
|
-
checkReconnect: V(this,
|
|
7282
|
-
getHeartbeatMsg: V(this,
|
|
7283
|
-
onReconnectSuccess: V(this,
|
|
7284
|
-
onReconnectStop: V(this,
|
|
7280
|
+
onMessage: V(this, Bt),
|
|
7281
|
+
checkReconnect: V(this, qt),
|
|
7282
|
+
getHeartbeatMsg: V(this, Ut),
|
|
7283
|
+
onReconnectSuccess: V(this, Dt),
|
|
7284
|
+
onReconnectStop: V(this, Ct)
|
|
7285
7285
|
})), this.state = "connecting", await V(this, kt).connect(), this.state = "connected", V(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", V(this, yt)), u(V(this, kt));
|
|
7286
7286
|
}));
|
|
7287
7287
|
/**
|
|
@@ -7295,7 +7295,7 @@ class CallsWebSocket {
|
|
|
7295
7295
|
const { destructionTimer: _ } = V(this, dt)[E];
|
|
7296
7296
|
clearTimeout(_);
|
|
7297
7297
|
}
|
|
7298
|
-
|
|
7298
|
+
vt(this, dt, {}), await ((u = V(this, kt)) == null ? void 0 : u.close()), vt(this, kt, void 0), this.state = "closed";
|
|
7299
7299
|
});
|
|
7300
7300
|
/**
|
|
7301
7301
|
* 发送消息
|
|
@@ -7313,7 +7313,7 @@ class CallsWebSocket {
|
|
|
7313
7313
|
compress: !1,
|
|
7314
7314
|
...e
|
|
7315
7315
|
});
|
|
7316
|
-
V(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) || V(this,
|
|
7316
|
+
V(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) || V(this, Et).call(this, "req", O)), u && V(this, Mt).call(this, O, { resolve: E, reject: _ });
|
|
7317
7317
|
const $ = com.quick.voice.proto.CommonReq.encode(O).finish();
|
|
7318
7318
|
(N = V(this, kt)) == null || N.sendMessage($);
|
|
7319
7319
|
}));
|
|
@@ -7347,7 +7347,7 @@ class CallsWebSocket {
|
|
|
7347
7347
|
*/
|
|
7348
7348
|
Z(this, "removeNotify", (I = []) => {
|
|
7349
7349
|
if (I.length === 0)
|
|
7350
|
-
|
|
7350
|
+
vt(this, yt, {});
|
|
7351
7351
|
else {
|
|
7352
7352
|
const u = Object.keys(V(this, yt));
|
|
7353
7353
|
for (const E of u)
|
|
@@ -7355,10 +7355,10 @@ class CallsWebSocket {
|
|
|
7355
7355
|
}
|
|
7356
7356
|
V(this, ut).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", V(this, yt));
|
|
7357
7357
|
});
|
|
7358
|
-
|
|
7358
|
+
vt(this, ut, { ...V(this, ut), ...I });
|
|
7359
7359
|
}
|
|
7360
7360
|
}
|
|
7361
|
-
kt = new WeakMap(), ut = new WeakMap(),
|
|
7361
|
+
kt = new WeakMap(), ut = new WeakMap(), Rt = new WeakMap(), dt = new WeakMap(), yt = new WeakMap(), qt = new WeakMap(), Dt = new WeakMap(), Ct = new WeakMap(), Ut = new WeakMap(), Et = new WeakMap(), Mt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap();
|
|
7362
7362
|
var y = Object.defineProperty, x = (a) => {
|
|
7363
7363
|
throw TypeError(a);
|
|
7364
7364
|
}, 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,6 +7414,7 @@ class K {
|
|
|
7414
7414
|
}
|
|
7415
7415
|
}
|
|
7416
7416
|
d = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
|
|
7417
|
+
var Lt;
|
|
7417
7418
|
class RoomBase {
|
|
7418
7419
|
constructor() {
|
|
7419
7420
|
Z(this, "options", {
|
|
@@ -7425,7 +7426,6 @@ class RoomBase {
|
|
|
7425
7426
|
debug: !1,
|
|
7426
7427
|
newPublishAutoSubscribe: !0
|
|
7427
7428
|
});
|
|
7428
|
-
Z(this, "localStreamActiveMap", /* @__PURE__ */ new Map());
|
|
7429
7429
|
Z(this, "prohibitNotify", !1);
|
|
7430
7430
|
// 是否禁止通知
|
|
7431
7431
|
Z(this, "isEarly", !1);
|
|
@@ -7440,8 +7440,11 @@ class RoomBase {
|
|
|
7440
7440
|
// SDK通讯实例 // SDK通讯实例
|
|
7441
7441
|
Z(this, "peerIns", new RTCPeerConnection({ bundlePolicy: "max-bundle" }));
|
|
7442
7442
|
Z(this, "transceiverMap", /* @__PURE__ */ new Map());
|
|
7443
|
+
// 本地发射器
|
|
7443
7444
|
Z(this, "userMap", /* @__PURE__ */ new Map());
|
|
7444
7445
|
// 用户
|
|
7446
|
+
Z(this, "setLocalStreamActiveMap", /* @__PURE__ */ new Map());
|
|
7447
|
+
// 本地数据是否已开启调用
|
|
7445
7448
|
// 设备错误信息
|
|
7446
7449
|
Z(this, "mediaDevicesErrInfo", {
|
|
7447
7450
|
microphoneCamera_audio: "",
|
|
@@ -7449,8 +7452,8 @@ class RoomBase {
|
|
|
7449
7452
|
screenSharing_video: "",
|
|
7450
7453
|
screenSharing_audio: ""
|
|
7451
7454
|
});
|
|
7452
|
-
|
|
7453
|
-
this.taskQueue.
|
|
7455
|
+
at(this, Lt, () => {
|
|
7456
|
+
this.taskQueue.setCondition("createWs", !0), this.taskQueue.setCondition("createSession", !1), this.taskQueue.setCondition("ice", !1);
|
|
7454
7457
|
});
|
|
7455
7458
|
/**
|
|
7456
7459
|
* 获取房间信息
|
|
@@ -7548,70 +7551,32 @@ class RoomBase {
|
|
|
7548
7551
|
* 处理为应用层数据
|
|
7549
7552
|
*/
|
|
7550
7553
|
Z(this, "usersFilter", (I) => ft(I, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "permissions", "isPublished", "updateStreams"]).sort((_, k) => _.id.localeCompare(k.id, "en")));
|
|
7551
|
-
|
|
7554
|
+
V(this, Lt).call(this);
|
|
7552
7555
|
}
|
|
7553
7556
|
}
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
I.type = "sine", I.frequency.setValueAtTime(0, a.currentTime);
|
|
7557
|
-
const u = a.createGain();
|
|
7558
|
-
u.gain.value = 0, I.connect(u), u.connect(a.destination), I.start();
|
|
7559
|
-
const E = a.createMediaStreamDestination();
|
|
7560
|
-
return u.disconnect(), I.connect(E), E.stream;
|
|
7561
|
-
}, createFakeVideoStream = (a = 10, I = 10, u = 30) => {
|
|
7562
|
-
const E = document.createElement("canvas"), _ = E.getContext("2d");
|
|
7563
|
-
E.width = a, E.height = I;
|
|
7564
|
-
let k = 0;
|
|
7565
|
-
return setInterval(() => {
|
|
7566
|
-
_.clearRect(0, 0, E.width, E.height);
|
|
7567
|
-
const O = _.createLinearGradient(0, 0, E.width, E.height);
|
|
7568
|
-
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;
|
|
7569
|
-
}, 100), E.captureStream(u);
|
|
7570
|
-
};
|
|
7571
|
-
var bt, vt, _t, St, Pt, Bt, Lt, $t, jt;
|
|
7557
|
+
Lt = new WeakMap();
|
|
7558
|
+
var $t, bt, wt, _t, jt, Zt, Tt, Ft;
|
|
7572
7559
|
class RoomMedias extends RoomBase {
|
|
7573
|
-
//
|
|
7560
|
+
// 媒体流上下文
|
|
7574
7561
|
constructor() {
|
|
7575
7562
|
super();
|
|
7576
|
-
|
|
7563
|
+
at(this, $t, []);
|
|
7577
7564
|
// 可用媒体设备列表
|
|
7578
7565
|
at(this, bt, /* @__PURE__ */ new Map());
|
|
7579
7566
|
// 媒体流设备管理
|
|
7580
|
-
at(this,
|
|
7567
|
+
at(this, wt, /* @__PURE__ */ new Map());
|
|
7581
7568
|
// 媒体轨道参数管理
|
|
7582
7569
|
at(this, _t, /* @__PURE__ */ new Map());
|
|
7583
|
-
// 媒体流上下文
|
|
7584
|
-
at(this, St, /* @__PURE__ */ new Map());
|
|
7585
|
-
// 初始化假数据流
|
|
7586
|
-
at(this, Pt, () => {
|
|
7587
|
-
for (const u of mediaType_keys)
|
|
7588
|
-
switch (u) {
|
|
7589
|
-
case "microphoneCamera_audio":
|
|
7590
|
-
V(this, St).set("microphoneCamera_audio", createMutedAudioStream());
|
|
7591
|
-
break;
|
|
7592
|
-
case "microphoneCamera_video":
|
|
7593
|
-
V(this, St).set("microphoneCamera_video", createFakeVideoStream());
|
|
7594
|
-
break;
|
|
7595
|
-
case "screenSharing_audio":
|
|
7596
|
-
V(this, St).set("screenSharing_audio", createMutedAudioStream());
|
|
7597
|
-
break;
|
|
7598
|
-
case "screenSharing_video":
|
|
7599
|
-
V(this, St).set("screenSharing_video", createFakeVideoStream());
|
|
7600
|
-
break;
|
|
7601
|
-
}
|
|
7602
|
-
});
|
|
7603
|
-
// 获取假数据流
|
|
7604
|
-
Z(this, "getPhoneyStreams", (u) => V(this, St).get(u));
|
|
7605
7570
|
/**
|
|
7606
7571
|
* 初始化媒体参数
|
|
7607
7572
|
*/
|
|
7608
|
-
at(this,
|
|
7609
|
-
V(this,
|
|
7573
|
+
at(this, jt, () => {
|
|
7574
|
+
V(this, wt).set("microphoneCamera_audio", {}), V(this, wt).set("microphoneCamera_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), V(this, wt).set("screenSharing_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), V(this, wt).set("screenSharing_audio", {});
|
|
7610
7575
|
});
|
|
7611
7576
|
/**
|
|
7612
7577
|
* 初始化媒体设备类型
|
|
7613
7578
|
*/
|
|
7614
|
-
at(this,
|
|
7579
|
+
at(this, Zt, () => {
|
|
7615
7580
|
V(this, bt).set("audioinput", "default"), V(this, bt).set("videoinput", "default"), V(this, bt).set("audiooutput", "default");
|
|
7616
7581
|
});
|
|
7617
7582
|
/**
|
|
@@ -7714,13 +7679,13 @@ class RoomMedias extends RoomBase {
|
|
|
7714
7679
|
const u = V(this, _t).values();
|
|
7715
7680
|
for (const E of u)
|
|
7716
7681
|
E.stop();
|
|
7717
|
-
|
|
7682
|
+
vt(this, _t, /* @__PURE__ */ new Map());
|
|
7718
7683
|
});
|
|
7719
7684
|
/**
|
|
7720
7685
|
* 设置轨道媒体参数
|
|
7721
7686
|
*/
|
|
7722
7687
|
Z(this, "setMediaTrackConstraints", async (u, E) => {
|
|
7723
|
-
V(this,
|
|
7688
|
+
V(this, wt).set(u, E);
|
|
7724
7689
|
const k = this.getUserStream(this.options.userId, u).getTracks();
|
|
7725
7690
|
if (k.length !== 0)
|
|
7726
7691
|
for (const e of k) {
|
|
@@ -7732,7 +7697,7 @@ class RoomMedias extends RoomBase {
|
|
|
7732
7697
|
* 初始化本地流
|
|
7733
7698
|
*/
|
|
7734
7699
|
Z(this, "initLocalStream", async (u) => {
|
|
7735
|
-
const { userId: E } = this.options, _ = V(this,
|
|
7700
|
+
const { userId: E } = this.options, _ = V(this, wt).get(u);
|
|
7736
7701
|
switch (this.removeUserMediaStreamContext(E, u), u) {
|
|
7737
7702
|
// 麦克风
|
|
7738
7703
|
case "microphoneCamera_audio":
|
|
@@ -7774,18 +7739,18 @@ class RoomMedias extends RoomBase {
|
|
|
7774
7739
|
/**
|
|
7775
7740
|
* 获取媒体设备列表
|
|
7776
7741
|
*/
|
|
7777
|
-
at(this,
|
|
7778
|
-
this
|
|
7742
|
+
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) => {
|
|
7743
|
+
vt(this, $t, u);
|
|
7779
7744
|
}).catch(function(u) {
|
|
7780
7745
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", u);
|
|
7781
|
-
}), this
|
|
7746
|
+
}), V(this, $t)));
|
|
7782
7747
|
/**
|
|
7783
7748
|
* 媒体设备发生变化
|
|
7784
7749
|
*/
|
|
7785
|
-
at(this,
|
|
7750
|
+
at(this, Ft, () => {
|
|
7786
7751
|
navigator.mediaDevices && (navigator.mediaDevices.ondevicechange = async () => {
|
|
7787
|
-
await V(this,
|
|
7788
|
-
}), V(this,
|
|
7752
|
+
await V(this, Tt).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
|
|
7753
|
+
}), V(this, Tt).call(this);
|
|
7789
7754
|
});
|
|
7790
7755
|
/**
|
|
7791
7756
|
* 获取正在使用的媒体设备ID
|
|
@@ -7816,7 +7781,7 @@ class RoomMedias extends RoomBase {
|
|
|
7816
7781
|
* @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
|
|
7817
7782
|
* @returns MediaDeviceInfo[]
|
|
7818
7783
|
*/
|
|
7819
|
-
Z(this, "getEnumerateDevices", async (u) => (await V(this,
|
|
7784
|
+
Z(this, "getEnumerateDevices", async (u) => (await V(this, Tt).call(this), V(this, $t).filter((_) => _.kind === u)));
|
|
7820
7785
|
/**
|
|
7821
7786
|
* 获取可用音频输入设备
|
|
7822
7787
|
* @returns MediaDeviceInfo[]
|
|
@@ -7832,10 +7797,10 @@ class RoomMedias extends RoomBase {
|
|
|
7832
7797
|
* @returns MediaDeviceInfo[]
|
|
7833
7798
|
*/
|
|
7834
7799
|
Z(this, "getEnumerateVideoinputDevices", () => this.getEnumerateDevices("videoinput"));
|
|
7835
|
-
V(this,
|
|
7800
|
+
V(this, Ft).call(this), V(this, Zt).call(this), V(this, jt).call(this);
|
|
7836
7801
|
}
|
|
7837
7802
|
}
|
|
7838
|
-
|
|
7803
|
+
$t = new WeakMap(), bt = new WeakMap(), wt = new WeakMap(), _t = new WeakMap(), jt = new WeakMap(), Zt = new WeakMap(), Tt = new WeakMap(), Ft = new WeakMap();
|
|
7839
7804
|
class RoomUsers extends RoomMedias {
|
|
7840
7805
|
constructor() {
|
|
7841
7806
|
super();
|
|
@@ -8122,10 +8087,29 @@ class RoomUsers extends RoomMedias {
|
|
|
8122
8087
|
});
|
|
8123
8088
|
}
|
|
8124
8089
|
}
|
|
8125
|
-
|
|
8090
|
+
const createMutedAudioStream = () => {
|
|
8091
|
+
const a = new AudioContext(), I = a.createOscillator();
|
|
8092
|
+
I.type = "sine", I.frequency.setValueAtTime(0, a.currentTime);
|
|
8093
|
+
const u = a.createGain();
|
|
8094
|
+
u.gain.value = 0, I.connect(u), u.connect(a.destination), I.start();
|
|
8095
|
+
const E = a.createMediaStreamDestination();
|
|
8096
|
+
return u.disconnect(), I.connect(E), E.stream;
|
|
8097
|
+
}, createFakeVideoStream = (a = 10, I = 10, u = 30) => {
|
|
8098
|
+
const E = document.createElement("canvas"), _ = E.getContext("2d");
|
|
8099
|
+
E.width = a, E.height = I;
|
|
8100
|
+
let k = 0;
|
|
8101
|
+
return setInterval(() => {
|
|
8102
|
+
_.clearRect(0, 0, E.width, E.height);
|
|
8103
|
+
const O = _.createLinearGradient(0, 0, E.width, E.height);
|
|
8104
|
+
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;
|
|
8105
|
+
}, 100), E.captureStream(u);
|
|
8106
|
+
};
|
|
8107
|
+
var St, Ht, xt, zt, Jt, Wt;
|
|
8126
8108
|
class RoomPeer extends RoomUsers {
|
|
8127
8109
|
constructor() {
|
|
8128
8110
|
super();
|
|
8111
|
+
at(this, St, /* @__PURE__ */ new Map());
|
|
8112
|
+
// 假媒体流 (创建轨道用)
|
|
8129
8113
|
Z(this, "getPeerStatsTimer", 0);
|
|
8130
8114
|
// 获取报告的定时器
|
|
8131
8115
|
Z(this, "reports", []);
|
|
@@ -8142,22 +8126,29 @@ class RoomPeer extends RoomUsers {
|
|
|
8142
8126
|
jitter: "0"
|
|
8143
8127
|
// 网络抖动
|
|
8144
8128
|
});
|
|
8145
|
-
Z(this, "connectedResolveMap", /* @__PURE__ */ new Map());
|
|
8146
8129
|
Z(this, "initPeer", () => {
|
|
8147
|
-
this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), V(this,
|
|
8130
|
+
this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.transceiverMap = /* @__PURE__ */ new Map(), V(this, zt).call(this), V(this, Wt).call(this);
|
|
8148
8131
|
});
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8132
|
+
// 初始化假数据流
|
|
8133
|
+
at(this, Ht, () => {
|
|
8134
|
+
for (const u of mediaType_keys)
|
|
8135
|
+
switch (u) {
|
|
8136
|
+
case "microphoneCamera_audio":
|
|
8137
|
+
V(this, St).set("microphoneCamera_audio", createMutedAudioStream());
|
|
8138
|
+
break;
|
|
8139
|
+
case "microphoneCamera_video":
|
|
8140
|
+
V(this, St).set("microphoneCamera_video", createFakeVideoStream());
|
|
8141
|
+
break;
|
|
8142
|
+
case "screenSharing_audio":
|
|
8143
|
+
V(this, St).set("screenSharing_audio", createMutedAudioStream());
|
|
8144
|
+
break;
|
|
8145
|
+
case "screenSharing_video":
|
|
8146
|
+
V(this, St).set("screenSharing_video", createFakeVideoStream());
|
|
8147
|
+
break;
|
|
8148
|
+
}
|
|
8160
8149
|
});
|
|
8150
|
+
// 获取假数据流
|
|
8151
|
+
at(this, xt, (u) => V(this, St).get(u));
|
|
8161
8152
|
/**
|
|
8162
8153
|
* 替换发射器媒体流
|
|
8163
8154
|
*/
|
|
@@ -8169,7 +8160,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8169
8160
|
let n;
|
|
8170
8161
|
if (e) {
|
|
8171
8162
|
const { sender: O } = e;
|
|
8172
|
-
E ? n = this.getUserStream(_, k) : n = this.
|
|
8163
|
+
E ? n = this.getUserStream(_, k) : n = V(this, xt).call(this, k);
|
|
8173
8164
|
const [$] = n.getTracks();
|
|
8174
8165
|
O.replaceTrack($);
|
|
8175
8166
|
}
|
|
@@ -8198,14 +8189,14 @@ class RoomPeer extends RoomUsers {
|
|
|
8198
8189
|
const E = [];
|
|
8199
8190
|
for (const _ of u) {
|
|
8200
8191
|
if (this.transceiverMap.has(_)) continue;
|
|
8201
|
-
const k = this.
|
|
8192
|
+
const k = V(this, xt).call(this, _), [e] = k.getTracks(), n = this.peerIns.addTransceiver(e, { direction: "sendonly" });
|
|
8202
8193
|
this.transceiverMap.set(_, n), E.push(_);
|
|
8203
8194
|
}
|
|
8204
8195
|
if (u.length === 0 || E.length) {
|
|
8205
8196
|
const _ = await this.peerIns.createOffer();
|
|
8206
8197
|
if (this.options.debug) {
|
|
8207
8198
|
const k = libExports.parse(_.sdp), e = ft(k.media, ["mid", "msid", "type"]);
|
|
8208
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->
|
|
8199
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->quickvo: setLocalDescription", { msidArr: e, sdpJson: k, description: _ });
|
|
8209
8200
|
}
|
|
8210
8201
|
await this.peerIns.setLocalDescription(_);
|
|
8211
8202
|
}
|
|
@@ -8225,7 +8216,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8225
8216
|
const u = await this.getAllUserTrackMids(), E = this.peerIns.getTransceivers();
|
|
8226
8217
|
for (const _ of E) {
|
|
8227
8218
|
const { mid: k } = _;
|
|
8228
|
-
Number(k) === 0 || u.includes(k) || (_.stop(), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->
|
|
8219
|
+
Number(k) === 0 || u.includes(k) || (_.stop(), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: clearTransceivers: ${k} is stop.`, _));
|
|
8229
8220
|
}
|
|
8230
8221
|
});
|
|
8231
8222
|
/**
|
|
@@ -8273,7 +8264,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8273
8264
|
const nt = { ...Y, mid: P, msid: J };
|
|
8274
8265
|
e.push(nt);
|
|
8275
8266
|
}
|
|
8276
|
-
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->
|
|
8267
|
+
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->quickvo: await subscribe ${e.length}/${k.length}`, { mediaType: tt, mid: P, userTrack: Y, e: $ }), k.length === e.length && n();
|
|
8277
8268
|
}
|
|
8278
8269
|
};
|
|
8279
8270
|
this.peerIns.addEventListener("track", O), E = setTimeout(() => n(), 5 * 1e3);
|
|
@@ -8283,7 +8274,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8283
8274
|
/**
|
|
8284
8275
|
* 监听webrtc ice通讯连接
|
|
8285
8276
|
*/
|
|
8286
|
-
at(this,
|
|
8277
|
+
at(this, zt, () => {
|
|
8287
8278
|
let u = 0;
|
|
8288
8279
|
const E = () => {
|
|
8289
8280
|
this.setRoomState("closed");
|
|
@@ -8335,14 +8326,14 @@ class RoomPeer extends RoomUsers {
|
|
|
8335
8326
|
const O = this.peerIns.getTransceivers();
|
|
8336
8327
|
for (const $ of O) {
|
|
8337
8328
|
const { sender: N, receiver: D } = $;
|
|
8338
|
-
N.track && e(N.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->
|
|
8329
|
+
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.`, $), N.track.enabled = !1, N.track.stop(), this.peerIns.removeTrack(N), $.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.`, $), D.track.enabled = !1, D.track.stop(), $.stop());
|
|
8339
8330
|
}
|
|
8340
8331
|
});
|
|
8341
8332
|
Z(this, "createOffer", async () => {
|
|
8342
8333
|
const u = await this.peerIns.createOffer();
|
|
8343
8334
|
if (this.options.debug) {
|
|
8344
8335
|
const E = libExports.parse(u.sdp), _ = ft(E.media, ["mid", "msid", "type"]);
|
|
8345
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->
|
|
8336
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->quickvo: createOffer", { msidArr: _, sdpJson: E, description: u });
|
|
8346
8337
|
}
|
|
8347
8338
|
await this.peerIns.setLocalDescription(u);
|
|
8348
8339
|
});
|
|
@@ -8350,7 +8341,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8350
8341
|
const u = await this.peerIns.createAnswer();
|
|
8351
8342
|
if (this.options.debug) {
|
|
8352
8343
|
const E = libExports.parse(u.sdp), _ = ft(E.media, ["mid", "msid", "type"]);
|
|
8353
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->
|
|
8344
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->quickvo: createAnswer", { msidArr: _, sdpJson: E, description: u });
|
|
8354
8345
|
}
|
|
8355
8346
|
await this.peerIns.setLocalDescription(u);
|
|
8356
8347
|
});
|
|
@@ -8367,7 +8358,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8367
8358
|
Z(this, "setRemoteDescription", async (u) => {
|
|
8368
8359
|
if (this.options.debug) {
|
|
8369
8360
|
const E = libExports.parse(u.sdp), _ = ft(E.media, ["mid", "msid", "type"]);
|
|
8370
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->
|
|
8361
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->quickvo: setRemoteDescription", { msidArr: _, sdpJson: E, description: u });
|
|
8371
8362
|
}
|
|
8372
8363
|
return await this.peerIns.setRemoteDescription(u), u;
|
|
8373
8364
|
});
|
|
@@ -8432,7 +8423,7 @@ class RoomPeer extends RoomUsers {
|
|
|
8432
8423
|
/**
|
|
8433
8424
|
* 计算网络质量
|
|
8434
8425
|
*/
|
|
8435
|
-
at(this,
|
|
8426
|
+
at(this, Jt, async () => {
|
|
8436
8427
|
try {
|
|
8437
8428
|
const u = await this.peerIns.getStats(), E = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"], k = [...u.values()].filter((nt) => E.includes(nt.type));
|
|
8438
8429
|
let e = 0, n = 0, O = 0, $ = 0, N = 0, D = 0, q = [], P = [];
|
|
@@ -8462,15 +8453,15 @@ class RoomPeer extends RoomUsers {
|
|
|
8462
8453
|
}
|
|
8463
8454
|
}
|
|
8464
8455
|
} catch (u) {
|
|
8465
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->
|
|
8456
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setNetQuality is err.", u);
|
|
8466
8457
|
}
|
|
8467
8458
|
});
|
|
8468
8459
|
/**
|
|
8469
8460
|
* 获取连接的所有轨道分析数据
|
|
8470
8461
|
*/
|
|
8471
|
-
at(this,
|
|
8462
|
+
at(this, Wt, () => {
|
|
8472
8463
|
const u = async () => {
|
|
8473
|
-
this.peerIns.connectionState !== "connected" || !this.options.roomId || V(this,
|
|
8464
|
+
this.peerIns.connectionState !== "connected" || !this.options.roomId || V(this, Jt).call(this);
|
|
8474
8465
|
};
|
|
8475
8466
|
this.getPeerStatsTimer = setInterval(u, 1 * 1e3);
|
|
8476
8467
|
});
|
|
@@ -8478,10 +8469,11 @@ class RoomPeer extends RoomUsers {
|
|
|
8478
8469
|
* 停止网络报告分析
|
|
8479
8470
|
*/
|
|
8480
8471
|
Z(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
|
|
8472
|
+
V(this, Ht).call(this);
|
|
8481
8473
|
}
|
|
8482
8474
|
}
|
|
8483
|
-
|
|
8484
|
-
var
|
|
8475
|
+
St = new WeakMap(), Ht = new WeakMap(), xt = new WeakMap(), zt = new WeakMap(), Jt = new WeakMap(), Wt = new WeakMap();
|
|
8476
|
+
var Kt, It;
|
|
8485
8477
|
class RoomCalls extends RoomPeer {
|
|
8486
8478
|
constructor() {
|
|
8487
8479
|
super();
|
|
@@ -8496,8 +8488,9 @@ class RoomCalls extends RoomPeer {
|
|
|
8496
8488
|
*/
|
|
8497
8489
|
Z(this, "setLocalStream", (u, E) => new Promise(async (_, k) => {
|
|
8498
8490
|
try {
|
|
8491
|
+
this.setLocalStreamActiveMap.set(u, E);
|
|
8499
8492
|
const { userId: e } = this.options;
|
|
8500
|
-
if (E ?
|
|
8493
|
+
if (E ? await this.initLocalStream(u) : this.removeUserMediaStreamContext(e, u), u === "screenSharing_audio" || u === "screenSharing_video") {
|
|
8501
8494
|
{
|
|
8502
8495
|
const $ = this.getUserStream(e, "screenSharing_audio").getTracks();
|
|
8503
8496
|
for (const N of $)
|
|
@@ -8515,6 +8508,25 @@ class RoomCalls extends RoomPeer {
|
|
|
8515
8508
|
k(e);
|
|
8516
8509
|
}
|
|
8517
8510
|
}));
|
|
8511
|
+
/**
|
|
8512
|
+
* 设置正在使用的媒体设备
|
|
8513
|
+
* @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
|
|
8514
|
+
* @param deviceId 设备ID
|
|
8515
|
+
*/
|
|
8516
|
+
Z(this, "setMediaDeviceKind", async (u, E) => {
|
|
8517
|
+
await this.setDeviceKind(u, E);
|
|
8518
|
+
const _ = await this.getCaller(), { tracks: k = [], callActionMap: e } = _, n = async (O) => {
|
|
8519
|
+
if (this.setLocalStreamActiveMap.get(O)) {
|
|
8520
|
+
try {
|
|
8521
|
+
await this.initLocalStream(O);
|
|
8522
|
+
} catch (N) {
|
|
8523
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: initLocalStream is error.", N), await this.inactiveTracks([O], !1);
|
|
8524
|
+
}
|
|
8525
|
+
k.find((N) => N.mediaType === O && e[O]) && await this.replaceSenderStream([O], !0);
|
|
8526
|
+
}
|
|
8527
|
+
};
|
|
8528
|
+
u === "audioinput" && await n("microphoneCamera_audio"), u === "videoinput" && await n("microphoneCamera_video");
|
|
8529
|
+
});
|
|
8518
8530
|
/**
|
|
8519
8531
|
* 添加广播事件
|
|
8520
8532
|
* @param notify Notify
|
|
@@ -8525,7 +8537,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8525
8537
|
* 广播给房间其他人
|
|
8526
8538
|
* 只有当自己建立了发射轨道 并且 加入房间后才进行广播
|
|
8527
8539
|
*/
|
|
8528
|
-
at(this,
|
|
8540
|
+
at(this, Kt, async (u) => {
|
|
8529
8541
|
const { roomId: E } = this.options;
|
|
8530
8542
|
if (!E) return;
|
|
8531
8543
|
const { id: _, tracks: k = [] } = await this.getCaller();
|
|
@@ -8574,7 +8586,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8574
8586
|
Z(this, "quitRoom", () => new Promise(async (u) => {
|
|
8575
8587
|
const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
|
|
8576
8588
|
try {
|
|
8577
|
-
this.stopSubscribe(), this.stopGetPeerStats(), this.
|
|
8589
|
+
this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), this.setRoomState("ready");
|
|
8578
8590
|
} catch {
|
|
8579
8591
|
}
|
|
8580
8592
|
await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoom", data: k }), u(!0);
|
|
@@ -8587,7 +8599,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8587
8599
|
Z(this, "quitRoomEx", () => new Promise(async (u) => {
|
|
8588
8600
|
const { roomId: E, userId: _ } = this.options, k = { roomId: E, user: { id: _ } };
|
|
8589
8601
|
try {
|
|
8590
|
-
this.stopSubscribe(), this.stopGetPeerStats(), this.
|
|
8602
|
+
this.stopSubscribe(), this.stopGetPeerStats(), this.clearUsers(), this.clearUserStreams(), await this.replaceSenderStream([], !1);
|
|
8591
8603
|
} catch {
|
|
8592
8604
|
}
|
|
8593
8605
|
await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.sendMessage({ event: "quitRoomEx", data: k }), u(!0);
|
|
@@ -8620,28 +8632,25 @@ class RoomCalls extends RoomPeer {
|
|
|
8620
8632
|
Z(this, "publish", (u) => new Promise(async (E, _) => {
|
|
8621
8633
|
const k = async () => {
|
|
8622
8634
|
try {
|
|
8623
|
-
u.includes("screenSharing_audio") && !u.includes("screenSharing_video") && (u = [...u, "screenSharing_video"]);
|
|
8624
|
-
const e = await this.getCaller();
|
|
8635
|
+
u.includes("screenSharing_audio") && !u.includes("screenSharing_video") && (u = [...u, "screenSharing_video"]), await this.replaceSenderStream(u, !1), await this.createTrack(u);
|
|
8636
|
+
const e = await this.getCaller(), n = [];
|
|
8625
8637
|
for (const D of u)
|
|
8626
8638
|
if (this.getUserStream(e.id, D).getTracks().length === 0)
|
|
8627
8639
|
try {
|
|
8628
8640
|
await this.setLocalStream(D, !0);
|
|
8629
8641
|
} catch (j) {
|
|
8630
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setLocalStream is error.", j);
|
|
8642
|
+
n.push(D), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setLocalStream is error.", j);
|
|
8631
8643
|
}
|
|
8632
|
-
const
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
await this.
|
|
8636
|
-
const O = this.getSenderTracks(u), $ = [...e.tracks, ...O], N = await this.getCallAction($);
|
|
8637
|
-
await this.updateUsertracks(e.id, $, !0), V(this, zt).call(this, u), await V(this, Tt).call(this, N), await this.replaceSenderStream(n, !0);
|
|
8644
|
+
const O = this.getSenderTracks(u), $ = [...e.tracks, ...O];
|
|
8645
|
+
await this.updateUsertracks(e.id, $, !0);
|
|
8646
|
+
const N = await this.getCallAction($);
|
|
8647
|
+
await V(this, It).call(this, N), await this.replaceSenderStream(u, !0), V(this, Kt).call(this, u), await this.inactiveTracks(n, !1);
|
|
8638
8648
|
{
|
|
8639
8649
|
await this.emitNotifyUpdateUsers();
|
|
8640
8650
|
const D = await this.getCaller();
|
|
8641
8651
|
E(D);
|
|
8642
8652
|
}
|
|
8643
8653
|
} catch (e) {
|
|
8644
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", e);
|
|
8645
8654
|
for (const n of u)
|
|
8646
8655
|
await this.setLocalStream(n, !1);
|
|
8647
8656
|
_(`publish is error: ${e.message || e}`);
|
|
@@ -8670,7 +8679,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8670
8679
|
await this.replaceSenderStream(u, !0), await this.removeSenders(u), await this.closeUserTracks(e.id, n, !0);
|
|
8671
8680
|
{
|
|
8672
8681
|
const $ = await this.getCallAction(e.tracks);
|
|
8673
|
-
await V(this,
|
|
8682
|
+
await V(this, It).call(this, $);
|
|
8674
8683
|
}
|
|
8675
8684
|
await this.createOffer(), await this.cwsIns.sendMessage({
|
|
8676
8685
|
event: "closeTrack",
|
|
@@ -8734,7 +8743,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8734
8743
|
};
|
|
8735
8744
|
await D();
|
|
8736
8745
|
} catch (n) {
|
|
8737
|
-
|
|
8746
|
+
this.taskQueue.setCondition("subscribe", !0), k(`subscribe is error: ${n.message || n}`);
|
|
8738
8747
|
}
|
|
8739
8748
|
};
|
|
8740
8749
|
this.taskQueue.addTask(e, ["createWs", "createSession", "ice", "createTrack", "closeTrack"], { describe: "subscribe" });
|
|
@@ -8797,7 +8806,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8797
8806
|
}
|
|
8798
8807
|
}
|
|
8799
8808
|
const O = await this.getCallAction(n);
|
|
8800
|
-
await V(this,
|
|
8809
|
+
await V(this, It).call(this, O), await this.emitNotifyUpdateUsers(), _(!0);
|
|
8801
8810
|
}));
|
|
8802
8811
|
/**
|
|
8803
8812
|
* 远端调试
|
|
@@ -8813,7 +8822,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8813
8822
|
/**
|
|
8814
8823
|
* 更新自己通话状态
|
|
8815
8824
|
*/
|
|
8816
|
-
at(this,
|
|
8825
|
+
at(this, It, async (u) => new Promise(async (E, _) => {
|
|
8817
8826
|
const { roomId: k, userId: e } = this.options, n = { roomId: k, user: { id: e, callAction: u } };
|
|
8818
8827
|
await this.cwsIns.sendMessage({ event: "updateCall", data: n }).then(async (O) => {
|
|
8819
8828
|
const { code: $ = 0 } = O;
|
|
@@ -8864,7 +8873,7 @@ class RoomCalls extends RoomPeer {
|
|
|
8864
8873
|
return this.setRoomState("connecting"), new Promise((u) => {
|
|
8865
8874
|
const E = async () => {
|
|
8866
8875
|
try {
|
|
8867
|
-
|
|
8876
|
+
this.taskQueue.setCondition("createSession", !1), await this.addSenders(), await this.cwsIns.sendMessage({
|
|
8868
8877
|
event: "connectCF",
|
|
8869
8878
|
data: { sdp: this.getSdp() }
|
|
8870
8879
|
}).then(async (_) => {
|
|
@@ -8915,13 +8924,13 @@ class RoomCalls extends RoomPeer {
|
|
|
8915
8924
|
this.setRoomState("ready");
|
|
8916
8925
|
}
|
|
8917
8926
|
}
|
|
8918
|
-
|
|
8927
|
+
Kt = new WeakMap(), It = new WeakMap();
|
|
8919
8928
|
class Room extends RoomCalls {
|
|
8920
8929
|
constructor() {
|
|
8921
8930
|
super();
|
|
8922
8931
|
}
|
|
8923
8932
|
}
|
|
8924
|
-
var gt,
|
|
8933
|
+
var gt, Gt, Qt, Vt, Yt;
|
|
8925
8934
|
class QuickVO extends Room {
|
|
8926
8935
|
constructor(u) {
|
|
8927
8936
|
super();
|
|
@@ -8929,7 +8938,7 @@ class QuickVO extends Room {
|
|
|
8929
8938
|
/**
|
|
8930
8939
|
* 添加内部监听事件
|
|
8931
8940
|
*/
|
|
8932
|
-
at(this,
|
|
8941
|
+
at(this, Gt, () => {
|
|
8933
8942
|
{
|
|
8934
8943
|
const u = async (E) => {
|
|
8935
8944
|
const { qualities: _ = [] } = E.data, [k] = _;
|
|
@@ -9004,14 +9013,14 @@ class QuickVO extends Room {
|
|
|
9004
9013
|
/**
|
|
9005
9014
|
* cwsIns 发送消息前
|
|
9006
9015
|
*/
|
|
9007
|
-
at(this,
|
|
9016
|
+
at(this, Qt, () => {
|
|
9008
9017
|
this.cwsIns.sendMessageBefore = async () => {
|
|
9009
9018
|
};
|
|
9010
9019
|
});
|
|
9011
9020
|
/**
|
|
9012
9021
|
* 重连成功
|
|
9013
9022
|
*/
|
|
9014
|
-
at(this,
|
|
9023
|
+
at(this, Vt, () => {
|
|
9015
9024
|
this.cwsIns.onReconnectSuccess = async () => {
|
|
9016
9025
|
this.syncRoomInfo();
|
|
9017
9026
|
};
|
|
@@ -9019,7 +9028,7 @@ class QuickVO extends Room {
|
|
|
9019
9028
|
/**
|
|
9020
9029
|
* 重连停止
|
|
9021
9030
|
*/
|
|
9022
|
-
at(this,
|
|
9031
|
+
at(this, Yt, async () => {
|
|
9023
9032
|
});
|
|
9024
9033
|
/**
|
|
9025
9034
|
* 添加 FrameRequestCallback
|
|
@@ -9056,12 +9065,12 @@ class QuickVO extends Room {
|
|
|
9056
9065
|
* @example quickvo.destroy()
|
|
9057
9066
|
*/
|
|
9058
9067
|
Z(this, "destroy", async () => {
|
|
9059
|
-
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 销毁SDK"), this.stopGetPeerStats(), this.
|
|
9068
|
+
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();
|
|
9060
9069
|
});
|
|
9061
|
-
this.setOptions(u), this.initCwsCall(), V(this,
|
|
9070
|
+
this.setOptions(u), this.initCwsCall(), V(this, Qt).call(this), V(this, Vt).call(this), V(this, Yt).call(this), V(this, Gt).call(this);
|
|
9062
9071
|
}
|
|
9063
9072
|
}
|
|
9064
|
-
gt = new WeakMap(),
|
|
9073
|
+
gt = new WeakMap(), Gt = new WeakMap(), Qt = new WeakMap(), Vt = new WeakMap(), Yt = new WeakMap();
|
|
9065
9074
|
export {
|
|
9066
9075
|
QuickVO,
|
|
9067
9076
|
ignoreEvent
|