quickvo-sdk-js 0.2.2 → 0.2.4
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 +8 -0
- package/dist/enums/notifyName.d.ts +7 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +810 -669
- package/dist/index.umd.cjs +2 -2
- package/dist/protos/compiled.d.ts +3724 -3615
- package/dist/room/CallsWebSocket.d.ts +2 -2
- package/dist/room/Room.d.ts +0 -8
- package/dist/room/RoomBase.d.ts +38 -5
- package/dist/room/RoomCalls.d.ts +6 -6
- package/dist/room/RoomMedias.d.ts +104 -0
- package/dist/room/RoomPeer.d.ts +4 -1
- package/dist/room/RoomUsers.d.ts +10 -10
- package/dist/room/{mediaStreamsContext/AudioMediaStreamContext.d.ts → mediaStreams/AudioMediaContext.d.ts} +3 -2
- package/dist/room/{mediaStreamsContext/VideoMediaStreamContext.d.ts → mediaStreams/VideoMediaContext.d.ts} +3 -2
- package/dist/tools.d.ts +0 -17
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
- package/dist/PrAsyncQueue.d.ts +0 -33
- package/dist/room/MediaStreams.d.ts +0 -60
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Xt = Object.defineProperty;
|
|
2
|
+
var Vt = (_) => {
|
|
3
3
|
throw TypeError(_);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
5
|
+
var Qt = (_, D, $) => D in _ ? Xt(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $;
|
|
6
|
+
var K = (_, D, $) => Qt(_, typeof D != "symbol" ? D + "" : D, $), Yt = (_, D, $) => D.has(_) || Vt("Cannot " + $);
|
|
7
|
+
var G = (_, D, $) => (Yt(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), st = (_, D, $) => D.has(_) ? Vt("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), _t = (_, D, $, U) => (Yt(_, D, "write to private field"), U ? U.call(_, $) : D.set(_, $), $);
|
|
8
8
|
const v$1 = (_, D = []) => {
|
|
9
9
|
const $ = { ..._ }, U = Object.keys($);
|
|
10
10
|
for (const R of U)
|
|
@@ -704,9 +704,9 @@ function requireLib() {
|
|
|
704
704
|
return lib.grammar = $, lib.write = D, lib.parse = _.parse, lib.parseParams = _.parseParams, lib.parseFmtpConfig = _.parseFmtpConfig, lib.parsePayloads = _.parsePayloads, lib.parseRemoteCandidates = _.parseRemoteCandidates, lib.parseImageAttributes = _.parseImageAttributes, lib.parseSimulcastStreamList = _.parseSimulcastStreamList, lib;
|
|
705
705
|
}
|
|
706
706
|
var libExports = requireLib();
|
|
707
|
-
class
|
|
707
|
+
class AudioMediaContext {
|
|
708
708
|
constructor(D) {
|
|
709
|
-
|
|
709
|
+
K(this, "options", {
|
|
710
710
|
autoGainControl: !1,
|
|
711
711
|
// 自动增益
|
|
712
712
|
noiseSuppression: !1,
|
|
@@ -714,28 +714,29 @@ class AudioMediaStreamContext {
|
|
|
714
714
|
echoCancellation: !1
|
|
715
715
|
// 回声消除
|
|
716
716
|
});
|
|
717
|
-
|
|
718
|
-
|
|
717
|
+
K(this, "kind", "audio");
|
|
718
|
+
K(this, "stream", new MediaStream());
|
|
719
|
+
K(this, "audio", new Audio());
|
|
719
720
|
// @ts-ignore 音频上下文
|
|
720
|
-
|
|
721
|
+
K(this, "audioContext", new (window.AudioContext || window.webkitAudioContext)());
|
|
721
722
|
// 媒体流音频源节点
|
|
722
|
-
|
|
723
|
+
K(this, "mediaStreamAudioSourceNode");
|
|
723
724
|
// 增益节点 (自动增益)
|
|
724
|
-
|
|
725
|
+
K(this, "autoGainNode");
|
|
725
726
|
// 滤波器节点 (噪声抑制)
|
|
726
|
-
|
|
727
|
+
K(this, "biquadFilterNode");
|
|
727
728
|
// 延迟节点 (回声消除)
|
|
728
|
-
|
|
729
|
+
K(this, "delayNode");
|
|
729
730
|
// 增益节点 (音量控制)
|
|
730
|
-
|
|
731
|
+
K(this, "gainNode");
|
|
731
732
|
// 音频分析节点
|
|
732
|
-
|
|
733
|
+
K(this, "analyserNode");
|
|
733
734
|
// 缓冲区 存储分析节点的时域数据
|
|
734
|
-
|
|
735
|
+
K(this, "analyserArrayData");
|
|
735
736
|
/**
|
|
736
737
|
* 停止
|
|
737
738
|
*/
|
|
738
|
-
|
|
739
|
+
K(this, "stop", () => {
|
|
739
740
|
const D = this.stream.getTracks();
|
|
740
741
|
for (const $ of D)
|
|
741
742
|
$.enabled = !1, $.stop(), this.stream.removeTrack($);
|
|
@@ -743,7 +744,7 @@ class AudioMediaStreamContext {
|
|
|
743
744
|
/**
|
|
744
745
|
* 替换媒体
|
|
745
746
|
*/
|
|
746
|
-
|
|
747
|
+
K(this, "replaceStream", (D) => {
|
|
747
748
|
this.stop();
|
|
748
749
|
const [$] = D.getAudioTracks();
|
|
749
750
|
this.stream.addTrack($);
|
|
@@ -751,23 +752,23 @@ class AudioMediaStreamContext {
|
|
|
751
752
|
/**
|
|
752
753
|
* 获取数据流
|
|
753
754
|
*/
|
|
754
|
-
|
|
755
|
+
K(this, "getStream", () => this.mediaStreamAudioSourceNode.mediaStream);
|
|
755
756
|
/**
|
|
756
757
|
* 静音
|
|
757
758
|
*/
|
|
758
|
-
|
|
759
|
+
K(this, "setMute", (D = !0) => {
|
|
759
760
|
D ? this.analyserNode.disconnect(this.audioContext.destination) : this.analyserNode.connect(this.audioContext.destination);
|
|
760
761
|
});
|
|
761
762
|
/**
|
|
762
763
|
* 设置音量
|
|
763
764
|
*/
|
|
764
|
-
|
|
765
|
+
K(this, "setVolumeGain", (D) => {
|
|
765
766
|
this.gainNode.gain.setValueAtTime(D, this.audioContext.currentTime);
|
|
766
767
|
});
|
|
767
768
|
/**
|
|
768
769
|
* 获取音量
|
|
769
770
|
*/
|
|
770
|
-
|
|
771
|
+
K(this, "getVolume", () => {
|
|
771
772
|
const { analyserNode: D, analyserArrayData: $ } = this;
|
|
772
773
|
D.getByteFrequencyData($);
|
|
773
774
|
let U = 0;
|
|
@@ -778,12 +779,12 @@ class AudioMediaStreamContext {
|
|
|
778
779
|
/**
|
|
779
780
|
* 设置音频过滤
|
|
780
781
|
*/
|
|
781
|
-
|
|
782
|
+
K(this, "setFilter", (D = {}) => {
|
|
782
783
|
this.options = { ...this.options, ...D };
|
|
783
784
|
const { autoGainControl: $, noiseSuppression: U, echoCancellation: R } = this.options, { mediaStreamAudioSourceNode: N, autoGainNode: e, biquadFilterNode: o, delayNode: A, gainNode: M } = this, L = N;
|
|
784
785
|
return $ && L.connect(e), U && L.connect(o), R && L.connect(A), L.connect(M), D;
|
|
785
786
|
});
|
|
786
|
-
this.stream
|
|
787
|
+
this.stream.addTrack(D), 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(0.5, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 1024, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount);
|
|
787
788
|
const { gainNode: $, analyserNode: U } = this;
|
|
788
789
|
$.connect(U), this.audioContext.state === "suspended" ? document.addEventListener(
|
|
789
790
|
"touchend",
|
|
@@ -794,13 +795,14 @@ class AudioMediaStreamContext {
|
|
|
794
795
|
) : this.setFilter();
|
|
795
796
|
}
|
|
796
797
|
}
|
|
797
|
-
class
|
|
798
|
+
class VideoMediaContext {
|
|
798
799
|
constructor(D) {
|
|
799
|
-
|
|
800
|
+
K(this, "kind", "video");
|
|
801
|
+
K(this, "stream", new MediaStream());
|
|
800
802
|
/**
|
|
801
803
|
* 停止
|
|
802
804
|
*/
|
|
803
|
-
|
|
805
|
+
K(this, "stop", () => {
|
|
804
806
|
const D = this.stream.getTracks();
|
|
805
807
|
for (const $ of D)
|
|
806
808
|
$.enabled = !1, $.stop(), this.stream.removeTrack($);
|
|
@@ -808,7 +810,7 @@ class VideoMediaStreamContext {
|
|
|
808
810
|
/**
|
|
809
811
|
* 替换媒体
|
|
810
812
|
*/
|
|
811
|
-
|
|
813
|
+
K(this, "replaceStream", (D) => {
|
|
812
814
|
this.stop();
|
|
813
815
|
const [$] = D.getVideoTracks();
|
|
814
816
|
this.stream.addTrack($);
|
|
@@ -816,8 +818,8 @@ class VideoMediaStreamContext {
|
|
|
816
818
|
/**
|
|
817
819
|
* 获取数据流
|
|
818
820
|
*/
|
|
819
|
-
|
|
820
|
-
this.stream
|
|
821
|
+
K(this, "getStream", () => this.stream);
|
|
822
|
+
this.stream.addTrack(D);
|
|
821
823
|
}
|
|
822
824
|
}
|
|
823
825
|
const enum_roomState = {
|
|
@@ -1109,15 +1111,15 @@ function requireFloat() {
|
|
|
1109
1111
|
if (F < 22250738585072014e-324)
|
|
1110
1112
|
V = F / 5e-324, A(V >>> 0, Z, H + M), A((z << 31 | V / 4294967296) >>> 0, Z, H + L);
|
|
1111
1113
|
else {
|
|
1112
|
-
var
|
|
1113
|
-
|
|
1114
|
+
var W = Math.floor(Math.log(F) / Math.LN2);
|
|
1115
|
+
W === 1024 && (W = 1023), V = F * Math.pow(2, -W), A(V * 4503599627370496 >>> 0, Z, H + M), A((z << 31 | W + 1023 << 20 | V * 1048576 & 1048575) >>> 0, Z, H + L);
|
|
1114
1116
|
}
|
|
1115
1117
|
}
|
|
1116
1118
|
}
|
|
1117
1119
|
N.writeDoubleLE = e.bind(null, D, 0, 4), N.writeDoubleBE = e.bind(null, $, 4, 0);
|
|
1118
1120
|
function o(A, M, L, F, Z) {
|
|
1119
|
-
var H = A(F, Z + M), z = A(F, Z + L), V = (z >> 31) * 2 + 1,
|
|
1120
|
-
return
|
|
1121
|
+
var H = A(F, Z + M), z = A(F, Z + L), V = (z >> 31) * 2 + 1, W = z >>> 20 & 2047, J = 4294967296 * (z & 1048575) + H;
|
|
1122
|
+
return W === 2047 ? J ? NaN : V * (1 / 0) : W === 0 ? V * 5e-324 * J : V * Math.pow(2, W - 1075) * (J + 4503599627370496);
|
|
1121
1123
|
}
|
|
1122
1124
|
N.readDoubleLE = o.bind(null, U, 0, 4), N.readDoubleBE = o.bind(null, R, 4, 0);
|
|
1123
1125
|
}(), N;
|
|
@@ -1390,13 +1392,13 @@ function requireWriter() {
|
|
|
1390
1392
|
if (hasRequiredWriter) return writer;
|
|
1391
1393
|
hasRequiredWriter = 1, writer = A;
|
|
1392
1394
|
var _ = requireMinimal$1(), D, $ = _.LongBits, U = _.base64, R = _.utf8;
|
|
1393
|
-
function N(
|
|
1394
|
-
this.fn =
|
|
1395
|
+
function N(W, J, Y) {
|
|
1396
|
+
this.fn = W, this.len = J, this.next = void 0, this.val = Y;
|
|
1395
1397
|
}
|
|
1396
1398
|
function e() {
|
|
1397
1399
|
}
|
|
1398
|
-
function o(
|
|
1399
|
-
this.head =
|
|
1400
|
+
function o(W) {
|
|
1401
|
+
this.head = W.head, this.tail = W.tail, this.len = W.len, this.next = W.states;
|
|
1400
1402
|
}
|
|
1401
1403
|
function A() {
|
|
1402
1404
|
this.len = 0, this.head = new N(e, 0, 0), this.tail = this.head, this.states = null;
|
|
@@ -1412,19 +1414,19 @@ function requireWriter() {
|
|
|
1412
1414
|
};
|
|
1413
1415
|
A.create = M(), A.alloc = function(J) {
|
|
1414
1416
|
return new _.Array(J);
|
|
1415
|
-
}, _.Array !== Array && (A.alloc = _.pool(A.alloc, _.Array.prototype.subarray)), A.prototype._push = function(J,
|
|
1416
|
-
return this.tail = this.tail.next = new N(J,
|
|
1417
|
+
}, _.Array !== Array && (A.alloc = _.pool(A.alloc, _.Array.prototype.subarray)), A.prototype._push = function(J, Y, tt) {
|
|
1418
|
+
return this.tail = this.tail.next = new N(J, Y, tt), this.len += Y, this;
|
|
1417
1419
|
};
|
|
1418
|
-
function L(
|
|
1419
|
-
J[
|
|
1420
|
+
function L(W, J, Y) {
|
|
1421
|
+
J[Y] = W & 255;
|
|
1420
1422
|
}
|
|
1421
|
-
function F(
|
|
1422
|
-
for (;
|
|
1423
|
-
J[
|
|
1424
|
-
J[
|
|
1423
|
+
function F(W, J, Y) {
|
|
1424
|
+
for (; W > 127; )
|
|
1425
|
+
J[Y++] = W & 127 | 128, W >>>= 7;
|
|
1426
|
+
J[Y] = W;
|
|
1425
1427
|
}
|
|
1426
|
-
function Z(
|
|
1427
|
-
this.len =
|
|
1428
|
+
function Z(W, J) {
|
|
1429
|
+
this.len = W, this.next = void 0, this.val = J;
|
|
1428
1430
|
}
|
|
1429
1431
|
Z.prototype = Object.create(N.prototype), Z.prototype.fn = F, A.prototype.uint32 = function(J) {
|
|
1430
1432
|
return this.len += (this.tail = this.tail.next = new Z(
|
|
@@ -1436,66 +1438,66 @@ function requireWriter() {
|
|
|
1436
1438
|
}, A.prototype.sint32 = function(J) {
|
|
1437
1439
|
return this.uint32((J << 1 ^ J >> 31) >>> 0);
|
|
1438
1440
|
};
|
|
1439
|
-
function H(
|
|
1440
|
-
for (;
|
|
1441
|
-
J[
|
|
1442
|
-
for (;
|
|
1443
|
-
J[
|
|
1444
|
-
J[
|
|
1441
|
+
function H(W, J, Y) {
|
|
1442
|
+
for (; W.hi; )
|
|
1443
|
+
J[Y++] = W.lo & 127 | 128, W.lo = (W.lo >>> 7 | W.hi << 25) >>> 0, W.hi >>>= 7;
|
|
1444
|
+
for (; W.lo > 127; )
|
|
1445
|
+
J[Y++] = W.lo & 127 | 128, W.lo = W.lo >>> 7;
|
|
1446
|
+
J[Y++] = W.lo;
|
|
1445
1447
|
}
|
|
1446
1448
|
A.prototype.uint64 = function(J) {
|
|
1447
|
-
var
|
|
1448
|
-
return this._push(H,
|
|
1449
|
+
var Y = $.from(J);
|
|
1450
|
+
return this._push(H, Y.length(), Y);
|
|
1449
1451
|
}, A.prototype.int64 = A.prototype.uint64, A.prototype.sint64 = function(J) {
|
|
1450
|
-
var
|
|
1451
|
-
return this._push(H,
|
|
1452
|
+
var Y = $.from(J).zzEncode();
|
|
1453
|
+
return this._push(H, Y.length(), Y);
|
|
1452
1454
|
}, A.prototype.bool = function(J) {
|
|
1453
1455
|
return this._push(L, 1, J ? 1 : 0);
|
|
1454
1456
|
};
|
|
1455
|
-
function z(
|
|
1456
|
-
J[
|
|
1457
|
+
function z(W, J, Y) {
|
|
1458
|
+
J[Y] = W & 255, J[Y + 1] = W >>> 8 & 255, J[Y + 2] = W >>> 16 & 255, J[Y + 3] = W >>> 24;
|
|
1457
1459
|
}
|
|
1458
1460
|
A.prototype.fixed32 = function(J) {
|
|
1459
1461
|
return this._push(z, 4, J >>> 0);
|
|
1460
1462
|
}, A.prototype.sfixed32 = A.prototype.fixed32, A.prototype.fixed64 = function(J) {
|
|
1461
|
-
var
|
|
1462
|
-
return this._push(z, 4,
|
|
1463
|
+
var Y = $.from(J);
|
|
1464
|
+
return this._push(z, 4, Y.lo)._push(z, 4, Y.hi);
|
|
1463
1465
|
}, A.prototype.sfixed64 = A.prototype.fixed64, A.prototype.float = function(J) {
|
|
1464
1466
|
return this._push(_.float.writeFloatLE, 4, J);
|
|
1465
1467
|
}, A.prototype.double = function(J) {
|
|
1466
1468
|
return this._push(_.float.writeDoubleLE, 8, J);
|
|
1467
1469
|
};
|
|
1468
|
-
var V = _.Array.prototype.set ? function(J,
|
|
1469
|
-
|
|
1470
|
-
} : function(J,
|
|
1471
|
-
for (var
|
|
1472
|
-
|
|
1470
|
+
var V = _.Array.prototype.set ? function(J, Y, tt) {
|
|
1471
|
+
Y.set(J, tt);
|
|
1472
|
+
} : function(J, Y, tt) {
|
|
1473
|
+
for (var X = 0; X < J.length; ++X)
|
|
1474
|
+
Y[tt + X] = J[X];
|
|
1473
1475
|
};
|
|
1474
1476
|
return A.prototype.bytes = function(J) {
|
|
1475
|
-
var
|
|
1476
|
-
if (!
|
|
1477
|
+
var Y = J.length >>> 0;
|
|
1478
|
+
if (!Y)
|
|
1477
1479
|
return this._push(L, 1, 0);
|
|
1478
1480
|
if (_.isString(J)) {
|
|
1479
|
-
var tt = A.alloc(
|
|
1481
|
+
var tt = A.alloc(Y = U.length(J));
|
|
1480
1482
|
U.decode(J, tt, 0), J = tt;
|
|
1481
1483
|
}
|
|
1482
|
-
return this.uint32(
|
|
1484
|
+
return this.uint32(Y)._push(V, Y, J);
|
|
1483
1485
|
}, A.prototype.string = function(J) {
|
|
1484
|
-
var
|
|
1485
|
-
return
|
|
1486
|
+
var Y = R.length(J);
|
|
1487
|
+
return Y ? this.uint32(Y)._push(R.write, Y, J) : this._push(L, 1, 0);
|
|
1486
1488
|
}, A.prototype.fork = function() {
|
|
1487
1489
|
return this.states = new o(this), this.head = this.tail = new N(e, 0, 0), this.len = 0, this;
|
|
1488
1490
|
}, A.prototype.reset = function() {
|
|
1489
1491
|
return this.states ? (this.head = this.states.head, this.tail = this.states.tail, this.len = this.states.len, this.states = this.states.next) : (this.head = this.tail = new N(e, 0, 0), this.len = 0), this;
|
|
1490
1492
|
}, A.prototype.ldelim = function() {
|
|
1491
|
-
var J = this.head,
|
|
1492
|
-
return this.reset().uint32(tt), tt && (this.tail.next = J.next, this.tail =
|
|
1493
|
+
var J = this.head, Y = this.tail, tt = this.len;
|
|
1494
|
+
return this.reset().uint32(tt), tt && (this.tail.next = J.next, this.tail = Y, this.len += tt), this;
|
|
1493
1495
|
}, A.prototype.finish = function() {
|
|
1494
|
-
for (var J = this.head.next,
|
|
1495
|
-
J.fn(J.val,
|
|
1496
|
-
return
|
|
1497
|
-
}, A._configure = function(
|
|
1498
|
-
D =
|
|
1496
|
+
for (var J = this.head.next, Y = this.constructor.alloc(this.len), tt = 0; J; )
|
|
1497
|
+
J.fn(J.val, Y, tt), tt += J.len, J = J.next;
|
|
1498
|
+
return Y;
|
|
1499
|
+
}, A._configure = function(W) {
|
|
1500
|
+
D = W, A.create = M(), D._configure();
|
|
1499
1501
|
}, writer;
|
|
1500
1502
|
}
|
|
1501
1503
|
var writer_buffer, hasRequiredWriter_buffer;
|
|
@@ -4370,6 +4372,69 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
4370
4372
|
}, R.getTypeUrl = function(e) {
|
|
4371
4373
|
return e === void 0 && (e = "type.googleapis.com"), e + "/com.quick.voice.proto.ToggleLiveRoomRsq";
|
|
4372
4374
|
}, R;
|
|
4375
|
+
}(), U.CDNPlayAddressNotify = function() {
|
|
4376
|
+
function R(N) {
|
|
4377
|
+
if (N)
|
|
4378
|
+
for (let e = Object.keys(N), o = 0; o < e.length; ++o)
|
|
4379
|
+
N[e[o]] != null && (this[e[o]] = N[e[o]]);
|
|
4380
|
+
}
|
|
4381
|
+
return R.prototype.roomId = "", R.prototype.m3u8 = "", R.prototype.rtmp = "", R.create = function(e) {
|
|
4382
|
+
return new R(e);
|
|
4383
|
+
}, R.encode = function(e, o) {
|
|
4384
|
+
return o || (o = $Writer.create()), e.roomId != null && Object.hasOwnProperty.call(e, "roomId") && o.uint32(
|
|
4385
|
+
/* id 1, wireType 2 =*/
|
|
4386
|
+
10
|
|
4387
|
+
).string(e.roomId), e.m3u8 != null && Object.hasOwnProperty.call(e, "m3u8") && o.uint32(
|
|
4388
|
+
/* id 2, wireType 2 =*/
|
|
4389
|
+
18
|
|
4390
|
+
).string(e.m3u8), e.rtmp != null && Object.hasOwnProperty.call(e, "rtmp") && o.uint32(
|
|
4391
|
+
/* id 3, wireType 2 =*/
|
|
4392
|
+
26
|
|
4393
|
+
).string(e.rtmp), o;
|
|
4394
|
+
}, R.encodeDelimited = function(e, o) {
|
|
4395
|
+
return this.encode(e, o).ldelim();
|
|
4396
|
+
}, R.decode = function(e, o) {
|
|
4397
|
+
e instanceof $Reader || (e = $Reader.create(e));
|
|
4398
|
+
let A = o === void 0 ? e.len : e.pos + o, M = new $root.com.quick.voice.proto.CDNPlayAddressNotify();
|
|
4399
|
+
for (; e.pos < A; ) {
|
|
4400
|
+
let L = e.uint32();
|
|
4401
|
+
switch (L >>> 3) {
|
|
4402
|
+
case 1: {
|
|
4403
|
+
M.roomId = e.string();
|
|
4404
|
+
break;
|
|
4405
|
+
}
|
|
4406
|
+
case 2: {
|
|
4407
|
+
M.m3u8 = e.string();
|
|
4408
|
+
break;
|
|
4409
|
+
}
|
|
4410
|
+
case 3: {
|
|
4411
|
+
M.rtmp = e.string();
|
|
4412
|
+
break;
|
|
4413
|
+
}
|
|
4414
|
+
default:
|
|
4415
|
+
e.skipType(L & 7);
|
|
4416
|
+
break;
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
return M;
|
|
4420
|
+
}, R.decodeDelimited = function(e) {
|
|
4421
|
+
return e instanceof $Reader || (e = new $Reader(e)), this.decode(e, e.uint32());
|
|
4422
|
+
}, R.verify = function(e) {
|
|
4423
|
+
return typeof e != "object" || e === null ? "object expected" : e.roomId != null && e.hasOwnProperty("roomId") && !$util.isString(e.roomId) ? "roomId: string expected" : e.m3u8 != null && e.hasOwnProperty("m3u8") && !$util.isString(e.m3u8) ? "m3u8: string expected" : e.rtmp != null && e.hasOwnProperty("rtmp") && !$util.isString(e.rtmp) ? "rtmp: string expected" : null;
|
|
4424
|
+
}, R.fromObject = function(e) {
|
|
4425
|
+
if (e instanceof $root.com.quick.voice.proto.CDNPlayAddressNotify)
|
|
4426
|
+
return e;
|
|
4427
|
+
let o = new $root.com.quick.voice.proto.CDNPlayAddressNotify();
|
|
4428
|
+
return e.roomId != null && (o.roomId = String(e.roomId)), e.m3u8 != null && (o.m3u8 = String(e.m3u8)), e.rtmp != null && (o.rtmp = String(e.rtmp)), o;
|
|
4429
|
+
}, R.toObject = function(e, o) {
|
|
4430
|
+
o || (o = {});
|
|
4431
|
+
let A = {};
|
|
4432
|
+
return o.defaults && (A.roomId = "", A.m3u8 = "", A.rtmp = ""), e.roomId != null && e.hasOwnProperty("roomId") && (A.roomId = e.roomId), e.m3u8 != null && e.hasOwnProperty("m3u8") && (A.m3u8 = e.m3u8), e.rtmp != null && e.hasOwnProperty("rtmp") && (A.rtmp = e.rtmp), A;
|
|
4433
|
+
}, R.prototype.toJSON = function() {
|
|
4434
|
+
return this.constructor.toObject(this, minimalExports.util.toJSONOptions);
|
|
4435
|
+
}, R.getTypeUrl = function(e) {
|
|
4436
|
+
return e === void 0 && (e = "type.googleapis.com"), e + "/com.quick.voice.proto.CDNPlayAddressNotify";
|
|
4437
|
+
}, R;
|
|
4373
4438
|
}(), U.TrackType = function() {
|
|
4374
4439
|
const R = {}, N = Object.create(R);
|
|
4375
4440
|
return N[R[0] = "Microphone"] = 0, N[R[1] = "Camera"] = 1, N[R[2] = "Screen"] = 2, N[R[3] = "SystemVoice"] = 3, N;
|
|
@@ -4544,14 +4609,18 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
|
|
|
4544
4609
|
healthCheck: "心跳检测",
|
|
4545
4610
|
onNetQuality: "网络质量回调",
|
|
4546
4611
|
onLogin: "登录回调",
|
|
4547
|
-
onLocalStream: "
|
|
4548
|
-
|
|
4612
|
+
onLocalStream: "本地媒体流发生变化",
|
|
4613
|
+
onDevicechange: "媒体设备发生变化",
|
|
4614
|
+
onRoomUser: "房间用户变化",
|
|
4615
|
+
onRoomUsers: "房间所有用户所有变化",
|
|
4616
|
+
onRoomUsersStreams: "房间某些用户媒体流变化",
|
|
4549
4617
|
onRoomState: "房间状态变化",
|
|
4550
4618
|
onJoinRoom: "加入房间回调",
|
|
4551
4619
|
onQuitRoom: "退出房间回调",
|
|
4552
4620
|
onPublish: "监听到流发布",
|
|
4553
4621
|
onCloseTrack: "关闭轨道",
|
|
4554
4622
|
onUpdateCall: "更新通讯状态",
|
|
4623
|
+
onUpdateStreams: "更新媒体流",
|
|
4555
4624
|
onUpdatePermissions: "更新推流权限通知",
|
|
4556
4625
|
onTokenExpired: "Token已过期",
|
|
4557
4626
|
onDestroyRoom: "直播模式房间销毁",
|
|
@@ -5411,71 +5480,71 @@ var Deflate_1$1 = Deflate$1, deflate_2 = deflate$1, deflateRaw_1$1 = deflateRaw$
|
|
|
5411
5480
|
};
|
|
5412
5481
|
const BAD$1 = 16209, TYPE$1 = 16191;
|
|
5413
5482
|
var inffast = function _(D, $) {
|
|
5414
|
-
let U, R, N, e, o, A, M, L, F, Z, H, z, V,
|
|
5483
|
+
let U, R, N, e, o, A, M, L, F, Z, H, z, V, W, J, Y, tt, X, nt, lt, et, at, ct, ot;
|
|
5415
5484
|
const rt = D.state;
|
|
5416
|
-
U = D.next_in, ct = D.input, R = U + (D.avail_in - 5), N = D.next_out, ot = D.output, e = N - ($ - D.avail_out), o = N + (D.avail_out - 257), A = rt.dmax, M = rt.wsize, L = rt.whave, F = rt.wnext, Z = rt.window, H = rt.hold, z = rt.bits, V = rt.lencode,
|
|
5485
|
+
U = D.next_in, ct = D.input, R = U + (D.avail_in - 5), N = D.next_out, ot = D.output, e = N - ($ - D.avail_out), o = N + (D.avail_out - 257), A = rt.dmax, M = rt.wsize, L = rt.whave, F = rt.wnext, Z = rt.window, H = rt.hold, z = rt.bits, V = rt.lencode, W = rt.distcode, J = (1 << rt.lenbits) - 1, Y = (1 << rt.distbits) - 1;
|
|
5417
5486
|
t:
|
|
5418
5487
|
do {
|
|
5419
5488
|
z < 15 && (H += ct[U++] << z, z += 8, H += ct[U++] << z, z += 8), tt = V[H & J];
|
|
5420
5489
|
e:
|
|
5421
5490
|
for (; ; ) {
|
|
5422
|
-
if (
|
|
5491
|
+
if (X = tt >>> 24, H >>>= X, z -= X, X = tt >>> 16 & 255, X === 0)
|
|
5423
5492
|
ot[N++] = tt & 65535;
|
|
5424
|
-
else if (
|
|
5425
|
-
nt = tt & 65535,
|
|
5493
|
+
else if (X & 16) {
|
|
5494
|
+
nt = tt & 65535, X &= 15, X && (z < X && (H += ct[U++] << z, z += 8), nt += H & (1 << X) - 1, H >>>= X, z -= X), z < 15 && (H += ct[U++] << z, z += 8, H += ct[U++] << z, z += 8), tt = W[H & Y];
|
|
5426
5495
|
i:
|
|
5427
5496
|
for (; ; ) {
|
|
5428
|
-
if (
|
|
5429
|
-
if (
|
|
5497
|
+
if (X = tt >>> 24, H >>>= X, z -= X, X = tt >>> 16 & 255, X & 16) {
|
|
5498
|
+
if (lt = tt & 65535, X &= 15, z < X && (H += ct[U++] << z, z += 8, z < X && (H += ct[U++] << z, z += 8)), lt += H & (1 << X) - 1, lt > A) {
|
|
5430
5499
|
D.msg = "invalid distance too far back", rt.mode = BAD$1;
|
|
5431
5500
|
break t;
|
|
5432
5501
|
}
|
|
5433
|
-
if (H >>>=
|
|
5434
|
-
if (
|
|
5502
|
+
if (H >>>= X, z -= X, X = N - e, lt > X) {
|
|
5503
|
+
if (X = lt - X, X > L && rt.sane) {
|
|
5435
5504
|
D.msg = "invalid distance too far back", rt.mode = BAD$1;
|
|
5436
5505
|
break t;
|
|
5437
5506
|
}
|
|
5438
5507
|
if (et = 0, at = Z, F === 0) {
|
|
5439
|
-
if (et += M -
|
|
5440
|
-
nt -=
|
|
5508
|
+
if (et += M - X, X < nt) {
|
|
5509
|
+
nt -= X;
|
|
5441
5510
|
do
|
|
5442
5511
|
ot[N++] = Z[et++];
|
|
5443
|
-
while (--
|
|
5444
|
-
et = N -
|
|
5512
|
+
while (--X);
|
|
5513
|
+
et = N - lt, at = ot;
|
|
5445
5514
|
}
|
|
5446
|
-
} else if (F <
|
|
5447
|
-
if (et += M + F -
|
|
5448
|
-
nt -=
|
|
5515
|
+
} else if (F < X) {
|
|
5516
|
+
if (et += M + F - X, X -= F, X < nt) {
|
|
5517
|
+
nt -= X;
|
|
5449
5518
|
do
|
|
5450
5519
|
ot[N++] = Z[et++];
|
|
5451
|
-
while (--
|
|
5520
|
+
while (--X);
|
|
5452
5521
|
if (et = 0, F < nt) {
|
|
5453
|
-
|
|
5522
|
+
X = F, nt -= X;
|
|
5454
5523
|
do
|
|
5455
5524
|
ot[N++] = Z[et++];
|
|
5456
|
-
while (--
|
|
5457
|
-
et = N -
|
|
5525
|
+
while (--X);
|
|
5526
|
+
et = N - lt, at = ot;
|
|
5458
5527
|
}
|
|
5459
5528
|
}
|
|
5460
|
-
} else if (et += F -
|
|
5461
|
-
nt -=
|
|
5529
|
+
} else if (et += F - X, X < nt) {
|
|
5530
|
+
nt -= X;
|
|
5462
5531
|
do
|
|
5463
5532
|
ot[N++] = Z[et++];
|
|
5464
|
-
while (--
|
|
5465
|
-
et = N -
|
|
5533
|
+
while (--X);
|
|
5534
|
+
et = N - lt, at = ot;
|
|
5466
5535
|
}
|
|
5467
5536
|
for (; nt > 2; )
|
|
5468
5537
|
ot[N++] = at[et++], ot[N++] = at[et++], ot[N++] = at[et++], nt -= 3;
|
|
5469
5538
|
nt && (ot[N++] = at[et++], nt > 1 && (ot[N++] = at[et++]));
|
|
5470
5539
|
} else {
|
|
5471
|
-
et = N -
|
|
5540
|
+
et = N - lt;
|
|
5472
5541
|
do
|
|
5473
5542
|
ot[N++] = ot[et++], ot[N++] = ot[et++], ot[N++] = ot[et++], nt -= 3;
|
|
5474
5543
|
while (nt > 2);
|
|
5475
5544
|
nt && (ot[N++] = ot[et++], nt > 1 && (ot[N++] = ot[et++]));
|
|
5476
5545
|
}
|
|
5477
|
-
} else if ((
|
|
5478
|
-
tt =
|
|
5546
|
+
} else if ((X & 64) === 0) {
|
|
5547
|
+
tt = W[(tt & 65535) + (H & (1 << X) - 1)];
|
|
5479
5548
|
continue i;
|
|
5480
5549
|
} else {
|
|
5481
5550
|
D.msg = "invalid distance code", rt.mode = BAD$1;
|
|
@@ -5483,10 +5552,10 @@ var inffast = function _(D, $) {
|
|
|
5483
5552
|
}
|
|
5484
5553
|
break;
|
|
5485
5554
|
}
|
|
5486
|
-
} else if ((
|
|
5487
|
-
tt = V[(tt & 65535) + (H & (1 <<
|
|
5555
|
+
} else if ((X & 64) === 0) {
|
|
5556
|
+
tt = V[(tt & 65535) + (H & (1 << X) - 1)];
|
|
5488
5557
|
continue e;
|
|
5489
|
-
} else if (
|
|
5558
|
+
} else if (X & 32) {
|
|
5490
5559
|
rt.mode = TYPE$1;
|
|
5491
5560
|
break t;
|
|
5492
5561
|
} else {
|
|
@@ -5634,9 +5703,9 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
5634
5703
|
64
|
|
5635
5704
|
]), inflate_table = (_, D, $, U, R, N, e, o) => {
|
|
5636
5705
|
const A = o.bits;
|
|
5637
|
-
let M = 0, L = 0, F = 0, Z = 0, H = 0, z = 0, V = 0,
|
|
5706
|
+
let M = 0, L = 0, F = 0, Z = 0, H = 0, z = 0, V = 0, W = 0, J = 0, Y = 0, tt, X, nt, lt, et, at = null, ct;
|
|
5638
5707
|
const ot = new Uint16Array(MAXBITS + 1), rt = new Uint16Array(MAXBITS + 1);
|
|
5639
|
-
let
|
|
5708
|
+
let St = null, Gt, Nt, At;
|
|
5640
5709
|
for (M = 0; M <= MAXBITS; M++)
|
|
5641
5710
|
ot[M] = 0;
|
|
5642
5711
|
for (L = 0; L < U; L++)
|
|
@@ -5647,38 +5716,38 @@ const MAXBITS = 15, ENOUGH_LENS$1 = 852, ENOUGH_DISTS$1 = 592, CODES$1 = 0, LENS
|
|
|
5647
5716
|
return R[N++] = 1 << 24 | 64 << 16 | 0, R[N++] = 1 << 24 | 64 << 16 | 0, o.bits = 1, 0;
|
|
5648
5717
|
for (F = 1; F < Z && ot[F] === 0; F++)
|
|
5649
5718
|
;
|
|
5650
|
-
for (H < F && (H = F),
|
|
5651
|
-
if (
|
|
5719
|
+
for (H < F && (H = F), W = 1, M = 1; M <= MAXBITS; M++)
|
|
5720
|
+
if (W <<= 1, W -= ot[M], W < 0)
|
|
5652
5721
|
return -1;
|
|
5653
|
-
if (
|
|
5722
|
+
if (W > 0 && (_ === CODES$1 || Z !== 1))
|
|
5654
5723
|
return -1;
|
|
5655
5724
|
for (rt[1] = 0, M = 1; M < MAXBITS; M++)
|
|
5656
5725
|
rt[M + 1] = rt[M] + ot[M];
|
|
5657
5726
|
for (L = 0; L < U; L++)
|
|
5658
5727
|
D[$ + L] !== 0 && (e[rt[D[$ + L]]++] = L);
|
|
5659
|
-
if (_ === CODES$1 ? (at =
|
|
5728
|
+
if (_ === CODES$1 ? (at = St = e, ct = 20) : _ === LENS$1 ? (at = lbase, St = lext, ct = 257) : (at = dbase, St = dext, ct = 0), Y = 0, L = 0, M = F, et = N, z = H, V = 0, nt = -1, J = 1 << H, lt = J - 1, _ === LENS$1 && J > ENOUGH_LENS$1 || _ === DISTS$1 && J > ENOUGH_DISTS$1)
|
|
5660
5729
|
return 1;
|
|
5661
5730
|
for (; ; ) {
|
|
5662
|
-
|
|
5731
|
+
Gt = M - V, e[L] + 1 < ct ? (Nt = 0, At = e[L]) : e[L] >= ct ? (Nt = St[e[L] - ct], At = at[e[L] - ct]) : (Nt = 96, At = 0), tt = 1 << M - V, X = 1 << z, F = X;
|
|
5663
5732
|
do
|
|
5664
|
-
|
|
5665
|
-
while (
|
|
5666
|
-
for (tt = 1 << M - 1;
|
|
5733
|
+
X -= tt, R[et + (Y >> V) + X] = Gt << 24 | Nt << 16 | At | 0;
|
|
5734
|
+
while (X !== 0);
|
|
5735
|
+
for (tt = 1 << M - 1; Y & tt; )
|
|
5667
5736
|
tt >>= 1;
|
|
5668
|
-
if (tt !== 0 ? (
|
|
5737
|
+
if (tt !== 0 ? (Y &= tt - 1, Y += tt) : Y = 0, L++, --ot[M] === 0) {
|
|
5669
5738
|
if (M === Z)
|
|
5670
5739
|
break;
|
|
5671
5740
|
M = D[$ + e[L]];
|
|
5672
5741
|
}
|
|
5673
|
-
if (M > H && (
|
|
5674
|
-
for (V === 0 && (V = H), et += F, z = M - V,
|
|
5675
|
-
z++,
|
|
5742
|
+
if (M > H && (Y & lt) !== nt) {
|
|
5743
|
+
for (V === 0 && (V = H), et += F, z = M - V, W = 1 << z; z + V < Z && (W -= ot[z + V], !(W <= 0)); )
|
|
5744
|
+
z++, W <<= 1;
|
|
5676
5745
|
if (J += 1 << z, _ === LENS$1 && J > ENOUGH_LENS$1 || _ === DISTS$1 && J > ENOUGH_DISTS$1)
|
|
5677
5746
|
return 1;
|
|
5678
|
-
nt =
|
|
5747
|
+
nt = Y & lt, R[nt] = H << 24 | z << 16 | et - N | 0;
|
|
5679
5748
|
}
|
|
5680
5749
|
}
|
|
5681
|
-
return
|
|
5750
|
+
return Y !== 0 && (R[et + Y] = M - V << 24 | 64 << 16 | 0), o.bits = H, 0;
|
|
5682
5751
|
};
|
|
5683
5752
|
var inftrees = inflate_table;
|
|
5684
5753
|
const CODES = 0, LENS = 1, DISTS = 2, {
|
|
@@ -5749,10 +5818,10 @@ const fixedtables = (_) => {
|
|
|
5749
5818
|
const N = _.state;
|
|
5750
5819
|
return N.window === null && (N.wsize = 1 << N.wbits, N.wnext = 0, N.whave = 0, N.window = new Uint8Array(N.wsize)), U >= N.wsize ? (N.window.set(D.subarray($ - N.wsize, $), 0), N.wnext = 0, N.whave = N.wsize) : (R = N.wsize - N.wnext, R > U && (R = U), N.window.set(D.subarray($ - U, $ - U + R), N.wnext), U -= R, U ? (N.window.set(D.subarray($ - U, $), 0), N.wnext = U, N.whave = N.wsize) : (N.wnext += R, N.wnext === N.wsize && (N.wnext = 0), N.whave < N.wsize && (N.whave += R))), 0;
|
|
5751
5820
|
}, inflate$2 = (_, D) => {
|
|
5752
|
-
let $, U, R, N, e, o, A, M, L, F, Z, H, z, V,
|
|
5821
|
+
let $, U, R, N, e, o, A, M, L, F, Z, H, z, V, W = 0, J, Y, tt, X, nt, lt, et, at;
|
|
5753
5822
|
const ct = new Uint8Array(4);
|
|
5754
5823
|
let ot, rt;
|
|
5755
|
-
const
|
|
5824
|
+
const St = (
|
|
5756
5825
|
/* permutation of code lengths */
|
|
5757
5826
|
new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])
|
|
5758
5827
|
);
|
|
@@ -5978,10 +6047,10 @@ const fixedtables = (_) => {
|
|
|
5978
6047
|
break t;
|
|
5979
6048
|
o--, M += U[N++] << L, L += 8;
|
|
5980
6049
|
}
|
|
5981
|
-
$.lens[
|
|
6050
|
+
$.lens[St[$.have++]] = M & 7, M >>>= 3, L -= 3;
|
|
5982
6051
|
}
|
|
5983
6052
|
for (; $.have < 19; )
|
|
5984
|
-
$.lens[
|
|
6053
|
+
$.lens[St[$.have++]] = 0;
|
|
5985
6054
|
if ($.lencode = $.lendyn, $.lenbits = 7, ot = { bits: $.lenbits }, at = inftrees(CODES, $.lens, 0, 19, $.lencode, 0, $.work, ot), $.lenbits = ot.bits, at) {
|
|
5986
6055
|
_.msg = "invalid code lengths set", $.mode = BAD;
|
|
5987
6056
|
break;
|
|
@@ -5990,7 +6059,7 @@ const fixedtables = (_) => {
|
|
|
5990
6059
|
/* falls through */
|
|
5991
6060
|
case CODELENS:
|
|
5992
6061
|
for (; $.have < $.nlen + $.ndist; ) {
|
|
5993
|
-
for (;
|
|
6062
|
+
for (; W = $.lencode[M & (1 << $.lenbits) - 1], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(J <= L); ) {
|
|
5994
6063
|
if (o === 0)
|
|
5995
6064
|
break t;
|
|
5996
6065
|
o--, M += U[N++] << L, L += 8;
|
|
@@ -6057,32 +6126,32 @@ const fixedtables = (_) => {
|
|
|
6057
6126
|
_.next_out = e, _.avail_out = A, _.next_in = N, _.avail_in = o, $.hold = M, $.bits = L, inffast(_, Z), e = _.next_out, R = _.output, A = _.avail_out, N = _.next_in, U = _.input, o = _.avail_in, M = $.hold, L = $.bits, $.mode === TYPE && ($.back = -1);
|
|
6058
6127
|
break;
|
|
6059
6128
|
}
|
|
6060
|
-
for ($.back = 0;
|
|
6129
|
+
for ($.back = 0; W = $.lencode[M & (1 << $.lenbits) - 1], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(J <= L); ) {
|
|
6061
6130
|
if (o === 0)
|
|
6062
6131
|
break t;
|
|
6063
6132
|
o--, M += U[N++] << L, L += 8;
|
|
6064
6133
|
}
|
|
6065
|
-
if (
|
|
6066
|
-
for (
|
|
6134
|
+
if (Y && (Y & 240) === 0) {
|
|
6135
|
+
for (X = J, nt = Y, lt = tt; W = $.lencode[lt + ((M & (1 << X + nt) - 1) >> X)], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(X + J <= L); ) {
|
|
6067
6136
|
if (o === 0)
|
|
6068
6137
|
break t;
|
|
6069
6138
|
o--, M += U[N++] << L, L += 8;
|
|
6070
6139
|
}
|
|
6071
|
-
M >>>=
|
|
6140
|
+
M >>>= X, L -= X, $.back += X;
|
|
6072
6141
|
}
|
|
6073
|
-
if (M >>>= J, L -= J, $.back += J, $.length = tt,
|
|
6142
|
+
if (M >>>= J, L -= J, $.back += J, $.length = tt, Y === 0) {
|
|
6074
6143
|
$.mode = LIT;
|
|
6075
6144
|
break;
|
|
6076
6145
|
}
|
|
6077
|
-
if (
|
|
6146
|
+
if (Y & 32) {
|
|
6078
6147
|
$.back = -1, $.mode = TYPE;
|
|
6079
6148
|
break;
|
|
6080
6149
|
}
|
|
6081
|
-
if (
|
|
6150
|
+
if (Y & 64) {
|
|
6082
6151
|
_.msg = "invalid literal/length code", $.mode = BAD;
|
|
6083
6152
|
break;
|
|
6084
6153
|
}
|
|
6085
|
-
$.extra =
|
|
6154
|
+
$.extra = Y & 15, $.mode = LENEXT;
|
|
6086
6155
|
/* falls through */
|
|
6087
6156
|
case LENEXT:
|
|
6088
6157
|
if ($.extra) {
|
|
@@ -6096,24 +6165,24 @@ const fixedtables = (_) => {
|
|
|
6096
6165
|
$.was = $.length, $.mode = DIST;
|
|
6097
6166
|
/* falls through */
|
|
6098
6167
|
case DIST:
|
|
6099
|
-
for (;
|
|
6168
|
+
for (; W = $.distcode[M & (1 << $.distbits) - 1], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(J <= L); ) {
|
|
6100
6169
|
if (o === 0)
|
|
6101
6170
|
break t;
|
|
6102
6171
|
o--, M += U[N++] << L, L += 8;
|
|
6103
6172
|
}
|
|
6104
|
-
if ((
|
|
6105
|
-
for (
|
|
6173
|
+
if ((Y & 240) === 0) {
|
|
6174
|
+
for (X = J, nt = Y, lt = tt; W = $.distcode[lt + ((M & (1 << X + nt) - 1) >> X)], J = W >>> 24, Y = W >>> 16 & 255, tt = W & 65535, !(X + J <= L); ) {
|
|
6106
6175
|
if (o === 0)
|
|
6107
6176
|
break t;
|
|
6108
6177
|
o--, M += U[N++] << L, L += 8;
|
|
6109
6178
|
}
|
|
6110
|
-
M >>>=
|
|
6179
|
+
M >>>= X, L -= X, $.back += X;
|
|
6111
6180
|
}
|
|
6112
|
-
if (M >>>= J, L -= J, $.back += J,
|
|
6181
|
+
if (M >>>= J, L -= J, $.back += J, Y & 64) {
|
|
6113
6182
|
_.msg = "invalid distance code", $.mode = BAD;
|
|
6114
6183
|
break;
|
|
6115
6184
|
}
|
|
6116
|
-
$.offset = tt, $.extra =
|
|
6185
|
+
$.offset = tt, $.extra = Y & 15, $.mode = DISTEXT;
|
|
6117
6186
|
/* falls through */
|
|
6118
6187
|
case DISTEXT:
|
|
6119
6188
|
if ($.extra) {
|
|
@@ -6423,12 +6492,12 @@ const compressArrayBuffer = (_) => {
|
|
|
6423
6492
|
}
|
|
6424
6493
|
return _;
|
|
6425
6494
|
}, checkReconnect = (_) => !0;
|
|
6426
|
-
var
|
|
6495
|
+
var yt, ft, Rt, $t, bt, dt, ht, qt, Et, xt, Dt, Ct, Ut, Mt;
|
|
6427
6496
|
class CallsWebSocket {
|
|
6428
6497
|
// 重连停止的回调
|
|
6429
6498
|
constructor(D) {
|
|
6430
|
-
|
|
6431
|
-
|
|
6499
|
+
st(this, yt);
|
|
6500
|
+
st(this, ft, {
|
|
6432
6501
|
url: "wss://demo.putplay.cc/websocket",
|
|
6433
6502
|
// 地址
|
|
6434
6503
|
debug: !1,
|
|
@@ -6437,29 +6506,29 @@ class CallsWebSocket {
|
|
|
6437
6506
|
// 最大重连次数
|
|
6438
6507
|
timeout: 30 * 1e3
|
|
6439
6508
|
});
|
|
6440
|
-
|
|
6509
|
+
st(this, Rt, "");
|
|
6441
6510
|
// 缓存登录凭证
|
|
6442
|
-
|
|
6511
|
+
st(this, $t, !1);
|
|
6443
6512
|
// 是否在房间内
|
|
6444
|
-
|
|
6513
|
+
st(this, bt, 0);
|
|
6445
6514
|
// 活性时间戳 根据服务端的响应来更新当前连接活性 活性为0 说明连接已经存在异常进行重连
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6515
|
+
st(this, dt, {});
|
|
6516
|
+
st(this, ht, {});
|
|
6517
|
+
K(this, "onReconnectSuccess", async (D) => {
|
|
6449
6518
|
});
|
|
6450
6519
|
// 重连成功的回调
|
|
6451
|
-
|
|
6520
|
+
K(this, "onReconnectStop", async (D) => {
|
|
6452
6521
|
});
|
|
6453
6522
|
// 自定义心跳规则
|
|
6454
|
-
|
|
6523
|
+
st(this, qt, () => G(this, $t) ? com.quick.voice.proto.CommonReq.encode({ event: "heartbeat", sn: +`${O(1e5, 999999)}` }).finish() : "");
|
|
6455
6524
|
// 更新日志
|
|
6456
|
-
|
|
6525
|
+
st(this, Et, (D, $ = {}) => {
|
|
6457
6526
|
try {
|
|
6458
6527
|
const { time: U, event: R, data: N = {}, data_original: e = {}, data_remote: o, ...A } = $, M = E(U, "YYYY-MM-DD hh:mm:ss", { offset: 480 });
|
|
6459
6528
|
let L = {};
|
|
6460
|
-
const F = (
|
|
6461
|
-
const tt = JSON.parse(JSON.stringify(
|
|
6462
|
-
for (const nt of
|
|
6529
|
+
const F = (Y = {}) => {
|
|
6530
|
+
const tt = JSON.parse(JSON.stringify(Y)), X = Object.keys(tt);
|
|
6531
|
+
for (const nt of X)
|
|
6463
6532
|
(nt.includes("sdp") || nt.includes("Sdp")) && (tt[nt] = "");
|
|
6464
6533
|
return tt;
|
|
6465
6534
|
};
|
|
@@ -6474,105 +6543,105 @@ class CallsWebSocket {
|
|
|
6474
6543
|
}
|
|
6475
6544
|
let H = "#quickvo.logs";
|
|
6476
6545
|
ignoreEvent.includes(R) && (H = "#quickvo.ignoreEvents");
|
|
6477
|
-
const z = { "#action": Z, timeStr: M, event: R, data: L, time: U, ...A }, V = localStorage.getItem(H) || JSON.stringify([]),
|
|
6546
|
+
const z = { "#action": Z, timeStr: M, event: R, data: L, time: U, ...A }, V = localStorage.getItem(H) || JSON.stringify([]), W = JSON.parse(V), J = [z, ...W].slice(0, 500);
|
|
6478
6547
|
localStorage.setItem(H, JSON.stringify(J));
|
|
6479
6548
|
} catch (U) {
|
|
6480
6549
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: updataLogs is error", U);
|
|
6481
6550
|
}
|
|
6482
6551
|
});
|
|
6483
6552
|
// 活性检查器 每次发送消息前 、 接收消息后 都会调用进行检查
|
|
6484
|
-
|
|
6553
|
+
st(this, xt, (D) => new Promise(async ($) => {
|
|
6485
6554
|
const { event: U } = D, R = Date.now();
|
|
6486
|
-
U === "healthCheck" && (
|
|
6487
|
-
const N = 30 * 1e3 +
|
|
6488
|
-
R -
|
|
6555
|
+
U === "healthCheck" && (_t(this, bt, R), G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 刷新活性", { activetimeStamp: G(this, bt), activetimeStampStr: E(G(this, bt)) }));
|
|
6556
|
+
const N = 30 * 1e3 + G(this, ft).timeout;
|
|
6557
|
+
R - G(this, bt) >= N && G(this, yt) && (G(this, ft).debug && console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 活性超时, 尝试重新建立连接", G(this, yt)), await this.connect()), $(G(this, yt));
|
|
6489
6558
|
}));
|
|
6490
6559
|
// 清除事件
|
|
6491
|
-
|
|
6492
|
-
const $ = Object.keys(
|
|
6560
|
+
K(this, "clearEvents", (D = []) => {
|
|
6561
|
+
const $ = Object.keys(G(this, dt));
|
|
6493
6562
|
D.length === 0 && (D = $);
|
|
6494
6563
|
for (const U of $) {
|
|
6495
6564
|
if (!D.includes(U)) continue;
|
|
6496
|
-
const R =
|
|
6497
|
-
clearTimeout(R.destructionTimer), delete
|
|
6565
|
+
const R = G(this, dt)[U];
|
|
6566
|
+
clearTimeout(R.destructionTimer), delete G(this, dt)[U];
|
|
6498
6567
|
}
|
|
6499
6568
|
});
|
|
6500
6569
|
// 创建事件
|
|
6501
|
-
|
|
6570
|
+
st(this, Dt, (D, { resolve: $, reject: U }) => {
|
|
6502
6571
|
const { sn: R } = D, N = () => {
|
|
6503
|
-
const o =
|
|
6504
|
-
clearTimeout(o.destructionTimer), delete
|
|
6572
|
+
const o = G(this, dt)[R];
|
|
6573
|
+
clearTimeout(o.destructionTimer), delete G(this, dt)[R];
|
|
6505
6574
|
}, e = setTimeout(() => {
|
|
6506
|
-
const o =
|
|
6575
|
+
const o = G(this, dt)[R];
|
|
6507
6576
|
console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo:event is timeout", o.message), N(), U("event is timeout");
|
|
6508
|
-
},
|
|
6509
|
-
|
|
6577
|
+
}, G(this, ft).timeout);
|
|
6578
|
+
G(this, dt)[R] = { message: D, resolve: $, reject: U, destruction: N, destructionTimer: e };
|
|
6510
6579
|
});
|
|
6511
6580
|
// 获取事件
|
|
6512
|
-
|
|
6581
|
+
st(this, Ct, (D) => G(this, dt)[D]);
|
|
6513
6582
|
// 重连成功
|
|
6514
|
-
|
|
6583
|
+
st(this, Ut, async (D) => {
|
|
6515
6584
|
const $ = Date.now();
|
|
6516
|
-
|
|
6585
|
+
_t(this, bt, $), G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 重置活性", { activetimeStamp: G(this, bt), activetimeStampStr: E(G(this, bt)) }), await this.onReconnectSuccess(D);
|
|
6517
6586
|
});
|
|
6518
6587
|
/**
|
|
6519
6588
|
* 连接
|
|
6520
6589
|
* @param session
|
|
6521
6590
|
* @returns
|
|
6522
6591
|
*/
|
|
6523
|
-
|
|
6524
|
-
D &&
|
|
6525
|
-
const $ = `${
|
|
6526
|
-
return
|
|
6527
|
-
...
|
|
6592
|
+
K(this, "connect", async (D = "") => {
|
|
6593
|
+
D && _t(this, Rt, D), G(this, yt) && await G(this, yt).close();
|
|
6594
|
+
const $ = `${G(this, ft).url}?s=${G(this, Rt)}&t=${Date.now()}`;
|
|
6595
|
+
return _t(this, yt, new k$1({
|
|
6596
|
+
...G(this, ft),
|
|
6528
6597
|
url: $,
|
|
6529
6598
|
binaryType: "arraybuffer",
|
|
6530
|
-
onMessage:
|
|
6599
|
+
onMessage: G(this, Mt),
|
|
6531
6600
|
checkReconnect,
|
|
6532
|
-
getHeartbeatMsg:
|
|
6533
|
-
onReconnectSuccess:
|
|
6601
|
+
getHeartbeatMsg: G(this, qt),
|
|
6602
|
+
onReconnectSuccess: G(this, Ut),
|
|
6534
6603
|
onReconnectStop: (U) => this.onReconnectStop(U)
|
|
6535
|
-
})), await
|
|
6604
|
+
})), await G(this, yt).connect(), _t(this, bt, Date.now()), G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 当前广播事件", G(this, ht)), G(this, yt);
|
|
6536
6605
|
});
|
|
6537
6606
|
/**
|
|
6538
6607
|
* 关闭
|
|
6539
6608
|
*/
|
|
6540
|
-
|
|
6609
|
+
K(this, "close", async () => {
|
|
6541
6610
|
var $;
|
|
6542
|
-
|
|
6543
|
-
const D = Object.keys(
|
|
6611
|
+
G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: cws is close.");
|
|
6612
|
+
const D = Object.keys(G(this, dt));
|
|
6544
6613
|
for (const U of D) {
|
|
6545
|
-
const { destructionTimer: R } =
|
|
6614
|
+
const { destructionTimer: R } = G(this, dt)[U];
|
|
6546
6615
|
clearTimeout(R);
|
|
6547
6616
|
}
|
|
6548
|
-
|
|
6617
|
+
_t(this, dt, {}), _t(this, ht, {}), await (($ = G(this, yt)) == null ? void 0 : $.close());
|
|
6549
6618
|
});
|
|
6550
6619
|
/**
|
|
6551
6620
|
* 发送消息
|
|
6552
6621
|
* @param message Message
|
|
6553
6622
|
*/
|
|
6554
|
-
|
|
6623
|
+
K(this, "sendMessage", (D, $ = !0) => new Promise(async (U, R) => {
|
|
6555
6624
|
var L;
|
|
6556
6625
|
const { event: N, ...e } = D, o = Date.now(), A = sendMessageFormat({
|
|
6557
6626
|
event: N,
|
|
6558
6627
|
sn: +`${o}${O(1e3, 9999)}`,
|
|
6559
6628
|
time: o,
|
|
6560
|
-
valid:
|
|
6629
|
+
valid: G(this, ft).timeout,
|
|
6561
6630
|
version: 1,
|
|
6562
6631
|
compress: !1,
|
|
6563
6632
|
...e
|
|
6564
6633
|
});
|
|
6565
|
-
|
|
6634
|
+
G(this, ft).debug && (G(this, Et).call(this, "req", A), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff9700;padding:16px 0;", "------->quickvo: 发送消息↑", A)), await G(this, xt).call(this, A), N === "joinRoom" && _t(this, $t, !1), $ && G(this, Dt).call(this, A, { resolve: U, reject: R });
|
|
6566
6635
|
const M = com.quick.voice.proto.CommonReq.encode(A).finish();
|
|
6567
|
-
(L =
|
|
6636
|
+
(L = G(this, yt)) == null || L.sendMessage(M);
|
|
6568
6637
|
}));
|
|
6569
6638
|
// 接收消息
|
|
6570
|
-
|
|
6639
|
+
st(this, Mt, async (D) => {
|
|
6571
6640
|
const $ = new Uint8Array(D), U = com.quick.voice.proto.CommonRsp.decode($), { sn: R, event: N } = U, e = onMessageFormat(U);
|
|
6572
|
-
if (
|
|
6641
|
+
if (G(this, ft).debug && (G(this, Et).call(this, "res", e), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ff0097;padding:16px 0;", "------->quickvo: 响应消息↓", e)), await G(this, xt).call(this, e), N === "joinRoom" && _t(this, $t, !0), ignoreEvent.includes(N)) return;
|
|
6573
6642
|
if (notifyName_keys.includes(N))
|
|
6574
6643
|
return this.emitNotify(N, v$1(e, ["code", "data", "desc"]));
|
|
6575
|
-
const A =
|
|
6644
|
+
const A = G(this, Ct).call(this, R);
|
|
6576
6645
|
if (A) {
|
|
6577
6646
|
const { resolve: M = (F) => {
|
|
6578
6647
|
}, destruction: L = () => {
|
|
@@ -6583,10 +6652,10 @@ class CallsWebSocket {
|
|
|
6583
6652
|
/**
|
|
6584
6653
|
* 触发广播事件
|
|
6585
6654
|
* @param event 事件名称
|
|
6586
|
-
* @param
|
|
6655
|
+
* @param result 事件响应值
|
|
6587
6656
|
*/
|
|
6588
|
-
|
|
6589
|
-
const U =
|
|
6657
|
+
K(this, "emitNotify", async (D, $) => {
|
|
6658
|
+
const U = G(this, ht)[D] || [];
|
|
6590
6659
|
for (const R of U) {
|
|
6591
6660
|
const { callback: N = async () => {
|
|
6592
6661
|
} } = R;
|
|
@@ -6599,64 +6668,29 @@ class CallsWebSocket {
|
|
|
6599
6668
|
* @param _private
|
|
6600
6669
|
* @returns sn
|
|
6601
6670
|
*/
|
|
6602
|
-
|
|
6671
|
+
K(this, "addNotify", (D, $ = !1) => {
|
|
6603
6672
|
const { event: U, sn: R = pt(32) } = D;
|
|
6604
|
-
|
|
6605
|
-
const N =
|
|
6673
|
+
G(this, ht)[U] || (G(this, ht)[U] = []);
|
|
6674
|
+
const N = G(this, ht)[U], e = N.findIndex((o) => o.sn === R);
|
|
6606
6675
|
return e !== -1 && N.splice(e, 1), $ ? N.unshift(D) : N.push(D), R;
|
|
6607
6676
|
});
|
|
6608
6677
|
/**
|
|
6609
6678
|
* 移除广播
|
|
6610
6679
|
*/
|
|
6611
|
-
|
|
6680
|
+
K(this, "removeNotify", (D = []) => {
|
|
6612
6681
|
if (D.length === 0)
|
|
6613
|
-
|
|
6682
|
+
_t(this, ht, {});
|
|
6614
6683
|
else {
|
|
6615
|
-
const $ = Object.keys(
|
|
6684
|
+
const $ = Object.keys(G(this, ht));
|
|
6616
6685
|
for (const U of $)
|
|
6617
|
-
|
|
6686
|
+
G(this, ht)[U] = G(this, ht)[U].filter((R) => !D.includes(R.sn || ""));
|
|
6618
6687
|
}
|
|
6619
|
-
|
|
6688
|
+
G(this, ft).debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 移除广播事件", G(this, ht));
|
|
6620
6689
|
});
|
|
6621
|
-
|
|
6690
|
+
_t(this, ft, { ...G(this, ft), ...D });
|
|
6622
6691
|
}
|
|
6623
6692
|
}
|
|
6624
|
-
|
|
6625
|
-
const getTrackNamesFormTracks = (_, D = [], $ = "trackName") => {
|
|
6626
|
-
const U = [];
|
|
6627
|
-
for (const R of _) {
|
|
6628
|
-
const { type: N } = R;
|
|
6629
|
-
if (D.length === 0 || D.includes(N)) {
|
|
6630
|
-
const e = R[$];
|
|
6631
|
-
e && U.push(`${e}`);
|
|
6632
|
-
}
|
|
6633
|
-
}
|
|
6634
|
-
return U;
|
|
6635
|
-
}, getAverageVolume = (_, D) => {
|
|
6636
|
-
_.getByteFrequencyData(D);
|
|
6637
|
-
let $ = 0;
|
|
6638
|
-
for (let R = 0; R < D.length; R++)
|
|
6639
|
-
$ += D[R];
|
|
6640
|
-
return Math.ceil($ / D.length);
|
|
6641
|
-
}, getCallAction = async (_) => {
|
|
6642
|
-
let D = "";
|
|
6643
|
-
const $ = (R) => _.findIndex(({ type: e, enabled: o = !0 }) => e === R && o) === -1 ? "0" : "1";
|
|
6644
|
-
return D = `${$(0)}${D}`, D = `${$(1)}${D}`, D = `${$(2)}${D}`, D = `${$(3)}${D}`, parseInt(D, 2);
|
|
6645
|
-
}, getCallActionMap = (_ = 0) => {
|
|
6646
|
-
const $ = Number(_).toString(2).padStart(4, "0").split(""), [U, R, N, e] = $;
|
|
6647
|
-
return {
|
|
6648
|
-
microphoneCamera_audio: !!Number(e),
|
|
6649
|
-
microphoneCamera_video: !!Number(N),
|
|
6650
|
-
screenSharing_video: !!Number(R),
|
|
6651
|
-
screenSharing_audio: !!Number(U)
|
|
6652
|
-
};
|
|
6653
|
-
}, tools = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
6654
|
-
__proto__: null,
|
|
6655
|
-
getAverageVolume,
|
|
6656
|
-
getCallAction,
|
|
6657
|
-
getCallActionMap,
|
|
6658
|
-
getTrackNamesFormTracks
|
|
6659
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
6693
|
+
yt = new WeakMap(), ft = new WeakMap(), Rt = new WeakMap(), $t = new WeakMap(), bt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), qt = new WeakMap(), Et = new WeakMap(), xt = new WeakMap(), Dt = new WeakMap(), Ct = new WeakMap(), Ut = new WeakMap(), Mt = new WeakMap();
|
|
6660
6694
|
var l = Object.defineProperty, y = (_) => {
|
|
6661
6695
|
throw TypeError(_);
|
|
6662
6696
|
}, q = (_, D, $) => D in _ ? l(_, D, { enumerable: !0, configurable: !0, writable: !0, value: $ }) : _[D] = $, s = (_, D, $) => q(_, typeof D != "symbol" ? D + "" : D, $), P = (_, D, $) => D.has(_) || y("Cannot " + $), n = (_, D, $) => (P(_, D, "read from private field"), $ ? $.call(_) : D.get(_)), m = (_, D, $) => D.has(_) ? y("Cannot add the same private member more than once") : D instanceof WeakSet ? D.add(_) : D.set(_, $), a, d, u;
|
|
@@ -6691,7 +6725,7 @@ class k {
|
|
|
6691
6725
|
a = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap();
|
|
6692
6726
|
class RoomBase {
|
|
6693
6727
|
constructor() {
|
|
6694
|
-
|
|
6728
|
+
K(this, "options", {
|
|
6695
6729
|
appid: "",
|
|
6696
6730
|
sdkToken: "",
|
|
6697
6731
|
roomId: "",
|
|
@@ -6700,18 +6734,21 @@ class RoomBase {
|
|
|
6700
6734
|
debug: !1,
|
|
6701
6735
|
newPublishAutoSubscribe: !0
|
|
6702
6736
|
});
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6737
|
+
K(this, "prohibitNotify", !1);
|
|
6738
|
+
// 是否禁止通知
|
|
6739
|
+
K(this, "asyncQueue", new k());
|
|
6740
|
+
// 异步队列
|
|
6741
|
+
K(this, "state", "ready");
|
|
6706
6742
|
// 房间状态
|
|
6707
|
-
|
|
6743
|
+
K(this, "createAt", Date.now());
|
|
6708
6744
|
// 创建时间
|
|
6709
|
-
|
|
6745
|
+
K(this, "cwsIns", new CallsWebSocket());
|
|
6710
6746
|
// SDK通讯实例 // SDK通讯实例
|
|
6711
|
-
|
|
6712
|
-
|
|
6747
|
+
K(this, "peerIns", new RTCPeerConnection({ bundlePolicy: "max-bundle" }));
|
|
6748
|
+
K(this, "userMap", /* @__PURE__ */ new Map());
|
|
6749
|
+
// 用户
|
|
6713
6750
|
// 设备错误信息
|
|
6714
|
-
|
|
6751
|
+
K(this, "mediaDevicesErrInfo", {
|
|
6715
6752
|
microphoneCamera_audio: "",
|
|
6716
6753
|
microphoneCamera_video: "",
|
|
6717
6754
|
screenSharing_video: "",
|
|
@@ -6720,35 +6757,35 @@ class RoomBase {
|
|
|
6720
6757
|
/**
|
|
6721
6758
|
* 获取房间信息
|
|
6722
6759
|
*/
|
|
6723
|
-
|
|
6760
|
+
K(this, "getRoomInfo", () => {
|
|
6724
6761
|
const { options: D, state: $, createAt: U } = this;
|
|
6725
6762
|
return { ...D, state: $, createAt: U };
|
|
6726
6763
|
});
|
|
6727
6764
|
/**
|
|
6728
6765
|
* 设置房间状态
|
|
6729
6766
|
*/
|
|
6730
|
-
|
|
6767
|
+
K(this, "setRoomState", (D) => {
|
|
6731
6768
|
this.state = D;
|
|
6732
6769
|
const $ = enum_roomState[D], U = { state: D, stateStr: $ };
|
|
6733
|
-
this.cwsIns.emitNotify("onRoomState", { code: 200, data: U });
|
|
6770
|
+
this.cwsIns.emitNotify("onRoomState", { code: 200, data: U, desc: "room state is change." });
|
|
6734
6771
|
});
|
|
6735
6772
|
/**
|
|
6736
6773
|
* 设置属性
|
|
6737
6774
|
*/
|
|
6738
|
-
|
|
6775
|
+
K(this, "setOptions", async (D) => {
|
|
6739
6776
|
const $ = { ...this.options, ...D };
|
|
6740
6777
|
this.options = $;
|
|
6741
6778
|
});
|
|
6742
6779
|
/**
|
|
6743
6780
|
* 初始化通讯实例
|
|
6744
6781
|
*/
|
|
6745
|
-
|
|
6782
|
+
K(this, "initCwsCall", () => {
|
|
6746
6783
|
this.cwsIns = new CallsWebSocket({ ...this.options });
|
|
6747
6784
|
});
|
|
6748
6785
|
/**
|
|
6749
6786
|
* 获取媒体设备错误信息
|
|
6750
6787
|
*/
|
|
6751
|
-
|
|
6788
|
+
K(this, "getMediaDevicesErrInfo", async () => {
|
|
6752
6789
|
try {
|
|
6753
6790
|
const D = await navigator.mediaDevices.enumerateDevices();
|
|
6754
6791
|
D.find((U) => U.kind === "audioinput") || (this.mediaDevicesErrInfo.microphoneCamera_audio = "audioinput is not available."), D.find((U) => U.kind === "videoinput") || (this.mediaDevicesErrInfo.microphoneCamera_video = "videoinput is not available.");
|
|
@@ -6757,207 +6794,352 @@ class RoomBase {
|
|
|
6757
6794
|
}
|
|
6758
6795
|
return this.mediaDevicesErrInfo;
|
|
6759
6796
|
});
|
|
6797
|
+
/**
|
|
6798
|
+
* 获取MediaKey
|
|
6799
|
+
*/
|
|
6800
|
+
K(this, "getUserMediaKey", (D, $) => `${D}-${$}`);
|
|
6801
|
+
/**
|
|
6802
|
+
* 获取 CallAction map
|
|
6803
|
+
*/
|
|
6804
|
+
K(this, "getCallActionMap", (D = 0) => {
|
|
6805
|
+
const U = Number(D).toString(2).padStart(4, "0").split(""), [R, N, e, o] = U;
|
|
6806
|
+
return {
|
|
6807
|
+
microphoneCamera_audio: !!Number(o),
|
|
6808
|
+
microphoneCamera_video: !!Number(e),
|
|
6809
|
+
screenSharing_video: !!Number(N),
|
|
6810
|
+
screenSharing_audio: !!Number(R)
|
|
6811
|
+
};
|
|
6812
|
+
});
|
|
6813
|
+
/**
|
|
6814
|
+
* 获取音量
|
|
6815
|
+
*/
|
|
6816
|
+
K(this, "getAverageVolume", (D, $) => {
|
|
6817
|
+
D.getByteFrequencyData($);
|
|
6818
|
+
let U = 0;
|
|
6819
|
+
for (let N = 0; N < $.length; N++)
|
|
6820
|
+
U += $[N];
|
|
6821
|
+
return Math.ceil(U / $.length);
|
|
6822
|
+
});
|
|
6823
|
+
/**
|
|
6824
|
+
* 通过轨道计算当前用户的通话状态
|
|
6825
|
+
*/
|
|
6826
|
+
K(this, "getCallAction", async (D) => {
|
|
6827
|
+
let $ = "";
|
|
6828
|
+
const U = (N) => D.findIndex(({ type: o, enabled: A = !0 }) => o === N && A) === -1 ? "0" : "1";
|
|
6829
|
+
return $ = `${U(0)}${$}`, $ = `${U(1)}${$}`, $ = `${U(2)}${$}`, $ = `${U(3)}${$}`, parseInt($, 2);
|
|
6830
|
+
});
|
|
6831
|
+
/**
|
|
6832
|
+
* 获取指定轨道的名称数组
|
|
6833
|
+
* @param tracks 轨道
|
|
6834
|
+
* @param types number[] = []
|
|
6835
|
+
* @param keyName
|
|
6836
|
+
* @returns string[]
|
|
6837
|
+
*/
|
|
6838
|
+
K(this, "getTrackNamesFormTracks", (D, $ = [], U = "trackName") => {
|
|
6839
|
+
const R = [];
|
|
6840
|
+
for (const N of D) {
|
|
6841
|
+
const { type: e } = N;
|
|
6842
|
+
if ($.length === 0 || $.includes(e)) {
|
|
6843
|
+
const o = N[U];
|
|
6844
|
+
o && R.push(`${o}`);
|
|
6845
|
+
}
|
|
6846
|
+
}
|
|
6847
|
+
return R;
|
|
6848
|
+
});
|
|
6849
|
+
/**
|
|
6850
|
+
* 处理为应用层数据
|
|
6851
|
+
*/
|
|
6852
|
+
K(this, "usersFilter", (D) => mt(D, ["id", "isSelf", "joinTime", "tracks", "callAction", "callActionStr", "callActionMap", "network", "updateStreams", "permissions", "isPublished"]).sort((R, N) => R.id.localeCompare(N.id, "en")));
|
|
6760
6853
|
}
|
|
6761
6854
|
}
|
|
6762
|
-
|
|
6855
|
+
var wt, vt, kt, Pt, Bt, It, Lt;
|
|
6856
|
+
class RoomMedias extends RoomBase {
|
|
6857
|
+
// 媒体流上下文
|
|
6763
6858
|
constructor() {
|
|
6764
6859
|
super();
|
|
6765
|
-
|
|
6766
|
-
//
|
|
6767
|
-
|
|
6768
|
-
//
|
|
6769
|
-
|
|
6860
|
+
K(this, "mediaDevices", []);
|
|
6861
|
+
// 可用媒体设备列表
|
|
6862
|
+
st(this, wt, /* @__PURE__ */ new Map());
|
|
6863
|
+
// 媒体流设备管理
|
|
6864
|
+
st(this, vt, /* @__PURE__ */ new Map());
|
|
6865
|
+
// 媒体轨道参数管理
|
|
6866
|
+
st(this, kt, /* @__PURE__ */ new Map());
|
|
6770
6867
|
/**
|
|
6771
|
-
*
|
|
6868
|
+
* 初始化媒体参数
|
|
6772
6869
|
*/
|
|
6773
|
-
|
|
6870
|
+
st(this, Pt, () => {
|
|
6871
|
+
G(this, vt).set("microphoneCamera_audio", {}), G(this, vt).set("microphoneCamera_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), G(this, vt).set("screenSharing_video", { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }), G(this, vt).set("screenSharing_audio", {});
|
|
6872
|
+
});
|
|
6774
6873
|
/**
|
|
6775
|
-
*
|
|
6874
|
+
* 初始化媒体设备类型
|
|
6776
6875
|
*/
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
switch ($) {
|
|
6780
|
-
// 音频媒体处理
|
|
6781
|
-
case "microphoneCamera_audio":
|
|
6782
|
-
case "screenSharing_audio":
|
|
6783
|
-
U = "audio";
|
|
6784
|
-
break;
|
|
6785
|
-
// 视频媒体处理
|
|
6786
|
-
case "microphoneCamera_video":
|
|
6787
|
-
case "screenSharing_video":
|
|
6788
|
-
U = "video";
|
|
6789
|
-
break;
|
|
6790
|
-
}
|
|
6791
|
-
return U;
|
|
6876
|
+
st(this, Bt, () => {
|
|
6877
|
+
G(this, wt).set("audioinput", "default"), G(this, wt).set("videoinput", "default"), G(this, wt).set("audiooutput", "default");
|
|
6792
6878
|
});
|
|
6793
6879
|
/**
|
|
6794
|
-
*
|
|
6880
|
+
* 房间所有用户所有媒体流变化
|
|
6795
6881
|
*/
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
if (e.length !== 0) {
|
|
6799
|
-
for (const o of e) {
|
|
6800
|
-
const M = { ...o.getConstraints(), ...R };
|
|
6801
|
-
await o.applyConstraints(M);
|
|
6802
|
-
}
|
|
6803
|
-
await this.initUserMediaStreamContext($, U, N);
|
|
6804
|
-
}
|
|
6882
|
+
K(this, "emitNotifyUpdateUsersStreams", async ($) => {
|
|
6883
|
+
this.prohibitNotify || this.cwsIns.emitNotify("onRoomUsersStreams", { code: 200, data: $, desc: "users streams is change." });
|
|
6805
6884
|
});
|
|
6806
6885
|
/**
|
|
6807
6886
|
* 初始化用户媒体上下文
|
|
6808
6887
|
*/
|
|
6809
|
-
|
|
6888
|
+
K(this, "initUserMediaStreamContext", async ($, U, R) => {
|
|
6810
6889
|
var A;
|
|
6811
|
-
const N =
|
|
6812
|
-
if (
|
|
6890
|
+
const [N] = R.getTracks();
|
|
6891
|
+
if (!N) {
|
|
6813
6892
|
console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: tracks.length is 0.", { userId: $, mediaType: U, stream: R });
|
|
6814
6893
|
return;
|
|
6815
6894
|
}
|
|
6816
|
-
|
|
6895
|
+
this.removeUserMediaStreamContext($, U);
|
|
6896
|
+
const e = this.getUserMediaKey($, U), { kind: o } = N;
|
|
6897
|
+
switch (o) {
|
|
6817
6898
|
// 音频媒体处理
|
|
6818
6899
|
case "audio":
|
|
6819
6900
|
{
|
|
6820
|
-
const M = new
|
|
6821
|
-
|
|
6822
|
-
(A = M.audioContext) == null || A.setSinkId(this.audioOutput);
|
|
6823
|
-
} catch (L) {
|
|
6824
|
-
console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error", L);
|
|
6825
|
-
}
|
|
6826
|
-
this.audioMediaStreamContextMap.set(N, M);
|
|
6901
|
+
const M = new AudioMediaContext(N);
|
|
6902
|
+
G(this, kt).set(e, M);
|
|
6827
6903
|
}
|
|
6828
6904
|
break;
|
|
6829
6905
|
// 视频媒体处理
|
|
6830
6906
|
case "video":
|
|
6831
6907
|
{
|
|
6832
|
-
const M = new
|
|
6833
|
-
this.
|
|
6908
|
+
const M = new VideoMediaContext(N);
|
|
6909
|
+
G(this, kt).set(e, M);
|
|
6834
6910
|
}
|
|
6835
6911
|
break;
|
|
6836
6912
|
}
|
|
6913
|
+
{
|
|
6914
|
+
const M = this.getUserMediaStreamContext($, U);
|
|
6915
|
+
if (M && M.kind === "audio")
|
|
6916
|
+
try {
|
|
6917
|
+
const L = G(this, wt).get("audiooutput");
|
|
6918
|
+
(A = M.audioContext) == null || A.setSinkId(L);
|
|
6919
|
+
} catch (L) {
|
|
6920
|
+
console.warn("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: setSinkId is error", L);
|
|
6921
|
+
}
|
|
6922
|
+
}
|
|
6923
|
+
});
|
|
6924
|
+
/**
|
|
6925
|
+
* 获取用户媒体流上下文
|
|
6926
|
+
*/
|
|
6927
|
+
K(this, "getUserMediaStreamContext", ($, U) => {
|
|
6928
|
+
const R = this.getUserMediaKey($, U);
|
|
6929
|
+
return G(this, kt).get(R);
|
|
6930
|
+
});
|
|
6931
|
+
/**
|
|
6932
|
+
* 获取用户音频媒体流上下文
|
|
6933
|
+
*/
|
|
6934
|
+
K(this, "getUserAudioMediaStreamContext", ($, U) => {
|
|
6935
|
+
const R = this.getUserMediaKey($, U);
|
|
6936
|
+
return G(this, kt).get(R);
|
|
6937
|
+
});
|
|
6938
|
+
/**
|
|
6939
|
+
* 删除用户媒体流上下文
|
|
6940
|
+
*/
|
|
6941
|
+
K(this, "removeUserMediaStreamContext", ($, U) => {
|
|
6942
|
+
const R = this.getUserMediaKey($, U), N = G(this, kt).get(R);
|
|
6943
|
+
N == null || N.stop(), G(this, kt).delete(R);
|
|
6837
6944
|
});
|
|
6838
6945
|
/**
|
|
6839
6946
|
* 获取某个用户的某个数据流
|
|
6840
6947
|
*/
|
|
6841
|
-
|
|
6842
|
-
const R = this.
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6948
|
+
K(this, "getUserStream", ($, U) => {
|
|
6949
|
+
const R = this.getUserMediaStreamContext($, U);
|
|
6950
|
+
return (R == null ? void 0 : R.getStream()) || new MediaStream();
|
|
6951
|
+
});
|
|
6952
|
+
/**
|
|
6953
|
+
* 获取某个用户的某些数据流
|
|
6954
|
+
*/
|
|
6955
|
+
K(this, "getUserStreams", ($, U = []) => {
|
|
6956
|
+
U.length === 0 && (U = mediaType_keys);
|
|
6957
|
+
const R = {};
|
|
6958
|
+
for (const N of U) {
|
|
6959
|
+
const e = this.getUserStream($, N);
|
|
6960
|
+
R[N] = e;
|
|
6961
|
+
}
|
|
6962
|
+
return R;
|
|
6963
|
+
});
|
|
6964
|
+
/**
|
|
6965
|
+
* 删除某个用户的某些数据流
|
|
6966
|
+
*/
|
|
6967
|
+
K(this, "removeUserStreams", async ($, U = []) => {
|
|
6968
|
+
U.length === 0 && (U = mediaType_keys);
|
|
6969
|
+
for (const R of U)
|
|
6970
|
+
this.removeUserMediaStreamContext($, R);
|
|
6971
|
+
});
|
|
6972
|
+
/**
|
|
6973
|
+
* 清除所有媒体流使用
|
|
6974
|
+
*/
|
|
6975
|
+
K(this, "clearUserStreams", async () => {
|
|
6976
|
+
const $ = G(this, kt).values();
|
|
6977
|
+
for (const U of $)
|
|
6978
|
+
U.stop();
|
|
6979
|
+
_t(this, kt, /* @__PURE__ */ new Map());
|
|
6980
|
+
});
|
|
6981
|
+
/**
|
|
6982
|
+
* 设置轨道媒体参数
|
|
6983
|
+
*/
|
|
6984
|
+
K(this, "setMediaTrackConstraints", async ($, U) => {
|
|
6985
|
+
G(this, vt).set($, U);
|
|
6986
|
+
const N = this.getUserStream(this.options.userId, $).getTracks();
|
|
6987
|
+
if (N.length !== 0)
|
|
6988
|
+
for (const e of N) {
|
|
6989
|
+
const A = { ...e.getConstraints(), ...U };
|
|
6990
|
+
await e.applyConstraints(A);
|
|
6991
|
+
}
|
|
6992
|
+
});
|
|
6993
|
+
/**
|
|
6994
|
+
* 改变本地流
|
|
6995
|
+
* @param mediaType MediaType
|
|
6996
|
+
* @param active 激活状态
|
|
6997
|
+
* @example quickvo.setLocalStream('microphoneCamera_audio', false)
|
|
6998
|
+
* @returns Promise<Streams>
|
|
6999
|
+
*/
|
|
7000
|
+
K(this, "changeLocalStream", async ($) => {
|
|
7001
|
+
const { userId: U } = this.options, R = G(this, vt).get($);
|
|
7002
|
+
switch ($) {
|
|
7003
|
+
// 麦克风
|
|
7004
|
+
case "microphoneCamera_audio":
|
|
6847
7005
|
{
|
|
6848
|
-
const
|
|
6849
|
-
|
|
7006
|
+
const N = G(this, wt).get("audioinput"), e = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: N, ...R }, video: !1 });
|
|
7007
|
+
await this.initUserMediaStreamContext(U, "microphoneCamera_audio", e);
|
|
6850
7008
|
}
|
|
6851
7009
|
break;
|
|
6852
|
-
//
|
|
6853
|
-
case "
|
|
7010
|
+
// 摄像头
|
|
7011
|
+
case "microphoneCamera_video":
|
|
7012
|
+
{
|
|
7013
|
+
const N = G(this, wt).get("videoinput"), e = await navigator.mediaDevices.getUserMedia({ audio: !1, video: { deviceId: N, ...R } });
|
|
7014
|
+
await this.initUserMediaStreamContext(U, "microphoneCamera_video", e);
|
|
7015
|
+
}
|
|
7016
|
+
break;
|
|
7017
|
+
// 屏幕共享 音频
|
|
7018
|
+
case "screenSharing_audio":
|
|
6854
7019
|
{
|
|
6855
|
-
const
|
|
6856
|
-
|
|
7020
|
+
const N = await navigator.mediaDevices.getDisplayMedia({ audio: !0, video: !0, ...R }), e = N.getTracks();
|
|
7021
|
+
for (const o of e) {
|
|
7022
|
+
const { kind: A } = o, M = new MediaStream();
|
|
7023
|
+
M.addTrack(o), N.removeTrack(o), A === "audio" && await this.initUserMediaStreamContext(U, "screenSharing_audio", M), A === "video" && await this.initUserMediaStreamContext(U, "screenSharing_video", M);
|
|
7024
|
+
}
|
|
7025
|
+
}
|
|
7026
|
+
break;
|
|
7027
|
+
// 屏幕共享 视频
|
|
7028
|
+
case "screenSharing_video":
|
|
7029
|
+
{
|
|
7030
|
+
const N = await navigator.mediaDevices.getDisplayMedia({ audio: !1, video: !0, ...R });
|
|
7031
|
+
await this.initUserMediaStreamContext(U, "screenSharing_video", N);
|
|
6857
7032
|
}
|
|
6858
7033
|
break;
|
|
6859
7034
|
}
|
|
6860
|
-
|
|
7035
|
+
this.emitNotifyUpdateUsersStreams([{ userId: U, updateStreams: { [$]: !0 } }]);
|
|
6861
7036
|
});
|
|
6862
7037
|
/**
|
|
6863
|
-
*
|
|
7038
|
+
* 获取媒体设备列表
|
|
6864
7039
|
*/
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
}
|
|
6871
|
-
return U;
|
|
6872
|
-
});
|
|
7040
|
+
st(this, It, 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(($) => {
|
|
7041
|
+
this.mediaDevices = $;
|
|
7042
|
+
}).catch(function($) {
|
|
7043
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: getEnumerateDevices is err", $);
|
|
7044
|
+
}), this.mediaDevices));
|
|
6873
7045
|
/**
|
|
6874
|
-
*
|
|
7046
|
+
* 媒体设备发生变化
|
|
6875
7047
|
*/
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
7048
|
+
st(this, Lt, () => {
|
|
7049
|
+
navigator.mediaDevices.ondevicechange = async () => {
|
|
7050
|
+
await G(this, It).call(this), this.cwsIns.emitNotify("onDevicechange", { code: 200, data: {}, desc: "device is change." });
|
|
7051
|
+
}, G(this, It).call(this);
|
|
6879
7052
|
});
|
|
6880
7053
|
/**
|
|
6881
|
-
*
|
|
7054
|
+
* 获取正在使用的媒体设备ID
|
|
7055
|
+
* @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
|
|
7056
|
+
* @returns deviceId 设备ID
|
|
6882
7057
|
*/
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
7058
|
+
K(this, "getMediaDeviceKind", ($) => G(this, wt).get($));
|
|
7059
|
+
/**
|
|
7060
|
+
* 替换发射器媒体流
|
|
7061
|
+
*/
|
|
7062
|
+
K(this, "replaceSenderStream", async ($, U) => {
|
|
7063
|
+
var A;
|
|
7064
|
+
const R = this.userMap.get(this.options.userId);
|
|
7065
|
+
if (!R) return;
|
|
7066
|
+
const { mid: N } = R.tracks.find((M) => M.mediaType === $) || {};
|
|
7067
|
+
if (!N) return;
|
|
7068
|
+
const [e] = U.getTracks(), o = this.peerIns.getTransceivers();
|
|
7069
|
+
for (const M of o) {
|
|
7070
|
+
const { sender: L } = M;
|
|
7071
|
+
M.mid === N && ((A = L.track) == null || A.stop(), L.replaceTrack(e));
|
|
6888
7072
|
}
|
|
6889
7073
|
});
|
|
6890
7074
|
/**
|
|
6891
|
-
*
|
|
7075
|
+
* 设置正在使用的媒体设备
|
|
7076
|
+
* @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
|
|
7077
|
+
* @param deviceId 设备ID
|
|
6892
7078
|
*/
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
this.
|
|
7079
|
+
K(this, "setMediaDeviceKind", async ($, U) => {
|
|
7080
|
+
var N;
|
|
7081
|
+
G(this, wt).set($, U);
|
|
7082
|
+
const { userId: R } = this.options;
|
|
7083
|
+
if ($ === "audioinput" && this.getUserMediaStreamContext(R, "microphoneCamera_audio")) {
|
|
7084
|
+
await this.changeLocalStream("microphoneCamera_audio");
|
|
7085
|
+
const o = this.getUserStream(this.options.userId, "microphoneCamera_audio");
|
|
7086
|
+
await this.replaceSenderStream("microphoneCamera_audio", o);
|
|
6899
7087
|
}
|
|
6900
|
-
{
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
7088
|
+
if ($ === "videoinput" && this.getUserMediaStreamContext(R, "microphoneCamera_video")) {
|
|
7089
|
+
await this.changeLocalStream("microphoneCamera_video");
|
|
7090
|
+
const o = this.getUserStream(this.options.userId, "microphoneCamera_video");
|
|
7091
|
+
await this.replaceSenderStream("microphoneCamera_video", o);
|
|
7092
|
+
}
|
|
7093
|
+
if ($ === "audiooutput") {
|
|
7094
|
+
const e = G(this, kt).values();
|
|
7095
|
+
for (const o of e)
|
|
7096
|
+
(N = o.audioContext) == null || N.setSinkId(U);
|
|
6905
7097
|
}
|
|
6906
7098
|
});
|
|
6907
7099
|
/**
|
|
6908
|
-
*
|
|
7100
|
+
* 设置音频输出设备
|
|
7101
|
+
* @param deviceId 设备ID
|
|
7102
|
+
* @returns
|
|
6909
7103
|
*/
|
|
6910
|
-
|
|
6911
|
-
const U = $.getTracks();
|
|
6912
|
-
for (const R of U)
|
|
6913
|
-
R.enabled = !1, R.stop(), $.removeTrack(R);
|
|
6914
|
-
$ = new MediaStream();
|
|
6915
|
-
});
|
|
7104
|
+
K(this, "setAudioOutputDevice", ($) => this.setMediaDeviceKind("audiooutput", $));
|
|
6916
7105
|
/**
|
|
6917
|
-
*
|
|
7106
|
+
* 获取可用设备
|
|
7107
|
+
* @param mediaDeviceKind 设备类型 "audioinput" | "audiooutput" | "videoinput"
|
|
7108
|
+
* @returns MediaDeviceInfo[]
|
|
6918
7109
|
*/
|
|
6919
|
-
|
|
6920
|
-
this.mediaDevices = $.filter((U) => U.kind === "audiooutput");
|
|
6921
|
-
}).catch(function($) {
|
|
6922
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: err", $);
|
|
6923
|
-
}), this.mediaDevices));
|
|
7110
|
+
K(this, "getEnumerateDevices", async ($) => (await G(this, It).call(this), this.mediaDevices.filter((R) => R.kind === $)));
|
|
6924
7111
|
/**
|
|
6925
|
-
*
|
|
7112
|
+
* 获取可用音频输入设备
|
|
7113
|
+
* @returns MediaDeviceInfo[]
|
|
6926
7114
|
*/
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
7115
|
+
K(this, "getEnumerateAudioinputDevices", () => this.getEnumerateDevices("audioinput"));
|
|
7116
|
+
/**
|
|
7117
|
+
* 获取可用音频输出设备
|
|
7118
|
+
* @returns MediaDeviceInfo[]
|
|
7119
|
+
*/
|
|
7120
|
+
K(this, "getEnumerateAudioOutputDevices", () => this.getEnumerateDevices("audiooutput"));
|
|
7121
|
+
/**
|
|
7122
|
+
* 获取可用视频输入设备
|
|
7123
|
+
* @returns MediaDeviceInfo[]
|
|
7124
|
+
*/
|
|
7125
|
+
K(this, "getEnumerateVideoinputDevices", () => this.getEnumerateDevices("videoinput"));
|
|
7126
|
+
G(this, Lt).call(this), G(this, Bt).call(this), G(this, Pt).call(this);
|
|
6935
7127
|
}
|
|
6936
7128
|
}
|
|
6937
|
-
|
|
6938
|
-
|
|
7129
|
+
wt = new WeakMap(), vt = new WeakMap(), kt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), It = new WeakMap(), Lt = new WeakMap();
|
|
7130
|
+
class RoomUsers extends RoomMedias {
|
|
6939
7131
|
constructor() {
|
|
6940
7132
|
super();
|
|
6941
|
-
W(this, "userMap", /* @__PURE__ */ new Map());
|
|
6942
|
-
// 用户
|
|
6943
|
-
W(this, "prohibitNotify", !1);
|
|
6944
|
-
/**
|
|
6945
|
-
* 获取用户音频处理上下文
|
|
6946
|
-
*/
|
|
6947
|
-
W(this, "getUserAudioMediaStreamContext", ($, U) => {
|
|
6948
|
-
const R = this.getUserMediaKey($, U);
|
|
6949
|
-
return this.audioMediaStreamContextMap.get(R);
|
|
6950
|
-
});
|
|
6951
7133
|
/**
|
|
6952
7134
|
* 获取最大音量用户
|
|
6953
7135
|
*/
|
|
6954
|
-
|
|
7136
|
+
K(this, "getMaxVolumeUser", () => {
|
|
6955
7137
|
const $ = Array.from(this.userMap.values(), ({ id: R }) => R);
|
|
6956
7138
|
if ($.length === 0) return;
|
|
6957
7139
|
let U = [];
|
|
6958
7140
|
for (const R of $) {
|
|
6959
|
-
const N = this.
|
|
6960
|
-
if (!N) continue;
|
|
7141
|
+
const N = this.getUserMediaStreamContext(R, "microphoneCamera_audio");
|
|
7142
|
+
if (!N || N.kind !== "audio") continue;
|
|
6961
7143
|
const e = N.getVolume();
|
|
6962
7144
|
U.push({ id: R, volume: e });
|
|
6963
7145
|
}
|
|
@@ -6966,16 +7148,16 @@ class RoomUsers extends MediaStreams {
|
|
|
6966
7148
|
/**
|
|
6967
7149
|
* 设置音频过滤
|
|
6968
7150
|
*/
|
|
6969
|
-
|
|
7151
|
+
K(this, "setAudioFilter", async ($ = {}) => {
|
|
6970
7152
|
const U = await this.getUsersId();
|
|
6971
7153
|
for (const R of U) {
|
|
6972
7154
|
{
|
|
6973
|
-
const N = this.
|
|
6974
|
-
N == null || N.setFilter($);
|
|
7155
|
+
const N = this.getUserMediaStreamContext(R, "microphoneCamera_audio");
|
|
7156
|
+
(N == null ? void 0 : N.kind) === "audio" && (N == null || N.setFilter($));
|
|
6975
7157
|
}
|
|
6976
7158
|
{
|
|
6977
|
-
const N = this.
|
|
6978
|
-
N == null || N.setFilter($);
|
|
7159
|
+
const N = this.getUserMediaStreamContext(R, "screenSharing_audio");
|
|
7160
|
+
(N == null ? void 0 : N.kind) === "audio" && (N == null || N.setFilter($));
|
|
6979
7161
|
}
|
|
6980
7162
|
}
|
|
6981
7163
|
});
|
|
@@ -6984,9 +7166,9 @@ class RoomUsers extends MediaStreams {
|
|
|
6984
7166
|
* @param userId
|
|
6985
7167
|
* @param mediaType
|
|
6986
7168
|
*/
|
|
6987
|
-
|
|
6988
|
-
const N = this.
|
|
6989
|
-
N == null || N.setVolumeGain(R);
|
|
7169
|
+
K(this, "setVolume", ($, U, R) => {
|
|
7170
|
+
const N = this.getUserMediaStreamContext($, U);
|
|
7171
|
+
(N == null ? void 0 : N.kind) === "audio" && (N == null || N.setVolumeGain(R));
|
|
6990
7172
|
});
|
|
6991
7173
|
/**
|
|
6992
7174
|
* 获取声音大小
|
|
@@ -6994,27 +7176,28 @@ class RoomUsers extends MediaStreams {
|
|
|
6994
7176
|
* @param mediaType
|
|
6995
7177
|
* @returns volume
|
|
6996
7178
|
*/
|
|
6997
|
-
|
|
6998
|
-
const R = this.
|
|
6999
|
-
|
|
7179
|
+
K(this, "getVolume", ($, U) => {
|
|
7180
|
+
const R = this.getUserMediaStreamContext($, U);
|
|
7181
|
+
let N = 0;
|
|
7182
|
+
return (R == null ? void 0 : R.kind) === "audio" && (N = R == null ? void 0 : R.getVolume()), N;
|
|
7000
7183
|
});
|
|
7001
7184
|
/**
|
|
7002
7185
|
* 清除房间所有用户
|
|
7003
7186
|
*/
|
|
7004
|
-
|
|
7187
|
+
K(this, "clearUsers", () => {
|
|
7005
7188
|
this.userMap = /* @__PURE__ */ new Map();
|
|
7006
7189
|
});
|
|
7007
7190
|
/**
|
|
7008
7191
|
* 删除用户
|
|
7009
7192
|
*/
|
|
7010
|
-
|
|
7193
|
+
K(this, "removeUsers", async ($) => {
|
|
7011
7194
|
for (const U of $)
|
|
7012
7195
|
this.userMap.delete(U), await this.removeUserStreams(U);
|
|
7013
7196
|
});
|
|
7014
7197
|
/**
|
|
7015
7198
|
* 创建一个用户
|
|
7016
7199
|
*/
|
|
7017
|
-
|
|
7200
|
+
K(this, "createUser", async ($) => {
|
|
7018
7201
|
const U = Date.now(), R = {
|
|
7019
7202
|
id: $,
|
|
7020
7203
|
permissions: 0,
|
|
@@ -7045,11 +7228,11 @@ class RoomUsers extends MediaStreams {
|
|
|
7045
7228
|
/**
|
|
7046
7229
|
* 获取某个用户
|
|
7047
7230
|
*/
|
|
7048
|
-
|
|
7231
|
+
K(this, "getUser", async ($) => (this.userMap.has($) || await this.createUser($), this.userMap.get($)));
|
|
7049
7232
|
/**
|
|
7050
7233
|
* 获取某些用户
|
|
7051
7234
|
*/
|
|
7052
|
-
|
|
7235
|
+
K(this, "getUsers", async ($ = []) => {
|
|
7053
7236
|
$.length === 0 && ($ = [...this.userMap.keys()]);
|
|
7054
7237
|
const U = [];
|
|
7055
7238
|
for (const R of $) {
|
|
@@ -7061,7 +7244,7 @@ class RoomUsers extends MediaStreams {
|
|
|
7061
7244
|
/**
|
|
7062
7245
|
* 获取当前用户轨道所有mid
|
|
7063
7246
|
*/
|
|
7064
|
-
|
|
7247
|
+
K(this, "getAllUserTrackMids", async () => {
|
|
7065
7248
|
const $ = await this.getUsers(), U = [];
|
|
7066
7249
|
for (const R of $) {
|
|
7067
7250
|
const { tracks: N = [] } = R;
|
|
@@ -7073,7 +7256,7 @@ class RoomUsers extends MediaStreams {
|
|
|
7073
7256
|
/**
|
|
7074
7257
|
* 通过 trackName 查询所属 UserTrack
|
|
7075
7258
|
*/
|
|
7076
|
-
|
|
7259
|
+
K(this, "getUserTrackByTrackName", async ($) => {
|
|
7077
7260
|
const U = await this.getUsers(), R = [];
|
|
7078
7261
|
for (const N of U) {
|
|
7079
7262
|
const { tracks: e = [] } = N;
|
|
@@ -7087,7 +7270,7 @@ class RoomUsers extends MediaStreams {
|
|
|
7087
7270
|
/**
|
|
7088
7271
|
* 通过 mid 查询所属 UserTrack
|
|
7089
7272
|
*/
|
|
7090
|
-
|
|
7273
|
+
K(this, "getUserTrackFromMid", async ($) => {
|
|
7091
7274
|
const U = await this.getUsers();
|
|
7092
7275
|
let R;
|
|
7093
7276
|
for (const N of U) {
|
|
@@ -7103,36 +7286,36 @@ class RoomUsers extends MediaStreams {
|
|
|
7103
7286
|
/**
|
|
7104
7287
|
* 检查用户是否存在房间内
|
|
7105
7288
|
*/
|
|
7106
|
-
|
|
7289
|
+
K(this, "checkUserInRoom", ($) => this.userMap.has($));
|
|
7107
7290
|
/**
|
|
7108
7291
|
* 获取房间全部用户id
|
|
7109
7292
|
*/
|
|
7110
|
-
|
|
7293
|
+
K(this, "getUsersId", async () => [...this.userMap.keys()]);
|
|
7111
7294
|
/**
|
|
7112
7295
|
* 获取房间的访问者
|
|
7113
7296
|
*/
|
|
7114
|
-
|
|
7297
|
+
K(this, "getCaller", async () => await this.getUser(this.options.userId));
|
|
7115
7298
|
// 更新用户 isPublished 只有self 用户会用到
|
|
7116
|
-
|
|
7299
|
+
K(this, "updateIsPublished", async ($, U = !1) => {
|
|
7117
7300
|
const R = await this.getUser($);
|
|
7118
7301
|
R.isPublished = U;
|
|
7119
7302
|
});
|
|
7120
7303
|
/**
|
|
7121
7304
|
* 设置用户流是否更新
|
|
7122
7305
|
*/
|
|
7123
|
-
|
|
7306
|
+
K(this, "setUserUpdateStreams", async ($, U, R = !0) => {
|
|
7124
7307
|
const N = await this.getUser($), e = {
|
|
7125
7308
|
microphoneCamera_audio: !1,
|
|
7126
7309
|
microphoneCamera_video: !1,
|
|
7127
7310
|
screenSharing_video: !1,
|
|
7128
7311
|
screenSharing_audio: !1
|
|
7129
7312
|
};
|
|
7130
|
-
e[U] = R, N.updateStreams = e
|
|
7313
|
+
e[U] = R, N.updateStreams = e;
|
|
7131
7314
|
});
|
|
7132
7315
|
/**
|
|
7133
7316
|
* 更新用户轨道
|
|
7134
7317
|
*/
|
|
7135
|
-
|
|
7318
|
+
K(this, "updateUsertracks", async ($, U = [], R) => {
|
|
7136
7319
|
const N = await this.getUser($);
|
|
7137
7320
|
R && (U = [...N.tracks, ...U]), U = U.filter(({ mid: A = "" }) => A !== ""), U = it(U, ["type"]), U = U.sort((A, M) => A.type - M.type < 0 ? -1 : 1);
|
|
7138
7321
|
for (const A of U)
|
|
@@ -7165,21 +7348,21 @@ class RoomUsers extends MediaStreams {
|
|
|
7165
7348
|
/**
|
|
7166
7349
|
* 更新用户会话状态
|
|
7167
7350
|
*/
|
|
7168
|
-
|
|
7351
|
+
K(this, "updateUserCallAction", async ($, U = 0) => {
|
|
7169
7352
|
const R = await this.getUser($);
|
|
7170
|
-
R.callAction = U, R.callActionStr = U.toString(2).padStart(4, "0"), R.callActionMap = this.
|
|
7353
|
+
R.callAction = U, R.callActionStr = U.toString(2).padStart(4, "0"), R.callActionMap = this.getCallActionMap(U);
|
|
7171
7354
|
});
|
|
7172
7355
|
/**
|
|
7173
7356
|
* 更新用户网络信息
|
|
7174
7357
|
*/
|
|
7175
|
-
|
|
7358
|
+
K(this, "updateUserNetwork", async ($, U = { egress: 5, ingress: 5 }) => {
|
|
7176
7359
|
const R = await this.getUser($);
|
|
7177
7360
|
R.network = U;
|
|
7178
7361
|
});
|
|
7179
7362
|
/**
|
|
7180
7363
|
* 更新用户权限
|
|
7181
7364
|
*/
|
|
7182
|
-
|
|
7365
|
+
K(this, "updateUserPermissions", async ($, U) => {
|
|
7183
7366
|
if (U) {
|
|
7184
7367
|
const R = await this.getUser($);
|
|
7185
7368
|
R.permissions = U;
|
|
@@ -7188,39 +7371,48 @@ class RoomUsers extends MediaStreams {
|
|
|
7188
7371
|
/**
|
|
7189
7372
|
* 更新用户基本信息
|
|
7190
7373
|
*/
|
|
7191
|
-
|
|
7374
|
+
K(this, "updateUserBase", async ($) => {
|
|
7192
7375
|
const U = await this.getUser($);
|
|
7193
7376
|
U.isSelf = $ === this.options.userId, U.updateAt = Date.now();
|
|
7194
7377
|
});
|
|
7195
7378
|
/**
|
|
7196
7379
|
* 更新多个用户信息
|
|
7197
7380
|
*/
|
|
7198
|
-
|
|
7381
|
+
K(this, "updateUsers", async ($) => {
|
|
7199
7382
|
for (const U of $) {
|
|
7200
7383
|
const { id: R, tracks: N, callAction: e, permissions: o, isPublished: A } = U;
|
|
7201
7384
|
await this.updateUserBase(R), await this.updateIsPublished(R, A), await this.updateUserPermissions(R, o), await this.updateUsertracks(R, N, !0), await this.updateUserCallAction(R, e), await this.updateUserNetwork(R);
|
|
7202
7385
|
}
|
|
7203
7386
|
});
|
|
7204
7387
|
/**
|
|
7205
|
-
*
|
|
7388
|
+
* 广播用户状态变化
|
|
7389
|
+
* 当某个用户发送了变化则通过该回调进行通知
|
|
7390
|
+
*/
|
|
7391
|
+
K(this, "emitNotifyUpdateUser", async ($) => {
|
|
7392
|
+
if (this.prohibitNotify) return;
|
|
7393
|
+
const U = await this.getUsers([$]), [R] = this.usersFilter(U);
|
|
7394
|
+
this.cwsIns.emitNotify("onRoomUser", { code: 200, data: R, desc: "user info is change." });
|
|
7395
|
+
});
|
|
7396
|
+
/**
|
|
7397
|
+
* 广播全部用户状态变变化
|
|
7398
|
+
* 只要房间任意一个用户变化 都会通过该回调返回一个完整的用户列表
|
|
7206
7399
|
*/
|
|
7207
|
-
|
|
7400
|
+
K(this, "emitNotifyUpdateUsers", async () => {
|
|
7208
7401
|
if (this.prohibitNotify) return;
|
|
7209
|
-
const $ = await this.getUsers(),
|
|
7210
|
-
this.cwsIns.emitNotify("onRoomUsers", { code: 200, data:
|
|
7402
|
+
const $ = await this.getUsers(), U = this.usersFilter($);
|
|
7403
|
+
this.cwsIns.emitNotify("onRoomUsers", { code: 200, data: U, desc: "all users info is change." });
|
|
7211
7404
|
});
|
|
7212
7405
|
}
|
|
7213
7406
|
}
|
|
7214
|
-
var
|
|
7407
|
+
var Zt, Ft, jt, Ht;
|
|
7215
7408
|
class RoomPeer extends RoomUsers {
|
|
7216
7409
|
constructor() {
|
|
7217
7410
|
super();
|
|
7218
|
-
|
|
7219
|
-
W(this, "getPeerStatsTimer", 0);
|
|
7411
|
+
K(this, "getPeerStatsTimer", 0);
|
|
7220
7412
|
// 获取报告的定时器
|
|
7221
|
-
|
|
7413
|
+
K(this, "reports", []);
|
|
7222
7414
|
// 通信网络质量
|
|
7223
|
-
|
|
7415
|
+
K(this, "peerNetwork", {
|
|
7224
7416
|
lostRate: "0",
|
|
7225
7417
|
// 丢包率
|
|
7226
7418
|
roundTripTime: "0",
|
|
@@ -7228,14 +7420,16 @@ class RoomPeer extends RoomUsers {
|
|
|
7228
7420
|
jitter: "0"
|
|
7229
7421
|
// 网络抖动
|
|
7230
7422
|
});
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }),
|
|
7423
|
+
K(this, "connectedResolveMap", /* @__PURE__ */ new Map());
|
|
7424
|
+
K(this, "initPeer", () => {
|
|
7425
|
+
this.peerIns = new RTCPeerConnection({ bundlePolicy: "max-bundle" }), this.peerIns.ontrack = async ($) => {
|
|
7426
|
+
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: e", $);
|
|
7427
|
+
}, G(this, Zt).call(this), G(this, Ht).call(this);
|
|
7234
7428
|
});
|
|
7235
7429
|
/**
|
|
7236
7430
|
* 初始化发射器
|
|
7237
7431
|
*/
|
|
7238
|
-
|
|
7432
|
+
K(this, "initSender", async () => {
|
|
7239
7433
|
this.peerIns.addTransceiver("audio", { direction: "sendonly" });
|
|
7240
7434
|
const $ = await this.peerIns.createOffer();
|
|
7241
7435
|
if (this.options.debug) {
|
|
@@ -7247,18 +7441,18 @@ class RoomPeer extends RoomUsers {
|
|
|
7247
7441
|
/**
|
|
7248
7442
|
* 添加发射器
|
|
7249
7443
|
*/
|
|
7250
|
-
|
|
7251
|
-
const R = this.peerIns.addTransceiver(U, { direction: "sendonly" }),
|
|
7252
|
-
await this.peerIns.setLocalDescription(
|
|
7253
|
-
const { mid:
|
|
7254
|
-
if (!
|
|
7255
|
-
const {
|
|
7256
|
-
return { type:
|
|
7444
|
+
K(this, "addSender", async ($, U) => {
|
|
7445
|
+
const { userId: R } = this.options, N = this.peerIns.addTransceiver(U, { direction: "sendonly" }), e = await this.peerIns.createOffer();
|
|
7446
|
+
await this.peerIns.setLocalDescription(e);
|
|
7447
|
+
const { mid: o, sender: A } = N, { track: M } = A;
|
|
7448
|
+
if (!M) return;
|
|
7449
|
+
const { enabled: L } = M, F = mediaType_keys.findIndex((H) => H === $);
|
|
7450
|
+
return { type: F, enabled: L, trackName: `${R}_${F}`, location: "local", mid: o, userId: this.options.userId };
|
|
7257
7451
|
});
|
|
7258
7452
|
/**
|
|
7259
7453
|
* 清理收发器
|
|
7260
7454
|
*/
|
|
7261
|
-
|
|
7455
|
+
K(this, "clearTransceivers", async () => {
|
|
7262
7456
|
const $ = await this.getAllUserTrackMids(), U = this.peerIns.getTransceivers();
|
|
7263
7457
|
for (const R of U) {
|
|
7264
7458
|
const { mid: N } = R;
|
|
@@ -7266,7 +7460,7 @@ class RoomPeer extends RoomUsers {
|
|
|
7266
7460
|
}
|
|
7267
7461
|
});
|
|
7268
7462
|
// 等待ice连接
|
|
7269
|
-
|
|
7463
|
+
K(this, "connectionICE", () => new Promise(async ($) => {
|
|
7270
7464
|
if (this.peerIns.connectionState === "connected") return $(!0);
|
|
7271
7465
|
const U = pt();
|
|
7272
7466
|
this.connectedResolveMap.set(U, $);
|
|
@@ -7274,7 +7468,7 @@ class RoomPeer extends RoomUsers {
|
|
|
7274
7468
|
/**
|
|
7275
7469
|
* 监听订阅轨道结果
|
|
7276
7470
|
*/
|
|
7277
|
-
|
|
7471
|
+
K(this, "onSubscribeUserTracks", ($) => {
|
|
7278
7472
|
let U = 0;
|
|
7279
7473
|
return new Promise(async (R) => {
|
|
7280
7474
|
const N = [];
|
|
@@ -7288,41 +7482,49 @@ class RoomPeer extends RoomUsers {
|
|
|
7288
7482
|
{
|
|
7289
7483
|
let e = [];
|
|
7290
7484
|
const o = async () => {
|
|
7291
|
-
clearTimeout(U);
|
|
7292
|
-
const
|
|
7293
|
-
for (const
|
|
7294
|
-
const
|
|
7295
|
-
|
|
7485
|
+
clearTimeout(U), this.prohibitNotify = !1;
|
|
7486
|
+
const M = /* @__PURE__ */ new Map();
|
|
7487
|
+
for (const F of e) {
|
|
7488
|
+
const { userId: Z, mediaType: H } = F;
|
|
7489
|
+
if (!Z || !H) continue;
|
|
7490
|
+
M.has(Z) || M.set(Z, { userId: Z, tracks: [], updateStreams: {} });
|
|
7491
|
+
const V = M.get(Z);
|
|
7492
|
+
V.tracks.push(F), V.updateStreams[H] = !0;
|
|
7296
7493
|
}
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7494
|
+
const L = [...M.values()];
|
|
7495
|
+
for (const F of L) {
|
|
7496
|
+
const { userId: Z, tracks: H } = F;
|
|
7497
|
+
await this.updateUsertracks(Z, H, !0);
|
|
7498
|
+
}
|
|
7499
|
+
await this.emitNotifyUpdateUsersStreams(L), this.peerIns.removeEventListener("track", A), R(!0);
|
|
7500
|
+
}, A = async (M) => {
|
|
7300
7501
|
await this.connectionICE();
|
|
7301
|
-
const { streams:
|
|
7302
|
-
if (!
|
|
7303
|
-
const { userId:
|
|
7304
|
-
if (!(!
|
|
7305
|
-
if (await this.initUserMediaStreamContext(
|
|
7306
|
-
const
|
|
7307
|
-
|
|
7502
|
+
const { streams: L, transceiver: F } = M, [Z] = L, { mid: H, receiver: z } = F, { track: V } = z, { id: W, kind: J } = V, Y = N.find((nt) => nt.mid === `${H}`);
|
|
7503
|
+
if (!Y) return;
|
|
7504
|
+
const { userId: tt, mediaType: X } = Y;
|
|
7505
|
+
if (!(!tt || !X)) {
|
|
7506
|
+
if (await this.initUserMediaStreamContext(tt, X, Z), J === "audio") {
|
|
7507
|
+
const nt = this.getUserMediaStreamContext(tt, X);
|
|
7508
|
+
(nt == null ? void 0 : nt.kind) === "audio" && nt.setMute(!1);
|
|
7308
7509
|
}
|
|
7309
7510
|
{
|
|
7310
|
-
const
|
|
7311
|
-
e.push(
|
|
7511
|
+
const nt = { ...Y, mid: H, msid: W };
|
|
7512
|
+
e.push(nt);
|
|
7312
7513
|
}
|
|
7313
|
-
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->Breathe: await subscribe ${e.length}/${N.length}`, { mediaType:
|
|
7514
|
+
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#00b60f;", `------->Breathe: await subscribe ${e.length}/${N.length}`, { mediaType: X, mid: H, userTrack: Y, e: M }), N.length === e.length && o();
|
|
7314
7515
|
}
|
|
7315
|
-
}
|
|
7516
|
+
};
|
|
7517
|
+
this.peerIns.addEventListener("track", A), U = setTimeout(() => o(), 5 * 1e3);
|
|
7316
7518
|
}
|
|
7317
7519
|
});
|
|
7318
7520
|
});
|
|
7319
7521
|
/**
|
|
7320
7522
|
* 监听webrtc ice通讯连接
|
|
7321
7523
|
*/
|
|
7322
|
-
|
|
7524
|
+
st(this, Zt, async () => {
|
|
7323
7525
|
let $ = 0;
|
|
7324
7526
|
const U = () => {
|
|
7325
|
-
this.setRoomState("disconnected"), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {} });
|
|
7527
|
+
this.setRoomState("disconnected"), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {}, desc: "sdk is destroy." });
|
|
7326
7528
|
};
|
|
7327
7529
|
this.peerIns.onconnectionstatechange = async () => {
|
|
7328
7530
|
const R = this.peerIns.connectionState;
|
|
@@ -7357,7 +7559,7 @@ class RoomPeer extends RoomUsers {
|
|
|
7357
7559
|
/**
|
|
7358
7560
|
* 关闭某个用户的某些轨道
|
|
7359
7561
|
*/
|
|
7360
|
-
|
|
7562
|
+
K(this, "closeUserTracks", async ($, U = [], R = !1) => {
|
|
7361
7563
|
const N = [];
|
|
7362
7564
|
for (const M of U) {
|
|
7363
7565
|
const { trackName: L, msid: F } = M;
|
|
@@ -7367,7 +7569,7 @@ class RoomPeer extends RoomUsers {
|
|
|
7367
7569
|
if (!o) return;
|
|
7368
7570
|
for (const M of o.tracks) {
|
|
7369
7571
|
const { trackName: L, msid: F, userId: Z, mediaType: H } = M;
|
|
7370
|
-
!Z || !H || !e(F || L) || (
|
|
7572
|
+
!Z || !H || !e(F || L) || (this.removeUserMediaStreamContext(Z, H), F && delete M.msid);
|
|
7371
7573
|
}
|
|
7372
7574
|
if (R) {
|
|
7373
7575
|
const M = o.tracks.filter(({ trackName: L }) => !e(L));
|
|
@@ -7379,7 +7581,7 @@ class RoomPeer extends RoomUsers {
|
|
|
7379
7581
|
L.track && e(L.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->Breathe: sender: ${L.track.id} is stop.`, M), L.track.enabled = !1, L.track.stop(), L.replaceTrack(null), this.peerIns.removeTrack(L), M.stop()), F.track && e(F.track.id) && (console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->Breathe: receiver: ${F.track.id} is stop.`, M), F.track.enabled = !1, F.track.stop(), M.stop());
|
|
7380
7582
|
}
|
|
7381
7583
|
});
|
|
7382
|
-
|
|
7584
|
+
K(this, "createOffer", async () => {
|
|
7383
7585
|
const $ = await this.peerIns.createOffer();
|
|
7384
7586
|
if (this.options.debug) {
|
|
7385
7587
|
const U = libExports.parse($.sdp), R = mt(U.media, ["mid", "msid", "type"]);
|
|
@@ -7387,7 +7589,7 @@ class RoomPeer extends RoomUsers {
|
|
|
7387
7589
|
}
|
|
7388
7590
|
await this.peerIns.setLocalDescription($);
|
|
7389
7591
|
});
|
|
7390
|
-
|
|
7592
|
+
K(this, "createAnswer", async () => {
|
|
7391
7593
|
const $ = await this.peerIns.createAnswer();
|
|
7392
7594
|
if (this.options.debug) {
|
|
7393
7595
|
const U = libExports.parse($.sdp), R = mt(U.media, ["mid", "msid", "type"]);
|
|
@@ -7398,14 +7600,14 @@ class RoomPeer extends RoomUsers {
|
|
|
7398
7600
|
/**
|
|
7399
7601
|
* 生成本地sdp
|
|
7400
7602
|
*/
|
|
7401
|
-
|
|
7603
|
+
K(this, "getSdp", () => {
|
|
7402
7604
|
var $;
|
|
7403
7605
|
return ($ = this.peerIns.localDescription) == null ? void 0 : $.sdp;
|
|
7404
7606
|
});
|
|
7405
7607
|
/**
|
|
7406
7608
|
* 设置远程描述协议
|
|
7407
7609
|
*/
|
|
7408
|
-
|
|
7610
|
+
K(this, "setRemoteDescription", async ($) => {
|
|
7409
7611
|
if (this.options.debug) {
|
|
7410
7612
|
const U = libExports.parse($.sdp), R = mt(U.media, ["mid", "msid", "type"]);
|
|
7411
7613
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#ffffff;", "------->Breathe: setRemoteDescription", { msidArr: R, sdpJson: U, description: $ });
|
|
@@ -7415,14 +7617,14 @@ class RoomPeer extends RoomUsers {
|
|
|
7415
7617
|
/**
|
|
7416
7618
|
* 获取peer网络情况
|
|
7417
7619
|
*/
|
|
7418
|
-
|
|
7620
|
+
K(this, "getPeerNetwork", () => this.peerNetwork);
|
|
7419
7621
|
/**
|
|
7420
7622
|
* 设置通讯策略
|
|
7421
7623
|
* @param callStrategy "fixedPictureQuality" | "qualityPriority" | "fluencyPriority" | "balancedDowngrade"
|
|
7422
7624
|
* @param mediaTypes mediaType[] "microphoneCamera_audio" | "microphoneCamera_video" | "screenSharing_video" | "screenSharing_audio"
|
|
7423
7625
|
* @example quickvo.setCallStrategy('fixedPictureQuality')
|
|
7424
7626
|
*/
|
|
7425
|
-
|
|
7627
|
+
K(this, "setCallStrategy", async ($, U = []) => {
|
|
7426
7628
|
U.length === 0 && (U = mediaType_keys);
|
|
7427
7629
|
let R = "balanced";
|
|
7428
7630
|
switch ($) {
|
|
@@ -7451,7 +7653,7 @@ class RoomPeer extends RoomUsers {
|
|
|
7451
7653
|
* 设置 RTCRtpSender 参数
|
|
7452
7654
|
* @param parameters RTCRtpSendParameters
|
|
7453
7655
|
*/
|
|
7454
|
-
|
|
7656
|
+
K(this, "setRTCRtpSenderParameters", ($) => {
|
|
7455
7657
|
try {
|
|
7456
7658
|
const U = this.peerIns.getSenders();
|
|
7457
7659
|
for (const R of U) {
|
|
@@ -7465,33 +7667,33 @@ class RoomPeer extends RoomUsers {
|
|
|
7465
7667
|
/**
|
|
7466
7668
|
* 设置并分析报告
|
|
7467
7669
|
*/
|
|
7468
|
-
|
|
7670
|
+
st(this, Ft, async ($) => {
|
|
7469
7671
|
try {
|
|
7470
7672
|
let U = 0, R = 0, N = 0, e = 0, o = [], A = [];
|
|
7471
7673
|
for (const J of this.reports) {
|
|
7472
|
-
const { packetsSent:
|
|
7473
|
-
|
|
7674
|
+
const { packetsSent: Y, packetsLost: tt } = J;
|
|
7675
|
+
Y && (U += Y), tt && (R += tt);
|
|
7474
7676
|
}
|
|
7475
7677
|
for (const J of $) {
|
|
7476
|
-
const { packetsSent:
|
|
7477
|
-
|
|
7678
|
+
const { packetsSent: Y, packetsLost: tt, jitter: X, roundTripTime: nt } = J;
|
|
7679
|
+
Y && (N += Y), tt && (e += tt), X && A.push(X.toFixed(2)), nt && o.push((nt * 100).toFixed(2));
|
|
7478
7680
|
}
|
|
7479
7681
|
this.reports = $, A.sort().reverse(), o.sort().reverse();
|
|
7480
7682
|
const M = N - U, L = e - R;
|
|
7481
7683
|
if (M === 0) return;
|
|
7482
7684
|
const F = (L / M).toFixed(2), [Z = "0"] = o, [H = "0"] = A, z = { lostRate: F, roundTripTime: Z, jitter: H };
|
|
7483
|
-
JSON.stringify(z) !== JSON.stringify(this.peerNetwork) && this.cwsIns.emitNotify("onRoomNetwork", { code: 200, data: z }), this.peerNetwork = z;
|
|
7484
|
-
const
|
|
7485
|
-
const
|
|
7685
|
+
JSON.stringify(z) !== JSON.stringify(this.peerNetwork) && this.cwsIns.emitNotify("onRoomNetwork", { code: 200, data: z, desc: "room network is change." }), this.peerNetwork = z;
|
|
7686
|
+
const W = (J, Y, tt) => {
|
|
7687
|
+
const X = Number(J), nt = Number(Y), lt = Number(tt);
|
|
7486
7688
|
let et = "0";
|
|
7487
|
-
return
|
|
7689
|
+
return X < 0.03 && nt < 100 && lt < 0.05 ? et = "5" : X < 0.06 && nt < 160 && lt < 0.1 ? et = "4" : X < 0.1 && nt < 250 && lt < 0.15 ? et = "3" : X < 0.15 && nt < 400 && lt < 0.2 ? et = "2" : et = "1", Number(et);
|
|
7488
7690
|
};
|
|
7489
7691
|
{
|
|
7490
|
-
const J =
|
|
7491
|
-
if (await this.updateUserNetwork(this.options.userId,
|
|
7692
|
+
const J = W(F, Z, H), Y = await this.getCaller(), { network: tt } = Y, X = { egress: J, ingress: J }, nt = JSON.stringify(tt) !== JSON.stringify(X);
|
|
7693
|
+
if (await this.updateUserNetwork(this.options.userId, X), nt) {
|
|
7492
7694
|
this.emitNotifyUpdateUsers();
|
|
7493
|
-
const { userId:
|
|
7494
|
-
this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...
|
|
7695
|
+
const { userId: lt, roomId: et } = this.options;
|
|
7696
|
+
this.cwsIns.sendMessage({ event: "networkQualityChange", data: { ...X, userId: lt, roomId: et } }, !1);
|
|
7495
7697
|
}
|
|
7496
7698
|
}
|
|
7497
7699
|
} catch (U) {
|
|
@@ -7499,55 +7701,50 @@ class RoomPeer extends RoomUsers {
|
|
|
7499
7701
|
}
|
|
7500
7702
|
});
|
|
7501
7703
|
/**
|
|
7502
|
-
*
|
|
7704
|
+
* 获取分析报告
|
|
7503
7705
|
*/
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
o = [...A.values()].filter((L) => N.includes(L.type));
|
|
7512
|
-
});
|
|
7513
|
-
} catch {
|
|
7514
|
-
}
|
|
7515
|
-
e(o);
|
|
7516
|
-
});
|
|
7517
|
-
}, U = async () => {
|
|
7518
|
-
if (this.peerIns.connectionState !== "connected") return;
|
|
7519
|
-
const R = this.peerIns.getSenders();
|
|
7706
|
+
K(this, "getReportsByMid", async ($ = []) => $.length === 0 ? this.reports : this.reports.filter((U) => $.includes(U.mid)));
|
|
7707
|
+
/**
|
|
7708
|
+
* 获取轨道分析数据
|
|
7709
|
+
*/
|
|
7710
|
+
st(this, jt, async ($) => {
|
|
7711
|
+
const U = ["inbound-rtp", "remote-inbound-rtp", "outbound-rtp"];
|
|
7712
|
+
return new Promise(async (R) => {
|
|
7520
7713
|
let N = [];
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7714
|
+
try {
|
|
7715
|
+
await this.peerIns.getStats($).then((e) => {
|
|
7716
|
+
N = [...e.values()].filter((A) => U.includes(A.type));
|
|
7717
|
+
});
|
|
7718
|
+
} catch {
|
|
7526
7719
|
}
|
|
7527
|
-
|
|
7720
|
+
R(N);
|
|
7721
|
+
});
|
|
7722
|
+
});
|
|
7723
|
+
/**
|
|
7724
|
+
* 获取连接的所有轨道分析数据
|
|
7725
|
+
*/
|
|
7726
|
+
st(this, Ht, () => {
|
|
7727
|
+
const $ = async () => {
|
|
7728
|
+
if (this.peerIns.connectionState !== "connected") return;
|
|
7729
|
+
const U = await G(this, jt).call(this);
|
|
7730
|
+
G(this, Ft).call(this, U);
|
|
7528
7731
|
};
|
|
7529
|
-
this.getPeerStatsTimer = setInterval(
|
|
7732
|
+
this.getPeerStatsTimer = setInterval($, 1 * 1e3);
|
|
7530
7733
|
});
|
|
7531
7734
|
/**
|
|
7532
7735
|
* 停止网络报告分析
|
|
7533
7736
|
*/
|
|
7534
|
-
|
|
7737
|
+
K(this, "stopGetPeerStats", () => clearInterval(this.getPeerStatsTimer));
|
|
7535
7738
|
}
|
|
7536
7739
|
}
|
|
7537
|
-
|
|
7538
|
-
var
|
|
7740
|
+
Zt = new WeakMap(), Ft = new WeakMap(), jt = new WeakMap(), Ht = new WeakMap();
|
|
7741
|
+
var Ot, Tt, zt;
|
|
7539
7742
|
class RoomCalls extends RoomPeer {
|
|
7540
7743
|
constructor() {
|
|
7541
7744
|
super();
|
|
7542
7745
|
// sdk服务版本
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
/**
|
|
7546
|
-
* 添加广播事件
|
|
7547
|
-
* @param notify Notify
|
|
7548
|
-
* @returns sn
|
|
7549
|
-
*/
|
|
7550
|
-
W(this, "addNotify", ($) => this.cwsIns.addNotify($));
|
|
7746
|
+
K(this, "sdk_service_version", "1.0.3");
|
|
7747
|
+
st(this, Ot, !0);
|
|
7551
7748
|
/**
|
|
7552
7749
|
* 设置本地流
|
|
7553
7750
|
* @param mediaType MediaType
|
|
@@ -7555,64 +7752,35 @@ class RoomCalls extends RoomPeer {
|
|
|
7555
7752
|
* @example quickvo.setLocalStream('microphoneCamera_audio', false)
|
|
7556
7753
|
* @returns Promise<Streams>
|
|
7557
7754
|
*/
|
|
7558
|
-
|
|
7755
|
+
K(this, "setLocalStream", ($, U) => new Promise(async (R, N) => {
|
|
7559
7756
|
try {
|
|
7560
|
-
const { userId: e } = this.options
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
case "microphoneCamera_audio":
|
|
7569
|
-
{
|
|
7570
|
-
const M = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1, ...o });
|
|
7571
|
-
await this.initUserMediaStreamContext(e, "microphoneCamera_audio", M);
|
|
7572
|
-
}
|
|
7573
|
-
break;
|
|
7574
|
-
// 摄像头
|
|
7575
|
-
case "microphoneCamera_video":
|
|
7576
|
-
{
|
|
7577
|
-
const M = await navigator.mediaDevices.getUserMedia({ audio: !1, video: { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { min: 10, ideal: 30 } }, ...o });
|
|
7578
|
-
await this.initUserMediaStreamContext(e, "microphoneCamera_video", M);
|
|
7579
|
-
}
|
|
7580
|
-
break;
|
|
7581
|
-
// 屏幕共享 音频
|
|
7582
|
-
case "screenSharing_audio":
|
|
7583
|
-
{
|
|
7584
|
-
const M = await navigator.mediaDevices.getDisplayMedia({ audio: !0, video: !0, ...o }), L = M.getTracks();
|
|
7585
|
-
for (const F of L) {
|
|
7586
|
-
const { kind: Z } = F, H = new MediaStream();
|
|
7587
|
-
H.addTrack(F), M.removeTrack(F), Z === "audio" && await this.initUserMediaStreamContext(e, "screenSharing_audio", H), Z === "video" && await this.initUserMediaStreamContext(e, "screenSharing_video", H), F.onended = () => this.stopPublish(["screenSharing_audio", "screenSharing_video"]);
|
|
7588
|
-
}
|
|
7589
|
-
}
|
|
7590
|
-
break;
|
|
7591
|
-
// 屏幕共享 视频
|
|
7592
|
-
case "screenSharing_video":
|
|
7593
|
-
{
|
|
7594
|
-
const M = await navigator.mediaDevices.getDisplayMedia({ audio: !1, video: !0, ...o });
|
|
7595
|
-
await this.initUserMediaStreamContext(e, "screenSharing_video", M);
|
|
7596
|
-
}
|
|
7597
|
-
break;
|
|
7598
|
-
}
|
|
7599
|
-
else
|
|
7600
|
-
await this.removeUserStreams(e, [$]);
|
|
7601
|
-
const A = await this.getUserStreams(e);
|
|
7602
|
-
this.cwsIns.emitNotify("onLocalStream", { code: 200, data: A }), R(A);
|
|
7757
|
+
const { userId: e } = this.options;
|
|
7758
|
+
if (U ? await this.changeLocalStream($) : this.removeUserMediaStreamContext(e, $), $ === "screenSharing_audio" || $ === "screenSharing_video") {
|
|
7759
|
+
const M = this.getUserStream(e, $).getTracks();
|
|
7760
|
+
for (const L of M)
|
|
7761
|
+
L.onended = () => this.stopPublish(["screenSharing_audio", "screenSharing_video"]);
|
|
7762
|
+
}
|
|
7763
|
+
const o = this.getUserStreams(e);
|
|
7764
|
+
this.cwsIns.emitNotify("onLocalStream", { code: 200, data: o, desc: "local stream is change." }), R(o);
|
|
7603
7765
|
} catch (e) {
|
|
7604
7766
|
N(e);
|
|
7605
7767
|
}
|
|
7606
7768
|
}));
|
|
7769
|
+
/**
|
|
7770
|
+
* 添加广播事件
|
|
7771
|
+
* @param notify Notify
|
|
7772
|
+
* @returns sn
|
|
7773
|
+
*/
|
|
7774
|
+
K(this, "addNotify", ($) => this.cwsIns.addNotify($));
|
|
7607
7775
|
/**
|
|
7608
7776
|
* 加入房间
|
|
7609
7777
|
* @param roomOptions RoomOptions
|
|
7610
7778
|
* @example quickvo.joinRoom({ userId: '', roomId: '', sdkToken: '', callType: '1' , newPublishAutoSubscribe: true })
|
|
7611
7779
|
* @returns Promise<boolean>
|
|
7612
7780
|
*/
|
|
7613
|
-
|
|
7781
|
+
K(this, "joinRoom", async ($) => new Promise(async (U, R) => {
|
|
7614
7782
|
try {
|
|
7615
|
-
this.setOptions($), this.clearUsers(), this.clearUserStreams(), this.initPeer(), this.cwsIns.clearEvents(), await
|
|
7783
|
+
this.setOptions($), this.clearUsers(), this.clearUserStreams(), this.initPeer(), this.cwsIns.clearEvents(), await G(this, zt).call(this), this.setRoomState("connect");
|
|
7616
7784
|
const { roomId: N, userId: e, callType: o } = this.options;
|
|
7617
7785
|
await this.cwsIns.sendMessage({
|
|
7618
7786
|
event: "joinRoom",
|
|
@@ -7622,7 +7790,7 @@ class RoomCalls extends RoomPeer {
|
|
|
7622
7790
|
if (M !== 200) return R(L);
|
|
7623
7791
|
const { roomId: Z = "", roomUsers: H = [] } = F;
|
|
7624
7792
|
if (Z !== N) return R("加入的房间不匹配");
|
|
7625
|
-
|
|
7793
|
+
G(this, Ot) && this.createSession(), await this.updateUsers(H), this.setRoomState("connected"), await this.emitNotifyUpdateUsers();
|
|
7626
7794
|
const z = await this.getUsers();
|
|
7627
7795
|
U(z);
|
|
7628
7796
|
});
|
|
@@ -7635,25 +7803,20 @@ class RoomCalls extends RoomPeer {
|
|
|
7635
7803
|
* @example quickvo.quitRoom()
|
|
7636
7804
|
* @returns Promise<boolean>
|
|
7637
7805
|
*/
|
|
7638
|
-
|
|
7639
|
-
try {
|
|
7640
|
-
this.stopPublish();
|
|
7641
|
-
} catch (e) {
|
|
7642
|
-
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", e);
|
|
7643
|
-
}
|
|
7806
|
+
K(this, "quitRoom", async () => new Promise(async ($) => {
|
|
7644
7807
|
const { roomId: U, userId: R } = this.options, N = { roomId: U, user: { id: R } };
|
|
7645
|
-
|
|
7808
|
+
this.cwsIns.sendMessage({ event: "quitRoom", data: N }), await new Promise((e) => setTimeout(() => e(!0), 300)), this.cwsIns.emitNotify("onDestroy", { code: 200, data: {}, desc: "sdk is destroy." }), $(!0);
|
|
7646
7809
|
}));
|
|
7647
7810
|
/**
|
|
7648
7811
|
* 同步房间信息
|
|
7649
7812
|
* @example quickvo.syncRoomInfo()
|
|
7650
7813
|
*/
|
|
7651
|
-
|
|
7814
|
+
K(this, "syncRoomInfo", async () => new Promise(async ($, U) => {
|
|
7652
7815
|
const { userId: R } = this.options, N = await this.getUser(R), { id: e = R, callAction: o = 0 } = N;
|
|
7653
7816
|
await this.cwsIns.sendMessage({ event: "syncRoomInfo", data: { user: { id: e, callAction: o } } }).then(async (A) => {
|
|
7654
7817
|
if (A.code !== 200) return U(A.desc);
|
|
7655
7818
|
const M = A.data.users;
|
|
7656
|
-
this.clearUsers(),
|
|
7819
|
+
this.clearUsers(), await this.updateUsers(M), await this.updateUsertracks(N.id, N.tracks, !1), await this.subscribe();
|
|
7657
7820
|
{
|
|
7658
7821
|
const L = await this.getUsers();
|
|
7659
7822
|
$(L);
|
|
@@ -7667,22 +7830,22 @@ class RoomCalls extends RoomPeer {
|
|
|
7667
7830
|
* @example quickvo.publish(['microphoneCamera_audio', 'microphoneCamera_video'], 3)
|
|
7668
7831
|
* @returns Promise<RoomUser>
|
|
7669
7832
|
*/
|
|
7670
|
-
|
|
7671
|
-
|
|
7833
|
+
K(this, "publish", async ($, U = 3) => {
|
|
7834
|
+
G(this, Ot) && await this.connectionICE();
|
|
7672
7835
|
const R = () => new Promise(async (N, e) => {
|
|
7673
7836
|
try {
|
|
7674
7837
|
$.includes("screenSharing_audio") && !$.includes("screenSharing_video") && ($ = [...$, "screenSharing_video"]);
|
|
7675
7838
|
const o = await this.getCaller(), A = [];
|
|
7676
7839
|
for (const Z of $) {
|
|
7677
|
-
|
|
7840
|
+
this.getUserStream(o.id, Z).getTracks().length === 0 && await this.setLocalStream(Z, !0);
|
|
7678
7841
|
{
|
|
7679
|
-
const V =
|
|
7680
|
-
if (!
|
|
7681
|
-
const J = await this.addSender(Z,
|
|
7842
|
+
const V = this.getUserStream(o.id, Z), [W] = V.getTracks();
|
|
7843
|
+
if (!W) continue;
|
|
7844
|
+
const J = await this.addSender(Z, W);
|
|
7682
7845
|
J && A.push(J);
|
|
7683
7846
|
}
|
|
7684
7847
|
}
|
|
7685
|
-
const M = [...o.tracks, ...A], L = await this.
|
|
7848
|
+
const M = [...o.tracks, ...A], L = await this.getCallAction(M), F = async () => {
|
|
7686
7849
|
this.options.debug && console.info("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: surplus publish count is ${U}`), await this.cwsIns.sendMessage({
|
|
7687
7850
|
event: "publish",
|
|
7688
7851
|
data: { sdp: this.getSdp(), tracks: A, callAction: L }
|
|
@@ -7693,8 +7856,8 @@ class RoomCalls extends RoomPeer {
|
|
|
7693
7856
|
return await new Promise((J) => setTimeout(() => J(!0), 300)), U = U - 1, F();
|
|
7694
7857
|
throw this.options.debug && console.error("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: publish is error. count 0", { mediaTypes: $ }), new Error(z);
|
|
7695
7858
|
}
|
|
7696
|
-
const { remoteSdp:
|
|
7697
|
-
await this.setRemoteDescription({ type: "answer", sdp:
|
|
7859
|
+
const { remoteSdp: W } = V;
|
|
7860
|
+
await this.setRemoteDescription({ type: "answer", sdp: W }), await this.connectionICE(), await this.updateUsertracks(o.id, M, !0), await G(this, Tt).call(this, L), G(this, Ot) || this.cwsIns.sendMessage({ event: "pubNotify", data: { roomId: "", user: { id: o.id, tracks: A } } });
|
|
7698
7861
|
{
|
|
7699
7862
|
await this.emitNotifyUpdateUsers();
|
|
7700
7863
|
const J = await this.getCaller();
|
|
@@ -7715,7 +7878,7 @@ class RoomCalls extends RoomPeer {
|
|
|
7715
7878
|
* @example quickvo.stopPublish(['microphoneCamera_audio'])
|
|
7716
7879
|
* @returns Promise<RoomUser>
|
|
7717
7880
|
*/
|
|
7718
|
-
|
|
7881
|
+
K(this, "stopPublish", async ($ = []) => {
|
|
7719
7882
|
const U = () => new Promise(async (R, N) => {
|
|
7720
7883
|
try {
|
|
7721
7884
|
const e = await this.getCaller();
|
|
@@ -7727,8 +7890,8 @@ class RoomCalls extends RoomPeer {
|
|
|
7727
7890
|
if (o.length === 0) return A();
|
|
7728
7891
|
await this.closeUserTracks(e.id, o, !0);
|
|
7729
7892
|
{
|
|
7730
|
-
const M = await this.
|
|
7731
|
-
await
|
|
7893
|
+
const M = await this.getCallAction(e.tracks);
|
|
7894
|
+
await G(this, Tt).call(this, M);
|
|
7732
7895
|
}
|
|
7733
7896
|
await this.createOffer(), await this.cwsIns.sendMessage({
|
|
7734
7897
|
event: "closeTrack",
|
|
@@ -7750,8 +7913,8 @@ class RoomCalls extends RoomPeer {
|
|
|
7750
7913
|
* @example quickvo.subscribe(['trackName1','trackName2'])
|
|
7751
7914
|
* @returns Promise<RoomUser[]>
|
|
7752
7915
|
*/
|
|
7753
|
-
|
|
7754
|
-
|
|
7916
|
+
K(this, "subscribe", async ($ = [], U = 3) => {
|
|
7917
|
+
G(this, Ot) && await this.connectionICE();
|
|
7755
7918
|
const R = () => new Promise(async (N, e) => {
|
|
7756
7919
|
try {
|
|
7757
7920
|
this.prohibitNotify = !0;
|
|
@@ -7760,20 +7923,19 @@ class RoomCalls extends RoomPeer {
|
|
|
7760
7923
|
for (const Z of o) {
|
|
7761
7924
|
const { isSelf: H, tracks: z = [] } = Z;
|
|
7762
7925
|
if (!H) {
|
|
7763
|
-
const V = z.filter(({ trackName:
|
|
7926
|
+
const V = z.filter(({ trackName: W, mid: J = "" }) => J !== "" && ($.includes(W) || $.length === 0));
|
|
7764
7927
|
V.length !== 0 && A.push({ ...Z, tracks: V });
|
|
7765
7928
|
}
|
|
7766
7929
|
}
|
|
7767
7930
|
const M = async () => {
|
|
7768
|
-
this.prohibitNotify = !1;
|
|
7769
7931
|
const Z = Array.from(A, ({ id: z }) => z), H = await this.getUsers(Z);
|
|
7770
7932
|
await this.emitNotifyUpdateUsers(), N(H);
|
|
7771
7933
|
};
|
|
7772
7934
|
if (A.length === 0) return M();
|
|
7773
7935
|
const L = [];
|
|
7774
7936
|
for (const Z of A) {
|
|
7775
|
-
const { id: H, tracks: z } = Z, V = mt(z, ["type", "trackName"]),
|
|
7776
|
-
L.push(
|
|
7937
|
+
const { id: H, tracks: z } = Z, V = mt(z, ["type", "trackName"]), W = { id: H, tracks: V };
|
|
7938
|
+
L.push(W);
|
|
7777
7939
|
}
|
|
7778
7940
|
const F = async () => {
|
|
7779
7941
|
this.options.debug && console.info("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", `------->quickvo: surplus subscribe count is ${U}`), await this.cwsIns.sendMessage({
|
|
@@ -7783,11 +7945,11 @@ class RoomCalls extends RoomPeer {
|
|
|
7783
7945
|
const { code: H = 0, data: z, desc: V } = Z;
|
|
7784
7946
|
if (H !== 200) {
|
|
7785
7947
|
if (U > 0)
|
|
7786
|
-
return await new Promise((
|
|
7948
|
+
return await new Promise((Y) => setTimeout(() => Y(!0), 300)), U = U - 1, F();
|
|
7787
7949
|
throw this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: subscribe is error. count 0", { trackNames: $ }), new Error(V);
|
|
7788
7950
|
}
|
|
7789
|
-
const { remoteSdp:
|
|
7790
|
-
this.onSubscribeUserTracks(J).then(() => M()), await this.setRemoteDescription({ type: "offer", sdp:
|
|
7951
|
+
const { remoteSdp: W, users: J = [] } = z;
|
|
7952
|
+
this.onSubscribeUserTracks(J).then(() => M()), await this.setRemoteDescription({ type: "offer", sdp: W }), await this.renegotiate();
|
|
7791
7953
|
});
|
|
7792
7954
|
};
|
|
7793
7955
|
await F();
|
|
@@ -7802,7 +7964,7 @@ class RoomCalls extends RoomPeer {
|
|
|
7802
7964
|
* @param trackNames string[] = []
|
|
7803
7965
|
* @example quickvo.subscribe(['trackName1'])
|
|
7804
7966
|
*/
|
|
7805
|
-
|
|
7967
|
+
K(this, "stopSubscribe", async ($ = []) => {
|
|
7806
7968
|
const U = () => new Promise(async (R, N) => {
|
|
7807
7969
|
try {
|
|
7808
7970
|
const e = await this.getUsers(), o = [];
|
|
@@ -7811,8 +7973,8 @@ class RoomCalls extends RoomPeer {
|
|
|
7811
7973
|
for (const L of M) {
|
|
7812
7974
|
const { type: F, mid: Z, trackName: H, mediaType: z, msid: V } = L;
|
|
7813
7975
|
if (!(!z || !V) && ($.length === 0 || $.includes(H))) {
|
|
7814
|
-
const
|
|
7815
|
-
o.push(
|
|
7976
|
+
const W = { type: F, mid: Z, trackName: V };
|
|
7977
|
+
o.push(W), await this.closeUserTracks(A.id, [L]);
|
|
7816
7978
|
}
|
|
7817
7979
|
}
|
|
7818
7980
|
}
|
|
@@ -7836,7 +7998,7 @@ class RoomCalls extends RoomPeer {
|
|
|
7836
7998
|
* @param enabled 是否冻结
|
|
7837
7999
|
* @example quickvo.inactiveTracks(['microphoneCamera_audio'], false)
|
|
7838
8000
|
*/
|
|
7839
|
-
|
|
8001
|
+
K(this, "inactiveTracks", async ($, U) => {
|
|
7840
8002
|
const R = async () => {
|
|
7841
8003
|
const N = await this.getCaller();
|
|
7842
8004
|
if (!N) return;
|
|
@@ -7850,15 +8012,15 @@ class RoomCalls extends RoomPeer {
|
|
|
7850
8012
|
H.enabled = U;
|
|
7851
8013
|
}
|
|
7852
8014
|
}
|
|
7853
|
-
const A = await this.
|
|
7854
|
-
await
|
|
8015
|
+
const A = await this.getCallAction(o);
|
|
8016
|
+
await G(this, Tt).call(this, A), await this.emitNotifyUpdateUsers();
|
|
7855
8017
|
};
|
|
7856
8018
|
return this.asyncQueue.add(R, { key: "inactiveTracks" });
|
|
7857
8019
|
});
|
|
7858
8020
|
/**
|
|
7859
8021
|
* 远端调试
|
|
7860
8022
|
*/
|
|
7861
|
-
|
|
8023
|
+
K(this, "debugger", () => new Promise(async ($, U) => {
|
|
7862
8024
|
await this.cwsIns.sendMessage({ event: "debugger" }, !1).then(async (R) => {
|
|
7863
8025
|
if (R.code !== 200) return U(R.desc);
|
|
7864
8026
|
$(!0);
|
|
@@ -7869,7 +8031,7 @@ class RoomCalls extends RoomPeer {
|
|
|
7869
8031
|
/**
|
|
7870
8032
|
* 更新自己通话状态
|
|
7871
8033
|
*/
|
|
7872
|
-
|
|
8034
|
+
st(this, Tt, async ($) => new Promise(async (U, R) => {
|
|
7873
8035
|
const { roomId: N, userId: e } = this.options, o = { roomId: N, user: { id: e, callAction: $ } };
|
|
7874
8036
|
await this.cwsIns.sendMessage({ event: "updateCall", data: o }).then(async (A) => {
|
|
7875
8037
|
const { code: M = 0 } = A;
|
|
@@ -7880,7 +8042,7 @@ class RoomCalls extends RoomPeer {
|
|
|
7880
8042
|
/**
|
|
7881
8043
|
* 创建cf会话
|
|
7882
8044
|
*/
|
|
7883
|
-
|
|
8045
|
+
K(this, "createSession", async () => (await this.initSender(), new Promise(async ($, U) => await this.cwsIns.sendMessage({
|
|
7884
8046
|
event: "connectCF",
|
|
7885
8047
|
data: { sdp: this.getSdp() }
|
|
7886
8048
|
}).then(async (R) => {
|
|
@@ -7892,7 +8054,7 @@ class RoomCalls extends RoomPeer {
|
|
|
7892
8054
|
/**
|
|
7893
8055
|
* 协商流
|
|
7894
8056
|
*/
|
|
7895
|
-
|
|
8057
|
+
K(this, "renegotiate", async () => new Promise(async ($, U) => {
|
|
7896
8058
|
await this.createAnswer(), await this.cwsIns.sendMessage({ event: "renegotiate", data: { sdp: this.getSdp() } }).then(async (R) => {
|
|
7897
8059
|
if (R.code !== 200) return U("协商流错误");
|
|
7898
8060
|
$(!0);
|
|
@@ -7903,16 +8065,17 @@ class RoomCalls extends RoomPeer {
|
|
|
7903
8065
|
/**
|
|
7904
8066
|
* 登录
|
|
7905
8067
|
*/
|
|
7906
|
-
|
|
8068
|
+
st(this, zt, async () => new Promise(async ($, U) => {
|
|
7907
8069
|
try {
|
|
7908
8070
|
this.setRoomState("checkAuth");
|
|
7909
|
-
const { appid: R } = this.options, { userId: N, sdkToken: e } = this.options,
|
|
8071
|
+
const { appid: R } = this.options, { userId: N, sdkToken: e, roomId: o } = this.options, A = {
|
|
8072
|
+
a: e,
|
|
7910
8073
|
b: N,
|
|
7911
8074
|
c: R,
|
|
7912
|
-
|
|
8075
|
+
r: o,
|
|
7913
8076
|
v: this.sdk_service_version
|
|
7914
|
-
},
|
|
7915
|
-
await this.cwsIns.connect(
|
|
8077
|
+
}, M = btoa(encodeURI(JSON.stringify(A)));
|
|
8078
|
+
await this.cwsIns.connect(M), $(!0);
|
|
7916
8079
|
} catch (R) {
|
|
7917
8080
|
console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe:error", R), U(R);
|
|
7918
8081
|
}
|
|
@@ -7920,39 +8083,21 @@ class RoomCalls extends RoomPeer {
|
|
|
7920
8083
|
this.setRoomState("ready");
|
|
7921
8084
|
}
|
|
7922
8085
|
}
|
|
7923
|
-
|
|
8086
|
+
Ot = new WeakMap(), Tt = new WeakMap(), zt = new WeakMap();
|
|
7924
8087
|
class Room extends RoomCalls {
|
|
7925
8088
|
constructor() {
|
|
7926
8089
|
super();
|
|
7927
|
-
/**
|
|
7928
|
-
* 获取指定轨道的名称数组
|
|
7929
|
-
* @param tracks 轨道
|
|
7930
|
-
* @param types number[] = []
|
|
7931
|
-
* @param keyName
|
|
7932
|
-
* @returns string[]
|
|
7933
|
-
*/
|
|
7934
|
-
W(this, "getTrackNamesFormTracks", ($, U = [], R = "trackName") => {
|
|
7935
|
-
const N = [];
|
|
7936
|
-
for (const e of $) {
|
|
7937
|
-
const { type: o } = e;
|
|
7938
|
-
if (U.length === 0 || U.includes(o)) {
|
|
7939
|
-
const A = e[R];
|
|
7940
|
-
A && N.push(`${A}`);
|
|
7941
|
-
}
|
|
7942
|
-
}
|
|
7943
|
-
return N;
|
|
7944
|
-
});
|
|
7945
8090
|
}
|
|
7946
8091
|
}
|
|
7947
|
-
var
|
|
8092
|
+
var gt, Jt, Kt, Wt;
|
|
7948
8093
|
class QuickVO extends Room {
|
|
7949
8094
|
constructor($) {
|
|
7950
8095
|
super();
|
|
7951
|
-
|
|
8096
|
+
st(this, gt, /* @__PURE__ */ new Map());
|
|
7952
8097
|
/**
|
|
7953
8098
|
* 添加内部监听事件
|
|
7954
8099
|
*/
|
|
7955
|
-
|
|
8100
|
+
st(this, Jt, () => {
|
|
7956
8101
|
{
|
|
7957
8102
|
const $ = async (U) => {
|
|
7958
8103
|
const { qualities: R } = U.data;
|
|
@@ -7986,7 +8131,7 @@ class QuickVO extends Room {
|
|
|
7986
8131
|
await this.updateUsertracks(N, e, !0);
|
|
7987
8132
|
}
|
|
7988
8133
|
if (this.options.newPublishAutoSubscribe) {
|
|
7989
|
-
const R = this.
|
|
8134
|
+
const R = this.getTrackNamesFormTracks(U.data.user.tracks);
|
|
7990
8135
|
await this.subscribe(R);
|
|
7991
8136
|
} else
|
|
7992
8137
|
await this.emitNotifyUpdateUsers();
|
|
@@ -8004,28 +8149,28 @@ class QuickVO extends Room {
|
|
|
8004
8149
|
const $ = async (U) => {
|
|
8005
8150
|
const { id: R, callAction: N } = U.data.user;
|
|
8006
8151
|
if (!this.checkUserInRoom(R)) return;
|
|
8007
|
-
const e = await this.getUser(R), { tracks: o = [] } = e, A =
|
|
8152
|
+
const e = await this.getUser(R), { tracks: o = [] } = e, A = this.getUserStreams(R), M = this.getCallActionMap(N), L = [];
|
|
8008
8153
|
for (const F of o) {
|
|
8009
8154
|
const { type: Z } = F, H = mediaType_keys[Z], z = M[H];
|
|
8010
8155
|
if (Z === 0) {
|
|
8011
|
-
const { microphoneCamera_audio:
|
|
8012
|
-
for (const
|
|
8013
|
-
|
|
8156
|
+
const { microphoneCamera_audio: W } = A, J = W.getTracks();
|
|
8157
|
+
for (const Y of J)
|
|
8158
|
+
Y.enabled = z;
|
|
8014
8159
|
}
|
|
8015
8160
|
if (Z === 1) {
|
|
8016
|
-
const { microphoneCamera_video:
|
|
8017
|
-
for (const
|
|
8018
|
-
|
|
8161
|
+
const { microphoneCamera_video: W } = A, J = W.getTracks();
|
|
8162
|
+
for (const Y of J)
|
|
8163
|
+
Y.enabled = z;
|
|
8019
8164
|
}
|
|
8020
8165
|
if (Z === 2) {
|
|
8021
|
-
const { screenSharing_video:
|
|
8022
|
-
for (const
|
|
8023
|
-
|
|
8166
|
+
const { screenSharing_video: W } = A, J = W.getTracks();
|
|
8167
|
+
for (const Y of J)
|
|
8168
|
+
Y.enabled = z;
|
|
8024
8169
|
}
|
|
8025
8170
|
if (Z === 3) {
|
|
8026
|
-
const { screenSharing_audio:
|
|
8027
|
-
for (const
|
|
8028
|
-
|
|
8171
|
+
const { screenSharing_audio: W } = A, J = W.getTracks();
|
|
8172
|
+
for (const Y of J)
|
|
8173
|
+
Y.enabled = z;
|
|
8029
8174
|
}
|
|
8030
8175
|
const V = { ...F, enabled: z };
|
|
8031
8176
|
L.push(V);
|
|
@@ -8046,7 +8191,7 @@ class QuickVO extends Room {
|
|
|
8046
8191
|
/**
|
|
8047
8192
|
* 重连成功
|
|
8048
8193
|
*/
|
|
8049
|
-
|
|
8194
|
+
st(this, Kt, () => {
|
|
8050
8195
|
this.cwsIns.onReconnectSuccess = async () => {
|
|
8051
8196
|
this.syncRoomInfo();
|
|
8052
8197
|
};
|
|
@@ -8054,7 +8199,7 @@ class QuickVO extends Room {
|
|
|
8054
8199
|
/**
|
|
8055
8200
|
* 重连停止
|
|
8056
8201
|
*/
|
|
8057
|
-
|
|
8202
|
+
st(this, Wt, async () => {
|
|
8058
8203
|
this.cwsIns.onReconnectStop = async () => {
|
|
8059
8204
|
this.destroy();
|
|
8060
8205
|
};
|
|
@@ -8064,15 +8209,15 @@ class QuickVO extends Room {
|
|
|
8064
8209
|
* @param key string
|
|
8065
8210
|
* @param func FrameRequestCallback
|
|
8066
8211
|
*/
|
|
8067
|
-
|
|
8212
|
+
K(this, "addRequestAnimationFrame", async ($, U) => {
|
|
8068
8213
|
{
|
|
8069
|
-
const N =
|
|
8214
|
+
const N = G(this, gt).get($);
|
|
8070
8215
|
N && cancelAnimationFrame(N);
|
|
8071
8216
|
}
|
|
8072
8217
|
const R = (N = Date.now()) => {
|
|
8073
8218
|
U(N);
|
|
8074
8219
|
const e = requestAnimationFrame(R);
|
|
8075
|
-
|
|
8220
|
+
G(this, gt).set($, e);
|
|
8076
8221
|
};
|
|
8077
8222
|
R();
|
|
8078
8223
|
});
|
|
@@ -8080,11 +8225,11 @@ class QuickVO extends Room {
|
|
|
8080
8225
|
* 清理 FrameRequestCallback
|
|
8081
8226
|
* @param keys string[] = []
|
|
8082
8227
|
*/
|
|
8083
|
-
|
|
8084
|
-
$.length === 0 && ($ = [...
|
|
8228
|
+
K(this, "clearRequestAnimationFrame", async ($ = []) => {
|
|
8229
|
+
$.length === 0 && ($ = [...G(this, gt).keys()]);
|
|
8085
8230
|
const U = [];
|
|
8086
8231
|
for (const R of $) {
|
|
8087
|
-
const N =
|
|
8232
|
+
const N = G(this, gt).get(R);
|
|
8088
8233
|
N && (cancelAnimationFrame(N), U.push(N));
|
|
8089
8234
|
}
|
|
8090
8235
|
return U;
|
|
@@ -8093,18 +8238,14 @@ class QuickVO extends Room {
|
|
|
8093
8238
|
* 销毁
|
|
8094
8239
|
* @example quickvo.destroy()
|
|
8095
8240
|
*/
|
|
8096
|
-
|
|
8241
|
+
K(this, "destroy", async () => {
|
|
8097
8242
|
this.options.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->quickvo: 销毁SDK"), this.stopGetPeerStats(), this.asyncQueue.clear(), this.clearUsers(), this.clearUserStreams(), this.cwsIns.clearEvents(), await this.cwsIns.close();
|
|
8098
8243
|
});
|
|
8099
|
-
this.setOptions($), this.initCwsCall(),
|
|
8244
|
+
this.setOptions($), this.initCwsCall(), G(this, Kt).call(this), G(this, Wt).call(this), G(this, Jt).call(this);
|
|
8100
8245
|
}
|
|
8101
8246
|
}
|
|
8102
|
-
|
|
8247
|
+
gt = new WeakMap(), Jt = new WeakMap(), Kt = new WeakMap(), Wt = new WeakMap();
|
|
8103
8248
|
export {
|
|
8104
8249
|
QuickVO,
|
|
8105
|
-
getAverageVolume,
|
|
8106
|
-
getCallAction,
|
|
8107
|
-
getCallActionMap,
|
|
8108
|
-
getTrackNamesFormTracks,
|
|
8109
8250
|
ignoreEvent
|
|
8110
8251
|
};
|