sip-connector 14.0.1-0 → 14.1.0-alpha.1
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/ApiManager/@ApiManager.d.ts +58 -0
- package/dist/ApiManager/constants.d.ts +71 -0
- package/dist/ApiManager/eventNames.d.ts +33 -0
- package/dist/ApiManager/index.d.ts +2 -0
- package/dist/ApiManager/types.d.ts +99 -0
- package/dist/CallManager/@CallManager.d.ts +26 -0
- package/dist/CallManager/AbstractCallStrategy.d.ts +47 -0
- package/dist/CallManager/MCUCallStrategy.d.ts +30 -0
- package/dist/CallManager/RemoteStreamsManager.d.ts +8 -0
- package/dist/CallManager/causes.d.ts +12 -0
- package/dist/CallManager/eventNames.d.ts +45 -0
- package/dist/CallManager/hasCanceledCallError.d.ts +2 -0
- package/dist/CallManager/index.d.ts +5 -0
- package/dist/CallManager/types.d.ts +59 -0
- package/dist/ConnectionManager/@ConnectionManager.d.ts +47 -0
- package/dist/ConnectionManager/ConfigurationManager.d.ts +60 -0
- package/dist/ConnectionManager/ConnectionFlow.d.ts +83 -0
- package/dist/ConnectionManager/ConnectionStateMachine.d.ts +61 -0
- package/dist/ConnectionManager/RegistrationManager.d.ts +17 -0
- package/dist/ConnectionManager/SipOperations.d.ts +32 -0
- package/dist/ConnectionManager/UAFactory.d.ts +50 -0
- package/dist/ConnectionManager/eventNames.d.ts +16 -0
- package/dist/ConnectionManager/index.d.ts +3 -0
- package/dist/IncomingCallManager/@IncomingCallManager.d.ts +36 -0
- package/dist/IncomingCallManager/eventNames.d.ts +13 -0
- package/dist/IncomingCallManager/index.d.ts +2 -0
- package/dist/PresentationManager/@PresentationManager.d.ts +47 -0
- package/dist/PresentationManager/constants.d.ts +1 -0
- package/dist/PresentationManager/eventNames.d.ts +11 -0
- package/dist/PresentationManager/index.d.ts +1 -0
- package/dist/PresentationManager/types.d.ts +2 -0
- package/dist/SipConnector-CK3GgjXE.js +2492 -0
- package/dist/SipConnector-CwI8aFEA.cjs +1 -0
- package/dist/SipConnector.d.ts +107 -0
- package/dist/{src/SipConnectorFacade → SipConnectorFacade}/SipConnectorFacade.d.ts +34 -25
- package/dist/{src/__fixtures__ → __fixtures__}/BaseSession.mock.d.ts +9 -9
- package/dist/{src/__fixtures__ → __fixtures__}/RTCSessionMock.d.ts +25 -20
- package/dist/{src/__fixtures__ → __fixtures__}/UA.mock.d.ts +23 -25
- package/dist/{src/__fixtures__ → __fixtures__}/index.d.ts +4 -4
- package/dist/{src/__fixtures__ → __fixtures__}/jssip.mock.d.ts +3 -3
- package/dist/doMock.cjs +1 -1
- package/dist/{src/doMock.d.ts → doMock.d.ts} +1 -0
- package/dist/doMock.js +248 -217
- package/dist/index.cjs +1 -1
- package/dist/{src/index.d.ts → index.d.ts} +3 -1
- package/dist/index.js +529 -436
- package/dist/{src/tools → tools}/__fixtures__/connectToServer.d.ts +2 -2
- package/dist/{src/tools → tools}/index.d.ts +2 -2
- package/dist/{src/tools/sendDTMFAccumulated.d.ts → tools/sendDtmfFAccumulated.d.ts} +2 -2
- package/package.json +27 -33
- package/dist/SipConnector-CJN8qKAC.js +0 -1316
- package/dist/SipConnector-DO0YvSq6.cjs +0 -1
- package/dist/src/SipConnector.d.ts +0 -301
- package/dist/{src/SipConnectorFacade → SipConnectorFacade}/index.d.ts +0 -0
- package/dist/{src/__fixtures__ → __fixtures__}/RTCPeerConnectionMock.d.ts +1 -1
- /package/dist/{src/__fixtures__ → __fixtures__}/RTCRtpSenderMock.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/Registrator.mock.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/Request.mock.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/WebSocketInterface.mock.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/accountNotify.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/channels.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/channelsNotify.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/conferenceParticipantTokenIssuedNotify.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/delayPromise.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/enterRoom.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/mediaState.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/participantMoveRequests.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/participantNotify.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/remoteCallerData.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/utils.d.ts +0 -0
- /package/dist/{src/__fixtures__ → __fixtures__}/webcastNotify.d.ts +0 -0
- /package/dist/{src/causes.d.ts → causes.d.ts} +0 -0
- /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/{src/eventNames.d.ts → eventNames.d.ts} +0 -0
- /package/dist/{src/getExtraHeadersRemoteAddress.d.ts → getExtraHeadersRemoteAddress.d.ts} +0 -0
- /package/dist/{src/headers.d.ts → headers.d.ts} +0 -0
- /package/dist/{src/logger.d.ts → logger.d.ts} +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureDegradationPreference.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureEncodings.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureMaxBitrate.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/index.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +0 -0
- /package/dist/{src/setParametersToSender → setParametersToSender}/setParametersToSender.d.ts +0 -0
- /package/dist/{src/tools → tools}/__fixtures__/call.d.ts +0 -0
- /package/dist/{src/tools → tools}/__fixtures__/hasValidUri.d.ts +0 -0
- /package/dist/{src/tools → tools}/__fixtures__/permissions.d.ts +0 -0
- /package/dist/{src/tools → tools}/__fixtures__/processRequest.d.ts +0 -0
- /package/dist/{src/tools → tools}/__tests-utils__/parseObject.d.ts +0 -0
- /package/dist/{src/tools → tools}/__tests-utils__/resolveParseArray.d.ts +0 -0
- /package/dist/{src/tools → tools}/error/getLinkError.d.ts +0 -0
- /package/dist/{src/tools → tools}/error/getTypeFromError.d.ts +0 -0
- /package/dist/{src/tools → tools}/error/getValuesFromError.d.ts +0 -0
- /package/dist/{src/tools → tools}/error/index.d.ts +0 -0
- /package/dist/{src/tools → tools}/error/stringifyMessage.d.ts +0 -0
- /package/dist/{src/tools → tools}/generateSimulcastEncodings.d.ts +0 -0
- /package/dist/{src/tools → tools}/getExtraHeaders.d.ts +0 -0
- /package/dist/{src/tools → tools}/getUserAgent.d.ts +0 -0
- /package/dist/{src/tools → tools}/hasPurgatory.d.ts +0 -0
- /package/dist/{src/tools → tools}/prepareMediaStream.d.ts +0 -0
- /package/dist/{src/tools → tools}/resolveUpdateTransceiver.d.ts +0 -0
- /package/dist/{src/tools → tools}/setVideoTrackContentHints.d.ts +0 -0
- /package/dist/{src/tools → tools}/syncMediaState/index.d.ts +0 -0
- /package/dist/{src/tools → tools}/syncMediaState/resolveOnStartMainCam.d.ts +0 -0
- /package/dist/{src/tools → tools}/syncMediaState/resolveOnStartMic.d.ts +0 -0
- /package/dist/{src/tools → tools}/syncMediaState/resolveOnStopMainCam.d.ts +0 -0
- /package/dist/{src/tools → tools}/syncMediaState/resolveOnStopMic.d.ts +0 -0
- /package/dist/{src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{src/utils → utils}/errors.d.ts +0 -0
- /package/dist/{src/utils → utils}/findSenderByStream.d.ts +0 -0
- /package/dist/{src/utils → utils}/findVideoSender.d.ts +0 -0
- /package/dist/{src/utils → utils}/findVideoTrack.d.ts +0 -0
- /package/dist/{src/utils → utils}/getCodecFromSender.d.ts +0 -0
- /package/dist/{src/utils → utils}/replaceForbiddenSymbolsWithUnderscore.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/balance.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/getMaxBitrateByWidth.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/getMaxBitrateByWidthAndCodec.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/hasAv1Codec.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/hasIncludesString.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/index.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/processSender.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/scaleBitrate.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/scaleBitrateByCodec.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/scaleResolutionAndBitrate.d.ts +0 -0
- /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/setEncodingsToSender.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const v=require("events-constructor");require("@krivega/cancelable-promise");const W=require("debug"),k=require("repeated-calls"),Y=require("xstate"),_t="Connection Error",ut="Request Timeout",It="SIP Failure Code",Rt="Internal Error",Mt="Busy",x="Rejected",Ot="Redirected",Pt="Unavailable",Q="Not Found",pt="Address Incomplete",mt="Incompatible SDP",ft="Missing SDP",Dt="Authentication Error",vt="Terminated",yt="WebRTC Error",Ut="Canceled",bt="No Answer",wt="Expires",Lt="No ACK",Ft="Dialog Error",$t="User Denied Media Access",z="Bad Media Description",Wt="RTP Timeout",kt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:pt,AUTHENTICATION_ERROR:Dt,BAD_MEDIA_DESCRIPTION:z,BUSY:Mt,BYE:vt,CANCELED:Ut,CONNECTION_ERROR:_t,DIALOG_ERROR:Ft,EXPIRES:wt,INCOMPATIBLE_SDP:mt,INTERNAL_ERROR:Rt,MISSING_SDP:ft,NOT_FOUND:Q,NO_ACK:Lt,NO_ANSWER:bt,REDIRECTED:Ot,REJECTED:x,REQUEST_TIMEOUT:ut,RTP_TIMEOUT:Wt,SIP_FAILURE_CODE:It,UNAVAILABLE:Pt,USER_DENIED_MEDIA_ACCESS:$t,WEBRTC_ERROR:yt},Symbol.toStringTag,{value:"Module"})),J="incomingCall",X="declinedIncomingCall",j="failedIncomingCall",K="terminatedIncomingCall",V="connecting",Z="connected",ee="disconnected",te="newRTCSession",ne="registered",se="unregistered",ie="registrationFailed",re="newMessage",ae="sipEvent",oe="availableSecondRemoteStream",ce="notAvailableSecondRemoteStream",Te="mustStopPresentation",Ee="shareState",ge="enterRoom",Se="useLicense",de="peerconnection:confirmed",le="peerconnection:ontrack",he="channels",Ce="channels:notify",Ne="ended:fromserver",Ae="main-cam-control",_e="admin-stop-main-cam",ue="admin-start-main-cam",Ie="admin-stop-mic",Re="admin-start-mic",Me="admin-force-sync-media-state",Oe="participant:added-to-list-moderators",Pe="participant:removed-from-list-moderators",pe="participant:move-request-to-stream",me="participant:move-request-to-spectators",fe="participant:move-request-to-participants",De="participation:accepting-word-request",ve="participation:cancelling-word-request",ye="webcast:started",Ue="webcast:stopped",be="account:changed",we="account:deleted",Le="conference:participant-token-issued",Fe="ended",$e="sending",We="reinvite",ke="replaces",Ve="refer",Ge="progress",He="accepted",Be="confirmed",qe="peerconnection",Ye="failed",xe="muted",Qe="unmuted",ze="newDTMF",Je="newInfo",Xe="hold",je="unhold",Ke="update",Ze="sdp",et="icecandidate",tt="getusermediafailed",nt="peerconnection:createofferfailed",st="peerconnection:createanswerfailed",it="peerconnection:setlocaldescriptionfailed",rt="peerconnection:setremotedescriptionfailed",at="presentation:start",ot="presentation:started",ct="presentation:end",Tt="presentation:ended",Et="presentation:failed",Vt="SPECTATOR",Gt="PARTICIPANT",Ht=1e6;var G=(n=>(n.LOCAL="local",n.REMOTE="remote",n.SYSTEM="system",n))(G||{});const Bt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:He,ACCOUNT_CHANGED:be,ACCOUNT_DELETED:we,ADMIN_FORCE_SYNC_MEDIA_STATE:Me,ADMIN_START_MAIN_CAM:ue,ADMIN_START_MIC:Re,ADMIN_STOP_MAIN_CAM:_e,ADMIN_STOP_MIC:Ie,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:oe,CHANNELS:he,CHANNELS_NOTIFY:Ce,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:Le,CONFIRMED:Be,CONNECTED:Z,CONNECTING:V,DECLINED_INCOMING_CALL:X,DISCONNECTED:ee,ENDED:Fe,ENDED_FROM_SERVER:Ne,ENTER_ROOM:ge,FAILED:Ye,FAILED_INCOMING_CALL:j,GET_USER_MEDIA_FAILED:tt,HOLD:Xe,ICE_CANDIDATE:et,INCOMING_CALL:J,MAIN_CAM_CONTROL:Ae,MUST_STOP_PRESENTATION_EVENT:Te,MUTED:xe,NEW_DTMF:ze,NEW_INFO:Je,NEW_MESSAGE:re,NEW_RTC_SESSION:te,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:ce,ONE_MEGABIT_IN_BITS:Ht,Originator:G,PARTICIPANT:Gt,PARTICIPANT_ADDED_TO_LIST_MODERATORS:Oe,PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS:fe,PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS:me,PARTICIPANT_MOVE_REQUEST_TO_STREAM:pe,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:Pe,PARTICIPATION_ACCEPTING_WORD_REQUEST:De,PARTICIPATION_CANCELLING_WORD_REQUEST:ve,PEER_CONNECTION:qe,PEER_CONNECTION_CONFIRMED:de,PEER_CONNECTION_CREATE_ANSWER_FAILED:st,PEER_CONNECTION_CREATE_OFFER_FAILED:nt,PEER_CONNECTION_ONTRACK:le,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:it,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:rt,PRESENTATION_END:ct,PRESENTATION_ENDED:Tt,PRESENTATION_FAILED:Et,PRESENTATION_START:at,PRESENTATION_STARTED:ot,PROGRESS:Ge,REFER:Ve,REGISTERED:ne,REGISTRATION_FAILED:ie,REINVITE:We,REPLACES:ke,SDP:Ze,SENDING:$e,SHARE_STATE:Ee,SIP_EVENT:ae,SPECTATOR:Vt,TERMINATED_INCOMING_CALL:K,UNHOLD:je,UNMUTED:Qe,UNREGISTERED:se,UPDATE:Ke,USE_LICENSE:Se,WEBCAST_STARTED:ye,WEBCAST_STOPPED:Ue},Symbol.toStringTag,{value:"Module"})),gt=[J,X,K,j,De,ve,pe,Ce,Le,be,we,ye,Ue,Oe,Pe],H=[V,Z,ee,te,ne,se,ie,re,ae],St=[oe,ce,Te,Ee,ge,Se,de,le,he,Ne,Ae,ue,_e,Ie,Re,Me,me,fe],dt=[Fe,V,$e,We,ke,Ve,Ge,He,Be,qe,Ye,xe,Qe,ze,Je,Xe,je,Ke,Ze,et,tt,nt,st,it,rt,at,ot,ct,Tt,Et],qt=[...H,...gt],lt=[...dt,...St],Yt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:lt,SESSION_JSSIP_EVENT_NAMES:dt,SESSION_SYNTHETICS_EVENT_NAMES:St,UA_EVENT_NAMES:qt,UA_JSSIP_EVENT_NAMES:H,UA_SYNTHETICS_EVENT_NAMES:gt},Symbol.toStringTag,{value:"Module"})),B="sip-connector",O=W(B),xt=()=>{W.enable(B)},Qt=()=>{W.enable(`-${B}`)};var N=(n=>(n.PEER_CONNECTION="peerconnection",n.CONNECTING="connecting",n.SENDING="sending",n.PROGRESS="progress",n.ACCEPTED="accepted",n.CONFIRMED="confirmed",n.ENDED="ended",n.FAILED="failed",n.NEW_DTMF="newDTMF",n.NEW_INFO="newInfo",n.HOLD="hold",n.UNHOLD="unhold",n.MUTED="muted",n.UNMUTED="unmuted",n.REINVITE="reinvite",n.UPDATE="update",n.REFER="refer",n.REPLACES="replaces",n.SDP="sdp",n.ICE_CANDIDATE="icecandidate",n.GET_USER_MEDIA_FAILED="getusermediafailed",n.PEER_CONNECTION_CREATE_OFFER_FAILED="peerconnection:createofferfailed",n.PEER_CONNECTION_CREATE_ANSWER_FAILED="peerconnection:createanswerfailed",n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED="peerconnection:setlocaldescriptionfailed",n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED="peerconnection:setremotedescriptionfailed",n.START_PRESENTATION="presentation:start",n.STARTED_PRESENTATION="presentation:started",n.END_PRESENTATION="presentation:end",n.ENDED_PRESENTATION="presentation:ended",n.FAILED_PRESENTATION="presentation:failed",n.PEER_CONNECTION_CONFIRMED="peerconnection:confirmed",n.PEER_CONNECTION_ONTRACK="peerconnection:ontrack",n.ENDED_FROM_SERVER="ended:fromserver",n))(N||{}),D=(n=>(n.LOCAL="local",n.REMOTE="remote",n.SYSTEM="system",n))(D||{});const ht=["peerconnection","connecting","sending","progress","accepted","confirmed","ended","failed","newInfo","newDTMF","presentation:start","presentation:started","presentation:end","presentation:ended","presentation:failed","reinvite","update","refer","replaces","sdp","icecandidate","getusermediafailed","peerconnection:createofferfailed","peerconnection:createanswerfailed","peerconnection:setlocaldescriptionfailed","peerconnection:setremotedescriptionfailed"],zt=["peerconnection:confirmed","peerconnection:ontrack","ended:fromserver"],Jt=[...ht,...zt];function Xt(n){return e=>`sip:${e}@${n}`}const jt=(n,e)=>()=>Math.floor(Math.random()*(e-n))+n,Ct=n=>n.trim().replaceAll(" ","_"),Kt=jt(1e5,99999999),Zt=n=>n.some(t=>{const{kind:s}=t;return s==="video"}),en=(n,e)=>{n.getVideoTracks().forEach(s=>{"contentHint"in s&&s.contentHint!==e&&(s.contentHint=e)})},y=(n,{directionVideo:e,directionAudio:t,contentHint:s}={})=>{if(!n||e==="recvonly"&&t==="recvonly")return;const i=t==="recvonly"?[]:n.getAudioTracks(),r=e==="recvonly"?[]:n.getVideoTracks(),a=[...i,...r],o=new MediaStream(a);return o.getTracks=()=>[...o.getAudioTracks(),...o.getVideoTracks()],s&&s!=="none"&&en(o,s),o};class tn{isPendingCall=!1;isPendingAnswer=!1;rtcSession;remoteStreams={};events;callConfiguration={};constructor(e){this.events=e}}var q=(n=>(n.BYE="Terminated",n.WEBRTC_ERROR="WebRTC Error",n.CANCELED="Canceled",n.REQUEST_TIMEOUT="Request Timeout",n.REJECTED="Rejected",n.REDIRECTED="Redirected",n.UNAVAILABLE="Unavailable",n.NOT_FOUND="Not Found",n.ADDRESS_INCOMPLETE="Address Incomplete",n.INCOMPATIBLE_SDP="Incompatible SDP",n))(q||{});class nn{remoteStreams={};reset(){this.remoteStreams={}}generateStream(e,t){const{id:s}=e,i=this.remoteStreams[s]??new MediaStream;return t&&i.addTrack(t),i.addTrack(e),this.remoteStreams[s]=i,i}generateAudioStream(e){const{id:t}=e,s=this.remoteStreams[t]??new MediaStream;return s.addTrack(e),this.remoteStreams[t]=s,s}generateStreams(e){const t=[];return e.forEach((s,i)=>{if(s.kind==="audio")return;const r=s,a=e[i-1];let o;a?.kind==="audio"&&(o=a);const c=this.generateStream(r,o);t.push(c)}),t}generateAudioStreams(e){return e.map(t=>this.generateAudioStream(t))}}class sn extends tn{remoteStreamsManager=new nn;disposers=new Set;constructor(e){super(e),e.on(N.FAILED,this.handleEnded),e.on(N.ENDED,this.handleEnded)}get requested(){return this.isPendingCall||this.isPendingAnswer}get connection(){return this.rtcSession?.connection}get isCallActive(){return this.rtcSession?.isEstablished()===!0}get establishedRTCSession(){return this.rtcSession?.isEstablished()===!0?this.rtcSession:void 0}startCall=async(e,t,{number:s,mediaStream:i,extraHeaders:r=[],ontrack:a,iceServers:o,directionVideo:c,directionAudio:T,contentHint:S,offerToReceiveAudio:h=!0,offerToReceiveVideo:d=!0,sendEncodings:l,onAddedTransceiver:I})=>(this.isPendingCall=!0,new Promise((C,P)=>{this.callConfiguration.number=s,this.callConfiguration.answer=!1,this.handleCall({ontrack:a}).then(C).catch(b=>{P(b)}),this.rtcSession=e.call(t(s),{extraHeaders:r,mediaStream:y(i,{directionVideo:c,directionAudio:T,contentHint:S}),directionVideo:c,directionAudio:T,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:h,offerToReceiveVideo:d},sendEncodings:l,onAddedTransceiver:I}),this.subscribeToSessionEvents(this.rtcSession)}).finally(()=>{this.isPendingCall=!1}));async endCall(){const{rtcSession:e}=this;if(e&&!e.isEnded())return e.terminateAsync({cause:q.CANCELED}).finally(()=>{this.reset()});this.reset()}answerToIncomingCall=async(e,{mediaStream:t,ontrack:s,extraHeaders:i=[],iceServers:r,directionVideo:a,directionAudio:o,offerToReceiveAudio:c,offerToReceiveVideo:T,contentHint:S,sendEncodings:h,onAddedTransceiver:d})=>(this.isPendingAnswer=!0,new Promise((l,I)=>{try{const C=e();this.rtcSession=C,this.subscribeToSessionEvents(C),this.callConfiguration.answer=!0,this.callConfiguration.number=C.remote_identity.uri.user,this.handleCall({ontrack:s}).then(l).catch(b=>{I(b)});const P=y(t,{directionVideo:a,directionAudio:o,contentHint:S});C.answer({extraHeaders:i,directionVideo:a,directionAudio:o,mediaStream:P,pcConfig:{iceServers:r},rtcOfferConstraints:{offerToReceiveAudio:c,offerToReceiveVideo:T},sendEncodings:h,onAddedTransceiver:d})}catch(C){I(C)}}).finally(()=>{this.isPendingAnswer=!1}));getEstablishedRTCSession(){return this.rtcSession?.isEstablished()===!0?this.rtcSession:void 0}getCallConfiguration(){return{...this.callConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:s})=>s);return Zt(t)?this.remoteStreamsManager.generateStreams(t):this.remoteStreamsManager.generateAudioStreams(t)}async replaceMediaStream(e,t){if(!this.rtcSession)throw new Error("No rtcSession established");const{contentHint:s}=t??{},i=y(e,{contentHint:s});if(i===void 0)throw new Error("No preparedMediaStream");return this.rtcSession.replaceMediaStream(i,t)}handleCall=async({ontrack:e})=>new Promise((t,s)=>{const i=()=>{this.events.on(N.PEER_CONNECTION,S),this.events.on(N.CONFIRMED,h)},r=()=>{this.events.off(N.PEER_CONNECTION,S),this.events.off(N.CONFIRMED,h)},a=()=>{this.events.on(N.FAILED,c),this.events.on(N.ENDED,c)},o=()=>{this.events.off(N.FAILED,c),this.events.off(N.ENDED,c)},c=d=>{r(),o(),s(d)};let T;const S=({peerconnection:d})=>{T=d;const l=I=>{this.events.trigger(N.PEER_CONNECTION_ONTRACK,d),e&&e(I)};d.addEventListener("track",l),this.disposers.add(()=>{d.removeEventListener("track",l)})},h=()=>{T!==void 0&&this.events.trigger(N.PEER_CONNECTION_CONFIRMED,T),r(),o(),t(T)};i(),a()});subscribeToSessionEvents(e){this.events.eachTriggers((t,s)=>{const i=ht.find(r=>r===s);i&&(e.on(i,t),this.disposers.add(()=>{e.off(i,t)}))})}unsubscribeFromSessionEvents(){this.disposers.forEach(e=>{e()}),this.disposers.clear()}handleEnded=e=>{const{originator:t}=e;t===D.REMOTE&&this.events.trigger(N.ENDED_FROM_SERVER,e),this.reset()};reset=()=>{delete this.rtcSession,this.remoteStreamsManager.reset(),this.unsubscribeFromSessionEvents(),this.callConfiguration.number=void 0,this.callConfiguration.answer=!1}}class rn{events;strategy;constructor(e){this.events=new v(Jt),this.strategy=e??new sn(this.events)}get requested(){return this.strategy.requested}get connection(){return this.strategy.connection}get establishedRTCSession(){return this.strategy.establishedRTCSession}get isCallActive(){return this.strategy.isCallActive}on(e,t){return this.events.on(e,t)}once(e,t){return this.events.once(e,t)}onceRace(e,t){return this.events.onceRace(e,t)}async wait(e){return this.events.wait(e)}off(e,t){this.events.off(e,t)}setStrategy(e){this.strategy=e}startCall=async(...e)=>this.strategy.startCall(...e);endCall=async()=>this.strategy.endCall();answerToIncomingCall=async(...e)=>this.strategy.answerToIncomingCall(...e);getEstablishedRTCSession=()=>this.strategy.getEstablishedRTCSession();getCallConfiguration=()=>this.strategy.getCallConfiguration();getRemoteStreams=()=>this.strategy.getRemoteStreams();replaceMediaStream=async(...e)=>this.strategy.replaceMediaStream(...e)}var R=(n=>(n.START_PRESENTATION="presentation:start",n.STARTED_PRESENTATION="presentation:started",n.END_PRESENTATION="presentation:end",n.ENDED_PRESENTATION="presentation:ended",n.FAILED_PRESENTATION="presentation:failed",n))(R||{});const an=["presentation:start","presentation:started","presentation:end","presentation:ended","presentation:failed"],on=1,cn=n=>k.hasCanceledError(n);class Tn{promisePendingStartPresentation;promisePendingStopPresentation;streamPresentationCurrent;events;cancelableSendPresentationWithRepeatedCalls;callManager;constructor({callManager:e}){this.callManager=e,this.events=new v(an),this.subscribe()}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async startPresentation(e,t,{isNeedReinvite:s,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:o}={},c){const T=this.getRtcSessionProtected();if(this.streamPresentationCurrent)throw new Error("Presentation is already started");return this.sendPresentationWithDuplicatedCalls(e,{rtcSession:T,stream:t,presentationOptions:{isNeedReinvite:s,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:o},options:c})}async stopPresentation(e){this.cancelSendPresentationWithRepeatedCalls();const t=this.streamPresentationCurrent;let s=this.promisePendingStartPresentation??Promise.resolve(void 0);const i=this.callManager.getEstablishedRTCSession();return i&&t?s=e().then(async()=>i.stopPresentation(t)).catch(r=>{throw this.events.trigger(R.FAILED_PRESENTATION,r),r}):t&&this.events.trigger(R.ENDED_PRESENTATION,t),this.promisePendingStopPresentation=s,s.finally(()=>{this.resetPresentation()})}async updatePresentation(e,t,{contentHint:s,sendEncodings:i,onAddedTransceiver:r}={}){const a=this.getRtcSessionProtected();if(!this.streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this.sendPresentation(e,a,t,{contentHint:s,isNeedReinvite:!1,sendEncodings:i,onAddedTransceiver:r})}cancelSendPresentationWithRepeatedCalls(){this.cancelableSendPresentationWithRepeatedCalls?.cancel()}on(e,t){return this.events.on(e,t)}once(e,t){return this.events.once(e,t)}onceRace(e,t){return this.events.onceRace(e,t)}async wait(e){return this.events.wait(e)}off(e,t){this.events.off(e,t)}subscribe(){this.callManager.on("presentation:start",e=>{this.events.trigger(R.START_PRESENTATION,e)}),this.callManager.on("presentation:started",e=>{this.events.trigger(R.STARTED_PRESENTATION,e)}),this.callManager.on("presentation:end",e=>{this.events.trigger(R.END_PRESENTATION,e)}),this.callManager.on("presentation:ended",e=>{this.events.trigger(R.ENDED_PRESENTATION,e)}),this.callManager.on("presentation:failed",e=>{this.events.trigger(R.FAILED_PRESENTATION,e)}),this.callManager.on("failed",this.handleEnded),this.callManager.on("ended",this.handleEnded)}async sendPresentationWithDuplicatedCalls(e,{rtcSession:t,stream:s,presentationOptions:i,options:r={callLimit:on}}){const a=async()=>this.sendPresentation(e,t,s,i),o=()=>!!this.streamPresentationCurrent;return this.cancelableSendPresentationWithRepeatedCalls=k.repeatedCallsAsync({targetFunction:a,isComplete:o,isRejectAsValid:!0,...r}),this.cancelableSendPresentationWithRepeatedCalls.then(c=>c)}async sendPresentation(e,t,s,{isNeedReinvite:i=!0,contentHint:r="detail",sendEncodings:a,onAddedTransceiver:o}){const c=y(s,{contentHint:r});if(c===void 0)throw new Error("No streamPresentationTarget");this.streamPresentationCurrent=c;const T=e().then(async()=>t.startPresentation(c,i,{sendEncodings:a,onAddedTransceiver:o})).then(()=>s).catch(S=>{throw this.removeStreamPresentationCurrent(),this.events.trigger(R.FAILED_PRESENTATION,S),S});return this.promisePendingStartPresentation=T,T.finally(()=>{this.promisePendingStartPresentation=void 0})}getRtcSessionProtected=()=>{const e=this.callManager.getEstablishedRTCSession();if(!e)throw new Error("No rtcSession established");return e};handleEnded=()=>{this.reset()};reset(){this.cancelSendPresentationWithRepeatedCalls(),this.resetPresentation()}resetPresentation(){this.removeStreamPresentationCurrent(),this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}removeStreamPresentationCurrent(){delete this.streamPresentationCurrent}}const En="Error decline with 603",gn=1006,Sn=n=>typeof n=="object"&&n!==null&&"code"in n&&n.code===gn,dn=n=>n.message===En;var g=(n=>(n.CONTENT_TYPE_NAME="content-type",n.CONTENT_ENTER_ROOM="x-webrtc-enter-room",n.CONTENT_USE_LICENSE="X-WEBRTC-USE-LICENSE",n.PARTICIPANT_NAME="X-WEBRTC-PARTICIPANT-NAME",n.INPUT_CHANNELS="X-WEBRTC-INPUT-CHANNELS",n.OUTPUT_CHANNELS="X-WEBRTC-OUTPUT-CHANNELS",n.MAIN_CAM="X-WEBRTC-MAINCAM",n.MIC="X-WEBRTC-MIC",n.MEDIA_SYNC="X-WEBRTC-SYNC",n.MAIN_CAM_RESOLUTION="X-WEBRTC-MAINCAM-RESOLUTION",n.MEDIA_STATE="X-WEBRTC-MEDIA-STATE",n.MEDIA_TYPE="X-Vinteo-Media-Type",n.MAIN_CAM_STATE="X-Vinteo-MainCam-State",n.MIC_STATE="X-Vinteo-Mic-State",n.CONTENT_PARTICIPANT_STATE="X-WEBRTC-PARTSTATE",n.NOTIFY="X-VINTEO-NOTIFY",n.CONTENT_ENABLE_MEDIA_DEVICE="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",n.CONTENT_SHARE_STATE="x-webrtc-share-state",n.MUST_STOP_PRESENTATION_P2P="x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT",n.START_PRESENTATION_P2P="x-webrtc-share-state: YOUCANRECEIVECONTENT",n.STOP_PRESENTATION_P2P="x-webrtc-share-state: CONTENTEND",n.STOP_PRESENTATION="x-webrtc-share-state: STOPPRESENTATION",n.START_PRESENTATION="x-webrtc-share-state: LETMESTARTPRESENTATION",n.ENABLE_MAIN_CAM="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM",n))(g||{}),U=(n=>(n.AVAILABLE_SECOND_REMOTE_STREAM="YOUCANRECEIVECONTENT",n.NOT_AVAILABLE_SECOND_REMOTE_STREAM="CONTENTEND",n.MUST_STOP_PRESENTATION="YOUMUSTSTOPSENDCONTENT",n))(U||{}),w=(n=>(n.SPECTATOR="SPECTATOR",n.PARTICIPANT="PARTICIPANT",n))(w||{}),M=(n=>(n.ENTER_ROOM="application/vinteo.webrtc.roomname",n.MIC="application/vinteo.webrtc.mic",n.USE_LICENSE="application/vinteo.webrtc.uselic",n.PARTICIPANT_STATE="application/vinteo.webrtc.partstate",n.NOTIFY="application/vinteo.webrtc.notify",n.SHARE_STATE="application/vinteo.webrtc.sharedesktop",n.MAIN_CAM="application/vinteo.webrtc.maincam",n))(M||{}),u=(n=>(n.CHANNELS="application/vinteo.webrtc.channels",n.MEDIA_STATE="application/vinteo.webrtc.mediastate",n.REFUSAL="application/vinteo.webrtc.refusal",n.SHARE_STATE="application/vinteo.webrtc.sharedesktop",n.MAIN_CAM="application/vinteo.webrtc.maincam",n))(u||{}),m=(n=>(n.PAUSE_MAIN_CAM="PAUSEMAINCAM",n.RESUME_MAIN_CAM="RESUMEMAINCAM",n.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",n.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",n.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",n))(m||{}),L=(n=>(n.ADMIN_STOP_MIC="ADMINSTOPMIC",n.ADMIN_START_MIC="ADMINSTARTMIC",n))(L||{}),F=(n=>(n.ADMIN_SYNC_FORCED="1",n.ADMIN_SYNC_NOT_FORCED="0",n))(F||{}),E=(n=>(n.CHANNELS_NOTIFY="channels:notify",n.PARTICIPANT_ADDED_TO_LIST_MODERATORS="participant:added-to-list-moderators",n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS="participant:removed-from-list-moderators",n.PARTICIPANT_MOVE_REQUEST_TO_STREAM="participant:move-request-to-stream",n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS="participant:move-request-to-spectators",n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS="participant:move-request-to-participants",n.PARTICIPATION_ACCEPTING_WORD_REQUEST="participation:accepting-word-request",n.PARTICIPATION_CANCELLING_WORD_REQUEST="participation:cancelling-word-request",n.WEBCAST_STARTED="webcast:started",n.WEBCAST_STOPPED="webcast:stopped",n.ACCOUNT_CHANGED="account:changed",n.ACCOUNT_DELETED="account:deleted",n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED="conference:participant-token-issued",n.CHANNELS="channels",n.ENTER_ROOM="enterRoom",n.SHARE_STATE="shareState",n.MAIN_CAM_CONTROL="main-cam-control",n.USE_LICENSE="useLicense",n.ADMIN_START_MAIN_CAM="admin-start-main-cam",n.ADMIN_STOP_MAIN_CAM="admin-stop-main-cam",n.ADMIN_START_MIC="admin-start-mic",n.ADMIN_STOP_MIC="admin-stop-mic",n.ADMIN_FORCE_SYNC_MEDIA_STATE="admin-force-sync-media-state",n.AVAILABLE_SECOND_REMOTE_STREAM="availableSecondRemoteStream",n.NOT_AVAILABLE_SECOND_REMOTE_STREAM="notAvailableSecondRemoteStream",n.MUST_STOP_PRESENTATION="mustStopPresentation",n.NEW_DTMF="newDTMF",n))(E||{});const ln=["participation:accepting-word-request","participation:cancelling-word-request","participant:move-request-to-stream","channels:notify","conference:participant-token-issued","account:changed","account:deleted","webcast:started","webcast:stopped","participant:added-to-list-moderators","participant:removed-from-list-moderators","participant:move-request-to-spectators","participant:move-request-to-participants","channels","enterRoom","shareState","main-cam-control","useLicense","admin-start-main-cam","admin-stop-main-cam","admin-start-mic","admin-stop-mic","admin-force-sync-media-state","availableSecondRemoteStream","notAvailableSecondRemoteStream","mustStopPresentation","newDTMF"];var _=(n=>(n.CHANNELS="channels",n.WEBCAST_STARTED="WebcastStarted",n.WEBCAST_STOPPED="WebcastStopped",n.ACCOUNT_CHANGED="accountChanged",n.ACCOUNT_DELETED="accountDeleted",n.ADDED_TO_LIST_MODERATORS="addedToListModerators",n.REMOVED_FROM_LIST_MODERATORS="removedFromListModerators",n.ACCEPTING_WORD_REQUEST="ParticipationRequestAccepted",n.CANCELLING_WORD_REQUEST="ParticipationRequestRejected",n.MOVE_REQUEST_TO_STREAM="ParticipantMovedToWebcast",n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED="ConferenceParticipantTokenIssued",n))(_||{});class hn{events;connectionManager;callManager;constructor({connectionManager:e,callManager:t}){this.connectionManager=e,this.callManager=t,this.events=new v(ln),this.subscribe()}async waitChannels(){return this.wait(E.CHANNELS)}async waitSyncMediaState(){return this.wait(E.ADMIN_FORCE_SYNC_MEDIA_STATE)}async sendDTMF(e){return new Promise((t,s)=>{const i=this.callManager.getEstablishedRTCSession();if(!i){s(new Error("No rtcSession established"));return}this.callManager.once("newDTMF",({originator:r})=>{r===D.LOCAL&&t()}),i.sendDTMF(e,{duration:120,interToneGap:600})})}async sendChannels({inputChannels:e,outputChannels:t}){const s=this.callManager.getEstablishedRTCSession();if(!s)throw new Error("No rtcSession established");const i=`${g.INPUT_CHANNELS}: ${e}`,r=`${g.OUTPUT_CHANNELS}: ${t}`,a=[i,r];return s.sendInfo(u.CHANNELS,void 0,{extraHeaders:a})}async sendMediaState({cam:e,mic:t},s={}){const i=this.callManager.getEstablishedRTCSession();if(!i)throw new Error("No rtcSession established");const r=`${g.MEDIA_STATE}: currentstate`,a=`${g.MAIN_CAM_STATE}: ${Number(e)}`,o=`${g.MIC_STATE}: ${Number(t)}`,c=[r,a,o];return i.sendInfo(u.MEDIA_STATE,void 0,{noTerminateWhenError:!0,...s,extraHeaders:c})}async sendRefusalToTurnOn(e,t={}){const s=this.callManager.getEstablishedRTCSession();if(!s)throw new Error("No rtcSession established");const a=e==="mic"?0:1,c=[`${g.MEDIA_TYPE}: ${a}`];return s.sendInfo(u.REFUSAL,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.callManager.getEstablishedRTCSession())throw new Error("No rtcSession established");return this.sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.callManager.getEstablishedRTCSession())throw new Error("No rtcSession established");return this.sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}async sendMustStopPresentationP2P(){const e=this.callManager.getEstablishedRTCSession();if(!e)throw new Error("No rtcSession established");await e.sendInfo(u.SHARE_STATE,void 0,{extraHeaders:[g.MUST_STOP_PRESENTATION_P2P]})}async sendStoppedPresentationP2P(){const e=this.callManager.getEstablishedRTCSession();if(!e)throw new Error("No rtcSession established");await e.sendInfo(u.SHARE_STATE,void 0,{extraHeaders:[g.STOP_PRESENTATION_P2P]})}async sendStoppedPresentation(){const e=this.callManager.getEstablishedRTCSession();if(!e)throw new Error("No rtcSession established");await e.sendInfo(u.SHARE_STATE,void 0,{extraHeaders:[g.STOP_PRESENTATION]})}async askPermissionToStartPresentationP2P(){const e=this.callManager.getEstablishedRTCSession();if(!e)throw new Error("No rtcSession established");await e.sendInfo(u.SHARE_STATE,void 0,{extraHeaders:[g.START_PRESENTATION_P2P]})}async askPermissionToStartPresentation(){const e=this.callManager.getEstablishedRTCSession();if(!e)throw new Error("No rtcSession established");await e.sendInfo(u.SHARE_STATE,void 0,{extraHeaders:[g.START_PRESENTATION]})}async askPermissionToEnableCam(e={}){const t=this.callManager.getEstablishedRTCSession();if(!t)throw new Error("No rtcSession established");const s=[g.ENABLE_MAIN_CAM];return t.sendInfo(u.MAIN_CAM,void 0,{noTerminateWhenError:!0,...e,extraHeaders:s}).catch(i=>{if(dn(i))throw i})}on(e,t){return this.events.on(e,t)}once(e,t){return this.events.once(e,t)}onceRace(e,t){return this.events.onceRace(e,t)}async wait(e){return this.events.wait(e)}off(e,t){this.events.off(e,t)}subscribe(){this.connectionManager.on("sipEvent",this.handleSipEvent),this.callManager.on("newInfo",this.handleNewInfo),this.callManager.on("newDTMF",e=>{this.events.trigger("newDTMF",e)})}handleSipEvent=({request:e})=>{this.maybeHandleNotify(e)};maybeHandleNotify=e=>{try{const t=e.getHeader(g.NOTIFY);if(t){const s=JSON.parse(t);this.handleNotify(s)}}catch(t){O("error parse notify",t)}};handleNotify=e=>{switch(e.cmd){case _.CHANNELS:{const t=e;this.triggerChannelsNotify(t);break}case _.WEBCAST_STARTED:{const t=e;this.triggerWebcastStartedNotify(t);break}case _.WEBCAST_STOPPED:{const t=e;this.triggerWebcastStoppedNotify(t);break}case _.ADDED_TO_LIST_MODERATORS:{const t=e;this.triggerAddedToListModeratorsNotify(t);break}case _.REMOVED_FROM_LIST_MODERATORS:{const t=e;this.triggerRemovedFromListModeratorsNotify(t);break}case _.ACCEPTING_WORD_REQUEST:{const t=e;this.triggerParticipationAcceptingWordRequest(t);break}case _.CANCELLING_WORD_REQUEST:{const t=e;this.triggerParticipationCancellingWordRequest(t);break}case _.MOVE_REQUEST_TO_STREAM:{const t=e;this.triggerParticipantMoveRequestToStream(t);break}case _.ACCOUNT_CHANGED:{this.triggerAccountChangedNotify();break}case _.ACCOUNT_DELETED:{this.triggerAccountDeletedNotify();break}case _.CONFERENCE_PARTICIPANT_TOKEN_ISSUED:{const t=e;this.triggerConferenceParticipantTokenIssued(t);break}default:O("unknown cmd",e)}};handleNewInfo=e=>{const{originator:t}=e;if(t!==D.REMOTE)return;const{request:s}=e,i=s.getHeader(g.CONTENT_TYPE_NAME);if(i!==void 0)switch(i){case M.ENTER_ROOM:{this.triggerEnterRoom(s),this.maybeTriggerChannels(s);break}case M.NOTIFY:{this.maybeHandleNotify(s);break}case M.SHARE_STATE:{this.triggerShareState(s);break}case M.MAIN_CAM:{this.triggerMainCamControl(s);break}case M.MIC:{this.triggerMicControl(s);break}case M.USE_LICENSE:{this.triggerUseLicense(s);break}case M.PARTICIPANT_STATE:{this.maybeTriggerParticipantMoveRequest(s);break}}};triggerChannelsNotify=e=>{const t=e.input,s=e.output,i={inputChannels:t,outputChannels:s};this.events.trigger(E.CHANNELS_NOTIFY,i)};triggerWebcastStartedNotify=({body:{conference:e,type:t}})=>{const s={conference:e,type:t};this.events.trigger(E.WEBCAST_STARTED,s)};triggerWebcastStoppedNotify=({body:{conference:e,type:t}})=>{const s={conference:e,type:t};this.events.trigger(E.WEBCAST_STOPPED,s)};triggerAddedToListModeratorsNotify=({conference:e})=>{const t={conference:e};this.events.trigger(E.PARTICIPANT_ADDED_TO_LIST_MODERATORS,t)};triggerRemovedFromListModeratorsNotify=({conference:e})=>{const t={conference:e};this.events.trigger(E.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,t)};triggerParticipationAcceptingWordRequest=({body:{conference:e}})=>{const t={conference:e};this.events.trigger(E.PARTICIPATION_ACCEPTING_WORD_REQUEST,t)};triggerParticipationCancellingWordRequest=({body:{conference:e}})=>{const t={conference:e};this.events.trigger(E.PARTICIPATION_CANCELLING_WORD_REQUEST,t)};triggerParticipantMoveRequestToStream=({body:{conference:e}})=>{const t={conference:e};this.events.trigger(E.PARTICIPANT_MOVE_REQUEST_TO_STREAM,t)};triggerAccountChangedNotify=()=>{this.events.trigger(E.ACCOUNT_CHANGED,void 0)};triggerAccountDeletedNotify=()=>{this.events.trigger(E.ACCOUNT_DELETED,void 0)};triggerConferenceParticipantTokenIssued=({body:{conference:e,participant:t,jwt:s}})=>{const i={conference:e,participant:t,jwt:s};this.events.trigger(E.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,i)};maybeTriggerChannels=e=>{const t=e.getHeader(g.INPUT_CHANNELS),s=e.getHeader(g.OUTPUT_CHANNELS);if(t&&s){const i={inputChannels:t,outputChannels:s};this.events.trigger(E.CHANNELS,i)}};triggerEnterRoom=e=>{const t=e.getHeader(g.CONTENT_ENTER_ROOM),s=e.getHeader(g.PARTICIPANT_NAME);this.events.trigger(E.ENTER_ROOM,{room:t,participantName:s})};triggerShareState=e=>{const t=e.getHeader(g.CONTENT_SHARE_STATE);if(t!==void 0)switch(t){case U.AVAILABLE_SECOND_REMOTE_STREAM:{this.events.trigger(E.AVAILABLE_SECOND_REMOTE_STREAM,void 0);break}case U.NOT_AVAILABLE_SECOND_REMOTE_STREAM:{this.events.trigger(E.NOT_AVAILABLE_SECOND_REMOTE_STREAM,void 0);break}case U.MUST_STOP_PRESENTATION:{this.events.trigger(E.MUST_STOP_PRESENTATION,void 0);break}}};maybeTriggerParticipantMoveRequest=e=>{const t=e.getHeader(g.CONTENT_PARTICIPANT_STATE);t===w.SPECTATOR&&this.events.trigger(E.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS,void 0),t===w.PARTICIPANT&&this.events.trigger(E.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS,void 0)};triggerMainCamControl=e=>{const t=e.getHeader(g.MAIN_CAM),s=e.getHeader(g.MEDIA_SYNC),i=s===F.ADMIN_SYNC_FORCED;if(t===m.ADMIN_START_MAIN_CAM){this.events.trigger(E.ADMIN_START_MAIN_CAM,{isSyncForced:i});return}if(t===m.ADMIN_STOP_MAIN_CAM){this.events.trigger(E.ADMIN_STOP_MAIN_CAM,{isSyncForced:i});return}(t===m.RESUME_MAIN_CAM||t===m.PAUSE_MAIN_CAM)&&s!==void 0&&this.events.trigger(E.ADMIN_FORCE_SYNC_MEDIA_STATE,{isSyncForced:i});const r=e.getHeader(g.MAIN_CAM_RESOLUTION);this.events.trigger(E.MAIN_CAM_CONTROL,{mainCam:t,resolutionMainCam:r})};triggerMicControl=e=>{const t=e.getHeader(g.MIC),i=e.getHeader(g.MEDIA_SYNC)===F.ADMIN_SYNC_FORCED;t===L.ADMIN_START_MIC?this.events.trigger(E.ADMIN_START_MIC,{isSyncForced:i}):t===L.ADMIN_STOP_MIC&&this.events.trigger(E.ADMIN_STOP_MIC,{isSyncForced:i})};triggerUseLicense=e=>{const t=e.getHeader(g.CONTENT_USE_LICENSE);this.events.trigger(E.USE_LICENSE,t)}}class Cn{data={};getUa;constructor(e){this.getUa=e.getUa}isConfigured(){return this.getUa()!==void 0}get(){return{...this.data}}set(e){this.data={...e}}update(e,t){this.data[e]=t}clear(){this.data={}}isRegister(){return this.data.register===!0}getSipServerUrl(){return this.data.sipServerUrl}getDisplayName(){return this.data.displayName}getUser(){return this.data.user}getPassword(){return this.data.password}isRegisterEnabled(){return this.data.register===!0}}var A=(n=>(n.CONNECTING="connecting",n.CONNECTED="connected",n.DISCONNECTED="disconnected",n.NEW_RTC_SESSION="newRTCSession",n.REGISTERED="registered",n.UNREGISTERED="unregistered",n.REGISTRATION_FAILED="registrationFailed",n.NEW_MESSAGE="newMessage",n.SIP_EVENT="sipEvent",n))(A||{});const Nt=["connecting","connected","disconnected","newRTCSession","registered","unregistered","registrationFailed","newMessage","sipEvent"],Nn=[...Nt],An=3;class _n{cancelableConnectWithRepeatedCalls;JsSIP;events;uaFactory;stateMachine;registrationManager;getUa;setUa;getConnectionConfiguration;setConnectionConfiguration;updateConnectionConfiguration;setSipServerUrl;setSocket;constructor(e){this.JsSIP=e.JsSIP,this.events=e.events,this.uaFactory=e.uaFactory,this.stateMachine=e.stateMachine,this.registrationManager=e.registrationManager,this.getUa=e.getUa,this.setUa=e.setUa,this.getConnectionConfiguration=e.getConnectionConfiguration,this.setConnectionConfiguration=e.setConnectionConfiguration,this.updateConnectionConfiguration=e.updateConnectionConfiguration,this.setSipServerUrl=e.setSipServerUrl,this.setSocket=e.setSocket}connect=async(e,t)=>(this.cancelRequests(),this.connectWithDuplicatedCalls(e,t));set=async({displayName:e})=>new Promise((t,s)=>{const i=this.getUa();if(!i){s(new Error("this.ua is not initialized"));return}let r=!1;const a=this.getConnectionConfiguration();e!==void 0&&e!==a.displayName&&(r=i.set("display_name",Ct(e)),this.updateConnectionConfiguration("displayName",e));const o=r;o?t(o):s(new Error("nothing changed"))});disconnect=async()=>{const e=new Promise(s=>{this.events.once(A.DISCONNECTED,()=>{s()})}),t=this.getUa();return t?t.stop():this.events.trigger(A.DISCONNECTED,void 0),e.finally(()=>{this.setUa(void 0),this.stateMachine.reset()})};cancelRequests(){this.cancelConnectWithRepeatedCalls()}connectWithDuplicatedCalls=async(e,{callLimit:t=An}={})=>{const s=async()=>this.connectInner(e),i=r=>{const c=this.getUa()?.isConnected()===!0&&this.hasEqualConnectionConfiguration(e),T=r!=null&&!Sn(r);return c||T};return this.stateMachine.startConnect(),this.cancelableConnectWithRepeatedCalls=k.repeatedCallsAsync({targetFunction:s,isComplete:i,callLimit:t,isRejectAsValid:!0,isCheckBeforeCall:!1}),this.cancelableConnectWithRepeatedCalls.then(r=>{if(r instanceof this.JsSIP.UA)return r;throw r})};hasEqualConnectionConfiguration(e){const{configuration:t}=this.uaFactory.createConfiguration(e),i=this.getUa()?.configuration;return i?i.password===t.password&&i.register===t.register&&i.uri.toString()===t.uri&&i.display_name===t.display_name&&i.user_agent===t.user_agent&&i.sockets===t.sockets&&i.session_timers===t.session_timers&&i.register_expires===t.register_expires&&i.connection_recovery_min_interval===t.connection_recovery_min_interval&&i.connection_recovery_max_interval===t.connection_recovery_max_interval:!1}connectInner=async e=>this.initUa(e).then(async()=>this.start());initUa=async({user:e,password:t,sipServerUrl:s,sipWebSocketServerURL:i,remoteAddress:r,sessionTimers:a,registerExpires:o,connectionRecoveryMinInterval:c,connectionRecoveryMaxInterval:T,userAgent:S,displayName:h="",register:d=!1,extraHeaders:l=[]})=>{this.stateMachine.startInitUa(),this.setConnectionConfiguration({sipServerUrl:s,displayName:h,register:d,user:e,password:t}),this.getUa()&&await this.disconnect();const{ua:C,helpers:P}=this.uaFactory.createUAWithConfiguration({user:e,password:t,sipServerUrl:s,sipWebSocketServerURL:i,displayName:h,register:d,sessionTimers:a,registerExpires:o,connectionRecoveryMinInterval:c,connectionRecoveryMaxInterval:T,userAgent:S,remoteAddress:r,extraHeaders:l},this.events);return this.setUa(C),this.setSipServerUrl(P.getSipServerUrl),this.setSocket(P.socket),C};start=async()=>new Promise((e,t)=>{const s=this.getUa();if(!s){t(new Error("this.ua is not initialized"));return}let i;i=((c,T)=>{if(this.getConnectionConfiguration().register===!0)return this.registrationManager.subscribeToStartEvents(c,T);const h=A.CONNECTED,d=[A.DISCONNECTED];return this.events.on(h,c),d.forEach(l=>{this.events.on(l,T)}),()=>{this.events.off(h,c),d.forEach(l=>{this.events.off(l,T)})}})(()=>{i?.(),e(s)},c=>{i?.(),t(c)}),s.start()});cancelConnectWithRepeatedCalls(){this.cancelableConnectWithRepeatedCalls?.cancel()}}var At=(n=>(n.START_CONNECT="START_CONNECT",n.START_INIT_UA="START_INIT_UA",n.UA_CONNECTED="UA_CONNECTED",n.UA_REGISTERED="UA_REGISTERED",n.UA_UNREGISTERED="UA_UNREGISTERED",n.UA_DISCONNECTED="UA_DISCONNECTED",n.CONNECTION_FAILED="CONNECTION_FAILED",n.RESET="RESET",n))(At||{});const un=Y.setup({types:{context:{},events:{}},actions:{logTransition:(n,e)=>{O(`State transition: ${e.from} -> ${e.to} (${e.event})`)},logStateChange:(n,e)=>{O("ConnectionStateMachine state changed",e.state)}}}).createMachine({id:"connection",initial:"idle",context:{},states:{idle:{entry:{type:"logStateChange",params:{state:"idle"}},on:{START_CONNECT:{target:"connecting",actions:{type:"logTransition",params:{from:"idle",to:"connecting",event:"START_CONNECT"}}}}},connecting:{entry:{type:"logStateChange",params:{state:"connecting"}},on:{START_INIT_UA:{target:"initializing",actions:{type:"logTransition",params:{from:"connecting",to:"initializing",event:"START_INIT_UA"}}},UA_DISCONNECTED:{target:"disconnected",actions:{type:"logTransition",params:{from:"connecting",to:"disconnected",event:"UA_DISCONNECTED"}}},CONNECTION_FAILED:{target:"failed",actions:{type:"logTransition",params:{from:"connecting",to:"failed",event:"CONNECTION_FAILED"}}}}},initializing:{entry:{type:"logStateChange",params:{state:"initializing"}},on:{UA_CONNECTED:{target:"connected",actions:{type:"logTransition",params:{from:"initializing",to:"connected",event:"UA_CONNECTED"}}},UA_REGISTERED:{target:"registered",actions:{type:"logTransition",params:{from:"initializing",to:"registered",event:"UA_REGISTERED"}}},UA_DISCONNECTED:{target:"disconnected",actions:{type:"logTransition",params:{from:"initializing",to:"disconnected",event:"UA_DISCONNECTED"}}},CONNECTION_FAILED:{target:"failed",actions:{type:"logTransition",params:{from:"initializing",to:"failed",event:"CONNECTION_FAILED"}}}}},connected:{entry:{type:"logStateChange",params:{state:"connected"}},on:{UA_REGISTERED:{target:"registered",actions:{type:"logTransition",params:{from:"connected",to:"registered",event:"UA_REGISTERED"}}},UA_DISCONNECTED:{target:"disconnected",actions:{type:"logTransition",params:{from:"connected",to:"disconnected",event:"UA_DISCONNECTED"}}},CONNECTION_FAILED:{target:"failed",actions:{type:"logTransition",params:{from:"connected",to:"failed",event:"CONNECTION_FAILED"}}}}},registered:{entry:{type:"logStateChange",params:{state:"registered"}},on:{UA_UNREGISTERED:{target:"connected",actions:{type:"logTransition",params:{from:"registered",to:"connected",event:"UA_UNREGISTERED"}}},UA_DISCONNECTED:{target:"disconnected",actions:{type:"logTransition",params:{from:"registered",to:"disconnected",event:"UA_DISCONNECTED"}}},CONNECTION_FAILED:{target:"failed",actions:{type:"logTransition",params:{from:"registered",to:"failed",event:"CONNECTION_FAILED"}}}}},disconnected:{entry:{type:"logStateChange",params:{state:"disconnected"}},on:{RESET:{target:"idle",actions:{type:"logTransition",params:{from:"disconnected",to:"idle",event:"RESET"}}},START_CONNECT:{target:"connecting",actions:{type:"logTransition",params:{from:"disconnected",to:"connecting",event:"START_CONNECT"}}}}},failed:{entry:{type:"logStateChange",params:{state:"failed"}},on:{RESET:{target:"idle",actions:{type:"logTransition",params:{from:"failed",to:"idle",event:"RESET"}}},START_CONNECT:{target:"connecting",actions:{type:"logTransition",params:{from:"failed",to:"connecting",event:"START_CONNECT"}}}}}}});class In{actor;stateChangeListeners=new Set;events;unsubscribeFromEvents;actorSubscription;constructor(e){this.events=e,this.actor=Y.createActor(un),this.actorSubscription=this.actor.subscribe(t=>{const s=t.value;this.stateChangeListeners.forEach(i=>{i(s)})}),this.actor.start(),this.subscribeToEvents()}get state(){return this.actor.getSnapshot().value}get isIdle(){return this.hasState("idle")}get isConnecting(){return this.hasState("connecting")}get isInitializing(){return this.hasState("initializing")}get isConnected(){return this.hasState("connected")}get isRegistered(){return this.hasState("registered")}get isDisconnected(){return this.hasState("disconnected")}get isFailed(){return this.hasState("failed")}get isPending(){return this.isConnecting||this.isInitializing}get isPendingConnect(){return this.isConnecting}get isPendingInitUa(){return this.isInitializing}get isActiveConnection(){return this.isConnected||this.isRegistered}startConnect(){this.toStartConnect()}startInitUa(){this.toStartInitUa()}reset(){this.toIdle()}destroy(){this.unsubscribeFromEvents?.(),this.actorSubscription?.unsubscribe(),this.actor.stop()}onStateChange(e){return this.stateChangeListeners.add(e),()=>{this.stateChangeListeners.delete(e)}}canTransition(e){return this.actor.getSnapshot().can({type:e})}getValidEvents(){return Object.values(At).filter(e=>this.canTransition(e))}hasState(e){return this.actor.getSnapshot().matches(e)}sendEvent(e){const t=this.actor.getSnapshot(),s={type:e};if(!t.can(s)){O(`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`);return}this.actor.send(s)}toStartConnect=()=>{this.sendEvent("START_CONNECT")};toStartInitUa=()=>{this.sendEvent("START_INIT_UA")};toConnected=()=>{this.sendEvent("UA_CONNECTED")};toRegistered=()=>{this.sendEvent("UA_REGISTERED")};toUnregistered=()=>{this.sendEvent("UA_UNREGISTERED")};toDisconnected=()=>{this.sendEvent("UA_DISCONNECTED")};toFailed=()=>{this.sendEvent("CONNECTION_FAILED")};toIdle=()=>{this.sendEvent("RESET")};subscribeToEvents(){this.events.on("connected",this.toConnected),this.events.on("registered",this.toRegistered),this.events.on("unregistered",this.toUnregistered),this.events.on("disconnected",this.toDisconnected),this.events.on("registrationFailed",this.toFailed),this.unsubscribeFromEvents=()=>{this.events.off("connected",this.toConnected),this.events.off("registered",this.toRegistered),this.events.off("unregistered",this.toUnregistered),this.events.off("disconnected",this.toDisconnected),this.events.off("registrationFailed",this.toFailed)}}}class Rn{events;getUaProtected;constructor(e){this.events=e.events,this.getUaProtected=e.getUaProtected}async register(){const e=this.getUaProtected();return new Promise((t,s)=>{e.on(A.REGISTERED,t),e.on(A.REGISTRATION_FAILED,s),e.register()})}async unregister(){const e=this.getUaProtected();return new Promise(t=>{e.on(A.UNREGISTERED,t),e.unregister()})}async tryRegister(){try{await this.unregister()}catch(e){O("tryRegister",e)}return this.register()}subscribeToStartEvents(e,t){const s=A.REGISTERED,i=[A.REGISTRATION_FAILED,A.DISCONNECTED];return this.events.on(s,e),i.forEach(r=>{this.events.on(r,t)}),()=>{this.events.off(s,e),i.forEach(r=>{this.events.off(r,t)})}}}class Mn{uaFactory;getUaProtected;constructor(e){this.uaFactory=e.uaFactory,this.getUaProtected=e.getUaProtected}async sendOptions(e,t,s){const i=this.getUaProtected();return new Promise((r,a)=>{try{i.sendOptions(e,t,{extraHeaders:s,eventHandlers:{succeeded:()=>{r()},failed:a}})}catch(o){a(o)}})}async ping(e,t){const i=this.getUaProtected().configuration.uri;return this.sendOptions(i,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:s,sipWebSocketServerURL:i,remoteAddress:r,extraHeaders:a}){return new Promise((o,c)=>{const{configuration:T}=this.uaFactory.createConfiguration({sipWebSocketServerURL:i,displayName:t,userAgent:e,sipServerUrl:s}),S=this.uaFactory.createUA({...T,remoteAddress:r,extraHeaders:a}),h=()=>{const l=new Error("Telephony is not available");c(l)};S.once(A.DISCONNECTED,h);const d=()=>{S.removeAllListeners(),S.once(A.DISCONNECTED,()=>{o()}),S.stop()};S.once(A.CONNECTED,d),S.start()})}}const On=n=>{const e=[];return n!==void 0&&n!==""&&e.push(`X-Vinteo-Remote: ${n}`),e};class p{JsSIP;constructor(e){this.JsSIP=e}static isRegisteredUA(e){return!!e&&e.isRegistered()}static validateConfiguration({register:e,password:t,user:s,sipServerUrl:i,sipWebSocketServerURL:r}){if(!i)throw new Error("sipServerUrl is required");if(!r)throw new Error("sipWebSocketServerURL is required");if(e&&(t===void 0||t===""))throw new Error("password is required for authorized connection");if(e&&(s===void 0||s===""))throw new Error("user is required for authorized connection")}static resolveAuthorizationUser(e,t){return e&&t!==void 0&&t.trim()!==""?t.trim():`${Kt()}`}static buildExtraHeaders(e,t){const s=e!==void 0&&e!==""?On(e):[];return t===void 0?s:[...s,...t]}createConfiguration({user:e,password:t,sipWebSocketServerURL:s,displayName:i="",sipServerUrl:r,register:a=!1,sessionTimers:o=!1,registerExpires:c=300,connectionRecoveryMinInterval:T=2,connectionRecoveryMaxInterval:S=6,userAgent:h}){p.validateConfiguration({register:a,password:t,user:e,sipServerUrl:r,sipWebSocketServerURL:s});const d=p.resolveAuthorizationUser(a,e),l=Xt(r),I=l(d),C=new this.JsSIP.WebSocketInterface(s);return{configuration:{password:t,register:a,uri:I,display_name:Ct(i),user_agent:h,sdpSemantics:"unified-plan",sockets:[C],session_timers:o,register_expires:c,connection_recovery_min_interval:T,connection_recovery_max_interval:S},helpers:{socket:C,getSipServerUrl:l}}}createUA({remoteAddress:e,extraHeaders:t,...s}){const i=new this.JsSIP.UA(s),r=p.buildExtraHeaders(e,t);return r.length>0&&i.registrator().setExtraHeaders(r),i}createUAWithConfiguration(e,t){const{configuration:s,helpers:i}=this.createConfiguration(e),r=this.createUA({...s,remoteAddress:e.remoteAddress,extraHeaders:e.extraHeaders});return t.eachTriggers((a,o)=>{const c=Nt.find(T=>T===o);c&&r.on(c,a)}),{ua:r,helpers:i}}}class Pn{events;ua;socket;uaFactory;registrationManager;stateMachine;connectionFlow;sipOperations;configurationManager;JsSIP;constructor({JsSIP:e}){this.JsSIP=e,this.events=new v(Nn),this.uaFactory=new p(e),this.registrationManager=new Rn({events:this.events,getUaProtected:this.getUaProtected}),this.stateMachine=new In(this.events),this.configurationManager=new Cn({getUa:this.getUa}),this.sipOperations=new Mn({uaFactory:this.uaFactory,getUaProtected:this.getUaProtected}),this.connectionFlow=new _n({JsSIP:this.JsSIP,events:this.events,uaFactory:this.uaFactory,stateMachine:this.stateMachine,registrationManager:this.registrationManager,getUa:this.getUa,getConnectionConfiguration:this.getConnectionConfiguration,setConnectionConfiguration:t=>{this.configurationManager.set(t)},updateConnectionConfiguration:(t,s)=>{this.configurationManager.update(t,s)},setUa:t=>{this.ua=t},setSipServerUrl:t=>{this.getSipServerUrl=t},setSocket:t=>{this.socket=t}})}get requested(){return this.stateMachine.isPending}get isPendingConnect(){return this.stateMachine.isPendingConnect}get isPendingInitUa(){return this.stateMachine.isPendingInitUa}get connectionState(){return this.stateMachine.state}get isRegistered(){return p.isRegisteredUA(this.ua)}get isRegisterConfig(){return this.configurationManager.isRegister()}connect=async(e,t)=>this.connectionFlow.connect(e,t);set=async({displayName:e})=>this.connectionFlow.set({displayName:e});disconnect=async()=>this.connectionFlow.disconnect();async register(){return this.registrationManager.register()}async unregister(){return this.registrationManager.unregister()}tryRegister=async()=>this.registrationManager.tryRegister();sendOptions=async(e,t,s)=>this.sipOperations.sendOptions(e,t,s);ping=async(e,t)=>this.sipOperations.ping(e,t);checkTelephony=async e=>this.sipOperations.checkTelephony(e);on(e,t){return this.events.on(e,t)}once(e,t){return this.events.once(e,t)}onceRace(e,t){return this.events.onceRace(e,t)}async wait(e){return this.events.wait(e)}off(e,t){this.events.off(e,t)}isConfigured(){return this.configurationManager.isConfigured()}getConnectionConfiguration=()=>this.configurationManager.get();destroy(){this.stateMachine.destroy()}getSipServerUrl=e=>e;getUaProtected=()=>{if(!this.ua)throw new Error("UA not initialized");return this.ua};getUa=()=>this.ua}var f=(n=>(n.INCOMING_CALL="incomingCall",n.DECLINED_INCOMING_CALL="declinedIncomingCall",n.TERMINATED_INCOMING_CALL="terminatedIncomingCall",n.FAILED_INCOMING_CALL="failedIncomingCall",n))(f||{}),$=(n=>(n.LOCAL="local",n.REMOTE="remote",n.SYSTEM="system",n))($||{});const pn=["incomingCall","declinedIncomingCall","terminatedIncomingCall","failedIncomingCall"],mn=486,fn=487;class Dn{incomingRTCSession;connectionManager;events;constructor(e){this.connectionManager=e,this.events=new v(pn),this.start()}get remoteCallerData(){return{displayName:this.incomingRTCSession?.remote_identity.display_name,host:this.incomingRTCSession?.remote_identity.uri.host,incomingNumber:this.incomingRTCSession?.remote_identity.uri.user,rtcSession:this.incomingRTCSession}}get isAvailableIncomingCall(){return!!this.incomingRTCSession}start(){this.subscribe()}stop(){this.unsubscribe(),this.removeIncomingSession()}getIncomingRTCSession=()=>{const{incomingRTCSession:e}=this;if(!e)throw new Error("No incomingRTCSession");return e};extractIncomingRTCSession=()=>{const e=this.getIncomingRTCSession();return this.removeIncomingSession(),e};async declineToIncomingCall({statusCode:e=fn}={}){return new Promise((t,s)=>{try{const i=this.getIncomingRTCSession(),r=this.remoteCallerData;this.removeIncomingSession(),this.events.trigger(f.DECLINED_INCOMING_CALL,r),i.terminate({status_code:e}),t()}catch(i){s(i)}})}async busyIncomingCall(){return this.declineToIncomingCall({statusCode:mn})}on(e,t){return this.events.on(e,t)}once(e,t){return this.events.once(e,t)}onceRace(e,t){return this.events.onceRace(e,t)}async wait(e){return this.events.wait(e)}off(e,t){this.events.off(e,t)}subscribe(){this.connectionManager.on("newRTCSession",this.handleNewRTCSession)}unsubscribe(){this.connectionManager.off("newRTCSession",this.handleNewRTCSession)}handleNewRTCSession=({originator:e,session:t})=>{e===$.REMOTE&&this.setIncomingSession(t)};setIncomingSession(e){this.incomingRTCSession=e;const t=this.remoteCallerData;e.on("failed",s=>{this.removeIncomingSession(),s.originator===$.LOCAL?this.events.trigger(f.TERMINATED_INCOMING_CALL,t):this.events.trigger(f.FAILED_INCOMING_CALL,t)}),this.events.trigger(f.INCOMING_CALL,t)}removeIncomingSession(){delete this.incomingRTCSession}}class vn{connectionManager;callManager;apiManager;incomingCallManager;presentationManager;constructor({JsSIP:e}){this.connectionManager=new Pn({JsSIP:e}),this.callManager=new rn,this.apiManager=new hn({connectionManager:this.connectionManager,callManager:this.callManager}),this.incomingCallManager=new Dn(this.connectionManager),this.presentationManager=new Tn({callManager:this.callManager})}get requestedConnection(){return this.connectionManager.requested}get isPendingConnect(){return this.connectionManager.isPendingConnect}get isPendingInitUa(){return this.connectionManager.isPendingInitUa}get connectionState(){return this.connectionManager.connectionState}get isRegistered(){return this.connectionManager.isRegistered}get isRegisterConfig(){return this.connectionManager.isRegisterConfig}get socket(){return this.connectionManager.socket}get requestedCall(){return this.callManager.requested}get connection(){return this.callManager.connection}get establishedRTCSession(){return this.callManager.establishedRTCSession}get isCallActive(){return this.callManager.isCallActive}get remoteCallerData(){return this.incomingCallManager.remoteCallerData}get isAvailableIncomingCall(){return this.incomingCallManager.isAvailableIncomingCall}connect=async(...e)=>this.connectionManager.connect(...e);set=async(...e)=>this.connectionManager.set(...e);disconnect=async()=>this.connectionManager.disconnect();register=async()=>this.connectionManager.register();unregister=async()=>this.connectionManager.unregister();tryRegister=async()=>this.connectionManager.tryRegister();sendOptions=async(e,t,s)=>this.connectionManager.sendOptions(e,t,s);ping=async(e,t)=>this.connectionManager.ping(e,t);checkTelephony=async e=>this.connectionManager.checkTelephony(e);onConnection(e,t){return this.connectionManager.on(e,t)}onceConnection(e,t){return this.connectionManager.once(e,t)}onceRaceConnection(e,t){return this.connectionManager.onceRace(e,t)}async waitConnection(e){return this.connectionManager.wait(e)}offConnection(e,t){this.connectionManager.off(e,t)}isConfigured=()=>this.connectionManager.isConfigured();getConnectionConfiguration=()=>this.connectionManager.getConnectionConfiguration();getSipServerUrl=e=>this.connectionManager.getSipServerUrl(e);call=async e=>this.callManager.startCall(this.connectionManager.getUaProtected(),this.getSipServerUrl,e);hangUp=async()=>this.callManager.endCall();answerToIncomingCall=async e=>this.callManager.answerToIncomingCall(this.incomingCallManager.extractIncomingRTCSession,e);declineToIncomingCall=async(...e)=>this.incomingCallManager.declineToIncomingCall(...e);getEstablishedRTCSession=()=>this.callManager.getEstablishedRTCSession();getCallConfiguration=()=>this.callManager.getCallConfiguration();getRemoteStreams=()=>this.callManager.getRemoteStreams();replaceMediaStream=async(...e)=>this.callManager.replaceMediaStream(...e);onCall(e,t){return this.callManager.on(e,t)}onceCall(e,t){return this.callManager.once(e,t)}onceRaceCall(e,t){return this.callManager.onceRace(e,t)}async waitCall(e){return this.callManager.wait(e)}offIncomingCall(e,t){this.incomingCallManager.off(e,t)}onIncomingCall(e,t){return this.incomingCallManager.on(e,t)}onceIncomingCall(e,t){return this.incomingCallManager.once(e,t)}onceRaceIncomingCall(e,t){return this.incomingCallManager.onceRace(e,t)}async waitIncomingCall(e){return this.incomingCallManager.wait(e)}offCall(e,t){this.callManager.off(e,t)}async startPresentation(e,t={}){const{isP2P:s,callLimit:i,...r}=t;return this.presentationManager.startPresentation(async()=>{s===!0?(await this.apiManager.sendMustStopPresentationP2P(),await this.apiManager.askPermissionToStartPresentationP2P()):await this.apiManager.askPermissionToStartPresentation()},e,r,i===void 0?void 0:{callLimit:i})}async stopPresentation(e={}){const{isP2P:t}=e;return this.presentationManager.stopPresentation(async()=>{t===!0?await this.apiManager.sendMustStopPresentationP2P():await this.apiManager.sendStoppedPresentation()})}async updatePresentation(e,t={}){const{isP2P:s,...i}=t;return this.presentationManager.updatePresentation(async()=>{s===!0?(await this.apiManager.sendMustStopPresentationP2P(),await this.apiManager.askPermissionToStartPresentationP2P()):await this.apiManager.askPermissionToStartPresentation()},e,i)}async waitChannels(...e){return this.apiManager.waitChannels(...e)}async waitSyncMediaState(...e){return this.apiManager.waitSyncMediaState(...e)}async sendDTMF(...e){return this.apiManager.sendDTMF(...e)}async sendChannels(...e){return this.apiManager.sendChannels(...e)}async sendMediaState(...e){return this.apiManager.sendMediaState(...e)}async sendRefusalToTurnOn(...e){return this.apiManager.sendRefusalToTurnOn(...e)}async sendRefusalToTurnOnMic(...e){return this.apiManager.sendRefusalToTurnOnMic(...e)}async sendRefusalToTurnOnCam(...e){return this.apiManager.sendRefusalToTurnOnCam(...e)}async sendMustStopPresentationP2P(...e){return this.apiManager.sendMustStopPresentationP2P(...e)}async sendStoppedPresentationP2P(...e){return this.apiManager.sendStoppedPresentationP2P(...e)}async sendStoppedPresentation(...e){return this.apiManager.sendStoppedPresentation(...e)}async askPermissionToStartPresentationP2P(...e){return this.apiManager.askPermissionToStartPresentationP2P(...e)}async askPermissionToStartPresentation(...e){return this.apiManager.askPermissionToStartPresentation(...e)}async askPermissionToEnableCam(...e){return this.apiManager.askPermissionToEnableCam(...e)}onApi(e,t){return this.apiManager.on(e,t)}onceApi(e,t){return this.apiManager.once(e,t)}onceRaceApi(e,t){return this.apiManager.onceRace(e,t)}async waitApi(e){return this.apiManager.wait(e)}offApi(e,t){this.apiManager.off(e,t)}}exports.BAD_MEDIA_DESCRIPTION=z;exports.ECallCause=q;exports.NOT_FOUND=Q;exports.Originator=G;exports.Originator$1=D;exports.REJECTED=x;exports.SESSION_EVENT_NAMES=lt;exports.SipConnector=vn;exports.UA_JSSIP_EVENT_NAMES=H;exports.causes=kt;exports.constants=Bt;exports.disableDebug=Qt;exports.enableDebug=xt;exports.eventNames=Yt;exports.hasCanceledStartPresentationError=cn;exports.logger=O;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { TApiEvent, ApiManager } from './ApiManager';
|
|
2
|
+
import { TCallEvent, CallManager } from './CallManager';
|
|
3
|
+
import { TConnectionManagerEvent, ConnectionManager } from './ConnectionManager';
|
|
4
|
+
import { TIncomingCallEvent, IncomingCallManager } from './IncomingCallManager';
|
|
5
|
+
import { PresentationManager } from './PresentationManager';
|
|
6
|
+
import { TContentHint, TOnAddedTransceiver } from './PresentationManager/types';
|
|
7
|
+
import { TGetServerUrl, TJsSIP } from './types';
|
|
8
|
+
declare class SipConnector {
|
|
9
|
+
readonly connectionManager: ConnectionManager;
|
|
10
|
+
readonly callManager: CallManager;
|
|
11
|
+
readonly apiManager: ApiManager;
|
|
12
|
+
readonly incomingCallManager: IncomingCallManager;
|
|
13
|
+
readonly presentationManager: PresentationManager;
|
|
14
|
+
constructor({ JsSIP }: {
|
|
15
|
+
JsSIP: TJsSIP;
|
|
16
|
+
});
|
|
17
|
+
get requestedConnection(): boolean;
|
|
18
|
+
get isPendingConnect(): boolean;
|
|
19
|
+
get isPendingInitUa(): boolean;
|
|
20
|
+
get connectionState(): import('./ConnectionManager/ConnectionStateMachine').EState;
|
|
21
|
+
get isRegistered(): boolean;
|
|
22
|
+
get isRegisterConfig(): boolean;
|
|
23
|
+
get socket(): import('@krivega/jssip').WebSocketInterface | undefined;
|
|
24
|
+
get requestedCall(): boolean;
|
|
25
|
+
get connection(): RTCPeerConnection | undefined;
|
|
26
|
+
get establishedRTCSession(): import('@krivega/jssip').RTCSession | undefined;
|
|
27
|
+
get isCallActive(): boolean;
|
|
28
|
+
get remoteCallerData(): IncomingCallManager['remoteCallerData'];
|
|
29
|
+
get isAvailableIncomingCall(): IncomingCallManager['isAvailableIncomingCall'];
|
|
30
|
+
connect: ConnectionManager['connect'];
|
|
31
|
+
set: ConnectionManager['set'];
|
|
32
|
+
disconnect: () => Promise<void>;
|
|
33
|
+
register: () => Promise<import('@krivega/jssip').RegisteredEvent>;
|
|
34
|
+
unregister: () => Promise<import('@krivega/jssip').UnRegisteredEvent>;
|
|
35
|
+
tryRegister: () => Promise<import('@krivega/jssip').RegisteredEvent>;
|
|
36
|
+
sendOptions: (target: Parameters<ConnectionManager["sendOptions"]>[0], body?: Parameters<ConnectionManager["sendOptions"]>[1], extraHeaders?: Parameters<ConnectionManager["sendOptions"]>[2]) => Promise<void>;
|
|
37
|
+
ping: (body?: Parameters<ConnectionManager["ping"]>[0], extraHeaders?: Parameters<ConnectionManager["ping"]>[1]) => Promise<void>;
|
|
38
|
+
checkTelephony: ConnectionManager['checkTelephony'];
|
|
39
|
+
onConnection<T>(eventName: TConnectionManagerEvent, handler: (data: T) => void): () => void;
|
|
40
|
+
onceConnection<T>(eventName: TConnectionManagerEvent, handler: (data: T) => void): () => void;
|
|
41
|
+
onceRaceConnection<T>(eventNames: TConnectionManagerEvent[], handler: (data: T, eventName: string) => void): () => void;
|
|
42
|
+
waitConnection<T>(eventName: TConnectionManagerEvent): Promise<T>;
|
|
43
|
+
offConnection<T>(eventName: TConnectionManagerEvent, handler: (data: T) => void): void;
|
|
44
|
+
isConfigured: () => boolean;
|
|
45
|
+
getConnectionConfiguration: () => import('./ConnectionManager/ConfigurationManager').IConnectionConfiguration;
|
|
46
|
+
getSipServerUrl: TGetServerUrl;
|
|
47
|
+
call: (params: Parameters<CallManager["startCall"]>[2]) => Promise<RTCPeerConnection>;
|
|
48
|
+
hangUp: CallManager['endCall'];
|
|
49
|
+
answerToIncomingCall: (params: Parameters<CallManager["answerToIncomingCall"]>[1]) => Promise<RTCPeerConnection>;
|
|
50
|
+
declineToIncomingCall: IncomingCallManager['declineToIncomingCall'];
|
|
51
|
+
getEstablishedRTCSession: CallManager['getEstablishedRTCSession'];
|
|
52
|
+
getCallConfiguration: CallManager['getCallConfiguration'];
|
|
53
|
+
getRemoteStreams: CallManager['getRemoteStreams'];
|
|
54
|
+
replaceMediaStream: CallManager['replaceMediaStream'];
|
|
55
|
+
onCall<T>(eventName: TCallEvent, handler: (data: T) => void): () => void;
|
|
56
|
+
onceCall<T>(eventName: TCallEvent, handler: (data: T) => void): () => void;
|
|
57
|
+
onceRaceCall<T>(eventNames: TCallEvent[], handler: (data: T, eventName: string) => void): () => void;
|
|
58
|
+
waitCall<T>(eventName: TCallEvent): Promise<T>;
|
|
59
|
+
offIncomingCall<T>(eventName: TIncomingCallEvent, handler: (data: T) => void): void;
|
|
60
|
+
onIncomingCall<T>(eventName: TIncomingCallEvent, handler: (data: T) => void): () => void;
|
|
61
|
+
onceIncomingCall<T>(eventName: TIncomingCallEvent, handler: (data: T) => void): () => void;
|
|
62
|
+
onceRaceIncomingCall<T>(eventNames: TIncomingCallEvent[], handler: (data: T, eventName: string) => void): () => void;
|
|
63
|
+
waitIncomingCall<T>(eventName: TIncomingCallEvent): Promise<T>;
|
|
64
|
+
offCall<T>(eventName: TCallEvent, handler: (data: T) => void): void;
|
|
65
|
+
startPresentation(stream: MediaStream, options?: {
|
|
66
|
+
isP2P?: boolean;
|
|
67
|
+
isNeedReinvite?: boolean;
|
|
68
|
+
maxBitrate?: number;
|
|
69
|
+
contentHint?: TContentHint;
|
|
70
|
+
sendEncodings?: RTCRtpEncodingParameters[];
|
|
71
|
+
onAddedTransceiver?: TOnAddedTransceiver;
|
|
72
|
+
callLimit?: number;
|
|
73
|
+
}): Promise<MediaStream>;
|
|
74
|
+
stopPresentation(options?: {
|
|
75
|
+
isP2P?: boolean;
|
|
76
|
+
}): Promise<MediaStream | undefined>;
|
|
77
|
+
updatePresentation(stream: MediaStream, options?: {
|
|
78
|
+
isP2P?: boolean;
|
|
79
|
+
isNeedReinvite?: boolean;
|
|
80
|
+
maxBitrate?: number;
|
|
81
|
+
contentHint?: TContentHint;
|
|
82
|
+
sendEncodings?: RTCRtpEncodingParameters[];
|
|
83
|
+
onAddedTransceiver?: TOnAddedTransceiver;
|
|
84
|
+
}): Promise<MediaStream | undefined>;
|
|
85
|
+
waitChannels(...args: Parameters<ApiManager['waitChannels']>): Promise<import('./ApiManager/types').TChannels>;
|
|
86
|
+
waitSyncMediaState(...args: Parameters<ApiManager['waitSyncMediaState']>): Promise<{
|
|
87
|
+
isSyncForced: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
sendDTMF(...args: Parameters<ApiManager['sendDTMF']>): Promise<void>;
|
|
90
|
+
sendChannels(...args: Parameters<ApiManager['sendChannels']>): Promise<void>;
|
|
91
|
+
sendMediaState(...args: Parameters<ApiManager['sendMediaState']>): Promise<void>;
|
|
92
|
+
sendRefusalToTurnOn(...args: Parameters<ApiManager['sendRefusalToTurnOn']>): Promise<void>;
|
|
93
|
+
sendRefusalToTurnOnMic(...args: Parameters<ApiManager['sendRefusalToTurnOnMic']>): Promise<void>;
|
|
94
|
+
sendRefusalToTurnOnCam(...args: Parameters<ApiManager['sendRefusalToTurnOnCam']>): Promise<void>;
|
|
95
|
+
sendMustStopPresentationP2P(...args: Parameters<ApiManager['sendMustStopPresentationP2P']>): Promise<void>;
|
|
96
|
+
sendStoppedPresentationP2P(...args: Parameters<ApiManager['sendStoppedPresentationP2P']>): Promise<void>;
|
|
97
|
+
sendStoppedPresentation(...args: Parameters<ApiManager['sendStoppedPresentation']>): Promise<void>;
|
|
98
|
+
askPermissionToStartPresentationP2P(...args: Parameters<ApiManager['askPermissionToStartPresentationP2P']>): Promise<void>;
|
|
99
|
+
askPermissionToStartPresentation(...args: Parameters<ApiManager['askPermissionToStartPresentation']>): Promise<void>;
|
|
100
|
+
askPermissionToEnableCam(...args: Parameters<ApiManager['askPermissionToEnableCam']>): Promise<void>;
|
|
101
|
+
onApi<T>(eventName: TApiEvent, handler: (data: T) => void): () => void;
|
|
102
|
+
onceApi<T>(eventName: TApiEvent, handler: (data: T) => void): () => void;
|
|
103
|
+
onceRaceApi<T>(eventNames: TApiEvent[], handler: (data: T, eventName: string) => void): () => void;
|
|
104
|
+
waitApi<T>(eventName: TApiEvent): Promise<T>;
|
|
105
|
+
offApi<T>(eventName: TApiEvent, handler: (data: T) => void): void;
|
|
106
|
+
}
|
|
107
|
+
export default SipConnector;
|
|
@@ -2,16 +2,21 @@ import { UA } from '@krivega/jssip';
|
|
|
2
2
|
import { default as SipConnector } from '../SipConnector';
|
|
3
3
|
import { EUseLicense, TContentHint, TSimulcastEncoding } from '../types';
|
|
4
4
|
interface IProxyMethods {
|
|
5
|
-
on: SipConnector['
|
|
6
|
-
once: SipConnector['
|
|
7
|
-
onceRace: SipConnector['
|
|
8
|
-
wait: SipConnector['
|
|
9
|
-
off: SipConnector['
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
on: SipConnector['onConnection'];
|
|
6
|
+
once: SipConnector['onceConnection'];
|
|
7
|
+
onceRace: SipConnector['onceRaceConnection'];
|
|
8
|
+
wait: SipConnector['waitConnection'];
|
|
9
|
+
off: SipConnector['offConnection'];
|
|
10
|
+
onCall: SipConnector['onCall'];
|
|
11
|
+
onceCall: SipConnector['onceCall'];
|
|
12
|
+
onceRaceCall: SipConnector['onceRaceCall'];
|
|
13
|
+
waitCall: SipConnector['waitCall'];
|
|
14
|
+
offCall: SipConnector['offCall'];
|
|
15
|
+
onIncomingCall: SipConnector['onIncomingCall'];
|
|
16
|
+
onceIncomingCall: SipConnector['onceIncomingCall'];
|
|
17
|
+
onceRaceIncomingCall: SipConnector['onceRaceIncomingCall'];
|
|
18
|
+
waitIncomingCall: SipConnector['waitIncomingCall'];
|
|
19
|
+
offIncomingCall: SipConnector['offIncomingCall'];
|
|
15
20
|
sendDTMF: SipConnector['sendDTMF'];
|
|
16
21
|
hangUp: SipConnector['hangUp'];
|
|
17
22
|
declineToIncomingCall: SipConnector['declineToIncomingCall'];
|
|
@@ -24,19 +29,21 @@ interface IProxyMethods {
|
|
|
24
29
|
isRegistered: SipConnector['isRegistered'];
|
|
25
30
|
}
|
|
26
31
|
declare class SipConnectorFacade implements IProxyMethods {
|
|
27
|
-
readonly sipConnector: SipConnector;
|
|
28
|
-
private readonly preferredMimeTypesVideoCodecs?;
|
|
29
|
-
private readonly excludeMimeTypesVideoCodecs?;
|
|
30
32
|
on: IProxyMethods['on'];
|
|
31
33
|
once: IProxyMethods['once'];
|
|
32
34
|
onceRace: IProxyMethods['onceRace'];
|
|
33
35
|
wait: IProxyMethods['wait'];
|
|
34
36
|
off: IProxyMethods['off'];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
onCall: IProxyMethods['onCall'];
|
|
38
|
+
onceCall: IProxyMethods['onceCall'];
|
|
39
|
+
onceRaceCall: IProxyMethods['onceRaceCall'];
|
|
40
|
+
waitCall: IProxyMethods['waitCall'];
|
|
41
|
+
offCall: IProxyMethods['offCall'];
|
|
42
|
+
onIncomingCall: IProxyMethods['onIncomingCall'];
|
|
43
|
+
onceIncomingCall: IProxyMethods['onceIncomingCall'];
|
|
44
|
+
onceRaceIncomingCall: IProxyMethods['onceRaceIncomingCall'];
|
|
45
|
+
waitIncomingCall: IProxyMethods['waitIncomingCall'];
|
|
46
|
+
offIncomingCall: IProxyMethods['offIncomingCall'];
|
|
40
47
|
sendDTMF: IProxyMethods['sendDTMF'];
|
|
41
48
|
hangUp: IProxyMethods['hangUp'];
|
|
42
49
|
declineToIncomingCall: IProxyMethods['declineToIncomingCall'];
|
|
@@ -47,6 +54,9 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
47
54
|
connection: IProxyMethods['connection'];
|
|
48
55
|
isConfigured: IProxyMethods['isConfigured'];
|
|
49
56
|
isRegistered: IProxyMethods['isRegistered'];
|
|
57
|
+
readonly sipConnector: SipConnector;
|
|
58
|
+
private readonly preferredMimeTypesVideoCodecs?;
|
|
59
|
+
private readonly excludeMimeTypesVideoCodecs?;
|
|
50
60
|
constructor(sipConnector: SipConnector, { preferredMimeTypesVideoCodecs, excludeMimeTypesVideoCodecs, }?: {
|
|
51
61
|
preferredMimeTypesVideoCodecs?: string[];
|
|
52
62
|
excludeMimeTypesVideoCodecs?: string[];
|
|
@@ -94,7 +104,7 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
94
104
|
disconnectFromServer: () => Promise<{
|
|
95
105
|
isSuccessful: boolean;
|
|
96
106
|
}>;
|
|
97
|
-
|
|
107
|
+
answerToIncomingCall: (parameters: {
|
|
98
108
|
mediaStream: MediaStream;
|
|
99
109
|
extraHeaders?: string[] | undefined;
|
|
100
110
|
iceServers?: RTCIceServer[];
|
|
@@ -118,7 +128,7 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
118
128
|
isSuccessProgressCall: boolean;
|
|
119
129
|
}) => void;
|
|
120
130
|
onEndedCall?: () => void;
|
|
121
|
-
}) => Promise<RTCPeerConnection |
|
|
131
|
+
}) => Promise<RTCPeerConnection | undefined>;
|
|
122
132
|
updatePresentation: ({ mediaStream, isP2P, maxBitrate, contentHint, simulcastEncodings, degradationPreference, sendEncodings, preferredMimeTypesVideoCodecs, excludeMimeTypesVideoCodecs, }: {
|
|
123
133
|
mediaStream: MediaStream;
|
|
124
134
|
isP2P: boolean;
|
|
@@ -129,8 +139,8 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
129
139
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
130
140
|
preferredMimeTypesVideoCodecs?: string[];
|
|
131
141
|
excludeMimeTypesVideoCodecs?: string[];
|
|
132
|
-
}) => Promise<MediaStream |
|
|
133
|
-
startPresentation: ({ mediaStream, isP2P, maxBitrate, contentHint, simulcastEncodings, degradationPreference, sendEncodings, preferredMimeTypesVideoCodecs, excludeMimeTypesVideoCodecs, }: {
|
|
142
|
+
}) => Promise<MediaStream | undefined>;
|
|
143
|
+
startPresentation: ({ mediaStream, isP2P, maxBitrate, contentHint, simulcastEncodings, degradationPreference, sendEncodings, preferredMimeTypesVideoCodecs, excludeMimeTypesVideoCodecs, callLimit, }: {
|
|
134
144
|
mediaStream: MediaStream;
|
|
135
145
|
isP2P: boolean;
|
|
136
146
|
maxBitrate?: number;
|
|
@@ -140,12 +150,11 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
140
150
|
sendEncodings?: RTCRtpEncodingParameters[];
|
|
141
151
|
preferredMimeTypesVideoCodecs?: string[];
|
|
142
152
|
excludeMimeTypesVideoCodecs?: string[];
|
|
143
|
-
}, options?: {
|
|
144
153
|
callLimit: number;
|
|
145
|
-
}) => Promise<MediaStream |
|
|
154
|
+
}) => Promise<MediaStream | undefined>;
|
|
146
155
|
stopShareSipConnector: ({ isP2P }?: {
|
|
147
156
|
isP2P?: boolean;
|
|
148
|
-
}) => Promise<void | MediaStream>;
|
|
157
|
+
}) => Promise<void | MediaStream | undefined>;
|
|
149
158
|
sendRefusalToTurnOnMic: () => Promise<void>;
|
|
150
159
|
sendRefusalToTurnOnCam: () => Promise<void>;
|
|
151
160
|
sendMediaState: ({ isEnabledCam, isEnabledMic, }: {
|
|
@@ -11,21 +11,22 @@ declare class BaseSession implements RTCSession {
|
|
|
11
11
|
audio: boolean;
|
|
12
12
|
video: boolean;
|
|
13
13
|
};
|
|
14
|
-
constructor({ originator, eventHandlers, }: {
|
|
14
|
+
constructor({ originator, eventHandlers, remoteIdentity, }: {
|
|
15
15
|
originator?: string;
|
|
16
16
|
eventHandlers: TEventHandlers;
|
|
17
|
+
remoteIdentity: NameAddrHeader;
|
|
17
18
|
});
|
|
18
|
-
get C(): SessionStatus;
|
|
19
|
-
get causes(): constants.causes;
|
|
20
|
-
get id(): string;
|
|
21
|
-
set data(_data: unknown);
|
|
22
|
-
get data(): unknown;
|
|
23
19
|
get contact(): string;
|
|
24
20
|
get direction(): SessionDirection;
|
|
25
21
|
get local_identity(): NameAddrHeader;
|
|
26
22
|
get start_time(): Date;
|
|
27
23
|
get end_time(): Date;
|
|
28
24
|
get status(): SessionStatus;
|
|
25
|
+
get C(): SessionStatus;
|
|
26
|
+
get causes(): constants.causes;
|
|
27
|
+
get id(): string;
|
|
28
|
+
get data(): unknown;
|
|
29
|
+
set data(_data: unknown);
|
|
29
30
|
isInProgress(): boolean;
|
|
30
31
|
isEnded(): boolean;
|
|
31
32
|
isReadyToReOffer(): boolean;
|
|
@@ -48,7 +49,7 @@ declare class BaseSession implements RTCSession {
|
|
|
48
49
|
addListener(_event: string | symbol, _listener: (...arguments_: unknown[]) => void): this;
|
|
49
50
|
once(_event: string | symbol, _listener: (...arguments_: unknown[]) => void): this;
|
|
50
51
|
removeListener(_event: string | symbol, _listener: (...arguments_: unknown[]) => void): this;
|
|
51
|
-
off(
|
|
52
|
+
off(eventName: string | symbol, _listener: (...arguments_: unknown[]) => void): this;
|
|
52
53
|
removeAllListeners(_event?: string | symbol): this;
|
|
53
54
|
setMaxListeners(_n: number): this;
|
|
54
55
|
getMaxListeners(): number;
|
|
@@ -59,7 +60,7 @@ declare class BaseSession implements RTCSession {
|
|
|
59
60
|
prependListener(_event: string | symbol, _listener: (...arguments_: unknown[]) => void): this;
|
|
60
61
|
prependOnceListener(_event: string | symbol, _listener: (...arguments_: unknown[]) => void): this;
|
|
61
62
|
eventNames(): (string | symbol)[];
|
|
62
|
-
initEvents(eventHandlers
|
|
63
|
+
initEvents(eventHandlers?: TEventHandlers): void;
|
|
63
64
|
on<T>(eventName: string, handler: (data: T) => void): this;
|
|
64
65
|
trigger(eventName: TEventSession, data?: unknown): void;
|
|
65
66
|
/**
|
|
@@ -71,7 +72,6 @@ declare class BaseSession implements RTCSession {
|
|
|
71
72
|
*/
|
|
72
73
|
sendDTMF(): void;
|
|
73
74
|
startPresentation(stream: MediaStream): Promise<MediaStream>;
|
|
74
|
-
updatePresentation(stream: MediaStream): Promise<MediaStream>;
|
|
75
75
|
stopPresentation(stream: MediaStream): Promise<MediaStream>;
|
|
76
76
|
isEstablished(): boolean;
|
|
77
77
|
}
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
import { IncomingInfoEvent } from '@krivega/jssip';
|
|
1
|
+
import { IncomingInfoEvent, NameAddrHeader } from '@krivega/jssip';
|
|
2
2
|
import { TEventHandlers, default as BaseSession } from './BaseSession.mock';
|
|
3
3
|
export declare const FAILED_CONFERENCE_NUMBER = "777";
|
|
4
4
|
export declare const createDeclineStartPresentationError: () => Error;
|
|
5
5
|
declare class RTCSessionMock extends BaseSession {
|
|
6
|
-
|
|
7
|
-
status_code?: number;
|
|
8
|
-
private isEndedInner;
|
|
6
|
+
private static presentationError?;
|
|
9
7
|
private static startPresentationError?;
|
|
10
8
|
private static countStartPresentationError;
|
|
11
9
|
private static countStartsPresentation;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
mediaStream?: MediaStream;
|
|
15
|
-
eventHandlers: TEventHandlers;
|
|
16
|
-
originator: string;
|
|
17
|
-
});
|
|
18
|
-
static setStartPresentationError(startPresentationError: Error, { count }?: {
|
|
19
|
-
count?: number;
|
|
20
|
-
}): void;
|
|
21
|
-
static resetStartPresentationError(): void;
|
|
22
|
-
startPresentation(stream: MediaStream): Promise<MediaStream>;
|
|
23
|
-
initPeerconnection(mediaStream: MediaStream | undefined): boolean;
|
|
24
|
-
createPeerconnection(sendedStream: MediaStream): void;
|
|
25
|
-
connect(target: string): void;
|
|
10
|
+
url: string;
|
|
11
|
+
status_code?: number;
|
|
26
12
|
/**
|
|
27
13
|
* answer
|
|
28
14
|
*
|
|
@@ -35,11 +21,31 @@ declare class RTCSessionMock extends BaseSession {
|
|
|
35
21
|
answer: jest.Mock<void, [{
|
|
36
22
|
mediaStream: MediaStream;
|
|
37
23
|
}], any>;
|
|
24
|
+
replaceMediaStream: jest.Mock<Promise<void>, [_mediaStream: MediaStream], any>;
|
|
25
|
+
private isEndedInner;
|
|
26
|
+
constructor({ url, mediaStream, eventHandlers, originator, remoteIdentity, }: {
|
|
27
|
+
url?: string;
|
|
28
|
+
mediaStream?: MediaStream;
|
|
29
|
+
eventHandlers: TEventHandlers;
|
|
30
|
+
originator: string;
|
|
31
|
+
remoteIdentity?: NameAddrHeader;
|
|
32
|
+
});
|
|
33
|
+
static setPresentationError(presentationError: Error): void;
|
|
34
|
+
static resetPresentationError(): void;
|
|
35
|
+
static setStartPresentationError(startPresentationError: Error, { count }?: {
|
|
36
|
+
count?: number;
|
|
37
|
+
}): void;
|
|
38
|
+
static resetStartPresentationError(): void;
|
|
39
|
+
startPresentation: (stream: MediaStream) => Promise<MediaStream>;
|
|
40
|
+
stopPresentation: (stream: MediaStream) => Promise<MediaStream>;
|
|
41
|
+
initPeerconnection(mediaStream: MediaStream | undefined): boolean;
|
|
42
|
+
createPeerconnection(sendedStream: MediaStream): void;
|
|
43
|
+
connect(target: string): void;
|
|
38
44
|
terminate({ status_code, cause }?: {
|
|
39
45
|
status_code?: number;
|
|
40
46
|
cause?: string;
|
|
41
47
|
}): this;
|
|
42
|
-
terminateAsync({ status_code, cause }?: {
|
|
48
|
+
terminateAsync({ status_code, cause, }?: {
|
|
43
49
|
status_code?: number;
|
|
44
50
|
cause?: string;
|
|
45
51
|
}): Promise<void>;
|
|
@@ -62,7 +68,6 @@ declare class RTCSessionMock extends BaseSession {
|
|
|
62
68
|
audio: boolean;
|
|
63
69
|
video: boolean;
|
|
64
70
|
};
|
|
65
|
-
replaceMediaStream(_mediaStream: MediaStream): Promise<void>;
|
|
66
71
|
onmute({ audio, video }: {
|
|
67
72
|
audio: boolean;
|
|
68
73
|
video: boolean;
|
|
@@ -12,41 +12,39 @@ declare class UA implements IUA {
|
|
|
12
12
|
private static startError?;
|
|
13
13
|
private static countStartError;
|
|
14
14
|
private static countStarts;
|
|
15
|
-
static setStartError(startError: DisconnectEvent, { count }?: {
|
|
16
|
-
count?: number;
|
|
17
|
-
}): void;
|
|
18
|
-
static resetStartError(): void;
|
|
19
|
-
static setAvailableTelephony(): void;
|
|
20
|
-
static setNotAvailableTelephony(): void;
|
|
21
15
|
events: Events<readonly (keyof UAEventMap)[]>;
|
|
16
|
+
readonly registratorInner: Registrator;
|
|
17
|
+
call: jest.Mock<RTCSessionMock, [url: string, parameters: {
|
|
18
|
+
mediaStream: MediaStream;
|
|
19
|
+
eventHandlers: TEventHandlers;
|
|
20
|
+
}], any>;
|
|
21
|
+
sendOptions: jest.Mock<void, [target: string, body?: string | undefined, options?: Record<string, unknown> | undefined], any>;
|
|
22
|
+
/**
|
|
23
|
+
* start – имитирует запуск UA.
|
|
24
|
+
*/
|
|
25
|
+
start: jest.Mock<void, [], any>;
|
|
26
|
+
/**
|
|
27
|
+
* stop – имитирует остановку UA.
|
|
28
|
+
*/
|
|
29
|
+
stop: jest.Mock<void, [], any>;
|
|
30
|
+
removeAllListeners: jest.Mock<this, [], any>;
|
|
31
|
+
once: jest.Mock<this, [eventName: string, handler: () => void], any>;
|
|
22
32
|
private startedTimeout?;
|
|
23
33
|
private stopedTimeout?;
|
|
24
34
|
private session?;
|
|
25
35
|
private isRegisteredInner?;
|
|
26
36
|
private isConnectedInner?;
|
|
27
37
|
private configuration;
|
|
28
|
-
readonly registratorInner: Registrator;
|
|
29
38
|
constructor(_configuration: UAConfigurationParams);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* stop
|
|
38
|
-
*
|
|
39
|
-
* @returns {undefined}
|
|
40
|
-
*/
|
|
41
|
-
stop(): void;
|
|
42
|
-
call: jest.Mock<RTCSessionMock, [url: string, parameters: {
|
|
43
|
-
mediaStream: MediaStream;
|
|
44
|
-
eventHandlers: TEventHandlers;
|
|
45
|
-
}], any>;
|
|
39
|
+
static setStartError(startError: DisconnectEvent, { count }?: {
|
|
40
|
+
count?: number;
|
|
41
|
+
}): void;
|
|
42
|
+
static resetStartError(): void;
|
|
43
|
+
static setAvailableTelephony(): void;
|
|
44
|
+
static setNotAvailableTelephony(): void;
|
|
45
|
+
static reset(): void;
|
|
46
46
|
on<T extends keyof UAEventMap>(eventName: T, handler: UAEventMap[T]): this;
|
|
47
|
-
once<T extends keyof UAEventMap>(eventName: T, handler: UAEventMap[T]): this;
|
|
48
47
|
off<T extends keyof UAEventMap>(eventName: T, handler: UAEventMap[T]): this;
|
|
49
|
-
removeAllListeners(): this;
|
|
50
48
|
trigger<T extends keyof UAEventMap>(eventName: T, data: Parameters<UAEventMap[T]>[0]): void;
|
|
51
49
|
/**
|
|
52
50
|
* terminateSessions
|
|
@@ -40,7 +40,7 @@ export declare const uaConfigurationWithAuthorization: {
|
|
|
40
40
|
session_timers: boolean;
|
|
41
41
|
sockets: import('./WebSocketInterface.mock').default[];
|
|
42
42
|
user_agent: string;
|
|
43
|
-
|
|
43
|
+
sdpSemantics: string;
|
|
44
44
|
register_expires: number;
|
|
45
45
|
connection_recovery_max_interval: number;
|
|
46
46
|
connection_recovery_min_interval: number;
|
|
@@ -53,7 +53,7 @@ export declare const uaConfigurationWithAuthorizationWithDisplayName: {
|
|
|
53
53
|
session_timers: boolean;
|
|
54
54
|
sockets: import('./WebSocketInterface.mock').default[];
|
|
55
55
|
user_agent: string;
|
|
56
|
-
|
|
56
|
+
sdpSemantics: string;
|
|
57
57
|
register_expires: number;
|
|
58
58
|
connection_recovery_max_interval: number;
|
|
59
59
|
connection_recovery_min_interval: number;
|
|
@@ -64,7 +64,7 @@ export declare const uaConfigurationWithoutAuthorization: {
|
|
|
64
64
|
session_timers: boolean;
|
|
65
65
|
sockets: import('./WebSocketInterface.mock').default[];
|
|
66
66
|
user_agent: string;
|
|
67
|
-
|
|
67
|
+
sdpSemantics: string;
|
|
68
68
|
register_expires: number;
|
|
69
69
|
connection_recovery_max_interval: number;
|
|
70
70
|
connection_recovery_min_interval: number;
|
|
@@ -75,7 +75,7 @@ export declare const uaConfigurationWithoutAuthorizationWithoutDisplayName: {
|
|
|
75
75
|
session_timers: boolean;
|
|
76
76
|
sockets: import('./WebSocketInterface.mock').default[];
|
|
77
77
|
user_agent: string;
|
|
78
|
-
|
|
78
|
+
sdpSemantics: string;
|
|
79
79
|
register_expires: number;
|
|
80
80
|
connection_recovery_max_interval: number;
|
|
81
81
|
connection_recovery_min_interval: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RTCSession, UA } from '@krivega/jssip';
|
|
2
|
-
import { default as
|
|
2
|
+
import { default as UAMock } from './UA.mock';
|
|
3
3
|
import { default as WebSocketInterfaceMock } from './WebSocketInterface.mock';
|
|
4
4
|
declare const jssip: {
|
|
5
5
|
triggerNewInfo: (rtcSession: RTCSession, extraHeaders: [string, string][]) => void;
|
|
6
6
|
triggerNewSipEvent: (ua: UA, extraHeaders: [string, string][]) => void;
|
|
7
|
-
triggerIncomingSession: (ua:
|
|
7
|
+
triggerIncomingSession: (ua: UAMock, { incomingNumber, displayName, host, }: {
|
|
8
8
|
incomingNumber?: string;
|
|
9
9
|
displayName: string;
|
|
10
10
|
host: string;
|
|
@@ -13,7 +13,7 @@ declare const jssip: {
|
|
|
13
13
|
originator: "local" | "remote";
|
|
14
14
|
}) => void;
|
|
15
15
|
WebSocketInterface: typeof WebSocketInterfaceMock;
|
|
16
|
-
UA: typeof
|
|
16
|
+
UA: typeof UAMock;
|
|
17
17
|
C: {
|
|
18
18
|
INVITE: string;
|
|
19
19
|
};
|