sip-connector 13.2.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/SipConnectorFacade/SipConnectorFacade.d.ts +6 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +108 -102
- package/package.json +6 -6
|
@@ -15,11 +15,13 @@ interface IProxyMethods {
|
|
|
15
15
|
sendDTMF: SipConnector['sendDTMF'];
|
|
16
16
|
hangUp: SipConnector['hangUp'];
|
|
17
17
|
declineToIncomingCall: SipConnector['declineToIncomingCall'];
|
|
18
|
-
isConfigured: SipConnector['isConfigured'];
|
|
19
18
|
sendChannels: SipConnector['sendChannels'];
|
|
20
19
|
checkTelephony: SipConnector['checkTelephony'];
|
|
21
20
|
waitChannels: SipConnector['waitChannels'];
|
|
21
|
+
ping: SipConnector['ping'];
|
|
22
22
|
connection: SipConnector['connection'];
|
|
23
|
+
isConfigured: SipConnector['isConfigured'];
|
|
24
|
+
isRegistered: SipConnector['isRegistered'];
|
|
23
25
|
}
|
|
24
26
|
declare class SipConnectorFacade implements IProxyMethods {
|
|
25
27
|
readonly sipConnector: SipConnector;
|
|
@@ -38,11 +40,13 @@ declare class SipConnectorFacade implements IProxyMethods {
|
|
|
38
40
|
sendDTMF: IProxyMethods['sendDTMF'];
|
|
39
41
|
hangUp: IProxyMethods['hangUp'];
|
|
40
42
|
declineToIncomingCall: IProxyMethods['declineToIncomingCall'];
|
|
41
|
-
isConfigured: IProxyMethods['isConfigured'];
|
|
42
43
|
sendChannels: IProxyMethods['sendChannels'];
|
|
43
44
|
checkTelephony: IProxyMethods['checkTelephony'];
|
|
44
45
|
waitChannels: IProxyMethods['waitChannels'];
|
|
46
|
+
ping: IProxyMethods['ping'];
|
|
45
47
|
connection: IProxyMethods['connection'];
|
|
48
|
+
isConfigured: IProxyMethods['isConfigured'];
|
|
49
|
+
isRegistered: IProxyMethods['isRegistered'];
|
|
46
50
|
constructor(sipConnector: SipConnector, { preferredMimeTypesVideoCodecs, excludeMimeTypesVideoCodecs, }?: {
|
|
47
51
|
preferredMimeTypesVideoCodecs?: string[];
|
|
48
52
|
excludeMimeTypesVideoCodecs?: 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 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;
|
|
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,6 +1,6 @@
|
|
|
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
|
|
3
|
+
var c = (n, e, t) => oe(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
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";
|
|
@@ -8,13 +8,13 @@ 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;
|
|
@@ -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,7 +158,7 @@ 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);
|
|
@@ -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) => {
|
|
@@ -354,64 +354,70 @@ const Ce = (n = new Error()) => {
|
|
|
354
354
|
"sendDTMF",
|
|
355
355
|
"hangUp",
|
|
356
356
|
"declineToIncomingCall",
|
|
357
|
-
"isConfigured",
|
|
358
357
|
"sendChannels",
|
|
359
358
|
"checkTelephony",
|
|
360
359
|
"waitChannels",
|
|
361
|
-
"
|
|
360
|
+
"ping",
|
|
361
|
+
"connection",
|
|
362
|
+
"isConfigured",
|
|
363
|
+
"isRegistered"
|
|
362
364
|
]);
|
|
363
365
|
class Sn {
|
|
364
366
|
constructor(e, {
|
|
365
367
|
preferredMimeTypesVideoCodecs: t,
|
|
366
368
|
excludeMimeTypesVideoCodecs: s
|
|
367
369
|
} = {}) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
370
|
+
c(this, "sipConnector");
|
|
371
|
+
c(this, "preferredMimeTypesVideoCodecs");
|
|
372
|
+
c(this, "excludeMimeTypesVideoCodecs");
|
|
371
373
|
// @ts-expect-error: proxy method
|
|
372
|
-
|
|
374
|
+
c(this, "on");
|
|
373
375
|
// @ts-expect-error: proxy method
|
|
374
|
-
|
|
376
|
+
c(this, "once");
|
|
375
377
|
// @ts-expect-error: proxy method
|
|
376
|
-
|
|
378
|
+
c(this, "onceRace");
|
|
377
379
|
// @ts-expect-error: proxy method
|
|
378
|
-
|
|
380
|
+
c(this, "wait");
|
|
379
381
|
// @ts-expect-error: proxy method
|
|
380
|
-
|
|
382
|
+
c(this, "off");
|
|
381
383
|
// @ts-expect-error: proxy method
|
|
382
|
-
|
|
384
|
+
c(this, "onSession");
|
|
383
385
|
// @ts-expect-error: proxy method
|
|
384
|
-
|
|
386
|
+
c(this, "onceSession");
|
|
385
387
|
// @ts-expect-error: proxy method
|
|
386
|
-
|
|
388
|
+
c(this, "onceRaceSession");
|
|
387
389
|
// @ts-expect-error: proxy method
|
|
388
|
-
|
|
390
|
+
c(this, "waitSession");
|
|
389
391
|
// @ts-expect-error: proxy method
|
|
390
|
-
|
|
392
|
+
c(this, "offSession");
|
|
391
393
|
// @ts-expect-error: proxy method
|
|
392
|
-
|
|
394
|
+
c(this, "sendDTMF");
|
|
393
395
|
// @ts-expect-error: proxy method
|
|
394
|
-
|
|
396
|
+
c(this, "hangUp");
|
|
395
397
|
// @ts-expect-error: proxy method
|
|
396
|
-
|
|
398
|
+
c(this, "declineToIncomingCall");
|
|
397
399
|
// @ts-expect-error: proxy method
|
|
398
|
-
|
|
400
|
+
c(this, "sendChannels");
|
|
399
401
|
// @ts-expect-error: proxy method
|
|
400
|
-
|
|
402
|
+
c(this, "checkTelephony");
|
|
401
403
|
// @ts-expect-error: proxy method
|
|
402
|
-
|
|
404
|
+
c(this, "waitChannels");
|
|
403
405
|
// @ts-expect-error: proxy method
|
|
404
|
-
|
|
406
|
+
c(this, "ping");
|
|
405
407
|
// proxy method
|
|
406
|
-
|
|
407
|
-
|
|
408
|
+
c(this, "connection");
|
|
409
|
+
// @ts-expect-error: proxy method
|
|
410
|
+
c(this, "isConfigured");
|
|
411
|
+
// @ts-expect-error: proxy method
|
|
412
|
+
c(this, "isRegistered");
|
|
413
|
+
c(this, "connectToServer", async (e) => {
|
|
408
414
|
const {
|
|
409
415
|
userAgent: t,
|
|
410
416
|
sipWebSocketServerURL: s,
|
|
411
417
|
sipServerUrl: o,
|
|
412
418
|
remoteAddress: r,
|
|
413
419
|
displayName: i,
|
|
414
|
-
name:
|
|
420
|
+
name: u,
|
|
415
421
|
password: l,
|
|
416
422
|
isRegisteredUser: S,
|
|
417
423
|
isDisconnectOnFail: C
|
|
@@ -423,18 +429,18 @@ class Sn {
|
|
|
423
429
|
remoteAddress: r,
|
|
424
430
|
displayName: i,
|
|
425
431
|
password: l,
|
|
426
|
-
user:
|
|
432
|
+
user: u,
|
|
427
433
|
register: S
|
|
428
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)));
|
|
429
435
|
});
|
|
430
|
-
|
|
436
|
+
c(this, "callToServer", async (e) => {
|
|
431
437
|
const {
|
|
432
438
|
conference: t,
|
|
433
439
|
mediaStream: s,
|
|
434
440
|
extraHeaders: o,
|
|
435
441
|
iceServers: r,
|
|
436
442
|
contentHint: i,
|
|
437
|
-
simulcastEncodings:
|
|
443
|
+
simulcastEncodings: u,
|
|
438
444
|
degradationPreference: l,
|
|
439
445
|
sendEncodings: S,
|
|
440
446
|
offerToReceiveAudio: C,
|
|
@@ -449,10 +455,10 @@ class Sn {
|
|
|
449
455
|
onFailProgressCall: E,
|
|
450
456
|
onFinishProgressCall: T,
|
|
451
457
|
onEndedCall: b
|
|
452
|
-
} = e,
|
|
458
|
+
} = e, A = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
453
459
|
onReadyRemoteStreams: m
|
|
454
460
|
}), v = this.resolveHandleReadyRemoteStreams({
|
|
455
|
-
onReadyRemoteStreams:
|
|
461
|
+
onReadyRemoteStreams: A
|
|
456
462
|
}), O = P(
|
|
457
463
|
{
|
|
458
464
|
degradationPreference: l
|
|
@@ -474,18 +480,18 @@ class Sn {
|
|
|
474
480
|
directionAudio: F,
|
|
475
481
|
sendEncodings: B({
|
|
476
482
|
mediaStream: s,
|
|
477
|
-
simulcastEncodings:
|
|
483
|
+
simulcastEncodings: u,
|
|
478
484
|
sendEncodings: S
|
|
479
485
|
}),
|
|
480
486
|
number: t,
|
|
481
487
|
onAddedTransceiver: O,
|
|
482
488
|
ontrack: v
|
|
483
489
|
}));
|
|
484
|
-
let M = !1,
|
|
490
|
+
let M = !1, _;
|
|
485
491
|
const w = (a("subscribeEnterConference: onEnterConference", y), R ?? y ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
|
|
486
|
-
a("enterRoom", { _room: d, isSuccessProgressCall: M }),
|
|
492
|
+
a("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? R && R() : y && y({ isSuccessProgressCall: M });
|
|
487
493
|
}) : () => {
|
|
488
|
-
}), k = (d) => (a("onSuccess"), M = !0,
|
|
494
|
+
}), k = (d) => (a("onSuccess"), M = !0, A(), h && h({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
|
|
489
495
|
w(), b && b();
|
|
490
496
|
}), d), U = (d) => {
|
|
491
497
|
throw a("onFail"), E && E(), w(), d;
|
|
@@ -494,15 +500,15 @@ class Sn {
|
|
|
494
500
|
};
|
|
495
501
|
return a("onBeforeProgressCall"), p && p(t), N().then(k).catch((d) => U(d)).finally(V);
|
|
496
502
|
});
|
|
497
|
-
|
|
498
|
-
|
|
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) => {
|
|
499
505
|
const {
|
|
500
506
|
mediaStream: t,
|
|
501
507
|
extraHeaders: s,
|
|
502
508
|
iceServers: o,
|
|
503
509
|
contentHint: r,
|
|
504
510
|
simulcastEncodings: i,
|
|
505
|
-
degradationPreference:
|
|
511
|
+
degradationPreference: u,
|
|
506
512
|
sendEncodings: l,
|
|
507
513
|
offerToReceiveAudio: S,
|
|
508
514
|
offerToReceiveVideo: C,
|
|
@@ -518,11 +524,11 @@ class Sn {
|
|
|
518
524
|
onEndedCall: T
|
|
519
525
|
} = e, b = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
520
526
|
onReadyRemoteStreams: F
|
|
521
|
-
}),
|
|
527
|
+
}), A = this.resolveHandleReadyRemoteStreams({
|
|
522
528
|
onReadyRemoteStreams: b
|
|
523
529
|
}), v = P(
|
|
524
530
|
{
|
|
525
|
-
degradationPreference:
|
|
531
|
+
degradationPreference: u
|
|
526
532
|
},
|
|
527
533
|
{
|
|
528
534
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
@@ -545,16 +551,16 @@ class Sn {
|
|
|
545
551
|
sendEncodings: l
|
|
546
552
|
}),
|
|
547
553
|
onAddedTransceiver: v,
|
|
548
|
-
ontrack:
|
|
554
|
+
ontrack: A
|
|
549
555
|
}), N = () => {
|
|
550
556
|
const { remoteCallerData: d } = this.sipConnector;
|
|
551
557
|
return d.incomingNumber;
|
|
552
558
|
};
|
|
553
|
-
let M = !1,
|
|
559
|
+
let M = !1, _;
|
|
554
560
|
const w = (a("subscribeEnterConference: onEnterConference", R), h ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
|
|
555
|
-
a("enterRoom", { _room: d, isSuccessProgressCall: M }),
|
|
561
|
+
a("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? h && h() : R && R({ isSuccessProgressCall: M });
|
|
556
562
|
}) : () => {
|
|
557
|
-
}), k = (d) => (a("onSuccess"), M = !0, b(), p && p({ isPurgatory: D(
|
|
563
|
+
}), k = (d) => (a("onSuccess"), M = !0, b(), p && p({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
|
|
558
564
|
w(), T && T();
|
|
559
565
|
}), d), U = (d) => {
|
|
560
566
|
throw a("onFail"), y && y(), w(), d;
|
|
@@ -567,14 +573,14 @@ class Sn {
|
|
|
567
573
|
}
|
|
568
574
|
return O().then(k).catch((d) => U(d)).finally(V);
|
|
569
575
|
});
|
|
570
|
-
|
|
576
|
+
c(this, "updatePresentation", async ({
|
|
571
577
|
mediaStream: e,
|
|
572
578
|
isP2P: t,
|
|
573
579
|
maxBitrate: s,
|
|
574
580
|
contentHint: o,
|
|
575
581
|
simulcastEncodings: r,
|
|
576
582
|
degradationPreference: i,
|
|
577
|
-
sendEncodings:
|
|
583
|
+
sendEncodings: u,
|
|
578
584
|
preferredMimeTypesVideoCodecs: l,
|
|
579
585
|
excludeMimeTypesVideoCodecs: S
|
|
580
586
|
}) => {
|
|
@@ -594,19 +600,19 @@ class Sn {
|
|
|
594
600
|
sendEncodings: B({
|
|
595
601
|
mediaStream: e,
|
|
596
602
|
simulcastEncodings: r,
|
|
597
|
-
sendEncodings:
|
|
603
|
+
sendEncodings: u
|
|
598
604
|
}),
|
|
599
605
|
onAddedTransceiver: C
|
|
600
606
|
});
|
|
601
607
|
});
|
|
602
|
-
|
|
608
|
+
c(this, "startPresentation", async ({
|
|
603
609
|
mediaStream: e,
|
|
604
610
|
isP2P: t,
|
|
605
611
|
maxBitrate: s,
|
|
606
612
|
contentHint: o,
|
|
607
613
|
simulcastEncodings: r,
|
|
608
614
|
degradationPreference: i,
|
|
609
|
-
sendEncodings:
|
|
615
|
+
sendEncodings: u,
|
|
610
616
|
preferredMimeTypesVideoCodecs: l,
|
|
611
617
|
excludeMimeTypesVideoCodecs: S
|
|
612
618
|
}, C) => {
|
|
@@ -628,49 +634,49 @@ class Sn {
|
|
|
628
634
|
sendEncodings: B({
|
|
629
635
|
mediaStream: e,
|
|
630
636
|
simulcastEncodings: r,
|
|
631
|
-
sendEncodings:
|
|
637
|
+
sendEncodings: u
|
|
632
638
|
}),
|
|
633
639
|
onAddedTransceiver: f
|
|
634
640
|
},
|
|
635
641
|
C
|
|
636
642
|
);
|
|
637
643
|
});
|
|
638
|
-
|
|
644
|
+
c(this, "stopShareSipConnector", async ({ isP2P: e = !1 } = {}) => (a("stopShareSipConnector"), this.sipConnector.stopPresentation({
|
|
639
645
|
isP2P: e
|
|
640
646
|
}).catch((t) => {
|
|
641
647
|
a(t);
|
|
642
648
|
})));
|
|
643
|
-
|
|
649
|
+
c(this, "sendRefusalToTurnOnMic", async () => {
|
|
644
650
|
if (this.sipConnector.isCallActive)
|
|
645
651
|
return a("sendRefusalToTurnOnMic"), this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
|
|
646
652
|
a("sendRefusalToTurnOnMic: error", e);
|
|
647
653
|
});
|
|
648
654
|
});
|
|
649
|
-
|
|
655
|
+
c(this, "sendRefusalToTurnOnCam", async () => {
|
|
650
656
|
if (this.sipConnector.isCallActive)
|
|
651
657
|
return a("sendRefusalToTurnOnCam"), this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
|
|
652
658
|
a("sendRefusalToTurnOnCam: error", e);
|
|
653
659
|
});
|
|
654
660
|
});
|
|
655
|
-
|
|
661
|
+
c(this, "sendMediaState", async ({
|
|
656
662
|
isEnabledCam: e,
|
|
657
663
|
isEnabledMic: t
|
|
658
664
|
}) => {
|
|
659
665
|
if (this.sipConnector.isCallActive)
|
|
660
666
|
return a("sendMediaState"), this.sipConnector.sendMediaState({ cam: e, mic: t });
|
|
661
667
|
});
|
|
662
|
-
|
|
668
|
+
c(this, "replaceMediaStream", async (e, {
|
|
663
669
|
deleteExisting: t,
|
|
664
670
|
addMissing: s,
|
|
665
671
|
forceRenegotiation: o,
|
|
666
672
|
contentHint: r,
|
|
667
673
|
simulcastEncodings: i,
|
|
668
|
-
degradationPreference:
|
|
674
|
+
degradationPreference: u,
|
|
669
675
|
sendEncodings: l
|
|
670
676
|
} = {}) => {
|
|
671
677
|
const S = P(
|
|
672
678
|
{
|
|
673
|
-
degradationPreference:
|
|
679
|
+
degradationPreference: u
|
|
674
680
|
},
|
|
675
681
|
{
|
|
676
682
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
@@ -690,34 +696,34 @@ class Sn {
|
|
|
690
696
|
onAddedTransceiver: S
|
|
691
697
|
});
|
|
692
698
|
});
|
|
693
|
-
|
|
699
|
+
c(this, "askPermissionToEnableCam", async () => {
|
|
694
700
|
if (this.sipConnector.isCallActive)
|
|
695
701
|
return a("askPermissionToEnableCam"), this.sipConnector.askPermissionToEnableCam();
|
|
696
702
|
});
|
|
697
|
-
|
|
703
|
+
c(this, "resolveHandleReadyRemoteStreamsDebounced", ({
|
|
698
704
|
onReadyRemoteStreams: e
|
|
699
705
|
}) => fe(() => {
|
|
700
706
|
const t = this.sipConnector.getRemoteStreams();
|
|
701
707
|
a("remoteStreams", t), t && e(t);
|
|
702
708
|
}, 200));
|
|
703
|
-
|
|
709
|
+
c(this, "resolveHandleReadyRemoteStreams", ({
|
|
704
710
|
onReadyRemoteStreams: e
|
|
705
711
|
}) => ({ track: t }) => {
|
|
706
712
|
Ze(t) && e();
|
|
707
713
|
});
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
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)));
|
|
713
719
|
return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.sipConnector = e, new Proxy(this, {
|
|
714
720
|
get: (o, r, i) => {
|
|
715
721
|
if (typeof r == "string" && en.has(r) && r in this.sipConnector) {
|
|
716
722
|
const l = Reflect.get(this.sipConnector, r, this.sipConnector);
|
|
717
723
|
return typeof l == "function" ? l.bind(this.sipConnector) : l;
|
|
718
724
|
}
|
|
719
|
-
const
|
|
720
|
-
return typeof
|
|
725
|
+
const u = Reflect.get(o, r, i);
|
|
726
|
+
return typeof u == "function" ? u.bind(o) : u;
|
|
721
727
|
}
|
|
722
728
|
});
|
|
723
729
|
}
|
|
@@ -731,7 +737,7 @@ export {
|
|
|
731
737
|
Sn as SipConnectorFacade,
|
|
732
738
|
pn as causes,
|
|
733
739
|
yn as constants,
|
|
734
|
-
|
|
740
|
+
An as debug,
|
|
735
741
|
sn as default,
|
|
736
742
|
En as disableDebug,
|
|
737
743
|
Tn as enableDebug,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sip-connector",
|
|
3
|
-
"version": "13.
|
|
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": {
|