sip-connector 9.2.1 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ declare const configureScaleResolutionDownBy: (encodingCurrent: RTCRtpEncodingParameters, scaleResolutionDownBy?: number) => RTCRtpEncodingParameters;
2
+ export default configureScaleResolutionDownBy;
@@ -0,0 +1,2 @@
1
+ declare const hasChangedRTCRtpSendParameters: (parameters1: RTCRtpSendParameters, parameters2: RTCRtpSendParameters) => boolean;
2
+ export default hasChangedRTCRtpSendParameters;
@@ -0,0 +1 @@
1
+ export { default } from './setParametersToSender';
@@ -0,0 +1,2 @@
1
+ declare const resolveHasNeedToUpdateItemEncoding: (defaultValue?: number) => (itemEncodingTarget: typeof defaultValue, itemEncodingCurrent?: number) => boolean;
2
+ export default resolveHasNeedToUpdateItemEncoding;
@@ -0,0 +1,7 @@
1
+ import { TRtpSendParameters } from '../types';
2
+ type TResult = {
3
+ parameters: RTCRtpSendParameters;
4
+ isChanged: boolean;
5
+ };
6
+ declare const setParametersToSender: (sender: RTCRtpSender, parametersTarget: TRtpSendParameters) => Promise<TResult>;
7
+ export default setParametersToSender;
@@ -1,11 +1,10 @@
1
1
  import { default as SipConnector } from '../SipConnector';
