sip-connector 13.1.0 → 13.2.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.
@@ -1,10 +1,7 @@
1
1
  import { UA } from '@krivega/jssip';
2
2
  import { default as SipConnector } from '../SipConnector';
3
3
  import { EUseLicense, TContentHint, TSimulcastEncoding } from '../types';
4
- declare class SipConnectorFacade {
5
- readonly sipConnector: SipConnector;
6
- private readonly preferredMimeTypesVideoCodecs?;
7
- private readonly excludeMimeTypesVideoCodecs?;
4
+ interface IProxyMethods {
8
5
  on: SipConnector['on'];
9
6
  once: SipConnector['once'];
10
7
  onceRace: SipConnector['onceRace'];
@@ -22,12 +19,34 @@ declare class SipConnectorFacade {
22
19
  sendChannels: SipConnector['sendChannels'];
23
20
  checkTelephony: SipConnector['checkTelephony'];
24
21
  waitChannels: SipConnector['waitChannels'];
25
- ping: SipConnector['ping'];
22
+ connection: SipConnector['connection'];
23
+ }
24
+ declare class SipConnectorFacade implements IProxyMethods {
25
+ readonly sipConnector: SipConnector;
26
+ private readonly preferredMimeTypesVideoCodecs?;
27
+ private readonly excludeMimeTypesVideoCodecs?;
28
+ on: IProxyMethods['on'];
29
+ once: IProxyMethods['once'];
30
+ onceRace: IProxyMethods['onceRace'];
31
+ wait: IProxyMethods['wait'];
32
+ off: IProxyMethods['off'];
33
+ onSession: IProxyMethods['onSession'];
34
+ onceSession: IProxyMethods['onceSession'];
35
+ onceRaceSession: IProxyMethods['onceRaceSession'];
36
+ waitSession: IProxyMethods['waitSession'];
37
+ offSession: IProxyMethods['offSession'];
38
+ sendDTMF: IProxyMethods['sendDTMF'];
39
+ hangUp: IProxyMethods['hangUp'];
40
+ declineToIncomingCall: IProxyMethods['declineToIncomingCall'];
41
+ isConfigured: IProxyMethods['isConfigured'];
42
+ sendChannels: IProxyMethods['sendChannels'];
43
+ checkTelephony: IProxyMethods['checkTelephony'];
44
+ waitChannels: IProxyMethods['waitChannels'];
45
+ connection: IProxyMethods['connection'];
26
46
  constructor(sipConnector: SipConnector, { preferredMimeTypesVideoCodecs, excludeMimeTypesVideoCodecs, }?: {
27
47
  preferredMimeTypesVideoCodecs?: string[];
28
48
  excludeMimeTypesVideoCodecs?: string[];
29
49
  });
30
- get isRegistered(): boolean;
31
50
  connectToServer: (parameters: {
32
51
  userAgent: string;
33
52
  sipWebSocketServerURL: string;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ne=Object.defineProperty;var te=(n,e,t)=>e in n?ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var l=(n,e,t)=>te(n,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("./SipConnector-CE4F15z6.cjs"),se=require("sequent-promises"),oe=require("stack-promises"),re=require("@krivega/cancelable-promise"),ie=require("repeated-calls"),ce=require("ts-debounce"),ae=require("debug"),$=n=>{const{url:e,cause:t}=n;let s=e;return(t===o.BAD_MEDIA_DESCRIPTION||t===o.NOT_FOUND)&&(s=`${n.message.to.uri.user}@${n.message.to.uri.host}`),s};var j=(n=>(n.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",n.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",n.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",n.NOT_FOUND_ERROR="NOT_FOUND_ERROR",n.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",n.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",n))(j||{});const le=(n=new Error)=>{var r;const{cause:e,socket:t}=n;let s="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{s="WRONG_USER_OR_PASSWORD";break}case o.BAD_MEDIA_DESCRIPTION:{s="BAD_MEDIA_ERROR";break}case o.NOT_FOUND:{s="NOT_FOUND_ERROR";break}default:t&&((r=t==null?void 0:t._ws)==null?void 0:r.readyState)===3?s="WS_CONNECTION_FAILED":$(n)&&(s="CONNECT_SERVER_FAILED_BY_LINK")}return s},ue=n=>{let e="";try{e=JSON.stringify(n)}catch(t){o.logger("failed to stringify message",t)}return e},de=(n=new Error)=>{const{code:e,cause:t,message:s}=n,r=$(n),i={code:"",cause:"",message:""};return typeof s=="object"&&s!==null?i.message=ue(s):s&&(i.message=String(s)),r&&(i.link=r),e&&(i.code=e),t&&(i.cause=t),i},ge=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:j,getLinkError:$,getTypeFromError:le,getValuesFromError:de},Symbol.toStringTag,{value:"Module"})),Se=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:s,isRegistered:r,isPresentationCall:i})=>{const c=[],a=t?"0":"1",u=s?"0":"1";return c.push(`X-Vinteo-Mic-State: ${a}`,`X-Vinteo-MainCam-State: ${u}`),r||c.push("X-Vinteo-Purgatory-Call: yes"),n&&c.push(`X-Vinteo-Session: ${n}`),i&&c.push("X-Vinteo-Presentation-Call: yes"),e&&c.push(`X-Vinteo-Remote: ${e}`),c},Ce="[@*!|]",he="_",fe=n=>{let e=n;return e=e.replaceAll(new RegExp(Ce,"g"),he),e},me=({appName:n,appVersion:e,browserName:t,browserVersion:s})=>{const i=`${fe(n)} ${e}`;return`ChromeNew - ${t?`${t} ${s}, ${i}`:i}`},Re=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:s,appName:r})=>n?me({appVersion:e,browserName:t,browserVersion:s,appName:r}):"Chrome",W="purgatory",B=n=>n===W,pe=n=>e=>[...e].map(s=>async()=>n(s)),Ee=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const r=pe(e)(n);return se.sequentPromises(r,t)},ye=n=>t=>(o.logger("onStartMainCam"),n.onSession("admin-start-main-cam",t)),Te=n=>t=>(o.logger("onStartMic"),n.onSession("admin-start-mic",t)),be=n=>t=>(o.logger("onStopMainCam"),n.onSession("admin-stop-main-cam",t)),Me=n=>t=>(o.logger("onStopMic"),n.onSession("admin-stop-mic",t)),Ae=({sipConnector:n})=>{const e=(h,p)=>({isSyncForced:f=!1})=>{if(f){h();return}p()},t=ye(n),s=be(n),r=Te(n),i=Me(n);let c=()=>{},a=()=>{},u=()=>{},g=()=>{};const C=({onStartMainCamForced:h,onStartMainCamNotForced:p,onStopMainCamForced:f,onStopMainCamNotForced:m,onStartMicForced:E,onStartMicNotForced:y,onStopMicForced:T,onStopMicNotForced:b})=>{const _=e(h,p);c=t(_);const v=e(f,m);a=s(v);const O=e(E,y);u=r(O);const N=e(T,b);g=i(N)},S=()=>{c(),a(),u(),g()};return{start:h=>{C(h)},stop:()=>{S()}}},_e=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:W,createSyncMediaState:Ae,error:ge,getExtraHeaders:Se,getUserAgent:Re,hasPurgatory:B,sendDTMFAccumulated:Ee},Symbol.toStringTag,{value:"Module"})),ve=n=>[...n.keys()].map(e=>n.get(e)),Oe=(n,e)=>ve(n).find(t=>t.type===e),G=async n=>n.getStats().then(e=>{const t=Oe(e,"codec");return t==null?void 0:t.mimeType}),Ne=n=>n.find(e=>{var t;return((t=e==null?void 0:e.track)==null?void 0:t.kind)==="video"}),K=(n,e)=>n!==void 0&&e!==void 0&&n.toLowerCase().includes(e.toLowerCase()),Pe=1e6,R=n=>n*Pe,Y=R(.06),De=R(4),we=n=>n<=64?Y:n<=128?R(.12):n<=256?R(.25):n<=384?R(.32):n<=426?R(.38):n<=640?R(.5):n<=848?R(.7):n<=1280?R(1):n<=1920?R(2):De,Be="av1",Ie=n=>K(n,Be),Fe=.6,z=(n,e)=>Ie(e)?n*Fe:n,ke=n=>z(Y,n),Q=(n,e)=>{const t=we(n);return z(t,e)},Ue=1,J=({videoTrack:n,targetSize:e,codec:t})=>{const s=n.getSettings(),r=s.width,i=s.height,c=r/e.width,a=i/e.height,u=Math.max(c,a,Ue),g=Q(e.width,t);return{scaleResolutionDownBy:u,maxBitrate:g}},Z=oe.createStackPromises(),Ve=async()=>Z().catch(n=>{o.logger("videoSendingBalancer: error",n)}),Le=async n=>(Z.add(n),Ve()),q=async({sender:n,scaleResolutionDownBy:e,maxBitrate:t,onSetParameters:s})=>Le(async()=>o.setEncodingsToSender(n,{scaleResolutionDownBy:e,maxBitrate:t},s)),xe=async({sender:n,codec:e},t)=>{const r=ke(e);return q({sender:n,maxBitrate:r,onSetParameters:t,scaleResolutionDownBy:200})},L=async({sender:n,videoTrack:e,codec:t},s)=>{const c=e.getSettings().width,a=Q(c,t);return q({sender:n,maxBitrate:a,onSetParameters:s,scaleResolutionDownBy:1})},$e=async({sender:n,videoTrack:e,resolution:t,codec:s},r)=>{const[i,c]=t.split("x"),{maxBitrate:a,scaleResolutionDownBy:u}=J({videoTrack:e,codec:s,targetSize:{width:Number(i),height:Number(c)}});return q({sender:n,maxBitrate:a,onSetParameters:r,scaleResolutionDownBy:u})},qe=async({mainCam:n,resolutionMainCam:e,sender:t,videoTrack:s,codec:r},i)=>{switch(n){case o.EEventsMainCAM.PAUSE_MAIN_CAM:return xe({sender:t,codec:r},i);case o.EEventsMainCAM.RESUME_MAIN_CAM:return L({sender:t,videoTrack:s,codec:r},i);case o.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return e!==void 0?$e({sender:t,videoTrack:s,codec:r,resolution:e},i):L({sender:t,videoTrack:s,codec:r},i);default:return L({sender:t,videoTrack:s,codec:r},i)}},H={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},X=async({mainCam:n,resolutionMainCam:e,connection:t,onSetParameters:s,ignoreForCodec:r})=>{const i=t.getSenders(),c=Ne(i);if(!(c!=null&&c.track))return H;const a=await G(c);return K(a,r)?H:qe({mainCam:n,resolutionMainCam:e,sender:c,codec:a,videoTrack:c.track},s)},He=(n,{ignoreForCodec:e,onSetParameters:t}={})=>{const s=async()=>{const{connection:u}=n;if(!u)throw new Error("connection is not exist");return X({connection:u,onSetParameters:t,ignoreForCodec:e})};let r=s;const i=async u=>(r=async()=>{const{mainCam:g,resolutionMainCam:C}=u,{connection:S}=n;if(!S)throw new Error("connection is not exist");return X({mainCam:g,resolutionMainCam:C,connection:S,onSetParameters:t,ignoreForCodec:e})},r());return{subscribe:()=>{n.onSession("main-cam-control",i)},unsubscribe:()=>{n.offSession("main-cam-control",i)},balanceByTrack:s,resetMainCamControl(){r=s},async reBalance(){return r()}}},Xe=n=>n.getVideoTracks()[0],D=({mediaStream:n,simulcastEncodings:e,sendEncodings:t})=>{if(e&&e.length>0){const s=t??[],r=Xe(n);return e.forEach((i,c)=>{const a=s[c]??{};a.active=!0,i.rid!==void 0&&(a.rid=i.rid),i.scalabilityMode!==void 0&&(a.scalabilityMode=i.scalabilityMode);const{maxBitrate:u,scaleResolutionDownBy:g}=J({videoTrack:r,targetSize:{width:i.width,height:i.height}});a.maxBitrate=u,a.scaleResolutionDownBy=g,s[c]=a}),s}return t},je=(n,e)=>[...n,...e].filter((r,i,c)=>i===c.findIndex(a=>a.clockRate===r.clockRate&&a.mimeType===r.mimeType&&a.channels===r.channels&&a.sdpFmtpLine===r.sdpFmtpLine)),We=n=>{const e=RTCRtpSender.getCapabilities(n),t=RTCRtpReceiver.getCapabilities(n),s=e===null?[]:e.codecs,r=t===null?[]:t.codecs;return je(s,r)},Ge=(n,e)=>e===void 0||e.length===0?n:n.sort((t,s)=>{const r=e.indexOf(t.mimeType),i=e.indexOf(s.mimeType),c=r===-1?Number.MAX_VALUE:r,a=i===-1?Number.MAX_VALUE:i;return c-a}),Ke=(n,e)=>e===void 0||e.length===0?n:n.filter(t=>!e.includes(t.mimeType)),w=(n,{preferredMimeTypesVideoCodecs:e,excludeMimeTypesVideoCodecs:t})=>async s=>{var r;if(typeof s.setCodecPreferences=="function"&&((r=s.sender.track)==null?void 0:r.kind)==="video"&&(e!==void 0&&(e==null?void 0:e.length)>0||t!==void 0&&(t==null?void 0:t.length)>0)){const i=We("video"),c=Ke(i,t),a=Ge(c,e);s.setCodecPreferences(a)}Object.keys(n).length>0&&await o.setParametersToSender(s.sender,n)},x=n=>{if(!re.isCanceledError(n)&&!ie.hasCanceledError(n))throw n;return{isSuccessful:!1}},Ye=({kind:n,readyState:e})=>n==="video"&&e==="live";class ze{constructor(e,{preferredMimeTypesVideoCodecs:t,excludeMimeTypesVideoCodecs:s}={}){l(this,"sipConnector");l(this,"preferredMimeTypesVideoCodecs");l(this,"excludeMimeTypesVideoCodecs");l(this,"on");l(this,"once");l(this,"onceRace");l(this,"wait");l(this,"off");l(this,"onSession");l(this,"onceSession");l(this,"onceRaceSession");l(this,"waitSession");l(this,"offSession");l(this,"sendDTMF");l(this,"hangUp");l(this,"declineToIncomingCall");l(this,"isConfigured");l(this,"sendChannels");l(this,"checkTelephony");l(this,"waitChannels");l(this,"ping");l(this,"connectToServer",async e=>{const{userAgent:t,sipWebSocketServerURL:s,sipServerUrl:r,remoteAddress:i,displayName:c,name:a,password:u,isRegisteredUser:g,isDisconnectOnFail:C}=e;return o.logger("connectToServer",e),this.sipConnector.connect({userAgent:t,sipWebSocketServerURL:s,sipServerUrl:r,remoteAddress:i,displayName:c,password:u,user:a,register:g}).then(S=>(o.logger("connectToServer then"),{ua:S,isSuccessful:!0})).catch(async S=>(o.logger("connectToServer catch: error",S),C===!0?this.sipConnector.disconnect().then(()=>x(S)).catch(()=>x(S)):x(S)))});l(this,"callToServer",async e=>{const{conference:t,mediaStream:s,extraHeaders:r,iceServers:i,contentHint:c,simulcastEncodings:a,degradationPreference:u,sendEncodings:g,offerToReceiveAudio:C,offerToReceiveVideo:S,directionVideo:I,directionAudio:F,setRemoteStreams:h,onBeforeProgressCall:p,onSuccessProgressCall:f,onEnterPurgatory:m,onEnterConference:E,onFailProgressCall:y,onFinishProgressCall:T,onEndedCall:b}=e,_=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:h}),v=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:_}),O=w({degradationPreference:u},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});o.logger("callToServer",e);const N=async()=>(o.logger("startCall"),this.sipConnector.call({mediaStream:s,extraHeaders:r,iceServers:i,contentHint:c,offerToReceiveAudio:C,offerToReceiveVideo:S,directionVideo:I,directionAudio:F,sendEncodings:D({mediaStream:s,simulcastEncodings:a,sendEncodings:g}),number:t,onAddedTransceiver:O,ontrack:v}));let M=!1,A;const P=(o.logger("subscribeEnterConference: onEnterConference",E),m??E?this.sipConnector.onSession("enterRoom",({room:d})=>{o.logger("enterRoom",{_room:d,isSuccessProgressCall:M}),A=d,B(A)?m&&m():E&&E({isSuccessProgressCall:M})}):()=>{}),k=d=>(o.logger("onSuccess"),M=!0,_(),f&&f({isPurgatory:B(A)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{P(),b&&b()}),d),U=d=>{throw o.logger("onFail"),y&&y(),P(),d},V=()=>{o.logger("onFinish"),T&&T()};return o.logger("onBeforeProgressCall"),p&&p(t),N().then(k).catch(d=>U(d)).finally(V)});l(this,"disconnectFromServer",async()=>this.sipConnector.disconnect().then(()=>(o.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(o.logger("disconnectFromServer: catch",e),{isSuccessful:!1})));l(this,"answerIncomingCall",async e=>{const{mediaStream:t,extraHeaders:s,iceServers:r,contentHint:i,simulcastEncodings:c,degradationPreference:a,sendEncodings:u,offerToReceiveAudio:g,offerToReceiveVideo:C,directionVideo:S,directionAudio:I,setRemoteStreams:F,onBeforeProgressCall:h,onSuccessProgressCall:p,onEnterPurgatory:f,onEnterConference:m,onFailProgressCall:E,onFinishProgressCall:y,onEndedCall:T}=e,b=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:F}),_=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:b}),v=w({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});o.logger("answerIncomingCall",e);const O=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:s,iceServers:r,contentHint:i,offerToReceiveAudio:g,offerToReceiveVideo:C,directionVideo:S,directionAudio:I,sendEncodings:D({mediaStream:t,simulcastEncodings:c,sendEncodings:u}),onAddedTransceiver:v,ontrack:_}),N=()=>{const{remoteCallerData:d}=this.sipConnector;return d.incomingNumber};let M=!1,A;const P=(o.logger("subscribeEnterConference: onEnterConference",m),f??m?this.sipConnector.onSession("enterRoom",d=>{o.logger("enterRoom",{_room:d,isSuccessProgressCall:M}),A=d,B(A)?f&&f():m&&m({isSuccessProgressCall:M})}):()=>{}),k=d=>(o.logger("onSuccess"),M=!0,b(),p&&p({isPurgatory:B(A)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{P(),T&&T()}),d),U=d=>{throw o.logger("onFail"),E&&E(),P(),d},V=()=>{o.logger("onFinish"),y&&y()};if(o.logger("onBeforeProgressCall"),h){const d=N();h(d)}return O().then(k).catch(d=>U(d)).finally(V)});l(this,"updatePresentation",async({mediaStream:e,isP2P:t,maxBitrate:s,contentHint:r,simulcastEncodings:i,degradationPreference:c,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g})=>{const C=w({degradationPreference:c},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return o.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,maxBitrate:s,contentHint:r,sendEncodings:D({mediaStream:e,simulcastEncodings:i,sendEncodings:a}),onAddedTransceiver:C})});l(this,"startPresentation",async({mediaStream:e,isP2P:t,maxBitrate:s,contentHint:r,simulcastEncodings:i,degradationPreference:c,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g},C)=>{const S=w({degradationPreference:c},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return o.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,maxBitrate:s,contentHint:r,sendEncodings:D({mediaStream:e,simulcastEncodings:i,sendEncodings:a}),onAddedTransceiver:S},C)});l(this,"stopShareSipConnector",async({isP2P:e=!1}={})=>(o.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{o.logger(t)})));l(this,"sendRefusalToTurnOnMic",async()=>{if(this.sipConnector.isCallActive)return o.logger("sendRefusalToTurnOnMic"),this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{o.logger("sendRefusalToTurnOnMic: error",e)})});l(this,"sendRefusalToTurnOnCam",async()=>{if(this.sipConnector.isCallActive)return o.logger("sendRefusalToTurnOnCam"),this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{o.logger("sendRefusalToTurnOnCam: error",e)})});l(this,"sendMediaState",async({isEnabledCam:e,isEnabledMic:t})=>{if(this.sipConnector.isCallActive)return o.logger("sendMediaState"),this.sipConnector.sendMediaState({cam:e,mic:t})});l(this,"replaceMediaStream",async(e,{deleteExisting:t,addMissing:s,forceRenegotiation:r,contentHint:i,simulcastEncodings:c,degradationPreference:a,sendEncodings:u}={})=>{const g=w({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});return o.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:s,forceRenegotiation:r,contentHint:i,sendEncodings:D({mediaStream:e,simulcastEncodings:c,sendEncodings:u}),onAddedTransceiver:g})});l(this,"askPermissionToEnableCam",async()=>{if(this.sipConnector.isCallActive)return o.logger("askPermissionToEnableCam"),this.sipConnector.askPermissionToEnableCam()});l(this,"resolveHandleReadyRemoteStreamsDebounced",({onReadyRemoteStreams:e})=>ce.debounce(()=>{const t=this.sipConnector.getRemoteStreams();o.logger("remoteStreams",t),t&&e(t)},200));l(this,"resolveHandleReadyRemoteStreams",({onReadyRemoteStreams:e})=>({track:t})=>{Ye(t)&&e()});l(this,"getRemoteStreams",()=>(o.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams()));l(this,"onUseLicense",e=>(o.logger("onUseLicense"),this.sipConnector.onSession("useLicense",e)));l(this,"onMustStopPresentation",e=>(o.logger("onMustStopPresentation"),this.sipConnector.onSession("mustStopPresentation",e)));l(this,"onMoveToSpectators",e=>(o.logger("onMoveToSpectators"),this.sipConnector.onSession(o.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS,e)));l(this,"onMoveToParticipants",e=>(o.logger("onMoveToParticipants"),this.sipConnector.onSession(o.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS,e)));this.preferredMimeTypesVideoCodecs=t,this.excludeMimeTypesVideoCodecs=s,this.sipConnector=e,this.on=this.sipConnector.on.bind(e),this.once=this.sipConnector.once.bind(e),this.onceRace=this.sipConnector.onceRace.bind(e),this.wait=this.sipConnector.wait.bind(e),this.off=this.sipConnector.off.bind(e),this.onSession=this.sipConnector.onSession.bind(e),this.onceSession=this.sipConnector.onceSession.bind(e),this.onceRaceSession=this.sipConnector.onceRaceSession.bind(e),this.waitSession=this.sipConnector.waitSession.bind(e),this.offSession=this.sipConnector.offSession.bind(e),this.sendDTMF=this.sipConnector.sendDTMF.bind(e),this.hangUp=this.sipConnector.hangUp.bind(e),this.declineToIncomingCall=this.sipConnector.declineToIncomingCall.bind(e),this.isConfigured=this.sipConnector.isConfigured.bind(e),this.sendChannels=this.sipConnector.sendChannels.bind(e),this.checkTelephony=this.sipConnector.checkTelephony.bind(e),this.waitChannels=this.sipConnector.waitChannels.bind(e),this.ping=this.sipConnector.ping.bind(e)}get isRegistered(){return this.sipConnector.isRegistered}}exports.EEventsMainCAM=o.EEventsMainCAM;exports.EEventsMic=o.EEventsMic;exports.EEventsSyncMediaState=o.EEventsSyncMediaState;exports.EMimeTypesVideoCodecs=o.EMimeTypesVideoCodecs;exports.EUseLicense=o.EUseLicense;exports.causes=o.causes;exports.constants=o.constants;exports.default=o.SipConnector;exports.disableDebug=o.disableDebug;exports.enableDebug=o.enableDebug;exports.eventNames=o.eventNames;exports.hasCanceledCallError=o.hasCanceledCallError;exports.setParametersToSender=o.setParametersToSender;exports.debug=ae;exports.SipConnectorFacade=ze;exports.getCodecFromSender=G;exports.resolveVideoSendingBalancer=He;exports.tools=_e;
