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