usc-rtc-client 2.2.0 → 2.3.0
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 +18 -10
- package/dist/client/RtcClient.d.ts +2 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.es.js +349 -288
- package/dist/index.umd.js +5 -5
- package/dist/session/RtcAbstractSession.d.ts +0 -2
- package/package.json +4 -5
package/dist/index.es.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var S = /* @__PURE__ */ ((i) => (i.bye = "bye", i.stream = "stream", i.reInvite = "reInvite", i.localAudioChange = "localAudioChange", i.localVideoChange = "localVideoChange", i.localStreamChange = "localStreamChange", i))(S || {}),
|
|
2
|
-
let
|
|
3
|
-
const
|
|
1
|
+
var S = /* @__PURE__ */ ((i) => (i.bye = "bye", i.stream = "stream", i.reInvite = "reInvite", i.localAudioChange = "localAudioChange", i.localVideoChange = "localVideoChange", i.localStreamChange = "localStreamChange", i))(S || {}), j = /* @__PURE__ */ ((i) => (i.connected = "connected", i.disconnected = "disconnected", i.invite = "invite", i))(j || {}), D = /* @__PURE__ */ ((i) => (i.PTTInfo = "PTTInfo", i.FPREInfo = "FPREInfo", i.IMSInfo = "IMSInfo", i.ERROR = "error", i.SPEAKER = "speaker", i.TALKING = "talking", i.ACTIVE_GROUP = "activeGroup", i.JOIN_INFO = "joinInfo", i))(D || {}), T = /* @__PURE__ */ ((i) => (i.MESSAGE_TYPE_REGISTER = "REGISTER", i.MESSAGE_TYPE_INVITE = "INVITE", i.MESSAGE_TYPE_REINVITE = "reINVITE", i.MESSAGE_TYPE_ICE = "ICE", i.MESSAGE_TYPE_INFO = "INFO", i.MESSAGE_TYPE_BYE = "BYE", i))(T || {}), W = /* @__PURE__ */ ((i) => (i.FPRE = "fpre", i.IMS = "ims", i.PTT_QUERY_ONLINE_USER = "15", i.PTT_ANSWER_ONLINE_USER = "115", i.PTT_QUERY_INFO = "16", i.PTT_QUERY_INFO_CONFIRM = "116", i))(W || {});
|
|
2
|
+
let H = (i = 21) => crypto.getRandomValues(new Uint8Array(i)).reduce((e, t) => (t &= 63, t < 36 ? e += t.toString(36) : t < 62 ? e += (t - 26).toString(36).toUpperCase() : t > 62 ? e += "-" : e += "_", e), "");
|
|
3
|
+
const te = (i) => {
|
|
4
4
|
i !== void 0 && (i.pause(), i.removeAttribute("src"), i.removeAttribute("srcObject"));
|
|
5
|
-
},
|
|
5
|
+
}, ie = (i, e) => {
|
|
6
6
|
i !== void 0 && e !== void 0 && (e.srcObject = i, e.play());
|
|
7
|
-
},
|
|
7
|
+
}, se = (i) => {
|
|
8
8
|
i.onaddtrack = null, i.onremovetrack = null, i.getTracks().forEach((e) => {
|
|
9
9
|
i?.removeTrack(e), e.onended = null, e.onmute = null, e.onunmute = null, e.stop();
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
|
-
let
|
|
12
|
+
let V = !1;
|
|
13
13
|
const p = (i, ...e) => {
|
|
14
|
-
|
|
14
|
+
V && console.log(
|
|
15
15
|
`%c usc-rtc-devtools %c ${i} %c `,
|
|
16
16
|
"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",
|
|
17
17
|
"background:#41b883 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff",
|
|
18
18
|
"background:transparent",
|
|
19
19
|
...e
|
|
20
20
|
);
|
|
21
|
-
},
|
|
22
|
-
|
|
21
|
+
}, pe = (i, ...e) => {
|
|
22
|
+
V && console.log(
|
|
23
23
|
`%c usc-rtc-devtools %c ${i} %c `,
|
|
24
24
|
"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",
|
|
25
25
|
"background:#ff0000 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff",
|
|
26
26
|
"background:transparent",
|
|
27
27
|
...e
|
|
28
28
|
);
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
|
|
29
|
+
}, We = () => {
|
|
30
|
+
V = !1;
|
|
31
|
+
}, Ue = () => {
|
|
32
|
+
V = !0;
|
|
33
33
|
};
|
|
34
|
-
class
|
|
34
|
+
class ge {
|
|
35
35
|
static formatOffer(e) {
|
|
36
36
|
let { sdp: t } = e;
|
|
37
37
|
if (t === void 0)
|
|
@@ -41,12 +41,12 @@ class ve {
|
|
|
41
41
|
`), e.sdp = t, e;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
var
|
|
45
|
-
function
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
var i = typeof Reflect == "object" ? Reflect : null, e = i && typeof i.apply == "function" ? i.apply : function(o,
|
|
49
|
-
return Function.prototype.apply.call(o,
|
|
44
|
+
var P = { exports: {} }, J;
|
|
45
|
+
function ke() {
|
|
46
|
+
if (J) return P.exports;
|
|
47
|
+
J = 1;
|
|
48
|
+
var i = typeof Reflect == "object" ? Reflect : null, e = i && typeof i.apply == "function" ? i.apply : function(o, c, u) {
|
|
49
|
+
return Function.prototype.apply.call(o, c, u);
|
|
50
50
|
}, t;
|
|
51
51
|
i && typeof i.ownKeys == "function" ? t = i.ownKeys : Object.getOwnPropertySymbols ? t = function(o) {
|
|
52
52
|
return Object.getOwnPropertyNames(o).concat(Object.getOwnPropertySymbols(o));
|
|
@@ -62,21 +62,21 @@ function pe() {
|
|
|
62
62
|
function r() {
|
|
63
63
|
r.init.call(this);
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
var
|
|
67
|
-
function
|
|
65
|
+
P.exports = r, P.exports.once = fe, r.EventEmitter = r, r.prototype._events = void 0, r.prototype._eventsCount = 0, r.prototype._maxListeners = void 0;
|
|
66
|
+
var d = 10;
|
|
67
|
+
function h(a) {
|
|
68
68
|
if (typeof a != "function")
|
|
69
69
|
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof a);
|
|
70
70
|
}
|
|
71
71
|
Object.defineProperty(r, "defaultMaxListeners", {
|
|
72
72
|
enumerable: !0,
|
|
73
73
|
get: function() {
|
|
74
|
-
return
|
|
74
|
+
return d;
|
|
75
75
|
},
|
|
76
76
|
set: function(a) {
|
|
77
77
|
if (typeof a != "number" || a < 0 || n(a))
|
|
78
78
|
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + a + ".");
|
|
79
|
-
|
|
79
|
+
d = a;
|
|
80
80
|
}
|
|
81
81
|
}), r.init = function() {
|
|
82
82
|
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
@@ -91,105 +91,105 @@ function pe() {
|
|
|
91
91
|
r.prototype.getMaxListeners = function() {
|
|
92
92
|
return k(this);
|
|
93
93
|
}, r.prototype.emit = function(o) {
|
|
94
|
-
for (var
|
|
95
|
-
var
|
|
94
|
+
for (var c = [], u = 1; u < arguments.length; u++) c.push(arguments[u]);
|
|
95
|
+
var l = o === "error", v = this._events;
|
|
96
96
|
if (v !== void 0)
|
|
97
|
-
|
|
98
|
-
else if (!
|
|
97
|
+
l = l && v.error === void 0;
|
|
98
|
+
else if (!l)
|
|
99
99
|
return !1;
|
|
100
|
-
if (
|
|
100
|
+
if (l) {
|
|
101
101
|
var f;
|
|
102
|
-
if (
|
|
102
|
+
if (c.length > 0 && (f = c[0]), f instanceof Error)
|
|
103
103
|
throw f;
|
|
104
|
-
var
|
|
105
|
-
throw
|
|
104
|
+
var w = new Error("Unhandled error." + (f ? " (" + f.message + ")" : ""));
|
|
105
|
+
throw w.context = f, w;
|
|
106
106
|
}
|
|
107
|
-
var
|
|
108
|
-
if (
|
|
107
|
+
var I = v[o];
|
|
108
|
+
if (I === void 0)
|
|
109
109
|
return !1;
|
|
110
|
-
if (typeof
|
|
111
|
-
e(
|
|
110
|
+
if (typeof I == "function")
|
|
111
|
+
e(I, this, c);
|
|
112
112
|
else
|
|
113
|
-
for (var
|
|
114
|
-
e(
|
|
113
|
+
for (var B = I.length, ve = K(I, B), u = 0; u < B; ++u)
|
|
114
|
+
e(ve[u], this, c);
|
|
115
115
|
return !0;
|
|
116
116
|
};
|
|
117
|
-
function
|
|
118
|
-
var
|
|
119
|
-
if (
|
|
117
|
+
function C(a, o, c, u) {
|
|
118
|
+
var l, v, f;
|
|
119
|
+
if (h(c), v = a._events, v === void 0 ? (v = a._events = /* @__PURE__ */ Object.create(null), a._eventsCount = 0) : (v.newListener !== void 0 && (a.emit(
|
|
120
120
|
"newListener",
|
|
121
121
|
o,
|
|
122
|
-
|
|
122
|
+
c.listener ? c.listener : c
|
|
123
123
|
), v = a._events), f = v[o]), f === void 0)
|
|
124
|
-
f = v[o] =
|
|
125
|
-
else if (typeof f == "function" ? f = v[o] = u ? [
|
|
124
|
+
f = v[o] = c, ++a._eventsCount;
|
|
125
|
+
else if (typeof f == "function" ? f = v[o] = u ? [c, f] : [f, c] : u ? f.unshift(c) : f.push(c), l = k(a), l > 0 && f.length > l && !f.warned) {
|
|
126
126
|
f.warned = !0;
|
|
127
|
-
var
|
|
128
|
-
|
|
127
|
+
var w = new Error("Possible EventEmitter memory leak detected. " + f.length + " " + String(o) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
128
|
+
w.name = "MaxListenersExceededWarning", w.emitter = a, w.type = o, w.count = f.length, s(w);
|
|
129
129
|
}
|
|
130
130
|
return a;
|
|
131
131
|
}
|
|
132
|
-
r.prototype.addListener = function(o,
|
|
133
|
-
return
|
|
134
|
-
}, r.prototype.on = r.prototype.addListener, r.prototype.prependListener = function(o,
|
|
135
|
-
return
|
|
132
|
+
r.prototype.addListener = function(o, c) {
|
|
133
|
+
return C(this, o, c, !1);
|
|
134
|
+
}, r.prototype.on = r.prototype.addListener, r.prototype.prependListener = function(o, c) {
|
|
135
|
+
return C(this, o, c, !0);
|
|
136
136
|
};
|
|
137
137
|
function A() {
|
|
138
138
|
if (!this.fired)
|
|
139
139
|
return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
140
140
|
}
|
|
141
|
-
function L(a, o,
|
|
142
|
-
var u = { fired: !1, wrapFn: void 0, target: a, type: o, listener:
|
|
143
|
-
return
|
|
144
|
-
}
|
|
145
|
-
r.prototype.once = function(o,
|
|
146
|
-
return
|
|
147
|
-
}, r.prototype.prependOnceListener = function(o,
|
|
148
|
-
return
|
|
149
|
-
}, r.prototype.removeListener = function(o,
|
|
150
|
-
var u,
|
|
151
|
-
if (
|
|
141
|
+
function L(a, o, c) {
|
|
142
|
+
var u = { fired: !1, wrapFn: void 0, target: a, type: o, listener: c }, l = A.bind(u);
|
|
143
|
+
return l.listener = c, u.wrapFn = l, l;
|
|
144
|
+
}
|
|
145
|
+
r.prototype.once = function(o, c) {
|
|
146
|
+
return h(c), this.on(o, L(this, o, c)), this;
|
|
147
|
+
}, r.prototype.prependOnceListener = function(o, c) {
|
|
148
|
+
return h(c), this.prependListener(o, L(this, o, c)), this;
|
|
149
|
+
}, r.prototype.removeListener = function(o, c) {
|
|
150
|
+
var u, l, v, f, w;
|
|
151
|
+
if (h(c), l = this._events, l === void 0)
|
|
152
152
|
return this;
|
|
153
|
-
if (u =
|
|
153
|
+
if (u = l[o], u === void 0)
|
|
154
154
|
return this;
|
|
155
|
-
if (u ===
|
|
156
|
-
--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete
|
|
155
|
+
if (u === c || u.listener === c)
|
|
156
|
+
--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete l[o], l.removeListener && this.emit("removeListener", o, u.listener || c));
|
|
157
157
|
else if (typeof u != "function") {
|
|
158
158
|
for (v = -1, f = u.length - 1; f >= 0; f--)
|
|
159
|
-
if (u[f] ===
|
|
160
|
-
|
|
159
|
+
if (u[f] === c || u[f].listener === c) {
|
|
160
|
+
w = u[f].listener, v = f;
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
163
|
if (v < 0)
|
|
164
164
|
return this;
|
|
165
|
-
v === 0 ? u.shift() :
|
|
165
|
+
v === 0 ? u.shift() : le(u, v), u.length === 1 && (l[o] = u[0]), l.removeListener !== void 0 && this.emit("removeListener", o, w || c);
|
|
166
166
|
}
|
|
167
167
|
return this;
|
|
168
168
|
}, r.prototype.off = r.prototype.removeListener, r.prototype.removeAllListeners = function(o) {
|
|
169
|
-
var
|
|
169
|
+
var c, u, l;
|
|
170
170
|
if (u = this._events, u === void 0)
|
|
171
171
|
return this;
|
|
172
172
|
if (u.removeListener === void 0)
|
|
173
173
|
return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : u[o] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete u[o]), this;
|
|
174
174
|
if (arguments.length === 0) {
|
|
175
175
|
var v = Object.keys(u), f;
|
|
176
|
-
for (
|
|
177
|
-
f = v[
|
|
176
|
+
for (l = 0; l < v.length; ++l)
|
|
177
|
+
f = v[l], f !== "removeListener" && this.removeAllListeners(f);
|
|
178
178
|
return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
|
|
179
179
|
}
|
|
180
|
-
if (
|
|
181
|
-
this.removeListener(o,
|
|
182
|
-
else if (
|
|
183
|
-
for (
|
|
184
|
-
this.removeListener(o,
|
|
180
|
+
if (c = u[o], typeof c == "function")
|
|
181
|
+
this.removeListener(o, c);
|
|
182
|
+
else if (c !== void 0)
|
|
183
|
+
for (l = c.length - 1; l >= 0; l--)
|
|
184
|
+
this.removeListener(o, c[l]);
|
|
185
185
|
return this;
|
|
186
186
|
};
|
|
187
|
-
function F(a, o,
|
|
187
|
+
function F(a, o, c) {
|
|
188
188
|
var u = a._events;
|
|
189
189
|
if (u === void 0)
|
|
190
190
|
return [];
|
|
191
|
-
var
|
|
192
|
-
return
|
|
191
|
+
var l = u[o];
|
|
192
|
+
return l === void 0 ? [] : typeof l == "function" ? c ? [l.listener || l] : [l] : c ? he(l) : K(l, l.length);
|
|
193
193
|
}
|
|
194
194
|
r.prototype.listeners = function(o) {
|
|
195
195
|
return F(this, o, !0);
|
|
@@ -201,60 +201,60 @@ function pe() {
|
|
|
201
201
|
function Y(a) {
|
|
202
202
|
var o = this._events;
|
|
203
203
|
if (o !== void 0) {
|
|
204
|
-
var
|
|
205
|
-
if (typeof
|
|
204
|
+
var c = o[a];
|
|
205
|
+
if (typeof c == "function")
|
|
206
206
|
return 1;
|
|
207
|
-
if (
|
|
208
|
-
return
|
|
207
|
+
if (c !== void 0)
|
|
208
|
+
return c.length;
|
|
209
209
|
}
|
|
210
210
|
return 0;
|
|
211
211
|
}
|
|
212
212
|
r.prototype.eventNames = function() {
|
|
213
213
|
return this._eventsCount > 0 ? t(this._events) : [];
|
|
214
214
|
};
|
|
215
|
-
function
|
|
216
|
-
for (var
|
|
217
|
-
|
|
218
|
-
return
|
|
215
|
+
function K(a, o) {
|
|
216
|
+
for (var c = new Array(o), u = 0; u < o; ++u)
|
|
217
|
+
c[u] = a[u];
|
|
218
|
+
return c;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function le(a, o) {
|
|
221
221
|
for (; o + 1 < a.length; o++)
|
|
222
222
|
a[o] = a[o + 1];
|
|
223
223
|
a.pop();
|
|
224
224
|
}
|
|
225
|
-
function
|
|
226
|
-
for (var o = new Array(a.length),
|
|
227
|
-
o[
|
|
225
|
+
function he(a) {
|
|
226
|
+
for (var o = new Array(a.length), c = 0; c < o.length; ++c)
|
|
227
|
+
o[c] = a[c].listener || a[c];
|
|
228
228
|
return o;
|
|
229
229
|
}
|
|
230
|
-
function
|
|
231
|
-
return new Promise(function(
|
|
232
|
-
function
|
|
230
|
+
function fe(a, o) {
|
|
231
|
+
return new Promise(function(c, u) {
|
|
232
|
+
function l(f) {
|
|
233
233
|
a.removeListener(o, v), u(f);
|
|
234
234
|
}
|
|
235
235
|
function v() {
|
|
236
|
-
typeof a.removeListener == "function" && a.removeListener("error",
|
|
236
|
+
typeof a.removeListener == "function" && a.removeListener("error", l), c([].slice.call(arguments));
|
|
237
237
|
}
|
|
238
|
-
|
|
238
|
+
$(a, o, v, { once: !0 }), o !== "error" && me(a, l, { once: !0 });
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
|
-
function
|
|
242
|
-
typeof a.on == "function" &&
|
|
241
|
+
function me(a, o, c) {
|
|
242
|
+
typeof a.on == "function" && $(a, "error", o, c);
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function $(a, o, c, u) {
|
|
245
245
|
if (typeof a.on == "function")
|
|
246
|
-
u.once ? a.once(o,
|
|
246
|
+
u.once ? a.once(o, c) : a.on(o, c);
|
|
247
247
|
else if (typeof a.addEventListener == "function")
|
|
248
|
-
a.addEventListener(o, function
|
|
249
|
-
u.once && a.removeEventListener(o,
|
|
248
|
+
a.addEventListener(o, function l(v) {
|
|
249
|
+
u.once && a.removeEventListener(o, l), c(v);
|
|
250
250
|
});
|
|
251
251
|
else
|
|
252
252
|
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof a);
|
|
253
253
|
}
|
|
254
|
-
return
|
|
254
|
+
return P.exports;
|
|
255
255
|
}
|
|
256
|
-
var q =
|
|
257
|
-
class
|
|
256
|
+
var q = ke();
|
|
257
|
+
class Ce extends q.EventEmitter {
|
|
258
258
|
constructor() {
|
|
259
259
|
super(), this.localMediaStream = new MediaStream(), this.videoConstrains = { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { ideal: 20, max: 30 }, aspectRatio: { ideal: 16 / 9 } }, this.audioConstrants = { noiseSuppression: !0, echoCancellation: !0, autoGainControl: !0 }, super.setMaxListeners(0);
|
|
260
260
|
}
|
|
@@ -289,7 +289,7 @@ class ge extends q.EventEmitter {
|
|
|
289
289
|
* 将流渲染到dom上
|
|
290
290
|
*/
|
|
291
291
|
renderLocalStreamToContainer(e) {
|
|
292
|
-
|
|
292
|
+
ie(this.localMediaStream, e);
|
|
293
293
|
}
|
|
294
294
|
/**
|
|
295
295
|
* 获取所有的输入设备源
|
|
@@ -356,7 +356,7 @@ class ge extends q.EventEmitter {
|
|
|
356
356
|
this.releaseTrack(this.audioTrack), this.releaseTrack(this.videoTrack), this.audioTrack = void 0, this.videoTrack = void 0, this.localMediaStream = void 0;
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
-
class
|
|
359
|
+
class we extends Ce {
|
|
360
360
|
constructor() {
|
|
361
361
|
super(), this.videoCodecs = [], this.audioCodecs = [], this.audioReciveCodecs = [], this.preferCodec(), this.peerConnection = this.buildConnection();
|
|
362
362
|
}
|
|
@@ -425,13 +425,13 @@ class ke extends ge {
|
|
|
425
425
|
preferCodec(e = "H264", t = "PCMA") {
|
|
426
426
|
this.videoCodecs = [];
|
|
427
427
|
let s = RTCRtpSender.getCapabilities("video");
|
|
428
|
-
s !== null && this.videoCodecs.push(...s.codecs.filter((
|
|
428
|
+
s !== null && this.videoCodecs.push(...s.codecs.filter((h) => h.mimeType === `video/${e}`));
|
|
429
429
|
let n = RTCRtpReceiver.getCapabilities("video");
|
|
430
|
-
n !== null && this.videoCodecs.push(...n.codecs.filter((
|
|
430
|
+
n !== null && this.videoCodecs.push(...n.codecs.filter((h) => h.mimeType === `video/${e}`)), this.audioCodecs = [];
|
|
431
431
|
let r = RTCRtpSender.getCapabilities("audio");
|
|
432
|
-
r !== null && this.audioCodecs.push(...r.codecs.filter((
|
|
433
|
-
let
|
|
434
|
-
|
|
432
|
+
r !== null && this.audioCodecs.push(...r.codecs.filter((h) => h.mimeType === `audio/${t}`));
|
|
433
|
+
let d = RTCRtpReceiver.getCapabilities("audio");
|
|
434
|
+
d !== null && this.audioCodecs.push(...d.codecs.filter((h) => h.mimeType === `audio/${t}`));
|
|
435
435
|
}
|
|
436
436
|
trackIsInPeerConnection(e) {
|
|
437
437
|
return this.peerConnection?.getSenders().some((t) => t.track?.id === e.id) ?? !1;
|
|
@@ -464,7 +464,7 @@ class ke extends ge {
|
|
|
464
464
|
e.sender.track !== null && (e.sender.track.kind === "video" ? e.setCodecPreferences([...this.videoCodecs]) : e.sender.track.kind === "audio" && e.setCodecPreferences([...this.audioCodecs]));
|
|
465
465
|
});
|
|
466
466
|
} catch (e) {
|
|
467
|
-
|
|
467
|
+
pe("preferCodec error", e, this.audioCodecs, this.videoCodecs);
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
/**
|
|
@@ -475,7 +475,7 @@ class ke extends ge {
|
|
|
475
475
|
throw new Error("session is closed !");
|
|
476
476
|
this.updateTracks();
|
|
477
477
|
let e = await this.peerConnection.createOffer();
|
|
478
|
-
return e =
|
|
478
|
+
return e = ge.formatOffer(e), await this.peerConnection.setLocalDescription(e), e;
|
|
479
479
|
}
|
|
480
480
|
/**
|
|
481
481
|
* set offer
|
|
@@ -523,11 +523,11 @@ class ke extends ge {
|
|
|
523
523
|
* 销毁会话
|
|
524
524
|
*/
|
|
525
525
|
close() {
|
|
526
|
-
super.close(), this.peerConnection !== void 0 && (this.closeConnection(this.peerConnection), this.peerConnection = void 0), this.remoteStream !== void 0 &&
|
|
526
|
+
super.close(), this.peerConnection !== void 0 && (this.closeConnection(this.peerConnection), this.peerConnection = void 0), this.remoteStream !== void 0 && se(this.remoteStream);
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
var N = /* @__PURE__ */ ((i) => (i[i.timeout = 408] = "timeout", i[i.reject = 488] = "reject", i[i.busy = 486] = "busy", i[i.notfound = 404] = "notfound", i[i.notAllowedMedia = 415] = "notAllowedMedia", i[i.ok = 200] = "ok", i))(N || {});
|
|
530
|
-
class
|
|
530
|
+
class ne extends we {
|
|
531
531
|
constructor(e, t, s) {
|
|
532
532
|
super(), this.sessionId = t, this.rtcClient = e, this.remoteNumber = s;
|
|
533
533
|
}
|
|
@@ -567,7 +567,7 @@ class ie extends ke {
|
|
|
567
567
|
* 直接setoffer服务端有一些问题,使用此方案来处理一下,看看是否可行
|
|
568
568
|
*/
|
|
569
569
|
async pickNewConnection() {
|
|
570
|
-
this.peerConnection !== void 0 && this.closeConnection(this.peerConnection), this.peerConnection = this.buildConnection(), this.remoteStream !== void 0 && (
|
|
570
|
+
this.peerConnection !== void 0 && this.closeConnection(this.peerConnection), this.peerConnection = this.buildConnection(), this.remoteStream !== void 0 && (se(this.remoteStream), this.remoteStream = void 0, this.acceptCall());
|
|
571
571
|
}
|
|
572
572
|
checkIsNotUndefined(...e) {
|
|
573
573
|
for (const t of e)
|
|
@@ -581,21 +581,21 @@ class ie extends ke {
|
|
|
581
581
|
}
|
|
582
582
|
// 自动播放远程流到指定容器
|
|
583
583
|
playRemoteStream(e, t) {
|
|
584
|
-
const { audioOnly: s = !1
|
|
585
|
-
|
|
586
|
-
if (
|
|
587
|
-
const
|
|
588
|
-
|
|
584
|
+
const { audioOnly: s = !1 } = t || {};
|
|
585
|
+
this.on(S.stream, (n) => {
|
|
586
|
+
if (n.stream) {
|
|
587
|
+
const r = s ? new MediaStream(n.stream.getAudioTracks()) : n.stream;
|
|
588
|
+
ie(r, e);
|
|
589
589
|
}
|
|
590
590
|
}), this.on(S.bye, () => {
|
|
591
|
-
e && (e
|
|
591
|
+
e && te(e);
|
|
592
592
|
});
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
|
-
var
|
|
596
|
-
class Q extends
|
|
595
|
+
var b = /* @__PURE__ */ ((i) => (i.audio = "audio", i.video = "video", i.audioVideo = "audioVideo", i.unknown = "unknown", i))(b || {});
|
|
596
|
+
class Q extends ne {
|
|
597
597
|
constructor() {
|
|
598
|
-
super(...arguments), this.responseCallType =
|
|
598
|
+
super(...arguments), this.responseCallType = b.unknown;
|
|
599
599
|
}
|
|
600
600
|
/**
|
|
601
601
|
* 开始会话
|
|
@@ -604,9 +604,9 @@ class Q extends ie {
|
|
|
604
604
|
let [e, t] = this.checkIsNotUndefined(this.rtcClient, this.remoteNumber), s = await this.createOffer(), { status: n, sdp: r } = await e.invite(t, this.sessionId, s.sdp);
|
|
605
605
|
if (n === N.ok) {
|
|
606
606
|
await this.setAnswer(r);
|
|
607
|
-
const
|
|
608
|
-
`),
|
|
609
|
-
this.responseCallType =
|
|
607
|
+
const d = r.split(`\r
|
|
608
|
+
`), h = d.find((C) => C.startsWith("m=audio")), k = d.find((C) => C.startsWith("m=video"));
|
|
609
|
+
this.responseCallType = h && k ? b.audioVideo : h ? b.audio : k ? b.video : b.unknown;
|
|
610
610
|
}
|
|
611
611
|
return n;
|
|
612
612
|
}
|
|
@@ -617,17 +617,17 @@ class Q extends ie {
|
|
|
617
617
|
this.remoteNumber = e;
|
|
618
618
|
}
|
|
619
619
|
}
|
|
620
|
-
const
|
|
620
|
+
const x = class x {
|
|
621
621
|
constructor(e, t, s, n) {
|
|
622
|
-
this.req = e, this.seq = 0, this.from = t, this.to = s, this.registerid = `${
|
|
622
|
+
this.req = e, this.seq = 0, this.from = t, this.to = s, this.registerid = `${x.random}@${t}`, n !== void 0 && Object.assign(this, n);
|
|
623
623
|
}
|
|
624
624
|
};
|
|
625
|
-
|
|
626
|
-
let
|
|
627
|
-
var
|
|
628
|
-
const
|
|
629
|
-
`, z = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",
|
|
630
|
-
function
|
|
625
|
+
x.random = String(Date.now());
|
|
626
|
+
let y = x;
|
|
627
|
+
var M = /* @__PURE__ */ ((i) => (i.connected = "connected", i.disconnected = "disconnected", i.message = "message", i))(M || {});
|
|
628
|
+
const re = `(function(){"use strict";let e,n=!1;const o=self,a={},r={timeout:5*1e3,timeoutObj:null,reset(){return clearInterval(this.timeoutObj),this},sendOnline(){e.readyState===1&&e.send(JSON.stringify(Object.assign(a,{seq:++a.seq})))},start(){this.timeout!==0&&(this.timeoutObj=setInterval(()=>{this.sendOnline()},this.timeout))}};self.addEventListener("message",function(s){const t=s.data;switch(t.cmd){case"config":Object.assign(a,t.heartBeat),r.timeout=t.heartTime*1e3;break;case"start":self.postMessage({type:"webWorker",data:"启动webWorker"}),i(t.url);break;case"close":n=!0,e.close(),self.postMessage({type:"webWorker",data:"停止webWorker"}),self.postMessage({type:"close",data:"close"+new Date().toTimeString()}),self.close();break;case"msg":e.readyState===1&&e.send(JSON.stringify(t.data))}},!1);const i=function(s){e||(e=new WebSocket(s),e.onerror=function(t){c(s)},e.onclose=function(t){c(s)},e.onopen=t=>{o.postMessage({type:"open",data:"start"+new Date().toTimeString()}),r.reset().start()},e.onmessage=t=>{const l=JSON.parse(t.data);o.postMessage({type:"webSocket",data:l})})};function c(s){n||(n=!0,setTimeout(function(){e=null,i(s),n=!1},2e3))}})();
|
|
629
|
+
`, z = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", re], { type: "text/javascript;charset=utf-8" });
|
|
630
|
+
function Ee(i) {
|
|
631
631
|
let e;
|
|
632
632
|
try {
|
|
633
633
|
if (e = z && (self.URL || self.webkitURL).createObjectURL(z), !e) throw "";
|
|
@@ -639,16 +639,16 @@ function we(i) {
|
|
|
639
639
|
}), t;
|
|
640
640
|
} catch {
|
|
641
641
|
return new Worker(
|
|
642
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
642
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(re),
|
|
643
643
|
{
|
|
644
644
|
name: i?.name
|
|
645
645
|
}
|
|
646
646
|
);
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
class
|
|
649
|
+
class Te extends q.EventEmitter {
|
|
650
650
|
constructor(e, t, s) {
|
|
651
|
-
super(), this.server = e, this.ws = new
|
|
651
|
+
super(), this.server = e, this.ws = new Ee(), this.configHeartBeat(t, s);
|
|
652
652
|
}
|
|
653
653
|
/**
|
|
654
654
|
* connect to the websocket server
|
|
@@ -658,10 +658,10 @@ class Ce extends q.EventEmitter {
|
|
|
658
658
|
const { type: t, data: s } = e.data;
|
|
659
659
|
switch (t) {
|
|
660
660
|
case "webSocket":
|
|
661
|
-
p("websocket recive message ", s), this.emit(
|
|
661
|
+
p("websocket recive message ", s), this.emit(M.message, s);
|
|
662
662
|
return;
|
|
663
663
|
case "open":
|
|
664
|
-
p("websocket connected ", this.server), this.emit(
|
|
664
|
+
p("websocket connected ", this.server), this.emit(M.connected);
|
|
665
665
|
return;
|
|
666
666
|
}
|
|
667
667
|
};
|
|
@@ -688,7 +688,7 @@ class Ce extends q.EventEmitter {
|
|
|
688
688
|
p("websocket send message ", e), e !== void 0 && this.ws !== void 0 && this.ws.postMessage({ cmd: "msg", data: e });
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
|
-
class
|
|
691
|
+
class be extends q.EventEmitter {
|
|
692
692
|
// constructor(server: string, localNumber: string, expireTime: number, heartTime: number) {
|
|
693
693
|
// super(server, localNumber, expireTime, heartTime)
|
|
694
694
|
// }
|
|
@@ -701,12 +701,12 @@ class Ee extends q.EventEmitter {
|
|
|
701
701
|
async testWs(e) {
|
|
702
702
|
return e.reduce((t, s) => t.then(
|
|
703
703
|
(n) => Promise.resolve(n),
|
|
704
|
-
(n) => new Promise((r,
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
n.push(s),
|
|
708
|
-
},
|
|
709
|
-
|
|
704
|
+
(n) => new Promise((r, d) => {
|
|
705
|
+
const h = new WebSocket(s);
|
|
706
|
+
h.onopen = () => {
|
|
707
|
+
n.push(s), h.close(), r(n);
|
|
708
|
+
}, h.onclose = () => {
|
|
709
|
+
d(n);
|
|
710
710
|
};
|
|
711
711
|
})
|
|
712
712
|
), Promise.reject([])).then(
|
|
@@ -725,16 +725,16 @@ class Ee extends q.EventEmitter {
|
|
|
725
725
|
return new Promise((s, n) => {
|
|
726
726
|
if (t.length > 0) {
|
|
727
727
|
this.activeServer = t[0];
|
|
728
|
-
let r = new
|
|
728
|
+
let r = new Te(
|
|
729
729
|
this.activeServer,
|
|
730
|
-
new T
|
|
730
|
+
new y(T.MESSAGE_TYPE_REGISTER, this.localNumber, this.localNumber, { expire: this.expireTime }),
|
|
731
731
|
this.heartTime
|
|
732
732
|
);
|
|
733
|
-
r.on(
|
|
733
|
+
r.on(M.connected, () => {
|
|
734
734
|
this.socketWorker = r, this.onConnected(), s();
|
|
735
|
-
}), r.on(
|
|
736
|
-
this.socketWorker = void 0, this.onDisConnected(
|
|
737
|
-
}), r.on(
|
|
735
|
+
}), r.on(M.disconnected, (d) => {
|
|
736
|
+
this.socketWorker = void 0, this.onDisConnected(d), n("socketWorker connecion failed");
|
|
737
|
+
}), r.on(M.message, (d) => this.onReviceMessage(d)), r.connect();
|
|
738
738
|
} else
|
|
739
739
|
n("server is empty");
|
|
740
740
|
});
|
|
@@ -753,7 +753,7 @@ class Ee extends q.EventEmitter {
|
|
|
753
753
|
this.socketWorker !== void 0 && (this.unRegister(), this.socketWorker.close(), this.socketWorker = void 0);
|
|
754
754
|
}
|
|
755
755
|
}
|
|
756
|
-
class
|
|
756
|
+
class ye extends be {
|
|
757
757
|
constructor() {
|
|
758
758
|
super(...arguments), this.asyncProducer = /* @__PURE__ */ new Map();
|
|
759
759
|
}
|
|
@@ -772,7 +772,7 @@ class be extends Ee {
|
|
|
772
772
|
}
|
|
773
773
|
//连接断开
|
|
774
774
|
onDisConnected(e) {
|
|
775
|
-
this.asyncProducer.clear(), this.emit(
|
|
775
|
+
this.asyncProducer.clear(), this.emit(j.disconnected, e);
|
|
776
776
|
}
|
|
777
777
|
//invoke on message reviced
|
|
778
778
|
onReviceMessage(e) {
|
|
@@ -780,16 +780,16 @@ class be extends Ee {
|
|
|
780
780
|
t !== void 0 ? this.getAsyncResolve(s)?.call(void 0, e) : this.processMessage(e);
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
|
-
class
|
|
783
|
+
class Se extends ye {
|
|
784
784
|
/**
|
|
785
785
|
* send register message to the server
|
|
786
786
|
*/
|
|
787
787
|
async register() {
|
|
788
|
-
let e = new T
|
|
788
|
+
let e = new y(T.MESSAGE_TYPE_REGISTER, this.localNumber, this.localNumber, { expire: this.expireTime });
|
|
789
789
|
return this.sendRespondableMessage(e);
|
|
790
790
|
}
|
|
791
791
|
unRegister() {
|
|
792
|
-
let e = new T
|
|
792
|
+
let e = new y(T.MESSAGE_TYPE_REGISTER, this.localNumber, this.localNumber, { expire: 0 });
|
|
793
793
|
this.sendMessage(e);
|
|
794
794
|
}
|
|
795
795
|
/**
|
|
@@ -800,7 +800,7 @@ class ye extends be {
|
|
|
800
800
|
* @returns
|
|
801
801
|
*/
|
|
802
802
|
async invite(e, t, s) {
|
|
803
|
-
return this.sendRespondableMessage(new T
|
|
803
|
+
return this.sendRespondableMessage(new y(T.MESSAGE_TYPE_INVITE, this.localNumber, e, { cid: t, sdp: s }));
|
|
804
804
|
}
|
|
805
805
|
/**
|
|
806
806
|
* send a ice request to user
|
|
@@ -817,7 +817,7 @@ class ye extends be {
|
|
|
817
817
|
* @param cid session id
|
|
818
818
|
*/
|
|
819
819
|
sendBye(e, t) {
|
|
820
|
-
return this.sendMessage(new T
|
|
820
|
+
return this.sendMessage(new y(T.MESSAGE_TYPE_BYE, this.localNumber, e, { cid: t }));
|
|
821
821
|
}
|
|
822
822
|
/**
|
|
823
823
|
* answer message
|
|
@@ -842,10 +842,10 @@ class ye extends be {
|
|
|
842
842
|
}
|
|
843
843
|
//发送dtmf
|
|
844
844
|
async sendDtmf(e, t, s) {
|
|
845
|
-
return this.sendMessage(new T
|
|
845
|
+
return this.sendMessage(new y(T.MESSAGE_TYPE_INFO, this.localNumber, e, { cid: t, info: { msg: "dtmf", dtmf: s } }));
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
-
var
|
|
848
|
+
var Le;
|
|
849
849
|
function _() {
|
|
850
850
|
}
|
|
851
851
|
_.prototype = /* @__PURE__ */ Object.create(null);
|
|
@@ -859,61 +859,61 @@ m.prototype._events = void 0;
|
|
|
859
859
|
m.prototype._maxListeners = void 0;
|
|
860
860
|
m.defaultMaxListeners = 10;
|
|
861
861
|
m.init = function() {
|
|
862
|
-
this.domain = null, m.usingDomains &&
|
|
862
|
+
this.domain = null, m.usingDomains && Le.active, (!this._events || this._events === Object.getPrototypeOf(this)._events) && (this._events = new _(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
863
863
|
};
|
|
864
864
|
m.prototype.setMaxListeners = function(e) {
|
|
865
865
|
if (typeof e != "number" || e < 0 || isNaN(e))
|
|
866
866
|
throw new TypeError('"n" argument must be a positive number');
|
|
867
867
|
return this._maxListeners = e, this;
|
|
868
868
|
};
|
|
869
|
-
function
|
|
869
|
+
function oe(i) {
|
|
870
870
|
return i._maxListeners === void 0 ? m.defaultMaxListeners : i._maxListeners;
|
|
871
871
|
}
|
|
872
872
|
m.prototype.getMaxListeners = function() {
|
|
873
|
-
return
|
|
873
|
+
return oe(this);
|
|
874
874
|
};
|
|
875
|
-
function
|
|
875
|
+
function _e(i, e, t) {
|
|
876
876
|
if (e)
|
|
877
877
|
i.call(t);
|
|
878
878
|
else
|
|
879
|
-
for (var s = i.length, n =
|
|
879
|
+
for (var s = i.length, n = O(i, s), r = 0; r < s; ++r)
|
|
880
880
|
n[r].call(t);
|
|
881
881
|
}
|
|
882
|
-
function
|
|
882
|
+
function Me(i, e, t, s) {
|
|
883
883
|
if (e)
|
|
884
884
|
i.call(t, s);
|
|
885
885
|
else
|
|
886
|
-
for (var n = i.length, r =
|
|
887
|
-
r[
|
|
886
|
+
for (var n = i.length, r = O(i, n), d = 0; d < n; ++d)
|
|
887
|
+
r[d].call(t, s);
|
|
888
888
|
}
|
|
889
|
-
function
|
|
889
|
+
function Re(i, e, t, s, n) {
|
|
890
890
|
if (e)
|
|
891
891
|
i.call(t, s, n);
|
|
892
892
|
else
|
|
893
|
-
for (var r = i.length,
|
|
894
|
-
|
|
893
|
+
for (var r = i.length, d = O(i, r), h = 0; h < r; ++h)
|
|
894
|
+
d[h].call(t, s, n);
|
|
895
895
|
}
|
|
896
|
-
function
|
|
896
|
+
function Ie(i, e, t, s, n, r) {
|
|
897
897
|
if (e)
|
|
898
898
|
i.call(t, s, n, r);
|
|
899
899
|
else
|
|
900
|
-
for (var
|
|
901
|
-
|
|
900
|
+
for (var d = i.length, h = O(i, d), k = 0; k < d; ++k)
|
|
901
|
+
h[k].call(t, s, n, r);
|
|
902
902
|
}
|
|
903
|
-
function
|
|
903
|
+
function Ne(i, e, t, s) {
|
|
904
904
|
if (e)
|
|
905
905
|
i.apply(t, s);
|
|
906
906
|
else
|
|
907
|
-
for (var n = i.length, r =
|
|
908
|
-
r[
|
|
907
|
+
for (var n = i.length, r = O(i, n), d = 0; d < n; ++d)
|
|
908
|
+
r[d].apply(t, s);
|
|
909
909
|
}
|
|
910
910
|
m.prototype.emit = function(e) {
|
|
911
|
-
var t, s, n, r,
|
|
912
|
-
if (
|
|
913
|
-
|
|
914
|
-
else if (!
|
|
911
|
+
var t, s, n, r, d, h, k, C = e === "error";
|
|
912
|
+
if (h = this._events, h)
|
|
913
|
+
C = C && h.error == null;
|
|
914
|
+
else if (!C)
|
|
915
915
|
return !1;
|
|
916
|
-
if (k = this.domain,
|
|
916
|
+
if (k = this.domain, C) {
|
|
917
917
|
if (t = arguments[1], k)
|
|
918
918
|
t || (t = new Error('Uncaught, unspecified "error" event')), t.domainEmitter = this, t.domain = k, t.domainThrown = !1, k.emit("error", t);
|
|
919
919
|
else {
|
|
@@ -924,59 +924,59 @@ m.prototype.emit = function(e) {
|
|
|
924
924
|
}
|
|
925
925
|
return !1;
|
|
926
926
|
}
|
|
927
|
-
if (s =
|
|
927
|
+
if (s = h[e], !s)
|
|
928
928
|
return !1;
|
|
929
929
|
var L = typeof s == "function";
|
|
930
930
|
switch (n = arguments.length, n) {
|
|
931
931
|
// fast cases
|
|
932
932
|
case 1:
|
|
933
|
-
|
|
933
|
+
_e(s, L, this);
|
|
934
934
|
break;
|
|
935
935
|
case 2:
|
|
936
|
-
|
|
936
|
+
Me(s, L, this, arguments[1]);
|
|
937
937
|
break;
|
|
938
938
|
case 3:
|
|
939
|
-
|
|
939
|
+
Re(s, L, this, arguments[1], arguments[2]);
|
|
940
940
|
break;
|
|
941
941
|
case 4:
|
|
942
|
-
|
|
942
|
+
Ie(s, L, this, arguments[1], arguments[2], arguments[3]);
|
|
943
943
|
break;
|
|
944
944
|
// slower
|
|
945
945
|
default:
|
|
946
|
-
for (r = new Array(n - 1),
|
|
947
|
-
r[
|
|
948
|
-
|
|
946
|
+
for (r = new Array(n - 1), d = 1; d < n; d++)
|
|
947
|
+
r[d - 1] = arguments[d];
|
|
948
|
+
Ne(s, L, this, r);
|
|
949
949
|
}
|
|
950
950
|
return !0;
|
|
951
951
|
};
|
|
952
|
-
function
|
|
953
|
-
var n, r,
|
|
952
|
+
function ae(i, e, t, s) {
|
|
953
|
+
var n, r, d;
|
|
954
954
|
if (typeof t != "function")
|
|
955
955
|
throw new TypeError('"listener" argument must be a function');
|
|
956
956
|
if (r = i._events, r ? (r.newListener && (i.emit(
|
|
957
957
|
"newListener",
|
|
958
958
|
e,
|
|
959
959
|
t.listener ? t.listener : t
|
|
960
|
-
), r = i._events),
|
|
961
|
-
|
|
962
|
-
else if (typeof
|
|
963
|
-
|
|
964
|
-
var
|
|
965
|
-
|
|
960
|
+
), r = i._events), d = r[e]) : (r = i._events = new _(), i._eventsCount = 0), !d)
|
|
961
|
+
d = r[e] = t, ++i._eventsCount;
|
|
962
|
+
else if (typeof d == "function" ? d = r[e] = s ? [t, d] : [d, t] : s ? d.unshift(t) : d.push(t), !d.warned && (n = oe(i), n && n > 0 && d.length > n)) {
|
|
963
|
+
d.warned = !0;
|
|
964
|
+
var h = new Error("Possible EventEmitter memory leak detected. " + d.length + " " + e + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
965
|
+
h.name = "MaxListenersExceededWarning", h.emitter = i, h.type = e, h.count = d.length, Oe(h);
|
|
966
966
|
}
|
|
967
967
|
return i;
|
|
968
968
|
}
|
|
969
|
-
function
|
|
969
|
+
function Oe(i) {
|
|
970
970
|
typeof console.warn == "function" ? console.warn(i) : console.log(i);
|
|
971
971
|
}
|
|
972
972
|
m.prototype.addListener = function(e, t) {
|
|
973
|
-
return
|
|
973
|
+
return ae(this, e, t, !1);
|
|
974
974
|
};
|
|
975
975
|
m.prototype.on = m.prototype.addListener;
|
|
976
976
|
m.prototype.prependListener = function(e, t) {
|
|
977
|
-
return
|
|
977
|
+
return ae(this, e, t, !0);
|
|
978
978
|
};
|
|
979
|
-
function
|
|
979
|
+
function ce(i, e, t) {
|
|
980
980
|
var s = !1;
|
|
981
981
|
function n() {
|
|
982
982
|
i.removeListener(e, n), s || (s = !0, t.apply(i, arguments));
|
|
@@ -986,15 +986,15 @@ function oe(i, e, t) {
|
|
|
986
986
|
m.prototype.once = function(e, t) {
|
|
987
987
|
if (typeof t != "function")
|
|
988
988
|
throw new TypeError('"listener" argument must be a function');
|
|
989
|
-
return this.on(e,
|
|
989
|
+
return this.on(e, ce(this, e, t)), this;
|
|
990
990
|
};
|
|
991
991
|
m.prototype.prependOnceListener = function(e, t) {
|
|
992
992
|
if (typeof t != "function")
|
|
993
993
|
throw new TypeError('"listener" argument must be a function');
|
|
994
|
-
return this.prependListener(e,
|
|
994
|
+
return this.prependListener(e, ce(this, e, t)), this;
|
|
995
995
|
};
|
|
996
996
|
m.prototype.removeListener = function(e, t) {
|
|
997
|
-
var s, n, r,
|
|
997
|
+
var s, n, r, d, h;
|
|
998
998
|
if (typeof t != "function")
|
|
999
999
|
throw new TypeError('"listener" argument must be a function');
|
|
1000
1000
|
if (n = this._events, !n)
|
|
@@ -1004,9 +1004,9 @@ m.prototype.removeListener = function(e, t) {
|
|
|
1004
1004
|
if (s === t || s.listener && s.listener === t)
|
|
1005
1005
|
--this._eventsCount === 0 ? this._events = new _() : (delete n[e], n.removeListener && this.emit("removeListener", e, s.listener || t));
|
|
1006
1006
|
else if (typeof s != "function") {
|
|
1007
|
-
for (r = -1,
|
|
1008
|
-
if (s[
|
|
1009
|
-
|
|
1007
|
+
for (r = -1, d = s.length; d-- > 0; )
|
|
1008
|
+
if (s[d] === t || s[d].listener && s[d].listener === t) {
|
|
1009
|
+
h = s[d].listener, r = d;
|
|
1010
1010
|
break;
|
|
1011
1011
|
}
|
|
1012
1012
|
if (r < 0)
|
|
@@ -1016,8 +1016,8 @@ m.prototype.removeListener = function(e, t) {
|
|
|
1016
1016
|
return this._events = new _(), this;
|
|
1017
1017
|
delete n[e];
|
|
1018
1018
|
} else
|
|
1019
|
-
|
|
1020
|
-
n.removeListener && this.emit("removeListener", e,
|
|
1019
|
+
Ae(s, r);
|
|
1020
|
+
n.removeListener && this.emit("removeListener", e, h || t);
|
|
1021
1021
|
}
|
|
1022
1022
|
return this;
|
|
1023
1023
|
};
|
|
@@ -1031,8 +1031,8 @@ m.prototype.removeAllListeners = function(e) {
|
|
|
1031
1031
|
if (!s.removeListener)
|
|
1032
1032
|
return arguments.length === 0 ? (this._events = new _(), this._eventsCount = 0) : s[e] && (--this._eventsCount === 0 ? this._events = new _() : delete s[e]), this;
|
|
1033
1033
|
if (arguments.length === 0) {
|
|
1034
|
-
for (var n = Object.keys(s), r = 0,
|
|
1035
|
-
|
|
1034
|
+
for (var n = Object.keys(s), r = 0, d; r < n.length; ++r)
|
|
1035
|
+
d = n[r], d !== "removeListener" && this.removeAllListeners(d);
|
|
1036
1036
|
return this.removeAllListeners("removeListener"), this._events = new _(), this._eventsCount = 0, this;
|
|
1037
1037
|
}
|
|
1038
1038
|
if (t = s[e], typeof t == "function")
|
|
@@ -1045,13 +1045,13 @@ m.prototype.removeAllListeners = function(e) {
|
|
|
1045
1045
|
};
|
|
1046
1046
|
m.prototype.listeners = function(e) {
|
|
1047
1047
|
var t, s, n = this._events;
|
|
1048
|
-
return n ? (t = n[e], t ? typeof t == "function" ? s = [t.listener || t] : s =
|
|
1048
|
+
return n ? (t = n[e], t ? typeof t == "function" ? s = [t.listener || t] : s = Pe(t) : s = []) : s = [], s;
|
|
1049
1049
|
};
|
|
1050
1050
|
m.listenerCount = function(i, e) {
|
|
1051
|
-
return typeof i.listenerCount == "function" ? i.listenerCount(e) :
|
|
1051
|
+
return typeof i.listenerCount == "function" ? i.listenerCount(e) : de.call(i, e);
|
|
1052
1052
|
};
|
|
1053
|
-
m.prototype.listenerCount =
|
|
1054
|
-
function
|
|
1053
|
+
m.prototype.listenerCount = de;
|
|
1054
|
+
function de(i) {
|
|
1055
1055
|
var e = this._events;
|
|
1056
1056
|
if (e) {
|
|
1057
1057
|
var t = e[i];
|
|
@@ -1065,17 +1065,17 @@ function ae(i) {
|
|
|
1065
1065
|
m.prototype.eventNames = function() {
|
|
1066
1066
|
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
|
1067
1067
|
};
|
|
1068
|
-
function
|
|
1068
|
+
function Ae(i, e) {
|
|
1069
1069
|
for (var t = e, s = t + 1, n = i.length; s < n; t += 1, s += 1)
|
|
1070
1070
|
i[t] = i[s];
|
|
1071
1071
|
i.pop();
|
|
1072
1072
|
}
|
|
1073
|
-
function
|
|
1073
|
+
function O(i, e) {
|
|
1074
1074
|
for (var t = new Array(e); e--; )
|
|
1075
1075
|
t[e] = i[e];
|
|
1076
1076
|
return t;
|
|
1077
1077
|
}
|
|
1078
|
-
function
|
|
1078
|
+
function Pe(i) {
|
|
1079
1079
|
for (var e = new Array(i.length), t = 0; t < e.length; ++t)
|
|
1080
1080
|
e[t] = i[t].listener || i[t];
|
|
1081
1081
|
return e;
|
|
@@ -1102,7 +1102,7 @@ const g = {
|
|
|
1102
1102
|
429: "群内无用户",
|
|
1103
1103
|
430: "管理员的索引号冲突",
|
|
1104
1104
|
431: "还有子管理员存在"
|
|
1105
|
-
},
|
|
1105
|
+
}, R = {
|
|
1106
1106
|
connected: "connected",
|
|
1107
1107
|
// the socket is connected
|
|
1108
1108
|
disconnected: "disconnected",
|
|
@@ -1126,7 +1126,7 @@ const g = {
|
|
|
1126
1126
|
...e
|
|
1127
1127
|
);
|
|
1128
1128
|
};
|
|
1129
|
-
class
|
|
1129
|
+
class xe extends m {
|
|
1130
1130
|
server = "";
|
|
1131
1131
|
ws = null;
|
|
1132
1132
|
constructor(e) {
|
|
@@ -1137,12 +1137,12 @@ class Ae extends m {
|
|
|
1137
1137
|
*/
|
|
1138
1138
|
connect() {
|
|
1139
1139
|
this.ws = new WebSocket(this.server), this.ws.onopen = () => {
|
|
1140
|
-
E("websocket connected ", this.server), this.emit(
|
|
1140
|
+
E("websocket connected ", this.server), this.emit(R.connected);
|
|
1141
1141
|
}, this.ws.onclose = () => {
|
|
1142
|
-
E("websocket disconnected ", this.server), this.ws = void 0, this.emit(
|
|
1142
|
+
E("websocket disconnected ", this.server), this.ws = void 0, this.emit(R.disconnected);
|
|
1143
1143
|
}, this.ws.onmessage = ({ data: e }) => {
|
|
1144
1144
|
let t = JSON.parse(e);
|
|
1145
|
-
E("websocket recive message ", t), this.emit(
|
|
1145
|
+
E("websocket recive message ", t), this.emit(R.message, t);
|
|
1146
1146
|
};
|
|
1147
1147
|
}
|
|
1148
1148
|
/**
|
|
@@ -1158,7 +1158,7 @@ class Ae extends m {
|
|
|
1158
1158
|
E("websocket send message ", e), e !== void 0 && this.ws !== void 0 && this.ws.readyState === 1 && this.ws.send(JSON.stringify(e));
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
|
-
class
|
|
1161
|
+
class Ge extends m {
|
|
1162
1162
|
socket = void 0;
|
|
1163
1163
|
timer = void 0;
|
|
1164
1164
|
waitinggroup = void 0;
|
|
@@ -1172,16 +1172,16 @@ class xe extends m {
|
|
|
1172
1172
|
async initClient() {
|
|
1173
1173
|
return this.destorySocket(), new Promise((e, t) => {
|
|
1174
1174
|
if (this.server !== void 0) {
|
|
1175
|
-
let s = new
|
|
1176
|
-
s.on(
|
|
1175
|
+
let s = new xe(this.server);
|
|
1176
|
+
s.on(R.connected, () => {
|
|
1177
1177
|
this.socket = s, this.timer = setInterval(() => {
|
|
1178
1178
|
this.sendMessage({ req: 0 });
|
|
1179
1179
|
}, this.heartTime * 1e3), e();
|
|
1180
|
-
}), s.on(
|
|
1180
|
+
}), s.on(R.disconnected, () => {
|
|
1181
1181
|
this.socket = void 0, this.autoReconnect ? setTimeout(() => {
|
|
1182
1182
|
this.initClient();
|
|
1183
1183
|
}, 3e3) : this.emit(g.DISCONNECTED), t("socket connecion failed");
|
|
1184
|
-
}), s.on(
|
|
1184
|
+
}), s.on(R.message, (n) => this.onReviceMessage(n)), s.connect();
|
|
1185
1185
|
} else
|
|
1186
1186
|
t("server is empty");
|
|
1187
1187
|
});
|
|
@@ -1226,10 +1226,10 @@ class xe extends m {
|
|
|
1226
1226
|
this.destorySocket();
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
1229
|
-
const
|
|
1230
|
-
let s = new
|
|
1229
|
+
const Ve = async (i, e = 20, t = !0) => {
|
|
1230
|
+
let s = new Ge(i, e, t);
|
|
1231
1231
|
return await s.initClient(), s;
|
|
1232
|
-
}, G = class G extends
|
|
1232
|
+
}, G = class G extends Se {
|
|
1233
1233
|
constructor(e) {
|
|
1234
1234
|
let t = e.expireTime || G.defaultExpireTime;
|
|
1235
1235
|
super(e.server, e.localNumber, t, e.heartTime || (e.localNumber ? 5 : 0)), this.enablePtt = e.enablePtt, this.pttServer = e.pttServer;
|
|
@@ -1237,7 +1237,7 @@ const Pe = async (i, e = 20, t = !0) => {
|
|
|
1237
1237
|
async initPttClient() {
|
|
1238
1238
|
if (this.enablePtt)
|
|
1239
1239
|
if (this.pttServer) {
|
|
1240
|
-
const e = await
|
|
1240
|
+
const e = await Ve(this.pttServer);
|
|
1241
1241
|
if (!e) return Promise.reject("ptt客户端初始化失败!");
|
|
1242
1242
|
e.on(g.ACTIVE_GROUP, (t) => {
|
|
1243
1243
|
this.emit(g.ACTIVE_GROUP, t);
|
|
@@ -1279,58 +1279,113 @@ const Pe = async (i, e = 20, t = !0) => {
|
|
|
1279
1279
|
}
|
|
1280
1280
|
};
|
|
1281
1281
|
G.defaultExpireTime = 60;
|
|
1282
|
-
let
|
|
1283
|
-
class
|
|
1282
|
+
let U = G;
|
|
1283
|
+
class De extends ne {
|
|
1284
1284
|
//invite seq
|
|
1285
1285
|
constructor(e, t, s, n, r) {
|
|
1286
|
-
super(e, t, s), this.callType =
|
|
1287
|
-
const
|
|
1288
|
-
`),
|
|
1289
|
-
this.callType =
|
|
1286
|
+
super(e, t, s), this.callType = b.unknown, this.inviteSeq = r, this.inviteOffer = n;
|
|
1287
|
+
const d = n.split(`\r
|
|
1288
|
+
`), h = d.find((C) => C.startsWith("m=audio")), k = d.find((C) => C.startsWith("m=video"));
|
|
1289
|
+
this.callType = h && k ? b.audioVideo : h ? b.audio : k ? b.video : b.unknown;
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
|
-
|
|
1292
|
+
const ee = {
|
|
1293
|
+
404: "不存在该用户或者设备(VPA)",
|
|
1294
|
+
407: "太多人观看同一设备(VPA)",
|
|
1295
|
+
426: "同一时间播放太多文件(MSU)",
|
|
1296
|
+
427: "MTC不支持主码流请求(MTC)",
|
|
1297
|
+
500: "SIP建立时间超时(VPA)",
|
|
1298
|
+
501: "CMU反应超时(VPA, MTC)",
|
|
1299
|
+
502: "连接视频源超时",
|
|
1300
|
+
503: "播放失败",
|
|
1301
|
+
504: "播放超时(VPA)",
|
|
1302
|
+
505: "TCP连接断开(VPA, MTC, MGW)",
|
|
1303
|
+
506: "视频源没有连接进入(VDO)",
|
|
1304
|
+
507: "发送消息到视频失败(VDO)",
|
|
1305
|
+
508: "TCP连接失败",
|
|
1306
|
+
509: "TCP无流超时(5s无流, VPA)",
|
|
1307
|
+
510: "摄像头主动停止(VDO)",
|
|
1308
|
+
511: "播放端无Play进入, 超时(VDO)",
|
|
1309
|
+
512: "无人观看,主动释放",
|
|
1310
|
+
513: "呼叫还没有建立(MGW)",
|
|
1311
|
+
514: "呼叫已经释放了(MGW)",
|
|
1312
|
+
515: "操作员断开摄像头(MGW)",
|
|
1313
|
+
516: "查询CMU失败(VPA, MTC, MGW)",
|
|
1314
|
+
517: "视频源返回建立连接错误",
|
|
1315
|
+
518: "播放后无流进入(VPA)",
|
|
1316
|
+
519: "会议输出操作失败",
|
|
1317
|
+
520: "会议停止输出操作失败",
|
|
1318
|
+
521: "会议腿断开连接操作失败",
|
|
1319
|
+
522: "会议腿连接操作失败",
|
|
1320
|
+
523: "文件节点创建失败",
|
|
1321
|
+
524: "MCU侧资源已经占用",
|
|
1322
|
+
525: "MCU创建会议失败",
|
|
1323
|
+
526: "播放文件连接失败",
|
|
1324
|
+
527: "分配文件ID超时",
|
|
1325
|
+
528: "单元连接没有建立",
|
|
1326
|
+
529: "发送内部消息失败",
|
|
1327
|
+
530: "UDP流中断",
|
|
1328
|
+
531: "文件不存在",
|
|
1329
|
+
600: "MGW系统忙",
|
|
1330
|
+
601: "MGW分配Pair失败",
|
|
1331
|
+
602: "MGW重启",
|
|
1332
|
+
603: "CONF分配失败",
|
|
1333
|
+
604: "功能还没有实现",
|
|
1334
|
+
702: "分配资源超时(MGW)",
|
|
1335
|
+
703: "连接资源超时(MGW)",
|
|
1336
|
+
800: "已经在播放中",
|
|
1337
|
+
801: "发送INVITE失败(GBS)",
|
|
1338
|
+
802: "呼叫不存在(MGW)",
|
|
1339
|
+
803: "摄像头离线(HKVS, DHVS)",
|
|
1340
|
+
804: "摄像头不存在",
|
|
1341
|
+
805: "参数缺少或者不对(GBS)",
|
|
1342
|
+
806: "调用SDK VideoStart失败(HKVS, DHVS)",
|
|
1343
|
+
807: "不支持的功能",
|
|
1344
|
+
808: "创建文件失败",
|
|
1345
|
+
809: "云台控制失败",
|
|
1346
|
+
810: "对端释放呼叫(GBS)",
|
|
1347
|
+
811: "呼叫建立超时(GBS)",
|
|
1348
|
+
812: "用户没有输入会议接入号",
|
|
1349
|
+
813: "管理员踢出",
|
|
1350
|
+
814: "管理员结束",
|
|
1351
|
+
815: "管理员移出",
|
|
1352
|
+
816: "管理员结束呼叫",
|
|
1353
|
+
817: "RTMP链接地址错误",
|
|
1354
|
+
818: "RTMP连接设备失败",
|
|
1355
|
+
900: "计划到时释放"
|
|
1356
|
+
};
|
|
1357
|
+
class ue extends U {
|
|
1293
1358
|
constructor() {
|
|
1294
1359
|
super(...arguments), this.allSession = [];
|
|
1295
1360
|
}
|
|
1296
1361
|
//开启一个视频呼叫会话
|
|
1297
1362
|
createSession(e) {
|
|
1298
|
-
let t = new Q(this,
|
|
1363
|
+
let t = new Q(this, H(), e);
|
|
1299
1364
|
return this.allSession.push(t), t;
|
|
1300
1365
|
}
|
|
1301
1366
|
//创建监控会话并播放远程流
|
|
1302
1367
|
playRemote(e, t, s) {
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
p("playRemote start status", l), l === N.ok ? n(c) : r(new Error(`Failed to start session, status: ${l}`));
|
|
1308
|
-
}).catch((l) => {
|
|
1309
|
-
r(l);
|
|
1310
|
-
}), c.on(S.bye, () => {
|
|
1311
|
-
this.removeSession(c);
|
|
1312
|
-
});
|
|
1313
|
-
} catch (c) {
|
|
1314
|
-
r(c);
|
|
1315
|
-
}
|
|
1316
|
-
});
|
|
1368
|
+
let n = new Q(this, H(), e);
|
|
1369
|
+
return this.allSession.push(n), n.playRemoteStream(t, s), n.start(), n.on(S.bye, (r) => {
|
|
1370
|
+
r.errorno in ee && (r.message = ee[r.errorno]), this.removeSession(n), s?.onerror && s.onerror(r);
|
|
1371
|
+
}), n;
|
|
1317
1372
|
}
|
|
1318
1373
|
//处理一些服务端主动发送来的消息
|
|
1319
1374
|
processMessage(e) {
|
|
1320
1375
|
let { req: t } = e;
|
|
1321
|
-
if (t ===
|
|
1322
|
-
let s = new
|
|
1323
|
-
this.allSession.push(s), this.emit(
|
|
1324
|
-
} else if (t ===
|
|
1376
|
+
if (t === T.MESSAGE_TYPE_INVITE) {
|
|
1377
|
+
let s = new De(this, e.cid, e.from, e.sdp, e.seq);
|
|
1378
|
+
this.allSession.push(s), this.emit(j.invite, s);
|
|
1379
|
+
} else if (t === T.MESSAGE_TYPE_REINVITE) {
|
|
1325
1380
|
let s = this.allSession.find((n) => n.sessionId == e.cid);
|
|
1326
1381
|
s !== void 0 && (s.inviteSeq = e.seq, s.inviteOffer = e.sdp, s.acceptCall(), s.emit(S.reInvite, s));
|
|
1327
|
-
} else if (t ===
|
|
1382
|
+
} else if (t === T.MESSAGE_TYPE_ICE)
|
|
1328
1383
|
this.allSession.find((s) => s.sessionId === e.cid)?.reciveIceRequest(e);
|
|
1329
|
-
else if (t ===
|
|
1384
|
+
else if (t === T.MESSAGE_TYPE_BYE) {
|
|
1330
1385
|
let s = this.allSession.find((n) => n.sessionId === e.cid);
|
|
1331
|
-
s !== void 0 && (s.emit(S.bye), s.destroy(!1));
|
|
1386
|
+
s !== void 0 && (s.emit(S.bye, e), s.destroy(!1));
|
|
1332
1387
|
}
|
|
1333
|
-
t ==
|
|
1388
|
+
t == W.FPRE && this.emit(D.FPREInfo, e), t == W.IMS && this.emit(D.IMSInfo, e);
|
|
1334
1389
|
}
|
|
1335
1390
|
destroy() {
|
|
1336
1391
|
this.allSession !== void 0 && this.allSession.forEach((e) => {
|
|
@@ -1344,35 +1399,41 @@ class ce extends W {
|
|
|
1344
1399
|
super.onDisConnected(), this.destroy();
|
|
1345
1400
|
}
|
|
1346
1401
|
}
|
|
1347
|
-
const
|
|
1348
|
-
let e = new
|
|
1402
|
+
const je = async (i) => {
|
|
1403
|
+
let e = new ue(i);
|
|
1349
1404
|
await e.reConnect(), await e.initPttClient().catch((s) => {
|
|
1350
1405
|
console.error(s);
|
|
1351
|
-
}),
|
|
1406
|
+
}), y.random = String(Date.now());
|
|
1352
1407
|
let t = await e.register();
|
|
1353
1408
|
return t.status === N.ok ? e : (e.destroy(), Promise.reject(t));
|
|
1354
|
-
},
|
|
1355
|
-
|
|
1356
|
-
let n = new
|
|
1357
|
-
|
|
1358
|
-
|
|
1409
|
+
}, qe = async (i, e, t, s) => {
|
|
1410
|
+
y.random = String(Date.now());
|
|
1411
|
+
let n = new ue({ server: i, localNumber: "anonymous", ...s });
|
|
1412
|
+
await n.reConnect();
|
|
1413
|
+
const r = n.playRemote(e, t, s);
|
|
1414
|
+
return {
|
|
1415
|
+
destroy: () => {
|
|
1416
|
+
te(t), r.destroy(), n.destroy();
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
}, Fe = async () => {
|
|
1359
1420
|
await navigator.mediaDevices.getUserMedia({ audio: !0, video: !0 });
|
|
1360
1421
|
};
|
|
1361
1422
|
export {
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1423
|
+
D as PTTEvent,
|
|
1424
|
+
De as RtcCalledSession,
|
|
1425
|
+
b as RtcCalledType,
|
|
1426
|
+
ue as RtcClient,
|
|
1427
|
+
j as RtcClientEvent,
|
|
1367
1428
|
N as RtcInviteStatus,
|
|
1368
1429
|
Q as RtcSession,
|
|
1369
1430
|
S as RtcSessionEvent,
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1431
|
+
Fe as authDevice,
|
|
1432
|
+
se as closeStreamAndTrack,
|
|
1433
|
+
je as createRtcClient,
|
|
1434
|
+
We as disableLog,
|
|
1435
|
+
Ue as enableLog,
|
|
1436
|
+
qe as playRemote,
|
|
1437
|
+
te as releaseStreamFromContainer,
|
|
1438
|
+
ie as renderStreamToContainer
|
|
1378
1439
|
};
|