1
+ "use strict";var ne=Object.defineProperty;var te=(n,e,t)=>e in n?ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var u=(n,e,t)=>te(n,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("./SipConnector-CE4F15z6.cjs"),se=require("sequent-promises"),oe=require("stack-promises"),re=require("@krivega/cancelable-promise"),ie=require("repeated-calls"),ce=require("ts-debounce"),ae=require("debug"),$=n=>{const{url:e,cause:t}=n;let s=e;return(t===o.BAD_MEDIA_DESCRIPTION||t===o.NOT_FOUND)&&(s=`${n.message.to.uri.user}@${n.message.to.uri.host}`),s};var j=(n=>(n.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",n.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",n.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",n.NOT_FOUND_ERROR="NOT_FOUND_ERROR",n.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",n.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",n))(j||{});const ue=(n=new Error)=>{var r;const{cause:e,socket:t}=n;let s="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{s="WRONG_USER_OR_PASSWORD";break}case o.BAD_MEDIA_DESCRIPTION:{s="BAD_MEDIA_ERROR";break}case o.NOT_FOUND:{s="NOT_FOUND_ERROR";break}default:t&&((r=t==null?void 0:t._ws)==null?void 0:r.readyState)===3?s="WS_CONNECTION_FAILED":$(n)&&(s="CONNECT_SERVER_FAILED_BY_LINK")}return s},le=n=>{let e="";try{e=JSON.stringify(n)}catch(t){o.logger("failed to stringify message",t)}return e},de=(n=new Error)=>{const{code:e,cause:t,message:s}=n,r=$(n),i={code:"",cause:"",message:""};return typeof s=="object"&&s!==null?i.message=le(s):s&&(i.message=String(s)),r&&(i.link=r),e&&(i.code=e),t&&(i.cause=t),i},ge=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:j,getLinkError:$,getTypeFromError:ue,getValuesFromError:de},Symbol.toStringTag,{value:"Module"})),Se=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:s,isRegistered:r,isPresentationCall:i})=>{const c=[],a=t?"0":"1",l=s?"0":"1";return c.push(`X-Vinteo-Mic-State: ${a}`,`X-Vinteo-MainCam-State: ${l}`),r||c.push("X-Vinteo-Purgatory-Call: yes"),n&&c.push(`X-Vinteo-Session: ${n}`),i&&c.push("X-Vinteo-Presentation-Call: yes"),e&&c.push(`X-Vinteo-Remote: ${e}`),c},Ce="[@*!|]",fe="_",me=n=>{let e=n;return e=e.replaceAll(new RegExp(Ce,"g"),fe),e},he=({appName:n,appVersion:e,browserName:t,browserVersion:s})=>{const i=`${me(n)} ${e}`;return`ChromeNew - ${t?`${t} ${s}, ${i}`:i}`},Re=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:s,appName:r})=>n?he({appVersion:e,browserName:t,browserVersion:s,appName:r}):"Chrome",W="purgatory",w=n=>n===W,pe=n=>e=>[...e].map(s=>async()=>n(s)),Ee=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const r=pe(e)(n);return se.sequentPromises(r,t)},ye=n=>t=>(o.logger("onStartMainCam"),n.onSession("admin-start-main-cam",t)),Te=n=>t=>(o.logger("onStartMic"),n.onSession("admin-start-mic",t)),Me=n=>t=>(o.logger("onStopMainCam"),n.onSession("admin-stop-main-cam",t)),be=n=>t=>(o.logger("onStopMic"),n.onSession("admin-stop-mic",t)),Ae=({sipConnector:n})=>{const e=(f,p)=>({isSyncForced:m=!1})=>{if(m){f();return}p()},t=ye(n),s=Me(n),r=Te(n),i=be(n);let c=()=>{},a=()=>{},l=()=>{},g=()=>{};const C=({onStartMainCamForced:f,onStartMainCamNotForced:p,onStopMainCamForced:m,onStopMainCamNotForced:h,onStartMicForced:E,onStartMicNotForced:y,onStopMicForced:T,onStopMicNotForced:M})=>{const _=e(f,p);c=t(_);const v=e(m,h);a=s(v);const O=e(E,y);l=r(O);const N=e(T,M);g=i(N)},S=()=>{c(),a(),l(),g()};return{start:f=>{C(f)},stop:()=>{S()}}},_e=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:W,createSyncMediaState:Ae,error:ge,getExtraHeaders:Se,getUserAgent:Re,hasPurgatory:w,sendDTMFAccumulated:Ee},Symbol.toStringTag,{value:"Module"})),ve=n=>[...n.keys()].map(e=>n.get(e)),Oe=(n,e)=>ve(n).find(t=>t.type===e),G=async n=>n.getStats().then(e=>{const t=Oe(e,"codec");return t==null?void 0:t.mimeType}),Ne=n=>n.find(e=>{var t;return((t=e==null?void 0:e.track)==null?void 0:t.kind)==="video"}),K=(n,e)=>n!==void 0&&e!==void 0&&n.toLowerCase().includes(e.toLowerCase()),Pe=1e6,R=n=>n*Pe,Y=R(.06),Be=R(4),De=n=>n<=64?Y:n<=128?R(.12):n<=256?R(.25):n<=384?R(.32):n<=426?R(.38):n<=640?R(.5):n<=848?R(.7):n<=1280?R(1):n<=1920?R(2):Be,we="av1",Ie=n=>K(n,we),Fe=.6,z=(n,e)=>Ie(e)?n*Fe:n,ke=n=>z(Y,n),Q=(n,e)=>{const t=De(n);return z(t,e)},Ue=1,J=({videoTrack:n,targetSize:e,codec:t})=>{const s=n.getSettings(),r=s.width,i=s.height,c=r/e.width,a=i/e.height,l=Math.max(c,a,Ue),g=Q(e.width,t);return{scaleResolutionDownBy:l,maxBitrate:g}},Z=oe.createStackPromises(),Ve=async()=>Z().catch(n=>{o.logger("videoSendingBalancer: error",n)}),Le=async n=>(Z.add(n),Ve()),q=async({sender:n,scaleResolutionDownBy:e,maxBitrate:t,onSetParameters:s})=>Le(async()=>o.setEncodingsToSender(n,{scaleResolutionDownBy:e,maxBitrate:t},s)),xe=async({sender:n,codec:e},t)=>{const r=ke(e);return q({sender:n,maxBitrate:r,onSetParameters:t,scaleResolutionDownBy:200})},L=async({sender:n,videoTrack:e,codec:t},s)=>{const c=e.getSettings().width,a=Q(c,t);return q({sender:n,maxBitrate:a,onSetParameters:s,scaleResolutionDownBy:1})},$e=async({sender:n,videoTrack:e,resolution:t,codec:s},r)=>{const[i,c]=t.split("x"),{maxBitrate:a,scaleResolutionDownBy:l}=J({videoTrack:e,codec:s,targetSize:{width:Number(i),height:Number(c)}});return q({sender:n,maxBitrate:a,onSetParameters:r,scaleResolutionDownBy:l})},qe=async({mainCam:n,resolutionMainCam:e,sender:t,videoTrack:s,codec:r},i)=>{switch(n){case o.EEventsMainCAM.PAUSE_MAIN_CAM:return xe({sender:t,codec:r},i);case o.EEventsMainCAM.RESUME_MAIN_CAM:return L({sender:t,videoTrack:s,codec:r},i);case o.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return e!==void 0?$e({sender:t,videoTrack:s,codec:r,resolution:e},i):L({sender:t,videoTrack:s,codec:r},i);default:return L({sender:t,videoTrack:s,codec:r},i)}},H={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},X=async({mainCam:n,resolutionMainCam:e,connection:t,onSetParameters:s,ignoreForCodec:r})=>{const i=t.getSenders(),c=Ne(i);if(!(c!=null&&c.track))return H;const a=await G(c);return K(a,r)?H:qe({mainCam:n,resolutionMainCam:e,sender:c,codec:a,videoTrack:c.track},s)},He=(n,{ignoreForCodec:e,onSetParameters:t}={})=>{const s=async()=>{const{connection:l}=n;if(!l)throw new Error("connection is not exist");return X({connection:l,onSetParameters:t,ignoreForCodec:e})};let r=s;const i=async l=>(r=async()=>{const{mainCam:g,resolutionMainCam:C}=l,{connection:S}=n;if(!S)throw new Error("connection is not exist");return X({mainCam:g,resolutionMainCam:C,connection:S,onSetParameters:t,ignoreForCodec:e})},r());return{subscribe:()=>{n.onSession("main-cam-control",i)},unsubscribe:()=>{n.offSession("main-cam-control",i)},balanceByTrack:s,resetMainCamControl(){r=s},async reBalance(){return r()}}},Xe=n=>n.getVideoTracks()[0],B=({mediaStream:n,simulcastEncodings:e,sendEncodings:t})=>{if(e&&e.length>0){const s=t??[],r=Xe(n);return e.forEach((i,c)=>{const a=s[c]??{};a.active=!0,i.rid!==void 0&&(a.rid=i.rid),i.scalabilityMode!==void 0&&(a.scalabilityMode=i.scalabilityMode);const{maxBitrate:l,scaleResolutionDownBy:g}=J({videoTrack:r,targetSize:{width:i.width,height:i.height}});a.maxBitrate=l,a.scaleResolutionDownBy=g,s[c]=a}),s}return t},je=(n,e)=>[...n,...e].filter((r,i,c)=>i===c.findIndex(a=>a.clockRate===r.clockRate&&a.mimeType===r.mimeType&&a.channels===r.channels&&a.sdpFmtpLine===r.sdpFmtpLine)),We=n=>{const e=RTCRtpSender.getCapabilities(n),t=RTCRtpReceiver.getCapabilities(n),s=e===null?[]:e.codecs,r=t===null?[]:t.codecs;return je(s,r)},Ge=(n,e)=>e===void 0||e.length===0?n:n.sort((t,s)=>{const r=e.indexOf(t.mimeType),i=e.indexOf(s.mimeType),c=r===-1?Number.MAX_VALUE:r,a=i===-1?Number.MAX_VALUE:i;return c-a}),Ke=(n,e)=>e===void 0||e.length===0?n:n.filter(t=>!e.includes(t.mimeType)),D=(n,{preferredMimeTypesVideoCodecs:e,excludeMimeTypesVideoCodecs:t})=>async s=>{var r;if(typeof s.setCodecPreferences=="function"&&((r=s.sender.track)==null?void 0:r.kind)==="video"&&(e!==void 0&&(e==null?void 0:e.length)>0||t!==void 0&&(t==null?void 0:t.length)>0)){const i=We("video"),c=Ke(i,t),a=Ge(c,e);s.setCodecPreferences(a)}Object.keys(n).length>0&&await o.setParametersToSender(s.sender,n)},x=n=>{if(!re.isCanceledError(n)&&!ie.hasCanceledError(n))throw n;return{isSuccessful:!1}},Ye=({kind:n,readyState:e})=>n==="video"&&e==="live",ze=new Set(["on","once","onceRace","wait","off","onSession","onceSession","onceRaceSession","waitSession","offSession","sendDTMF","hangUp","declineToIncomingCall","isConfigured","sendChannels","checkTelephony","waitChannels","connection"]);class Qe{constructor(e,{preferredMimeTypesVideoCodecs:t,excludeMimeTypesVideoCodecs:s}={}){u(this,"sipConnector");u(this,"preferredMimeTypesVideoCodecs");u(this,"excludeMimeTypesVideoCodecs");u(this,"on");u(this,"once");u(this,"onceRace");u(this,"wait");u(this,"off");u(this,"onSession");u(this,"onceSession");u(this,"onceRaceSession");u(this,"waitSession");u(this,"offSession");u(this,"sendDTMF");u(this,"hangUp");u(this,"declineToIncomingCall");u(this,"isConfigured");u(this,"sendChannels");u(this,"checkTelephony");u(this,"waitChannels");u(this,"connection");u(this,"connectToServer",async e=>{const{userAgent:t,sipWebSocketServerURL:s,sipServerUrl:r,remoteAddress:i,displayName:c,name:a,password:l,isRegisteredUser:g,isDisconnectOnFail:C}=e;return o.logger("connectToServer",e),this.sipConnector.connect({userAgent:t,sipWebSocketServerURL:s,sipServerUrl:r,remoteAddress:i,displayName:c,password:l,user:a,register:g}).then(S=>(o.logger("connectToServer then"),{ua:S,isSuccessful:!0})).catch(async S=>(o.logger("connectToServer catch: error",S),C===!0?this.sipConnector.disconnect().then(()=>x(S)).catch(()=>x(S)):x(S)))});u(this,"callToServer",async e=>{const{conference:t,mediaStream:s,extraHeaders:r,iceServers:i,contentHint:c,simulcastEncodings:a,degradationPreference:l,sendEncodings:g,offerToReceiveAudio:C,offerToReceiveVideo:S,directionVideo:I,directionAudio:F,setRemoteStreams:f,onBeforeProgressCall:p,onSuccessProgressCall:m,onEnterPurgatory:h,onEnterConference:E,onFailProgressCall:y,onFinishProgressCall:T,onEndedCall:M}=e,_=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:f}),v=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:_}),O=D({degradationPreference:l},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});o.logger("callToServer",e);const N=async()=>(o.logger("startCall"),this.sipConnector.call({mediaStream:s,extraHeaders:r,iceServers:i,contentHint:c,offerToReceiveAudio:C,offerToReceiveVideo:S,directionVideo:I,directionAudio:F,sendEncodings:B({mediaStream:s,simulcastEncodings:a,sendEncodings:g}),number:t,onAddedTransceiver:O,ontrack:v}));let b=!1,A;const P=(o.logger("subscribeEnterConference: onEnterConference",E),h??E?this.sipConnector.onSession("enterRoom",({room:d})=>{o.logger("enterRoom",{_room:d,isSuccessProgressCall:b}),A=d,w(A)?h&&h():E&&E({isSuccessProgressCall:b})}):()=>{}),k=d=>(o.logger("onSuccess"),b=!0,_(),m&&m({isPurgatory:w(A)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{P(),M&&M()}),d),U=d=>{throw o.logger("onFail"),y&&y(),P(),d},V=()=>{o.logger("onFinish"),T&&T()};return o.logger("onBeforeProgressCall"),p&&p(t),N().then(k).catch(d=>U(d)).finally(V)});u(this,"disconnectFromServer",async()=>this.sipConnector.disconnect().then(()=>(o.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(o.logger("disconnectFromServer: catch",e),{isSuccessful:!1})));u(this,"answerIncomingCall",async e=>{const{mediaStream:t,extraHeaders:s,iceServers:r,contentHint:i,simulcastEncodings:c,degradationPreference:a,sendEncodings:l,offerToReceiveAudio:g,offerToReceiveVideo:C,directionVideo:S,directionAudio:I,setRemoteStreams:F,onBeforeProgressCall:f,onSuccessProgressCall:p,onEnterPurgatory:m,onEnterConference:h,onFailProgressCall:E,onFinishProgressCall:y,onEndedCall:T}=e,M=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:F}),_=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:M}),v=D({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});o.logger("answerIncomingCall",e);const O=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:s,iceServers:r,contentHint:i,offerToReceiveAudio:g,offerToReceiveVideo:C,directionVideo:S,directionAudio:I,sendEncodings:B({mediaStream:t,simulcastEncodings:c,sendEncodings:l}),onAddedTransceiver:v,ontrack:_}),N=()=>{const{remoteCallerData:d}=this.sipConnector;return d.incomingNumber};let b=!1,A;const P=(o.logger("subscribeEnterConference: onEnterConference",h),m??h?this.sipConnector.onSession("enterRoom",d=>{o.logger("enterRoom",{_room:d,isSuccessProgressCall:b}),A=d,w(A)?m&&m():h&&h({isSuccessProgressCall:b})}):()=>{}),k=d=>(o.logger("onSuccess"),b=!0,M(),p&&p({isPurgatory:w(A)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{P(),T&&T()}),d),U=d=>{throw o.logger("onFail"),E&&E(),P(),d},V=()=>{o.logger("onFinish"),y&&y()};if(o.logger("onBeforeProgressCall"),f){const d=N();f(d)}return O().then(k).catch(d=>U(d)).finally(V)});u(this,"updatePresentation",async({mediaStream:e,isP2P:t,maxBitrate:s,contentHint:r,simulcastEncodings:i,degradationPreference:c,sendEncodings:a,preferredMimeTypesVideoCodecs:l,excludeMimeTypesVideoCodecs:g})=>{const C=D({degradationPreference:c},{preferredMimeTypesVideoCodecs:l,excludeMimeTypesVideoCodecs:g});return o.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,maxBitrate:s,contentHint:r,sendEncodings:B({mediaStream:e,simulcastEncodings:i,sendEncodings:a}),onAddedTransceiver:C})});u(this,"startPresentation",async({mediaStream:e,isP2P:t,maxBitrate:s,contentHint:r,simulcastEncodings:i,degradationPreference:c,sendEncodings:a,preferredMimeTypesVideoCodecs:l,excludeMimeTypesVideoCodecs:g},C)=>{const S=D({degradationPreference:c},{preferredMimeTypesVideoCodecs:l,excludeMimeTypesVideoCodecs:g});return o.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,maxBitrate:s,contentHint:r,sendEncodings:B({mediaStream:e,simulcastEncodings:i,sendEncodings:a}),onAddedTransceiver:S},C)});u(this,"stopShareSipConnector",async({isP2P:e=!1}={})=>(o.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{o.logger(t)})));u(this,"sendRefusalToTurnOnMic",async()=>{if(this.sipConnector.isCallActive)return o.logger("sendRefusalToTurnOnMic"),this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{o.logger("sendRefusalToTurnOnMic: error",e)})});u(this,"sendRefusalToTurnOnCam",async()=>{if(this.sipConnector.isCallActive)return o.logger("sendRefusalToTurnOnCam"),this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{o.logger("sendRefusalToTurnOnCam: error",e)})});u(this,"sendMediaState",async({isEnabledCam:e,isEnabledMic:t})=>{if(this.sipConnector.isCallActive)return o.logger("sendMediaState"),this.sipConnector.sendMediaState({cam:e,mic:t})});u(this,"replaceMediaStream",async(e,{deleteExisting:t,addMissing:s,forceRenegotiation:r,contentHint:i,simulcastEncodings:c,degradationPreference:a,sendEncodings:l}={})=>{const g=D({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});return o.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:s,forceRenegotiation:r,contentHint:i,sendEncodings:B({mediaStream:e,simulcastEncodings:c,sendEncodings:l}),onAddedTransceiver:g})});u(this,"askPermissionToEnableCam",async()=>{if(this.sipConnector.isCallActive)return o.logger("askPermissionToEnableCam"),this.sipConnector.askPermissionToEnableCam()});u(this,"resolveHandleReadyRemoteStreamsDebounced",({onReadyRemoteStreams:e})=>ce.debounce(()=>{const t=this.sipConnector.getRemoteStreams();o.logger("remoteStreams",t),t&&e(t)},200));u(this,"resolveHandleReadyRemoteStreams",({onReadyRemoteStreams:e})=>({track:t})=>{Ye(t)&&e()});u(this,"getRemoteStreams",()=>(o.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams()));u(this,"onUseLicense",e=>(o.logger("onUseLicense"),this.sipConnector.onSession("useLicense",e)));u(this,"onMustStopPresentation",e=>(o.logger("onMustStopPresentation"),this.sipConnector.onSession("mustStopPresentation",e)));u(this,"onMoveToSpectators",e=>(o.logger("onMoveToSpectators"),this.sipConnector.onSession(o.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS,e)));u(this,"onMoveToParticipants",e=>(o.logger("onMoveToParticipants"),this.sipConnector.onSession(o.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS,e)));return this.preferredMimeTypesVideoCodecs=t,this.excludeMimeTypesVideoCodecs=s,this.sipConnector=e,new Proxy(this,{get:(r,i,c)=>{if(typeof i=="string"&&ze.has(i)&&i in this.sipConnector){const l=Reflect.get(this.sipConnector,i,this.sipConnector);return typeof l=="function"?l.bind(this.sipConnector):l}const a=Reflect.get(r,i,c);return typeof a=="function"?a.bind(r):a}})}}exports.EEventsMainCAM=o.EEventsMainCAM;exports.EEventsMic=o.EEventsMic;exports.EEventsSyncMediaState=o.EEventsSyncMediaState;exports.EMimeTypesVideoCodecs=o.EMimeTypesVideoCodecs;exports.EUseLicense=o.EUseLicense;exports.causes=o.causes;exports.constants=o.constants;exports.default=o.SipConnector;exports.disableDebug=o.disableDebug;exports.enableDebug=o.enableDebug;exports.eventNames=o.eventNames;exports.hasCanceledCallError=o.hasCanceledCallError;exports.setParametersToSender=o.setParametersToSender;exports.debug=ae;exports.SipConnectorFacade=Qe;exports.getCodecFromSender=G;exports.resolveVideoSendingBalancer=He;exports.tools=_e;
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  var se = Object.defineProperty;
2
2
  var oe = (n, e, t) => e in n ? se(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var u = (n, e, t) => oe(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { B as G, N as K, l as a, E as L, s as re, a as ie, P as ce, b as ae, S as tn } from "./SipConnector-B4xLnl6L.js";
5
- import { i as Cn, j as fn, m as mn, k as Rn, c as gn, d as pn, f as yn, g as Tn, e as En, h as bn } from "./SipConnector-B4xLnl6L.js";
4
+ import { B as G, N as K, l as a, E as x, s as re, a as ie, P as ce, b as ae, S as sn } from "./SipConnector-B4xLnl6L.js";
5
+ import { i as mn, j as hn, m as Rn, k as gn, c as pn, d as yn, f as En, g as Tn, e as bn, h as Mn } from "./SipConnector-B4xLnl6L.js";
6
6
  import { sequentPromises as ue } from "sequent-promises";
7
- import { createStackPromises as de } from "stack-promises";
8
- import { isCanceledError as le } from "@krivega/cancelable-promise";
7
+ import { createStackPromises as le } from "stack-promises";
8
+ import { isCanceledError as de } from "@krivega/cancelable-promise";
9
9
  import { hasCanceledError as Se } from "repeated-calls";
10
- import { debounce as he } from "ts-debounce";
11
- import { default as An } from "debug";
10
+ import { debounce as fe } from "ts-debounce";
11
+ import { default as _n } from "debug";
12
12
  const H = (n) => {
13
13
  const { url: e, cause: t } = n;
14
14
  let s = e;
@@ -36,7 +36,7 @@ const Ce = (n = new Error()) => {
36
36
  t && ((o = t == null ? void 0 : t._ws) == null ? void 0 : o.readyState) === 3 ? s = "WS_CONNECTION_FAILED" : H(n) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
37
37
  }
38
38
  return s;
39
- }, fe = (n) => {
39
+ }, me = (n) => {
40
40
  let e = "";
41
41
  try {
42
42
  e = JSON.stringify(n);
@@ -44,15 +44,15 @@ const Ce = (n = new Error()) => {
44
44
  a("failed to stringify message", t);
45
45
  }
46
46
  return e;
47
- }, me = (n = new Error()) => {
47
+ }, he = (n = new Error()) => {
48
48
  const { code: e, cause: t, message: s } = n, o = H(n), r = { code: "", cause: "", message: "" };
49
- return typeof s == "object" && s !== null ? r.message = fe(s) : s && (r.message = String(s)), o && (r.link = o), e && (r.code = e), t && (r.cause = t), r;
49
+ return typeof s == "object" && s !== null ? r.message = me(s) : s && (r.message = String(s)), o && (r.link = o), e && (r.code = e), t && (r.cause = t), r;
50
50
  }, Re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51
51
  __proto__: null,
52
52
  EErrorTypes: q,
53
53
  getLinkError: H,
54
54
  getTypeFromError: Ce,
55
- getValuesFromError: me
55
+ getValuesFromError: he
56
56
  }, Symbol.toStringTag, { value: "Module" })), ge = ({
57
57
  sessionId: n,
58
58
  remoteAddress: e,
@@ -61,18 +61,18 @@ const Ce = (n = new Error()) => {
61
61
  isRegistered: o,
62
62
  isPresentationCall: r
63
63
  }) => {
64
- const i = [], c = t ? "0" : "1", d = s ? "0" : "1";
65
- return i.push(`X-Vinteo-Mic-State: ${c}`, `X-Vinteo-MainCam-State: ${d}`), o || i.push("X-Vinteo-Purgatory-Call: yes"), n && i.push(`X-Vinteo-Session: ${n}`), r && i.push("X-Vinteo-Presentation-Call: yes"), e && i.push(`X-Vinteo-Remote: ${e}`), i;
66
- }, pe = "[@*!|]", ye = "_", Te = (n) => {
64
+ const i = [], c = t ? "0" : "1", l = s ? "0" : "1";
65
+ return i.push(`X-Vinteo-Mic-State: ${c}`, `X-Vinteo-MainCam-State: ${l}`), o || i.push("X-Vinteo-Purgatory-Call: yes"), n && i.push(`X-Vinteo-Session: ${n}`), r && i.push("X-Vinteo-Presentation-Call: yes"), e && i.push(`X-Vinteo-Remote: ${e}`), i;
66
+ }, pe = "[@*!|]", ye = "_", Ee = (n) => {
67
67
  let e = n;
68
68
  return e = e.replaceAll(new RegExp(pe, "g"), ye), e;
69
- }, Ee = ({
69
+ }, Te = ({
70
70
  appName: n,
71
71
  appVersion: e,
72
72
  browserName: t,
73
73
  browserVersion: s
74
74
  }) => {
75
- const r = `${Te(n)} ${e}`;
75
+ const r = `${Ee(n)} ${e}`;
76
76
  return `ChromeNew - ${t ? `${t} ${s}, ${r}` : r}`;
77
77
  }, be = ({
78
78
  isUnifiedSdpSemantic: n,
@@ -80,7 +80,7 @@ const Ce = (n = new Error()) => {
80
80
  browserName: t,
81
81
  browserVersion: s,
82
82
  appName: o
83
- }) => n ? Ee({ appVersion: e, browserName: t, browserVersion: s, appName: o }) : "Chrome", Y = "purgatory", D = (n) => n === Y, Me = (n) => (e) => [...e].map((s) => async () => n(s)), Ae = async ({
83
+ }) => n ? Te({ appVersion: e, browserName: t, browserVersion: s, appName: o }) : "Chrome", Y = "purgatory", D = (n) => n === Y, Me = (n) => (e) => [...e].map((s) => async () => n(s)), Ae = async ({
84
84
  accumulatedKeys: n,
85
85
  sendKey: e,
86
86
  canRunTask: t
@@ -88,54 +88,54 @@ const Ce = (n = new Error()) => {
88
88
  const o = Me(e)(n);
89
89
  return ue(o, t);
90
90
  }, _e = (n) => (t) => (a("onStartMainCam"), n.onSession("admin-start-main-cam", t)), ve = (n) => (t) => (a("onStartMic"), n.onSession("admin-start-mic", t)), Oe = (n) => (t) => (a("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), Ne = (n) => (t) => (a("onStopMic"), n.onSession("admin-stop-mic", t)), we = ({ sipConnector: n }) => {
91
- const e = (f, p) => ({ isSyncForced: m = !1 }) => {
92
- if (m) {
93
- f();
91
+ const e = (m, p) => ({ isSyncForced: h = !1 }) => {
92
+ if (h) {
93
+ m();
94
94
  return;
95
95
  }
96
96
  p();
97
97
  }, t = _e(n), s = Oe(n), o = ve(n), r = Ne(n);
98
98
  let i = () => {
99
99
  }, c = () => {
100
- }, d = () => {
100
+ }, l = () => {
101
101
  }, S = () => {
102
102
  };
103
103
  const C = ({
104
- onStartMainCamForced: f,
104
+ onStartMainCamForced: m,
105
105
  onStartMainCamNotForced: p,
106
- onStopMainCamForced: m,
106
+ onStopMainCamForced: h,
107
107
  onStopMainCamNotForced: R,
108
108
  onStartMicForced: y,
109
- onStartMicNotForced: T,
110
- onStopMicForced: E,
109
+ onStartMicNotForced: E,
110
+ onStopMicForced: T,
111
111
  onStopMicNotForced: b
112
112
  }) => {
113
113
  const _ = e(
114
- f,
114
+ m,
115
115
  p
116
116
  );
117
117
  i = t(_);
118
118
  const v = e(
119
- m,
119
+ h,
120
120
  R
121
121
  );
122
122
  c = s(v);
123
- const O = e(y, T);
124
- d = o(O);
125
- const N = e(E, b);
123
+ const O = e(y, E);
124
+ l = o(O);
125
+ const N = e(T, b);
126
126
  S = r(N);
127
- }, h = () => {
128
- i(), c(), d(), S();
127
+ }, f = () => {
128
+ i(), c(), l(), S();
129
129
  };
130
130
  return {
131
- start: (f) => {
132
- C(f);
131
+ start: (m) => {
132
+ C(m);
133
133
  },
134
134
  stop: () => {
135
- h();
135
+ f();
136
136
  }
137
137
  };
138
- }, un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
138
+ }, ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
139
139
  __proto__: null,
140
140
  PURGATORY_CONFERENCE_NUMBER: Y,
141
141
  createSyncMediaState: we,
@@ -150,7 +150,7 @@ const Ce = (n = new Error()) => {
150
150
  }), Ie = (n) => n.find((e) => {
151
151
  var t;
152
152
  return ((t = e == null ? void 0 : e.track) == null ? void 0 : t.kind) === "video";
153
- }), z = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Fe = 1e6, g = (n) => n * Fe, Q = g(0.06), ke = g(4), Ue = (n) => n <= 64 ? Q : n <= 128 ? g(0.12) : n <= 256 ? g(0.25) : n <= 384 ? g(0.32) : n <= 426 ? g(0.38) : n <= 640 ? g(0.5) : n <= 848 ? g(0.7) : n <= 1280 ? g(1) : n <= 1920 ? g(2) : ke, Ve = "av1", Le = (n) => z(n, Ve), xe = 0.6, J = (n, e) => Le(e) ? n * xe : n, $e = (n) => J(Q, n), Z = (n, e) => {
153
+ }), z = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Fe = 1e6, g = (n) => n * Fe, Q = g(0.06), ke = g(4), Ue = (n) => n <= 64 ? Q : n <= 128 ? g(0.12) : n <= 256 ? g(0.25) : n <= 384 ? g(0.32) : n <= 426 ? g(0.38) : n <= 640 ? g(0.5) : n <= 848 ? g(0.7) : n <= 1280 ? g(1) : n <= 1920 ? g(2) : ke, Ve = "av1", xe = (n) => z(n, Ve), Le = 0.6, J = (n, e) => xe(e) ? n * Le : n, $e = (n) => J(Q, n), Z = (n, e) => {
154
154
  const t = Ue(n);
155
155
  return J(t, e);
156
156
  }, He = 1, ee = ({
@@ -158,9 +158,9 @@ const Ce = (n = new Error()) => {
158
158
  targetSize: e,
159
159
  codec: t
160
160
  }) => {
161
- const s = n.getSettings(), o = s.width, r = s.height, i = o / e.width, c = r / e.height, d = Math.max(i, c, He), S = Z(e.width, t);
162
- return { scaleResolutionDownBy: d, maxBitrate: S };
163
- }, ne = de(), Xe = async () => ne().catch((n) => {
161
+ const s = n.getSettings(), o = s.width, r = s.height, i = o / e.width, c = r / e.height, l = Math.max(i, c, He), S = Z(e.width, t);
162
+ return { scaleResolutionDownBy: l, maxBitrate: S };
163
+ }, ne = le(), Xe = async () => ne().catch((n) => {
164
164
  a("videoSendingBalancer: error", n);
165
165
  }), je = async (n) => (ne.add(n), Xe()), X = async ({
166
166
  sender: n,
@@ -175,7 +175,7 @@ const Ce = (n = new Error()) => {
175
175
  onSetParameters: t,
176
176
  scaleResolutionDownBy: 200
177
177
  });
178
- }, x = async ({
178
+ }, L = async ({
179
179
  sender: n,
180
180
  videoTrack: e,
181
181
  codec: t
@@ -193,7 +193,7 @@ const Ce = (n = new Error()) => {
193
193
  resolution: t,
194
194
  codec: s
195
195
  }, o) => {
196
- const [r, i] = t.split("x"), { maxBitrate: c, scaleResolutionDownBy: d } = ee({
196
+ const [r, i] = t.split("x"), { maxBitrate: c, scaleResolutionDownBy: l } = ee({
197
197
  videoTrack: e,
198
198
  codec: s,
199
199
  targetSize: {
@@ -205,7 +205,7 @@ const Ce = (n = new Error()) => {
205
205
  sender: n,
206
206
  maxBitrate: c,
207
207
  onSetParameters: o,
208
- scaleResolutionDownBy: d
208
+ scaleResolutionDownBy: l
209
209
  });
210
210
  }, Ke = async ({
211
211
  mainCam: n,
@@ -215,17 +215,17 @@ const Ce = (n = new Error()) => {
215
215
  codec: o
216
216
  }, r) => {
217
217
  switch (n) {
218
- case L.PAUSE_MAIN_CAM:
218
+ case x.PAUSE_MAIN_CAM:
219
219
  return We({ sender: t, codec: o }, r);
220
- case L.RESUME_MAIN_CAM:
221
- return x({ sender: t, videoTrack: s, codec: o }, r);
222
- case L.MAX_MAIN_CAM_RESOLUTION:
220
+ case x.RESUME_MAIN_CAM:
221
+ return L({ sender: t, videoTrack: s, codec: o }, r);
222
+ case x.MAX_MAIN_CAM_RESOLUTION:
223
223
  return e !== void 0 ? Ge(
224
224
  { sender: t, videoTrack: s, codec: o, resolution: e },
225
225
  r
226
- ) : x({ sender: t, videoTrack: s, codec: o }, r);
226
+ ) : L({ sender: t, videoTrack: s, codec: o }, r);
227
227
  default:
228
- return x({ sender: t, videoTrack: s, codec: o }, r);
228
+ return L({ sender: t, videoTrack: s, codec: o }, r);
229
229
  }
230
230
  }, j = {
231
231
  isChanged: !1,
@@ -262,24 +262,24 @@ const Ce = (n = new Error()) => {
262
262
  onSetParameters: t
263
263
  } = {}) => {
264
264
  const s = async () => {
265
- const { connection: d } = n;
266
- if (!d)
265
+ const { connection: l } = n;
266
+ if (!l)
267
267
  throw new Error("connection is not exist");
268
268
  return W({
269
- connection: d,
269
+ connection: l,
270
270
  onSetParameters: t,
271
271
  ignoreForCodec: e
272
272
  });
273
273
  };
274
274
  let o = s;
275
- const r = async (d) => (o = async () => {
276
- const { mainCam: S, resolutionMainCam: C } = d, { connection: h } = n;
277
- if (!h)
275
+ const r = async (l) => (o = async () => {
276
+ const { mainCam: S, resolutionMainCam: C } = l, { connection: f } = n;
277
+ if (!f)
278
278
  throw new Error("connection is not exist");
279
279
  return W({
280
280
  mainCam: S,
281
281
  resolutionMainCam: C,
282
- connection: h,
282
+ connection: f,
283
283
  onSetParameters: t,
284
284
  ignoreForCodec: e
285
285
  });
@@ -309,14 +309,14 @@ const Ce = (n = new Error()) => {
309
309
  return e.forEach((r, i) => {
310
310
  const c = s[i] ?? {};
311
311
  c.active = !0, r.rid !== void 0 && (c.rid = r.rid), r.scalabilityMode !== void 0 && (c.scalabilityMode = r.scalabilityMode);
312
- const { maxBitrate: d, scaleResolutionDownBy: S } = ee({
312
+ const { maxBitrate: l, scaleResolutionDownBy: S } = ee({
313
313
  videoTrack: o,
314
314
  targetSize: {
315
315
  width: r.width,
316
316
  height: r.height
317
317
  }
318
318
  });
319
- c.maxBitrate = d, c.scaleResolutionDownBy = S, s[i] = c;
319
+ c.maxBitrate = l, c.scaleResolutionDownBy = S, s[i] = c;
320
320
  }), s;
321
321
  }
322
322
  return t;
@@ -337,11 +337,30 @@ const Ce = (n = new Error()) => {
337
337
  }
338
338
  Object.keys(n).length > 0 && await ie(s.sender, n);
339
339
  }, $ = (n) => {
340
- if (!le(n) && !Se(n))
340
+ if (!de(n) && !Se(n))
341
341
  throw n;
342
342
  return { isSuccessful: !1 };
343
- }, Ze = ({ kind: n, readyState: e }) => n === "video" && e === "live";
344
- class ln {
343
+ }, Ze = ({ kind: n, readyState: e }) => n === "video" && e === "live", en = /* @__PURE__ */ new Set([
344
+ "on",
345
+ "once",
346
+ "onceRace",
347
+ "wait",
348
+ "off",
349
+ "onSession",
350
+ "onceSession",
351
+ "onceRaceSession",
352
+ "waitSession",
353
+ "offSession",
354
+ "sendDTMF",
355
+ "hangUp",
356
+ "declineToIncomingCall",
357
+ "isConfigured",
358
+ "sendChannels",
359
+ "checkTelephony",
360
+ "waitChannels",
361
+ "connection"
362
+ ]);
363
+ class Sn {
345
364
  constructor(e, {
346
365
  preferredMimeTypesVideoCodecs: t,
347
366
  excludeMimeTypesVideoCodecs: s
@@ -349,24 +368,42 @@ class ln {
349
368
  u(this, "sipConnector");
350
369
  u(this, "preferredMimeTypesVideoCodecs");
351
370
  u(this, "excludeMimeTypesVideoCodecs");
371
+ // @ts-expect-error: proxy method
352
372
  u(this, "on");
373
+ // @ts-expect-error: proxy method
353
374
  u(this, "once");
375
+ // @ts-expect-error: proxy method
354
376
  u(this, "onceRace");
377
+ // @ts-expect-error: proxy method
355
378
  u(this, "wait");
379
+ // @ts-expect-error: proxy method
356
380
  u(this, "off");
381
+ // @ts-expect-error: proxy method
357
382
  u(this, "onSession");
383
+ // @ts-expect-error: proxy method
358
384
  u(this, "onceSession");
385
+ // @ts-expect-error: proxy method
359
386
  u(this, "onceRaceSession");
387
+ // @ts-expect-error: proxy method
360
388
  u(this, "waitSession");
389
+ // @ts-expect-error: proxy method
361
390
  u(this, "offSession");
391
+ // @ts-expect-error: proxy method
362
392
  u(this, "sendDTMF");
393
+ // @ts-expect-error: proxy method
363
394
  u(this, "hangUp");
395
+ // @ts-expect-error: proxy method
364
396
  u(this, "declineToIncomingCall");
397
+ // @ts-expect-error: proxy method
365
398
  u(this, "isConfigured");
399
+ // @ts-expect-error: proxy method
366
400
  u(this, "sendChannels");
401
+ // @ts-expect-error: proxy method
367
402
  u(this, "checkTelephony");
403
+ // @ts-expect-error: proxy method
368
404
  u(this, "waitChannels");
369
- u(this, "ping");
405
+ // proxy method
406
+ u(this, "connection");
370
407
  u(this, "connectToServer", async (e) => {
371
408
  const {
372
409
  userAgent: t,
@@ -375,7 +412,7 @@ class ln {
375
412
  remoteAddress: r,
376
413
  displayName: i,
377
414
  name: c,
378
- password: d,
415
+ password: l,
379
416
  isRegisteredUser: S,
380
417
  isDisconnectOnFail: C
381
418
  } = e;
@@ -385,10 +422,10 @@ class ln {
385
422
  sipServerUrl: o,
386
423
  remoteAddress: r,
387
424
  displayName: i,
388
- password: d,
425
+ password: l,
389
426
  user: c,
390
427
  register: S
391
- }).then((h) => (a("connectToServer then"), { ua: h, isSuccessful: !0 })).catch(async (h) => (a("connectToServer catch: error", h), C === !0 ? this.sipConnector.disconnect().then(() => $(h)).catch(() => $(h)) : $(h)));
428
+ }).then((f) => (a("connectToServer then"), { ua: f, isSuccessful: !0 })).catch(async (f) => (a("connectToServer catch: error", f), C === !0 ? this.sipConnector.disconnect().then(() => $(f)).catch(() => $(f)) : $(f)));
392
429
  });
393
430
  u(this, "callToServer", async (e) => {
394
431
  const {
@@ -398,27 +435,27 @@ class ln {
398
435
  iceServers: r,
399
436
  contentHint: i,
400
437
  simulcastEncodings: c,
401
- degradationPreference: d,
438
+ degradationPreference: l,
402
439
  sendEncodings: S,
403
440
  offerToReceiveAudio: C,
404
- offerToReceiveVideo: h,
441
+ offerToReceiveVideo: f,
405
442
  directionVideo: I,
406
443
  directionAudio: F,
407
- setRemoteStreams: f,
444
+ setRemoteStreams: m,
408
445
  onBeforeProgressCall: p,
409
- onSuccessProgressCall: m,
446
+ onSuccessProgressCall: h,
410
447
  onEnterPurgatory: R,
411
448
  onEnterConference: y,
412
- onFailProgressCall: T,
413
- onFinishProgressCall: E,
449
+ onFailProgressCall: E,
450
+ onFinishProgressCall: T,
414
451
  onEndedCall: b
415
452
  } = e, _ = this.resolveHandleReadyRemoteStreamsDebounced({
416
- onReadyRemoteStreams: f
453
+ onReadyRemoteStreams: m
417
454
  }), v = this.resolveHandleReadyRemoteStreams({
418
455
  onReadyRemoteStreams: _
419
456
  }), O = P(
420
457
  {
421
- degradationPreference: d
458
+ degradationPreference: l
422
459
  },
423
460
  {
424
461
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
@@ -432,7 +469,7 @@ class ln {
432
469
  iceServers: r,
433
470
  contentHint: i,
434
471
  offerToReceiveAudio: C,
435
- offerToReceiveVideo: h,
472
+ offerToReceiveVideo: f,
436
473
  directionVideo: I,
437
474
  directionAudio: F,
438
475
  sendEncodings: B({
@@ -445,17 +482,17 @@ class ln {
445
482
  ontrack: v
446
483
  }));
447
484
  let M = !1, A;
448
- const w = (a("subscribeEnterConference: onEnterConference", y), R ?? y ? this.sipConnector.onSession("enterRoom", ({ room: l }) => {
449
- a("enterRoom", { _room: l, isSuccessProgressCall: M }), A = l, D(A) ? R && R() : y && y({ isSuccessProgressCall: M });
485
+ const w = (a("subscribeEnterConference: onEnterConference", y), R ?? y ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
486
+ a("enterRoom", { _room: d, isSuccessProgressCall: M }), A = d, D(A) ? R && R() : y && y({ isSuccessProgressCall: M });
450
487
  }) : () => {
451
- }), k = (l) => (a("onSuccess"), M = !0, _(), m && m({ isPurgatory: D(A) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
488
+ }), k = (d) => (a("onSuccess"), M = !0, _(), h && h({ isPurgatory: D(A) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
452
489
  w(), b && b();
453
- }), l), U = (l) => {
454
- throw a("onFail"), T && T(), w(), l;
490
+ }), d), U = (d) => {
491
+ throw a("onFail"), E && E(), w(), d;
455
492
  }, V = () => {
456
- a("onFinish"), E && E();
493
+ a("onFinish"), T && T();
457
494
  };
458
- return a("onBeforeProgressCall"), p && p(t), N().then(k).catch((l) => U(l)).finally(V);
495
+ return a("onBeforeProgressCall"), p && p(t), N().then(k).catch((d) => U(d)).finally(V);
459
496
  });
460
497
  u(this, "disconnectFromServer", async () => this.sipConnector.disconnect().then(() => (a("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (a("disconnectFromServer: catch", e), { isSuccessful: !1 })));
461
498
  u(this, "answerIncomingCall", async (e) => {
@@ -466,19 +503,19 @@ class ln {
466
503
  contentHint: r,
467
504
  simulcastEncodings: i,
468
505
  degradationPreference: c,
469
- sendEncodings: d,
506
+ sendEncodings: l,
470
507
  offerToReceiveAudio: S,
471
508
  offerToReceiveVideo: C,
472
- directionVideo: h,
509
+ directionVideo: f,
473
510
  directionAudio: I,
474
511
  setRemoteStreams: F,
475
- onBeforeProgressCall: f,
512
+ onBeforeProgressCall: m,
476
513
  onSuccessProgressCall: p,
477
- onEnterPurgatory: m,
514
+ onEnterPurgatory: h,
478
515
  onEnterConference: R,
479
516
  onFailProgressCall: y,
480
- onFinishProgressCall: T,
481
- onEndedCall: E
517
+ onFinishProgressCall: E,
518
+ onEndedCall: T
482
519
  } = e, b = this.resolveHandleReadyRemoteStreamsDebounced({
483
520
  onReadyRemoteStreams: F
484
521
  }), _ = this.resolveHandleReadyRemoteStreams({
@@ -500,35 +537,35 @@ class ln {
500
537
  contentHint: r,
501
538
  offerToReceiveAudio: S,
502
539
  offerToReceiveVideo: C,
503
- directionVideo: h,
540
+ directionVideo: f,
504
541
  directionAudio: I,
505
542
  sendEncodings: B({
506
543
  mediaStream: t,
507
544
  simulcastEncodings: i,
508
- sendEncodings: d
545
+ sendEncodings: l
509
546
  }),
510
547
  onAddedTransceiver: v,
511
548
  ontrack: _
512
549
  }), N = () => {
513
- const { remoteCallerData: l } = this.sipConnector;
514
- return l.incomingNumber;
550
+ const { remoteCallerData: d } = this.sipConnector;
551
+ return d.incomingNumber;
515
552
  };
516
553
  let M = !1, A;
517
- const w = (a("subscribeEnterConference: onEnterConference", R), m ?? R ? this.sipConnector.onSession("enterRoom", (l) => {
518
- a("enterRoom", { _room: l, isSuccessProgressCall: M }), A = l, D(A) ? m && m() : R && R({ isSuccessProgressCall: M });
554
+ const w = (a("subscribeEnterConference: onEnterConference", R), h ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
555
+ a("enterRoom", { _room: d, isSuccessProgressCall: M }), A = d, D(A) ? h && h() : R && R({ isSuccessProgressCall: M });
519
556
  }) : () => {
520
- }), k = (l) => (a("onSuccess"), M = !0, b(), p && p({ isPurgatory: D(A) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
521
- w(), E && E();
522
- }), l), U = (l) => {
523
- throw a("onFail"), y && y(), w(), l;
557
+ }), k = (d) => (a("onSuccess"), M = !0, b(), p && p({ isPurgatory: D(A) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
558
+ w(), T && T();
559
+ }), d), U = (d) => {
560
+ throw a("onFail"), y && y(), w(), d;
524
561
  }, V = () => {
525
- a("onFinish"), T && T();
562
+ a("onFinish"), E && E();
526
563
  };
527
- if (a("onBeforeProgressCall"), f) {
528
- const l = N();
529
- f(l);
564
+ if (a("onBeforeProgressCall"), m) {
565
+ const d = N();
566
+ m(d);
530
567
  }
531
- return O().then(k).catch((l) => U(l)).finally(V);
568
+ return O().then(k).catch((d) => U(d)).finally(V);
532
569
  });
533
570
  u(this, "updatePresentation", async ({
534
571
  mediaStream: e,
@@ -538,7 +575,7 @@ class ln {
538
575
  simulcastEncodings: r,
539
576
  degradationPreference: i,
540
577
  sendEncodings: c,
541
- preferredMimeTypesVideoCodecs: d,
578
+ preferredMimeTypesVideoCodecs: l,
542
579
  excludeMimeTypesVideoCodecs: S
543
580
  }) => {
544
581
  const C = P(
@@ -546,7 +583,7 @@ class ln {
546
583
  degradationPreference: i
547
584
  },
548
585
  {
549
- preferredMimeTypesVideoCodecs: d,
586
+ preferredMimeTypesVideoCodecs: l,
550
587
  excludeMimeTypesVideoCodecs: S
551
588
  }
552
589
  );
@@ -570,15 +607,15 @@ class ln {
570
607
  simulcastEncodings: r,
571
608
  degradationPreference: i,
572
609
  sendEncodings: c,
573
- preferredMimeTypesVideoCodecs: d,
610
+ preferredMimeTypesVideoCodecs: l,
574
611
  excludeMimeTypesVideoCodecs: S
575
612
  }, C) => {
576
- const h = P(
613
+ const f = P(
577
614
  {
578
615
  degradationPreference: i
579
616
  },
580
617
  {
581
- preferredMimeTypesVideoCodecs: d,
618
+ preferredMimeTypesVideoCodecs: l,
582
619
  excludeMimeTypesVideoCodecs: S
583
620
  }
584
621
  );
@@ -593,7 +630,7 @@ class ln {
593
630
  simulcastEncodings: r,
594
631
  sendEncodings: c
595
632
  }),
596
- onAddedTransceiver: h
633
+ onAddedTransceiver: f
597
634
  },
598
635
  C
599
636
  );
@@ -629,7 +666,7 @@ class ln {
629
666
  contentHint: r,
630
667
  simulcastEncodings: i,
631
668
  degradationPreference: c,
632
- sendEncodings: d
669
+ sendEncodings: l
633
670
  } = {}) => {
634
671
  const S = P(
635
672
  {
@@ -648,7 +685,7 @@ class ln {
648
685
  sendEncodings: B({
649
686
  mediaStream: e,
650
687
  simulcastEncodings: i,
651
- sendEncodings: d
688
+ sendEncodings: l
652
689
  }),
653
690
  onAddedTransceiver: S
654
691
  });
@@ -659,7 +696,7 @@ class ln {
659
696
  });
660
697
  u(this, "resolveHandleReadyRemoteStreamsDebounced", ({
661
698
  onReadyRemoteStreams: e
662
- }) => he(() => {
699
+ }) => fe(() => {
663
700
  const t = this.sipConnector.getRemoteStreams();
664
701
  a("remoteStreams", t), t && e(t);
665
702
  }, 200));
@@ -673,29 +710,35 @@ class ln {
673
710
  u(this, "onMustStopPresentation", (e) => (a("onMustStopPresentation"), this.sipConnector.onSession("mustStopPresentation", e)));
674
711
  u(this, "onMoveToSpectators", (e) => (a("onMoveToSpectators"), this.sipConnector.onSession(ce, e)));
675
712
  u(this, "onMoveToParticipants", (e) => (a("onMoveToParticipants"), this.sipConnector.onSession(ae, e)));
676
- this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.sipConnector = e, this.on = this.sipConnector.on.bind(e), this.once = this.sipConnector.once.bind(e), this.onceRace = this.sipConnector.onceRace.bind(e), this.wait = this.sipConnector.wait.bind(e), this.off = this.sipConnector.off.bind(e), this.onSession = this.sipConnector.onSession.bind(e), this.onceSession = this.sipConnector.onceSession.bind(e), this.onceRaceSession = this.sipConnector.onceRaceSession.bind(e), this.waitSession = this.sipConnector.waitSession.bind(e), this.offSession = this.sipConnector.offSession.bind(e), this.sendDTMF = this.sipConnector.sendDTMF.bind(e), this.hangUp = this.sipConnector.hangUp.bind(e), this.declineToIncomingCall = this.sipConnector.declineToIncomingCall.bind(e), this.isConfigured = this.sipConnector.isConfigured.bind(e), this.sendChannels = this.sipConnector.sendChannels.bind(e), this.checkTelephony = this.sipConnector.checkTelephony.bind(e), this.waitChannels = this.sipConnector.waitChannels.bind(e), this.ping = this.sipConnector.ping.bind(e);
677
- }
678
- get isRegistered() {
679
- return this.sipConnector.isRegistered;
713
+ return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.sipConnector = e, new Proxy(this, {
714
+ get: (o, r, i) => {
715
+ if (typeof r == "string" && en.has(r) && r in this.sipConnector) {
716
+ const l = Reflect.get(this.sipConnector, r, this.sipConnector);
717
+ return typeof l == "function" ? l.bind(this.sipConnector) : l;
718
+ }
719
+ const c = Reflect.get(o, r, i);
720
+ return typeof c == "function" ? c.bind(o) : c;
721
+ }
722
+ });
680
723
  }
681
724
  }
682
725
  export {
683
- L as EEventsMainCAM,
684
- Cn as EEventsMic,
685
- fn as EEventsSyncMediaState,
686
- mn as EMimeTypesVideoCodecs,
687
- Rn as EUseLicense,
688
- ln as SipConnectorFacade,
689
- gn as causes,
690
- pn as constants,
691
- An as debug,
692
- tn as default,
693
- yn as disableDebug,
726
+ x as EEventsMainCAM,
727
+ mn as EEventsMic,
728
+ hn as EEventsSyncMediaState,
729
+ Rn as EMimeTypesVideoCodecs,
730
+ gn as EUseLicense,
731
+ Sn as SipConnectorFacade,
732
+ pn as causes,
733
+ yn as constants,
734
+ _n as debug,
735
+ sn as default,
736
+ En as disableDebug,
694
737
  Tn as enableDebug,
695
- En as eventNames,
738
+ bn as eventNames,
696
739
  De as getCodecFromSender,
697
- bn as hasCanceledCallError,
740
+ Mn as hasCanceledCallError,
698
741
  dn as resolveVideoSendingBalancer,
699
742
  ie as setParametersToSender,
700
- un as tools
743
+ ln as tools
701
744
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-connector",
3
- "version": "13.1.0",
3
+ "version": "13.2.0",
4
4
  "description": "Module for connect to Vinteo server",
5
5
  "keywords": [
6
6
  "webrtc",
@@ -64,7 +64,7 @@
64
64
  "dependencies": {
65
65
  "@krivega/cancelable-promise": "^1.1.3",
66
66
  "@krivega/jssip": "^5.1.0",
67
- "debug": "^4.3.7",
67
+ "debug": "^4.4.0",
68
68
  "events-constructor": "^1.3.0",
69
69
  "repeated-calls": "^2.3.0",
70
70
  "sequent-promises": "^2.0.1",
@@ -105,14 +105,14 @@
105
105
  "ts-node": "^10.9.2",
106
106
  "tsc-files": "^1.1.4",
107
107
  "typescript": "^5.7.2",
108
- "vite": "^6.0.2",
108
+ "vite": "^6.0.3",
109
109
  "vite-plugin-dts": "^4.3.0",
110
- "vite-tsconfig-paths": "^5.1.3"
110
+ "vite-tsconfig-paths": "^5.1.4"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "@krivega/cancelable-promise": "^1.1.3",
114
114
  "@krivega/jssip": "^5.1.0",
115
- "debug": "^4.3.7",
115
+ "debug": "^4.4.0",
116
116
  "events-constructor": "^1.3.0",
117
117
  "repeated-calls": "^2.2.1",
118
118
  "sequent-promises": "^2.0.1",