usc-rtc-client 2.3.0 → 3.1.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,4 +1,4 @@
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 || {});
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 || {}), 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 || {}), 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
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
3
  const te = (i) => {
4
4
  i !== void 0 && (i.pause(), i.removeAttribute("src"), i.removeAttribute("srcObject"));
@@ -26,23 +26,13 @@ const p = (i, ...e) => {
26
26
  "background:transparent",
27
27
  ...e
28
28
  );
29
- }, We = () => {
29
+ }, De = () => {
30
30
  V = !1;
31
- }, Ue = () => {
31
+ }, We = () => {
32
32
  V = !0;
33
33
  };
34
- class ge {
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
34
  var P = { exports: {} }, J;
45
- function ke() {
35
+ function ge() {
46
36
  if (J) return P.exports;
47
37
  J = 1;
48
38
  var i = typeof Reflect == "object" ? Reflect : null, e = i && typeof i.apply == "function" ? i.apply : function(o, c, u) {
@@ -134,12 +124,12 @@ function ke() {
134
124
  }, r.prototype.on = r.prototype.addListener, r.prototype.prependListener = function(o, c) {
135
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
131
  function L(a, o, c) {
142
- var u = { fired: !1, wrapFn: void 0, target: a, type: o, listener: c }, l = A.bind(u);
132
+ var u = { fired: !1, wrapFn: void 0, target: a, type: o, listener: c }, l = O.bind(u);
143
133
  return l.listener = c, u.wrapFn = l, l;
144
134
  }
145
135
  r.prototype.once = function(o, c) {
@@ -253,8 +243,8 @@ function ke() {
253
243
  }
254
244
  return P.exports;
255
245
  }
256
- var q = ke();
257
- class Ce 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
  }
@@ -356,13 +346,16 @@ class Ce 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 we extends Ce {
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
  }
363
353
  /**生成一个peerconnection */
364
354
  buildConnection() {
365
- let e = new RTCPeerConnection();
355
+ let e = new RTCPeerConnection({
356
+ bundlePolicy: "max-bundle",
357
+ rtcpMuxPolicy: "require"
358
+ });
366
359
  return e.addEventListener("connectionstatechange", (t) => p("connectionstatechange", t)), e.addEventListener("icecandidate", (t) => {
367
360
  p("icecandidate", t), this.onIceCandidate(t);
368
361
  }), e.addEventListener("datachannel", (t) => p("datachannel", t)), e.addEventListener("icecandidateerror", (t) => p("icecandidateerror", t)), e.addEventListener("iceconnectionstatechange", (t) => p("iceconnectionstatechange", t)), e.addEventListener("icegatheringstatechange", (t) => p("icegatheringstatechange", t)), e.addEventListener("negotiationneeded", (t) => p("negotiationneeded", t)), e.addEventListener("signalingstatechange", (t) => p("signalingstatechange", t)), e.addEventListener("track", (t) => this.reciveTrack(t)), e;
@@ -475,7 +468,7 @@ class we extends Ce {
475
468
  throw new Error("session is closed !");
476
469
  this.updateTracks();
477
470
  let e = await this.peerConnection.createOffer();
478
- return e = ge.formatOffer(e), await this.peerConnection.setLocalDescription(e), e;
471
+ return await this.peerConnection.setLocalDescription(e), e;
479
472
  }
480
473
  /**
481
474
  * set offer
@@ -527,7 +520,7 @@ class we extends Ce {
527
520
  }
528
521
  }
529
522
  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 ne extends we {
523
+ class ne extends Ce {
531
524
  constructor(e, t, s) {
532
525
  super(), this.sessionId = t, this.rtcClient = e, this.remoteNumber = s;
533
526
  }
@@ -592,10 +585,10 @@ class ne extends we {
592
585
  });
593
586
  }
594
587
  }
595
- var b = /* @__PURE__ */ ((i) => (i.audio = "audio", i.video = "video", i.audioVideo = "audioVideo", i.unknown = "unknown", i))(b || {});
588
+ var y = /* @__PURE__ */ ((i) => (i.audio = "audio", i.video = "video", i.audioVideo = "audioVideo", i.unknown = "unknown", i))(y || {});
596
589
  class Q extends ne {
597
590
  constructor() {
598
- super(...arguments), this.responseCallType = b.unknown;
591
+ super(...arguments), this.responseCallType = y.unknown;
599
592
  }
600
593
  /**
601
594
  * 开始会话
@@ -606,7 +599,7 @@ class Q extends ne {
606
599
  await this.setAnswer(r);
607
600
  const d = r.split(`\r
608
601
  `), 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;
602
+ this.responseCallType = h && k ? y.audioVideo : h ? y.audio : k ? y.video : y.unknown;
610
603
  }
611
604
  return n;
612
605
  }
@@ -623,11 +616,11 @@ const x = class x {
623
616
  }
624
617
  };
625
618
  x.random = String(Date.now());
626
- let y = x;
619
+ let T = x;
627
620
  var M = /* @__PURE__ */ ((i) => (i.connected = "connected", i.disconnected = "disconnected", i.message = "message", i))(M || {});
628
621
  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
622
  `, 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) {
623
+ function we(i) {
631
624
  let e;
632
625
  try {
633
626
  if (e = z && (self.URL || self.webkitURL).createObjectURL(z), !e) throw "";
@@ -646,9 +639,9 @@ function Ee(i) {
646
639
  );
647
640
  }
648
641
  }
649
- class Te extends q.EventEmitter {
642
+ class Ee extends q.EventEmitter {
650
643
  constructor(e, t, s) {
651
- super(), this.server = e, this.ws = new Ee(), this.configHeartBeat(t, s);
644
+ super(), this.server = e, this.ws = new we(), this.configHeartBeat(t, s);
652
645
  }
653
646
  /**
654
647
  * connect to the websocket server
@@ -725,9 +718,9 @@ class be extends q.EventEmitter {
725
718
  return new Promise((s, n) => {
726
719
  if (t.length > 0) {
727
720
  this.activeServer = t[0];
728
- let r = new Te(
721
+ let r = new Ee(
729
722
  this.activeServer,
730
- new y(T.MESSAGE_TYPE_REGISTER, this.localNumber, this.localNumber, { expire: this.expireTime }),
723
+ new T(b.MESSAGE_TYPE_REGISTER, this.localNumber, this.localNumber, { expire: this.expireTime }),
731
724
  this.heartTime
732
725
  );
733
726
  r.on(M.connected, () => {
@@ -772,7 +765,7 @@ class ye extends be {
772
765
  }
773
766
  //连接断开
774
767
  onDisConnected(e) {
775
- this.asyncProducer.clear(), this.emit(j.disconnected, e);
768
+ this.asyncProducer.clear(), this.emit(U.disconnected, e);
776
769
  }
777
770
  //invoke on message reviced
778
771
  onReviceMessage(e) {
@@ -780,16 +773,16 @@ class ye extends be {
780
773
  t !== void 0 ? this.getAsyncResolve(s)?.call(void 0, e) : this.processMessage(e);
781
774
  }
782
775
  }
783
- class Se extends ye {
776
+ class Te extends ye {
784
777
  /**
785
778
  * send register message to the server
786
779
  */
787
780
  async register() {
788
- let e = new y(T.MESSAGE_TYPE_REGISTER, this.localNumber, this.localNumber, { expire: this.expireTime });
781
+ let e = new T(b.MESSAGE_TYPE_REGISTER, this.localNumber, this.localNumber, { expire: this.expireTime });
789
782
  return this.sendRespondableMessage(e);
790
783
  }
791
784
  unRegister() {
792
- let e = new y(T.MESSAGE_TYPE_REGISTER, this.localNumber, this.localNumber, { expire: 0 });
785
+ let e = new T(b.MESSAGE_TYPE_REGISTER, this.localNumber, this.localNumber, { expire: 0 });
793
786
  this.sendMessage(e);
794
787
  }
795
788
  /**
@@ -800,7 +793,7 @@ class Se extends ye {
800
793
  * @returns
801
794
  */
802
795
  async invite(e, t, s) {
803
- return this.sendRespondableMessage(new y(T.MESSAGE_TYPE_INVITE, this.localNumber, e, { cid: t, sdp: s }));
796
+ return this.sendRespondableMessage(new T(b.MESSAGE_TYPE_INVITE, this.localNumber, e, { cid: t, sdp: s }));
804
797
  }
805
798
  /**
806
799
  * send a ice request to user
@@ -817,7 +810,7 @@ class Se extends ye {
817
810
  * @param cid session id
818
811
  */
819
812
  sendBye(e, t) {
820
- return this.sendMessage(new y(T.MESSAGE_TYPE_BYE, this.localNumber, e, { cid: t }));
813
+ return this.sendMessage(new T(b.MESSAGE_TYPE_BYE, this.localNumber, e, { cid: t }));
821
814
  }
822
815
  /**
823
816
  * answer message
@@ -842,10 +835,10 @@ class Se extends ye {
842
835
  }
843
836
  //发送dtmf
844
837
  async sendDtmf(e, t, s) {
845
- return this.sendMessage(new y(T.MESSAGE_TYPE_INFO, this.localNumber, e, { cid: t, info: { msg: "dtmf", dtmf: s } }));
838
+ return this.sendMessage(new T(b.MESSAGE_TYPE_INFO, this.localNumber, e, { cid: t, info: { msg: "dtmf", dtmf: s } }));
846
839
  }
847
840
  }
848
- var Le;
841
+ var Se;
849
842
  function _() {
850
843
  }
851
844
  _.prototype = /* @__PURE__ */ Object.create(null);
@@ -859,7 +852,7 @@ m.prototype._events = void 0;
859
852
  m.prototype._maxListeners = void 0;
860
853
  m.defaultMaxListeners = 10;
861
854
  m.init = function() {
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;
855
+ 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
856
  };
864
857
  m.prototype.setMaxListeners = function(e) {
865
858
  if (typeof e != "number" || e < 0 || isNaN(e))
@@ -872,39 +865,39 @@ function oe(i) {
872
865
  m.prototype.getMaxListeners = function() {
873
866
  return oe(this);
874
867
  };
875
- function _e(i, e, t) {
868
+ function Le(i, e, t) {
876
869
  if (e)
877
870
  i.call(t);
878
871
  else
879
- for (var s = i.length, n = O(i, s), r = 0; r < s; ++r)
872
+ for (var s = i.length, n = A(i, s), r = 0; r < s; ++r)
880
873
  n[r].call(t);
881
874
  }
882
- function Me(i, e, t, s) {
875
+ function _e(i, e, t, s) {
883
876
  if (e)
884
877
  i.call(t, s);
885
878
  else
886
- for (var n = i.length, r = O(i, n), d = 0; d < n; ++d)
879
+ for (var n = i.length, r = A(i, n), d = 0; d < n; ++d)
887
880
  r[d].call(t, s);
888
881
  }
889
- function Re(i, e, t, s, n) {
882
+ function Me(i, e, t, s, n) {
890
883
  if (e)
891
884
  i.call(t, s, n);
892
885
  else
893
- for (var r = i.length, d = O(i, r), h = 0; h < r; ++h)
886
+ for (var r = i.length, d = A(i, r), h = 0; h < r; ++h)
894
887
  d[h].call(t, s, n);
895
888
  }
896
- function Ie(i, e, t, s, n, r) {
889
+ function Re(i, e, t, s, n, r) {
897
890
  if (e)
898
891
  i.call(t, s, n, r);
899
892
  else
900
- for (var d = i.length, h = O(i, d), k = 0; k < d; ++k)
893
+ for (var d = i.length, h = A(i, d), k = 0; k < d; ++k)
901
894
  h[k].call(t, s, n, r);
902
895
  }
903
- function Ne(i, e, t, s) {
896
+ function Ie(i, e, t, s) {
904
897
  if (e)
905
898
  i.apply(t, s);
906
899
  else
907
- for (var n = i.length, r = O(i, n), d = 0; d < n; ++d)
900
+ for (var n = i.length, r = A(i, n), d = 0; d < n; ++d)
908
901
  r[d].apply(t, s);
909
902
  }
910
903
  m.prototype.emit = function(e) {
@@ -919,8 +912,8 @@ m.prototype.emit = function(e) {
919
912
  else {
920
913
  if (t instanceof Error)
921
914
  throw t;
922
- var A = new Error('Uncaught, unspecified "error" event. (' + t + ")");
923
- throw A.context = t, A;
915
+ var O = new Error('Uncaught, unspecified "error" event. (' + t + ")");
916
+ throw O.context = t, O;
924
917
  }
925
918
  return !1;
926
919
  }
@@ -930,22 +923,22 @@ m.prototype.emit = function(e) {
930
923
  switch (n = arguments.length, n) {
931
924
  // fast cases
932
925
  case 1:
933
- _e(s, L, this);
926
+ Le(s, L, this);
934
927
  break;
935
928
  case 2:
936
- Me(s, L, this, arguments[1]);
929
+ _e(s, L, this, arguments[1]);
937
930
  break;
938
931
  case 3:
939
- Re(s, L, this, arguments[1], arguments[2]);
932
+ Me(s, L, this, arguments[1], arguments[2]);
940
933
  break;
941
934
  case 4:
942
- Ie(s, L, this, arguments[1], arguments[2], arguments[3]);
935
+ Re(s, L, this, arguments[1], arguments[2], arguments[3]);
943
936
  break;
944
937
  // slower
945
938
  default:
946
939
  for (r = new Array(n - 1), d = 1; d < n; d++)
947
940
  r[d - 1] = arguments[d];
948
- Ne(s, L, this, r);
941
+ Ie(s, L, this, r);
949
942
  }
950
943
  return !0;
951
944
  };
@@ -962,11 +955,11 @@ function ae(i, e, t, s) {
962
955
  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
956
  d.warned = !0;
964
957
  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);
958
+ h.name = "MaxListenersExceededWarning", h.emitter = i, h.type = e, h.count = d.length, Ne(h);
966
959
  }
967
960
  return i;
968
961
  }
969
- function Oe(i) {
962
+ function Ne(i) {
970
963
  typeof console.warn == "function" ? console.warn(i) : console.log(i);
971
964
  }
972
965
  m.prototype.addListener = function(e, t) {
@@ -1045,7 +1038,7 @@ m.prototype.removeAllListeners = function(e) {
1045
1038
  };
1046
1039
  m.prototype.listeners = function(e) {
1047
1040
  var t, s, n = this._events;
1048
- return n ? (t = n[e], t ? typeof t == "function" ? s = [t.listener || t] : s = Pe(t) : s = []) : s = [], s;
1041
+ return n ? (t = n[e], t ? typeof t == "function" ? s = [t.listener || t] : s = Oe(t) : s = []) : s = [], s;
1049
1042
  };
1050
1043
  m.listenerCount = function(i, e) {
1051
1044
  return typeof i.listenerCount == "function" ? i.listenerCount(e) : de.call(i, e);
@@ -1070,12 +1063,12 @@ function Ae(i, e) {
1070
1063
  i[t] = i[s];
1071
1064
  i.pop();
1072
1065
  }
1073
- function O(i, e) {
1066
+ function A(i, e) {
1074
1067
  for (var t = new Array(e); e--; )
1075
1068
  t[e] = i[e];
1076
1069
  return t;
1077
1070
  }
1078
- function Pe(i) {
1071
+ function Oe(i) {
1079
1072
  for (var e = new Array(i.length), t = 0; t < e.length; ++t)
1080
1073
  e[t] = i[t].listener || i[t];
1081
1074
  return e;
@@ -1126,7 +1119,7 @@ const g = {
1126
1119
  ...e
1127
1120
  );
1128
1121
  };
1129
- class xe extends m {
1122
+ class Pe extends m {
1130
1123
  server = "";
1131
1124
  ws = null;
1132
1125
  constructor(e) {
@@ -1158,7 +1151,7 @@ class xe extends m {
1158
1151
  E("websocket send message ", e), e !== void 0 && this.ws !== void 0 && this.ws.readyState === 1 && this.ws.send(JSON.stringify(e));
1159
1152
  }
1160
1153
  }
1161
- class Ge extends m {
1154
+ class xe extends m {
1162
1155
  socket = void 0;
1163
1156
  timer = void 0;
1164
1157
  waitinggroup = void 0;
@@ -1172,7 +1165,7 @@ class Ge extends m {
1172
1165
  async initClient() {
1173
1166
  return this.destorySocket(), new Promise((e, t) => {
1174
1167
  if (this.server !== void 0) {
1175
- let s = new xe(this.server);
1168
+ let s = new Pe(this.server);
1176
1169
  s.on(R.connected, () => {
1177
1170
  this.socket = s, this.timer = setInterval(() => {
1178
1171
  this.sendMessage({ req: 0 });
@@ -1226,10 +1219,10 @@ class Ge extends m {
1226
1219
  this.destorySocket();
1227
1220
  }
1228
1221
  }
1229
- const Ve = async (i, e = 20, t = !0) => {
1230
- let s = new Ge(i, e, t);
1222
+ const Ge = async (i, e = 20, t = !0) => {
1223
+ let s = new xe(i, e, t);
1231
1224
  return await s.initClient(), s;
1232
- }, G = class G extends Se {
1225
+ }, G = class G extends Te {
1233
1226
  constructor(e) {
1234
1227
  let t = e.expireTime || G.defaultExpireTime;
1235
1228
  super(e.server, e.localNumber, t, e.heartTime || (e.localNumber ? 5 : 0)), this.enablePtt = e.enablePtt, this.pttServer = e.pttServer;
@@ -1237,7 +1230,7 @@ const Ve = async (i, e = 20, t = !0) => {
1237
1230
  async initPttClient() {
1238
1231
  if (this.enablePtt)
1239
1232
  if (this.pttServer) {
1240
- const e = await Ve(this.pttServer);
1233
+ const e = await Ge(this.pttServer);
1241
1234
  if (!e) return Promise.reject("ptt客户端初始化失败!");
1242
1235
  e.on(g.ACTIVE_GROUP, (t) => {
1243
1236
  this.emit(g.ACTIVE_GROUP, t);
@@ -1279,14 +1272,14 @@ const Ve = async (i, e = 20, t = !0) => {
1279
1272
  }
1280
1273
  };
1281
1274
  G.defaultExpireTime = 60;
1282
- let U = G;
1283
- class De extends ne {
1275
+ let j = G;
1276
+ class Ve extends ne {
1284
1277
  //invite seq
1285
1278
  constructor(e, t, s, n, r) {
1286
- super(e, t, s), this.callType = b.unknown, this.inviteSeq = r, this.inviteOffer = n;
1279
+ super(e, t, s), this.callType = y.unknown, this.inviteSeq = r, this.inviteOffer = n;
1287
1280
  const d = n.split(`\r
1288
1281
  `), 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;
1282
+ this.callType = h && k ? y.audioVideo : h ? y.audio : k ? y.video : y.unknown;
1290
1283
  }
1291
1284
  }
1292
1285
  const ee = {
@@ -1354,7 +1347,7 @@ const ee = {
1354
1347
  818: "RTMP连接设备失败",
1355
1348
  900: "计划到时释放"
1356
1349
  };
1357
- class ue extends U {
1350
+ class ue extends j {
1358
1351
  constructor() {
1359
1352
  super(...arguments), this.allSession = [];
1360
1353
  }
@@ -1373,15 +1366,15 @@ class ue extends U {
1373
1366
  //处理一些服务端主动发送来的消息
1374
1367
  processMessage(e) {
1375
1368
  let { req: t } = e;
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) {
1369
+ if (t === b.MESSAGE_TYPE_INVITE) {
1370
+ let s = new Ve(this, e.cid, e.from, e.sdp, e.seq);
1371
+ this.allSession.push(s), this.emit(U.invite, s);
1372
+ } else if (t === b.MESSAGE_TYPE_REINVITE) {
1380
1373
  let s = this.allSession.find((n) => n.sessionId == e.cid);
1381
1374
  s !== void 0 && (s.inviteSeq = e.seq, s.inviteOffer = e.sdp, s.acceptCall(), s.emit(S.reInvite, s));
1382
- } else if (t === T.MESSAGE_TYPE_ICE)
1375
+ } else if (t === b.MESSAGE_TYPE_ICE)
1383
1376
  this.allSession.find((s) => s.sessionId === e.cid)?.reciveIceRequest(e);
1384
- else if (t === T.MESSAGE_TYPE_BYE) {
1377
+ else if (t === b.MESSAGE_TYPE_BYE) {
1385
1378
  let s = this.allSession.find((n) => n.sessionId === e.cid);
1386
1379
  s !== void 0 && (s.emit(S.bye, e), s.destroy(!1));
1387
1380
  }
@@ -1403,11 +1396,11 @@ const je = async (i) => {
1403
1396
  let e = new ue(i);
1404
1397
  await e.reConnect(), await e.initPttClient().catch((s) => {
1405
1398
  console.error(s);
1406
- }), y.random = String(Date.now());
1399
+ }), T.random = String(Date.now());
1407
1400
  let t = await e.register();
1408
1401
  return t.status === N.ok ? e : (e.destroy(), Promise.reject(t));
1409
- }, qe = async (i, e, t, s) => {
1410
- y.random = String(Date.now());
1402
+ }, Ue = async (i, e, t, s) => {
1403
+ T.random = String(Date.now());
1411
1404
  let n = new ue({ server: i, localNumber: "anonymous", ...s });
1412
1405
  await n.reConnect();
1413
1406
  const r = n.playRemote(e, t, s);
@@ -1416,24 +1409,24 @@ const je = async (i) => {
1416
1409
  te(t), r.destroy(), n.destroy();
1417
1410
  }
1418
1411
  };
1419
- }, Fe = async () => {
1412
+ }, qe = async () => {
1420
1413
  await navigator.mediaDevices.getUserMedia({ audio: !0, video: !0 });
1421
1414
  };
1422
1415
  export {
1423
1416
  D as PTTEvent,
1424
- De as RtcCalledSession,
1425
- b as RtcCalledType,
1417
+ Ve as RtcCalledSession,
1418
+ y as RtcCalledType,
1426
1419
  ue as RtcClient,
1427
- j as RtcClientEvent,
1420
+ U as RtcClientEvent,
1428
1421
  N as RtcInviteStatus,
1429
1422
  Q as RtcSession,
1430
1423
  S as RtcSessionEvent,
1431
- Fe as authDevice,
1424
+ qe as authDevice,
1432
1425
  se as closeStreamAndTrack,
1433
1426
  je as createRtcClient,
1434
- We as disableLog,
1435
- Ue as enableLog,
1436
- qe as playRemote,
1427
+ De as disableLog,
1428
+ We as enableLog,
1429
+ Ue as playRemote,
1437
1430
  te as releaseStreamFromContainer,
1438
1431
  ie as renderStreamToContainer
1439
1432
  };
package/dist/index.umd.js CHANGED
@@ -1,6 +1,4 @@
1
- (function(p,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(p=typeof globalThis<"u"?globalThis:p||self,w(p.UscRtc={}))})(this,(function(p){"use strict";var w=(i=>(i.bye="bye",i.stream="stream",i.reInvite="reInvite",i.localAudioChange="localAudioChange",i.localVideoChange="localVideoChange",i.localStreamChange="localStreamChange",i))(w||{}),P=(i=>(i.connected="connected",i.disconnected="disconnected",i.invite="invite",i))(P||{}),x=(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))(x||{}),y=(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))(y||{}),U=(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))(U||{});let J=(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),"");const q=i=>{i!==void 0&&(i.pause(),i.removeAttribute("src"),i.removeAttribute("srcObject"))},F=(i,e)=>{i!==void 0&&e!==void 0&&(e.srcObject=i,e.play())},Y=i=>{i.onaddtrack=null,i.onremovetrack=null,i.getTracks().forEach(e=>{i?.removeTrack(e),e.onended=null,e.onmute=null,e.onunmute=null,e.stop()})};let G=!1;const g=(i,...e)=>{G&&console.log(`%c usc-rtc-devtools %c ${i} %c `,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#41b883 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",...e)},fe=(i,...e)=>{G&&console.log(`%c usc-rtc-devtools %c ${i} %c `,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff0000 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",...e)},me=()=>{G=!1},ve=()=>{G=!0};class pe{static formatOffer(e){let{sdp:t}=e;if(t===void 0)throw new Error("offer sdp is empty");return t=t.split(`\r
2
- `).filter(s=>s.indexOf("a=group:BUNDLE")===-1).join(`\r
3
- `),e.sdp=t,e}}var V={exports:{}},Q;function ge(){if(Q)return V.exports;Q=1;var i=typeof Reflect=="object"?Reflect:null,e=i&&typeof i.apply=="function"?i.apply:function(o,c,u){return Function.prototype.apply.call(o,c,u)},t;i&&typeof i.ownKeys=="function"?t=i.ownKeys:Object.getOwnPropertySymbols?t=function(o){return Object.getOwnPropertyNames(o).concat(Object.getOwnPropertySymbols(o))}:t=function(o){return Object.getOwnPropertyNames(o)};function s(a){console&&console.warn&&console.warn(a)}var n=Number.isNaN||function(o){return o!==o};function r(){r.init.call(this)}V.exports=r,V.exports.once=qe,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var d=10;function h(a){if(typeof a!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof a)}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return d},set:function(a){if(typeof a!="number"||a<0||n(a))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+a+".");d=a}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(o){if(typeof o!="number"||o<0||n(o))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+o+".");return this._maxListeners=o,this};function C(a){return a._maxListeners===void 0?r.defaultMaxListeners:a._maxListeners}r.prototype.getMaxListeners=function(){return C(this)},r.prototype.emit=function(o){for(var c=[],u=1;u<arguments.length;u++)c.push(arguments[u]);var l=o==="error",v=this._events;if(v!==void 0)l=l&&v.error===void 0;else if(!l)return!1;if(l){var f;if(c.length>0&&(f=c[0]),f instanceof Error)throw f;var S=new Error("Unhandled error."+(f?" ("+f.message+")":""));throw S.context=f,S}var A=v[o];if(A===void 0)return!1;if(typeof A=="function")e(A,this,c);else for(var he=A.length,Ye=ue(A,he),u=0;u<he;++u)e(Ye[u],this,c);return!0};function E(a,o,c,u){var l,v,f;if(h(c),v=a._events,v===void 0?(v=a._events=Object.create(null),a._eventsCount=0):(v.newListener!==void 0&&(a.emit("newListener",o,c.listener?c.listener:c),v=a._events),f=v[o]),f===void 0)f=v[o]=c,++a._eventsCount;else if(typeof f=="function"?f=v[o]=u?[c,f]:[f,c]:u?f.unshift(c):f.push(c),l=C(a),l>0&&f.length>l&&!f.warned){f.warned=!0;var S=new Error("Possible EventEmitter memory leak detected. "+f.length+" "+String(o)+" listeners added. Use emitter.setMaxListeners() to increase limit");S.name="MaxListenersExceededWarning",S.emitter=a,S.type=o,S.count=f.length,s(S)}return a}r.prototype.addListener=function(o,c){return E(this,o,c,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(o,c){return E(this,o,c,!0)};function j(){if(!this.fired)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)}function R(a,o,c){var u={fired:!1,wrapFn:void 0,target:a,type:o,listener:c},l=j.bind(u);return l.listener=c,u.wrapFn=l,l}r.prototype.once=function(o,c){return h(c),this.on(o,R(this,o,c)),this},r.prototype.prependOnceListener=function(o,c){return h(c),this.prependListener(o,R(this,o,c)),this},r.prototype.removeListener=function(o,c){var u,l,v,f,S;if(h(c),l=this._events,l===void 0)return this;if(u=l[o],u===void 0)return this;if(u===c||u.listener===c)--this._eventsCount===0?this._events=Object.create(null):(delete l[o],l.removeListener&&this.emit("removeListener",o,u.listener||c));else if(typeof u!="function"){for(v=-1,f=u.length-1;f>=0;f--)if(u[f]===c||u[f].listener===c){S=u[f].listener,v=f;break}if(v<0)return this;v===0?u.shift():je(u,v),u.length===1&&(l[o]=u[0]),l.removeListener!==void 0&&this.emit("removeListener",o,S||c)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(o){var c,u,l;if(u=this._events,u===void 0)return this;if(u.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):u[o]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete u[o]),this;if(arguments.length===0){var v=Object.keys(u),f;for(l=0;l<v.length;++l)f=v[l],f!=="removeListener"&&this.removeAllListeners(f);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(c=u[o],typeof c=="function")this.removeListener(o,c);else if(c!==void 0)for(l=c.length-1;l>=0;l--)this.removeListener(o,c[l]);return this};function ce(a,o,c){var u=a._events;if(u===void 0)return[];var l=u[o];return l===void 0?[]:typeof l=="function"?c?[l.listener||l]:[l]:c?Ue(l):ue(l,l.length)}r.prototype.listeners=function(o){return ce(this,o,!0)},r.prototype.rawListeners=function(o){return ce(this,o,!1)},r.listenerCount=function(a,o){return typeof a.listenerCount=="function"?a.listenerCount(o):de.call(a,o)},r.prototype.listenerCount=de;function de(a){var o=this._events;if(o!==void 0){var c=o[a];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}r.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function ue(a,o){for(var c=new Array(o),u=0;u<o;++u)c[u]=a[u];return c}function je(a,o){for(;o+1<a.length;o++)a[o]=a[o+1];a.pop()}function Ue(a){for(var o=new Array(a.length),c=0;c<o.length;++c)o[c]=a[c].listener||a[c];return o}function qe(a,o){return new Promise(function(c,u){function l(f){a.removeListener(o,v),u(f)}function v(){typeof a.removeListener=="function"&&a.removeListener("error",l),c([].slice.call(arguments))}le(a,o,v,{once:!0}),o!=="error"&&Fe(a,l,{once:!0})})}function Fe(a,o,c){typeof a.on=="function"&&le(a,"error",o,c)}function le(a,o,c,u){if(typeof a.on=="function")u.once?a.once(o,c):a.on(o,c);else if(typeof a.addEventListener=="function")a.addEventListener(o,function l(v){u.once&&a.removeEventListener(o,l),c(v)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof a)}return V.exports}var K=ge();class ke extends K.EventEmitter{constructor(){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)}releaseTrack(e){e!==void 0&&(this.localMediaStream?.removeTrack(e),e.stop())}addDeviceChangeListener(e){navigator.mediaDevices.addEventListener("devicechange",e)}removeDeviceChangeListener(e){navigator.mediaDevices.removeEventListener("devicechange",e)}setVideoTrack(e){this.emit(w.localVideoChange,{from:this.videoTrack,to:e}),this.videoTrack!==e&&(this.localMediaStream?.addTrack(e),this.localTractChange(this.videoTrack,e)),this.videoTrack=e}setAudioTrack(e){this.emit(w.localAudioChange,{from:this.audioTrack,to:e}),this.audioTrack!==e&&(this.localMediaStream?.addTrack(e),this.localTractChange(this.audioTrack,e)),this.audioTrack=e}renderLocalStreamToContainer(e){F(this.localMediaStream,e)}async getAllInputResource(){let e=await navigator.mediaDevices.enumerateDevices();return{audio:e.filter(t=>t.kind==="audioinput"),video:e.filter(t=>t.kind==="videoinput")}}async useDefaultDevice(e){let t={audio:!0,video:!0},s=await navigator.mediaDevices.getUserMedia(t);this.setAudioTrack(s.getAudioTracks()[0]),this.setVideoTrack(s.getVideoTracks()[0]),this.renderLocalStreamToContainer(e)}async useAudio(e){let t=e===void 0?{audio:{...this.audioConstrants},video:!1}:{video:!1,audio:{deviceId:e,...this.audioConstrants}},s=await navigator.mediaDevices.getUserMedia(t);return this.setAudioTrack(s.getAudioTracks()[0]),s.getAudioTracks()[0]}async useDeviceVideo(e){let t=e===void 0?{audio:!1,video:{...this.videoConstrains}}:{audio:!1,video:{deviceId:e,...this.videoConstrains}},s=await navigator.mediaDevices.getUserMedia(t);return this.setVideoTrack(s.getVideoTracks()[0]),s.getVideoTracks()[0]}async useDeskTopVideo(){let e=await navigator.mediaDevices.getDisplayMedia({video:{...this.videoConstrains},audio:!1});return this.setVideoTrack(e.getVideoTracks()[0]),e.getVideoTracks()[0]}disableAudio(){this.audioTrack!==void 0&&this.audioTrack.enabled&&(g("local audio status change",this.audioTrack),this.audioTrack.enabled=!1,this.setAudioTrack(this.audioTrack))}enableAudio(){this.audioTrack!==void 0&&!this.audioTrack.enabled&&(g("local audio status change",this.audioTrack),this.audioTrack.enabled=!0,this.setAudioTrack(this.audioTrack))}disableVideo(){this.videoTrack!==void 0&&this.videoTrack.enabled&&(g("local video status change",this.videoTrack),this.videoTrack.enabled=!1,this.setVideoTrack(this.videoTrack))}enableVideo(){this.videoTrack!==void 0&&!this.videoTrack.enabled&&(g("local video status change",this.videoTrack),this.videoTrack.enabled=!0,this.setVideoTrack(this.videoTrack))}close(){this.releaseTrack(this.audioTrack),this.releaseTrack(this.videoTrack),this.audioTrack=void 0,this.videoTrack=void 0,this.localMediaStream=void 0}}class Ce extends ke{constructor(){super(),this.videoCodecs=[],this.audioCodecs=[],this.audioReciveCodecs=[],this.preferCodec(),this.peerConnection=this.buildConnection()}buildConnection(){let e=new RTCPeerConnection;return e.addEventListener("connectionstatechange",t=>g("connectionstatechange",t)),e.addEventListener("icecandidate",t=>{g("icecandidate",t),this.onIceCandidate(t)}),e.addEventListener("datachannel",t=>g("datachannel",t)),e.addEventListener("icecandidateerror",t=>g("icecandidateerror",t)),e.addEventListener("iceconnectionstatechange",t=>g("iceconnectionstatechange",t)),e.addEventListener("icegatheringstatechange",t=>g("icegatheringstatechange",t)),e.addEventListener("negotiationneeded",t=>g("negotiationneeded",t)),e.addEventListener("signalingstatechange",t=>g("signalingstatechange",t)),e.addEventListener("track",t=>this.reciveTrack(t)),e}async localTractChange(e,t){if(this.remoteStream!==void 0&&this.peerConnection!==void 0)if(t!==void 0){let s=this.peerConnection.getSenders().find(n=>n.track?.kind===t.kind);s!==void 0&&s.replaceTrack(t)}else{let s=this.peerConnection.getSenders().find(n=>n.track?.kind===e?.kind);s!==void 0&&this.peerConnection.removeTrack(s)}t!==void 0&&(t.onended=s=>g("local track end",s),t.onmute=s=>{g("local mute",s),this.emitLocalStreamChange()},t.onunmute=s=>{g("local unmute",s),this.emitLocalStreamChange()}),this.releaseTrack(e),this.emitLocalStreamChange()}isInMeeting(){return this.remoteStream!==void 0}hasRemoteVideo(e){return e?.getVideoTracks().some(t=>t.muted===!1&&t.readyState==="live")??!1}emitLocalStreamChange(){this.emit(w.localStreamChange,{audioOnly:!this.hasRemoteVideo(this.localMediaStream),stream:this.localMediaStream})}emitRemoteStreamChange(){this.emit(w.stream,{audioOnly:!this.hasRemoteVideo(this.remoteStream),stream:this.remoteStream})}trigerStreamChange(e=100){this.emitStreamTimeout!==void 0&&clearTimeout(this.emitStreamTimeout),this.emitStreamTimeout=setTimeout(()=>{this.emitRemoteStreamChange(),this.emitStreamTimeout=void 0},e)}reciveTrack(e){g("recive track",e),this.remoteStream===void 0&&(this.remoteStream=new MediaStream),e.track.addEventListener("ended",()=>this.trigerStreamChange()),e.track.addEventListener("mute",()=>this.trigerStreamChange(3e3)),e.track.addEventListener("unmute",()=>this.trigerStreamChange(10)),this.remoteStream.addTrack(e.track),this.trigerStreamChange()}preferCodec(e="H264",t="PCMA"){this.videoCodecs=[];let s=RTCRtpSender.getCapabilities("video");s!==null&&this.videoCodecs.push(...s.codecs.filter(h=>h.mimeType===`video/${e}`));let n=RTCRtpReceiver.getCapabilities("video");n!==null&&this.videoCodecs.push(...n.codecs.filter(h=>h.mimeType===`video/${e}`)),this.audioCodecs=[];let r=RTCRtpSender.getCapabilities("audio");r!==null&&this.audioCodecs.push(...r.codecs.filter(h=>h.mimeType===`audio/${t}`));let d=RTCRtpReceiver.getCapabilities("audio");d!==null&&this.audioCodecs.push(...d.codecs.filter(h=>h.mimeType===`audio/${t}`))}trackIsInPeerConnection(e){return this.peerConnection?.getSenders().some(t=>t.track?.id===e.id)??!1}updateTracks(){if(this.peerConnection===void 0||this.peerConnection.signalingState==="closed")throw new Error("session is closed !");if(this.audioTrack===void 0&&this.videoTrack===void 0){this.peerConnection.addTransceiver("audio",{direction:"recvonly"}),this.peerConnection.addTransceiver("video",{direction:"recvonly"});return}if(this.audioTrack!==void 0&&!this.trackIsInPeerConnection(this.audioTrack))try{this.peerConnection.addTrack(this.audioTrack)}catch{}if(this.videoTrack!==void 0&&!this.trackIsInPeerConnection(this.videoTrack))try{this.peerConnection.addTrack(this.videoTrack)}catch{}try{this.peerConnection.getTransceivers().forEach(e=>{e.sender.track!==null&&(e.sender.track.kind==="video"?e.setCodecPreferences([...this.videoCodecs]):e.sender.track.kind==="audio"&&e.setCodecPreferences([...this.audioCodecs]))})}catch(e){fe("preferCodec error",e,this.audioCodecs,this.videoCodecs)}}async createOffer(){if(this.peerConnection===void 0)throw new Error("session is closed !");this.updateTracks();let e=await this.peerConnection.createOffer();return e=pe.formatOffer(e),await this.peerConnection.setLocalDescription(e),e}async setOffer(e){if(this.peerConnection===void 0)throw new Error("session is closed !");this.updateTracks(),await this.peerConnection.setRemoteDescription({type:"offer",sdp:e})}async createAnswer(){if(this.peerConnection===void 0)throw new Error("session is closed !");this.updateTracks();let e=await this.peerConnection.createAnswer();return this.peerConnection.setLocalDescription(e),e}async setAnswer(e){if(this.peerConnection===void 0)throw new Error("session is closed !");await this.peerConnection.setRemoteDescription({type:"answer",sdp:e})}setRemoteIce(e){if(this.peerConnection===void 0)throw new Error("session is closed !");let t=new RTCIceCandidate(e);this.peerConnection.addIceCandidate(t)}closeConnection(e){e.close(),e.ontrack=null,e.onicecandidate=null,e.oniceconnectionstatechange=null,e.onsignalingstatechange=null,e.onicegatheringstatechange=null,e.onnegotiationneeded=null,e.onicecandidateerror=null,e.ondatachannel=null,e.onconnectionstatechange=null}close(){super.close(),this.peerConnection!==void 0&&(this.closeConnection(this.peerConnection),this.peerConnection=void 0),this.remoteStream!==void 0&&Y(this.remoteStream)}}var M=(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))(M||{});class z extends Ce{constructor(e,t,s){super(),this.sessionId=t,this.rtcClient=e,this.remoteNumber=s}reciveIceRequest({ice:e}){this.setRemoteIce(JSON.parse(e))}getRemoteNumber(){return this.remoteNumber}onIceCandidate(e){}destroy(e=!0){this.removeAllListeners(),this.rtcClient!==void 0&&(this.remoteNumber!==void 0&&(e&&this.rtcClient.sendBye(this.remoteNumber,this.sessionId),this.remoteNumber=void 0),this.rtcClient.removeSession(this)),this.rtcClient=void 0,super.close()}rejectCall(){let[e,t,s]=this.checkIsNotUndefined(this.rtcClient,this.remoteNumber,this.inviteSeq);e.answer(M.reject,s,t,this.sessionId),this.destroy()}async acceptCall(){if(this.inviteOffer!==void 0){await this.setOffer(this.inviteOffer);let[e,t,s]=this.checkIsNotUndefined(this.rtcClient,this.remoteNumber,this.inviteSeq),{sdp:n}=await this.createAnswer();e.answer(M.ok,s,t,this.sessionId,n)}}async pickNewConnection(){this.peerConnection!==void 0&&this.closeConnection(this.peerConnection),this.peerConnection=this.buildConnection(),this.remoteStream!==void 0&&(Y(this.remoteStream),this.remoteStream=void 0,this.acceptCall())}checkIsNotUndefined(...e){for(const t of e)if(t===void 0)throw new Error("someone is undefined");return e}async sendDtmf(e){this.rtcClient?.sendDtmf(this.remoteNumber,this.sessionId,e)}playRemoteStream(e,t){const{audioOnly:s=!1}=t||{};this.on(w.stream,n=>{if(n.stream){const r=s?new MediaStream(n.stream.getAudioTracks()):n.stream;F(r,e)}}),this.on(w.bye,()=>{e&&q(e)})}}var T=(i=>(i.audio="audio",i.video="video",i.audioVideo="audioVideo",i.unknown="unknown",i))(T||{});class $ extends z{constructor(){super(...arguments),this.responseCallType=T.unknown}async start(){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);if(n===M.ok){await this.setAnswer(r);const d=r.split(`\r
1
+ (function(p,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(p=typeof globalThis<"u"?globalThis:p||self,w(p.UscRtc={}))})(this,(function(p){"use strict";var w=(i=>(i.bye="bye",i.stream="stream",i.reInvite="reInvite",i.localAudioChange="localAudioChange",i.localVideoChange="localVideoChange",i.localStreamChange="localStreamChange",i))(w||{}),P=(i=>(i.connected="connected",i.disconnected="disconnected",i.invite="invite",i))(P||{}),x=(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))(x||{}),b=(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||{}),U=(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))(U||{});let J=(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),"");const q=i=>{i!==void 0&&(i.pause(),i.removeAttribute("src"),i.removeAttribute("srcObject"))},F=(i,e)=>{i!==void 0&&e!==void 0&&(e.srcObject=i,e.play())},Y=i=>{i.onaddtrack=null,i.onremovetrack=null,i.getTracks().forEach(e=>{i?.removeTrack(e),e.onended=null,e.onmute=null,e.onunmute=null,e.stop()})};let G=!1;const g=(i,...e)=>{G&&console.log(`%c usc-rtc-devtools %c ${i} %c `,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#41b883 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",...e)},fe=(i,...e)=>{G&&console.log(`%c usc-rtc-devtools %c ${i} %c `,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff0000 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",...e)},me=()=>{G=!1},ve=()=>{G=!0};var V={exports:{}},Q;function pe(){if(Q)return V.exports;Q=1;var i=typeof Reflect=="object"?Reflect:null,e=i&&typeof i.apply=="function"?i.apply:function(o,c,u){return Function.prototype.apply.call(o,c,u)},t;i&&typeof i.ownKeys=="function"?t=i.ownKeys:Object.getOwnPropertySymbols?t=function(o){return Object.getOwnPropertyNames(o).concat(Object.getOwnPropertySymbols(o))}:t=function(o){return Object.getOwnPropertyNames(o)};function s(a){console&&console.warn&&console.warn(a)}var n=Number.isNaN||function(o){return o!==o};function r(){r.init.call(this)}V.exports=r,V.exports.once=Ue,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var d=10;function h(a){if(typeof a!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof a)}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return d},set:function(a){if(typeof a!="number"||a<0||n(a))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+a+".");d=a}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(o){if(typeof o!="number"||o<0||n(o))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+o+".");return this._maxListeners=o,this};function C(a){return a._maxListeners===void 0?r.defaultMaxListeners:a._maxListeners}r.prototype.getMaxListeners=function(){return C(this)},r.prototype.emit=function(o){for(var c=[],u=1;u<arguments.length;u++)c.push(arguments[u]);var l=o==="error",v=this._events;if(v!==void 0)l=l&&v.error===void 0;else if(!l)return!1;if(l){var f;if(c.length>0&&(f=c[0]),f instanceof Error)throw f;var S=new Error("Unhandled error."+(f?" ("+f.message+")":""));throw S.context=f,S}var O=v[o];if(O===void 0)return!1;if(typeof O=="function")e(O,this,c);else for(var he=O.length,Fe=ue(O,he),u=0;u<he;++u)e(Fe[u],this,c);return!0};function E(a,o,c,u){var l,v,f;if(h(c),v=a._events,v===void 0?(v=a._events=Object.create(null),a._eventsCount=0):(v.newListener!==void 0&&(a.emit("newListener",o,c.listener?c.listener:c),v=a._events),f=v[o]),f===void 0)f=v[o]=c,++a._eventsCount;else if(typeof f=="function"?f=v[o]=u?[c,f]:[f,c]:u?f.unshift(c):f.push(c),l=C(a),l>0&&f.length>l&&!f.warned){f.warned=!0;var S=new Error("Possible EventEmitter memory leak detected. "+f.length+" "+String(o)+" listeners added. Use emitter.setMaxListeners() to increase limit");S.name="MaxListenersExceededWarning",S.emitter=a,S.type=o,S.count=f.length,s(S)}return a}r.prototype.addListener=function(o,c){return E(this,o,c,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(o,c){return E(this,o,c,!0)};function j(){if(!this.fired)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)}function R(a,o,c){var u={fired:!1,wrapFn:void 0,target:a,type:o,listener:c},l=j.bind(u);return l.listener=c,u.wrapFn=l,l}r.prototype.once=function(o,c){return h(c),this.on(o,R(this,o,c)),this},r.prototype.prependOnceListener=function(o,c){return h(c),this.prependListener(o,R(this,o,c)),this},r.prototype.removeListener=function(o,c){var u,l,v,f,S;if(h(c),l=this._events,l===void 0)return this;if(u=l[o],u===void 0)return this;if(u===c||u.listener===c)--this._eventsCount===0?this._events=Object.create(null):(delete l[o],l.removeListener&&this.emit("removeListener",o,u.listener||c));else if(typeof u!="function"){for(v=-1,f=u.length-1;f>=0;f--)if(u[f]===c||u[f].listener===c){S=u[f].listener,v=f;break}if(v<0)return this;v===0?u.shift():We(u,v),u.length===1&&(l[o]=u[0]),l.removeListener!==void 0&&this.emit("removeListener",o,S||c)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(o){var c,u,l;if(u=this._events,u===void 0)return this;if(u.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):u[o]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete u[o]),this;if(arguments.length===0){var v=Object.keys(u),f;for(l=0;l<v.length;++l)f=v[l],f!=="removeListener"&&this.removeAllListeners(f);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(c=u[o],typeof c=="function")this.removeListener(o,c);else if(c!==void 0)for(l=c.length-1;l>=0;l--)this.removeListener(o,c[l]);return this};function ce(a,o,c){var u=a._events;if(u===void 0)return[];var l=u[o];return l===void 0?[]:typeof l=="function"?c?[l.listener||l]:[l]:c?je(l):ue(l,l.length)}r.prototype.listeners=function(o){return ce(this,o,!0)},r.prototype.rawListeners=function(o){return ce(this,o,!1)},r.listenerCount=function(a,o){return typeof a.listenerCount=="function"?a.listenerCount(o):de.call(a,o)},r.prototype.listenerCount=de;function de(a){var o=this._events;if(o!==void 0){var c=o[a];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}r.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function ue(a,o){for(var c=new Array(o),u=0;u<o;++u)c[u]=a[u];return c}function We(a,o){for(;o+1<a.length;o++)a[o]=a[o+1];a.pop()}function je(a){for(var o=new Array(a.length),c=0;c<o.length;++c)o[c]=a[c].listener||a[c];return o}function Ue(a,o){return new Promise(function(c,u){function l(f){a.removeListener(o,v),u(f)}function v(){typeof a.removeListener=="function"&&a.removeListener("error",l),c([].slice.call(arguments))}le(a,o,v,{once:!0}),o!=="error"&&qe(a,l,{once:!0})})}function qe(a,o,c){typeof a.on=="function"&&le(a,"error",o,c)}function le(a,o,c,u){if(typeof a.on=="function")u.once?a.once(o,c):a.on(o,c);else if(typeof a.addEventListener=="function")a.addEventListener(o,function l(v){u.once&&a.removeEventListener(o,l),c(v)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof a)}return V.exports}var K=pe();class ge extends K.EventEmitter{constructor(){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)}releaseTrack(e){e!==void 0&&(this.localMediaStream?.removeTrack(e),e.stop())}addDeviceChangeListener(e){navigator.mediaDevices.addEventListener("devicechange",e)}removeDeviceChangeListener(e){navigator.mediaDevices.removeEventListener("devicechange",e)}setVideoTrack(e){this.emit(w.localVideoChange,{from:this.videoTrack,to:e}),this.videoTrack!==e&&(this.localMediaStream?.addTrack(e),this.localTractChange(this.videoTrack,e)),this.videoTrack=e}setAudioTrack(e){this.emit(w.localAudioChange,{from:this.audioTrack,to:e}),this.audioTrack!==e&&(this.localMediaStream?.addTrack(e),this.localTractChange(this.audioTrack,e)),this.audioTrack=e}renderLocalStreamToContainer(e){F(this.localMediaStream,e)}async getAllInputResource(){let e=await navigator.mediaDevices.enumerateDevices();return{audio:e.filter(t=>t.kind==="audioinput"),video:e.filter(t=>t.kind==="videoinput")}}async useDefaultDevice(e){let t={audio:!0,video:!0},s=await navigator.mediaDevices.getUserMedia(t);this.setAudioTrack(s.getAudioTracks()[0]),this.setVideoTrack(s.getVideoTracks()[0]),this.renderLocalStreamToContainer(e)}async useAudio(e){let t=e===void 0?{audio:{...this.audioConstrants},video:!1}:{video:!1,audio:{deviceId:e,...this.audioConstrants}},s=await navigator.mediaDevices.getUserMedia(t);return this.setAudioTrack(s.getAudioTracks()[0]),s.getAudioTracks()[0]}async useDeviceVideo(e){let t=e===void 0?{audio:!1,video:{...this.videoConstrains}}:{audio:!1,video:{deviceId:e,...this.videoConstrains}},s=await navigator.mediaDevices.getUserMedia(t);return this.setVideoTrack(s.getVideoTracks()[0]),s.getVideoTracks()[0]}async useDeskTopVideo(){let e=await navigator.mediaDevices.getDisplayMedia({video:{...this.videoConstrains},audio:!1});return this.setVideoTrack(e.getVideoTracks()[0]),e.getVideoTracks()[0]}disableAudio(){this.audioTrack!==void 0&&this.audioTrack.enabled&&(g("local audio status change",this.audioTrack),this.audioTrack.enabled=!1,this.setAudioTrack(this.audioTrack))}enableAudio(){this.audioTrack!==void 0&&!this.audioTrack.enabled&&(g("local audio status change",this.audioTrack),this.audioTrack.enabled=!0,this.setAudioTrack(this.audioTrack))}disableVideo(){this.videoTrack!==void 0&&this.videoTrack.enabled&&(g("local video status change",this.videoTrack),this.videoTrack.enabled=!1,this.setVideoTrack(this.videoTrack))}enableVideo(){this.videoTrack!==void 0&&!this.videoTrack.enabled&&(g("local video status change",this.videoTrack),this.videoTrack.enabled=!0,this.setVideoTrack(this.videoTrack))}close(){this.releaseTrack(this.audioTrack),this.releaseTrack(this.videoTrack),this.audioTrack=void 0,this.videoTrack=void 0,this.localMediaStream=void 0}}class ke extends ge{constructor(){super(),this.videoCodecs=[],this.audioCodecs=[],this.audioReciveCodecs=[],this.preferCodec(),this.peerConnection=this.buildConnection()}buildConnection(){let e=new RTCPeerConnection({bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});return e.addEventListener("connectionstatechange",t=>g("connectionstatechange",t)),e.addEventListener("icecandidate",t=>{g("icecandidate",t),this.onIceCandidate(t)}),e.addEventListener("datachannel",t=>g("datachannel",t)),e.addEventListener("icecandidateerror",t=>g("icecandidateerror",t)),e.addEventListener("iceconnectionstatechange",t=>g("iceconnectionstatechange",t)),e.addEventListener("icegatheringstatechange",t=>g("icegatheringstatechange",t)),e.addEventListener("negotiationneeded",t=>g("negotiationneeded",t)),e.addEventListener("signalingstatechange",t=>g("signalingstatechange",t)),e.addEventListener("track",t=>this.reciveTrack(t)),e}async localTractChange(e,t){if(this.remoteStream!==void 0&&this.peerConnection!==void 0)if(t!==void 0){let s=this.peerConnection.getSenders().find(n=>n.track?.kind===t.kind);s!==void 0&&s.replaceTrack(t)}else{let s=this.peerConnection.getSenders().find(n=>n.track?.kind===e?.kind);s!==void 0&&this.peerConnection.removeTrack(s)}t!==void 0&&(t.onended=s=>g("local track end",s),t.onmute=s=>{g("local mute",s),this.emitLocalStreamChange()},t.onunmute=s=>{g("local unmute",s),this.emitLocalStreamChange()}),this.releaseTrack(e),this.emitLocalStreamChange()}isInMeeting(){return this.remoteStream!==void 0}hasRemoteVideo(e){return e?.getVideoTracks().some(t=>t.muted===!1&&t.readyState==="live")??!1}emitLocalStreamChange(){this.emit(w.localStreamChange,{audioOnly:!this.hasRemoteVideo(this.localMediaStream),stream:this.localMediaStream})}emitRemoteStreamChange(){this.emit(w.stream,{audioOnly:!this.hasRemoteVideo(this.remoteStream),stream:this.remoteStream})}trigerStreamChange(e=100){this.emitStreamTimeout!==void 0&&clearTimeout(this.emitStreamTimeout),this.emitStreamTimeout=setTimeout(()=>{this.emitRemoteStreamChange(),this.emitStreamTimeout=void 0},e)}reciveTrack(e){g("recive track",e),this.remoteStream===void 0&&(this.remoteStream=new MediaStream),e.track.addEventListener("ended",()=>this.trigerStreamChange()),e.track.addEventListener("mute",()=>this.trigerStreamChange(3e3)),e.track.addEventListener("unmute",()=>this.trigerStreamChange(10)),this.remoteStream.addTrack(e.track),this.trigerStreamChange()}preferCodec(e="H264",t="PCMA"){this.videoCodecs=[];let s=RTCRtpSender.getCapabilities("video");s!==null&&this.videoCodecs.push(...s.codecs.filter(h=>h.mimeType===`video/${e}`));let n=RTCRtpReceiver.getCapabilities("video");n!==null&&this.videoCodecs.push(...n.codecs.filter(h=>h.mimeType===`video/${e}`)),this.audioCodecs=[];let r=RTCRtpSender.getCapabilities("audio");r!==null&&this.audioCodecs.push(...r.codecs.filter(h=>h.mimeType===`audio/${t}`));let d=RTCRtpReceiver.getCapabilities("audio");d!==null&&this.audioCodecs.push(...d.codecs.filter(h=>h.mimeType===`audio/${t}`))}trackIsInPeerConnection(e){return this.peerConnection?.getSenders().some(t=>t.track?.id===e.id)??!1}updateTracks(){if(this.peerConnection===void 0||this.peerConnection.signalingState==="closed")throw new Error("session is closed !");if(this.audioTrack===void 0&&this.videoTrack===void 0){this.peerConnection.addTransceiver("audio",{direction:"recvonly"}),this.peerConnection.addTransceiver("video",{direction:"recvonly"});return}if(this.audioTrack!==void 0&&!this.trackIsInPeerConnection(this.audioTrack))try{this.peerConnection.addTrack(this.audioTrack)}catch{}if(this.videoTrack!==void 0&&!this.trackIsInPeerConnection(this.videoTrack))try{this.peerConnection.addTrack(this.videoTrack)}catch{}try{this.peerConnection.getTransceivers().forEach(e=>{e.sender.track!==null&&(e.sender.track.kind==="video"?e.setCodecPreferences([...this.videoCodecs]):e.sender.track.kind==="audio"&&e.setCodecPreferences([...this.audioCodecs]))})}catch(e){fe("preferCodec error",e,this.audioCodecs,this.videoCodecs)}}async createOffer(){if(this.peerConnection===void 0)throw new Error("session is closed !");this.updateTracks();let e=await this.peerConnection.createOffer();return await this.peerConnection.setLocalDescription(e),e}async setOffer(e){if(this.peerConnection===void 0)throw new Error("session is closed !");this.updateTracks(),await this.peerConnection.setRemoteDescription({type:"offer",sdp:e})}async createAnswer(){if(this.peerConnection===void 0)throw new Error("session is closed !");this.updateTracks();let e=await this.peerConnection.createAnswer();return this.peerConnection.setLocalDescription(e),e}async setAnswer(e){if(this.peerConnection===void 0)throw new Error("session is closed !");await this.peerConnection.setRemoteDescription({type:"answer",sdp:e})}setRemoteIce(e){if(this.peerConnection===void 0)throw new Error("session is closed !");let t=new RTCIceCandidate(e);this.peerConnection.addIceCandidate(t)}closeConnection(e){e.close(),e.ontrack=null,e.onicecandidate=null,e.oniceconnectionstatechange=null,e.onsignalingstatechange=null,e.onicegatheringstatechange=null,e.onnegotiationneeded=null,e.onicecandidateerror=null,e.ondatachannel=null,e.onconnectionstatechange=null}close(){super.close(),this.peerConnection!==void 0&&(this.closeConnection(this.peerConnection),this.peerConnection=void 0),this.remoteStream!==void 0&&Y(this.remoteStream)}}var M=(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))(M||{});class z extends ke{constructor(e,t,s){super(),this.sessionId=t,this.rtcClient=e,this.remoteNumber=s}reciveIceRequest({ice:e}){this.setRemoteIce(JSON.parse(e))}getRemoteNumber(){return this.remoteNumber}onIceCandidate(e){}destroy(e=!0){this.removeAllListeners(),this.rtcClient!==void 0&&(this.remoteNumber!==void 0&&(e&&this.rtcClient.sendBye(this.remoteNumber,this.sessionId),this.remoteNumber=void 0),this.rtcClient.removeSession(this)),this.rtcClient=void 0,super.close()}rejectCall(){let[e,t,s]=this.checkIsNotUndefined(this.rtcClient,this.remoteNumber,this.inviteSeq);e.answer(M.reject,s,t,this.sessionId),this.destroy()}async acceptCall(){if(this.inviteOffer!==void 0){await this.setOffer(this.inviteOffer);let[e,t,s]=this.checkIsNotUndefined(this.rtcClient,this.remoteNumber,this.inviteSeq),{sdp:n}=await this.createAnswer();e.answer(M.ok,s,t,this.sessionId,n)}}async pickNewConnection(){this.peerConnection!==void 0&&this.closeConnection(this.peerConnection),this.peerConnection=this.buildConnection(),this.remoteStream!==void 0&&(Y(this.remoteStream),this.remoteStream=void 0,this.acceptCall())}checkIsNotUndefined(...e){for(const t of e)if(t===void 0)throw new Error("someone is undefined");return e}async sendDtmf(e){this.rtcClient?.sendDtmf(this.remoteNumber,this.sessionId,e)}playRemoteStream(e,t){const{audioOnly:s=!1}=t||{};this.on(w.stream,n=>{if(n.stream){const r=s?new MediaStream(n.stream.getAudioTracks()):n.stream;F(r,e)}}),this.on(w.bye,()=>{e&&q(e)})}}var T=(i=>(i.audio="audio",i.video="video",i.audioVideo="audioVideo",i.unknown="unknown",i))(T||{});class $ extends z{constructor(){super(...arguments),this.responseCallType=T.unknown}async start(){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);if(n===M.ok){await this.setAnswer(r);const d=r.split(`\r
4
2
  `),h=d.find(E=>E.startsWith("m=audio")),C=d.find(E=>E.startsWith("m=video"));this.responseCallType=h&&C?T.audioVideo:h?T.audio:C?T.video:T.unknown}return n}addRemote(e){this.remoteNumber=e}}const D=class D{constructor(e,t,s,n){this.req=e,this.seq=0,this.from=t,this.to=s,this.registerid=`${D.random}@${t}`,n!==void 0&&Object.assign(this,n)}};D.random=String(Date.now());let L=D;var I=(i=>(i.connected="connected",i.disconnected="disconnected",i.message="message",i))(I||{});const X=`(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))}})();
5
- `,Z=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",X],{type:"text/javascript;charset=utf-8"});function we(i){let e;try{if(e=Z&&(self.URL||self.webkitURL).createObjectURL(Z),!e)throw"";const t=new Worker(e,{name:i?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(X),{name:i?.name})}}class Ee extends K.EventEmitter{constructor(e,t,s){super(),this.server=e,this.ws=new we,this.configHeartBeat(t,s)}connect(){this.initWebsocket(),this.ws.onmessage=e=>{const{type:t,data:s}=e.data;switch(t){case"webSocket":g("websocket recive message ",s),this.emit(I.message,s);return;case"open":g("websocket connected ",this.server),this.emit(I.connected);return}}}configHeartBeat(e,t){g("websocket heartBeat",e),g("websocket heartTime",t),this.ws.postMessage({cmd:"config",heartBeat:e,heartTime:t})}initWebsocket(){this.ws.postMessage({cmd:"start",url:this.server})}send(e){this.ws.postMessage({cmd:"msg",data:e})}close(){this.ws.postMessage({cmd:"close"})}sendMessage(e){g("websocket send message ",e),e!==void 0&&this.ws!==void 0&&this.ws.postMessage({cmd:"msg",data:e})}}class Te extends K.EventEmitter{constructor(e,t,s,n){super(),this.activeServer="",this.server=e,this.localNumber=t,this.expireTime=s,this.heartTime=n,super.setMaxListeners(0)}async testWs(e){return e.reduce((t,s)=>t.then(n=>Promise.resolve(n),n=>new Promise((r,d)=>{const h=new WebSocket(s);h.onopen=()=>{n.push(s),h.close(),r(n)},h.onclose=()=>{d(n)}})),Promise.reject([])).then(t=>Promise.resolve(t),t=>Promise.resolve(t))}async reConnect(){this.destroy();let e=[];this.server!==void 0&&(typeof this.server=="string"?e=[this.server]:e=this.server);const t=await this.testWs(e);return new Promise((s,n)=>{if(t.length>0){this.activeServer=t[0];let r=new Ee(this.activeServer,new L(y.MESSAGE_TYPE_REGISTER,this.localNumber,this.localNumber,{expire:this.expireTime}),this.heartTime);r.on(I.connected,()=>{this.socketWorker=r,this.onConnected(),s()}),r.on(I.disconnected,d=>{this.socketWorker=void 0,this.onDisConnected(d),n("socketWorker connecion failed")}),r.on(I.message,d=>this.onReviceMessage(d)),r.connect()}else n("server is empty")})}sendMessage(e){if(this.socketWorker!==void 0)this.socketWorker.sendMessage(e);else throw new Error("socketWorker is closed")}destroy(){this.socketWorker!==void 0&&(this.unRegister(),this.socketWorker.close(),this.socketWorker=void 0)}}class ye extends Te{constructor(){super(...arguments),this.asyncProducer=new Map}async sendRespondableMessage(e){return this.sendMessage(e),new Promise(t=>this.asyncProducer.set(e.seq,t))}getAsyncResolve(e){let t=this.asyncProducer.get(e);return t!==void 0&&this.asyncProducer.delete(e),t}onDisConnected(e){this.asyncProducer.clear(),this.emit(P.disconnected,e)}onReviceMessage(e){let{status:t,seq:s}=e;t!==void 0?this.getAsyncResolve(s)?.call(void 0,e):this.processMessage(e)}}class be extends ye{async register(){let e=new L(y.MESSAGE_TYPE_REGISTER,this.localNumber,this.localNumber,{expire:this.expireTime});return this.sendRespondableMessage(e)}unRegister(){let e=new L(y.MESSAGE_TYPE_REGISTER,this.localNumber,this.localNumber,{expire:0});this.sendMessage(e)}async invite(e,t,s){return this.sendRespondableMessage(new L(y.MESSAGE_TYPE_INVITE,this.localNumber,e,{cid:t,sdp:s}))}sendIce(e,t,s){}sendBye(e,t){return this.sendMessage(new L(y.MESSAGE_TYPE_BYE,this.localNumber,e,{cid:t}))}answer(e,t,s,n,r){this.sendMessage({status:e,seq:t,from:s,to:this.localNumber,cid:n,sdp:r})}sendPttMessage(e){this.sendMessage(e)}async sendDtmf(e,t,s){return this.sendMessage(new L(y.MESSAGE_TYPE_INFO,this.localNumber,e,{cid:t,info:{msg:"dtmf",dtmf:s}}))}}var Se;function _(){}_.prototype=Object.create(null);function m(){m.init.call(this)}m.EventEmitter=m,m.usingDomains=!1,m.prototype.domain=void 0,m.prototype._events=void 0,m.prototype._maxListeners=void 0,m.defaultMaxListeners=10,m.init=function(){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},m.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function ee(i){return i._maxListeners===void 0?m.defaultMaxListeners:i._maxListeners}m.prototype.getMaxListeners=function(){return ee(this)};function Le(i,e,t){if(e)i.call(t);else for(var s=i.length,n=N(i,s),r=0;r<s;++r)n[r].call(t)}function _e(i,e,t,s){if(e)i.call(t,s);else for(var n=i.length,r=N(i,n),d=0;d<n;++d)r[d].call(t,s)}function Re(i,e,t,s,n){if(e)i.call(t,s,n);else for(var r=i.length,d=N(i,r),h=0;h<r;++h)d[h].call(t,s,n)}function Me(i,e,t,s,n,r){if(e)i.call(t,s,n,r);else for(var d=i.length,h=N(i,d),C=0;C<d;++C)h[C].call(t,s,n,r)}function Ie(i,e,t,s){if(e)i.apply(t,s);else for(var n=i.length,r=N(i,n),d=0;d<n;++d)r[d].apply(t,s)}m.prototype.emit=function(e){var t,s,n,r,d,h,C,E=e==="error";if(h=this._events,h)E=E&&h.error==null;else if(!E)return!1;if(C=this.domain,E){if(t=arguments[1],C)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=C,t.domainThrown=!1,C.emit("error",t);else{if(t instanceof Error)throw t;var j=new Error('Uncaught, unspecified "error" event. ('+t+")");throw j.context=t,j}return!1}if(s=h[e],!s)return!1;var R=typeof s=="function";switch(n=arguments.length,n){case 1:Le(s,R,this);break;case 2:_e(s,R,this,arguments[1]);break;case 3:Re(s,R,this,arguments[1],arguments[2]);break;case 4:Me(s,R,this,arguments[1],arguments[2],arguments[3]);break;default:for(r=new Array(n-1),d=1;d<n;d++)r[d-1]=arguments[d];Ie(s,R,this,r)}return!0};function te(i,e,t,s){var n,r,d;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(r=i._events,r?(r.newListener&&(i.emit("newListener",e,t.listener?t.listener:t),r=i._events),d=r[e]):(r=i._events=new _,i._eventsCount=0),!d)d=r[e]=t,++i._eventsCount;else if(typeof d=="function"?d=r[e]=s?[t,d]:[d,t]:s?d.unshift(t):d.push(t),!d.warned&&(n=ee(i),n&&n>0&&d.length>n)){d.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+d.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=i,h.type=e,h.count=d.length,Oe(h)}return i}function Oe(i){typeof console.warn=="function"?console.warn(i):console.log(i)}m.prototype.addListener=function(e,t){return te(this,e,t,!1)},m.prototype.on=m.prototype.addListener,m.prototype.prependListener=function(e,t){return te(this,e,t,!0)};function ie(i,e,t){var s=!1;function n(){i.removeListener(e,n),s||(s=!0,t.apply(i,arguments))}return n.listener=t,n}m.prototype.once=function(e,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,ie(this,e,t)),this},m.prototype.prependOnceListener=function(e,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,ie(this,e,t)),this},m.prototype.removeListener=function(e,t){var s,n,r,d,h;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(n=this._events,!n)return this;if(s=n[e],!s)return this;if(s===t||s.listener&&s.listener===t)--this._eventsCount===0?this._events=new _:(delete n[e],n.removeListener&&this.emit("removeListener",e,s.listener||t));else if(typeof s!="function"){for(r=-1,d=s.length;d-- >0;)if(s[d]===t||s[d].listener&&s[d].listener===t){h=s[d].listener,r=d;break}if(r<0)return this;if(s.length===1){if(s[0]=void 0,--this._eventsCount===0)return this._events=new _,this;delete n[e]}else Ne(s,r);n.removeListener&&this.emit("removeListener",e,h||t)}return this},m.prototype.off=function(i,e){return this.removeListener(i,e)},m.prototype.removeAllListeners=function(e){var t,s;if(s=this._events,!s)return this;if(!s.removeListener)return arguments.length===0?(this._events=new _,this._eventsCount=0):s[e]&&(--this._eventsCount===0?this._events=new _:delete s[e]),this;if(arguments.length===0){for(var n=Object.keys(s),r=0,d;r<n.length;++r)d=n[r],d!=="removeListener"&&this.removeAllListeners(d);return this.removeAllListeners("removeListener"),this._events=new _,this._eventsCount=0,this}if(t=s[e],typeof t=="function")this.removeListener(e,t);else if(t)do this.removeListener(e,t[t.length-1]);while(t[0]);return this},m.prototype.listeners=function(e){var t,s,n=this._events;return n?(t=n[e],t?typeof t=="function"?s=[t.listener||t]:s=Ae(t):s=[]):s=[],s},m.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):se.call(i,e)},m.prototype.listenerCount=se;function se(i){var e=this._events;if(e){var t=e[i];if(typeof t=="function")return 1;if(t)return t.length}return 0}m.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function Ne(i,e){for(var t=e,s=t+1,n=i.length;s<n;t+=1,s+=1)i[t]=i[s];i.pop()}function N(i,e){for(var t=new Array(e);e--;)t[e]=i[e];return t}function Ae(i){for(var e=new Array(i.length),t=0;t<e.length;++t)e[t]=i[t].listener||i[t];return e}const k={ERROR:"error",SPEAKER:"speaker",TALKING:"talking",ACTIVE_GROUP:"activeGroup",JOIN_INFO:"joinInfo",DISCONNECTED:"disConnected"},ne={400:"消息不符规范",401:"验证不通过",403:"无权利操作",404:"不存在该用户",415:"错误参数",405:"无法操作",424:"不存在XD群",425:"管理员没有",426:"已存在管理员",427:"以前被拒绝过,或者删除过",428:"超出所配置的下属管理员的数量",429:"群内无用户",430:"管理员的索引号冲突",431:"还有子管理员存在"},O={connected:"connected",disconnected:"disconnected",message:"message"},b=(i,...e)=>{console.log(`%c usc-ptt-devtools %c ${i} %c `,"background:#16aae0 ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#14e04e ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",...e)},re=(i,...e)=>{console.log(`%c usc-ptt-devtools %c ${i} %c `,"background:#16aae0 ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#e02514 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",...e)};class Pe extends m{server="";ws=null;constructor(e){super(),this.server=e}connect(){this.ws=new WebSocket(this.server),this.ws.onopen=()=>{b("websocket connected ",this.server),this.emit(O.connected)},this.ws.onclose=()=>{b("websocket disconnected ",this.server),this.ws=void 0,this.emit(O.disconnected)},this.ws.onmessage=({data:e})=>{let t=JSON.parse(e);b("websocket recive message ",t),this.emit(O.message,t)}}close(){this.ws!==void 0&&(this.ws.close(),this.ws=void 0)}sendMessage(e){b("websocket send message ",e),e!==void 0&&this.ws!==void 0&&this.ws.readyState===1&&this.ws.send(JSON.stringify(e))}}class xe extends m{socket=void 0;timer=void 0;waitinggroup=void 0;speaker="";activeGroup="";talking=!1;constructor(e,t=20,s=!0){if(super(),!e)return re("服务器地址为空!");this.server=e,this.heartTime=t,this.autoReconnect=s}async initClient(){return this.destorySocket(),new Promise((e,t)=>{if(this.server!==void 0){let s=new Pe(this.server);s.on(O.connected,()=>{this.socket=s,this.timer=setInterval(()=>{this.sendMessage({req:0})},this.heartTime*1e3),e()}),s.on(O.disconnected,()=>{this.socket=void 0,this.autoReconnect?setTimeout(()=>{this.initClient()},3e3):this.emit(k.DISCONNECTED),t("socket connecion failed")}),s.on(O.message,n=>this.onReviceMessage(n)),s.connect()}else t("server is empty")})}onReviceMessage(e){b(e);const{info:t,msg:s,res:n}=e;if(t===10&&(this.speaker=`${s.speaker}`,b(`${this.speaker}正在说话`),this.emit(k.SPEAKER,this.speaker)),t===11&&(n.code===200?(this.activeGroup=this.waitinggroup,b(`加入组${this.activeGroup}`)):(this.activeGroup="",re(ne[n.code]),this.emit(k.ERROR,ne[n.code])),this.emit(k.ACTIVE_GROUP,this.activeGroup)),t===13&&(n.code===200?this.talking=!0:this.talking=!1,b(`talking:${this.talking}`),this.emit(k.TALKING,this.talking)),t===14&&(this.speaker="",b(`${this.speaker}停止说话`),this.emit(k.SPEAKER,this.speaker)),t===15){const r={user:s.number,group:s.g_num,code:s.status};b(`${r}进入组`),this.emit(k.JOIN_INFO,r)}}joinGroup(e,t,s,n){this.socket&&(this.waitinggroup=e,this.sendMessage({req:1,group:e,user:t,ptts:s,port:n}))}quitGroup(){this.socket&&(this.activeGroup="",this.emit(k.ACTIVE_GROUP,this.activeGroup),this.sendMessage({req:2}))}talk(){this.socket&&this.sendMessage({req:3})}stop(){this.talking=!1,b(`talking:${this.talking}`),this.emit(k.TALKING,this.talking),this.socket&&this.sendMessage({req:4})}sendMessage(e){if(this.socket!==void 0)this.socket.sendMessage(e);else throw new Error("socket is closed")}destorySocket(){this.socket!==void 0&&(this.socket.close(),this.socket=void 0)}destory(){this.destorySocket()}}const Ge=async(i,e=20,t=!0)=>{let s=new xe(i,e,t);return await s.initClient(),s},W=class W extends be{constructor(e){let t=e.expireTime||W.defaultExpireTime;super(e.server,e.localNumber,t,e.heartTime||(e.localNumber?5:0)),this.enablePtt=e.enablePtt,this.pttServer=e.pttServer}async initPttClient(){if(this.enablePtt)if(this.pttServer){const e=await Ge(this.pttServer);if(!e)return Promise.reject("ptt客户端初始化失败!");e.on(k.ACTIVE_GROUP,t=>{this.emit(k.ACTIVE_GROUP,t)}),e.on(k.SPEAKER,t=>{this.emit(k.SPEAKER,t)}),e.on(k.TALKING,t=>{this.emit(k.TALKING,t)}),e.on(k.JOIN_INFO,t=>{this.emit(k.JOIN_INFO,t)}),e.on(k.DISCONNECTED,t=>{this.emit(k.DISCONNECTED,t)}),this.pttClient=e}else return Promise.reject("pttServer不存在")}joinGroup(e,t,s,n){this.pttClient?.joinGroup(e,t,s,n)}quitGroup(){this.pttClient?.quitGroup()}talk(){this.pttClient?.talk()}stop(){this.pttClient?.stop()}onConnected(){}onDisConnected(){super.onDisConnected()}};W.defaultExpireTime=60;let B=W;class oe extends z{constructor(e,t,s,n,r){super(e,t,s),this.callType=T.unknown,this.inviteSeq=r,this.inviteOffer=n;const d=n.split(`\r
6
- `),h=d.find(E=>E.startsWith("m=audio")),C=d.find(E=>E.startsWith("m=video"));this.callType=h&&C?T.audioVideo:h?T.audio:C?T.video:T.unknown}}const ae={404:"不存在该用户或者设备(VPA)",407:"太多人观看同一设备(VPA)",426:"同一时间播放太多文件(MSU)",427:"MTC不支持主码流请求(MTC)",500:"SIP建立时间超时(VPA)",501:"CMU反应超时(VPA, MTC)",502:"连接视频源超时",503:"播放失败",504:"播放超时(VPA)",505:"TCP连接断开(VPA, MTC, MGW)",506:"视频源没有连接进入(VDO)",507:"发送消息到视频失败(VDO)",508:"TCP连接失败",509:"TCP无流超时(5s无流, VPA)",510:"摄像头主动停止(VDO)",511:"播放端无Play进入, 超时(VDO)",512:"无人观看,主动释放",513:"呼叫还没有建立(MGW)",514:"呼叫已经释放了(MGW)",515:"操作员断开摄像头(MGW)",516:"查询CMU失败(VPA, MTC, MGW)",517:"视频源返回建立连接错误",518:"播放后无流进入(VPA)",519:"会议输出操作失败",520:"会议停止输出操作失败",521:"会议腿断开连接操作失败",522:"会议腿连接操作失败",523:"文件节点创建失败",524:"MCU侧资源已经占用",525:"MCU创建会议失败",526:"播放文件连接失败",527:"分配文件ID超时",528:"单元连接没有建立",529:"发送内部消息失败",530:"UDP流中断",531:"文件不存在",600:"MGW系统忙",601:"MGW分配Pair失败",602:"MGW重启",603:"CONF分配失败",604:"功能还没有实现",702:"分配资源超时(MGW)",703:"连接资源超时(MGW)",800:"已经在播放中",801:"发送INVITE失败(GBS)",802:"呼叫不存在(MGW)",803:"摄像头离线(HKVS, DHVS)",804:"摄像头不存在",805:"参数缺少或者不对(GBS)",806:"调用SDK VideoStart失败(HKVS, DHVS)",807:"不支持的功能",808:"创建文件失败",809:"云台控制失败",810:"对端释放呼叫(GBS)",811:"呼叫建立超时(GBS)",812:"用户没有输入会议接入号",813:"管理员踢出",814:"管理员结束",815:"管理员移出",816:"管理员结束呼叫",817:"RTMP链接地址错误",818:"RTMP连接设备失败",900:"计划到时释放"};class H extends B{constructor(){super(...arguments),this.allSession=[]}createSession(e){let t=new $(this,J(),e);return this.allSession.push(t),t}playRemote(e,t,s){let n=new $(this,J(),e);return this.allSession.push(n),n.playRemoteStream(t,s),n.start(),n.on(w.bye,r=>{r.errorno in ae&&(r.message=ae[r.errorno]),this.removeSession(n),s?.onerror&&s.onerror(r)}),n}processMessage(e){let{req:t}=e;if(t===y.MESSAGE_TYPE_INVITE){let s=new oe(this,e.cid,e.from,e.sdp,e.seq);this.allSession.push(s),this.emit(P.invite,s)}else if(t===y.MESSAGE_TYPE_REINVITE){let s=this.allSession.find(n=>n.sessionId==e.cid);s!==void 0&&(s.inviteSeq=e.seq,s.inviteOffer=e.sdp,s.acceptCall(),s.emit(w.reInvite,s))}else if(t===y.MESSAGE_TYPE_ICE)this.allSession.find(s=>s.sessionId===e.cid)?.reciveIceRequest(e);else if(t===y.MESSAGE_TYPE_BYE){let s=this.allSession.find(n=>n.sessionId===e.cid);s!==void 0&&(s.emit(w.bye,e),s.destroy(!1))}t==U.FPRE&&this.emit(x.FPREInfo,e),t==U.IMS&&this.emit(x.IMSInfo,e)}destroy(){this.allSession!==void 0&&this.allSession.forEach(e=>{e.destroy()}),super.destroy()}removeSession(e){this.allSession!==void 0&&(this.allSession=this.allSession.filter(t=>t.sessionId!==e.sessionId))}onDisConnected(){super.onDisConnected(),this.destroy()}}const Ve=async i=>{let e=new H(i);await e.reConnect(),await e.initPttClient().catch(s=>{console.error(s)}),L.random=String(Date.now());let t=await e.register();return t.status===M.ok?e:(e.destroy(),Promise.reject(t))},De=async(i,e,t,s)=>{L.random=String(Date.now());let n=new H({server:i,localNumber:"anonymous",...s});await n.reConnect();const r=n.playRemote(e,t,s);return{destroy:()=>{q(t),r.destroy(),n.destroy()}}},We=async()=>{await navigator.mediaDevices.getUserMedia({audio:!0,video:!0})};p.PTTEvent=x,p.RtcCalledSession=oe,p.RtcCalledType=T,p.RtcClient=H,p.RtcClientEvent=P,p.RtcInviteStatus=M,p.RtcSession=$,p.RtcSessionEvent=w,p.authDevice=We,p.closeStreamAndTrack=Y,p.createRtcClient=Ve,p.disableLog=me,p.enableLog=ve,p.playRemote=De,p.releaseStreamFromContainer=q,p.renderStreamToContainer=F,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
3
+ `,Z=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",X],{type:"text/javascript;charset=utf-8"});function Ce(i){let e;try{if(e=Z&&(self.URL||self.webkitURL).createObjectURL(Z),!e)throw"";const t=new Worker(e,{name:i?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(X),{name:i?.name})}}class we extends K.EventEmitter{constructor(e,t,s){super(),this.server=e,this.ws=new Ce,this.configHeartBeat(t,s)}connect(){this.initWebsocket(),this.ws.onmessage=e=>{const{type:t,data:s}=e.data;switch(t){case"webSocket":g("websocket recive message ",s),this.emit(I.message,s);return;case"open":g("websocket connected ",this.server),this.emit(I.connected);return}}}configHeartBeat(e,t){g("websocket heartBeat",e),g("websocket heartTime",t),this.ws.postMessage({cmd:"config",heartBeat:e,heartTime:t})}initWebsocket(){this.ws.postMessage({cmd:"start",url:this.server})}send(e){this.ws.postMessage({cmd:"msg",data:e})}close(){this.ws.postMessage({cmd:"close"})}sendMessage(e){g("websocket send message ",e),e!==void 0&&this.ws!==void 0&&this.ws.postMessage({cmd:"msg",data:e})}}class Ee extends K.EventEmitter{constructor(e,t,s,n){super(),this.activeServer="",this.server=e,this.localNumber=t,this.expireTime=s,this.heartTime=n,super.setMaxListeners(0)}async testWs(e){return e.reduce((t,s)=>t.then(n=>Promise.resolve(n),n=>new Promise((r,d)=>{const h=new WebSocket(s);h.onopen=()=>{n.push(s),h.close(),r(n)},h.onclose=()=>{d(n)}})),Promise.reject([])).then(t=>Promise.resolve(t),t=>Promise.resolve(t))}async reConnect(){this.destroy();let e=[];this.server!==void 0&&(typeof this.server=="string"?e=[this.server]:e=this.server);const t=await this.testWs(e);return new Promise((s,n)=>{if(t.length>0){this.activeServer=t[0];let r=new we(this.activeServer,new L(b.MESSAGE_TYPE_REGISTER,this.localNumber,this.localNumber,{expire:this.expireTime}),this.heartTime);r.on(I.connected,()=>{this.socketWorker=r,this.onConnected(),s()}),r.on(I.disconnected,d=>{this.socketWorker=void 0,this.onDisConnected(d),n("socketWorker connecion failed")}),r.on(I.message,d=>this.onReviceMessage(d)),r.connect()}else n("server is empty")})}sendMessage(e){if(this.socketWorker!==void 0)this.socketWorker.sendMessage(e);else throw new Error("socketWorker is closed")}destroy(){this.socketWorker!==void 0&&(this.unRegister(),this.socketWorker.close(),this.socketWorker=void 0)}}class Te extends Ee{constructor(){super(...arguments),this.asyncProducer=new Map}async sendRespondableMessage(e){return this.sendMessage(e),new Promise(t=>this.asyncProducer.set(e.seq,t))}getAsyncResolve(e){let t=this.asyncProducer.get(e);return t!==void 0&&this.asyncProducer.delete(e),t}onDisConnected(e){this.asyncProducer.clear(),this.emit(P.disconnected,e)}onReviceMessage(e){let{status:t,seq:s}=e;t!==void 0?this.getAsyncResolve(s)?.call(void 0,e):this.processMessage(e)}}class be extends Te{async register(){let e=new L(b.MESSAGE_TYPE_REGISTER,this.localNumber,this.localNumber,{expire:this.expireTime});return this.sendRespondableMessage(e)}unRegister(){let e=new L(b.MESSAGE_TYPE_REGISTER,this.localNumber,this.localNumber,{expire:0});this.sendMessage(e)}async invite(e,t,s){return this.sendRespondableMessage(new L(b.MESSAGE_TYPE_INVITE,this.localNumber,e,{cid:t,sdp:s}))}sendIce(e,t,s){}sendBye(e,t){return this.sendMessage(new L(b.MESSAGE_TYPE_BYE,this.localNumber,e,{cid:t}))}answer(e,t,s,n,r){this.sendMessage({status:e,seq:t,from:s,to:this.localNumber,cid:n,sdp:r})}sendPttMessage(e){this.sendMessage(e)}async sendDtmf(e,t,s){return this.sendMessage(new L(b.MESSAGE_TYPE_INFO,this.localNumber,e,{cid:t,info:{msg:"dtmf",dtmf:s}}))}}var ye;function _(){}_.prototype=Object.create(null);function m(){m.init.call(this)}m.EventEmitter=m,m.usingDomains=!1,m.prototype.domain=void 0,m.prototype._events=void 0,m.prototype._maxListeners=void 0,m.defaultMaxListeners=10,m.init=function(){this.domain=null,m.usingDomains&&ye.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new _,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},m.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function ee(i){return i._maxListeners===void 0?m.defaultMaxListeners:i._maxListeners}m.prototype.getMaxListeners=function(){return ee(this)};function Se(i,e,t){if(e)i.call(t);else for(var s=i.length,n=A(i,s),r=0;r<s;++r)n[r].call(t)}function Le(i,e,t,s){if(e)i.call(t,s);else for(var n=i.length,r=A(i,n),d=0;d<n;++d)r[d].call(t,s)}function _e(i,e,t,s,n){if(e)i.call(t,s,n);else for(var r=i.length,d=A(i,r),h=0;h<r;++h)d[h].call(t,s,n)}function Re(i,e,t,s,n,r){if(e)i.call(t,s,n,r);else for(var d=i.length,h=A(i,d),C=0;C<d;++C)h[C].call(t,s,n,r)}function Me(i,e,t,s){if(e)i.apply(t,s);else for(var n=i.length,r=A(i,n),d=0;d<n;++d)r[d].apply(t,s)}m.prototype.emit=function(e){var t,s,n,r,d,h,C,E=e==="error";if(h=this._events,h)E=E&&h.error==null;else if(!E)return!1;if(C=this.domain,E){if(t=arguments[1],C)t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=C,t.domainThrown=!1,C.emit("error",t);else{if(t instanceof Error)throw t;var j=new Error('Uncaught, unspecified "error" event. ('+t+")");throw j.context=t,j}return!1}if(s=h[e],!s)return!1;var R=typeof s=="function";switch(n=arguments.length,n){case 1:Se(s,R,this);break;case 2:Le(s,R,this,arguments[1]);break;case 3:_e(s,R,this,arguments[1],arguments[2]);break;case 4:Re(s,R,this,arguments[1],arguments[2],arguments[3]);break;default:for(r=new Array(n-1),d=1;d<n;d++)r[d-1]=arguments[d];Me(s,R,this,r)}return!0};function te(i,e,t,s){var n,r,d;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(r=i._events,r?(r.newListener&&(i.emit("newListener",e,t.listener?t.listener:t),r=i._events),d=r[e]):(r=i._events=new _,i._eventsCount=0),!d)d=r[e]=t,++i._eventsCount;else if(typeof d=="function"?d=r[e]=s?[t,d]:[d,t]:s?d.unshift(t):d.push(t),!d.warned&&(n=ee(i),n&&n>0&&d.length>n)){d.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+d.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=i,h.type=e,h.count=d.length,Ie(h)}return i}function Ie(i){typeof console.warn=="function"?console.warn(i):console.log(i)}m.prototype.addListener=function(e,t){return te(this,e,t,!1)},m.prototype.on=m.prototype.addListener,m.prototype.prependListener=function(e,t){return te(this,e,t,!0)};function ie(i,e,t){var s=!1;function n(){i.removeListener(e,n),s||(s=!0,t.apply(i,arguments))}return n.listener=t,n}m.prototype.once=function(e,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,ie(this,e,t)),this},m.prototype.prependOnceListener=function(e,t){if(typeof t!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,ie(this,e,t)),this},m.prototype.removeListener=function(e,t){var s,n,r,d,h;if(typeof t!="function")throw new TypeError('"listener" argument must be a function');if(n=this._events,!n)return this;if(s=n[e],!s)return this;if(s===t||s.listener&&s.listener===t)--this._eventsCount===0?this._events=new _:(delete n[e],n.removeListener&&this.emit("removeListener",e,s.listener||t));else if(typeof s!="function"){for(r=-1,d=s.length;d-- >0;)if(s[d]===t||s[d].listener&&s[d].listener===t){h=s[d].listener,r=d;break}if(r<0)return this;if(s.length===1){if(s[0]=void 0,--this._eventsCount===0)return this._events=new _,this;delete n[e]}else Ne(s,r);n.removeListener&&this.emit("removeListener",e,h||t)}return this},m.prototype.off=function(i,e){return this.removeListener(i,e)},m.prototype.removeAllListeners=function(e){var t,s;if(s=this._events,!s)return this;if(!s.removeListener)return arguments.length===0?(this._events=new _,this._eventsCount=0):s[e]&&(--this._eventsCount===0?this._events=new _:delete s[e]),this;if(arguments.length===0){for(var n=Object.keys(s),r=0,d;r<n.length;++r)d=n[r],d!=="removeListener"&&this.removeAllListeners(d);return this.removeAllListeners("removeListener"),this._events=new _,this._eventsCount=0,this}if(t=s[e],typeof t=="function")this.removeListener(e,t);else if(t)do this.removeListener(e,t[t.length-1]);while(t[0]);return this},m.prototype.listeners=function(e){var t,s,n=this._events;return n?(t=n[e],t?typeof t=="function"?s=[t.listener||t]:s=Ae(t):s=[]):s=[],s},m.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):se.call(i,e)},m.prototype.listenerCount=se;function se(i){var e=this._events;if(e){var t=e[i];if(typeof t=="function")return 1;if(t)return t.length}return 0}m.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function Ne(i,e){for(var t=e,s=t+1,n=i.length;s<n;t+=1,s+=1)i[t]=i[s];i.pop()}function A(i,e){for(var t=new Array(e);e--;)t[e]=i[e];return t}function Ae(i){for(var e=new Array(i.length),t=0;t<e.length;++t)e[t]=i[t].listener||i[t];return e}const k={ERROR:"error",SPEAKER:"speaker",TALKING:"talking",ACTIVE_GROUP:"activeGroup",JOIN_INFO:"joinInfo",DISCONNECTED:"disConnected"},ne={400:"消息不符规范",401:"验证不通过",403:"无权利操作",404:"不存在该用户",415:"错误参数",405:"无法操作",424:"不存在XD群",425:"管理员没有",426:"已存在管理员",427:"以前被拒绝过,或者删除过",428:"超出所配置的下属管理员的数量",429:"群内无用户",430:"管理员的索引号冲突",431:"还有子管理员存在"},N={connected:"connected",disconnected:"disconnected",message:"message"},y=(i,...e)=>{console.log(`%c usc-ptt-devtools %c ${i} %c `,"background:#16aae0 ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#14e04e ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",...e)},re=(i,...e)=>{console.log(`%c usc-ptt-devtools %c ${i} %c `,"background:#16aae0 ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#e02514 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",...e)};class Oe extends m{server="";ws=null;constructor(e){super(),this.server=e}connect(){this.ws=new WebSocket(this.server),this.ws.onopen=()=>{y("websocket connected ",this.server),this.emit(N.connected)},this.ws.onclose=()=>{y("websocket disconnected ",this.server),this.ws=void 0,this.emit(N.disconnected)},this.ws.onmessage=({data:e})=>{let t=JSON.parse(e);y("websocket recive message ",t),this.emit(N.message,t)}}close(){this.ws!==void 0&&(this.ws.close(),this.ws=void 0)}sendMessage(e){y("websocket send message ",e),e!==void 0&&this.ws!==void 0&&this.ws.readyState===1&&this.ws.send(JSON.stringify(e))}}class Pe extends m{socket=void 0;timer=void 0;waitinggroup=void 0;speaker="";activeGroup="";talking=!1;constructor(e,t=20,s=!0){if(super(),!e)return re("服务器地址为空!");this.server=e,this.heartTime=t,this.autoReconnect=s}async initClient(){return this.destorySocket(),new Promise((e,t)=>{if(this.server!==void 0){let s=new Oe(this.server);s.on(N.connected,()=>{this.socket=s,this.timer=setInterval(()=>{this.sendMessage({req:0})},this.heartTime*1e3),e()}),s.on(N.disconnected,()=>{this.socket=void 0,this.autoReconnect?setTimeout(()=>{this.initClient()},3e3):this.emit(k.DISCONNECTED),t("socket connecion failed")}),s.on(N.message,n=>this.onReviceMessage(n)),s.connect()}else t("server is empty")})}onReviceMessage(e){y(e);const{info:t,msg:s,res:n}=e;if(t===10&&(this.speaker=`${s.speaker}`,y(`${this.speaker}正在说话`),this.emit(k.SPEAKER,this.speaker)),t===11&&(n.code===200?(this.activeGroup=this.waitinggroup,y(`加入组${this.activeGroup}`)):(this.activeGroup="",re(ne[n.code]),this.emit(k.ERROR,ne[n.code])),this.emit(k.ACTIVE_GROUP,this.activeGroup)),t===13&&(n.code===200?this.talking=!0:this.talking=!1,y(`talking:${this.talking}`),this.emit(k.TALKING,this.talking)),t===14&&(this.speaker="",y(`${this.speaker}停止说话`),this.emit(k.SPEAKER,this.speaker)),t===15){const r={user:s.number,group:s.g_num,code:s.status};y(`${r}进入组`),this.emit(k.JOIN_INFO,r)}}joinGroup(e,t,s,n){this.socket&&(this.waitinggroup=e,this.sendMessage({req:1,group:e,user:t,ptts:s,port:n}))}quitGroup(){this.socket&&(this.activeGroup="",this.emit(k.ACTIVE_GROUP,this.activeGroup),this.sendMessage({req:2}))}talk(){this.socket&&this.sendMessage({req:3})}stop(){this.talking=!1,y(`talking:${this.talking}`),this.emit(k.TALKING,this.talking),this.socket&&this.sendMessage({req:4})}sendMessage(e){if(this.socket!==void 0)this.socket.sendMessage(e);else throw new Error("socket is closed")}destorySocket(){this.socket!==void 0&&(this.socket.close(),this.socket=void 0)}destory(){this.destorySocket()}}const xe=async(i,e=20,t=!0)=>{let s=new Pe(i,e,t);return await s.initClient(),s},W=class W extends be{constructor(e){let t=e.expireTime||W.defaultExpireTime;super(e.server,e.localNumber,t,e.heartTime||(e.localNumber?5:0)),this.enablePtt=e.enablePtt,this.pttServer=e.pttServer}async initPttClient(){if(this.enablePtt)if(this.pttServer){const e=await xe(this.pttServer);if(!e)return Promise.reject("ptt客户端初始化失败!");e.on(k.ACTIVE_GROUP,t=>{this.emit(k.ACTIVE_GROUP,t)}),e.on(k.SPEAKER,t=>{this.emit(k.SPEAKER,t)}),e.on(k.TALKING,t=>{this.emit(k.TALKING,t)}),e.on(k.JOIN_INFO,t=>{this.emit(k.JOIN_INFO,t)}),e.on(k.DISCONNECTED,t=>{this.emit(k.DISCONNECTED,t)}),this.pttClient=e}else return Promise.reject("pttServer不存在")}joinGroup(e,t,s,n){this.pttClient?.joinGroup(e,t,s,n)}quitGroup(){this.pttClient?.quitGroup()}talk(){this.pttClient?.talk()}stop(){this.pttClient?.stop()}onConnected(){}onDisConnected(){super.onDisConnected()}};W.defaultExpireTime=60;let B=W;class oe extends z{constructor(e,t,s,n,r){super(e,t,s),this.callType=T.unknown,this.inviteSeq=r,this.inviteOffer=n;const d=n.split(`\r
4
+ `),h=d.find(E=>E.startsWith("m=audio")),C=d.find(E=>E.startsWith("m=video"));this.callType=h&&C?T.audioVideo:h?T.audio:C?T.video:T.unknown}}const ae={404:"不存在该用户或者设备(VPA)",407:"太多人观看同一设备(VPA)",426:"同一时间播放太多文件(MSU)",427:"MTC不支持主码流请求(MTC)",500:"SIP建立时间超时(VPA)",501:"CMU反应超时(VPA, MTC)",502:"连接视频源超时",503:"播放失败",504:"播放超时(VPA)",505:"TCP连接断开(VPA, MTC, MGW)",506:"视频源没有连接进入(VDO)",507:"发送消息到视频失败(VDO)",508:"TCP连接失败",509:"TCP无流超时(5s无流, VPA)",510:"摄像头主动停止(VDO)",511:"播放端无Play进入, 超时(VDO)",512:"无人观看,主动释放",513:"呼叫还没有建立(MGW)",514:"呼叫已经释放了(MGW)",515:"操作员断开摄像头(MGW)",516:"查询CMU失败(VPA, MTC, MGW)",517:"视频源返回建立连接错误",518:"播放后无流进入(VPA)",519:"会议输出操作失败",520:"会议停止输出操作失败",521:"会议腿断开连接操作失败",522:"会议腿连接操作失败",523:"文件节点创建失败",524:"MCU侧资源已经占用",525:"MCU创建会议失败",526:"播放文件连接失败",527:"分配文件ID超时",528:"单元连接没有建立",529:"发送内部消息失败",530:"UDP流中断",531:"文件不存在",600:"MGW系统忙",601:"MGW分配Pair失败",602:"MGW重启",603:"CONF分配失败",604:"功能还没有实现",702:"分配资源超时(MGW)",703:"连接资源超时(MGW)",800:"已经在播放中",801:"发送INVITE失败(GBS)",802:"呼叫不存在(MGW)",803:"摄像头离线(HKVS, DHVS)",804:"摄像头不存在",805:"参数缺少或者不对(GBS)",806:"调用SDK VideoStart失败(HKVS, DHVS)",807:"不支持的功能",808:"创建文件失败",809:"云台控制失败",810:"对端释放呼叫(GBS)",811:"呼叫建立超时(GBS)",812:"用户没有输入会议接入号",813:"管理员踢出",814:"管理员结束",815:"管理员移出",816:"管理员结束呼叫",817:"RTMP链接地址错误",818:"RTMP连接设备失败",900:"计划到时释放"};class H extends B{constructor(){super(...arguments),this.allSession=[]}createSession(e){let t=new $(this,J(),e);return this.allSession.push(t),t}playRemote(e,t,s){let n=new $(this,J(),e);return this.allSession.push(n),n.playRemoteStream(t,s),n.start(),n.on(w.bye,r=>{r.errorno in ae&&(r.message=ae[r.errorno]),this.removeSession(n),s?.onerror&&s.onerror(r)}),n}processMessage(e){let{req:t}=e;if(t===b.MESSAGE_TYPE_INVITE){let s=new oe(this,e.cid,e.from,e.sdp,e.seq);this.allSession.push(s),this.emit(P.invite,s)}else if(t===b.MESSAGE_TYPE_REINVITE){let s=this.allSession.find(n=>n.sessionId==e.cid);s!==void 0&&(s.inviteSeq=e.seq,s.inviteOffer=e.sdp,s.acceptCall(),s.emit(w.reInvite,s))}else if(t===b.MESSAGE_TYPE_ICE)this.allSession.find(s=>s.sessionId===e.cid)?.reciveIceRequest(e);else if(t===b.MESSAGE_TYPE_BYE){let s=this.allSession.find(n=>n.sessionId===e.cid);s!==void 0&&(s.emit(w.bye,e),s.destroy(!1))}t==U.FPRE&&this.emit(x.FPREInfo,e),t==U.IMS&&this.emit(x.IMSInfo,e)}destroy(){this.allSession!==void 0&&this.allSession.forEach(e=>{e.destroy()}),super.destroy()}removeSession(e){this.allSession!==void 0&&(this.allSession=this.allSession.filter(t=>t.sessionId!==e.sessionId))}onDisConnected(){super.onDisConnected(),this.destroy()}}const Ge=async i=>{let e=new H(i);await e.reConnect(),await e.initPttClient().catch(s=>{console.error(s)}),L.random=String(Date.now());let t=await e.register();return t.status===M.ok?e:(e.destroy(),Promise.reject(t))},Ve=async(i,e,t,s)=>{L.random=String(Date.now());let n=new H({server:i,localNumber:"anonymous",...s});await n.reConnect();const r=n.playRemote(e,t,s);return{destroy:()=>{q(t),r.destroy(),n.destroy()}}},De=async()=>{await navigator.mediaDevices.getUserMedia({audio:!0,video:!0})};p.PTTEvent=x,p.RtcCalledSession=oe,p.RtcCalledType=T,p.RtcClient=H,p.RtcClientEvent=P,p.RtcInviteStatus=M,p.RtcSession=$,p.RtcSessionEvent=w,p.authDevice=De,p.closeStreamAndTrack=Y,p.createRtcClient=Ge,p.disableLog=me,p.enableLog=ve,p.playRemote=Ve,p.releaseStreamFromContainer=q,p.renderStreamToContainer=F,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usc-rtc-client",
3
- "version": "2.3.0",
3
+ "version": "3.1.0",
4
4
  "description": "usc rtc client",
5
5
  "main": "./dist/index.umd.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,6 +0,0 @@
1
- /**
2
- * usc webrtc 协议格式
3
- */
4
- export declare class UscRtcProtocol {
5
- static formatOffer(offer: RTCSessionDescriptionInit): RTCSessionDescriptionInit;
6
- }