sip-connector 6.21.7 → 6.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SipConnector-XqVe938n.cjs +1 -0
- package/dist/{SipConnector-abcad4a1.js → SipConnector-_AhwhWtL.js} +91 -91
- package/dist/SipConnector.d.ts +7 -7
- package/dist/__fixtures__/participantMoveRequests.d.ts +4 -4
- package/dist/constants.d.ts +2 -2
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/eventNames.d.ts +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -6
- package/package.json +17 -17
- package/dist/SipConnector-3317ff75.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Rt=Object.defineProperty;var It=(r,e,t)=>e in r?Rt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>(It(r,typeof e!="symbol"?e+"":e,t),t);const T=require("@krivega/cancelable-promise"),pe=require("events-constructor"),B=require("debug"),mt="Connection Error",He="Request Timeout",ft="SIP Failure Code",Ot="Internal Error",Dt="Busy",V="Rejected",Mt="Redirected",Pt="Unavailable",qe="Not Found",pt="Address Incomplete",vt="Incompatible SDP",bt="Missing SDP",yt="Authentication Error",ke="Terminated",wt="WebRTC Error",Fe="Canceled",Ut="No Answer",Lt="Expires",Ht="No ACK",qt="Dialog Error",kt="User Denied Media Access",We="Bad Media Description",Ft="RTP Timeout",Wt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:pt,AUTHENTICATION_ERROR:yt,BAD_MEDIA_DESCRIPTION:We,BUSY:Dt,BYE:ke,CANCELED:Fe,CONNECTION_ERROR:mt,DIALOG_ERROR:qt,EXPIRES:Lt,INCOMPATIBLE_SDP:vt,INTERNAL_ERROR:Ot,MISSING_SDP:bt,NOT_FOUND:qe,NO_ACK:Ht,NO_ANSWER:Ut,REDIRECTED:Mt,REJECTED:V,REQUEST_TIMEOUT:He,RTP_TIMEOUT:Ft,SIP_FAILURE_CODE:ft,UNAVAILABLE:Pt,USER_DENIED_MEDIA_ACCESS:kt,WEBRTC_ERROR:wt},Symbol.toStringTag,{value:"Module"})),Y="incomingCall",x="declinedIncomingCall",G="failedIncomingCall",$="terminatedIncomingCall",L="connecting",O="connected",N="disconnected",D="newRTCSession",A="registered",X="unregistered",R="registrationFailed",Be="newMessage",J="sipEvent",z="availableSecondRemoteStream",Q="notAvailableSecondRemoteStream",K="mustStopPresentation",M="shareState",j="enterRoom",Z="useLicense",ee="peerconnection:confirmed",te="peerconnection:ontrack",P="channels",se="channels:notify",ne="ended:fromserver",ie="main-cam-control",re="admin-stop-main-cam",oe="admin-start-main-cam",ae="admin-stop-mic",ce="admin-start-mic",p="admin-force-sync-media-state",Ee="participant:added-to-list-moderators",_e="participant:removed-from-list-moderators",he="participant:move-request-to-stream",de="participation:accepting-word-request",le="participation:cancelling-word-request",ue="webcast:started",Te="webcast:stopped",Se="account:changed",Ne="account:deleted",Ce="conference:participant-token-issued",I="ended",Ve="sending",Ye="reinvite",xe="replaces",Ge="refer",$e="progress",Xe="accepted",v="confirmed",b="peerconnection",C="failed",Je="muted",ze="unmuted",ge="newDTMF",Ae="newInfo",Qe="hold",Ke="unhold",je="update",Ze="sdp",et="icecandidate",tt="getusermediafailed",st="peerconnection:createofferfailed",nt="peerconnection:createanswerfailed",it="peerconnection:setlocaldescriptionfailed",rt="peerconnection:setremotedescriptionfailed",ot="presentation:start",at="presentation:started",ct="presentation:end",Re="presentation:ended",y="presentation:failed",Bt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Xe,ACCOUNT_CHANGED:Se,ACCOUNT_DELETED:Ne,ADMIN_FORCE_SYNC_MEDIA_STATE:p,ADMIN_START_MAIN_CAM:oe,ADMIN_START_MIC:ce,ADMIN_STOP_MAIN_CAM:re,ADMIN_STOP_MIC:ae,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:z,CHANNELS:P,CHANNELS_NOTIFY:se,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:Ce,CONFIRMED:v,CONNECTED:O,CONNECTING:L,DECLINED_INCOMING_CALL:x,DISCONNECTED:N,ENDED:I,ENDED_FROM_SERVER:ne,ENTER_ROOM:j,FAILED:C,FAILED_INCOMING_CALL:G,GET_USER_MEDIA_FAILED:tt,HOLD:Qe,ICE_CANDIDATE:et,INCOMING_CALL:Y,MAIN_CAM_CONTROL:ie,MUST_STOP_PRESENTATION_EVENT:K,MUTED:Je,NEW_DTMF:ge,NEW_INFO:Ae,NEW_MESSAGE:Be,NEW_RTC_SESSION:D,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Q,PARTICIPANT_ADDED_TO_LIST_MODERATORS:Ee,PARTICIPANT_MOVE_REQUEST_TO_STREAM:he,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:_e,PARTICIPATION_ACCEPTING_WORD_REQUEST:de,PARTICIPATION_CANCELLING_WORD_REQUEST:le,PEER_CONNECTION:b,PEER_CONNECTION_CONFIRMED:ee,PEER_CONNECTION_CREATE_ANSWER_FAILED:nt,PEER_CONNECTION_CREATE_OFFER_FAILED:st,PEER_CONNECTION_ONTRACK:te,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:it,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:rt,PRESENTATION_END:ct,PRESENTATION_ENDED:Re,PRESENTATION_FAILED:y,PRESENTATION_START:ot,PRESENTATION_STARTED:at,PROGRESS:$e,REFER:Ge,REGISTERED:A,REGISTRATION_FAILED:R,REINVITE:Ye,REPLACES:xe,SDP:Ze,SENDING:Ve,SHARE_STATE:M,SIP_EVENT:J,TERMINATED_INCOMING_CALL:$,UNHOLD:Ke,UNMUTED:ze,UNREGISTERED:X,UPDATE:je,USE_LICENSE:Z,WEBCAST_STARTED:ue,WEBCAST_STOPPED:Te},Symbol.toStringTag,{value:"Module"})),Et=[Y,x,$,G,de,le,he,se,Ce,Se,Ne,ue,Te,Ee,_e],Ie=[L,O,N,D,A,X,R,Be,J],_t=[z,Q,K,M,j,Z,ee,te,P,ne,ie,oe,re,ae,ce,p],me=[I,L,Ve,Ye,xe,Ge,$e,Xe,v,b,C,Je,ze,ge,Ae,Qe,Ke,je,Ze,et,tt,st,nt,it,rt,ot,at,ct,Re,y],fe=[...Ie,...Et],Oe=[...me,..._t],Vt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:Oe,SESSION_JSSIP_EVENT_NAMES:me,SESSION_SYNTHETICS_EVENT_NAMES:_t,UA_EVENT_NAMES:fe,UA_JSSIP_EVENT_NAMES:Ie,UA_SYNTHETICS_EVENT_NAMES:Et},Symbol.toStringTag,{value:"Module"})),Yt=r=>{const e=[];return r&&e.push(`X-Vinteo-Remote: ${r}`),e},xt="content-type",Gt="x-webrtc-enter-room",q="application/vinteo.webrtc.sharedesktop",$t="application/vinteo.webrtc.roomname",Xt="application/vinteo.webrtc.channels",Jt="application/vinteo.webrtc.mediastate",zt="application/vinteo.webrtc.refusal",ve="application/vinteo.webrtc.maincam",Qt="application/vinteo.webrtc.mic",Kt="application/vinteo.webrtc.uselic",jt="X-WEBRTC-USE-LICENSE",be="X-WEBRTC-INPUT-CHANNELS",ye="X-WEBRTC-OUTPUT-CHANNELS",Zt="X-WEBRTC-MAINCAM",es="X-WEBRTC-MIC",we="X-WEBRTC-SYNC",ts="X-WEBRTC-MAINCAM-RESOLUTION",ss="X-WEBRTC-MEDIA-STATE",ns="X-Vinteo-Media-Type",is="X-Vinteo-MainCam-State",rs="X-Vinteo-Mic-State",os="application/vinteo.webrtc.notify",as="X-VINTEO-NOTIFY",m="x-webrtc-share-state",cs=`${m}: LETMESTARTPRESENTATION`,Es=`${m}: STOPPRESENTATION`,ht="YOUCANRECEIVECONTENT",dt="CONTENTEND",_s="YOUMUSTSTOPSENDCONTENT",hs=`${m}: ${ht}`,ds=`${m}: ${dt}`,ls="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",us=`${ls}: LETMESTARTMAINCAM`,De="sip-connector",F=B(De),Ts=()=>{B.enable(`${De}`)},Ss=()=>{B.enable(`-${De}`)};var g=(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))(g||{}),w=(r=>(r.ADMIN_STOP_MIC="ADMINSTOPMIC",r.ADMIN_START_MIC="ADMINSTARTMIC",r))(w||{}),U=(r=>(r.ADMIN_SYNC_FORCED="1",r.ADMIN_SYNC_NOT_FORCED="0",r))(U||{}),lt=(r=>(r.AUDIO="AUDIO",r.VIDEO="VIDEO",r.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",r))(lt||{});function Ns(r){return e=>`sip:${e}@${r}`}const Cs=(r,e)=>()=>Math.floor(Math.random()*(e-r))+r,Ue=r=>r.trim().replaceAll(" ","_"),gs=Cs(1e5,99999999),k=(r,{videoMode:e,audioMode:t}={})=>{if(!r||e==="recvonly"&&t==="recvonly")return;const s=t==="recvonly"?[]:r.getAudioTracks(),n=e==="recvonly"?[]:r.getVideoTracks(),o=[...s,...n],a=new MediaStream(o);return a.getTracks=()=>[...a.getAudioTracks(),...a.getVideoTracks()],a},As=r=>r.some(t=>{const{kind:s}=t;return s==="video"}),Rs="Error decline with 603",Is=r=>r.message===Rs,ms=(r,e)=>r.find(t=>t.track&&e.getTracks().includes(t.track)),ut=1,Tt=r=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==r,fs=Tt(ut),Os=(r,e)=>{const t=r===void 0?void 0:Math.max(r,ut);if(t!==void 0&&fs(t,e))return t},Ds=Tt(),Ms=(r,e)=>{if(Ds(r,e))return r},St=async(r,e,t)=>{const s=r.getParameters();(s.encodings===void 0||s.encodings.length===0)&&(s.encodings=[{}]);const[n]=s.encodings,o=n.scaleResolutionDownBy,a=Os(e.scaleResolutionDownBy,o);let c=!1;a!==void 0&&(s.encodings[0].scaleResolutionDownBy=a,c=!0);const E=n.maxBitrate,_=Ms(e.maxBitrate,E);return _!==void 0&&(s.encodings[0].maxBitrate=_,c=!0),c?(t&&t(s),r.setParameters(s).then(()=>({parameters:s,isChanged:c}))):{parameters:s,isChanged:c}},Ps=async(r,e,t)=>{const s=ms(r,e);if(s)return St(s,{maxBitrate:t})},ps=486,vs=487,W="local",Le="remote",bs=(r=new Error)=>{const{originator:e,cause:t}=r;return T.isCanceledError(r)?!0:typeof t=="string"?t===He||t===V||e===W&&(t===Fe||t===ke):!1},S="SipConnector",ys="channels",ws="WebcastStarted",Us="WebcastStopped",Ls="accountChanged",Hs="accountDeleted",qs="addedToListModerators",ks="removedFromListModerators",Fs="ParticipationRequestAccepted",Ws="ParticipationRequestRejected",Bs="ParticipantMovedToWebcast",Vs="ConferenceParticipantTokenIssued";class Ys{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,"_cancelableCreateUa");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=>(this._cancelRequests(),this._cancelableConnect.request(e)));i(this,"createUa",async e=>this._cancelableCreateUa.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(L,void 0);try{await this.unregister()}catch(e){F("tryRegister",e)}return this.register()});i(this,"declineToIncomingCall",async({statusCode:e=vs}={})=>new Promise((t,s)=>{if(!this.isAvailableIncomingCall){s(new Error("no incomingSession"));return}const n=this.incomingSession,o=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(x,o),t(n.terminate({status_code:e}))}));i(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:ps}));i(this,"removeIncomingSession",()=>{delete this.incomingSession});i(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===Le){this.incomingSession=t;const s=this.remoteCallerData;t.on(C,n=>{this.removeIncomingSession(),n.originator===W?this._uaEvents.trigger($,s):this._uaEvents.trigger(G,s)}),this._uaEvents.trigger(Y,s)}});i(this,"_connect",async e=>this.createUa(e).then(async()=>this._start()));i(this,"_createUa",async({displayName:e="",user:t,password:s,register:n=!1,sipServerUrl:o,sipWebSocketServerURL:a,remoteAddress:c,extraHeaders:E=[],sdpSemantics:_="plan-b",sessionTimers:h=!1,registerExpires:d=60*5,connectionRecoveryMinInterval:l=2,connectionRecoveryMaxInterval:u=6,userAgent:f})=>{if(!o)throw new Error("sipServerUrl is required");if(!a)throw new Error("sipWebSocketServerURL is required");if(n&&!t)throw new Error("user is required for authorized connection");if(n&&!s)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:o,displayName:e,register:n,user:t,password:s},this._init({sipServerUrl:o,sipWebSocketServerURL:a});const H=n&&t?t.trim():`${gs()}`,Me={password:s,register:n,display_name:Ue(e),user_agent:f,sdp_semantics:_,sockets:[this.socket],uri:this.getSipServerUrl(H),session_timers:h,register_expires:d,connection_recovery_min_interval:l,connection_recovery_max_interval:u};this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!Me.register,this.ua=new this.JsSIP.UA(Me),this._uaEvents.eachTriggers((Ct,gt)=>{const Pe=Ie.find(At=>At===gt);Pe&&this.ua&&this.ua.on(Pe,Ct)});const Nt=[...Yt(c),...E];return this.ua.registrator().setExtraHeaders(Nt),this.ua});i(this,"_start",async()=>new Promise((e,t)=>{const{ua:s}=this;if(!s){t(new Error("this.ua is not initialized"));return}const n=()=>{c(),e(s)},o=E=>{c(),t(E)},a=()=>{this.isRegisterConfig?(this.on(A,n),this.on(R,o)):this.on(O,n),this.on(N,o)},c=()=>{this.off(A,n),this.off(R,o),this.off(O,n),this.off(N,o)};a(),this.on(D,this.handleNewRTCSession),s.start()}));i(this,"_set",async({displayName:e,password:t})=>new Promise((s,n)=>{const{ua:o}=this;if(!o){n(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",Ue(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=o.set("password",t),this._connectionConfiguration.password=t);const E=a||c;c&&this.isRegisterConfig?this.register().then(()=>{s(E)}).catch(n):E?s(E):n(E)}));i(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());i(this,"_disconnect",async()=>{this.off(D,this.handleNewRTCSession);const e=new Promise(t=>{this.once(N,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(N,void 0)):this._uaEvents.trigger(N,void 0),e});i(this,"_call",async({number:e,mediaStream:t,extraHeaders:s=[],ontrack:n,iceServers:o,videoMode:a,audioMode:c,degradationPreference:E,offerToReceiveAudio:_=!0,offerToReceiveVideo:h=!0})=>new Promise((d,l)=>{const{ua:u}=this;if(!u){l(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:n}).then(d).catch(l),this.session=u.call(this.getSipServerUrl(e),{extraHeaders:s,mediaStream:k(t,{videoMode:a,audioMode:c}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,degradationPreference:E,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:_,offerToReceiveVideo:h}})}));i(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:s=[],iceServers:n,videoMode:o,audioMode:a,degradationPreference:c})=>new Promise((E,_)=>{if(!this.isAvailableIncomingCall){_(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:h}=this;if(!h){_(new Error("No session established"));return}this._sessionEvents.eachTriggers((l,u)=>{const f=me.find(H=>H===u);f&&h.on(f,l)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=h.remote_identity.uri.user,this._handleCall({ontrack:t}).then(E).catch(_);const d=k(e,{videoMode:o,audioMode:a});h.answer({extraHeaders:s,videoMode:o,audioMode:a,degradationPreference:c,mediaStream:d,pcConfig:{iceServers:n}})}));i(this,"_handleCall",async({ontrack:e})=>new Promise((t,s)=>{const n=()=>{this.onSession(b,h),this.onSession(v,d)},o=()=>{this.offSession(b,h),this.offSession(v,d)},a=()=>{this.onSession(C,E),this.onSession(I,E)},c=()=>{this.offSession(C,E),this.offSession(I,E)},E=l=>{o(),c(),s(l)};let _;const h=({peerconnection:l})=>{_=l,_.ontrack=u=>{this._sessionEvents.trigger(te,_),e&&e(u)}},d=()=>{_&&this._sessionEvents.trigger(ee,_),o(),c(),t(_)};n(),a()}));i(this,"_restoreSession",()=>{this._resetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});i(this,"_sendDTMF",async e=>new Promise((t,s)=>{const{session:n}=this;if(!n){s(new Error("No session established"));return}this.onceSession(ge,({originator:o})=>{o===W&&t()}),n.sendDTMF(e,{duration:120,interToneGap:600})}));i(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;this._streamPresentationCurrent&&await this.stopPresentation(),this._restoreSession(),e.isEnded()||e.terminate()}});i(this,"_handleShareState",e=>{switch(e){case ht:{this._sessionEvents.trigger(z,void 0);break}case dt:{this._sessionEvents.trigger(Q,void 0);break}case _s:{this._sessionEvents.trigger(K,void 0);break}}});i(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(be),s=e.getHeader(ye);if(t&&s){const n={inputChannels:t,outputChannels:s};this._sessionEvents.trigger(P,n)}});i(this,"_handleNotify",e=>{switch(e.cmd){case ys:{const t=e;this._triggerChannelsNotify(t);break}case ws:{const t=e;this._triggerWebcastStartedNotify(t);break}case Us:{const t=e;this._triggerWebcastStoppedNotify(t);break}case qs:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case ks:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case Fs:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case Ws:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case Bs:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case Ls:{this._triggerAccountChangedNotify();break}case Hs:{this._triggerAccountDeletedNotify();break}case Vs:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:F("unknown cmd",e.cmd)}});i(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(_e,t)});i(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Ee,t)});i(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const s={conference:e,type:t};this._uaEvents.trigger(ue,s)});i(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const s={conference:e,type:t};this._uaEvents.trigger(Te,s)});i(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Se,void 0)});i(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(Ne,void 0)});i(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:s}})=>{const n={conference:e,participant:t,jwt:s};this._uaEvents.trigger(Ce,n)});i(this,"_triggerChannelsNotify",e=>{const t=e.input,s=e.output,n={inputChannels:t,outputChannels:s};this._uaEvents.trigger(se,n)});i(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(de,t)});i(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(le,t)});i(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(he,t)});i(this,"_triggerEnterRoom",e=>{const t=e.getHeader(Gt);this._sessionEvents.trigger(j,t)});i(this,"_triggerShareState",e=>{const t=e.getHeader(m);this._sessionEvents.trigger(M,t)});i(this,"_triggerMainCamControl",e=>{const t=e.getHeader(Zt),s=e.getHeader(we),n=s===U.ADMIN_SYNC_FORCED;if(t===g.ADMIN_START_MAIN_CAM)this._sessionEvents.trigger(oe,{isSyncForced:n});else if(t===g.ADMIN_STOP_MAIN_CAM)this._sessionEvents.trigger(re,{isSyncForced:n});else if((t===g.RESUME_MAIN_CAM||t===g.PAUSE_MAIN_CAM)&&s)this._sessionEvents.trigger(p,{isSyncForced:n});else{const o=e.getHeader(ts);this._sessionEvents.trigger(ie,{mainCam:t,resolutionMainCam:o})}});i(this,"_triggerMicControl",e=>{const t=e.getHeader(es),n=e.getHeader(we)===U.ADMIN_SYNC_FORCED;t===w.ADMIN_START_MIC?this._sessionEvents.trigger(ce,{isSyncForced:n}):t===w.ADMIN_STOP_MIC&&this._sessionEvents.trigger(ae,{isSyncForced:n})});i(this,"_triggerUseLicense",e=>{const t=e.getHeader(jt);this._sessionEvents.trigger(Z,t)});i(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:s}=e,n=s.getHeader(xt);if(n)switch(n){case $t:{this._triggerEnterRoom(s),this._maybeTriggerChannels(s);break}case os:{this._maybeHandleNotify(s);break}case q:{this._triggerShareState(s);break}case ve:{this._triggerMainCamControl(s);break}case Qt:{this._triggerMicControl(s);break}case Kt:{this._triggerUseLicense(s);break}}});i(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});i(this,"_maybeHandleNotify",e=>{const t=e.getHeader(as);if(t){const s=JSON.parse(t);this._handleNotify(s)}});i(this,"_handleEnded",e=>{const{originator:t}=e;t===Le&&this._sessionEvents.trigger(ne,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new pe(Oe),this._uaEvents=new pe(fe),this._cancelableConnect=new T.CancelableRequest(this._connect,{moduleName:S,afterCancelRequest:()=>{this._cancelableCreateUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableCreateUa=new T.CancelableRequest(this._createUa,{moduleName:S}),this._cancelableDisconnect=new T.CancelableRequest(this._disconnect,{moduleName:S}),this._cancelableSet=new T.CancelableRequest(this._set,{moduleName:S}),this._cancelableCall=new T.CancelableRequest(this._call,{moduleName:S}),this._cancelableAnswer=new T.CancelableRequest(this._answer,{moduleName:S}),this._cancelableSendDTMF=new T.CancelableRequest(this._sendDTMF,{moduleName:S}),this.onSession(M,this._handleShareState),this.onSession(Ae,this._handleNewInfo),this.on(J,this._handleSipEvent),this.onSession(C,this._handleEnded),this.onSession(I,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(A,e),this.ua.on(R,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(X,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,s){if(!this.ua)throw new Error("is not connected");return new Promise((n,o)=>{try{this.ua.sendOptions(e,t,{extraHeaders:s,eventHandlers:{succeeded:()=>{n()},failed:o}})}catch(a){o(a)}})}async ping(e,t){var n;if(!((n=this.ua)!=null&&n.configuration.uri))throw new Error("is not connected");const s=this.ua.configuration.uri;return this.sendOptions(s,e,t)}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");return this.session.replaceMediaStream(e,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[us];return this.session.sendInfo(ve,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(s=>{if(Is(s))throw s})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentation(e,t,{maxBitrate:s,degradationPreference:n,isNeedReinvite:o=!0,isP2P:a=!1}){const c=k(t);this._streamPresentationCurrent=c;const E=a?[hs]:[cs],_=e.sendInfo(q,void 0,{extraHeaders:E}).then(async()=>e.startPresentation(c,o,n)).then(async()=>{const{connection:h}=this;if(!h||s===void 0)return;const d=h.getSenders();return Ps(d,t,s)}).then(()=>t).catch(h=>{throw this._sessionEvents.trigger(y,h),h});return this.promisePendingStartPresentation=_,_.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t=!0,isP2P:s=!1,maxBitrate:n,degradationPreference:o}={}){const a=this.establishedSession;if(!a)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return this._sendPresentation(a,e,{isNeedReinvite:t,isP2P:s,maxBitrate:n,degradationPreference:o})}async stopPresentation({isP2P:e=!1}={}){const t=this._streamPresentationCurrent;let s=this.promisePendingStartPresentation??Promise.resolve();const n=e?[ds]:[Es],o=this.establishedSession;return o&&t&&(s=s.then(async()=>o.sendInfo(q,void 0,{extraHeaders:n})).then(async()=>o.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(y,a),a})),!o&&t&&this._sessionEvents.trigger(Re,t),this.promisePendingStopPresentation=s,s.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t=!1,maxBitrate:s,degradationPreference:n}={}){const o=this.establishedSession;if(!o)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(o,e,{isP2P:t,maxBitrate:s,degradationPreference:n,isNeedReinvite:!1})}_resetPresentation(){delete this._streamPresentationCurrent,this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}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:s})=>s);return As(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,s,n,o,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(n=(s=this.incomingSession)==null?void 0:s.remote_identity)==null?void 0:n.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._cancelableCreateUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){return this.session&&this.session.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}_init({sipServerUrl:e,sipWebSocketServerURL:t}){this.getSipServerUrl=Ns(e),this.socket=new this.JsSIP.WebSocketInterface(t)}_generateStream(e,t){const{id:s}=e,n=this._remoteStreams[s]||new MediaStream;return t&&n.addTrack(t),n.addTrack(e),this._remoteStreams[s]=n,n}_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,n)=>{if(s.kind==="audio")return;const o=s,a=e[n-1];let c;a&&a.kind==="audio"&&(c=a);const E=this._generateStream(o,c);t.push(E)}),t}_generateAudioStreams(e){return e.map(s=>this._generateAudioStream(s))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectRequests()}_cancelConnectRequests(){this._cancelableConnect.cancelRequest()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(P)}async waitSyncMediaState(){return this.waitSession(p)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const s=`${be}: ${e}`,n=`${ye}: ${t}`,o=[s,n];return this.session.sendInfo(Xt,void 0,{extraHeaders:o})}async sendMediaState({cam:e,mic:t},s={}){if(!this.session)throw new Error("No session established");const n=`${ss}: currentstate`,o=`${is}: ${Number(e)}`,a=`${rs}: ${Number(t)}`,c=[n,o,a];return this.session.sendInfo(Jt,void 0,{noTerminateWhenError:!0,...s,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${ns}: ${e==="mic"?0:1}`];return this.session.sendInfo(zt,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=We;exports.EEventsMainCAM=g;exports.EEventsMic=w;exports.EEventsSyncMediaState=U;exports.EUseLicense=lt;exports.NOT_FOUND=qe;exports.REJECTED=V;exports.SESSION_EVENT_NAMES=Oe;exports.SipConnector=Ys;exports.UA_EVENT_NAMES=fe;exports.causes=Wt;exports.constants=Bt;exports.disableDebug=Ss;exports.enableDebug=Ts;exports.eventNames=Vt;exports.hasCanceledCallError=bs;exports.logger=F;exports.setEncodingsToSender=St;
|
|
@@ -4,32 +4,32 @@ var i = (r, e, t) => (gt(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
|
4
4
|
import { CancelableRequest as T, isCanceledError as Ct } from "@krivega/cancelable-promise";
|
|
5
5
|
import Oe from "events-constructor";
|
|
6
6
|
import W from "debug";
|
|
7
|
-
const At = "Connection Error",
|
|
7
|
+
const At = "Connection Error", be = "Request Timeout", Rt = "SIP Failure Code", It = "Internal Error", mt = "Busy", Ue = "Rejected", ft = "Redirected", Ot = "Unavailable", Dt = "Not Found", Mt = "Address Incomplete", Pt = "Incompatible SDP", pt = "Missing SDP", vt = "Authentication Error", Le = "Terminated", wt = "WebRTC Error", He = "Canceled", yt = "No Answer", bt = "Expires", Ut = "No ACK", Lt = "Dialog Error", Ht = "User Denied Media Access", kt = "Bad Media Description", qt = "RTP Timeout", Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8
8
|
__proto__: null,
|
|
9
|
-
ADDRESS_INCOMPLETE:
|
|
9
|
+
ADDRESS_INCOMPLETE: Mt,
|
|
10
10
|
AUTHENTICATION_ERROR: vt,
|
|
11
11
|
BAD_MEDIA_DESCRIPTION: kt,
|
|
12
|
-
BUSY:
|
|
12
|
+
BUSY: mt,
|
|
13
13
|
BYE: Le,
|
|
14
14
|
CANCELED: He,
|
|
15
15
|
CONNECTION_ERROR: At,
|
|
16
16
|
DIALOG_ERROR: Lt,
|
|
17
|
-
EXPIRES:
|
|
17
|
+
EXPIRES: bt,
|
|
18
18
|
INCOMPATIBLE_SDP: Pt,
|
|
19
|
-
INTERNAL_ERROR:
|
|
19
|
+
INTERNAL_ERROR: It,
|
|
20
20
|
MISSING_SDP: pt,
|
|
21
|
-
NOT_FOUND:
|
|
21
|
+
NOT_FOUND: Dt,
|
|
22
22
|
NO_ACK: Ut,
|
|
23
23
|
NO_ANSWER: yt,
|
|
24
24
|
REDIRECTED: ft,
|
|
25
25
|
REJECTED: Ue,
|
|
26
|
-
REQUEST_TIMEOUT:
|
|
27
|
-
RTP_TIMEOUT:
|
|
26
|
+
REQUEST_TIMEOUT: be,
|
|
27
|
+
RTP_TIMEOUT: qt,
|
|
28
28
|
SIP_FAILURE_CODE: Rt,
|
|
29
29
|
UNAVAILABLE: Ot,
|
|
30
30
|
USER_DENIED_MEDIA_ACCESS: Ht,
|
|
31
|
-
WEBRTC_ERROR:
|
|
32
|
-
}, Symbol.toStringTag, { value: "Module" })), B = "incomingCall", V = "declinedIncomingCall", Y = "failedIncomingCall", x = "terminatedIncomingCall",
|
|
31
|
+
WEBRTC_ERROR: wt
|
|
32
|
+
}, Symbol.toStringTag, { value: "Module" })), B = "incomingCall", V = "declinedIncomingCall", Y = "failedIncomingCall", x = "terminatedIncomingCall", b = "connecting", O = "connected", N = "disconnected", D = "newRTCSession", A = "registered", G = "unregistered", R = "registrationFailed", ke = "newMessage", $ = "sipEvent", X = "availableSecondRemoteStream", J = "notAvailableSecondRemoteStream", z = "mustStopPresentation", M = "shareState", Q = "enterRoom", K = "useLicense", j = "peerconnection:confirmed", Z = "peerconnection:ontrack", P = "channels", ee = "channels:notify", te = "ended:fromserver", se = "main-cam-control", ne = "admin-stop-main-cam", ie = "admin-start-main-cam", re = "admin-stop-mic", oe = "admin-start-mic", p = "admin-force-sync-media-state", ae = "participant:added-to-list-moderators", ce = "participant:removed-from-list-moderators", Ee = "participant:move-request-to-stream", _e = "participation:accepting-word-request", he = "participation:cancelling-word-request", de = "webcast:started", le = "webcast:stopped", ue = "account:changed", Te = "account:deleted", Se = "conference:participant-token-issued", I = "ended", qe = "sending", Fe = "reinvite", We = "replaces", Be = "refer", Ve = "progress", Ye = "accepted", v = "confirmed", w = "peerconnection", g = "failed", xe = "muted", Ge = "unmuted", Ne = "newDTMF", ge = "newInfo", $e = "hold", Xe = "unhold", Je = "update", ze = "sdp", Qe = "icecandidate", Ke = "getusermediafailed", je = "peerconnection:createofferfailed", Ze = "peerconnection:createanswerfailed", et = "peerconnection:setlocaldescriptionfailed", tt = "peerconnection:setremotedescriptionfailed", st = "presentation:start", nt = "presentation:started", it = "presentation:end", Ce = "presentation:ended", y = "presentation:failed", xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
33
33
|
__proto__: null,
|
|
34
34
|
ACCEPTED: Ye,
|
|
35
35
|
ACCOUNT_CHANGED: ue,
|
|
@@ -45,16 +45,16 @@ const At = "Connection Error", we = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
45
45
|
CONFERENCE_PARTICIPANT_TOKEN_ISSUED: Se,
|
|
46
46
|
CONFIRMED: v,
|
|
47
47
|
CONNECTED: O,
|
|
48
|
-
CONNECTING:
|
|
48
|
+
CONNECTING: b,
|
|
49
49
|
DECLINED_INCOMING_CALL: V,
|
|
50
50
|
DISCONNECTED: N,
|
|
51
|
-
ENDED:
|
|
51
|
+
ENDED: I,
|
|
52
52
|
ENDED_FROM_SERVER: te,
|
|
53
53
|
ENTER_ROOM: Q,
|
|
54
54
|
FAILED: g,
|
|
55
55
|
FAILED_INCOMING_CALL: Y,
|
|
56
56
|
GET_USER_MEDIA_FAILED: Ke,
|
|
57
|
-
HOLD:
|
|
57
|
+
HOLD: $e,
|
|
58
58
|
ICE_CANDIDATE: Qe,
|
|
59
59
|
INCOMING_CALL: B,
|
|
60
60
|
MAIN_CAM_CONTROL: se,
|
|
@@ -63,14 +63,14 @@ const At = "Connection Error", we = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
63
63
|
NEW_DTMF: Ne,
|
|
64
64
|
NEW_INFO: ge,
|
|
65
65
|
NEW_MESSAGE: ke,
|
|
66
|
-
NEW_RTC_SESSION:
|
|
66
|
+
NEW_RTC_SESSION: D,
|
|
67
67
|
NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: J,
|
|
68
68
|
PARTICIPANT_ADDED_TO_LIST_MODERATORS: ae,
|
|
69
|
-
|
|
70
|
-
PARTICIPANT_MOVE_REQUEST_TO_CONFERENCE: Ee,
|
|
71
|
-
PARTICIPANT_MOVE_REQUEST_TO_STREAM: _e,
|
|
69
|
+
PARTICIPANT_MOVE_REQUEST_TO_STREAM: Ee,
|
|
72
70
|
PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: ce,
|
|
73
|
-
|
|
71
|
+
PARTICIPATION_ACCEPTING_WORD_REQUEST: _e,
|
|
72
|
+
PARTICIPATION_CANCELLING_WORD_REQUEST: he,
|
|
73
|
+
PEER_CONNECTION: w,
|
|
74
74
|
PEER_CONNECTION_CONFIRMED: j,
|
|
75
75
|
PEER_CONNECTION_CREATE_ANSWER_FAILED: Ze,
|
|
76
76
|
PEER_CONNECTION_CREATE_OFFER_FAILED: je,
|
|
@@ -86,16 +86,16 @@ const At = "Connection Error", we = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
86
86
|
REFER: Be,
|
|
87
87
|
REGISTERED: A,
|
|
88
88
|
REGISTRATION_FAILED: R,
|
|
89
|
-
REINVITE:
|
|
89
|
+
REINVITE: Fe,
|
|
90
90
|
REPLACES: We,
|
|
91
91
|
SDP: ze,
|
|
92
|
-
SENDING:
|
|
93
|
-
SHARE_STATE:
|
|
94
|
-
SIP_EVENT:
|
|
92
|
+
SENDING: qe,
|
|
93
|
+
SHARE_STATE: M,
|
|
94
|
+
SIP_EVENT: $,
|
|
95
95
|
TERMINATED_INCOMING_CALL: x,
|
|
96
96
|
UNHOLD: Xe,
|
|
97
|
-
UNMUTED:
|
|
98
|
-
UNREGISTERED:
|
|
97
|
+
UNMUTED: Ge,
|
|
98
|
+
UNREGISTERED: G,
|
|
99
99
|
UPDATE: Je,
|
|
100
100
|
USE_LICENSE: K,
|
|
101
101
|
WEBCAST_STARTED: de,
|
|
@@ -105,8 +105,8 @@ const At = "Connection Error", we = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
105
105
|
V,
|
|
106
106
|
x,
|
|
107
107
|
Y,
|
|
108
|
-
he,
|
|
109
108
|
_e,
|
|
109
|
+
he,
|
|
110
110
|
Ee,
|
|
111
111
|
ee,
|
|
112
112
|
Se,
|
|
@@ -117,20 +117,20 @@ const At = "Connection Error", we = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
117
117
|
ae,
|
|
118
118
|
ce
|
|
119
119
|
], Ae = [
|
|
120
|
-
|
|
120
|
+
b,
|
|
121
121
|
O,
|
|
122
122
|
N,
|
|
123
|
-
|
|
123
|
+
D,
|
|
124
124
|
A,
|
|
125
|
-
|
|
125
|
+
G,
|
|
126
126
|
R,
|
|
127
127
|
ke,
|
|
128
|
-
|
|
128
|
+
$
|
|
129
129
|
], ot = [
|
|
130
130
|
X,
|
|
131
131
|
J,
|
|
132
132
|
z,
|
|
133
|
-
|
|
133
|
+
M,
|
|
134
134
|
Q,
|
|
135
135
|
K,
|
|
136
136
|
j,
|
|
@@ -144,22 +144,22 @@ const At = "Connection Error", we = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
144
144
|
oe,
|
|
145
145
|
p
|
|
146
146
|
], Re = [
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
Fe,
|
|
147
|
+
I,
|
|
148
|
+
b,
|
|
150
149
|
qe,
|
|
150
|
+
Fe,
|
|
151
151
|
We,
|
|
152
152
|
Be,
|
|
153
153
|
Ve,
|
|
154
154
|
Ye,
|
|
155
155
|
v,
|
|
156
|
-
|
|
156
|
+
w,
|
|
157
157
|
g,
|
|
158
158
|
xe,
|
|
159
|
-
|
|
159
|
+
Ge,
|
|
160
160
|
Ne,
|
|
161
161
|
ge,
|
|
162
|
-
|
|
162
|
+
$e,
|
|
163
163
|
Xe,
|
|
164
164
|
Je,
|
|
165
165
|
ze,
|
|
@@ -177,7 +177,7 @@ const At = "Connection Error", we = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
177
177
|
], at = [...Ae, ...rt], ct = [
|
|
178
178
|
...Re,
|
|
179
179
|
...ot
|
|
180
|
-
],
|
|
180
|
+
], Gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
181
181
|
__proto__: null,
|
|
182
182
|
SESSION_EVENT_NAMES: ct,
|
|
183
183
|
SESSION_JSSIP_EVENT_NAMES: Re,
|
|
@@ -185,19 +185,19 @@ const At = "Connection Error", we = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
185
185
|
UA_EVENT_NAMES: at,
|
|
186
186
|
UA_JSSIP_EVENT_NAMES: Ae,
|
|
187
187
|
UA_SYNTHETICS_EVENT_NAMES: rt
|
|
188
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
188
|
+
}, Symbol.toStringTag, { value: "Module" })), Ft = (r) => {
|
|
189
189
|
const e = [];
|
|
190
190
|
return r && e.push(`X-Vinteo-Remote: ${r}`), e;
|
|
191
|
-
}, Wt = "content-type", Bt = "x-webrtc-enter-room", L = "application/vinteo.webrtc.sharedesktop", Vt = "application/vinteo.webrtc.roomname", Yt = "application/vinteo.webrtc.channels", xt = "application/vinteo.webrtc.mediastate",
|
|
192
|
-
W.enable(`${
|
|
191
|
+
}, Wt = "content-type", Bt = "x-webrtc-enter-room", L = "application/vinteo.webrtc.sharedesktop", Vt = "application/vinteo.webrtc.roomname", Yt = "application/vinteo.webrtc.channels", xt = "application/vinteo.webrtc.mediastate", Gt = "application/vinteo.webrtc.refusal", De = "application/vinteo.webrtc.maincam", $t = "application/vinteo.webrtc.mic", Xt = "application/vinteo.webrtc.uselic", Jt = "X-WEBRTC-USE-LICENSE", Me = "X-WEBRTC-INPUT-CHANNELS", Pe = "X-WEBRTC-OUTPUT-CHANNELS", zt = "X-WEBRTC-MAINCAM", Qt = "X-WEBRTC-MIC", pe = "X-WEBRTC-SYNC", Kt = "X-WEBRTC-MAINCAM-RESOLUTION", jt = "X-WEBRTC-MEDIA-STATE", Zt = "X-Vinteo-Media-Type", es = "X-Vinteo-MainCam-State", ts = "X-Vinteo-Mic-State", ss = "application/vinteo.webrtc.notify", ns = "X-VINTEO-NOTIFY", m = "x-webrtc-share-state", is = `${m}: LETMESTARTPRESENTATION`, rs = `${m}: STOPPRESENTATION`, Et = "YOUCANRECEIVECONTENT", _t = "CONTENTEND", os = "YOUMUSTSTOPSENDCONTENT", as = `${m}: ${Et}`, cs = `${m}: ${_t}`, Es = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", _s = `${Es}: LETMESTARTMAINCAM`, Ie = "sip-connector", ve = W(Ie), $s = () => {
|
|
192
|
+
W.enable(`${Ie}`);
|
|
193
193
|
}, Xs = () => {
|
|
194
|
-
W.enable(`-${
|
|
194
|
+
W.enable(`-${Ie}`);
|
|
195
195
|
};
|
|
196
|
-
var C = /* @__PURE__ */ ((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))(C || {}), k = /* @__PURE__ */ ((r) => (r.ADMIN_STOP_MIC = "ADMINSTOPMIC", r.ADMIN_START_MIC = "ADMINSTARTMIC", r))(k || {}),
|
|
196
|
+
var C = /* @__PURE__ */ ((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))(C || {}), k = /* @__PURE__ */ ((r) => (r.ADMIN_STOP_MIC = "ADMINSTOPMIC", r.ADMIN_START_MIC = "ADMINSTARTMIC", r))(k || {}), q = /* @__PURE__ */ ((r) => (r.ADMIN_SYNC_FORCED = "1", r.ADMIN_SYNC_NOT_FORCED = "0", r))(q || {}), hs = /* @__PURE__ */ ((r) => (r.AUDIO = "AUDIO", r.VIDEO = "VIDEO", r.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", r))(hs || {});
|
|
197
197
|
function ds(r) {
|
|
198
198
|
return (e) => `sip:${e}@${r}`;
|
|
199
199
|
}
|
|
200
|
-
const ls = (r, e) => () => Math.floor(Math.random() * (e - r)) + r,
|
|
200
|
+
const ls = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, we = (r) => r.trim().replaceAll(" ", "_"), us = ls(1e5, 99999999), H = (r, {
|
|
201
201
|
videoMode: e,
|
|
202
202
|
audioMode: t
|
|
203
203
|
} = {}) => {
|
|
@@ -217,10 +217,10 @@ const ls = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, be = (r) =>
|
|
|
217
217
|
e
|
|
218
218
|
))
|
|
219
219
|
return t;
|
|
220
|
-
}, Rs = dt(),
|
|
220
|
+
}, Rs = dt(), Is = (r, e) => {
|
|
221
221
|
if (Rs(r, e))
|
|
222
222
|
return r;
|
|
223
|
-
},
|
|
223
|
+
}, ms = async (r, e, t) => {
|
|
224
224
|
const s = r.getParameters();
|
|
225
225
|
(s.encodings === void 0 || s.encodings.length === 0) && (s.encodings = [{}]);
|
|
226
226
|
const [n] = s.encodings, o = n.scaleResolutionDownBy, a = As(
|
|
@@ -229,16 +229,16 @@ const ls = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, be = (r) =>
|
|
|
229
229
|
);
|
|
230
230
|
let c = !1;
|
|
231
231
|
a !== void 0 && (s.encodings[0].scaleResolutionDownBy = a, c = !0);
|
|
232
|
-
const E = n.maxBitrate, _ =
|
|
232
|
+
const E = n.maxBitrate, _ = Is(e.maxBitrate, E);
|
|
233
233
|
return _ !== void 0 && (s.encodings[0].maxBitrate = _, c = !0), c ? (t && t(s), r.setParameters(s).then(() => ({ parameters: s, isChanged: c }))) : { parameters: s, isChanged: c };
|
|
234
234
|
}, fs = async (r, e, t) => {
|
|
235
235
|
const s = gs(r, e);
|
|
236
236
|
if (s)
|
|
237
|
-
return
|
|
238
|
-
}, Os = 486,
|
|
237
|
+
return ms(s, { maxBitrate: t });
|
|
238
|
+
}, Os = 486, Ds = 487, F = "local", ye = "remote", Js = (r = new Error()) => {
|
|
239
239
|
const { originator: e, cause: t } = r;
|
|
240
|
-
return Ct(r) ? !0 : typeof t == "string" ? t ===
|
|
241
|
-
}, S = "SipConnector",
|
|
240
|
+
return Ct(r) ? !0 : typeof t == "string" ? t === be || t === Ue || e === F && (t === He || t === Le) : !1;
|
|
241
|
+
}, S = "SipConnector", Ms = "channels", Ps = "WebcastStarted", ps = "WebcastStopped", vs = "accountChanged", ws = "accountDeleted", ys = "addedToListModerators", bs = "removedFromListModerators", Us = "ParticipationRequestAccepted", Ls = "ParticipationRequestRejected", Hs = "ParticipantMovedToWebcast", ks = "ConferenceParticipantTokenIssued";
|
|
242
242
|
class zs {
|
|
243
243
|
constructor({ JsSIP: e }) {
|
|
244
244
|
i(this, "_isRegisterConfig", !1);
|
|
@@ -273,7 +273,7 @@ class zs {
|
|
|
273
273
|
i(this, "tryRegister", async () => {
|
|
274
274
|
if (!this.isRegisterConfig)
|
|
275
275
|
throw new Error("Config is not registered");
|
|
276
|
-
this._uaEvents.trigger(
|
|
276
|
+
this._uaEvents.trigger(b, void 0);
|
|
277
277
|
try {
|
|
278
278
|
await this.unregister();
|
|
279
279
|
} catch (e) {
|
|
@@ -281,7 +281,7 @@ class zs {
|
|
|
281
281
|
}
|
|
282
282
|
return this.register();
|
|
283
283
|
});
|
|
284
|
-
i(this, "declineToIncomingCall", async ({ statusCode: e =
|
|
284
|
+
i(this, "declineToIncomingCall", async ({ statusCode: e = Ds } = {}) => new Promise((t, s) => {
|
|
285
285
|
if (!this.isAvailableIncomingCall) {
|
|
286
286
|
s(new Error("no incomingSession"));
|
|
287
287
|
return;
|
|
@@ -298,7 +298,7 @@ class zs {
|
|
|
298
298
|
this.incomingSession = t;
|
|
299
299
|
const s = this.remoteCallerData;
|
|
300
300
|
t.on(g, (n) => {
|
|
301
|
-
this.removeIncomingSession(), n.originator ===
|
|
301
|
+
this.removeIncomingSession(), n.originator === F ? this._uaEvents.trigger(x, s) : this._uaEvents.trigger(Y, s);
|
|
302
302
|
}), this._uaEvents.trigger(B, s);
|
|
303
303
|
}
|
|
304
304
|
});
|
|
@@ -335,10 +335,10 @@ class zs {
|
|
|
335
335
|
user: t,
|
|
336
336
|
password: s
|
|
337
337
|
}, this._init({ sipServerUrl: o, sipWebSocketServerURL: a });
|
|
338
|
-
const U = n && t ? t.trim() : `${us()}`,
|
|
338
|
+
const U = n && t ? t.trim() : `${us()}`, me = {
|
|
339
339
|
password: s,
|
|
340
340
|
register: n,
|
|
341
|
-
display_name:
|
|
341
|
+
display_name: we(e),
|
|
342
342
|
user_agent: f,
|
|
343
343
|
sdp_semantics: _,
|
|
344
344
|
sockets: [this.socket],
|
|
@@ -348,11 +348,11 @@ class zs {
|
|
|
348
348
|
connection_recovery_min_interval: l,
|
|
349
349
|
connection_recovery_max_interval: u
|
|
350
350
|
};
|
|
351
|
-
this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!
|
|
351
|
+
this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!me.register, this.ua = new this.JsSIP.UA(me), this._uaEvents.eachTriggers((ut, Tt) => {
|
|
352
352
|
const fe = Ae.find((St) => St === Tt);
|
|
353
353
|
fe && this.ua && this.ua.on(fe, ut);
|
|
354
354
|
});
|
|
355
|
-
const lt = [...
|
|
355
|
+
const lt = [...Ft(c), ...E];
|
|
356
356
|
return this.ua.registrator().setExtraHeaders(lt), this.ua;
|
|
357
357
|
});
|
|
358
358
|
i(this, "_start", async () => new Promise((e, t) => {
|
|
@@ -370,7 +370,7 @@ class zs {
|
|
|
370
370
|
}, c = () => {
|
|
371
371
|
this.off(A, n), this.off(R, o), this.off(O, n), this.off(N, o);
|
|
372
372
|
};
|
|
373
|
-
a(), this.on(
|
|
373
|
+
a(), this.on(D, this.handleNewRTCSession), s.start();
|
|
374
374
|
}));
|
|
375
375
|
i(this, "_set", async ({ displayName: e, password: t }) => new Promise((s, n) => {
|
|
376
376
|
const { ua: o } = this;
|
|
@@ -379,7 +379,7 @@ class zs {
|
|
|
379
379
|
return;
|
|
380
380
|
}
|
|
381
381
|
let a = !1, c = !1;
|
|
382
|
-
e !== void 0 && e !== this._connectionConfiguration.displayName && (a = o.set("display_name",
|
|
382
|
+
e !== void 0 && e !== this._connectionConfiguration.displayName && (a = o.set("display_name", we(e)), this._connectionConfiguration.displayName = e), t !== void 0 && t !== this._connectionConfiguration.password && (c = o.set("password", t), this._connectionConfiguration.password = t);
|
|
383
383
|
const E = a || c;
|
|
384
384
|
c && this.isRegisterConfig ? this.register().then(() => {
|
|
385
385
|
s(E);
|
|
@@ -387,7 +387,7 @@ class zs {
|
|
|
387
387
|
}));
|
|
388
388
|
i(this, "_disconnectWithoutCancelRequests", async () => this._cancelableDisconnect.request());
|
|
389
389
|
i(this, "_disconnect", async () => {
|
|
390
|
-
this.off(
|
|
390
|
+
this.off(D, this.handleNewRTCSession);
|
|
391
391
|
const e = new Promise((t) => {
|
|
392
392
|
this.once(N, () => {
|
|
393
393
|
delete this.ua, t();
|
|
@@ -471,13 +471,13 @@ class zs {
|
|
|
471
471
|
}));
|
|
472
472
|
i(this, "_handleCall", async ({ ontrack: e }) => new Promise((t, s) => {
|
|
473
473
|
const n = () => {
|
|
474
|
-
this.onSession(
|
|
474
|
+
this.onSession(w, h), this.onSession(v, d);
|
|
475
475
|
}, o = () => {
|
|
476
|
-
this.offSession(
|
|
476
|
+
this.offSession(w, h), this.offSession(v, d);
|
|
477
477
|
}, a = () => {
|
|
478
|
-
this.onSession(g, E), this.onSession(
|
|
478
|
+
this.onSession(g, E), this.onSession(I, E);
|
|
479
479
|
}, c = () => {
|
|
480
|
-
this.offSession(g, E), this.offSession(
|
|
480
|
+
this.offSession(g, E), this.offSession(I, E);
|
|
481
481
|
}, E = (l) => {
|
|
482
482
|
o(), c(), s(l);
|
|
483
483
|
};
|
|
@@ -501,7 +501,7 @@ class zs {
|
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
503
|
this.onceSession(Ne, ({ originator: o }) => {
|
|
504
|
-
o ===
|
|
504
|
+
o === F && t();
|
|
505
505
|
}), n.sendDTMF(e, {
|
|
506
506
|
duration: 120,
|
|
507
507
|
interToneGap: 600
|
|
@@ -530,7 +530,7 @@ class zs {
|
|
|
530
530
|
}
|
|
531
531
|
});
|
|
532
532
|
i(this, "_maybeTriggerChannels", (e) => {
|
|
533
|
-
const t = e.getHeader(
|
|
533
|
+
const t = e.getHeader(Me), s = e.getHeader(Pe);
|
|
534
534
|
if (t && s) {
|
|
535
535
|
const n = {
|
|
536
536
|
inputChannels: t,
|
|
@@ -541,7 +541,7 @@ class zs {
|
|
|
541
541
|
});
|
|
542
542
|
i(this, "_handleNotify", (e) => {
|
|
543
543
|
switch (e.cmd) {
|
|
544
|
-
case
|
|
544
|
+
case Ms: {
|
|
545
545
|
const t = e;
|
|
546
546
|
this._triggerChannelsNotify(t);
|
|
547
547
|
break;
|
|
@@ -561,19 +561,19 @@ class zs {
|
|
|
561
561
|
this._triggerAddedToListModeratorsNotify(t);
|
|
562
562
|
break;
|
|
563
563
|
}
|
|
564
|
-
case
|
|
564
|
+
case bs: {
|
|
565
565
|
const t = e;
|
|
566
566
|
this._triggerRemovedFromListModeratorsNotify(t);
|
|
567
567
|
break;
|
|
568
568
|
}
|
|
569
569
|
case Us: {
|
|
570
570
|
const t = e;
|
|
571
|
-
this.
|
|
571
|
+
this._triggerParticipationAcceptingWordRequest(t);
|
|
572
572
|
break;
|
|
573
573
|
}
|
|
574
574
|
case Ls: {
|
|
575
575
|
const t = e;
|
|
576
|
-
this.
|
|
576
|
+
this._triggerParticipationCancellingWordRequest(t);
|
|
577
577
|
break;
|
|
578
578
|
}
|
|
579
579
|
case Hs: {
|
|
@@ -585,7 +585,7 @@ class zs {
|
|
|
585
585
|
this._triggerAccountChangedNotify();
|
|
586
586
|
break;
|
|
587
587
|
}
|
|
588
|
-
case
|
|
588
|
+
case ws: {
|
|
589
589
|
this._triggerAccountDeletedNotify();
|
|
590
590
|
break;
|
|
591
591
|
}
|
|
@@ -655,15 +655,15 @@ class zs {
|
|
|
655
655
|
};
|
|
656
656
|
this._uaEvents.trigger(ee, n);
|
|
657
657
|
});
|
|
658
|
-
i(this, "
|
|
658
|
+
i(this, "_triggerParticipationAcceptingWordRequest", ({
|
|
659
659
|
body: { conference: e }
|
|
660
660
|
}) => {
|
|
661
661
|
const t = {
|
|
662
662
|
conference: e
|
|
663
663
|
};
|
|
664
|
-
this._uaEvents.trigger(
|
|
664
|
+
this._uaEvents.trigger(_e, t);
|
|
665
665
|
});
|
|
666
|
-
i(this, "
|
|
666
|
+
i(this, "_triggerParticipationCancellingWordRequest", ({
|
|
667
667
|
body: { conference: e }
|
|
668
668
|
}) => {
|
|
669
669
|
const t = {
|
|
@@ -677,18 +677,18 @@ class zs {
|
|
|
677
677
|
const t = {
|
|
678
678
|
conference: e
|
|
679
679
|
};
|
|
680
|
-
this._uaEvents.trigger(
|
|
680
|
+
this._uaEvents.trigger(Ee, t);
|
|
681
681
|
});
|
|
682
682
|
i(this, "_triggerEnterRoom", (e) => {
|
|
683
683
|
const t = e.getHeader(Bt);
|
|
684
684
|
this._sessionEvents.trigger(Q, t);
|
|
685
685
|
});
|
|
686
686
|
i(this, "_triggerShareState", (e) => {
|
|
687
|
-
const t = e.getHeader(
|
|
688
|
-
this._sessionEvents.trigger(
|
|
687
|
+
const t = e.getHeader(m);
|
|
688
|
+
this._sessionEvents.trigger(M, t);
|
|
689
689
|
});
|
|
690
690
|
i(this, "_triggerMainCamControl", (e) => {
|
|
691
|
-
const t = e.getHeader(zt), s = e.getHeader(pe), n = s ===
|
|
691
|
+
const t = e.getHeader(zt), s = e.getHeader(pe), n = s === q.ADMIN_SYNC_FORCED;
|
|
692
692
|
if (t === C.ADMIN_START_MAIN_CAM)
|
|
693
693
|
this._sessionEvents.trigger(ie, { isSyncForced: n });
|
|
694
694
|
else if (t === C.ADMIN_STOP_MAIN_CAM)
|
|
@@ -704,7 +704,7 @@ class zs {
|
|
|
704
704
|
}
|
|
705
705
|
});
|
|
706
706
|
i(this, "_triggerMicControl", (e) => {
|
|
707
|
-
const t = e.getHeader(Qt), n = e.getHeader(pe) ===
|
|
707
|
+
const t = e.getHeader(Qt), n = e.getHeader(pe) === q.ADMIN_SYNC_FORCED;
|
|
708
708
|
t === k.ADMIN_START_MIC ? this._sessionEvents.trigger(oe, { isSyncForced: n }) : t === k.ADMIN_STOP_MIC && this._sessionEvents.trigger(re, { isSyncForced: n });
|
|
709
709
|
});
|
|
710
710
|
i(this, "_triggerUseLicense", (e) => {
|
|
@@ -730,11 +730,11 @@ class zs {
|
|
|
730
730
|
this._triggerShareState(s);
|
|
731
731
|
break;
|
|
732
732
|
}
|
|
733
|
-
case
|
|
733
|
+
case De: {
|
|
734
734
|
this._triggerMainCamControl(s);
|
|
735
735
|
break;
|
|
736
736
|
}
|
|
737
|
-
case
|
|
737
|
+
case $t: {
|
|
738
738
|
this._triggerMicControl(s);
|
|
739
739
|
break;
|
|
740
740
|
}
|
|
@@ -774,7 +774,7 @@ class zs {
|
|
|
774
774
|
}), this._cancelableCall = new T(
|
|
775
775
|
this._call,
|
|
776
776
|
{ moduleName: S }
|
|
777
|
-
), this._cancelableAnswer = new T(this._answer, { moduleName: S }), this._cancelableSendDTMF = new T(this._sendDTMF, { moduleName: S }), this.onSession(
|
|
777
|
+
), this._cancelableAnswer = new T(this._answer, { moduleName: S }), this._cancelableSendDTMF = new T(this._sendDTMF, { moduleName: S }), this.onSession(M, this._handleShareState), this.onSession(ge, this._handleNewInfo), this.on($, this._handleSipEvent), this.onSession(g, this._handleEnded), this.onSession(I, this._handleEnded);
|
|
778
778
|
}
|
|
779
779
|
async register() {
|
|
780
780
|
return new Promise((e, t) => {
|
|
@@ -783,7 +783,7 @@ class zs {
|
|
|
783
783
|
}
|
|
784
784
|
async unregister() {
|
|
785
785
|
return new Promise((e, t) => {
|
|
786
|
-
this.isRegistered && this.ua ? (this.ua.on(
|
|
786
|
+
this.isRegistered && this.ua ? (this.ua.on(G, e), this.ua.unregister()) : t(new Error("ua is not registered"));
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
789
|
async sendOptions(e, t, s) {
|
|
@@ -821,7 +821,7 @@ class zs {
|
|
|
821
821
|
if (!this.session)
|
|
822
822
|
throw new Error("No session established");
|
|
823
823
|
const t = [_s];
|
|
824
|
-
return this.session.sendInfo(
|
|
824
|
+
return this.session.sendInfo(De, void 0, {
|
|
825
825
|
noTerminateWhenError: !0,
|
|
826
826
|
...e,
|
|
827
827
|
extraHeaders: t
|
|
@@ -1035,7 +1035,7 @@ class zs {
|
|
|
1035
1035
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
1036
1036
|
if (!this.session)
|
|
1037
1037
|
throw new Error("No session established");
|
|
1038
|
-
const s = `${
|
|
1038
|
+
const s = `${Me}: ${e}`, n = `${Pe}: ${t}`, o = [
|
|
1039
1039
|
s,
|
|
1040
1040
|
n
|
|
1041
1041
|
];
|
|
@@ -1059,7 +1059,7 @@ class zs {
|
|
|
1059
1059
|
if (!this.session)
|
|
1060
1060
|
throw new Error("No session established");
|
|
1061
1061
|
const c = [`${Zt}: ${e === "mic" ? 0 : 1}`];
|
|
1062
|
-
return this.session.sendInfo(
|
|
1062
|
+
return this.session.sendInfo(Gt, void 0, {
|
|
1063
1063
|
noTerminateWhenError: !0,
|
|
1064
1064
|
...t,
|
|
1065
1065
|
extraHeaders: c
|
|
@@ -1079,20 +1079,20 @@ class zs {
|
|
|
1079
1079
|
export {
|
|
1080
1080
|
kt as B,
|
|
1081
1081
|
C as E,
|
|
1082
|
-
|
|
1082
|
+
Dt as N,
|
|
1083
1083
|
Ue as R,
|
|
1084
1084
|
zs as S,
|
|
1085
1085
|
at as U,
|
|
1086
1086
|
xs as a,
|
|
1087
|
-
|
|
1087
|
+
$s as b,
|
|
1088
1088
|
Ys as c,
|
|
1089
1089
|
Xs as d,
|
|
1090
|
-
|
|
1090
|
+
Gs as e,
|
|
1091
1091
|
k as f,
|
|
1092
|
-
|
|
1092
|
+
q as g,
|
|
1093
1093
|
Js as h,
|
|
1094
1094
|
hs as i,
|
|
1095
1095
|
ct as j,
|
|
1096
1096
|
ve as l,
|
|
1097
|
-
|
|
1097
|
+
ms as s
|
|
1098
1098
|
};
|
package/dist/SipConnector.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ declare const CMD_CHANNELS: "channels";
|
|
|
17
17
|
declare const CMD_WEBCAST_STARTED: "WebcastStarted";
|
|
18
18
|
declare const CMD_ADDED_TO_LIST_MODERATORS: "addedToListModerators";
|
|
19
19
|
declare const CMD_REMOVED_FROM_LIST_MODERATORS: "removedFromListModerators";
|
|
20
|
-
declare const
|
|
21
|
-
declare const CMD_CANCELLING_WORD_REQUEST: "
|
|
20
|
+
declare const CMD_ACCEPTING_WORD_REQUEST: "ParticipationRequestAccepted";
|
|
21
|
+
declare const CMD_CANCELLING_WORD_REQUEST: "ParticipationRequestRejected";
|
|
22
22
|
declare const CMD_MOVE_REQUEST_TO_STREAM: "ParticipantMovedToWebcast";
|
|
23
23
|
declare const CMD_CONFERENCE_PARTICIPANT_TOKEN_ISSUED: "ConferenceParticipantTokenIssued";
|
|
24
24
|
type TAddedToListModeratorsInfoNotify = {
|
|
@@ -29,13 +29,13 @@ type TRemovedFromListModeratorsInfoNotify = {
|
|
|
29
29
|
cmd: typeof CMD_REMOVED_FROM_LIST_MODERATORS;
|
|
30
30
|
conference: string;
|
|
31
31
|
};
|
|
32
|
-
type
|
|
33
|
-
cmd: typeof
|
|
32
|
+
type TAcceptingWordRequestInfoNotify = {
|
|
33
|
+
cmd: typeof CMD_ACCEPTING_WORD_REQUEST;
|
|
34
34
|
body: {
|
|
35
35
|
conference: string;
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
type
|
|
38
|
+
type TCancellingWordRequestInfoNotify = {
|
|
39
39
|
cmd: typeof CMD_CANCELLING_WORD_REQUEST;
|
|
40
40
|
body: {
|
|
41
41
|
conference: string;
|
|
@@ -261,8 +261,8 @@ export default class SipConnector {
|
|
|
261
261
|
_triggerAccountDeletedNotify: () => void;
|
|
262
262
|
_triggerConferenceParticipantTokenIssued: ({ body: { conference, participant, jwt }, }: TConferenceParticipantTokenIssued) => void;
|
|
263
263
|
_triggerChannelsNotify: (channelsInfo: TChannelsInfoNotify) => void;
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
_triggerParticipationAcceptingWordRequest: ({ body: { conference }, }: TAcceptingWordRequestInfoNotify) => void;
|
|
265
|
+
_triggerParticipationCancellingWordRequest: ({ body: { conference }, }: TCancellingWordRequestInfoNotify) => void;
|
|
266
266
|
_triggerParticipantMoveRequestToStream: ({ body: { conference }, }: TMoveRequestToStreamInfoNotify) => void;
|
|
267
267
|
_triggerEnterRoom: (request: IncomingRequest) => void;
|
|
268
268
|
_triggerShareState: (request: IncomingRequest) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const acceptingWordRequestHeaders: [string, string][];
|
|
2
|
+
export declare const acceptingWordRequestData: {
|
|
3
3
|
conference: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const cancellingWordRequestHeaders: [string, string][];
|
|
6
|
+
export declare const cancellingWordRequestData: {
|
|
7
7
|
conference: string;
|
|
8
8
|
};
|
|
9
9
|
export declare const moveRequestToStreamHeaders: [string, string][];
|
package/dist/constants.d.ts
CHANGED
|
@@ -30,9 +30,9 @@ export declare const ADMIN_START_MIC = "admin-start-mic";
|
|
|
30
30
|
export declare const ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state";
|
|
31
31
|
export declare const PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators";
|
|
32
32
|
export declare const PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators";
|
|
33
|
-
export declare const PARTICIPANT_MOVE_REQUEST_TO_CONFERENCE = "participant:move-request-to-conference";
|
|
34
33
|
export declare const PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream";
|
|
35
|
-
export declare const
|
|
34
|
+
export declare const PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request";
|
|
35
|
+
export declare const PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request";
|
|
36
36
|
export declare const WEBCAST_STARTED = "webcast:started";
|
|
37
37
|
export declare const WEBCAST_STOPPED = "webcast:stopped";
|
|
38
38
|
export declare const ACCOUNT_CHANGED = "account:changed";
|
package/dist/doMock.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var W=Object.defineProperty;var b=(i,e,t)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var n=(i,e,t)=>(b(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./SipConnector-3317ff75.cjs"),D=require("@krivega/jssip/lib/NameAddrHeader"),k=require("@krivega/jssip/lib/URI"),L=require("node:events"),P=require("@krivega/jssip/lib/SIPMessage"),f=require("events-constructor");require("@krivega/cancelable-promise");require("debug");class R extends P.IncomingRequest{constructor(t){super();n(this,"headers");this.headers=new Headers(t)}getHeader(t){return this.headers.get(t)||""}}var x=Object.defineProperty,F=(i,e,t)=>e in i?x(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,s=(i,e,t)=>(F(i,typeof e!="symbol"?e+"":e,t),t);const m="ended",U="mute",V="isolationchange",z="overconstrained",q="unmute",H=[m,U,q,V,z];class S{constructor(e,{id:t="identifier",constraints:r={}}={}){s(this,"events"),s(this,"id"),s(this,"kind"),s(this,"constraints"),s(this,"enabled"),s(this,"contentHint",""),s(this,"readyState","live"),s(this,"isolated",!1),s(this,"label",""),s(this,"muted",!1),s(this,"onended",null),s(this,"onisolationchange",null),s(this,"onmute",null),s(this,"onunmute",null),s(this,"getConstraints",()=>this.constraints),s(this,"stop",()=>{const o={...new Event(m)};this.events.trigger(m,o),this.readyState=m,this.onended&&this.onended(o)}),s(this,"addEventListener",(o,a)=>{this.events.on(o,a)}),s(this,"removeEventListener",(o,a)=>{this.events.off(o,a)}),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints={...r},this.events=new f(H)}clone(){return{...this}}getCapabilities(){return{width:{min:352,max:4096},height:{min:288,max:2160}}}getSettings(){let e=0,t=0;return typeof this.constraints.width=="object"&&this.constraints.width.ideal!==void 0?e=this.constraints.width.ideal:typeof this.constraints.width=="object"&&this.constraints.width.exact!==void 0?e=this.constraints.width.exact:typeof this.constraints.width=="number"&&this.constraints.width&&(e=this.constraints.width),typeof this.constraints.height=="object"&&this.constraints.height.ideal!==void 0?t=this.constraints.height.ideal:typeof this.constraints.height=="object"&&this.constraints.height.exact!==void 0?t=this.constraints.height.exact:typeof this.constraints.height=="number"&&this.constraints.height&&(t=this.constraints.height),{width:e,height:t}}async applyConstraints(e){this.constraints={...e}}dispatchEvent(e){const t=e.type;return this.events.trigger(t,e),!0}}const j=i=>new S("audio",i),$=i=>new S("video",i);class B{constructor({originator:e="local",eventHandlers:t}){n(this,"originator");n(this,"_connection");n(this,"_events");n(this,"_remote_identity");n(this,"_mutedOptions",{audio:!1,video:!1});this.originator=e,this._events=new f(u.SESSION_EVENT_NAMES),this.initEvents(t)}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}set data(e){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}get connection(){return this._connection}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get remote_identity(){return this._remote_identity}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(e){throw new Error("Method not implemented.")}terminate(e){throw new Error("Method not implemented.")}async sendInfo(e,t,r){throw new Error("Method not implemented.")}hold(e,t){throw new Error("Method not implemented.")}unhold(e,t){throw new Error("Method not implemented.")}async renegotiate(e,t){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(e){throw new Error("Method not implemented.")}unmute(e){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(e,t){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(e,t){throw new Error("Method not implemented.")}addListener(e,t){throw new Error("Method not implemented.")}once(e,t){throw new Error("Method not implemented.")}removeListener(e,t){throw new Error("Method not implemented.")}off(e,t){throw new Error("Method not implemented.")}removeAllListeners(e){throw new Error("Method not implemented.")}setMaxListeners(e){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(e){throw new Error("Method not implemented.")}rawListeners(e){throw new Error("Method not implemented.")}emit(e,...t){throw new Error("Method not implemented.")}listenerCount(e){throw new Error("Method not implemented.")}prependListener(e,t){throw new Error("Method not implemented.")}prependOnceListener(e,t){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(e=[]){Object.entries(e).forEach(([t,r])=>this.on(t,r))}on(e,t){return this._events.on(e,t),this}trigger(e,t){this._events.trigger(e,t)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(e){return e}async updatePresentation(e){return e}async stopPresentation(e){return e}isEstablished(){return!0}}class K{constructor(e,t){n(this,"_senders",[]);n(this,"_receivers",[]);n(this,"canTrickleIceCandidates");n(this,"connectionState");n(this,"currentLocalDescription");n(this,"currentRemoteDescription");n(this,"iceConnectionState");n(this,"iceGatheringState");n(this,"idpErrorInfo");n(this,"idpLoginUrl");n(this,"localDescription");n(this,"onconnectionstatechange");n(this,"ondatachannel");n(this,"onicecandidate");n(this,"onicecandidateerror",null);n(this,"oniceconnectionstatechange");n(this,"onicegatheringstatechange");n(this,"onnegotiationneeded");n(this,"onsignalingstatechange");n(this,"ontrack");n(this,"peerIdentity");n(this,"pendingLocalDescription");n(this,"pendingRemoteDescription");n(this,"remoteDescription");n(this,"sctp",null);n(this,"signalingState");n(this,"getReceivers",()=>this._receivers);n(this,"getSenders",()=>this._senders);n(this,"addTrack",e=>{const t={track:e};return this._senders.push(t),t});this._receivers=t.map(r=>({track:r}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(e){throw new Error("Method not implemented.")}addTransceiver(e,t){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(e,t){throw new Error("Method not implemented.")}createDataChannel(e,t){throw new Error("Method not implemented.")}async createOffer(e,t,r){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(e){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(e){throw new Error("Method not implemented.")}setConfiguration(e){throw new Error("Method not implemented.")}async setLocalDescription(e){throw new Error("Method not implemented.")}async setRemoteDescription(e){throw new Error("Method not implemented.")}addEventListener(e,t,r){throw new Error("Method not implemented.")}removeEventListener(e,t,r){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}}function Y(i){const e=i.match(/[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const p=400,T="777",J=i=>i.getVideoTracks().length>0;class y extends B{constructor({url:t="",mediaStream:r,eventHandlers:o,originator:a}){super({originator:a,eventHandlers:o});n(this,"url");n(this,"status_code");n(this,"_isEnded",!1);n(this,"answer",jest.fn(({mediaStream:t})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(t),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},p)}));this.url=t,this.initPeerconnection(r)}initPeerconnection(t){return t?(this.createPeerconnection(t),!0):!1}createPeerconnection(t){const r=j();r.id="mainaudio1";const o=[r];if(J(t)){const C=$();C.id="mainvideo1",o.push(C)}this._connection=new K(void 0,o),this._addStream(t),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},p)}connect(t){const r=Y(t);setTimeout(()=>{this.url.includes(T)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:u.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",r)},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},p)}terminate({status_code:t}={}){return this.status_code=t,this.trigger("ended",{status_code:t}),this._isEnded=!1,this}terminateRemote({status_code:t}={}){return this.status_code=t,this.trigger("ended",{status_code:t,originator:"remote"}),this}_addStream(t,r="getTracks"){t[r]().forEach(o=>this.connection.addTrack(o))}_forEachSenders(t){const r=this.connection.getSenders();for(const o of r)t(o);return r}_toggleMuteAudio(t){this._forEachSenders(({track:r})=>{r&&r.kind==="audio"&&(r.enabled=!t)})}_toggleMuteVideo(t){this._forEachSenders(({track:r})=>{r&&r.kind==="video"&&(r.enabled=!t)})}mute(t){t.audio&&(this._mutedOptions.audio=!0,this._toggleMuteAudio(this._mutedOptions.audio)),t.video&&(this._mutedOptions.video=!0,this._toggleMuteVideo(this._mutedOptions.video)),this._onmute(t)}unmute(t){t.audio&&(this._mutedOptions.audio=!1),t.video&&(this._mutedOptions.video=!1),this.trigger("unmuted",t)}isMuted(){return this._mutedOptions}async replaceMediaStream(t){return t}_onmute({audio:t,video:r}){this.trigger("muted",{audio:t,video:r})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(t){this.trigger("newInfo",t)}}class G{constructor(){n(this,"extraHeaders")}setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",w="PASSWORD_CORRECT_2",A="NAME_INCORRECT",c=400;class X{constructor(e){n(this,"_events");n(this,"_startedTimeout");n(this,"_stopedTimeout");n(this,"session");n(this,"_isRegistered");n(this,"_isConnected");n(this,"configuration");n(this,"_registrator");n(this,"call",jest.fn((e,t)=>{const{mediaStream:r,eventHandlers:o}=t;return this.session=new y({url:e,mediaStream:r,eventHandlers:o,originator:"local"}),this.session.connect(e),this.session}));this._events=new f(u.UA_EVENT_NAMES),this.configuration=e,this._registrator=new G}start(){this.register()}stop(){this._startedTimeout&&clearTimeout(this._startedTimeout),this._stopedTimeout&&clearTimeout(this._stopedTimeout),this.unregister(),this.isStarted()?this._stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:new Error("stoped")})},c):this.trigger("disconnected",{error:new Error("stoped")})}on(e,t){return this._events.on(e,t),this}trigger(e,t){this._events.trigger(e,t)}terminateSessions(){this.session.terminate()}set(e,t){return this.configuration[e]=t,!0}register(){this._startedTimeout&&clearTimeout(this._startedTimeout);const{password:e,register:t,uri:r}=this.configuration;t&&r.includes(A)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},c)):!this._isRegistered&&t&&(e===d||e===w)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},c)):t&&e!==d&&e!==w&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},c)),this.trigger("connected"),this._isConnected=!0}unregister(){this._isRegistered=!1,this._isConnected=!1,this.trigger("unregistered")}isRegistered(){return!!this._isRegistered}isStarted(){return this.configuration&&(this.configuration.register&&!!this._isRegistered||!this.configuration.register&&!!this._isConnected)}registrator(){return this._registrator}newSipEvent(e){this.trigger("sipEvent",e)}}class Q{constructor(e){n(this,"url");this.url=e}}class Z extends L.EventEmitter{constructor(t,r){super();n(this,"contentType");n(this,"body");this.contentType=t,this.body=r}}const E="remote",ee=(i,e)=>{const t=new R(e),r={originator:E,request:t,info:new Z("","")};i.newInfo(r)},te=(i,e)=>{const r={request:new R(e)};i.newSipEvent(r)},ne=(i,{incomingNumber:e="1234",displayName:t,host:r})=>{const o=new y({originator:E}),a=new k("sip",e,r);o._remote_identity=new D(a,t),i.trigger("newRTCSession",{originator:E,session:o})},re=(i,e)=>{e?i.trigger("failed",e):i.trigger("failed",i)},I={triggerNewInfo:ee,triggerNewSipEvent:te,triggerIncomingSession:ne,triggerFailIncomingSession:re,WebSocketInterface:Q,UA:X,C:{INVITE:"INVITE"}},l="user",h="displayName",g="SIP_SERVER_URL",M="SIP_WEB_SOCKET_SERVER_URL",ie=new I.WebSocketInterface(M),v={userAgent:"Chrome",sipServerUrl:g,sipWebSocketServerURL:M},oe={...v},O={...v,user:l,password:d,register:!0},se={...O,displayName:h},ae={...v,displayName:h,register:!1},_={session_timers:!1,sockets:[ie],user_agent:"Chrome",sdp_semantics:"plan-b",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},de={..._,password:d,uri:`sip:${l}@${g}`,display_name:"",register:!0},he={..._,password:d,uri:`sip:${l}@${g}`,display_name:h,register:!0},ce={..._,display_name:h,register:!1},me={..._,display_name:"",register:!1},N="10.10.10.10",ue=[`X-Vinteo-Remote: ${N}`],le=()=>new u.SipConnector({JsSIP:I});exports.FAILED_CONFERENCE_NUMBER=T;exports.NAME_INCORRECT=A;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=w;exports.SIP_SERVER_URL=g;exports.SIP_WEB_SOCKET_SERVER_URL=M;exports.dataForConnectionWithAuthorization=O;exports.dataForConnectionWithAuthorizationWithDisplayName=se;exports.dataForConnectionWithoutAuthorization=ae;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=oe;exports.default=le;exports.displayName=h;exports.extraHeadersRemoteAddress=ue;exports.remoteAddress=N;exports.uaConfigurationWithAuthorization=de;exports.uaConfigurationWithAuthorizationWithDisplayName=he;exports.uaConfigurationWithoutAuthorization=ce;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=me;exports.user=l;
|
|
1
|
+
"use strict";var W=Object.defineProperty;var b=(i,e,t)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var n=(i,e,t)=>(b(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./SipConnector-XqVe938n.cjs"),D=require("@krivega/jssip/lib/NameAddrHeader"),k=require("@krivega/jssip/lib/URI"),L=require("node:events"),P=require("@krivega/jssip/lib/SIPMessage"),f=require("events-constructor");require("@krivega/cancelable-promise");require("debug");class R extends P.IncomingRequest{constructor(t){super();n(this,"headers");this.headers=new Headers(t)}getHeader(t){return this.headers.get(t)||""}}var x=Object.defineProperty,F=(i,e,t)=>e in i?x(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,s=(i,e,t)=>(F(i,typeof e!="symbol"?e+"":e,t),t);const m="ended",U="mute",V="isolationchange",z="overconstrained",q="unmute",H=[m,U,q,V,z];class S{constructor(e,{id:t="identifier",constraints:r={}}={}){s(this,"events"),s(this,"id"),s(this,"kind"),s(this,"constraints"),s(this,"enabled"),s(this,"contentHint",""),s(this,"readyState","live"),s(this,"isolated",!1),s(this,"label",""),s(this,"muted",!1),s(this,"onended",null),s(this,"onisolationchange",null),s(this,"onmute",null),s(this,"onunmute",null),s(this,"getConstraints",()=>this.constraints),s(this,"stop",()=>{const o={...new Event(m)};this.events.trigger(m,o),this.readyState=m,this.onended&&this.onended(o)}),s(this,"addEventListener",(o,a)=>{this.events.on(o,a)}),s(this,"removeEventListener",(o,a)=>{this.events.off(o,a)}),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints={...r},this.events=new f(H)}clone(){return{...this}}getCapabilities(){return{width:{min:352,max:4096},height:{min:288,max:2160}}}getSettings(){let e=0,t=0;return typeof this.constraints.width=="object"&&this.constraints.width.ideal!==void 0?e=this.constraints.width.ideal:typeof this.constraints.width=="object"&&this.constraints.width.exact!==void 0?e=this.constraints.width.exact:typeof this.constraints.width=="number"&&this.constraints.width&&(e=this.constraints.width),typeof this.constraints.height=="object"&&this.constraints.height.ideal!==void 0?t=this.constraints.height.ideal:typeof this.constraints.height=="object"&&this.constraints.height.exact!==void 0?t=this.constraints.height.exact:typeof this.constraints.height=="number"&&this.constraints.height&&(t=this.constraints.height),{width:e,height:t}}async applyConstraints(e){this.constraints={...e}}dispatchEvent(e){const t=e.type;return this.events.trigger(t,e),!0}}const j=i=>new S("audio",i),$=i=>new S("video",i);class B{constructor({originator:e="local",eventHandlers:t}){n(this,"originator");n(this,"_connection");n(this,"_events");n(this,"_remote_identity");n(this,"_mutedOptions",{audio:!1,video:!1});this.originator=e,this._events=new f(u.SESSION_EVENT_NAMES),this.initEvents(t)}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}set data(e){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}get connection(){return this._connection}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get remote_identity(){return this._remote_identity}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(e){throw new Error("Method not implemented.")}terminate(e){throw new Error("Method not implemented.")}async sendInfo(e,t,r){throw new Error("Method not implemented.")}hold(e,t){throw new Error("Method not implemented.")}unhold(e,t){throw new Error("Method not implemented.")}async renegotiate(e,t){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(e){throw new Error("Method not implemented.")}unmute(e){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(e,t){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(e,t){throw new Error("Method not implemented.")}addListener(e,t){throw new Error("Method not implemented.")}once(e,t){throw new Error("Method not implemented.")}removeListener(e,t){throw new Error("Method not implemented.")}off(e,t){throw new Error("Method not implemented.")}removeAllListeners(e){throw new Error("Method not implemented.")}setMaxListeners(e){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(e){throw new Error("Method not implemented.")}rawListeners(e){throw new Error("Method not implemented.")}emit(e,...t){throw new Error("Method not implemented.")}listenerCount(e){throw new Error("Method not implemented.")}prependListener(e,t){throw new Error("Method not implemented.")}prependOnceListener(e,t){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(e=[]){Object.entries(e).forEach(([t,r])=>this.on(t,r))}on(e,t){return this._events.on(e,t),this}trigger(e,t){this._events.trigger(e,t)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(e){return e}async updatePresentation(e){return e}async stopPresentation(e){return e}isEstablished(){return!0}}class K{constructor(e,t){n(this,"_senders",[]);n(this,"_receivers",[]);n(this,"canTrickleIceCandidates");n(this,"connectionState");n(this,"currentLocalDescription");n(this,"currentRemoteDescription");n(this,"iceConnectionState");n(this,"iceGatheringState");n(this,"idpErrorInfo");n(this,"idpLoginUrl");n(this,"localDescription");n(this,"onconnectionstatechange");n(this,"ondatachannel");n(this,"onicecandidate");n(this,"onicecandidateerror",null);n(this,"oniceconnectionstatechange");n(this,"onicegatheringstatechange");n(this,"onnegotiationneeded");n(this,"onsignalingstatechange");n(this,"ontrack");n(this,"peerIdentity");n(this,"pendingLocalDescription");n(this,"pendingRemoteDescription");n(this,"remoteDescription");n(this,"sctp",null);n(this,"signalingState");n(this,"getReceivers",()=>this._receivers);n(this,"getSenders",()=>this._senders);n(this,"addTrack",e=>{const t={track:e};return this._senders.push(t),t});this._receivers=t.map(r=>({track:r}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(e){throw new Error("Method not implemented.")}addTransceiver(e,t){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(e,t){throw new Error("Method not implemented.")}createDataChannel(e,t){throw new Error("Method not implemented.")}async createOffer(e,t,r){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(e){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(e){throw new Error("Method not implemented.")}setConfiguration(e){throw new Error("Method not implemented.")}async setLocalDescription(e){throw new Error("Method not implemented.")}async setRemoteDescription(e){throw new Error("Method not implemented.")}addEventListener(e,t,r){throw new Error("Method not implemented.")}removeEventListener(e,t,r){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}}function Y(i){const e=i.match(/[\d.]+/g);if(!e)throw new Error("wrong sip url");return e[0]}const p=400,T="777",J=i=>i.getVideoTracks().length>0;class y extends B{constructor({url:t="",mediaStream:r,eventHandlers:o,originator:a}){super({originator:a,eventHandlers:o});n(this,"url");n(this,"status_code");n(this,"_isEnded",!1);n(this,"answer",jest.fn(({mediaStream:t})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(t),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},p)}));this.url=t,this.initPeerconnection(r)}initPeerconnection(t){return t?(this.createPeerconnection(t),!0):!1}createPeerconnection(t){const r=j();r.id="mainaudio1";const o=[r];if(J(t)){const C=$();C.id="mainvideo1",o.push(C)}this._connection=new K(void 0,o),this._addStream(t),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},p)}connect(t){const r=Y(t);setTimeout(()=>{this.url.includes(T)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:u.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",r)},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},p)}terminate({status_code:t}={}){return this.status_code=t,this.trigger("ended",{status_code:t}),this._isEnded=!1,this}terminateRemote({status_code:t}={}){return this.status_code=t,this.trigger("ended",{status_code:t,originator:"remote"}),this}_addStream(t,r="getTracks"){t[r]().forEach(o=>this.connection.addTrack(o))}_forEachSenders(t){const r=this.connection.getSenders();for(const o of r)t(o);return r}_toggleMuteAudio(t){this._forEachSenders(({track:r})=>{r&&r.kind==="audio"&&(r.enabled=!t)})}_toggleMuteVideo(t){this._forEachSenders(({track:r})=>{r&&r.kind==="video"&&(r.enabled=!t)})}mute(t){t.audio&&(this._mutedOptions.audio=!0,this._toggleMuteAudio(this._mutedOptions.audio)),t.video&&(this._mutedOptions.video=!0,this._toggleMuteVideo(this._mutedOptions.video)),this._onmute(t)}unmute(t){t.audio&&(this._mutedOptions.audio=!1),t.video&&(this._mutedOptions.video=!1),this.trigger("unmuted",t)}isMuted(){return this._mutedOptions}async replaceMediaStream(t){return t}_onmute({audio:t,video:r}){this.trigger("muted",{audio:t,video:r})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(t){this.trigger("newInfo",t)}}class G{constructor(){n(this,"extraHeaders")}setExtraHeaders(e){this.extraHeaders=e}setExtraContactParams(){}}const d="PASSWORD_CORRECT",w="PASSWORD_CORRECT_2",A="NAME_INCORRECT",c=400;class X{constructor(e){n(this,"_events");n(this,"_startedTimeout");n(this,"_stopedTimeout");n(this,"session");n(this,"_isRegistered");n(this,"_isConnected");n(this,"configuration");n(this,"_registrator");n(this,"call",jest.fn((e,t)=>{const{mediaStream:r,eventHandlers:o}=t;return this.session=new y({url:e,mediaStream:r,eventHandlers:o,originator:"local"}),this.session.connect(e),this.session}));this._events=new f(u.UA_EVENT_NAMES),this.configuration=e,this._registrator=new G}start(){this.register()}stop(){this._startedTimeout&&clearTimeout(this._startedTimeout),this._stopedTimeout&&clearTimeout(this._stopedTimeout),this.unregister(),this.isStarted()?this._stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:new Error("stoped")})},c):this.trigger("disconnected",{error:new Error("stoped")})}on(e,t){return this._events.on(e,t),this}trigger(e,t){this._events.trigger(e,t)}terminateSessions(){this.session.terminate()}set(e,t){return this.configuration[e]=t,!0}register(){this._startedTimeout&&clearTimeout(this._startedTimeout);const{password:e,register:t,uri:r}=this.configuration;t&&r.includes(A)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},c)):!this._isRegistered&&t&&(e===d||e===w)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},c)):t&&e!==d&&e!==w&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},c)),this.trigger("connected"),this._isConnected=!0}unregister(){this._isRegistered=!1,this._isConnected=!1,this.trigger("unregistered")}isRegistered(){return!!this._isRegistered}isStarted(){return this.configuration&&(this.configuration.register&&!!this._isRegistered||!this.configuration.register&&!!this._isConnected)}registrator(){return this._registrator}newSipEvent(e){this.trigger("sipEvent",e)}}class Q{constructor(e){n(this,"url");this.url=e}}class Z extends L.EventEmitter{constructor(t,r){super();n(this,"contentType");n(this,"body");this.contentType=t,this.body=r}}const E="remote",ee=(i,e)=>{const t=new R(e),r={originator:E,request:t,info:new Z("","")};i.newInfo(r)},te=(i,e)=>{const r={request:new R(e)};i.newSipEvent(r)},ne=(i,{incomingNumber:e="1234",displayName:t,host:r})=>{const o=new y({originator:E}),a=new k("sip",e,r);o._remote_identity=new D(a,t),i.trigger("newRTCSession",{originator:E,session:o})},re=(i,e)=>{e?i.trigger("failed",e):i.trigger("failed",i)},I={triggerNewInfo:ee,triggerNewSipEvent:te,triggerIncomingSession:ne,triggerFailIncomingSession:re,WebSocketInterface:Q,UA:X,C:{INVITE:"INVITE"}},l="user",h="displayName",g="SIP_SERVER_URL",M="SIP_WEB_SOCKET_SERVER_URL",ie=new I.WebSocketInterface(M),v={userAgent:"Chrome",sipServerUrl:g,sipWebSocketServerURL:M},oe={...v},O={...v,user:l,password:d,register:!0},se={...O,displayName:h},ae={...v,displayName:h,register:!1},_={session_timers:!1,sockets:[ie],user_agent:"Chrome",sdp_semantics:"plan-b",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},de={..._,password:d,uri:`sip:${l}@${g}`,display_name:"",register:!0},he={..._,password:d,uri:`sip:${l}@${g}`,display_name:h,register:!0},ce={..._,display_name:h,register:!1},me={..._,display_name:"",register:!1},N="10.10.10.10",ue=[`X-Vinteo-Remote: ${N}`],le=()=>new u.SipConnector({JsSIP:I});exports.FAILED_CONFERENCE_NUMBER=T;exports.NAME_INCORRECT=A;exports.PASSWORD_CORRECT=d;exports.PASSWORD_CORRECT_2=w;exports.SIP_SERVER_URL=g;exports.SIP_WEB_SOCKET_SERVER_URL=M;exports.dataForConnectionWithAuthorization=O;exports.dataForConnectionWithAuthorizationWithDisplayName=se;exports.dataForConnectionWithoutAuthorization=ae;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=oe;exports.default=le;exports.displayName=h;exports.extraHeadersRemoteAddress=ue;exports.remoteAddress=N;exports.uaConfigurationWithAuthorization=de;exports.uaConfigurationWithAuthorizationWithDisplayName=he;exports.uaConfigurationWithoutAuthorization=ce;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=me;exports.user=l;
|
package/dist/doMock.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var y = Object.defineProperty;
|
|
2
2
|
var I = (i, e, t) => e in i ? y(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var n = (i, e, t) => (I(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { j as b, R as O, U as k, S as A } from "./SipConnector-
|
|
4
|
+
import { j as b, R as O, U as k, S as A } from "./SipConnector-_AhwhWtL.js";
|
|
5
5
|
import N from "@krivega/jssip/lib/NameAddrHeader";
|
|
6
6
|
import L from "@krivega/jssip/lib/URI";
|
|
7
7
|
import { EventEmitter as D } from "node:events";
|
package/dist/eventNames.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const UA_SYNTHETICS_EVENT_NAMES: readonly ["incomingCall", "declinedIncomingCall", "terminatedIncomingCall", "failedIncomingCall", "
|
|
1
|
+
export declare const UA_SYNTHETICS_EVENT_NAMES: readonly ["incomingCall", "declinedIncomingCall", "terminatedIncomingCall", "failedIncomingCall", "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"];
|
|
2
2
|
export declare const UA_JSSIP_EVENT_NAMES: readonly ["connecting", "connected", "disconnected", "newRTCSession", "registered", "unregistered", "registrationFailed", "newMessage", "sipEvent"];
|
|
3
3
|
export declare const SESSION_SYNTHETICS_EVENT_NAMES: readonly ["availableSecondRemoteStream", "notAvailableSecondRemoteStream", "mustStopPresentation", "shareState", "enterRoom", "useLicense", "peerconnection:confirmed", "peerconnection:ontrack", "channels", "ended:fromserver", "main-cam-control", "admin-start-main-cam", "admin-stop-main-cam", "admin-stop-mic", "admin-start-mic", "admin-force-sync-media-state"];
|
|
4
4
|
export declare const SESSION_JSSIP_EVENT_NAMES: readonly ["ended", "connecting", "sending", "reinvite", "replaces", "refer", "progress", "accepted", "confirmed", "peerconnection", "failed", "muted", "unmuted", "newDTMF", "newInfo", "hold", "unhold", "update", "sdp", "icecandidate", "getusermediafailed", "peerconnection:createofferfailed", "peerconnection:createanswerfailed", "peerconnection:setlocaldescriptionfailed", "peerconnection:setremotedescriptionfailed", "presentation:start", "presentation:started", "presentation:end", "presentation:ended", "presentation:failed"];
|
|
5
|
-
export declare const UA_EVENT_NAMES: ("incomingCall" | "declinedIncomingCall" | "failedIncomingCall" | "terminatedIncomingCall" | "connecting" | "connected" | "disconnected" | "newRTCSession" | "registered" | "unregistered" | "registrationFailed" | "newMessage" | "sipEvent" | "channels:notify" | "participant:added-to-list-moderators" | "participant:removed-from-list-moderators" | "participant:move-request-to-
|
|
5
|
+
export declare const UA_EVENT_NAMES: ("incomingCall" | "declinedIncomingCall" | "failedIncomingCall" | "terminatedIncomingCall" | "connecting" | "connected" | "disconnected" | "newRTCSession" | "registered" | "unregistered" | "registrationFailed" | "newMessage" | "sipEvent" | "channels:notify" | "participant:added-to-list-moderators" | "participant:removed-from-list-moderators" | "participant:move-request-to-stream" | "participation:accepting-word-request" | "participation:cancelling-word-request" | "webcast:started" | "webcast:stopped" | "account:changed" | "account:deleted" | "conference:participant-token-issued")[];
|
|
6
6
|
export declare const SESSION_EVENT_NAMES: readonly ["ended", "connecting", "sending", "reinvite", "replaces", "refer", "progress", "accepted", "confirmed", "peerconnection", "failed", "muted", "unmuted", "newDTMF", "newInfo", "hold", "unhold", "update", "sdp", "icecandidate", "getusermediafailed", "peerconnection:createofferfailed", "peerconnection:createanswerfailed", "peerconnection:setlocaldescriptionfailed", "peerconnection:setremotedescriptionfailed", "presentation:start", "presentation:started", "presentation:end", "presentation:ended", "presentation:failed", "availableSecondRemoteStream", "notAvailableSecondRemoteStream", "mustStopPresentation", "shareState", "enterRoom", "useLicense", "peerconnection:confirmed", "peerconnection:ontrack", "channels", "ended:fromserver", "main-cam-control", "admin-start-main-cam", "admin-stop-main-cam", "admin-stop-mic", "admin-start-mic", "admin-force-sync-media-state"];
|
|
7
7
|
export type TEventUA = (typeof UA_EVENT_NAMES)[number];
|
|
8
8
|
export type TEventSession = (typeof SESSION_EVENT_NAMES)[number];
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./SipConnector-3317ff75.cjs"),q=require("ts-debounce"),H=require("@krivega/cancelable-promise"),Y=require("debug");require("events-constructor");const L="purgatory",P=e=>e===L,w=e=>()=>(s.logger("getRemoteStreams"),e.getRemoteStreams()),z=({kind:e,readyState:n})=>e==="video"&&n==="live",x=e=>({track:n})=>{z(n)&&e()},B=({getRemoteStreams:e,setRemoteStreams:n})=>q.debounce(()=>{const t=e();s.logger("remoteStreams",t),t&&n(t)},200),J=e=>async t=>{const{mediaStream:r,extraHeaders:o,iceServers:c,degradationPreference:a,setRemoteStreams:u,onBeforeProgressCall:d,onSuccessProgressCall:E,onEnterPurgatory:f,onEnterConference:m,onFailProgressCall:y,onFinishProgressCall:h,onEndedCall:M}=t,C=B({setRemoteStreams:u,getRemoteStreams:w(e)}),T=x(C);s.logger("answerIncomingCall",t);const O=async()=>e.answerToIncomingCall({mediaStream:r,extraHeaders:o,iceServers:c,degradationPreference:a,ontrack:T}),A=()=>{const{remoteCallerData:S}=e;return S.incomingNumber};let _=!1,i;const l=(()=>(s.logger("subscribeEnterConference: onEnterConference",m),f??m?e.onSession("enterRoom",S=>{s.logger("enterRoom",{_room:S,isSuccessProgressCall:_}),i=S,P(i)?f&&f():m&&m({isSuccessProgressCall:_})}):()=>{}))(),R=S=>(s.logger("onSuccess"),_=!0,C(),E&&E({isPurgatory:P(i)}),e.onceRaceSession(["ended","failed"],()=>{l(),M&&M()}),S),b=S=>{throw s.logger("onFail"),y&&y(),l(),S},N=()=>{s.logger("onFinish"),h&&h()};if(s.logger("onBeforeProgressCall"),d){const S=A();d(S)}return O().then(R).catch(b).finally(N)},Q=e=>async t=>{const{conference:r,mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,setRemoteStreams:d,onBeforeProgressCall:E,onSuccessProgressCall:f,onEnterPurgatory:m,onEnterConference:y,onFailProgressCall:h,onFinishProgressCall:M,onEndedCall:C}=t,T=B({setRemoteStreams:d,getRemoteStreams:w(e)}),O=x(T);s.logger("callToServer",t);const A=async()=>(s.logger("startCall"),e.call({mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,number:r,ontrack:O}));let _=!1,i;const l=(()=>(s.logger("subscribeEnterConference: onEnterConference",y),m??y?e.onSession("enterRoom",S=>{s.logger("enterRoom",{_room:S,isSuccessProgressCall:_}),i=S,P(i)?m&&m():y&&y({isSuccessProgressCall:_})}):()=>{}))(),R=S=>(s.logger("onSuccess"),_=!0,T(),f&&f({isPurgatory:P(i)}),e.onceRaceSession(["ended","failed"],()=>{l(),C&&C()}),S),b=S=>{throw s.logger("onFail"),h&&h(),l(),S},N=()=>{s.logger("onFinish"),M&&M()};return s.logger("onBeforeProgressCall"),E&&E(r),A().then(R).catch(b).finally(N)},p=e=>{if(!H.isCanceledError(e))throw e;return!1},Z=e=>async t=>{const{userAgent:r,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,name:d,password:E,isRegisteredUser:f,sdpSemantics:m,isDisconnectOnFail:y}=t;return s.logger("connectToServer",t),e.connect({userAgent:r,sdpSemantics:m,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,password:E,user:d,register:f}).then(()=>(s.logger("connectToServer then"),!0)).catch(async h=>(s.logger("connectToServer catch: error",h),y===!0?e.disconnect().then(()=>p(h)).catch(()=>p(h)):p(h)))},ee=e=>async()=>(s.logger("disconnectFromServer"),e.disconnect().then(()=>(s.logger("disconnectFromServer: then"),!1)).catch(n=>(s.logger("disconnectFromServer: catch",n),!1))),D=e=>{const{url:n,cause:t}=e;let r=n;return(t===s.BAD_MEDIA_DESCRIPTION||t===s.NOT_FOUND)&&(r=`${e.message.to.uri.user}@${e.message.to.uri.host}`),r};var V=(e=>(e.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",e.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",e.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",e.NOT_FOUND_ERROR="NOT_FOUND_ERROR",e.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",e.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",e))(V||{});const ne=(e=new Error)=>{var o;const{cause:n,socket:t}=e;let r="CONNECT_SERVER_FAILED";switch(n){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case s.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case s.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t&&((o=t==null?void 0:t._ws)==null?void 0:o.readyState)===3?r="WS_CONNECTION_FAILED":D(e)&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},te=(e=new Error)=>{const{code:n,cause:t,message:r}=e,o=D(e),c={};return r&&(c.message=r),o&&(c.link=o),n&&(c.code=n),t&&(c.cause=t),c},re=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:V,getLinkError:D,getTypeFromError:ne,getValuesFromError:te},Symbol.toStringTag,{value:"Module"})),se=({sessionId:e,remoteAddress:n,isMutedAudio:t,isMutedVideo:r,isRegistered:o,isPresentationCall:c})=>{const a=[],u=t?"0":"1",d=r?"0":"1";return a.push(`X-Vinteo-Mic-State: ${u}`,`X-Vinteo-MainCam-State: ${d}`),o||a.push("X-Vinteo-Purgatory-Call: yes"),e&&a.push(`X-Vinteo-Session: ${e}`),c&&a.push("X-Vinteo-Presentation-Call: yes"),n&&a.push(`X-Vinteo-Remote: ${n}`),a},oe=({appName:e,appVersion:n,browserName:t,browserVersion:r})=>{const o=`${e} ${n}`;return`ChromeNew - ${t?`${t} ${r}, ${o}`:o}`},ce=({isUnifiedSdpSemantic:e,appVersion:n,browserName:t,browserVersion:r,appName:o})=>e?oe({appVersion:n,browserName:t,browserVersion:r,appName:o}):"Chrome",ae=e=>async()=>{if(e.isCallActive)return s.logger("askPermissionToEnableCam"),e.askPermissionToEnableCam()},ie=e=>t=>(s.logger("onMustStopPresentation"),e.onSession("mustStopPresentation",t)),ue=e=>t=>(s.logger("onUseLicense"),e.onSession("useLicense",t)),le=e=>async({isEnabledCam:t,isEnabledMic:r})=>{if(e.isCallActive)return s.logger("sendMediaState"),e.sendMediaState({cam:t,mic:r})},ge=e=>async()=>{if(e.isCallActive)return s.logger("sendRefusalToTurnOnCam"),e.sendRefusalToTurnOnCam().catch(t=>{s.logger("sendRefusalToTurnOnCam: error",t)})},Se=e=>async()=>{if(e.isCallActive)return s.logger("sendRefusalToTurnOnMic"),e.sendRefusalToTurnOnMic().catch(t=>{s.logger("sendRefusalToTurnOnMic: error",t)})},de=1e6,me=({maxBitrate:e=de,sipConnector:n})=>async({mediaStream:r,isP2P:o=!1})=>(s.logger("startPresentation"),n.startPresentation(r,{isP2P:o,maxBitrate:e})),fe=({sipConnector:e})=>async({isP2P:t=!1}={})=>(s.logger("stopShareSipConnector"),e.stopPresentation({isP2P:t}).catch(s.logger)),Ee=1e6,Ce=({sipConnector:e,maxBitrate:n=Ee})=>async({mediaStream:r,isP2P:o=!1})=>(s.logger("updatePresentation"),e.updatePresentation(r,{isP2P:o,maxBitrate:n})),Re="ERROR_NOT_RUNNING",he=e=>{const n=new Error("Promise was not running");return n.basePromise=e,n.id=Re,n.name="Not running",n},Me=async(e,n)=>e.reduce(async(t,r)=>t.then(async({success:o,errors:c,results:a})=>(!n||n(r)?r():Promise.reject(he(r))).then(u=>({errors:c,success:[...o,u],results:[...a,u],isSuccessful:!0,isError:!1})).catch(u=>({success:o,errors:[...c,u],results:[...a,u],isSuccessful:!1,isError:!0}))),Promise.resolve({success:[],errors:[],results:[],isSuccessful:!1,isError:!1})),ye=e=>n=>[...n].map(r=>async()=>e(r)),Te=async({accumulatedKeys:e,sendKey:n,canRunTask:t})=>{const o=ye(n)(e);return Me(o,t)},_e=e=>t=>(s.logger("onStartMainCam"),e.onSession("admin-start-main-cam",t)),be=e=>t=>(s.logger("onStartMic"),e.onSession("admin-start-mic",t)),ve=e=>t=>(s.logger("onStopMainCam"),e.onSession("admin-stop-main-cam",t)),Ne=e=>t=>(s.logger("onStopMic"),e.onSession("admin-stop-mic",t)),Oe=({sipConnector:e})=>{const n=(M,C)=>({isSyncForced:T=!1})=>{if(T){M();return}C()},t=_e(e),r=ve(e),o=be(e),c=Ne(e);let a=()=>{},u=()=>{},d=()=>{},E=()=>{};const f=({onStartMainCamForced:M,onStartMainCamNotForced:C,onStopMainCamForced:T,onStopMainCamNotForced:O,onStartMicForced:A,onStartMicNotForced:_,onStopMicForced:i,onStopMicNotForced:g})=>{const l=n(M,C);a=t(l);const R=n(T,O);u=r(R);const b=n(A,_);d=o(b);const N=n(i,g);E=c(N)},m=()=>{a(),u(),d(),E()};return{start:M=>{f(M)},stop:()=>{m()}}},Ae=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:L,createSyncMediaState:Oe,error:re,getExtraHeaders:se,getUserAgent:ce,hasPurgatory:P,resolveAnswerIncomingCall:J,resolveAskPermissionToEnableCam:ae,resolveCallToServer:Q,resolveConnectToServer:Z,resolveDisconnectFromServer:ee,resolveGetRemoteStreams:w,resolveOnMustStopPresentation:ie,resolveOnUseLicense:ue,resolveSendMediaState:le,resolveSendRefusalToTurnOnCam:ge,resolveSendRefusalToTurnOnMic:Se,resolveStartPresentation:me,resolveStopShareSipConnector:fe,resolveUpdatePresentation:Ce,resolveUpdateRemoteStreams:B,sendDTMFAccumulated:Te},Symbol.toStringTag,{value:"Module"})),Pe=e=>[...e.keys()].map(n=>e.get(n)),pe=(e,n)=>Pe(e).find(t=>t.type===n),$=async e=>e.getStats().then(n=>{const t=pe(n,"codec");return t==null?void 0:t.mimeType}),Ie=e=>e.find(n=>{var t;return((t=n==null?void 0:n.track)==null?void 0:t.kind)==="video"}),j=(e,n)=>e!==void 0&&n!==void 0&&e.toLowerCase().includes(n.toLowerCase()),we="ERROR_NOT_RUNNING",Be=e=>{const n=new Error("Promise was not running");return n.basePromise=e,n.id=we,n.name="Not running",n},De=async(e,n)=>e.reduce(async(t,r)=>t.then(async({success:o,errors:c,results:a})=>(!n||n(r)?r():Promise.reject(Be(r))).then(u=>({errors:c,success:[...o,u],results:[...a,u],isSuccessful:!0,isError:!1})).catch(u=>({success:o,errors:[...c,u],results:[...a,u],isSuccessful:!1,isError:!0}))),Promise.resolve({success:[],errors:[],results:[],isSuccessful:!1,isError:!1})),ke=new Error("Stack is empty"),Fe=new Error("Promise is not actual"),Ue=new Error("stackPromises only works with functions that returns a Promise"),Le=({noRejectIsNotActual:e=!1,noRunIsNotActual:n=!1}={})=>{const t=[],r=[],o=({task:i,index:g})=>{r.push({task:i,index:g})},c=(i,{task:g,index:l})=>{const R=r.find(({task:b,index:N})=>g===b&&l===N);if(!R)throw new Error("Task not found");if(R.promise)throw new Error("Task is already running");R.promise=i},a=({task:i,index:g})=>{const l=r.find(({task:R,index:b})=>i===R&&g===b);if(l)return l.promise},u=({task:i})=>{const g=r.at(-1);return(g==null?void 0:g.task)===i},d=({task:i,index:g})=>(o({task:i,index:g}),async()=>{let l=a({task:i,index:g});const R=u({task:i});return!l&&n&&!R?Promise.resolve():(l||(l=i({isActual:R}),c(l,{task:i,index:g})),l)}),E=({resolve:i,reject:g})=>({results:l,isSuccessful:R})=>{const b=l.length,N=t.length;if(b===N){const S=l.at(-1);if(R){i(S);return}g(S);return}if(e){const S=l.at(-1);i(S);return}g(Fe)};let f=!1;const m=()=>{f=!0},y=()=>{f=!1},h=()=>f,M=async()=>(m(),De(t,h)),C=async()=>{if(t.length===0)throw ke;return new Promise((i,g)=>{const l=E({resolve:i,reject:g});M().then(l).catch(l)})},T=i=>{if(typeof i!="function")throw Ue;const g=t.length;return t.push(d({task:i,index:g})),C},O=async i=>(T(i),C()),A=()=>{t.length=0,r.length=0},_=()=>{y(),A()};return C.add=T,C.run=O,C.stop=_,C},xe=1e6,v=e=>e*xe,G=v(.06),Ve=v(4),$e=e=>e<=64?G:e<=128?v(.12):e<=256?v(.25):e<=384?v(.32):e<=426?v(.38):e<=640?v(.5):e<=848?v(.7):e<=1280?v(1):e<=1920?v(2):Ve,je="av1",Ge=e=>j(e,je),Xe=.6,X=(e,n)=>Ge(n)?e*Xe:e,Ke=e=>X(G,e),K=(e,n)=>{const t=$e(e);return X(t,n)},W=Le(),We=async()=>W().catch(e=>{s.logger("videoSendingBalancer: error",e)}),qe=async e=>(W.add(e),We()),k=async({sender:e,scaleResolutionDownBy:n,maxBitrate:t,onSetParameters:r})=>qe(async()=>s.setEncodingsToSender(e,{scaleResolutionDownBy:n,maxBitrate:t},r)),He=async({sender:e,codec:n},t)=>{const o=Ke(n);return k({sender:e,maxBitrate:o,onSetParameters:t,scaleResolutionDownBy:200})},I=async({sender:e,track:n,codec:t},r)=>{const a=n.getSettings().width,u=K(a,t);return k({sender:e,maxBitrate:u,onSetParameters:r,scaleResolutionDownBy:1})},Ye=async({sender:e,track:n,resolution:t,codec:r},o)=>{const c=n.getSettings(),a=c.width,u=c.height,[d,E]=t.split("x"),f=a/Number(d),m=u/Number(E),h=Math.max(f,m,1),M=K(Number(d),r);return k({sender:e,maxBitrate:M,onSetParameters:o,scaleResolutionDownBy:h})},ze=async({mainCam:e,resolutionMainCam:n,sender:t,track:r,codec:o},c)=>{switch(e){case s.EEventsMainCAM.PAUSE_MAIN_CAM:return He({sender:t,codec:o},c);case s.EEventsMainCAM.RESUME_MAIN_CAM:return I({sender:t,track:r,codec:o},c);case s.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return n!==void 0?Ye({sender:t,track:r,codec:o,resolution:n},c):I({sender:t,track:r,codec:o},c);default:return I({sender:t,track:r,codec:o},c)}},F={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},U=async({mainCam:e,resolutionMainCam:n,connection:t,onSetParameters:r,ignoreForCodec:o})=>{const c=t.getSenders(),a=Ie(c);if(!(a!=null&&a.track))return F;const u=await $(a);return j(u,o)?F:ze({mainCam:e,resolutionMainCam:n,sender:a,codec:u,track:a.track},r)},Je=(e,{ignoreForCodec:n,onSetParameters:t}={})=>{const r=async()=>{const{connection:d}=e;if(!d)throw new Error("connection is not exist");return U({connection:d,onSetParameters:t,ignoreForCodec:n})};let o=r;const c=async d=>(o=async()=>{const{mainCam:E,resolutionMainCam:f}=d,{connection:m}=e;if(!m)throw new Error("connection is not exist");return U({mainCam:E,resolutionMainCam:f,connection:m,onSetParameters:t,ignoreForCodec:n})},o());return{subscribe:()=>{e.onSession("main-cam-control",c)},unsubscribe:()=>{e.offSession("main-cam-control",c)},balanceByTrack:r,resetMainCamControl(){o=r},async reBalance(){return o()}}};exports.EEventsMainCAM=s.EEventsMainCAM;exports.EEventsMic=s.EEventsMic;exports.EEventsSyncMediaState=s.EEventsSyncMediaState;exports.EUseLicense=s.EUseLicense;exports.causes=s.causes;exports.constants=s.constants;exports.default=s.SipConnector;exports.disableDebug=s.disableDebug;exports.enableDebug=s.enableDebug;exports.eventNames=s.eventNames;exports.hasCanceledCallError=s.hasCanceledCallError;exports.debug=Y;exports.getCodecFromSender=$;exports.resolveVideoSendingBalancer=Je;exports.tools=Ae;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./SipConnector-XqVe938n.cjs"),q=require("ts-debounce"),H=require("@krivega/cancelable-promise"),Y=require("debug");require("events-constructor");const L="purgatory",P=e=>e===L,w=e=>()=>(s.logger("getRemoteStreams"),e.getRemoteStreams()),z=({kind:e,readyState:n})=>e==="video"&&n==="live",x=e=>({track:n})=>{z(n)&&e()},B=({getRemoteStreams:e,setRemoteStreams:n})=>q.debounce(()=>{const t=e();s.logger("remoteStreams",t),t&&n(t)},200),J=e=>async t=>{const{mediaStream:r,extraHeaders:o,iceServers:c,degradationPreference:a,setRemoteStreams:u,onBeforeProgressCall:d,onSuccessProgressCall:E,onEnterPurgatory:f,onEnterConference:m,onFailProgressCall:y,onFinishProgressCall:h,onEndedCall:M}=t,C=B({setRemoteStreams:u,getRemoteStreams:w(e)}),T=x(C);s.logger("answerIncomingCall",t);const O=async()=>e.answerToIncomingCall({mediaStream:r,extraHeaders:o,iceServers:c,degradationPreference:a,ontrack:T}),A=()=>{const{remoteCallerData:S}=e;return S.incomingNumber};let _=!1,i;const l=(s.logger("subscribeEnterConference: onEnterConference",m),f??m?e.onSession("enterRoom",S=>{s.logger("enterRoom",{_room:S,isSuccessProgressCall:_}),i=S,P(i)?f&&f():m&&m({isSuccessProgressCall:_})}):()=>{}),R=S=>(s.logger("onSuccess"),_=!0,C(),E&&E({isPurgatory:P(i)}),e.onceRaceSession(["ended","failed"],()=>{l(),M&&M()}),S),b=S=>{throw s.logger("onFail"),y&&y(),l(),S},N=()=>{s.logger("onFinish"),h&&h()};if(s.logger("onBeforeProgressCall"),d){const S=A();d(S)}return O().then(R).catch(b).finally(N)},Q=e=>async t=>{const{conference:r,mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,setRemoteStreams:d,onBeforeProgressCall:E,onSuccessProgressCall:f,onEnterPurgatory:m,onEnterConference:y,onFailProgressCall:h,onFinishProgressCall:M,onEndedCall:C}=t,T=B({setRemoteStreams:d,getRemoteStreams:w(e)}),O=x(T);s.logger("callToServer",t);const A=async()=>(s.logger("startCall"),e.call({mediaStream:o,extraHeaders:c,iceServers:a,degradationPreference:u,number:r,ontrack:O}));let _=!1,i;const l=(s.logger("subscribeEnterConference: onEnterConference",y),m??y?e.onSession("enterRoom",S=>{s.logger("enterRoom",{_room:S,isSuccessProgressCall:_}),i=S,P(i)?m&&m():y&&y({isSuccessProgressCall:_})}):()=>{}),R=S=>(s.logger("onSuccess"),_=!0,T(),f&&f({isPurgatory:P(i)}),e.onceRaceSession(["ended","failed"],()=>{l(),C&&C()}),S),b=S=>{throw s.logger("onFail"),h&&h(),l(),S},N=()=>{s.logger("onFinish"),M&&M()};return s.logger("onBeforeProgressCall"),E&&E(r),A().then(R).catch(b).finally(N)},p=e=>{if(!H.isCanceledError(e))throw e;return!1},Z=e=>async t=>{const{userAgent:r,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,name:d,password:E,isRegisteredUser:f,sdpSemantics:m,isDisconnectOnFail:y}=t;return s.logger("connectToServer",t),e.connect({userAgent:r,sdpSemantics:m,sipWebSocketServerURL:o,sipServerUrl:c,remoteAddress:a,displayName:u,password:E,user:d,register:f}).then(()=>(s.logger("connectToServer then"),!0)).catch(async h=>(s.logger("connectToServer catch: error",h),y===!0?e.disconnect().then(()=>p(h)).catch(()=>p(h)):p(h)))},ee=e=>async()=>(s.logger("disconnectFromServer"),e.disconnect().then(()=>(s.logger("disconnectFromServer: then"),!1)).catch(n=>(s.logger("disconnectFromServer: catch",n),!1))),D=e=>{const{url:n,cause:t}=e;let r=n;return(t===s.BAD_MEDIA_DESCRIPTION||t===s.NOT_FOUND)&&(r=`${e.message.to.uri.user}@${e.message.to.uri.host}`),r};var V=(e=>(e.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",e.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",e.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",e.NOT_FOUND_ERROR="NOT_FOUND_ERROR",e.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",e.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",e))(V||{});const ne=(e=new Error)=>{var o;const{cause:n,socket:t}=e;let r="CONNECT_SERVER_FAILED";switch(n){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case s.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case s.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t&&((o=t==null?void 0:t._ws)==null?void 0:o.readyState)===3?r="WS_CONNECTION_FAILED":D(e)&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},te=(e=new Error)=>{const{code:n,cause:t,message:r}=e,o=D(e),c={};return r&&(c.message=r),o&&(c.link=o),n&&(c.code=n),t&&(c.cause=t),c},re=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:V,getLinkError:D,getTypeFromError:ne,getValuesFromError:te},Symbol.toStringTag,{value:"Module"})),se=({sessionId:e,remoteAddress:n,isMutedAudio:t,isMutedVideo:r,isRegistered:o,isPresentationCall:c})=>{const a=[],u=t?"0":"1",d=r?"0":"1";return a.push(`X-Vinteo-Mic-State: ${u}`,`X-Vinteo-MainCam-State: ${d}`),o||a.push("X-Vinteo-Purgatory-Call: yes"),e&&a.push(`X-Vinteo-Session: ${e}`),c&&a.push("X-Vinteo-Presentation-Call: yes"),n&&a.push(`X-Vinteo-Remote: ${n}`),a},oe=({appName:e,appVersion:n,browserName:t,browserVersion:r})=>{const o=`${e} ${n}`;return`ChromeNew - ${t?`${t} ${r}, ${o}`:o}`},ce=({isUnifiedSdpSemantic:e,appVersion:n,browserName:t,browserVersion:r,appName:o})=>e?oe({appVersion:n,browserName:t,browserVersion:r,appName:o}):"Chrome",ae=e=>async()=>{if(e.isCallActive)return s.logger("askPermissionToEnableCam"),e.askPermissionToEnableCam()},ie=e=>t=>(s.logger("onMustStopPresentation"),e.onSession("mustStopPresentation",t)),ue=e=>t=>(s.logger("onUseLicense"),e.onSession("useLicense",t)),le=e=>async({isEnabledCam:t,isEnabledMic:r})=>{if(e.isCallActive)return s.logger("sendMediaState"),e.sendMediaState({cam:t,mic:r})},ge=e=>async()=>{if(e.isCallActive)return s.logger("sendRefusalToTurnOnCam"),e.sendRefusalToTurnOnCam().catch(t=>{s.logger("sendRefusalToTurnOnCam: error",t)})},Se=e=>async()=>{if(e.isCallActive)return s.logger("sendRefusalToTurnOnMic"),e.sendRefusalToTurnOnMic().catch(t=>{s.logger("sendRefusalToTurnOnMic: error",t)})},de=1e6,me=({maxBitrate:e=de,sipConnector:n})=>async({mediaStream:r,isP2P:o=!1})=>(s.logger("startPresentation"),n.startPresentation(r,{isP2P:o,maxBitrate:e})),fe=({sipConnector:e})=>async({isP2P:t=!1}={})=>(s.logger("stopShareSipConnector"),e.stopPresentation({isP2P:t}).catch(s.logger)),Ee=1e6,Ce=({sipConnector:e,maxBitrate:n=Ee})=>async({mediaStream:r,isP2P:o=!1})=>(s.logger("updatePresentation"),e.updatePresentation(r,{isP2P:o,maxBitrate:n})),Re="ERROR_NOT_RUNNING",he=e=>{const n=new Error("Promise was not running");return n.basePromise=e,n.id=Re,n.name="Not running",n},Me=async(e,n)=>e.reduce(async(t,r)=>t.then(async({success:o,errors:c,results:a})=>(!n||n(r)?r():Promise.reject(he(r))).then(u=>({errors:c,success:[...o,u],results:[...a,u],isSuccessful:!0,isError:!1})).catch(u=>({success:o,errors:[...c,u],results:[...a,u],isSuccessful:!1,isError:!0}))),Promise.resolve({success:[],errors:[],results:[],isSuccessful:!1,isError:!1})),ye=e=>n=>[...n].map(r=>async()=>e(r)),Te=async({accumulatedKeys:e,sendKey:n,canRunTask:t})=>{const o=ye(n)(e);return Me(o,t)},_e=e=>t=>(s.logger("onStartMainCam"),e.onSession("admin-start-main-cam",t)),be=e=>t=>(s.logger("onStartMic"),e.onSession("admin-start-mic",t)),ve=e=>t=>(s.logger("onStopMainCam"),e.onSession("admin-stop-main-cam",t)),Ne=e=>t=>(s.logger("onStopMic"),e.onSession("admin-stop-mic",t)),Oe=({sipConnector:e})=>{const n=(M,C)=>({isSyncForced:T=!1})=>{if(T){M();return}C()},t=_e(e),r=ve(e),o=be(e),c=Ne(e);let a=()=>{},u=()=>{},d=()=>{},E=()=>{};const f=({onStartMainCamForced:M,onStartMainCamNotForced:C,onStopMainCamForced:T,onStopMainCamNotForced:O,onStartMicForced:A,onStartMicNotForced:_,onStopMicForced:i,onStopMicNotForced:g})=>{const l=n(M,C);a=t(l);const R=n(T,O);u=r(R);const b=n(A,_);d=o(b);const N=n(i,g);E=c(N)},m=()=>{a(),u(),d(),E()};return{start:M=>{f(M)},stop:()=>{m()}}},Ae=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:L,createSyncMediaState:Oe,error:re,getExtraHeaders:se,getUserAgent:ce,hasPurgatory:P,resolveAnswerIncomingCall:J,resolveAskPermissionToEnableCam:ae,resolveCallToServer:Q,resolveConnectToServer:Z,resolveDisconnectFromServer:ee,resolveGetRemoteStreams:w,resolveOnMustStopPresentation:ie,resolveOnUseLicense:ue,resolveSendMediaState:le,resolveSendRefusalToTurnOnCam:ge,resolveSendRefusalToTurnOnMic:Se,resolveStartPresentation:me,resolveStopShareSipConnector:fe,resolveUpdatePresentation:Ce,resolveUpdateRemoteStreams:B,sendDTMFAccumulated:Te},Symbol.toStringTag,{value:"Module"})),Pe=e=>[...e.keys()].map(n=>e.get(n)),pe=(e,n)=>Pe(e).find(t=>t.type===n),$=async e=>e.getStats().then(n=>{const t=pe(n,"codec");return t==null?void 0:t.mimeType}),Ie=e=>e.find(n=>{var t;return((t=n==null?void 0:n.track)==null?void 0:t.kind)==="video"}),j=(e,n)=>e!==void 0&&n!==void 0&&e.toLowerCase().includes(n.toLowerCase()),we="ERROR_NOT_RUNNING",Be=e=>{const n=new Error("Promise was not running");return n.basePromise=e,n.id=we,n.name="Not running",n},De=async(e,n)=>e.reduce(async(t,r)=>t.then(async({success:o,errors:c,results:a})=>(!n||n(r)?r():Promise.reject(Be(r))).then(u=>({errors:c,success:[...o,u],results:[...a,u],isSuccessful:!0,isError:!1})).catch(u=>({success:o,errors:[...c,u],results:[...a,u],isSuccessful:!1,isError:!0}))),Promise.resolve({success:[],errors:[],results:[],isSuccessful:!1,isError:!1})),ke=new Error("Stack is empty"),Fe=new Error("Promise is not actual"),Ue=new Error("stackPromises only works with functions that returns a Promise"),Le=({noRejectIsNotActual:e=!1,noRunIsNotActual:n=!1}={})=>{const t=[],r=[],o=({task:i,index:g})=>{r.push({task:i,index:g})},c=(i,{task:g,index:l})=>{const R=r.find(({task:b,index:N})=>g===b&&l===N);if(!R)throw new Error("Task not found");if(R.promise)throw new Error("Task is already running");R.promise=i},a=({task:i,index:g})=>{const l=r.find(({task:R,index:b})=>i===R&&g===b);if(l)return l.promise},u=({task:i})=>{const g=r.at(-1);return(g==null?void 0:g.task)===i},d=({task:i,index:g})=>(o({task:i,index:g}),async()=>{let l=a({task:i,index:g});const R=u({task:i});return!l&&n&&!R?Promise.resolve():(l||(l=i({isActual:R}),c(l,{task:i,index:g})),l)}),E=({resolve:i,reject:g})=>({results:l,isSuccessful:R})=>{const b=l.length,N=t.length;if(b===N){const S=l.at(-1);if(R){i(S);return}g(S);return}if(e){const S=l.at(-1);i(S);return}g(Fe)};let f=!1;const m=()=>{f=!0},y=()=>{f=!1},h=()=>f,M=async()=>(m(),De(t,h)),C=async()=>{if(t.length===0)throw ke;return new Promise((i,g)=>{const l=E({resolve:i,reject:g});M().then(l).catch(l)})},T=i=>{if(typeof i!="function")throw Ue;const g=t.length;return t.push(d({task:i,index:g})),C},O=async i=>(T(i),C()),A=()=>{t.length=0,r.length=0},_=()=>{y(),A()};return C.add=T,C.run=O,C.stop=_,C},xe=1e6,v=e=>e*xe,G=v(.06),Ve=v(4),$e=e=>e<=64?G:e<=128?v(.12):e<=256?v(.25):e<=384?v(.32):e<=426?v(.38):e<=640?v(.5):e<=848?v(.7):e<=1280?v(1):e<=1920?v(2):Ve,je="av1",Ge=e=>j(e,je),Xe=.6,X=(e,n)=>Ge(n)?e*Xe:e,Ke=e=>X(G,e),K=(e,n)=>{const t=$e(e);return X(t,n)},W=Le(),We=async()=>W().catch(e=>{s.logger("videoSendingBalancer: error",e)}),qe=async e=>(W.add(e),We()),k=async({sender:e,scaleResolutionDownBy:n,maxBitrate:t,onSetParameters:r})=>qe(async()=>s.setEncodingsToSender(e,{scaleResolutionDownBy:n,maxBitrate:t},r)),He=async({sender:e,codec:n},t)=>{const o=Ke(n);return k({sender:e,maxBitrate:o,onSetParameters:t,scaleResolutionDownBy:200})},I=async({sender:e,track:n,codec:t},r)=>{const a=n.getSettings().width,u=K(a,t);return k({sender:e,maxBitrate:u,onSetParameters:r,scaleResolutionDownBy:1})},Ye=async({sender:e,track:n,resolution:t,codec:r},o)=>{const c=n.getSettings(),a=c.width,u=c.height,[d,E]=t.split("x"),f=a/Number(d),m=u/Number(E),h=Math.max(f,m,1),M=K(Number(d),r);return k({sender:e,maxBitrate:M,onSetParameters:o,scaleResolutionDownBy:h})},ze=async({mainCam:e,resolutionMainCam:n,sender:t,track:r,codec:o},c)=>{switch(e){case s.EEventsMainCAM.PAUSE_MAIN_CAM:return He({sender:t,codec:o},c);case s.EEventsMainCAM.RESUME_MAIN_CAM:return I({sender:t,track:r,codec:o},c);case s.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return n!==void 0?Ye({sender:t,track:r,codec:o,resolution:n},c):I({sender:t,track:r,codec:o},c);default:return I({sender:t,track:r,codec:o},c)}},F={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},U=async({mainCam:e,resolutionMainCam:n,connection:t,onSetParameters:r,ignoreForCodec:o})=>{const c=t.getSenders(),a=Ie(c);if(!(a!=null&&a.track))return F;const u=await $(a);return j(u,o)?F:ze({mainCam:e,resolutionMainCam:n,sender:a,codec:u,track:a.track},r)},Je=(e,{ignoreForCodec:n,onSetParameters:t}={})=>{const r=async()=>{const{connection:d}=e;if(!d)throw new Error("connection is not exist");return U({connection:d,onSetParameters:t,ignoreForCodec:n})};let o=r;const c=async d=>(o=async()=>{const{mainCam:E,resolutionMainCam:f}=d,{connection:m}=e;if(!m)throw new Error("connection is not exist");return U({mainCam:E,resolutionMainCam:f,connection:m,onSetParameters:t,ignoreForCodec:n})},o());return{subscribe:()=>{e.onSession("main-cam-control",c)},unsubscribe:()=>{e.offSession("main-cam-control",c)},balanceByTrack:r,resetMainCamControl(){o=r},async reBalance(){return o()}}};exports.EEventsMainCAM=s.EEventsMainCAM;exports.EEventsMic=s.EEventsMic;exports.EEventsSyncMediaState=s.EEventsSyncMediaState;exports.EUseLicense=s.EUseLicense;exports.causes=s.causes;exports.constants=s.constants;exports.default=s.SipConnector;exports.disableDebug=s.disableDebug;exports.enableDebug=s.enableDebug;exports.eventNames=s.eventNames;exports.hasCanceledCallError=s.hasCanceledCallError;exports.debug=Y;exports.getCodecFromSender=$;exports.resolveVideoSendingBalancer=Je;exports.tools=Ae;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as c, B as x, N as V, E as P, s as z, S as en } from "./SipConnector-
|
|
2
|
-
import { f as un, g as ln, i as Sn, c as dn, a as mn, d as fn, b as Cn, e as En, h as gn } from "./SipConnector-
|
|
1
|
+
import { l as c, B as x, N as V, E as P, s as z, S as en } from "./SipConnector-_AhwhWtL.js";
|
|
2
|
+
import { f as un, g as ln, i as Sn, c as dn, a as mn, d as fn, b as Cn, e as En, h as gn } from "./SipConnector-_AhwhWtL.js";
|
|
3
3
|
import { debounce as q } from "ts-debounce";
|
|
4
4
|
import { isCanceledError as J } from "@krivega/cancelable-promise";
|
|
5
5
|
import { default as hn } from "debug";
|
|
@@ -42,10 +42,10 @@ const $ = "purgatory", A = (e) => e === $, B = (e) => () => (c("getRemoteStreams
|
|
|
42
42
|
return d.incomingNumber;
|
|
43
43
|
};
|
|
44
44
|
let M = !1, i;
|
|
45
|
-
const l = (
|
|
45
|
+
const l = (c("subscribeEnterConference: onEnterConference", f), C ?? f ? e.onSession("enterRoom", (d) => {
|
|
46
46
|
c("enterRoom", { _room: d, isSuccessProgressCall: M }), i = d, A(i) ? C && C() : f && f({ isSuccessProgressCall: M });
|
|
47
47
|
}) : () => {
|
|
48
|
-
})
|
|
48
|
+
}), R = (d) => (c("onSuccess"), M = !0, g(), E && E({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
|
|
49
49
|
l(), y && y();
|
|
50
50
|
}), d), b = (d) => {
|
|
51
51
|
throw c("onFail"), T && T(), l(), d;
|
|
@@ -86,10 +86,10 @@ const $ = "purgatory", A = (e) => e === $, B = (e) => () => (c("getRemoteStreams
|
|
|
86
86
|
ontrack: v
|
|
87
87
|
}));
|
|
88
88
|
let M = !1, i;
|
|
89
|
-
const l = (
|
|
89
|
+
const l = (c("subscribeEnterConference: onEnterConference", T), f ?? T ? e.onSession("enterRoom", (d) => {
|
|
90
90
|
c("enterRoom", { _room: d, isSuccessProgressCall: M }), i = d, A(i) ? f && f() : T && T({ isSuccessProgressCall: M });
|
|
91
91
|
}) : () => {
|
|
92
|
-
})
|
|
92
|
+
}), R = (d) => (c("onSuccess"), M = !0, _(), C && C({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
|
|
93
93
|
l(), g && g();
|
|
94
94
|
}), d), b = (d) => {
|
|
95
95
|
throw c("onFail"), h && h(), l(), d;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sip-connector",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.22.0",
|
|
4
4
|
"description": "Module for connect to Vinteo server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webrtc",
|
|
@@ -72,39 +72,39 @@
|
|
|
72
72
|
"webrtc-mock": "^1.0.1"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@babel/preset-typescript": "^7.23.
|
|
76
|
-
"@commitlint/cli": "^18.
|
|
77
|
-
"@commitlint/config-conventional": "^18.
|
|
78
|
-
"@nabla/vite-plugin-eslint": "^
|
|
79
|
-
"@types/debug": "^4.1.
|
|
80
|
-
"@types/jest": "^29.5.
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
82
|
-
"@typescript-eslint/parser": "^6.
|
|
75
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
76
|
+
"@commitlint/cli": "^18.4.3",
|
|
77
|
+
"@commitlint/config-conventional": "^18.4.3",
|
|
78
|
+
"@nabla/vite-plugin-eslint": "^2.0.2",
|
|
79
|
+
"@types/debug": "^4.1.12",
|
|
80
|
+
"@types/jest": "^29.5.10",
|
|
81
|
+
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
82
|
+
"@typescript-eslint/parser": "^6.12.0",
|
|
83
83
|
"cross-env": "^7.0.3",
|
|
84
|
-
"eslint": "^8.
|
|
84
|
+
"eslint": "^8.54.0",
|
|
85
85
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
86
86
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
87
87
|
"eslint-config-prettier": "^9.0.0",
|
|
88
88
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
89
89
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
90
90
|
"eslint-plugin-import": "^2.29.0",
|
|
91
|
-
"eslint-plugin-jest": "^27.
|
|
91
|
+
"eslint-plugin-jest": "^27.6.0",
|
|
92
92
|
"eslint-plugin-prettier": "^5.0.1",
|
|
93
|
-
"eslint-plugin-unicorn": "^
|
|
93
|
+
"eslint-plugin-unicorn": "^49.0.0",
|
|
94
94
|
"husky": "^8.0.3",
|
|
95
95
|
"jest": "^29.7.0",
|
|
96
96
|
"jest-environment-jsdom": "^29.7.0",
|
|
97
97
|
"jest-extended": "^4.0.2",
|
|
98
98
|
"jest-junit": "^16.0.0",
|
|
99
|
-
"lint-staged": "^15.0
|
|
100
|
-
"prettier": "^3.0
|
|
99
|
+
"lint-staged": "^15.1.0",
|
|
100
|
+
"prettier": "^3.1.0",
|
|
101
101
|
"standard-version": "^9.5.0",
|
|
102
102
|
"ts-jest": "^29.1.1",
|
|
103
103
|
"ts-node": "^10.9.1",
|
|
104
104
|
"tsc-files": "^1.1.4",
|
|
105
|
-
"typescript": "^5.
|
|
106
|
-
"vite": "^
|
|
107
|
-
"vite-plugin-dts": "^3.6.
|
|
105
|
+
"typescript": "^5.3.2",
|
|
106
|
+
"vite": "^5.0.2",
|
|
107
|
+
"vite-plugin-dts": "^3.6.3",
|
|
108
108
|
"vite-tsconfig-paths": "^4.2.1"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var Rt=Object.defineProperty;var It=(r,e,t)=>e in r?Rt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>(It(r,typeof e!="symbol"?e+"":e,t),t);const T=require("@krivega/cancelable-promise"),pe=require("events-constructor"),B=require("debug"),mt="Connection Error",He="Request Timeout",ft="SIP Failure Code",Ot="Internal Error",Mt="Busy",V="Rejected",Dt="Redirected",Pt="Unavailable",qe="Not Found",pt="Address Incomplete",vt="Incompatible SDP",bt="Missing SDP",yt="Authentication Error",Fe="Terminated",wt="WebRTC Error",ke="Canceled",Ut="No Answer",Lt="Expires",Ht="No ACK",qt="Dialog Error",Ft="User Denied Media Access",We="Bad Media Description",kt="RTP Timeout",Wt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:pt,AUTHENTICATION_ERROR:yt,BAD_MEDIA_DESCRIPTION:We,BUSY:Mt,BYE:Fe,CANCELED:ke,CONNECTION_ERROR:mt,DIALOG_ERROR:qt,EXPIRES:Lt,INCOMPATIBLE_SDP:vt,INTERNAL_ERROR:Ot,MISSING_SDP:bt,NOT_FOUND:qe,NO_ACK:Ht,NO_ANSWER:Ut,REDIRECTED:Dt,REJECTED:V,REQUEST_TIMEOUT:He,RTP_TIMEOUT:kt,SIP_FAILURE_CODE:ft,UNAVAILABLE:Pt,USER_DENIED_MEDIA_ACCESS:Ft,WEBRTC_ERROR:wt},Symbol.toStringTag,{value:"Module"})),Y="incomingCall",x="declinedIncomingCall",$="failedIncomingCall",G="terminatedIncomingCall",L="connecting",O="connected",N="disconnected",M="newRTCSession",A="registered",X="unregistered",R="registrationFailed",Be="newMessage",J="sipEvent",z="availableSecondRemoteStream",Q="notAvailableSecondRemoteStream",K="mustStopPresentation",D="shareState",j="enterRoom",Z="useLicense",ee="peerconnection:confirmed",te="peerconnection:ontrack",P="channels",se="channels:notify",ne="ended:fromserver",ie="main-cam-control",re="admin-stop-main-cam",oe="admin-start-main-cam",ae="admin-stop-mic",ce="admin-start-mic",p="admin-force-sync-media-state",Ee="participant:added-to-list-moderators",_e="participant:removed-from-list-moderators",he="participant:move-request-to-conference",de="participant:move-request-to-stream",le="participant:canceling-word-request",ue="webcast:started",Te="webcast:stopped",Se="account:changed",Ne="account:deleted",Ce="conference:participant-token-issued",I="ended",Ve="sending",Ye="reinvite",xe="replaces",$e="refer",Ge="progress",Xe="accepted",v="confirmed",b="peerconnection",C="failed",Je="muted",ze="unmuted",ge="newDTMF",Ae="newInfo",Qe="hold",Ke="unhold",je="update",Ze="sdp",et="icecandidate",tt="getusermediafailed",st="peerconnection:createofferfailed",nt="peerconnection:createanswerfailed",it="peerconnection:setlocaldescriptionfailed",rt="peerconnection:setremotedescriptionfailed",ot="presentation:start",at="presentation:started",ct="presentation:end",Re="presentation:ended",y="presentation:failed",Bt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:Xe,ACCOUNT_CHANGED:Se,ACCOUNT_DELETED:Ne,ADMIN_FORCE_SYNC_MEDIA_STATE:p,ADMIN_START_MAIN_CAM:oe,ADMIN_START_MIC:ce,ADMIN_STOP_MAIN_CAM:re,ADMIN_STOP_MIC:ae,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:z,CHANNELS:P,CHANNELS_NOTIFY:se,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:Ce,CONFIRMED:v,CONNECTED:O,CONNECTING:L,DECLINED_INCOMING_CALL:x,DISCONNECTED:N,ENDED:I,ENDED_FROM_SERVER:ne,ENTER_ROOM:j,FAILED:C,FAILED_INCOMING_CALL:$,GET_USER_MEDIA_FAILED:tt,HOLD:Qe,ICE_CANDIDATE:et,INCOMING_CALL:Y,MAIN_CAM_CONTROL:ie,MUST_STOP_PRESENTATION_EVENT:K,MUTED:Je,NEW_DTMF:ge,NEW_INFO:Ae,NEW_MESSAGE:Be,NEW_RTC_SESSION:M,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Q,PARTICIPANT_ADDED_TO_LIST_MODERATORS:Ee,PARTICIPANT_CANCELLING_WORD_REQUEST:le,PARTICIPANT_MOVE_REQUEST_TO_CONFERENCE:he,PARTICIPANT_MOVE_REQUEST_TO_STREAM:de,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:_e,PEER_CONNECTION:b,PEER_CONNECTION_CONFIRMED:ee,PEER_CONNECTION_CREATE_ANSWER_FAILED:nt,PEER_CONNECTION_CREATE_OFFER_FAILED:st,PEER_CONNECTION_ONTRACK:te,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:it,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:rt,PRESENTATION_END:ct,PRESENTATION_ENDED:Re,PRESENTATION_FAILED:y,PRESENTATION_START:ot,PRESENTATION_STARTED:at,PROGRESS:Ge,REFER:$e,REGISTERED:A,REGISTRATION_FAILED:R,REINVITE:Ye,REPLACES:xe,SDP:Ze,SENDING:Ve,SHARE_STATE:D,SIP_EVENT:J,TERMINATED_INCOMING_CALL:G,UNHOLD:Ke,UNMUTED:ze,UNREGISTERED:X,UPDATE:je,USE_LICENSE:Z,WEBCAST_STARTED:ue,WEBCAST_STOPPED:Te},Symbol.toStringTag,{value:"Module"})),Et=[Y,x,G,$,le,de,he,se,Ce,Se,Ne,ue,Te,Ee,_e],Ie=[L,O,N,M,A,X,R,Be,J],_t=[z,Q,K,D,j,Z,ee,te,P,ne,ie,oe,re,ae,ce,p],me=[I,L,Ve,Ye,xe,$e,Ge,Xe,v,b,C,Je,ze,ge,Ae,Qe,Ke,je,Ze,et,tt,st,nt,it,rt,ot,at,ct,Re,y],fe=[...Ie,...Et],Oe=[...me,..._t],Vt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:Oe,SESSION_JSSIP_EVENT_NAMES:me,SESSION_SYNTHETICS_EVENT_NAMES:_t,UA_EVENT_NAMES:fe,UA_JSSIP_EVENT_NAMES:Ie,UA_SYNTHETICS_EVENT_NAMES:Et},Symbol.toStringTag,{value:"Module"})),Yt=r=>{const e=[];return r&&e.push(`X-Vinteo-Remote: ${r}`),e},xt="content-type",$t="x-webrtc-enter-room",q="application/vinteo.webrtc.sharedesktop",Gt="application/vinteo.webrtc.roomname",Xt="application/vinteo.webrtc.channels",Jt="application/vinteo.webrtc.mediastate",zt="application/vinteo.webrtc.refusal",ve="application/vinteo.webrtc.maincam",Qt="application/vinteo.webrtc.mic",Kt="application/vinteo.webrtc.uselic",jt="X-WEBRTC-USE-LICENSE",be="X-WEBRTC-INPUT-CHANNELS",ye="X-WEBRTC-OUTPUT-CHANNELS",Zt="X-WEBRTC-MAINCAM",es="X-WEBRTC-MIC",we="X-WEBRTC-SYNC",ts="X-WEBRTC-MAINCAM-RESOLUTION",ss="X-WEBRTC-MEDIA-STATE",ns="X-Vinteo-Media-Type",is="X-Vinteo-MainCam-State",rs="X-Vinteo-Mic-State",os="application/vinteo.webrtc.notify",as="X-VINTEO-NOTIFY",m="x-webrtc-share-state",cs=`${m}: LETMESTARTPRESENTATION`,Es=`${m}: STOPPRESENTATION`,ht="YOUCANRECEIVECONTENT",dt="CONTENTEND",_s="YOUMUSTSTOPSENDCONTENT",hs=`${m}: ${ht}`,ds=`${m}: ${dt}`,ls="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",us=`${ls}: LETMESTARTMAINCAM`,Me="sip-connector",k=B(Me),Ts=()=>{B.enable(`${Me}`)},Ss=()=>{B.enable(`-${Me}`)};var g=(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))(g||{}),w=(r=>(r.ADMIN_STOP_MIC="ADMINSTOPMIC",r.ADMIN_START_MIC="ADMINSTARTMIC",r))(w||{}),U=(r=>(r.ADMIN_SYNC_FORCED="1",r.ADMIN_SYNC_NOT_FORCED="0",r))(U||{}),lt=(r=>(r.AUDIO="AUDIO",r.VIDEO="VIDEO",r.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",r))(lt||{});function Ns(r){return e=>`sip:${e}@${r}`}const Cs=(r,e)=>()=>Math.floor(Math.random()*(e-r))+r,Ue=r=>r.trim().replaceAll(" ","_"),gs=Cs(1e5,99999999),F=(r,{videoMode:e,audioMode:t}={})=>{if(!r||e==="recvonly"&&t==="recvonly")return;const s=t==="recvonly"?[]:r.getAudioTracks(),n=e==="recvonly"?[]:r.getVideoTracks(),o=[...s,...n],a=new MediaStream(o);return a.getTracks=()=>[...a.getAudioTracks(),...a.getVideoTracks()],a},As=r=>r.some(t=>{const{kind:s}=t;return s==="video"}),Rs="Error decline with 603",Is=r=>r.message===Rs,ms=(r,e)=>r.find(t=>t.track&&e.getTracks().includes(t.track)),ut=1,Tt=r=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==r,fs=Tt(ut),Os=(r,e)=>{const t=r===void 0?void 0:Math.max(r,ut);if(t!==void 0&&fs(t,e))return t},Ms=Tt(),Ds=(r,e)=>{if(Ms(r,e))return r},St=async(r,e,t)=>{const s=r.getParameters();(s.encodings===void 0||s.encodings.length===0)&&(s.encodings=[{}]);const[n]=s.encodings,o=n.scaleResolutionDownBy,a=Os(e.scaleResolutionDownBy,o);let c=!1;a!==void 0&&(s.encodings[0].scaleResolutionDownBy=a,c=!0);const E=n.maxBitrate,_=Ds(e.maxBitrate,E);return _!==void 0&&(s.encodings[0].maxBitrate=_,c=!0),c?(t&&t(s),r.setParameters(s).then(()=>({parameters:s,isChanged:c}))):{parameters:s,isChanged:c}},Ps=async(r,e,t)=>{const s=ms(r,e);if(s)return St(s,{maxBitrate:t})},ps=486,vs=487,W="local",Le="remote",bs=(r=new Error)=>{const{originator:e,cause:t}=r;return T.isCanceledError(r)?!0:typeof t=="string"?t===He||t===V||e===W&&(t===ke||t===Fe):!1},S="SipConnector",ys="channels",ws="WebcastStarted",Us="WebcastStopped",Ls="accountChanged",Hs="accountDeleted",qs="addedToListModerators",Fs="removedFromListModerators",ks="WebcastParticipationAccepted",Ws="WebcastParticipationRejected",Bs="ParticipantMovedToWebcast",Vs="ConferenceParticipantTokenIssued";class Ys{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,"_cancelableCreateUa");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=>(this._cancelRequests(),this._cancelableConnect.request(e)));i(this,"createUa",async e=>this._cancelableCreateUa.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(L,void 0);try{await this.unregister()}catch(e){k("tryRegister",e)}return this.register()});i(this,"declineToIncomingCall",async({statusCode:e=vs}={})=>new Promise((t,s)=>{if(!this.isAvailableIncomingCall){s(new Error("no incomingSession"));return}const n=this.incomingSession,o=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(x,o),t(n.terminate({status_code:e}))}));i(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:ps}));i(this,"removeIncomingSession",()=>{delete this.incomingSession});i(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===Le){this.incomingSession=t;const s=this.remoteCallerData;t.on(C,n=>{this.removeIncomingSession(),n.originator===W?this._uaEvents.trigger(G,s):this._uaEvents.trigger($,s)}),this._uaEvents.trigger(Y,s)}});i(this,"_connect",async e=>this.createUa(e).then(async()=>this._start()));i(this,"_createUa",async({displayName:e="",user:t,password:s,register:n=!1,sipServerUrl:o,sipWebSocketServerURL:a,remoteAddress:c,extraHeaders:E=[],sdpSemantics:_="plan-b",sessionTimers:h=!1,registerExpires:d=60*5,connectionRecoveryMinInterval:l=2,connectionRecoveryMaxInterval:u=6,userAgent:f})=>{if(!o)throw new Error("sipServerUrl is required");if(!a)throw new Error("sipWebSocketServerURL is required");if(n&&!t)throw new Error("user is required for authorized connection");if(n&&!s)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:o,displayName:e,register:n,user:t,password:s},this._init({sipServerUrl:o,sipWebSocketServerURL:a});const H=n&&t?t.trim():`${gs()}`,De={password:s,register:n,display_name:Ue(e),user_agent:f,sdp_semantics:_,sockets:[this.socket],uri:this.getSipServerUrl(H),session_timers:h,register_expires:d,connection_recovery_min_interval:l,connection_recovery_max_interval:u};this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!De.register,this.ua=new this.JsSIP.UA(De),this._uaEvents.eachTriggers((Ct,gt)=>{const Pe=Ie.find(At=>At===gt);Pe&&this.ua&&this.ua.on(Pe,Ct)});const Nt=[...Yt(c),...E];return this.ua.registrator().setExtraHeaders(Nt),this.ua});i(this,"_start",async()=>new Promise((e,t)=>{const{ua:s}=this;if(!s){t(new Error("this.ua is not initialized"));return}const n=()=>{c(),e(s)},o=E=>{c(),t(E)},a=()=>{this.isRegisterConfig?(this.on(A,n),this.on(R,o)):this.on(O,n),this.on(N,o)},c=()=>{this.off(A,n),this.off(R,o),this.off(O,n),this.off(N,o)};a(),this.on(M,this.handleNewRTCSession),s.start()}));i(this,"_set",async({displayName:e,password:t})=>new Promise((s,n)=>{const{ua:o}=this;if(!o){n(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",Ue(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=o.set("password",t),this._connectionConfiguration.password=t);const E=a||c;c&&this.isRegisterConfig?this.register().then(()=>{s(E)}).catch(n):E?s(E):n(E)}));i(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());i(this,"_disconnect",async()=>{this.off(M,this.handleNewRTCSession);const e=new Promise(t=>{this.once(N,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(N,void 0)):this._uaEvents.trigger(N,void 0),e});i(this,"_call",async({number:e,mediaStream:t,extraHeaders:s=[],ontrack:n,iceServers:o,videoMode:a,audioMode:c,degradationPreference:E,offerToReceiveAudio:_=!0,offerToReceiveVideo:h=!0})=>new Promise((d,l)=>{const{ua:u}=this;if(!u){l(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:n}).then(d).catch(l),this.session=u.call(this.getSipServerUrl(e),{extraHeaders:s,mediaStream:F(t,{videoMode:a,audioMode:c}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,degradationPreference:E,pcConfig:{iceServers:o},rtcOfferConstraints:{offerToReceiveAudio:_,offerToReceiveVideo:h}})}));i(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:s=[],iceServers:n,videoMode:o,audioMode:a,degradationPreference:c})=>new Promise((E,_)=>{if(!this.isAvailableIncomingCall){_(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:h}=this;if(!h){_(new Error("No session established"));return}this._sessionEvents.eachTriggers((l,u)=>{const f=me.find(H=>H===u);f&&h.on(f,l)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=h.remote_identity.uri.user,this._handleCall({ontrack:t}).then(E).catch(_);const d=F(e,{videoMode:o,audioMode:a});h.answer({extraHeaders:s,videoMode:o,audioMode:a,degradationPreference:c,mediaStream:d,pcConfig:{iceServers:n}})}));i(this,"_handleCall",async({ontrack:e})=>new Promise((t,s)=>{const n=()=>{this.onSession(b,h),this.onSession(v,d)},o=()=>{this.offSession(b,h),this.offSession(v,d)},a=()=>{this.onSession(C,E),this.onSession(I,E)},c=()=>{this.offSession(C,E),this.offSession(I,E)},E=l=>{o(),c(),s(l)};let _;const h=({peerconnection:l})=>{_=l,_.ontrack=u=>{this._sessionEvents.trigger(te,_),e&&e(u)}},d=()=>{_&&this._sessionEvents.trigger(ee,_),o(),c(),t(_)};n(),a()}));i(this,"_restoreSession",()=>{this._resetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});i(this,"_sendDTMF",async e=>new Promise((t,s)=>{const{session:n}=this;if(!n){s(new Error("No session established"));return}this.onceSession(ge,({originator:o})=>{o===W&&t()}),n.sendDTMF(e,{duration:120,interToneGap:600})}));i(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;this._streamPresentationCurrent&&await this.stopPresentation(),this._restoreSession(),e.isEnded()||e.terminate()}});i(this,"_handleShareState",e=>{switch(e){case ht:{this._sessionEvents.trigger(z,void 0);break}case dt:{this._sessionEvents.trigger(Q,void 0);break}case _s:{this._sessionEvents.trigger(K,void 0);break}}});i(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(be),s=e.getHeader(ye);if(t&&s){const n={inputChannels:t,outputChannels:s};this._sessionEvents.trigger(P,n)}});i(this,"_handleNotify",e=>{switch(e.cmd){case ys:{const t=e;this._triggerChannelsNotify(t);break}case ws:{const t=e;this._triggerWebcastStartedNotify(t);break}case Us:{const t=e;this._triggerWebcastStoppedNotify(t);break}case qs:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case Fs:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case ks:{const t=e;this._triggerParticipantMoveRequestToConference(t);break}case Ws:{const t=e;this._triggerParticipantCancelingWordRequest(t);break}case Bs:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case Ls:{this._triggerAccountChangedNotify();break}case Hs:{this._triggerAccountDeletedNotify();break}case Vs:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:k("unknown cmd",e.cmd)}});i(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(_e,t)});i(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Ee,t)});i(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const s={conference:e,type:t};this._uaEvents.trigger(ue,s)});i(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const s={conference:e,type:t};this._uaEvents.trigger(Te,s)});i(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Se,void 0)});i(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(Ne,void 0)});i(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:s}})=>{const n={conference:e,participant:t,jwt:s};this._uaEvents.trigger(Ce,n)});i(this,"_triggerChannelsNotify",e=>{const t=e.input,s=e.output,n={inputChannels:t,outputChannels:s};this._uaEvents.trigger(se,n)});i(this,"_triggerParticipantMoveRequestToConference",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(he,t)});i(this,"_triggerParticipantCancelingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(le,t)});i(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(de,t)});i(this,"_triggerEnterRoom",e=>{const t=e.getHeader($t);this._sessionEvents.trigger(j,t)});i(this,"_triggerShareState",e=>{const t=e.getHeader(m);this._sessionEvents.trigger(D,t)});i(this,"_triggerMainCamControl",e=>{const t=e.getHeader(Zt),s=e.getHeader(we),n=s===U.ADMIN_SYNC_FORCED;if(t===g.ADMIN_START_MAIN_CAM)this._sessionEvents.trigger(oe,{isSyncForced:n});else if(t===g.ADMIN_STOP_MAIN_CAM)this._sessionEvents.trigger(re,{isSyncForced:n});else if((t===g.RESUME_MAIN_CAM||t===g.PAUSE_MAIN_CAM)&&s)this._sessionEvents.trigger(p,{isSyncForced:n});else{const o=e.getHeader(ts);this._sessionEvents.trigger(ie,{mainCam:t,resolutionMainCam:o})}});i(this,"_triggerMicControl",e=>{const t=e.getHeader(es),n=e.getHeader(we)===U.ADMIN_SYNC_FORCED;t===w.ADMIN_START_MIC?this._sessionEvents.trigger(ce,{isSyncForced:n}):t===w.ADMIN_STOP_MIC&&this._sessionEvents.trigger(ae,{isSyncForced:n})});i(this,"_triggerUseLicense",e=>{const t=e.getHeader(jt);this._sessionEvents.trigger(Z,t)});i(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:s}=e,n=s.getHeader(xt);if(n)switch(n){case Gt:{this._triggerEnterRoom(s),this._maybeTriggerChannels(s);break}case os:{this._maybeHandleNotify(s);break}case q:{this._triggerShareState(s);break}case ve:{this._triggerMainCamControl(s);break}case Qt:{this._triggerMicControl(s);break}case Kt:{this._triggerUseLicense(s);break}}});i(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});i(this,"_maybeHandleNotify",e=>{const t=e.getHeader(as);if(t){const s=JSON.parse(t);this._handleNotify(s)}});i(this,"_handleEnded",e=>{const{originator:t}=e;t===Le&&this._sessionEvents.trigger(ne,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new pe(Oe),this._uaEvents=new pe(fe),this._cancelableConnect=new T.CancelableRequest(this._connect,{moduleName:S,afterCancelRequest:()=>{this._cancelableCreateUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableCreateUa=new T.CancelableRequest(this._createUa,{moduleName:S}),this._cancelableDisconnect=new T.CancelableRequest(this._disconnect,{moduleName:S}),this._cancelableSet=new T.CancelableRequest(this._set,{moduleName:S}),this._cancelableCall=new T.CancelableRequest(this._call,{moduleName:S}),this._cancelableAnswer=new T.CancelableRequest(this._answer,{moduleName:S}),this._cancelableSendDTMF=new T.CancelableRequest(this._sendDTMF,{moduleName:S}),this.onSession(D,this._handleShareState),this.onSession(Ae,this._handleNewInfo),this.on(J,this._handleSipEvent),this.onSession(C,this._handleEnded),this.onSession(I,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(A,e),this.ua.on(R,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(X,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,s){if(!this.ua)throw new Error("is not connected");return new Promise((n,o)=>{try{this.ua.sendOptions(e,t,{extraHeaders:s,eventHandlers:{succeeded:()=>{n()},failed:o}})}catch(a){o(a)}})}async ping(e,t){var n;if(!((n=this.ua)!=null&&n.configuration.uri))throw new Error("is not connected");const s=this.ua.configuration.uri;return this.sendOptions(s,e,t)}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");return this.session.replaceMediaStream(e,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[us];return this.session.sendInfo(ve,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(s=>{if(Is(s))throw s})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentation(e,t,{maxBitrate:s,degradationPreference:n,isNeedReinvite:o=!0,isP2P:a=!1}){const c=F(t);this._streamPresentationCurrent=c;const E=a?[hs]:[cs],_=e.sendInfo(q,void 0,{extraHeaders:E}).then(async()=>e.startPresentation(c,o,n)).then(async()=>{const{connection:h}=this;if(!h||s===void 0)return;const d=h.getSenders();return Ps(d,t,s)}).then(()=>t).catch(h=>{throw this._sessionEvents.trigger(y,h),h});return this.promisePendingStartPresentation=_,_.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t=!0,isP2P:s=!1,maxBitrate:n,degradationPreference:o}={}){const a=this.establishedSession;if(!a)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return this._sendPresentation(a,e,{isNeedReinvite:t,isP2P:s,maxBitrate:n,degradationPreference:o})}async stopPresentation({isP2P:e=!1}={}){const t=this._streamPresentationCurrent;let s=this.promisePendingStartPresentation??Promise.resolve();const n=e?[ds]:[Es],o=this.establishedSession;return o&&t&&(s=s.then(async()=>o.sendInfo(q,void 0,{extraHeaders:n})).then(async()=>o.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(y,a),a})),!o&&t&&this._sessionEvents.trigger(Re,t),this.promisePendingStopPresentation=s,s.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t=!1,maxBitrate:s,degradationPreference:n}={}){const o=this.establishedSession;if(!o)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(o,e,{isP2P:t,maxBitrate:s,degradationPreference:n,isNeedReinvite:!1})}_resetPresentation(){delete this._streamPresentationCurrent,this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}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:s})=>s);return As(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,s,n,o,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(n=(s=this.incomingSession)==null?void 0:s.remote_identity)==null?void 0:n.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._cancelableCreateUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){return this.session&&this.session.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}_init({sipServerUrl:e,sipWebSocketServerURL:t}){this.getSipServerUrl=Ns(e),this.socket=new this.JsSIP.WebSocketInterface(t)}_generateStream(e,t){const{id:s}=e,n=this._remoteStreams[s]||new MediaStream;return t&&n.addTrack(t),n.addTrack(e),this._remoteStreams[s]=n,n}_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,n)=>{if(s.kind==="audio")return;const o=s,a=e[n-1];let c;a&&a.kind==="audio"&&(c=a);const E=this._generateStream(o,c);t.push(E)}),t}_generateAudioStreams(e){return e.map(s=>this._generateAudioStream(s))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectRequests()}_cancelConnectRequests(){this._cancelableConnect.cancelRequest()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(P)}async waitSyncMediaState(){return this.waitSession(p)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const s=`${be}: ${e}`,n=`${ye}: ${t}`,o=[s,n];return this.session.sendInfo(Xt,void 0,{extraHeaders:o})}async sendMediaState({cam:e,mic:t},s={}){if(!this.session)throw new Error("No session established");const n=`${ss}: currentstate`,o=`${is}: ${Number(e)}`,a=`${rs}: ${Number(t)}`,c=[n,o,a];return this.session.sendInfo(Jt,void 0,{noTerminateWhenError:!0,...s,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${ns}: ${e==="mic"?0:1}`];return this.session.sendInfo(zt,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=We;exports.EEventsMainCAM=g;exports.EEventsMic=w;exports.EEventsSyncMediaState=U;exports.EUseLicense=lt;exports.NOT_FOUND=qe;exports.REJECTED=V;exports.SESSION_EVENT_NAMES=Oe;exports.SipConnector=Ys;exports.UA_EVENT_NAMES=fe;exports.causes=Wt;exports.constants=Bt;exports.disableDebug=Ss;exports.enableDebug=Ts;exports.eventNames=Vt;exports.hasCanceledCallError=bs;exports.logger=k;exports.setEncodingsToSender=St;
|