2
- import { TContentHint } from '../types';
3
- type TDegradationPreference = 'balanced' | 'maintain-framerate' | 'maintain-resolution';
2
+ import { TContentHint, TRtpSendParameters } from '../types';
4
3
  declare const resolveAnswerIncomingCall: (sipConnector: SipConnector) => (parameters: {
5
4
  mediaStream: MediaStream;
6
5
  extraHeaders?: string[] | undefined;
7
6
  iceServers?: RTCIceServer[];
8
- degradationPreference?: TDegradationPreference;
7
+ rtpSendParameters?: TRtpSendParameters;
9
8
  contentHint?: TContentHint;
10
9
  setRemoteStreams: (streams: MediaStream[]) => void;
11
10
  onBeforeProgressCall?: (conference?: string) => void;
@@ -1,12 +1,11 @@
1
1
  import { default as SipConnector } from '../SipConnector';
2
- import { TContentHint } from '../types';
3
- type TDegradationPreference = 'balanced' | 'maintain-framerate' | 'maintain-resolution';
2
+ import { TContentHint, TRtpSendParameters } from '../types';
4
3
  declare const resolveCallToServer: (sipConnector: SipConnector) => (parameters: {
5
4
  conference: string;
6
5
  mediaStream: MediaStream;
7
6
  extraHeaders?: string[] | undefined;
8
7
  iceServers?: RTCIceServer[];
9
- degradationPreference?: TDegradationPreference;
8
+ rtpSendParameters?: TRtpSendParameters;
10
9
  contentHint?: TContentHint;
11
10
  setRemoteStreams: (streams: MediaStream[]) => void;
12
11
  onBeforeProgressCall?: (conference: string) => void;
@@ -0,0 +1,3 @@
1
+ import { TRtpSendParameters } from '../types';
2
+ declare const resolveHandleAddedSender: (rtpSendParameters?: TRtpSendParameters) => (sender: RTCRtpSender, track: MediaStreamTrack) => Promise<void>;
3
+ export default resolveHandleAddedSender;
@@ -1,10 +1,10 @@
1
1
  import { default as SipConnector } from '../SipConnector';
2
- import { TContentHint, TDegradationPreference } from '../types';
3
- declare const resolveStartPresentation: (sipConnector: SipConnector) => ({ mediaStream, isP2P, maxBitrate, degradationPreference, contentHint, }: {
2
+ import { TContentHint, TRtpSendParameters } from '../types';
3
+ declare const resolveStartPresentation: (sipConnector: SipConnector) => ({ mediaStream, isP2P, maxBitrate, rtpSendParameters, contentHint, }: {
4
4
  mediaStream: MediaStream;
5
5
  isP2P: boolean;
6
6
  maxBitrate?: number;
7
- degradationPreference?: TDegradationPreference;
7
+ rtpSendParameters?: TRtpSendParameters;
8
8
  contentHint?: TContentHint;
9
9
  }, options?: {
10
10
  callLimit: number;
@@ -1,10 +1,10 @@
1
1
  import { default as SipConnector } from '../SipConnector';
2
- import { TContentHint, TDegradationPreference } from '../types';
3
- declare const resolveUpdatePresentation: (sipConnector: SipConnector) => ({ mediaStream, isP2P, maxBitrate, degradationPreference, contentHint, }: {
2
+ import { TContentHint, TRtpSendParameters } from '../types';
3
+ declare const resolveUpdatePresentation: (sipConnector: SipConnector) => ({ mediaStream, isP2P, maxBitrate, rtpSendParameters, contentHint, }: {
4
4
  mediaStream: MediaStream;
5
5
  isP2P: boolean;
6
6
  maxBitrate?: number;
7
- degradationPreference?: TDegradationPreference;
7
+ rtpSendParameters?: TRtpSendParameters;
8
8
  contentHint?: TContentHint;
9
9
  }) => Promise<MediaStream | void>;
10
10
  export default resolveUpdatePresentation;
package/dist/types.d.ts CHANGED
@@ -46,5 +46,6 @@ export type TParametersCreateUaConfiguration = {
46
46
  connectionRecoveryMaxInterval?: number;
47
47
  userAgent?: string;
48
48
  };
49
- export type TDegradationPreference = 'balanced' | 'maintain-framerate' | 'maintain-resolution';
49
+ export type TOnAddedSender = (sender: RTCRtpSender, track: MediaStreamTrack, stream: MediaStream) => Promise<void>;
50
50
  export type TContentHint = 'motion' | 'detail' | 'text' | 'none';
51
+ export type TRtpSendParameters = Partial<Omit<RTCRtpSendParameters, 'transactionId'>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-connector",
3
- "version": "9.2.1",
3
+ "version": "10.0.0",
4
4
  "description": "Module for connect to Vinteo server",
5
5
  "keywords": [
6
6
  "webrtc",
@@ -58,12 +58,12 @@
58
58
  "release:pre": "standard-version --prerelease && npm run release:publish",
59
59
  "release:publish": "git push --follow-tags origin master && npm publish --access=public",
60
60
  "test": "jest --watch",
61
- "test:ci": "cross-env CI=true jest --passWithNoTests",
61
+ "test:ci": "cross-env CI=true jest",
62
62
  "test:coverage": "yarn test:ci --coverage --reporters=default --reporters=jest-junit"
63
63
  },
64
64
  "dependencies": {
65
65
  "@krivega/cancelable-promise": "^1.1.3",
66
- "@krivega/jssip": "^3.24.3",
66
+ "@krivega/jssip": "^4.0.0",
67
67
  "debug": "^4.3.7",
68
68
  "events-constructor": "^1.2.3",
69
69
  "repeated-calls": "^2.3.0",
@@ -73,13 +73,13 @@
73
73
  "webrtc-mock": "^1.1.6"
74
74
  },
75
75
  "devDependencies": {
76
- "@babel/preset-typescript": "^7.25.7",
76
+ "@babel/preset-typescript": "^7.25.9",
77
77
  "@commitlint/cli": "^19.5.0",
78
78
  "@commitlint/config-conventional": "^19.5.0",
79
79
  "@nabla/vite-plugin-eslint": "^2.0.4",
80
80
  "@types/debug": "^4.1.12",
81
81
  "@types/dom-mediacapture-transform": "^0.1.10",
82
- "@types/jest": "^29.5.13",
82
+ "@types/jest": "^29.5.14",
83
83
  "@typescript-eslint/eslint-plugin": "^7.15.0",
84
84
  "@typescript-eslint/parser": "^7.15.0",
85
85
  "cross-env": "^7.0.3",
@@ -105,13 +105,13 @@
105
105
  "ts-node": "^10.9.2",
106
106
  "tsc-files": "^1.1.4",
107
107
  "typescript": "^5.6.3",
108
- "vite": "^5.4.8",
109
- "vite-plugin-dts": "^4.2.3",
108
+ "vite": "^5.4.10",
109
+ "vite-plugin-dts": "^4.3.0",
110
110
  "vite-tsconfig-paths": "^5.0.1"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "@krivega/cancelable-promise": "^1.1.3",
114
- "@krivega/jssip": "^3.24.3",
114
+ "@krivega/jssip": "^4.0.0",
115
115
  "debug": "^4.3.7",
116
116
  "events-constructor": "^1.2.3",
117
117
  "repeated-calls": "^2.2.1",
@@ -1 +0,0 @@
1
- "use strict";var pt=Object.defineProperty;var Pt=(r,e,t)=>e in r?pt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>Pt(r,typeof e!="symbol"?e+"":e,t);const N=require("@krivega/cancelable-promise"),ve=require("events-constructor"),be=require("repeated-calls"),V=require("debug"),ft="Connection Error",qe="Request Timeout",Ot="SIP Failure Code",Dt="Internal Error",Mt="Busy",Y="Rejected",vt="Redirected",bt="Unavailable",ke="Not Found",yt="Address Incomplete",wt="Incompatible SDP",Ut="Missing SDP",Lt="Authentication Error",Fe="Terminated",Ht="WebRTC Error",Be="Canceled",Wt="No Answer",qt="Expires",kt="No ACK",Ft="Dialog Error",Bt="User Denied Media Access",Ve="Bad Media Description",Vt="RTP Timeout",Yt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:yt,AUTHENTICATION_ERROR:Lt,BAD_MEDIA_DESCRIPTION:Ve,BUSY:Mt,BYE:Fe,CANCELED:Be,CONNECTION_ERROR:ft,DIALOG_ERROR:Ft,EXPIRES:qt,INCOMPATIBLE_SDP:wt,INTERNAL_ERROR:Dt,MISSING_SDP:Ut,NOT_FOUND:ke,NO_ACK:kt,NO_ANSWER:Wt,REDIRECTED:vt,REJECTED:Y,REQUEST_TIMEOUT:qe,RTP_TIMEOUT:Vt,SIP_FAILURE_CODE:Ot,UNAVAILABLE:bt,USER_DENIED_MEDIA_ACCESS:Bt,WEBRTC_ERROR:Ht},Symbol.toStringTag,{value:"Module"})),x="incomingCall",G="declinedIncomingCall",$="failedIncomingCall",X="terminatedIncomingCall",k="connecting",m="connected",S="disconnected",v="newRTCSession",p="registered",J="unregistered",P="registrationFailed",Ye="newMessage",z="sipEvent",Q="availableSecondRemoteStream",j="notAvailableSecondRemoteStream",K="mustStopPresentation",b="shareState",Z="enterRoom",ee="useLicense",te="peerconnection:confirmed",ne="peerconnection:ontrack",y="channels",se="channels:notify",ie="ended:fromserver",re="main-cam-control",oe="admin-stop-main-cam",ae="admin-start-main-cam",ce="admin-stop-mic",_e="admin-start-mic",w="admin-force-sync-media-state",Ee="participant:added-to-list-moderators",le="participant:removed-from-list-moderators",he="participant:move-request-to-stream",de="participant:move-request-to-spectators",Te="participation:accepting-word-request",ue="participation:cancelling-word-request",Se="webcast:started",Ce="webcast:stopped",Ne="account:changed",ge="account:deleted",Ae="conference:participant-token-issued",f="ended",xe="sending",Ge="reinvite",$e="replaces",Xe="refer",Je="progress",ze="accepted",U="confirmed",L="peerconnection",A="failed",Qe="muted",je="unmuted",Re="newDTMF",Ie="newInfo",Ke="hold",Ze="unhold",et="update",tt="sdp",nt="icecandidate",st="getusermediafailed",it="peerconnection:createofferfailed",rt="peerconnection:createanswerfailed",ot="peerconnection:setlocaldescriptionfailed",at="peerconnection:setremotedescriptionfailed",ct="presentation:start",_t="presentation:started",Et="presentation:end",me="presentation:ended",H="presentation:failed",lt="SPECTATOR",ht=1e6,xt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:ze,ACCOUNT_CHANGED:Ne,ACCOUNT_DELETED:ge,ADMIN_FORCE_SYNC_MEDIA_STATE:w,ADMIN_START_MAIN_CAM:ae,ADMIN_START_MIC:_e,ADMIN_STOP_MAIN_CAM:oe,ADMIN_STOP_MIC:ce,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Q,CHANNELS:y,CHANNELS_NOTIFY:se,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:Ae,CONFIRMED:U,CONNECTED:m,CONNECTING:k,DECLINED_INCOMING_CALL:G,DISCONNECTED:S,ENDED:f,ENDED_FROM_SERVER:ie,ENTER_ROOM:Z,FAILED:A,FAILED_INCOMING_CALL:$,GET_USER_MEDIA_FAILED:st,HOLD:Ke,ICE_CANDIDATE:nt,INCOMING_CALL:x,MAIN_CAM_CONTROL:re,MUST_STOP_PRESENTATION_EVENT:K,MUTED:Qe,NEW_DTMF:Re,NEW_INFO:Ie,NEW_MESSAGE:Ye,NEW_RTC_SESSION:v,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:j,ONE_MEGABIT_IN_BITS:ht,PARTICIPANT_ADDED_TO_LIST_MODERATORS:Ee,PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS:de,PARTICIPANT_MOVE_REQUEST_TO_STREAM:he,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:le,PARTICIPATION_ACCEPTING_WORD_REQUEST:Te,PARTICIPATION_CANCELLING_WORD_REQUEST:ue,PEER_CONNECTION:L,PEER_CONNECTION_CONFIRMED:te,PEER_CONNECTION_CREATE_ANSWER_FAILED:rt,PEER_CONNECTION_CREATE_OFFER_FAILED:it,PEER_CONNECTION_ONTRACK:ne,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:ot,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:at,PRESENTATION_END:Et,PRESENTATION_ENDED:me,PRESENTATION_FAILED:H,PRESENTATION_START:ct,PRESENTATION_STARTED:_t,PROGRESS:Je,REFER:Xe,REGISTERED:p,REGISTRATION_FAILED:P,REINVITE:Ge,REPLACES:$e,SDP:tt,SENDING:xe,SHARE_STATE:b,SIP_EVENT:z,SPECTATOR:lt,TERMINATED_INCOMING_CALL:X,UNHOLD:Ze,UNMUTED:je,UNREGISTERED:J,UPDATE:et,USE_LICENSE:ee,WEBCAST_STARTED:Se,WEBCAST_STOPPED:Ce},Symbol.toStringTag,{value:"Module"})),dt=[x,G,X,$,Te,ue,he,se,Ae,Ne,ge,Se,Ce,Ee,le],pe=[k,m,S,v,p,J,P,Ye,z],Tt=[Q,j,K,b,Z,ee,te,ne,y,ie,re,ae,oe,ce,_e,w,de],Pe=[f,k,xe,Ge,$e,Xe,Je,ze,U,L,A,Qe,je,Re,Ie,Ke,Ze,et,tt,nt,st,it,rt,ot,at,ct,_t,Et,me,H],fe=[...pe,...dt],Oe=[...Pe,...Tt],Gt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:Oe,SESSION_JSSIP_EVENT_NAMES:Pe,SESSION_SYNTHETICS_EVENT_NAMES:Tt,UA_EVENT_NAMES:fe,UA_JSSIP_EVENT_NAMES:pe,UA_SYNTHETICS_EVENT_NAMES:dt},Symbol.toStringTag,{value:"Module"})),$t=r=>{const e=[];return r&&e.push(`X-Vinteo-Remote: ${r}`),e},Xt="content-type",Jt="x-webrtc-enter-room",O="application/vinteo.webrtc.sharedesktop",zt="application/vinteo.webrtc.roomname",Qt="application/vinteo.webrtc.channels",jt="application/vinteo.webrtc.mediastate",Kt="application/vinteo.webrtc.refusal",ye="application/vinteo.webrtc.maincam",Zt="application/vinteo.webrtc.mic",en="application/vinteo.webrtc.uselic",tn="X-WEBRTC-USE-LICENSE",nn="X-WEBRTC-PARTICIPANT-NAME",we="X-WEBRTC-INPUT-CHANNELS",Ue="X-WEBRTC-OUTPUT-CHANNELS",sn="X-WEBRTC-MAINCAM",rn="X-WEBRTC-MIC",Le="X-WEBRTC-SYNC",on="X-WEBRTC-MAINCAM-RESOLUTION",an="X-WEBRTC-MEDIA-STATE",cn="X-Vinteo-Media-Type",_n="X-Vinteo-MainCam-State",En="X-Vinteo-Mic-State",ln="application/vinteo.webrtc.partstate",hn="X-WEBRTC-PARTSTATE",dn="application/vinteo.webrtc.notify",Tn="X-VINTEO-NOTIFY",I="x-webrtc-share-state",un=`${I}: LETMESTARTPRESENTATION`,Sn=`${I}: STOPPRESENTATION`,ut="YOUCANRECEIVECONTENT",St="CONTENTEND",Ct="YOUMUSTSTOPSENDCONTENT",Cn=`${I}: ${Ct}`,Nn=`${I}: ${ut}`,gn=`${I}: ${St}`,An="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",Rn=`${An}: LETMESTARTMAINCAM`,De="sip-connector",M=V(De),In=()=>{V.enable(De)},mn=()=>{V.enable(`-${De}`)},pn=(r,e)=>{r.getVideoTracks().forEach(n=>{"contentHint"in n&&n.contentHint!==e&&(n.contentHint=e)})},D=(r,{videoMode:e,audioMode:t,contentHint:n}={})=>{if(!r||e==="recvonly"&&t==="recvonly")return;const s=t==="recvonly"?[]:r.getAudioTracks(),o=e==="recvonly"?[]:r.getVideoTracks(),a=[...s,...o],c=new MediaStream(a);return c.getTracks=()=>[...c.getAudioTracks(),...c.getVideoTracks()],n&&n!=="none"&&pn(c,n),c};var R=(r=>(r.PAUSE_MAIN_CAM="PAUSEMAINCAM",r.RESUME_MAIN_CAM="RESUMEMAINCAM",r.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",r.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",r.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",r))(R||{}),W=(r=>(r.ADMIN_STOP_MIC="ADMINSTOPMIC",r.ADMIN_START_MIC="ADMINSTARTMIC",r))(W||{}),q=(r=>(r.ADMIN_SYNC_FORCED="1",r.ADMIN_SYNC_NOT_FORCED="0",r))(q||{}),Nt=(r=>(r.AUDIO="AUDIO",r.VIDEO="VIDEO",r.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",r))(Nt||{});function Pn(r){return e=>`sip:${e}@${r}`}const fn=(r,e)=>()=>Math.floor(Math.random()*(e-r))+r,He=r=>r.trim().replaceAll(" ","_"),On=fn(1e5,99999999),Dn=r=>r.some(t=>{const{kind:n}=t;return n==="video"}),Mn="Error decline with 603",vn=1006,bn=r=>typeof r=="object"&&r!==null&&"code"in r&&r.code===vn,yn=r=>r.message===Mn,wn=(r,e)=>r.find(t=>t.track&&e.getTracks().includes(t.track)),gt=1,At=r=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==r,Un=At(gt),Ln=(r,e)=>{const t=r===void 0?void 0:Math.max(r,gt);if(t!==void 0&&Un(t,e))return t},Hn=At(),Wn=(r,e)=>{if(Hn(r,e))return r},Rt=async(r,e,t)=>{const n=r.getParameters();(n.encodings===void 0||n.encodings.length===0)&&(n.encodings=[{}]);const[s]=n.encodings,o=s.scaleResolutionDownBy,a=Ln(e.scaleResolutionDownBy,o);let c=!1;a!==void 0&&(n.encodings[0].scaleResolutionDownBy=a,c=!0);const _=s.maxBitrate,E=Wn(e.maxBitrate,_);return E!==void 0&&(n.encodings[0].maxBitrate=E,c=!0),c?(t&&t(n),r.setParameters(n).then(()=>({parameters:n,isChanged:c}))):{parameters:n,isChanged:c}},qn=async(r,e,t)=>{const n=wn(r,e);if(n)return Rt(n,{maxBitrate:t})},kn=486,Fn=487,B="local",We="remote",Bn=3,Vn=1,Yn=(r=new Error)=>{const{originator:e,cause:t}=r;return N.isCanceledError(r)?!0:typeof t=="string"?t===qe||t===Y||e===B&&(t===Be||t===Fe):!1},g="SipConnector",xn="channels",Gn="WebcastStarted",$n="WebcastStopped",Xn="accountChanged",Jn="accountDeleted",zn="addedToListModerators",Qn="removedFromListModerators",jn="ParticipationRequestAccepted",Kn="ParticipationRequestRejected",Zn="ParticipantMovedToWebcast",es="ConferenceParticipantTokenIssued";class ts{constructor({JsSIP:e}){i(this,"_isRegisterConfig",!1);i(this,"_connectionConfiguration",{});i(this,"_remoteStreams",{});i(this,"JsSIP");i(this,"_sessionEvents");i(this,"_uaEvents");i(this,"_cancelableConnect");i(this,"_cancelableConnectWithRepeatedCalls");i(this,"_cancelableSendPresentationWithRepeatedCalls");i(this,"_cancelableInitUa");i(this,"_cancelableDisconnect");i(this,"_cancelableSet");i(this,"_cancelableCall");i(this,"_cancelableAnswer");i(this,"_cancelableSendDTMF");i(this,"getSipServerUrl",e=>e);i(this,"promisePendingStartPresentation");i(this,"promisePendingStopPresentation");i(this,"ua");i(this,"session");i(this,"incomingSession");i(this,"_streamPresentationCurrent");i(this,"socket");i(this,"connect",async(e,t)=>(this._cancelRequests(),this._connectWithDuplicatedCalls(e,t)));i(this,"initUa",async e=>this._cancelableInitUa.request(e));i(this,"set",async e=>this._cancelableSet.request(e));i(this,"call",async e=>this._cancelableCall.request(e));i(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));i(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));i(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));i(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));i(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(k,void 0);try{await this.unregister()}catch(e){M("tryRegister",e)}return this.register()});i(this,"declineToIncomingCall",async({statusCode:e=Fn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const s=this.incomingSession,o=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(G,o),t(s.terminate({status_code:e}))}));i(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:kn}));i(this,"removeIncomingSession",()=>{delete this.incomingSession});i(this,"_connectWithDuplicatedCalls",async(e,{callLimit:t=Bn}={})=>{const n=async()=>this._cancelableConnect.request(e),s=o=>{var E;const c=!!((E=this.ua)!=null&&E.isConnected())&&this.hasEqualConnectionConfiguration(e),_=!!o&&!bn(o);return c||_};return this._cancelableConnectWithRepeatedCalls=be.repeatedCallsAsync({targetFunction:n,isComplete:s,callLimit:t,isRejectAsValid:!0,isCheckBeforeCall:!1,onAfterCancel:()=>{this._cancelableConnect.cancelRequest()}}),this._cancelableConnectWithRepeatedCalls.then(o=>{if(o instanceof this.JsSIP.UA)return o;throw o})});i(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===We){this.incomingSession=t;const n=this.remoteCallerData;t.on(A,s=>{this.removeIncomingSession(),s.originator===B?this._uaEvents.trigger(X,n):this._uaEvents.trigger($,n)}),this._uaEvents.trigger(x,n)}});i(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));i(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:s,remoteAddress:o,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:E,userAgent:l,displayName:h="",register:d=!1,extraHeaders:T=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!s)throw new Error("sipWebSocketServerURL is required");if(d&&!e)throw new Error("user is required for authorized connection");if(d&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:h,register:d,user:e,password:t};const{configuration:C,helpers:u}=this.createUaConfiguration({user:e,sipServerUrl:n,sipWebSocketServerURL:s,password:t,displayName:h,register:d,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:E,userAgent:l});return this.getSipServerUrl=u.getSipServerUrl,this.socket=u.socket,this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!d,this.ua=this._createUa({...C,remoteAddress:o,extraHeaders:T}),this._uaEvents.eachTriggers((F,It)=>{const Me=pe.find(mt=>mt===It);Me&&this.ua&&this.ua.on(Me,F)}),this.ua});i(this,"_createUa",({remoteAddress:e,extraHeaders:t=[],...n})=>{const s=new this.JsSIP.UA(n),a=[...e?$t(e):[],...t];return a.length>0&&s.registrator().setExtraHeaders(a),s});i(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const s=()=>{c(),e(n)},o=_=>{c(),t(_)},a=()=>{this.isRegisterConfig?(this.on(p,s),this.on(P,o)):this.on(m,s),this.on(S,o)},c=()=>{this.off(p,s),this.off(P,o),this.off(m,s),this.off(S,o)};a(),this.on(v,this.handleNewRTCSession),n.start()}));i(this,"_set",async({displayName:e,password:t})=>new Promise((n,s)=>{const{ua:o}=this;if(!o){s(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=o.set("display_name",He(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=o.set("password",t),this._connectionConfiguration.password=t);const _=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(_)}).catch(E=>{s(E)}):_?n(_):s(new Error("nothing changed"))}));i(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());i(this,"_disconnect",async()=>{this.off(v,this.handleNewRTCSession);const e=new Promise(t=>{this.once(S,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(S,void 0)):this._uaEvents.trigger(S,void 0),e});i(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:s,iceServers:o,videoMode:a,audioMode:c,degradationPreference:_,contentHint:E,offerToReceiveAudio:l=!0,offerToReceiveVideo:h=!0})=>new Promise((d,T)=>{const{ua:C}=this;if(!C){T(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:s}).then(d).catch(u=>{T(u)}),this.session=C.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:D(t,{videoMode:a,audioMode:c,contentHint:E}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,degradationPreference:_,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:l,offerToReceiveVideo:h}})}));i(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:s,videoMode:o,audioMode:a,degradationPreference:c,contentHint:_})=>new Promise((E,l)=>{if(!this.isAvailableIncomingCall){l(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:h}=this;if(!h){l(new Error("No session established"));return}this._sessionEvents.eachTriggers((T,C)=>{const u=Pe.find(F=>F===C);u&&h.on(u,T)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=h.remote_identity.uri.user,this._handleCall({ontrack:t}).then(E).catch(T=>{l(T)});const d=D(e,{videoMode:o,audioMode:a,contentHint:_});h.answer({extraHeaders:n,videoMode:o,audioMode:a,degradationPreference:c,mediaStream:d,pcConfig:{iceServers:s}})}));i(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const s=()=>{this.onSession(L,l),this.onSession(U,h)},o=()=>{this.offSession(L,l),this.offSession(U,h)},a=()=>{this.onSession(A,_),this.onSession(f,_)},c=()=>{this.offSession(A,_),this.offSession(f,_)},_=d=>{o(),c(),n(d)};let E;const l=({peerconnection:d})=>{E=d,E.ontrack=T=>{this._sessionEvents.trigger(ne,E),e&&e(T)}},h=()=>{E&&this._sessionEvents.trigger(te,E),o(),c(),t(E)};s(),a()}));i(this,"_restoreSession",()=>{this._cancelRequestsAndResetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});i(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:s}=this;if(!s){n(new Error("No session established"));return}this.onceSession(Re,({originator:o})=>{o===B&&t()}),s.sendDTMF(e,{duration:120,interToneGap:600})}));i(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;if(this._streamPresentationCurrent)try{await this.stopPresentation()}catch(t){M("error stop presentation: ",t)}if(this._restoreSession(),!e.isEnded())return e.terminateAsync()}});i(this,"_handleShareState",e=>{switch(e){case ut:{this._sessionEvents.trigger(Q,void 0);break}case St:{this._sessionEvents.trigger(j,void 0);break}case Ct:{this._sessionEvents.trigger(K,void 0);break}}});i(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(we),n=e.getHeader(Ue);if(t&&n){const s={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(y,s)}});i(this,"_handleNotify",e=>{switch(e.cmd){case xn:{const t=e;this._triggerChannelsNotify(t);break}case Gn:{const t=e;this._triggerWebcastStartedNotify(t);break}case $n:{const t=e;this._triggerWebcastStoppedNotify(t);break}case zn:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case Qn:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case jn:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case Kn:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case Zn:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case Xn:{this._triggerAccountChangedNotify();break}case Jn:{this._triggerAccountDeletedNotify();break}case es:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:M("unknown cmd",e.cmd)}});i(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(le,t)});i(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Ee,t)});i(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Se,n)});i(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Ce,n)});i(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Ne,void 0)});i(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(ge,void 0)});i(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const s={conference:e,participant:t,jwt:n};this._uaEvents.trigger(Ae,s)});i(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,s={inputChannels:t,outputChannels:n};this._uaEvents.trigger(se,s)});i(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Te,t)});i(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(ue,t)});i(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(he,t)});i(this,"_triggerEnterRoom",e=>{const t=e.getHeader(Jt),n=e.getHeader(nn);this._sessionEvents.trigger(Z,{room:t,participantName:n})});i(this,"_triggerShareState",e=>{const t=e.getHeader(I);this._sessionEvents.trigger(b,t)});i(this,"_maybeTriggerParticipantMoveRequestToSpectators",e=>{e.getHeader(hn)===lt&&this._sessionEvents.trigger(de,void 0)});i(this,"_triggerMainCamControl",e=>{const t=e.getHeader(sn),n=e.getHeader(Le),s=n===q.ADMIN_SYNC_FORCED;if(t===R.ADMIN_START_MAIN_CAM){this._sessionEvents.trigger(ae,{isSyncForced:s});return}if(t===R.ADMIN_STOP_MAIN_CAM){this._sessionEvents.trigger(oe,{isSyncForced:s});return}(t===R.RESUME_MAIN_CAM||t===R.PAUSE_MAIN_CAM)&&n&&this._sessionEvents.trigger(w,{isSyncForced:s});const o=e.getHeader(on);this._sessionEvents.trigger(re,{mainCam:t,resolutionMainCam:o})});i(this,"_triggerMicControl",e=>{const t=e.getHeader(rn),s=e.getHeader(Le)===q.ADMIN_SYNC_FORCED;t===W.ADMIN_START_MIC?this._sessionEvents.trigger(_e,{isSyncForced:s}):t===W.ADMIN_STOP_MIC&&this._sessionEvents.trigger(ce,{isSyncForced:s})});i(this,"_triggerUseLicense",e=>{const t=e.getHeader(tn);this._sessionEvents.trigger(ee,t)});i(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,s=n.getHeader(Xt);if(s)switch(s){case zt:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case dn:{this._maybeHandleNotify(n);break}case O:{this._triggerShareState(n);break}case ye:{this._triggerMainCamControl(n);break}case Zt:{this._triggerMicControl(n);break}case en:{this._triggerUseLicense(n);break}case ln:{this._maybeTriggerParticipantMoveRequestToSpectators(n);break}}});i(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});i(this,"_maybeHandleNotify",e=>{const t=e.getHeader(Tn);if(t){const n=JSON.parse(t);this._handleNotify(n)}});i(this,"_handleEnded",e=>{const{originator:t}=e;t===We&&this._sessionEvents.trigger(ie,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new ve(Oe),this._uaEvents=new ve(fe),this._cancelableConnect=new N.CancelableRequest(this._connect,{moduleName:g,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new N.CancelableRequest(this._initUa,{moduleName:g}),this._cancelableDisconnect=new N.CancelableRequest(this._disconnect,{moduleName:g}),this._cancelableSet=new N.CancelableRequest(this._set,{moduleName:g}),this._cancelableCall=new N.CancelableRequest(this._call,{moduleName:g}),this._cancelableAnswer=new N.CancelableRequest(this._answer,{moduleName:g}),this._cancelableSendDTMF=new N.CancelableRequest(this._sendDTMF,{moduleName:g}),this.onSession(b,this._handleShareState),this.onSession(Ie,this._handleNewInfo),this.on(z,this._handleSipEvent),this.onSession(A,this._handleEnded),this.onSession(f,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(p,e),this.ua.on(P,t),this.ua.register()):t(new Error("Config is not registered"))})}async unregister(){return new Promise((e,t)=>{this.isRegistered&&this.ua?(this.ua.on(J,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,n){if(!this.ua)throw new Error("is not connected");return new Promise((s,o)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{s()},failed:o}})}catch(a){o(a)}})}async ping(e,t){var s;if(!((s=this.ua)!=null&&s.configuration.uri))throw new Error("is not connected");const n=this.ua.configuration.uri;return this.sendOptions(n,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:n,sipWebSocketServerURL:s,remoteAddress:o,extraHeaders:a}){return new Promise((c,_)=>{const{configuration:E}=this.createUaConfiguration({sipWebSocketServerURL:s,displayName:t,userAgent:e,sipServerUrl:n}),l=this._createUa({...E,remoteAddress:o,extraHeaders:a}),h=()=>{const T=new Error("Telephony is not available");_(T)};l.once(S,h);const d=()=>{l.removeAllListeners(),l.once(S,c),l.stop()};l.once(m,d),l.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");const{contentHint:n}=t||{},s=D(e,{contentHint:n});return this.session.replaceMediaStream(s,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[Rn];return this.session.sendInfo(ye,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(yn(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentationWithDuplicatedCalls({session:e,stream:t,presentationOptions:n,options:s={callLimit:Vn}}){const o=async()=>this._sendPresentation(e,t,n),a=()=>!!this._streamPresentationCurrent;return this._cancelableSendPresentationWithRepeatedCalls=be.repeatedCallsAsync({targetFunction:o,isComplete:a,isRejectAsValid:!0,...s}),this._cancelableSendPresentationWithRepeatedCalls.then(c=>c)}hasEqualConnectionConfiguration(e){var s;const{configuration:t}=this.createUaConfiguration(e),n=(s=this.ua)==null?void 0:s.configuration;return(n==null?void 0:n.password)===t.password&&(n==null?void 0:n.register)===t.register&&(n==null?void 0:n.uri.toString())===t.uri&&(n==null?void 0:n.display_name)===t.display_name&&(n==null?void 0:n.user_agent)===t.user_agent&&(n==null?void 0:n.sockets)===t.sockets&&(n==null?void 0:n.session_timers)===t.session_timers&&(n==null?void 0:n.register_expires)===t.register_expires&&(n==null?void 0:n.connection_recovery_min_interval)===t.connection_recovery_min_interval&&(n==null?void 0:n.connection_recovery_max_interval)===t.connection_recovery_max_interval}createUaConfiguration({user:e,password:t,sipWebSocketServerURL:n,displayName:s="",sipServerUrl:o,register:a=!1,sessionTimers:c=!1,registerExpires:_=60*5,connectionRecoveryMinInterval:E=2,connectionRecoveryMaxInterval:l=6,userAgent:h}){if(a&&!t)throw new Error("password is required for authorized connection");const d=a&&e?e.trim():`${On()}`,T=Pn(o),C=T(d),u=new this.JsSIP.WebSocketInterface(n);return{configuration:{password:t,register:a,uri:C,display_name:He(s),user_agent:h,sdp_semantics:"unified-plan",sockets:[u],session_timers:c,register_expires:_,connection_recovery_min_interval:E,connection_recovery_max_interval:l},helpers:{socket:u,getSipServerUrl:T}}}async _sendPresentation(e,t,{maxBitrate:n=ht,degradationPreference:s="maintain-resolution",isNeedReinvite:o=!0,isP2P:a=!1,contentHint:c="detail"}){const _=D(t,{contentHint:c});this._streamPresentationCurrent=_;const E=a?[Nn]:[un],l=e.sendInfo(O,void 0,{extraHeaders:E}).then(async()=>e.startPresentation(_,o,s)).then(async()=>{const{connection:h}=this;if(!h||n===void 0)return;const d=h.getSenders();await qn(d,t,n)}).then(()=>t).catch(h=>{throw this._removeStreamPresentationCurrent(),this._sessionEvents.trigger(H,h),h});return this.promisePendingStartPresentation=l,l.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t,isP2P:n,maxBitrate:s,degradationPreference:o,contentHint:a}={},c){const _=this.establishedSession;if(!_)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return n&&await this.sendMustStopPresentation(_),this._sendPresentationWithDuplicatedCalls({session:_,stream:e,presentationOptions:{isNeedReinvite:t,isP2P:n,maxBitrate:s,degradationPreference:o,contentHint:a},options:c})}async sendMustStopPresentation(e){await e.sendInfo(O,void 0,{extraHeaders:[Cn]})}async stopPresentation({isP2P:e=!1}={}){this._cancelSendPresentationWithRepeatedCalls();const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const s=e?[gn]:[Sn],o=this.establishedSession;return o&&t&&(n=n.then(async()=>o.sendInfo(O,void 0,{extraHeaders:s})).then(async()=>o.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(H,a),a})),!o&&t&&this._sessionEvents.trigger(me,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t,maxBitrate:n,degradationPreference:s,contentHint:o}={}){const a=this.establishedSession;if(!a)throw new Error("No session established");if(!this._streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this._sendPresentation(a,e,{isP2P:t,maxBitrate:n,degradationPreference:s,contentHint:o,isNeedReinvite:!1})}_removeStreamPresentationCurrent(){delete this._streamPresentationCurrent}_resetPresentation(){this._removeStreamPresentationCurrent(),this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}_cancelRequestsAndResetPresentation(){this._cancelSendPresentationWithRepeatedCalls(),this._resetPresentation()}on(e,t){return this._uaEvents.on(e,t)}once(e,t){return this._uaEvents.once(e,t)}onceRace(e,t){return this._uaEvents.onceRace(e,t)}async wait(e){return this._uaEvents.wait(e)}off(e,t){this._uaEvents.off(e,t)}onSession(e,t){return this._sessionEvents.on(e,t)}onceSession(e,t){return this._sessionEvents.once(e,t)}onceRaceSession(e,t){return this._sessionEvents.onceRace(e,t)}async waitSession(e){return this._sessionEvents.wait(e)}offSession(e,t){this._sessionEvents.off(e,t)}isConfigured(){return!!this.ua}getConnectionConfiguration(){return{...this._connectionConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:n})=>n);return Dn(t)?this._generateStreams(t):this._generateAudioStreams(t)}get connection(){var t;return(t=this.session)==null?void 0:t.connection}get remoteCallerData(){var e,t,n,s,o,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(s=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:s.uri.host,incomingNumber:(a=(o=this.incomingSession)==null?void 0:o.remote_identity)==null?void 0:a.uri.user,session:this.incomingSession}}get requested(){return this._cancelableConnect.requested||this._cancelableInitUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){var e;return(e=this.session)!=null&&e.isEstablished()?this.session:void 0}get isRegistered(){return!!this.ua&&this.ua.isRegistered()}get isRegisterConfig(){return!!this.ua&&this._isRegisterConfig}get isCallActive(){return!!(this.ua&&this.session)}get isAvailableIncomingCall(){return!!this.incomingSession}_generateStream(e,t){const{id:n}=e,s=this._remoteStreams[n]||new MediaStream;return t&&s.addTrack(t),s.addTrack(e),this._remoteStreams[n]=s,s}_generateAudioStream(e){const{id:t}=e,n=this._remoteStreams[t]||new MediaStream;return n.addTrack(e),this._remoteStreams[t]=n,n}_generateStreams(e){const t=[];return e.forEach((n,s)=>{if(n.kind==="audio")return;const o=n,a=e[s-1];let c;a&&a.kind==="audio"&&(c=a);const _=this._generateStream(o,c);t.push(_)}),t}_generateAudioStreams(e){return e.map(n=>this._generateAudioStream(n))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectWithRepeatedCalls()}_cancelConnectWithRepeatedCalls(){var e;(e=this._cancelableConnectWithRepeatedCalls)==null||e.cancel()}_cancelSendPresentationWithRepeatedCalls(){var e;(e=this._cancelableSendPresentationWithRepeatedCalls)==null||e.cancel()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(y)}async waitSyncMediaState(){return this.waitSession(w)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${we}: ${e}`,s=`${Ue}: ${t}`,o=[n,s];return this.session.sendInfo(Qt,void 0,{extraHeaders:o})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const s=`${an}: currentstate`,o=`${_n}: ${Number(e)}`,a=`${En}: ${Number(t)}`,c=[s,o,a];return this.session.sendInfo(jt,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${cn}: ${e==="mic"?0:1}`];return this.session.sendInfo(Kt,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}}exports.BAD_MEDIA_DESCRIPTION=Ve;exports.EEventsMainCAM=R;exports.EEventsMic=W;exports.EEventsSyncMediaState=q;exports.EUseLicense=Nt;exports.NOT_FOUND=ke;exports.REJECTED=Y;exports.SESSION_EVENT_NAMES=Oe;exports.SipConnector=ts;exports.UA_EVENT_NAMES=fe;exports.causes=Yt;exports.constants=xt;exports.disableDebug=mn;exports.enableDebug=In;exports.eventNames=Gt;exports.hasCanceledCallError=Yn;exports.logger=M;exports.setEncodingsToSender=Rt;