sip-connector 13.3.0 → 13.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +129 -129
- package/package.json +6 -6
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 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","sendChannels","checkTelephony","waitChannels","ping","connection","isConfigured","isRegistered"]);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,"sendChannels");u(this,"checkTelephony");u(this,"waitChannels");u(this,"ping");u(this,"connection");u(this,"isConfigured");u(this,"isRegistered");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;
|
|
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 a=(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=[],u=t?"0":"1",l=s?"0":"1";return c.push(`X-Vinteo-Mic-State: ${u}`,`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=()=>{},u=()=>{},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);u=s(v);const O=e(E,y);l=r(O);const N=e(T,M);g=i(N)},S=()=>{c(),u(),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,u=i/e.height,l=Math.max(c,u,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()),H=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 H({sender:n,maxBitrate:r,onSetParameters:t,scaleResolutionDownBy:200})},L=async({sender:n,videoTrack:e,codec:t},s)=>{const c=e.getSettings().width,u=Q(c,t);return H({sender:n,maxBitrate:u,onSetParameters:s,scaleResolutionDownBy:1})},$e=async({sender:n,videoTrack:e,resolution:t,codec:s},r)=>{const[i,c]=t.split("x"),{maxBitrate:u,scaleResolutionDownBy:l}=J({videoTrack:e,codec:s,targetSize:{width:Number(i),height:Number(c)}});return H({sender:n,maxBitrate:u,onSetParameters:r,scaleResolutionDownBy:l})},He=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)}},q={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 q;const u=await G(c);return K(u,r)?q:He({mainCam:n,resolutionMainCam:e,sender:c,codec:u,videoTrack:c.track},s)},qe=(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 u=s[c]??{};u.active=!0,i.rid!==void 0&&(u.rid=i.rid),i.scalabilityMode!==void 0&&(u.scalabilityMode=i.scalabilityMode);const{maxBitrate:l,scaleResolutionDownBy:g}=J({videoTrack:r,targetSize:{width:i.width,height:i.height}});u.maxBitrate=l,u.scaleResolutionDownBy=g,s[c]=u}),s}return t},je=(n,e)=>n.filter(s=>e.some(r=>r.clockRate===s.clockRate&&r.mimeType===s.mimeType&&r.channels===s.channels&&r.sdpFmtpLine===s.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,u=i===-1?Number.MAX_VALUE:i;return c-u}),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),u=Ge(c,e);s.setCodecPreferences(u)}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","sendChannels","checkTelephony","waitChannels","ping","connection","isConfigured","isRegistered"]);class Qe{constructor(e,{preferredMimeTypesVideoCodecs:t,excludeMimeTypesVideoCodecs:s}={}){a(this,"sipConnector");a(this,"preferredMimeTypesVideoCodecs");a(this,"excludeMimeTypesVideoCodecs");a(this,"on");a(this,"once");a(this,"onceRace");a(this,"wait");a(this,"off");a(this,"onSession");a(this,"onceSession");a(this,"onceRaceSession");a(this,"waitSession");a(this,"offSession");a(this,"sendDTMF");a(this,"hangUp");a(this,"declineToIncomingCall");a(this,"sendChannels");a(this,"checkTelephony");a(this,"waitChannels");a(this,"ping");a(this,"connection");a(this,"isConfigured");a(this,"isRegistered");a(this,"connectToServer",async e=>{const{userAgent:t,sipWebSocketServerURL:s,sipServerUrl:r,remoteAddress:i,displayName:c,name:u,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:u,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)))});a(this,"callToServer",async e=>{const{conference:t,mediaStream:s,extraHeaders:r,iceServers:i,contentHint:c,simulcastEncodings:u,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:u,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)});a(this,"disconnectFromServer",async()=>this.sipConnector.disconnect().then(()=>(o.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(o.logger("disconnectFromServer: catch",e),{isSuccessful:!1})));a(this,"answerIncomingCall",async e=>{const{mediaStream:t,extraHeaders:s,iceServers:r,contentHint:i,simulcastEncodings:c,degradationPreference:u,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:u},{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)});a(this,"updatePresentation",async({mediaStream:e,isP2P:t,maxBitrate:s,contentHint:r,simulcastEncodings:i,degradationPreference:c,sendEncodings:u,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:u}),onAddedTransceiver:C})});a(this,"startPresentation",async({mediaStream:e,isP2P:t,maxBitrate:s,contentHint:r,simulcastEncodings:i,degradationPreference:c,sendEncodings:u,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:u}),onAddedTransceiver:S},C)});a(this,"stopShareSipConnector",async({isP2P:e=!1}={})=>(o.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{o.logger(t)})));a(this,"sendRefusalToTurnOnMic",async()=>{if(this.sipConnector.isCallActive)return o.logger("sendRefusalToTurnOnMic"),this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{o.logger("sendRefusalToTurnOnMic: error",e)})});a(this,"sendRefusalToTurnOnCam",async()=>{if(this.sipConnector.isCallActive)return o.logger("sendRefusalToTurnOnCam"),this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{o.logger("sendRefusalToTurnOnCam: error",e)})});a(this,"sendMediaState",async({isEnabledCam:e,isEnabledMic:t})=>{if(this.sipConnector.isCallActive)return o.logger("sendMediaState"),this.sipConnector.sendMediaState({cam:e,mic:t})});a(this,"replaceMediaStream",async(e,{deleteExisting:t,addMissing:s,forceRenegotiation:r,contentHint:i,simulcastEncodings:c,degradationPreference:u,sendEncodings:l}={})=>{const g=D({degradationPreference:u},{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})});a(this,"askPermissionToEnableCam",async()=>{if(this.sipConnector.isCallActive)return o.logger("askPermissionToEnableCam"),this.sipConnector.askPermissionToEnableCam()});a(this,"resolveHandleReadyRemoteStreamsDebounced",({onReadyRemoteStreams:e})=>ce.debounce(()=>{const t=this.sipConnector.getRemoteStreams();o.logger("remoteStreams",t),t&&e(t)},200));a(this,"resolveHandleReadyRemoteStreams",({onReadyRemoteStreams:e})=>({track:t})=>{Ye(t)&&e()});a(this,"getRemoteStreams",()=>(o.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams()));a(this,"onUseLicense",e=>(o.logger("onUseLicense"),this.sipConnector.onSession("useLicense",e)));a(this,"onMustStopPresentation",e=>(o.logger("onMustStopPresentation"),this.sipConnector.onSession("mustStopPresentation",e)));a(this,"onMoveToSpectators",e=>(o.logger("onMoveToSpectators"),this.sipConnector.onSession(o.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS,e)));a(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 u=Reflect.get(r,i,c);return typeof u=="function"?u.bind(r):u}})}}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=qe;exports.tools=_e;
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
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
|
-
var
|
|
4
|
-
import { B as G, N as K, l as
|
|
3
|
+
var c = (n, e, t) => oe(n, typeof e != "symbol" ? e + "" : e, t);
|
|
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
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
7
|
import { createStackPromises as le } from "stack-promises";
|
|
8
8
|
import { isCanceledError as de } from "@krivega/cancelable-promise";
|
|
9
9
|
import { hasCanceledError as Se } from "repeated-calls";
|
|
10
10
|
import { debounce as fe } from "ts-debounce";
|
|
11
|
-
import { default as
|
|
11
|
+
import { default as An } from "debug";
|
|
12
12
|
const H = (n) => {
|
|
13
13
|
const { url: e, cause: t } = n;
|
|
14
14
|
let s = e;
|
|
15
15
|
return (t === G || t === K) && (s = `${n.message.to.uri.user}@${n.message.to.uri.host}`), s;
|
|
16
16
|
};
|
|
17
|
-
var
|
|
17
|
+
var Y = /* @__PURE__ */ ((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))(Y || {});
|
|
18
18
|
const Ce = (n = new Error()) => {
|
|
19
19
|
var o;
|
|
20
20
|
const { cause: e, socket: t } = n;
|
|
@@ -41,7 +41,7 @@ const Ce = (n = new Error()) => {
|
|
|
41
41
|
try {
|
|
42
42
|
e = JSON.stringify(n);
|
|
43
43
|
} catch (t) {
|
|
44
|
-
|
|
44
|
+
a("failed to stringify message", t);
|
|
45
45
|
}
|
|
46
46
|
return e;
|
|
47
47
|
}, he = (n = new Error()) => {
|
|
@@ -49,7 +49,7 @@ const Ce = (n = new Error()) => {
|
|
|
49
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
|
-
EErrorTypes:
|
|
52
|
+
EErrorTypes: Y,
|
|
53
53
|
getLinkError: H,
|
|
54
54
|
getTypeFromError: Ce,
|
|
55
55
|
getValuesFromError: he
|
|
@@ -61,8 +61,8 @@ const Ce = (n = new Error()) => {
|
|
|
61
61
|
isRegistered: o,
|
|
62
62
|
isPresentationCall: r
|
|
63
63
|
}) => {
|
|
64
|
-
const i = [],
|
|
65
|
-
return i.push(`X-Vinteo-Mic-State: ${
|
|
64
|
+
const i = [], u = t ? "0" : "1", l = s ? "0" : "1";
|
|
65
|
+
return i.push(`X-Vinteo-Mic-State: ${u}`, `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
66
|
}, pe = "[@*!|]", ye = "_", Ee = (n) => {
|
|
67
67
|
let e = n;
|
|
68
68
|
return e = e.replaceAll(new RegExp(pe, "g"), ye), e;
|
|
@@ -80,23 +80,23 @@ const Ce = (n = new Error()) => {
|
|
|
80
80
|
browserName: t,
|
|
81
81
|
browserVersion: s,
|
|
82
82
|
appName: o
|
|
83
|
-
}) => n ? Te({ appVersion: e, browserName: t, browserVersion: s, appName: o }) : "Chrome",
|
|
83
|
+
}) => n ? Te({ appVersion: e, browserName: t, browserVersion: s, appName: o }) : "Chrome", q = "purgatory", D = (n) => n === q, Me = (n) => (e) => [...e].map((s) => async () => n(s)), _e = async ({
|
|
84
84
|
accumulatedKeys: n,
|
|
85
85
|
sendKey: e,
|
|
86
86
|
canRunTask: t
|
|
87
87
|
}) => {
|
|
88
88
|
const o = Me(e)(n);
|
|
89
89
|
return ue(o, t);
|
|
90
|
-
},
|
|
90
|
+
}, Ae = (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
91
|
const e = (m, p) => ({ isSyncForced: h = !1 }) => {
|
|
92
92
|
if (h) {
|
|
93
93
|
m();
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
p();
|
|
97
|
-
}, t =
|
|
97
|
+
}, t = Ae(n), s = Oe(n), o = ve(n), r = Ne(n);
|
|
98
98
|
let i = () => {
|
|
99
|
-
},
|
|
99
|
+
}, u = () => {
|
|
100
100
|
}, l = () => {
|
|
101
101
|
}, S = () => {
|
|
102
102
|
};
|
|
@@ -110,22 +110,22 @@ const Ce = (n = new Error()) => {
|
|
|
110
110
|
onStopMicForced: T,
|
|
111
111
|
onStopMicNotForced: b
|
|
112
112
|
}) => {
|
|
113
|
-
const
|
|
113
|
+
const A = e(
|
|
114
114
|
m,
|
|
115
115
|
p
|
|
116
116
|
);
|
|
117
|
-
i = t(
|
|
117
|
+
i = t(A);
|
|
118
118
|
const v = e(
|
|
119
119
|
h,
|
|
120
120
|
R
|
|
121
121
|
);
|
|
122
|
-
|
|
122
|
+
u = s(v);
|
|
123
123
|
const O = e(y, E);
|
|
124
124
|
l = o(O);
|
|
125
125
|
const N = e(T, b);
|
|
126
126
|
S = r(N);
|
|
127
127
|
}, f = () => {
|
|
128
|
-
i(),
|
|
128
|
+
i(), u(), l(), S();
|
|
129
129
|
};
|
|
130
130
|
return {
|
|
131
131
|
start: (m) => {
|
|
@@ -137,13 +137,13 @@ const Ce = (n = new Error()) => {
|
|
|
137
137
|
};
|
|
138
138
|
}, ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
139
139
|
__proto__: null,
|
|
140
|
-
PURGATORY_CONFERENCE_NUMBER:
|
|
140
|
+
PURGATORY_CONFERENCE_NUMBER: q,
|
|
141
141
|
createSyncMediaState: we,
|
|
142
142
|
error: Re,
|
|
143
143
|
getExtraHeaders: ge,
|
|
144
144
|
getUserAgent: be,
|
|
145
145
|
hasPurgatory: D,
|
|
146
|
-
sendDTMFAccumulated:
|
|
146
|
+
sendDTMFAccumulated: _e
|
|
147
147
|
}, Symbol.toStringTag, { value: "Module" })), Be = (n) => [...n.keys()].map((e) => n.get(e)), Pe = (n, e) => Be(n).find((t) => t.type === e), De = async (n) => n.getStats().then((e) => {
|
|
148
148
|
const t = Pe(e, "codec");
|
|
149
149
|
return t == null ? void 0 : t.mimeType;
|
|
@@ -158,10 +158,10 @@ 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,
|
|
161
|
+
const s = n.getSettings(), o = s.width, r = s.height, i = o / e.width, u = r / e.height, l = Math.max(i, u, He), S = Z(e.width, t);
|
|
162
162
|
return { scaleResolutionDownBy: l, maxBitrate: S };
|
|
163
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,
|
|
167
167
|
scaleResolutionDownBy: e,
|
|
@@ -180,10 +180,10 @@ const Ce = (n = new Error()) => {
|
|
|
180
180
|
videoTrack: e,
|
|
181
181
|
codec: t
|
|
182
182
|
}, s) => {
|
|
183
|
-
const i = e.getSettings().width,
|
|
183
|
+
const i = e.getSettings().width, u = Z(i, t);
|
|
184
184
|
return X({
|
|
185
185
|
sender: n,
|
|
186
|
-
maxBitrate:
|
|
186
|
+
maxBitrate: u,
|
|
187
187
|
onSetParameters: s,
|
|
188
188
|
scaleResolutionDownBy: 1
|
|
189
189
|
});
|
|
@@ -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:
|
|
196
|
+
const [r, i] = t.split("x"), { maxBitrate: u, scaleResolutionDownBy: l } = ee({
|
|
197
197
|
videoTrack: e,
|
|
198
198
|
codec: s,
|
|
199
199
|
targetSize: {
|
|
@@ -203,7 +203,7 @@ const Ce = (n = new Error()) => {
|
|
|
203
203
|
});
|
|
204
204
|
return X({
|
|
205
205
|
sender: n,
|
|
206
|
-
maxBitrate:
|
|
206
|
+
maxBitrate: u,
|
|
207
207
|
onSetParameters: o,
|
|
208
208
|
scaleResolutionDownBy: l
|
|
209
209
|
});
|
|
@@ -246,13 +246,13 @@ const Ce = (n = new Error()) => {
|
|
|
246
246
|
const r = t.getSenders(), i = Ie(r);
|
|
247
247
|
if (!(i != null && i.track))
|
|
248
248
|
return j;
|
|
249
|
-
const
|
|
250
|
-
return z(
|
|
249
|
+
const u = await De(i);
|
|
250
|
+
return z(u, o) ? j : Ke(
|
|
251
251
|
{
|
|
252
252
|
mainCam: n,
|
|
253
253
|
resolutionMainCam: e,
|
|
254
254
|
sender: i,
|
|
255
|
-
codec:
|
|
255
|
+
codec: u,
|
|
256
256
|
videoTrack: i.track
|
|
257
257
|
},
|
|
258
258
|
s
|
|
@@ -299,16 +299,16 @@ const Ce = (n = new Error()) => {
|
|
|
299
299
|
return o();
|
|
300
300
|
}
|
|
301
301
|
};
|
|
302
|
-
},
|
|
302
|
+
}, Ye = (n) => n.getVideoTracks()[0], B = ({
|
|
303
303
|
mediaStream: n,
|
|
304
304
|
simulcastEncodings: e,
|
|
305
305
|
sendEncodings: t
|
|
306
306
|
}) => {
|
|
307
307
|
if (e && e.length > 0) {
|
|
308
|
-
const s = t ?? [], o =
|
|
308
|
+
const s = t ?? [], o = Ye(n);
|
|
309
309
|
return e.forEach((r, i) => {
|
|
310
|
-
const
|
|
311
|
-
|
|
310
|
+
const u = s[i] ?? {};
|
|
311
|
+
u.active = !0, r.rid !== void 0 && (u.rid = r.rid), r.scalabilityMode !== void 0 && (u.scalabilityMode = r.scalabilityMode);
|
|
312
312
|
const { maxBitrate: l, scaleResolutionDownBy: S } = ee({
|
|
313
313
|
videoTrack: o,
|
|
314
314
|
targetSize: {
|
|
@@ -316,24 +316,24 @@ const Ce = (n = new Error()) => {
|
|
|
316
316
|
height: r.height
|
|
317
317
|
}
|
|
318
318
|
});
|
|
319
|
-
|
|
319
|
+
u.maxBitrate = l, u.scaleResolutionDownBy = S, s[i] = u;
|
|
320
320
|
}), s;
|
|
321
321
|
}
|
|
322
322
|
return t;
|
|
323
|
-
},
|
|
323
|
+
}, qe = (n, e) => n.filter((s) => e.some((o) => o.clockRate === s.clockRate && o.mimeType === s.mimeType && o.channels === s.channels && o.sdpFmtpLine === s.sdpFmtpLine)), ze = (n) => {
|
|
324
324
|
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, o = t === null ? [] : t.codecs;
|
|
325
|
-
return
|
|
325
|
+
return qe(s, o);
|
|
326
326
|
}, Qe = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
327
|
-
const o = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), i = o === -1 ? Number.MAX_VALUE : o,
|
|
328
|
-
return i -
|
|
327
|
+
const o = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), i = o === -1 ? Number.MAX_VALUE : o, u = r === -1 ? Number.MAX_VALUE : r;
|
|
328
|
+
return i - u;
|
|
329
329
|
}), Je = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), P = (n, {
|
|
330
330
|
preferredMimeTypesVideoCodecs: e,
|
|
331
331
|
excludeMimeTypesVideoCodecs: t
|
|
332
332
|
}) => async (s) => {
|
|
333
333
|
var o;
|
|
334
334
|
if (typeof s.setCodecPreferences == "function" && ((o = s.sender.track) == null ? void 0 : o.kind) === "video" && (e !== void 0 && (e == null ? void 0 : e.length) > 0 || t !== void 0 && (t == null ? void 0 : t.length) > 0)) {
|
|
335
|
-
const r = ze("video"), i = Je(r, t),
|
|
336
|
-
s.setCodecPreferences(
|
|
335
|
+
const r = ze("video"), i = Je(r, t), u = Qe(i, e);
|
|
336
|
+
s.setCodecPreferences(u);
|
|
337
337
|
}
|
|
338
338
|
Object.keys(n).length > 0 && await ie(s.sender, n);
|
|
339
339
|
}, $ = (n) => {
|
|
@@ -367,80 +367,80 @@ class Sn {
|
|
|
367
367
|
preferredMimeTypesVideoCodecs: t,
|
|
368
368
|
excludeMimeTypesVideoCodecs: s
|
|
369
369
|
} = {}) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
370
|
+
c(this, "sipConnector");
|
|
371
|
+
c(this, "preferredMimeTypesVideoCodecs");
|
|
372
|
+
c(this, "excludeMimeTypesVideoCodecs");
|
|
373
373
|
// @ts-expect-error: proxy method
|
|
374
|
-
|
|
374
|
+
c(this, "on");
|
|
375
375
|
// @ts-expect-error: proxy method
|
|
376
|
-
|
|
376
|
+
c(this, "once");
|
|
377
377
|
// @ts-expect-error: proxy method
|
|
378
|
-
|
|
378
|
+
c(this, "onceRace");
|
|
379
379
|
// @ts-expect-error: proxy method
|
|
380
|
-
|
|
380
|
+
c(this, "wait");
|
|
381
381
|
// @ts-expect-error: proxy method
|
|
382
|
-
|
|
382
|
+
c(this, "off");
|
|
383
383
|
// @ts-expect-error: proxy method
|
|
384
|
-
|
|
384
|
+
c(this, "onSession");
|
|
385
385
|
// @ts-expect-error: proxy method
|
|
386
|
-
|
|
386
|
+
c(this, "onceSession");
|
|
387
387
|
// @ts-expect-error: proxy method
|
|
388
|
-
|
|
388
|
+
c(this, "onceRaceSession");
|
|
389
389
|
// @ts-expect-error: proxy method
|
|
390
|
-
|
|
390
|
+
c(this, "waitSession");
|
|
391
391
|
// @ts-expect-error: proxy method
|
|
392
|
-
|
|
392
|
+
c(this, "offSession");
|
|
393
393
|
// @ts-expect-error: proxy method
|
|
394
|
-
|
|
394
|
+
c(this, "sendDTMF");
|
|
395
395
|
// @ts-expect-error: proxy method
|
|
396
|
-
|
|
396
|
+
c(this, "hangUp");
|
|
397
397
|
// @ts-expect-error: proxy method
|
|
398
|
-
|
|
398
|
+
c(this, "declineToIncomingCall");
|
|
399
399
|
// @ts-expect-error: proxy method
|
|
400
|
-
|
|
400
|
+
c(this, "sendChannels");
|
|
401
401
|
// @ts-expect-error: proxy method
|
|
402
|
-
|
|
402
|
+
c(this, "checkTelephony");
|
|
403
403
|
// @ts-expect-error: proxy method
|
|
404
|
-
|
|
404
|
+
c(this, "waitChannels");
|
|
405
405
|
// @ts-expect-error: proxy method
|
|
406
|
-
|
|
406
|
+
c(this, "ping");
|
|
407
407
|
// proxy method
|
|
408
|
-
|
|
408
|
+
c(this, "connection");
|
|
409
409
|
// @ts-expect-error: proxy method
|
|
410
|
-
|
|
410
|
+
c(this, "isConfigured");
|
|
411
411
|
// @ts-expect-error: proxy method
|
|
412
|
-
|
|
413
|
-
|
|
412
|
+
c(this, "isRegistered");
|
|
413
|
+
c(this, "connectToServer", async (e) => {
|
|
414
414
|
const {
|
|
415
415
|
userAgent: t,
|
|
416
416
|
sipWebSocketServerURL: s,
|
|
417
417
|
sipServerUrl: o,
|
|
418
418
|
remoteAddress: r,
|
|
419
419
|
displayName: i,
|
|
420
|
-
name:
|
|
420
|
+
name: u,
|
|
421
421
|
password: l,
|
|
422
422
|
isRegisteredUser: S,
|
|
423
423
|
isDisconnectOnFail: C
|
|
424
424
|
} = e;
|
|
425
|
-
return
|
|
425
|
+
return a("connectToServer", e), this.sipConnector.connect({
|
|
426
426
|
userAgent: t,
|
|
427
427
|
sipWebSocketServerURL: s,
|
|
428
428
|
sipServerUrl: o,
|
|
429
429
|
remoteAddress: r,
|
|
430
430
|
displayName: i,
|
|
431
431
|
password: l,
|
|
432
|
-
user:
|
|
432
|
+
user: u,
|
|
433
433
|
register: S
|
|
434
|
-
}).then((f) => (
|
|
434
|
+
}).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)));
|
|
435
435
|
});
|
|
436
|
-
|
|
436
|
+
c(this, "callToServer", async (e) => {
|
|
437
437
|
const {
|
|
438
438
|
conference: t,
|
|
439
439
|
mediaStream: s,
|
|
440
440
|
extraHeaders: o,
|
|
441
441
|
iceServers: r,
|
|
442
442
|
contentHint: i,
|
|
443
|
-
simulcastEncodings:
|
|
443
|
+
simulcastEncodings: u,
|
|
444
444
|
degradationPreference: l,
|
|
445
445
|
sendEncodings: S,
|
|
446
446
|
offerToReceiveAudio: C,
|
|
@@ -455,10 +455,10 @@ class Sn {
|
|
|
455
455
|
onFailProgressCall: E,
|
|
456
456
|
onFinishProgressCall: T,
|
|
457
457
|
onEndedCall: b
|
|
458
|
-
} = e,
|
|
458
|
+
} = e, A = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
459
459
|
onReadyRemoteStreams: m
|
|
460
460
|
}), v = this.resolveHandleReadyRemoteStreams({
|
|
461
|
-
onReadyRemoteStreams:
|
|
461
|
+
onReadyRemoteStreams: A
|
|
462
462
|
}), O = P(
|
|
463
463
|
{
|
|
464
464
|
degradationPreference: l
|
|
@@ -468,8 +468,8 @@ class Sn {
|
|
|
468
468
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
469
469
|
}
|
|
470
470
|
);
|
|
471
|
-
|
|
472
|
-
const N = async () => (
|
|
471
|
+
a("callToServer", e);
|
|
472
|
+
const N = async () => (a("startCall"), this.sipConnector.call({
|
|
473
473
|
mediaStream: s,
|
|
474
474
|
extraHeaders: o,
|
|
475
475
|
iceServers: r,
|
|
@@ -480,35 +480,35 @@ class Sn {
|
|
|
480
480
|
directionAudio: F,
|
|
481
481
|
sendEncodings: B({
|
|
482
482
|
mediaStream: s,
|
|
483
|
-
simulcastEncodings:
|
|
483
|
+
simulcastEncodings: u,
|
|
484
484
|
sendEncodings: S
|
|
485
485
|
}),
|
|
486
486
|
number: t,
|
|
487
487
|
onAddedTransceiver: O,
|
|
488
488
|
ontrack: v
|
|
489
489
|
}));
|
|
490
|
-
let M = !1,
|
|
491
|
-
const w = (
|
|
492
|
-
|
|
490
|
+
let M = !1, _;
|
|
491
|
+
const w = (a("subscribeEnterConference: onEnterConference", y), R ?? y ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
|
|
492
|
+
a("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? R && R() : y && y({ isSuccessProgressCall: M });
|
|
493
493
|
}) : () => {
|
|
494
|
-
}), k = (d) => (
|
|
494
|
+
}), k = (d) => (a("onSuccess"), M = !0, A(), h && h({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
|
|
495
495
|
w(), b && b();
|
|
496
496
|
}), d), U = (d) => {
|
|
497
|
-
throw
|
|
497
|
+
throw a("onFail"), E && E(), w(), d;
|
|
498
498
|
}, V = () => {
|
|
499
|
-
|
|
499
|
+
a("onFinish"), T && T();
|
|
500
500
|
};
|
|
501
|
-
return
|
|
501
|
+
return a("onBeforeProgressCall"), p && p(t), N().then(k).catch((d) => U(d)).finally(V);
|
|
502
502
|
});
|
|
503
|
-
|
|
504
|
-
|
|
503
|
+
c(this, "disconnectFromServer", async () => this.sipConnector.disconnect().then(() => (a("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (a("disconnectFromServer: catch", e), { isSuccessful: !1 })));
|
|
504
|
+
c(this, "answerIncomingCall", async (e) => {
|
|
505
505
|
const {
|
|
506
506
|
mediaStream: t,
|
|
507
507
|
extraHeaders: s,
|
|
508
508
|
iceServers: o,
|
|
509
509
|
contentHint: r,
|
|
510
510
|
simulcastEncodings: i,
|
|
511
|
-
degradationPreference:
|
|
511
|
+
degradationPreference: u,
|
|
512
512
|
sendEncodings: l,
|
|
513
513
|
offerToReceiveAudio: S,
|
|
514
514
|
offerToReceiveVideo: C,
|
|
@@ -524,18 +524,18 @@ class Sn {
|
|
|
524
524
|
onEndedCall: T
|
|
525
525
|
} = e, b = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
526
526
|
onReadyRemoteStreams: F
|
|
527
|
-
}),
|
|
527
|
+
}), A = this.resolveHandleReadyRemoteStreams({
|
|
528
528
|
onReadyRemoteStreams: b
|
|
529
529
|
}), v = P(
|
|
530
530
|
{
|
|
531
|
-
degradationPreference:
|
|
531
|
+
degradationPreference: u
|
|
532
532
|
},
|
|
533
533
|
{
|
|
534
534
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
535
535
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
536
536
|
}
|
|
537
537
|
);
|
|
538
|
-
|
|
538
|
+
a("answerIncomingCall", e);
|
|
539
539
|
const O = async () => this.sipConnector.answerToIncomingCall({
|
|
540
540
|
mediaStream: t,
|
|
541
541
|
extraHeaders: s,
|
|
@@ -551,36 +551,36 @@ class Sn {
|
|
|
551
551
|
sendEncodings: l
|
|
552
552
|
}),
|
|
553
553
|
onAddedTransceiver: v,
|
|
554
|
-
ontrack:
|
|
554
|
+
ontrack: A
|
|
555
555
|
}), N = () => {
|
|
556
556
|
const { remoteCallerData: d } = this.sipConnector;
|
|
557
557
|
return d.incomingNumber;
|
|
558
558
|
};
|
|
559
|
-
let M = !1,
|
|
560
|
-
const w = (
|
|
561
|
-
|
|
559
|
+
let M = !1, _;
|
|
560
|
+
const w = (a("subscribeEnterConference: onEnterConference", R), h ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
|
|
561
|
+
a("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? h && h() : R && R({ isSuccessProgressCall: M });
|
|
562
562
|
}) : () => {
|
|
563
|
-
}), k = (d) => (
|
|
563
|
+
}), k = (d) => (a("onSuccess"), M = !0, b(), p && p({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
|
|
564
564
|
w(), T && T();
|
|
565
565
|
}), d), U = (d) => {
|
|
566
|
-
throw
|
|
566
|
+
throw a("onFail"), y && y(), w(), d;
|
|
567
567
|
}, V = () => {
|
|
568
|
-
|
|
568
|
+
a("onFinish"), E && E();
|
|
569
569
|
};
|
|
570
|
-
if (
|
|
570
|
+
if (a("onBeforeProgressCall"), m) {
|
|
571
571
|
const d = N();
|
|
572
572
|
m(d);
|
|
573
573
|
}
|
|
574
574
|
return O().then(k).catch((d) => U(d)).finally(V);
|
|
575
575
|
});
|
|
576
|
-
|
|
576
|
+
c(this, "updatePresentation", async ({
|
|
577
577
|
mediaStream: e,
|
|
578
578
|
isP2P: t,
|
|
579
579
|
maxBitrate: s,
|
|
580
580
|
contentHint: o,
|
|
581
581
|
simulcastEncodings: r,
|
|
582
582
|
degradationPreference: i,
|
|
583
|
-
sendEncodings:
|
|
583
|
+
sendEncodings: u,
|
|
584
584
|
preferredMimeTypesVideoCodecs: l,
|
|
585
585
|
excludeMimeTypesVideoCodecs: S
|
|
586
586
|
}) => {
|
|
@@ -593,26 +593,26 @@ class Sn {
|
|
|
593
593
|
excludeMimeTypesVideoCodecs: S
|
|
594
594
|
}
|
|
595
595
|
);
|
|
596
|
-
return
|
|
596
|
+
return a("updatePresentation"), this.sipConnector.updatePresentation(e, {
|
|
597
597
|
isP2P: t,
|
|
598
598
|
maxBitrate: s,
|
|
599
599
|
contentHint: o,
|
|
600
600
|
sendEncodings: B({
|
|
601
601
|
mediaStream: e,
|
|
602
602
|
simulcastEncodings: r,
|
|
603
|
-
sendEncodings:
|
|
603
|
+
sendEncodings: u
|
|
604
604
|
}),
|
|
605
605
|
onAddedTransceiver: C
|
|
606
606
|
});
|
|
607
607
|
});
|
|
608
|
-
|
|
608
|
+
c(this, "startPresentation", async ({
|
|
609
609
|
mediaStream: e,
|
|
610
610
|
isP2P: t,
|
|
611
611
|
maxBitrate: s,
|
|
612
612
|
contentHint: o,
|
|
613
613
|
simulcastEncodings: r,
|
|
614
614
|
degradationPreference: i,
|
|
615
|
-
sendEncodings:
|
|
615
|
+
sendEncodings: u,
|
|
616
616
|
preferredMimeTypesVideoCodecs: l,
|
|
617
617
|
excludeMimeTypesVideoCodecs: S
|
|
618
618
|
}, C) => {
|
|
@@ -625,7 +625,7 @@ class Sn {
|
|
|
625
625
|
excludeMimeTypesVideoCodecs: S
|
|
626
626
|
}
|
|
627
627
|
);
|
|
628
|
-
return
|
|
628
|
+
return a("startPresentation"), this.sipConnector.startPresentation(
|
|
629
629
|
e,
|
|
630
630
|
{
|
|
631
631
|
isP2P: t,
|
|
@@ -634,56 +634,56 @@ class Sn {
|
|
|
634
634
|
sendEncodings: B({
|
|
635
635
|
mediaStream: e,
|
|
636
636
|
simulcastEncodings: r,
|
|
637
|
-
sendEncodings:
|
|
637
|
+
sendEncodings: u
|
|
638
638
|
}),
|
|
639
639
|
onAddedTransceiver: f
|
|
640
640
|
},
|
|
641
641
|
C
|
|
642
642
|
);
|
|
643
643
|
});
|
|
644
|
-
|
|
644
|
+
c(this, "stopShareSipConnector", async ({ isP2P: e = !1 } = {}) => (a("stopShareSipConnector"), this.sipConnector.stopPresentation({
|
|
645
645
|
isP2P: e
|
|
646
646
|
}).catch((t) => {
|
|
647
|
-
|
|
647
|
+
a(t);
|
|
648
648
|
})));
|
|
649
|
-
|
|
649
|
+
c(this, "sendRefusalToTurnOnMic", async () => {
|
|
650
650
|
if (this.sipConnector.isCallActive)
|
|
651
|
-
return
|
|
652
|
-
|
|
651
|
+
return a("sendRefusalToTurnOnMic"), this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
|
|
652
|
+
a("sendRefusalToTurnOnMic: error", e);
|
|
653
653
|
});
|
|
654
654
|
});
|
|
655
|
-
|
|
655
|
+
c(this, "sendRefusalToTurnOnCam", async () => {
|
|
656
656
|
if (this.sipConnector.isCallActive)
|
|
657
|
-
return
|
|
658
|
-
|
|
657
|
+
return a("sendRefusalToTurnOnCam"), this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
|
|
658
|
+
a("sendRefusalToTurnOnCam: error", e);
|
|
659
659
|
});
|
|
660
660
|
});
|
|
661
|
-
|
|
661
|
+
c(this, "sendMediaState", async ({
|
|
662
662
|
isEnabledCam: e,
|
|
663
663
|
isEnabledMic: t
|
|
664
664
|
}) => {
|
|
665
665
|
if (this.sipConnector.isCallActive)
|
|
666
|
-
return
|
|
666
|
+
return a("sendMediaState"), this.sipConnector.sendMediaState({ cam: e, mic: t });
|
|
667
667
|
});
|
|
668
|
-
|
|
668
|
+
c(this, "replaceMediaStream", async (e, {
|
|
669
669
|
deleteExisting: t,
|
|
670
670
|
addMissing: s,
|
|
671
671
|
forceRenegotiation: o,
|
|
672
672
|
contentHint: r,
|
|
673
673
|
simulcastEncodings: i,
|
|
674
|
-
degradationPreference:
|
|
674
|
+
degradationPreference: u,
|
|
675
675
|
sendEncodings: l
|
|
676
676
|
} = {}) => {
|
|
677
677
|
const S = P(
|
|
678
678
|
{
|
|
679
|
-
degradationPreference:
|
|
679
|
+
degradationPreference: u
|
|
680
680
|
},
|
|
681
681
|
{
|
|
682
682
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
683
683
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
684
684
|
}
|
|
685
685
|
);
|
|
686
|
-
return
|
|
686
|
+
return a("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
|
|
687
687
|
deleteExisting: t,
|
|
688
688
|
addMissing: s,
|
|
689
689
|
forceRenegotiation: o,
|
|
@@ -696,34 +696,34 @@ class Sn {
|
|
|
696
696
|
onAddedTransceiver: S
|
|
697
697
|
});
|
|
698
698
|
});
|
|
699
|
-
|
|
699
|
+
c(this, "askPermissionToEnableCam", async () => {
|
|
700
700
|
if (this.sipConnector.isCallActive)
|
|
701
|
-
return
|
|
701
|
+
return a("askPermissionToEnableCam"), this.sipConnector.askPermissionToEnableCam();
|
|
702
702
|
});
|
|
703
|
-
|
|
703
|
+
c(this, "resolveHandleReadyRemoteStreamsDebounced", ({
|
|
704
704
|
onReadyRemoteStreams: e
|
|
705
705
|
}) => fe(() => {
|
|
706
706
|
const t = this.sipConnector.getRemoteStreams();
|
|
707
|
-
|
|
707
|
+
a("remoteStreams", t), t && e(t);
|
|
708
708
|
}, 200));
|
|
709
|
-
|
|
709
|
+
c(this, "resolveHandleReadyRemoteStreams", ({
|
|
710
710
|
onReadyRemoteStreams: e
|
|
711
711
|
}) => ({ track: t }) => {
|
|
712
712
|
Ze(t) && e();
|
|
713
713
|
});
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
714
|
+
c(this, "getRemoteStreams", () => (a("getRemoteStreams"), this.sipConnector.getRemoteStreams()));
|
|
715
|
+
c(this, "onUseLicense", (e) => (a("onUseLicense"), this.sipConnector.onSession("useLicense", e)));
|
|
716
|
+
c(this, "onMustStopPresentation", (e) => (a("onMustStopPresentation"), this.sipConnector.onSession("mustStopPresentation", e)));
|
|
717
|
+
c(this, "onMoveToSpectators", (e) => (a("onMoveToSpectators"), this.sipConnector.onSession(ce, e)));
|
|
718
|
+
c(this, "onMoveToParticipants", (e) => (a("onMoveToParticipants"), this.sipConnector.onSession(ae, e)));
|
|
719
719
|
return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.sipConnector = e, new Proxy(this, {
|
|
720
720
|
get: (o, r, i) => {
|
|
721
721
|
if (typeof r == "string" && en.has(r) && r in this.sipConnector) {
|
|
722
722
|
const l = Reflect.get(this.sipConnector, r, this.sipConnector);
|
|
723
723
|
return typeof l == "function" ? l.bind(this.sipConnector) : l;
|
|
724
724
|
}
|
|
725
|
-
const
|
|
726
|
-
return typeof
|
|
725
|
+
const u = Reflect.get(o, r, i);
|
|
726
|
+
return typeof u == "function" ? u.bind(o) : u;
|
|
727
727
|
}
|
|
728
728
|
});
|
|
729
729
|
}
|
|
@@ -737,7 +737,7 @@ export {
|
|
|
737
737
|
Sn as SipConnectorFacade,
|
|
738
738
|
pn as causes,
|
|
739
739
|
yn as constants,
|
|
740
|
-
|
|
740
|
+
An as debug,
|
|
741
741
|
sn as default,
|
|
742
742
|
En as disableDebug,
|
|
743
743
|
Tn as enableDebug,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sip-connector",
|
|
3
|
-
"version": "13.3.
|
|
3
|
+
"version": "13.3.1",
|
|
4
4
|
"description": "Module for connect to Vinteo server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webrtc",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@babel/preset-typescript": "^7.26.0",
|
|
77
|
-
"@commitlint/cli": "^19.6.
|
|
77
|
+
"@commitlint/cli": "^19.6.1",
|
|
78
78
|
"@commitlint/config-conventional": "^19.6.0",
|
|
79
79
|
"@nabla/vite-plugin-eslint": "^2.0.5",
|
|
80
80
|
"@types/debug": "^4.1.12",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"eslint-import-resolver-typescript": "^3.7.0",
|
|
91
91
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
92
92
|
"eslint-plugin-import": "^2.31.0",
|
|
93
|
-
"eslint-plugin-jest": "^28.
|
|
93
|
+
"eslint-plugin-jest": "^28.10.0",
|
|
94
94
|
"eslint-plugin-prettier": "^5.2.1",
|
|
95
95
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
96
96
|
"husky": "^9.1.7",
|
|
@@ -98,15 +98,15 @@
|
|
|
98
98
|
"jest-environment-jsdom": "^29.7.0",
|
|
99
99
|
"jest-extended": "^4.0.2",
|
|
100
100
|
"jest-junit": "^16.0.0",
|
|
101
|
-
"lint-staged": "^15.2.
|
|
101
|
+
"lint-staged": "^15.2.11",
|
|
102
102
|
"prettier": "^3.4.2",
|
|
103
103
|
"standard-version": "^9.5.0",
|
|
104
104
|
"ts-jest": "^29.2.5",
|
|
105
105
|
"ts-node": "^10.9.2",
|
|
106
106
|
"tsc-files": "^1.1.4",
|
|
107
107
|
"typescript": "^5.7.2",
|
|
108
|
-
"vite": "^6.0.
|
|
109
|
-
"vite-plugin-dts": "^4.
|
|
108
|
+
"vite": "^6.0.4",
|
|
109
|
+
"vite-plugin-dts": "^4.4.0",
|
|
110
110
|
"vite-tsconfig-paths": "^5.1.4"
|
|
111
111
|
},
|
|
112
112
|
"peerDependencies": {
|