sip-connector 12.1.0 → 12.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { UA } from '@krivega/jssip';
2
2
  import { default as SipConnector } from '../SipConnector';
3
- import { EUseLicense, TContentHint, TSimulcastEncodings } from '../types';
3
+ import { EUseLicense, TContentHint, TSimulcastEncoding } from '../types';
4
4
  declare class SipConnectorFacade {
5
5
  private readonly sipConnector;
6
6
  private readonly preferredMimeTypesVideoCodecs?;
@@ -29,7 +29,7 @@ declare class SipConnectorFacade {
29
29
  extraHeaders?: string[] | undefined;
30
30
  iceServers?: RTCIceServer[];
31
31
  contentHint?: TContentHint;
32
- simulcastEncodings?: TSimulcastEncodings;
32
+ simulcastEncodings?: TSimulcastEncoding[];
33
33
  degradationPreference?: RTCDegradationPreference;
34
34
  sendEncodings?: RTCRtpEncodingParameters[];
35
35
  setRemoteStreams: (streams: MediaStream[]) => void;
@@ -53,7 +53,7 @@ declare class SipConnectorFacade {
53
53
  extraHeaders?: string[] | undefined;
54
54
  iceServers?: RTCIceServer[];
55
55
  contentHint?: TContentHint;
56
- simulcastEncodings?: TSimulcastEncodings;
56
+ simulcastEncodings?: TSimulcastEncoding[];
57
57
  degradationPreference?: RTCDegradationPreference;
58
58
  sendEncodings?: RTCRtpEncodingParameters[];
59
59
  setRemoteStreams: (streams: MediaStream[]) => void;
@@ -74,7 +74,7 @@ declare class SipConnectorFacade {
74
74
  isP2P: boolean;
75
75
  maxBitrate?: number;
76
76
  contentHint?: TContentHint;
77
- simulcastEncodings?: TSimulcastEncodings;
77
+ simulcastEncodings?: TSimulcastEncoding[];
78
78
  degradationPreference?: RTCDegradationPreference;
79
79
  sendEncodings?: RTCRtpEncodingParameters[];
80
80
  preferredMimeTypesVideoCodecs?: string[];
@@ -85,7 +85,7 @@ declare class SipConnectorFacade {
85
85
  isP2P: boolean;
86
86
  maxBitrate?: number;
87
87
  contentHint?: TContentHint;
88
- simulcastEncodings?: TSimulcastEncodings;
88
+ simulcastEncodings?: TSimulcastEncoding[];
89
89
  degradationPreference?: RTCDegradationPreference;
90
90
  sendEncodings?: RTCRtpEncodingParameters[];
91
91
  preferredMimeTypesVideoCodecs?: string[];
@@ -107,7 +107,7 @@ declare class SipConnectorFacade {
107
107
  addMissing?: boolean;
108
108
  forceRenegotiation?: boolean;
109
109
  contentHint?: TContentHint;
110
- simulcastEncodings?: TSimulcastEncodings;
110
+ simulcastEncodings?: TSimulcastEncoding[];
111
111
  degradationPreference?: RTCDegradationPreference;
112
112
  sendEncodings?: RTCRtpEncodingParameters[];
113
113
  }) => Promise<void>;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Q=Object.defineProperty;var J=(n,e,t)=>e in n?Q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var l=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./SipConnector-Ds1fhzNg.cjs"),Z=require("sequent-promises"),ee=require("stack-promises"),ne=require("@krivega/cancelable-promise"),te=require("repeated-calls"),re=require("ts-debounce"),se=require("debug"),L=n=>{const{url:e,cause:t}=n;let r=e;return(t===s.BAD_MEDIA_DESCRIPTION||t===s.NOT_FOUND)&&(r=`${n.message.to.uri.user}@${n.message.to.uri.host}`),r};var q=(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))(q||{});const oe=(n=new Error)=>{var o;const{cause:e,socket:t}=n;let r="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case s.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case s.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t&&((o=t==null?void 0:t._ws)==null?void 0:o.readyState)===3?r="WS_CONNECTION_FAILED":L(n)&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},ce=n=>{let e="";try{e=JSON.stringify(n)}catch(t){s.logger("failed to stringify message",t)}return e},ie=(n=new Error)=>{const{code:e,cause:t,message:r}=n,o=L(n),c={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?c.message=ce(r):r&&(c.message=String(r)),o&&(c.link=o),e&&(c.code=e),t&&(c.cause=t),c},ae=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:q,getLinkError:L,getTypeFromError:oe,getValuesFromError:ie},Symbol.toStringTag,{value:"Module"})),ue=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:r,isRegistered:o,isPresentationCall:c})=>{const i=[],a=t?"0":"1",u=r?"0":"1";return i.push(`X-Vinteo-Mic-State: ${a}`,`X-Vinteo-MainCam-State: ${u}`),o||i.push("X-Vinteo-Purgatory-Call: yes"),n&&i.push(`X-Vinteo-Session: ${n}`),c&&i.push("X-Vinteo-Presentation-Call: yes"),e&&i.push(`X-Vinteo-Remote: ${e}`),i},le="[@*!|]",de="_",ge=n=>{let e=n;return e=e.replaceAll(new RegExp(le,"g"),de),e},Se=({appName:n,appVersion:e,browserName:t,browserVersion:r})=>{const c=`${ge(n)} ${e}`;return`ChromeNew - ${t?`${t} ${r}, ${c}`:c}`},Ce=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:r,appName:o})=>n?Se({appVersion:e,browserName:t,browserVersion:r,appName:o}):"Chrome",H="purgatory",B=n=>n===H,me=n=>e=>[...e].map(r=>async()=>n(r)),fe=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const o=me(e)(n);return Z.sequentPromises(o,t)},he=n=>t=>(s.logger("onStartMainCam"),n.onSession("admin-start-main-cam",t)),Re=n=>t=>(s.logger("onStartMic"),n.onSession("admin-start-mic",t)),Ee=n=>t=>(s.logger("onStopMainCam"),n.onSession("admin-stop-main-cam",t)),pe=n=>t=>(s.logger("onStopMic"),n.onSession("admin-stop-mic",t)),ye=({sipConnector:n})=>{const e=(m,R)=>({isSyncForced:E=!1})=>{if(E){m();return}R()},t=he(n),r=Ee(n),o=Re(n),c=pe(n);let i=()=>{},a=()=>{},u=()=>{},g=()=>{};const C=({onStartMainCamForced:m,onStartMainCamNotForced:R,onStopMainCamForced:E,onStopMainCamNotForced:M,onStartMicForced:_,onStartMicNotForced:A,onStopMicForced:v,onStopMicNotForced:O})=>{const p=e(m,R);i=t(p);const y=e(E,M);a=r(y);const D=e(_,A);u=o(D);const b=e(v,O);g=c(b)},S=()=>{i(),a(),u(),g()};return{start:m=>{C(m)},stop:()=>{S()}}},Te=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:H,createSyncMediaState:ye,error:ae,getExtraHeaders:ue,getUserAgent:Ce,hasPurgatory:B,sendDTMFAccumulated:fe},Symbol.toStringTag,{value:"Module"})),Me=n=>[...n.keys()].map(e=>n.get(e)),be=(n,e)=>Me(n).find(t=>t.type===e),X=async n=>n.getStats().then(e=>{const t=be(e,"codec");return t==null?void 0:t.mimeType}),_e=n=>n.find(e=>{var t;return((t=e==null?void 0:e.track)==null?void 0:t.kind)==="video"}),j=(n,e)=>n!==void 0&&e!==void 0&&n.toLowerCase().includes(e.toLowerCase()),Ae=1e6,f=n=>n*Ae,W=f(.06),ve=f(4),Oe=n=>n<=64?W:n<=128?f(.12):n<=256?f(.25):n<=384?f(.32):n<=426?f(.38):n<=640?f(.5):n<=848?f(.7):n<=1280?f(1):n<=1920?f(2):ve,Ne="av1",Pe=n=>j(n,Ne),Be=.6,G=(n,e)=>Pe(e)?n*Be:n,De=n=>G(W,n),K=(n,e)=>{const t=Oe(n);return G(t,e)},Ie=1,Y=({videoTrack:n,targetSize:e,codec:t})=>{const r=n.getSettings(),o=r.width,c=r.height,i=o/e.width,a=c/e.height,u=Math.max(i,a,Ie),g=K(e.width,t);return{scaleResolutionDownBy:u,maxBitrate:g}},z=ee.createStackPromises(),we=async()=>z().catch(n=>{s.logger("videoSendingBalancer: error",n)}),Fe=async n=>(z.add(n),we()),V=async({sender:n,scaleResolutionDownBy:e,maxBitrate:t,onSetParameters:r})=>Fe(async()=>s.setEncodingsToSender(n,{scaleResolutionDownBy:e,maxBitrate:t},r)),ke=async({sender:n,codec:e},t)=>{const o=De(e);return V({sender:n,maxBitrate:o,onSetParameters:t,scaleResolutionDownBy:200})},k=async({sender:n,videoTrack:e,codec:t},r)=>{const i=e.getSettings().width,a=K(i,t);return V({sender:n,maxBitrate:a,onSetParameters:r,scaleResolutionDownBy:1})},Ue=async({sender:n,videoTrack:e,resolution:t,codec:r},o)=>{const[c,i]=t.split("x"),{maxBitrate:a,scaleResolutionDownBy:u}=Y({videoTrack:e,codec:r,targetSize:{width:Number(c),height:Number(i)}});return V({sender:n,maxBitrate:a,onSetParameters:o,scaleResolutionDownBy:u})},Le=async({mainCam:n,resolutionMainCam:e,sender:t,videoTrack:r,codec:o},c)=>{switch(n){case s.EEventsMainCAM.PAUSE_MAIN_CAM:return ke({sender:t,codec:o},c);case s.EEventsMainCAM.RESUME_MAIN_CAM:return k({sender:t,videoTrack:r,codec:o},c);case s.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return e!==void 0?Ue({sender:t,videoTrack:r,codec:o,resolution:e},c):k({sender:t,videoTrack:r,codec:o},c);default:return k({sender:t,videoTrack:r,codec:o},c)}},x={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},$=async({mainCam:n,resolutionMainCam:e,connection:t,onSetParameters:r,ignoreForCodec:o})=>{const c=t.getSenders(),i=_e(c);if(!(i!=null&&i.track))return x;const a=await X(i);return j(a,o)?x:Le({mainCam:n,resolutionMainCam:e,sender:i,codec:a,videoTrack:i.track},r)},Ve=(n,{ignoreForCodec:e,onSetParameters:t}={})=>{const r=async()=>{const{connection:u}=n;if(!u)throw new Error("connection is not exist");return $({connection:u,onSetParameters:t,ignoreForCodec:e})};let o=r;const c=async u=>(o=async()=>{const{mainCam:g,resolutionMainCam:C}=u,{connection:S}=n;if(!S)throw new Error("connection is not exist");return $({mainCam:g,resolutionMainCam:C,connection:S,onSetParameters:t,ignoreForCodec:e})},o());return{subscribe:()=>{n.onSession("main-cam-control",c)},unsubscribe:()=>{n.offSession("main-cam-control",c)},balanceByTrack:r,resetMainCamControl(){o=r},async reBalance(){return o()}}},xe=n=>n.getVideoTracks()[0],N=({mediaStream:n,simulcastEncodings:e,sendEncodings:t})=>{if(e&&e.length>0){const r=t??[],o=xe(n);return e.forEach((c,i)=>{const a=r[i]??{},{maxBitrate:u,scaleResolutionDownBy:g}=Y({videoTrack:o,targetSize:{width:c.width,height:c.height}});a.maxBitrate=u,a.scaleResolutionDownBy=g,r[i]=a}),r}return t},$e=(n,e)=>[...n,...e].filter((o,c,i)=>c===i.findIndex(a=>a.clockRate===o.clockRate&&a.mimeType===o.mimeType&&a.channels===o.channels&&a.sdpFmtpLine===o.sdpFmtpLine)),qe=n=>{const e=RTCRtpSender.getCapabilities(n),t=RTCRtpReceiver.getCapabilities(n),r=e===null?[]:e.codecs,o=t===null?[]:t.codecs;return $e(r,o)},He=(n,e)=>e===void 0||e.length===0?n:n.sort((t,r)=>{const o=e.indexOf(t.mimeType),c=e.indexOf(r.mimeType),i=o===-1?Number.MAX_VALUE:o,a=c===-1?Number.MAX_VALUE:c;return i-a}),Xe=(n,e)=>e===void 0||e.length===0?n:n.filter(t=>!e.includes(t.mimeType)),P=(n,{preferredMimeTypesVideoCodecs:e,excludeMimeTypesVideoCodecs:t})=>async r=>{var o;if(typeof r.setCodecPreferences=="function"&&((o=r.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)){const c=qe("video"),i=Xe(c,t),a=He(i,e);r.setCodecPreferences(a)}Object.keys(n).length>0&&await s.setParametersToSender(r.sender,n)},U=n=>{if(!ne.isCanceledError(n)&&!te.hasCanceledError(n))throw n;return{isSuccessful:!1}},je=({kind:n,readyState:e})=>n==="video"&&e==="live";class We{constructor(e,{preferredMimeTypesVideoCodecs:t,excludeMimeTypesVideoCodecs:r}={}){l(this,"sipConnector");l(this,"preferredMimeTypesVideoCodecs");l(this,"excludeMimeTypesVideoCodecs");l(this,"connectToServer",async e=>{const{userAgent:t,sipWebSocketServerURL:r,sipServerUrl:o,remoteAddress:c,displayName:i,name:a,password:u,isRegisteredUser:g,isDisconnectOnFail:C}=e;return s.logger("connectToServer",e),this.sipConnector.connect({userAgent:t,sipWebSocketServerURL:r,sipServerUrl:o,remoteAddress:c,displayName:i,password:u,user:a,register:g}).then(S=>(s.logger("connectToServer then"),{ua:S,isSuccessful:!0})).catch(async S=>(s.logger("connectToServer catch: error",S),C===!0?this.sipConnector.disconnect().then(()=>U(S)).catch(()=>U(S)):U(S)))});l(this,"callToServer",async e=>{const{conference:t,mediaStream:r,extraHeaders:o,iceServers:c,contentHint:i,simulcastEncodings:a,degradationPreference:u,sendEncodings:g,setRemoteStreams:C,onBeforeProgressCall:S,onSuccessProgressCall:T,onEnterPurgatory:h,onEnterConference:m,onFailProgressCall:R,onFinishProgressCall:E,onEndedCall:M}=e,_=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:C}),A=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:_}),v=P({degradationPreference:u},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});s.logger("callToServer",e);const O=async()=>(s.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:o,iceServers:c,contentHint:i,sendEncodings:N({mediaStream:r,simulcastEncodings:a,sendEncodings:g}),number:t,onAddedTransceiver:v,ontrack:A}));let p=!1,y;const b=(s.logger("subscribeEnterConference: onEnterConference",m),h??m?this.sipConnector.onSession("enterRoom",({room:d})=>{s.logger("enterRoom",{_room:d,isSuccessProgressCall:p}),y=d,B(y)?h&&h():m&&m({isSuccessProgressCall:p})}):()=>{}),I=d=>(s.logger("onSuccess"),p=!0,_(),T&&T({isPurgatory:B(y)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{b(),M&&M()}),d),w=d=>{throw s.logger("onFail"),R&&R(),b(),d},F=()=>{s.logger("onFinish"),E&&E()};return s.logger("onBeforeProgressCall"),S&&S(t),O().then(I).catch(d=>w(d)).finally(F)});l(this,"disconnectFromServer",async()=>this.sipConnector.disconnect().then(()=>(s.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(s.logger("disconnectFromServer: catch",e),{isSuccessful:!1})));l(this,"answerIncomingCall",async e=>{const{mediaStream:t,extraHeaders:r,iceServers:o,contentHint:c,simulcastEncodings:i,degradationPreference:a,sendEncodings:u,setRemoteStreams:g,onBeforeProgressCall:C,onSuccessProgressCall:S,onEnterPurgatory:T,onEnterConference:h,onFailProgressCall:m,onFinishProgressCall:R,onEndedCall:E}=e,M=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:g}),_=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:M}),A=P({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});s.logger("answerIncomingCall",e);const v=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:r,iceServers:o,contentHint:c,sendEncodings:N({mediaStream:t,simulcastEncodings:i,sendEncodings:u}),onAddedTransceiver:A,ontrack:_}),O=()=>{const{remoteCallerData:d}=this.sipConnector;return d.incomingNumber};let p=!1,y;const b=(s.logger("subscribeEnterConference: onEnterConference",h),T??h?this.sipConnector.onSession("enterRoom",d=>{s.logger("enterRoom",{_room:d,isSuccessProgressCall:p}),y=d,B(y)?T&&T():h&&h({isSuccessProgressCall:p})}):()=>{}),I=d=>(s.logger("onSuccess"),p=!0,M(),S&&S({isPurgatory:B(y)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{b(),E&&E()}),d),w=d=>{throw s.logger("onFail"),m&&m(),b(),d},F=()=>{s.logger("onFinish"),R&&R()};if(s.logger("onBeforeProgressCall"),C){const d=O();C(d)}return v().then(I).catch(d=>w(d)).finally(F)});l(this,"updatePresentation",async({mediaStream:e,isP2P:t,maxBitrate:r,contentHint:o,simulcastEncodings:c,degradationPreference:i,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g})=>{const C=P({degradationPreference:i},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return s.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,maxBitrate:r,contentHint:o,sendEncodings:N({mediaStream:e,simulcastEncodings:c,sendEncodings:a}),onAddedTransceiver:C})});l(this,"startPresentation",async({mediaStream:e,isP2P:t,maxBitrate:r,contentHint:o,simulcastEncodings:c,degradationPreference:i,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g},C)=>{const S=P({degradationPreference:i},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return s.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,maxBitrate:r,contentHint:o,sendEncodings:N({mediaStream:e,simulcastEncodings:c,sendEncodings:a}),onAddedTransceiver:S},C)});l(this,"stopShareSipConnector",async({isP2P:e=!1}={})=>(s.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{s.logger(t)})));l(this,"sendRefusalToTurnOnMic",async()=>{if(this.sipConnector.isCallActive)return s.logger("sendRefusalToTurnOnMic"),this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{s.logger("sendRefusalToTurnOnMic: error",e)})});l(this,"sendRefusalToTurnOnCam",async()=>{if(this.sipConnector.isCallActive)return s.logger("sendRefusalToTurnOnCam"),this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{s.logger("sendRefusalToTurnOnCam: error",e)})});l(this,"sendMediaState",async({isEnabledCam:e,isEnabledMic:t})=>{if(this.sipConnector.isCallActive)return s.logger("sendMediaState"),this.sipConnector.sendMediaState({cam:e,mic:t})});l(this,"replaceMediaStream",async(e,{deleteExisting:t,addMissing:r,forceRenegotiation:o,contentHint:c,simulcastEncodings:i,degradationPreference:a,sendEncodings:u}={})=>{const g=P({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});return s.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:r,forceRenegotiation:o,contentHint:c,sendEncodings:N({mediaStream:e,simulcastEncodings:i,sendEncodings:u}),onAddedTransceiver:g})});l(this,"askPermissionToEnableCam",async()=>{if(this.sipConnector.isCallActive)return s.logger("askPermissionToEnableCam"),this.sipConnector.askPermissionToEnableCam()});l(this,"resolveHandleReadyRemoteStreamsDebounced",({onReadyRemoteStreams:e})=>re.debounce(()=>{const t=this.sipConnector.getRemoteStreams();s.logger("remoteStreams",t),t&&e(t)},200));l(this,"resolveHandleReadyRemoteStreams",({onReadyRemoteStreams:e})=>({track:t})=>{je(t)&&e()});l(this,"getRemoteStreams",()=>(s.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams()));l(this,"onUseLicense",e=>(s.logger("onUseLicense"),this.sipConnector.onSession("useLicense",e)));l(this,"onMustStopPresentation",e=>(s.logger("onMustStopPresentation"),this.sipConnector.onSession("mustStopPresentation",e)));l(this,"onMoveToSpectators",e=>(s.logger("onMoveToSpectators"),this.sipConnector.onSession(s.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS,e)));l(this,"onMoveToParticipants",e=>(s.logger("onMoveToParticipants"),this.sipConnector.onSession(s.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS,e)));this.sipConnector=e,this.preferredMimeTypesVideoCodecs=t,this.excludeMimeTypesVideoCodecs=r}}exports.EEventsMainCAM=s.EEventsMainCAM;exports.EEventsMic=s.EEventsMic;exports.EEventsSyncMediaState=s.EEventsSyncMediaState;exports.EMimeTypesVideoCodecs=s.EMimeTypesVideoCodecs;exports.EUseLicense=s.EUseLicense;exports.causes=s.causes;exports.constants=s.constants;exports.default=s.SipConnector;exports.disableDebug=s.disableDebug;exports.enableDebug=s.enableDebug;exports.eventNames=s.eventNames;exports.hasCanceledCallError=s.hasCanceledCallError;exports.setParametersToSender=s.setParametersToSender;exports.debug=se;exports.SipConnectorFacade=We;exports.getCodecFromSender=X;exports.resolveVideoSendingBalancer=Ve;exports.tools=Te;
1
+ "use strict";var Q=Object.defineProperty;var J=(n,e,t)=>e in n?Q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var l=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./SipConnector-Ds1fhzNg.cjs"),Z=require("sequent-promises"),ee=require("stack-promises"),ne=require("@krivega/cancelable-promise"),te=require("repeated-calls"),re=require("ts-debounce"),se=require("debug"),L=n=>{const{url:e,cause:t}=n;let r=e;return(t===s.BAD_MEDIA_DESCRIPTION||t===s.NOT_FOUND)&&(r=`${n.message.to.uri.user}@${n.message.to.uri.host}`),r};var q=(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))(q||{});const oe=(n=new Error)=>{var o;const{cause:e,socket:t}=n;let r="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case s.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case s.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t&&((o=t==null?void 0:t._ws)==null?void 0:o.readyState)===3?r="WS_CONNECTION_FAILED":L(n)&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},ce=n=>{let e="";try{e=JSON.stringify(n)}catch(t){s.logger("failed to stringify message",t)}return e},ie=(n=new Error)=>{const{code:e,cause:t,message:r}=n,o=L(n),c={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?c.message=ce(r):r&&(c.message=String(r)),o&&(c.link=o),e&&(c.code=e),t&&(c.cause=t),c},ae=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:q,getLinkError:L,getTypeFromError:oe,getValuesFromError:ie},Symbol.toStringTag,{value:"Module"})),ue=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:r,isRegistered:o,isPresentationCall:c})=>{const i=[],a=t?"0":"1",u=r?"0":"1";return i.push(`X-Vinteo-Mic-State: ${a}`,`X-Vinteo-MainCam-State: ${u}`),o||i.push("X-Vinteo-Purgatory-Call: yes"),n&&i.push(`X-Vinteo-Session: ${n}`),c&&i.push("X-Vinteo-Presentation-Call: yes"),e&&i.push(`X-Vinteo-Remote: ${e}`),i},le="[@*!|]",de="_",ge=n=>{let e=n;return e=e.replaceAll(new RegExp(le,"g"),de),e},Se=({appName:n,appVersion:e,browserName:t,browserVersion:r})=>{const c=`${ge(n)} ${e}`;return`ChromeNew - ${t?`${t} ${r}, ${c}`:c}`},Ce=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:r,appName:o})=>n?Se({appVersion:e,browserName:t,browserVersion:r,appName:o}):"Chrome",H="purgatory",B=n=>n===H,me=n=>e=>[...e].map(r=>async()=>n(r)),fe=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const o=me(e)(n);return Z.sequentPromises(o,t)},he=n=>t=>(s.logger("onStartMainCam"),n.onSession("admin-start-main-cam",t)),Re=n=>t=>(s.logger("onStartMic"),n.onSession("admin-start-mic",t)),Ee=n=>t=>(s.logger("onStopMainCam"),n.onSession("admin-stop-main-cam",t)),pe=n=>t=>(s.logger("onStopMic"),n.onSession("admin-stop-mic",t)),ye=({sipConnector:n})=>{const e=(m,R)=>({isSyncForced:E=!1})=>{if(E){m();return}R()},t=he(n),r=Ee(n),o=Re(n),c=pe(n);let i=()=>{},a=()=>{},u=()=>{},g=()=>{};const C=({onStartMainCamForced:m,onStartMainCamNotForced:R,onStopMainCamForced:E,onStopMainCamNotForced:M,onStartMicForced:_,onStartMicNotForced:A,onStopMicForced:v,onStopMicNotForced:O})=>{const p=e(m,R);i=t(p);const y=e(E,M);a=r(y);const D=e(_,A);u=o(D);const b=e(v,O);g=c(b)},S=()=>{i(),a(),u(),g()};return{start:m=>{C(m)},stop:()=>{S()}}},Te=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:H,createSyncMediaState:ye,error:ae,getExtraHeaders:ue,getUserAgent:Ce,hasPurgatory:B,sendDTMFAccumulated:fe},Symbol.toStringTag,{value:"Module"})),Me=n=>[...n.keys()].map(e=>n.get(e)),be=(n,e)=>Me(n).find(t=>t.type===e),X=async n=>n.getStats().then(e=>{const t=be(e,"codec");return t==null?void 0:t.mimeType}),_e=n=>n.find(e=>{var t;return((t=e==null?void 0:e.track)==null?void 0:t.kind)==="video"}),j=(n,e)=>n!==void 0&&e!==void 0&&n.toLowerCase().includes(e.toLowerCase()),Ae=1e6,f=n=>n*Ae,W=f(.06),ve=f(4),Oe=n=>n<=64?W:n<=128?f(.12):n<=256?f(.25):n<=384?f(.32):n<=426?f(.38):n<=640?f(.5):n<=848?f(.7):n<=1280?f(1):n<=1920?f(2):ve,Ne="av1",Pe=n=>j(n,Ne),Be=.6,G=(n,e)=>Pe(e)?n*Be:n,De=n=>G(W,n),K=(n,e)=>{const t=Oe(n);return G(t,e)},Ie=1,Y=({videoTrack:n,targetSize:e,codec:t})=>{const r=n.getSettings(),o=r.width,c=r.height,i=o/e.width,a=c/e.height,u=Math.max(i,a,Ie),g=K(e.width,t);return{scaleResolutionDownBy:u,maxBitrate:g}},z=ee.createStackPromises(),we=async()=>z().catch(n=>{s.logger("videoSendingBalancer: error",n)}),Fe=async n=>(z.add(n),we()),V=async({sender:n,scaleResolutionDownBy:e,maxBitrate:t,onSetParameters:r})=>Fe(async()=>s.setEncodingsToSender(n,{scaleResolutionDownBy:e,maxBitrate:t},r)),ke=async({sender:n,codec:e},t)=>{const o=De(e);return V({sender:n,maxBitrate:o,onSetParameters:t,scaleResolutionDownBy:200})},k=async({sender:n,videoTrack:e,codec:t},r)=>{const i=e.getSettings().width,a=K(i,t);return V({sender:n,maxBitrate:a,onSetParameters:r,scaleResolutionDownBy:1})},Ue=async({sender:n,videoTrack:e,resolution:t,codec:r},o)=>{const[c,i]=t.split("x"),{maxBitrate:a,scaleResolutionDownBy:u}=Y({videoTrack:e,codec:r,targetSize:{width:Number(c),height:Number(i)}});return V({sender:n,maxBitrate:a,onSetParameters:o,scaleResolutionDownBy:u})},Le=async({mainCam:n,resolutionMainCam:e,sender:t,videoTrack:r,codec:o},c)=>{switch(n){case s.EEventsMainCAM.PAUSE_MAIN_CAM:return ke({sender:t,codec:o},c);case s.EEventsMainCAM.RESUME_MAIN_CAM:return k({sender:t,videoTrack:r,codec:o},c);case s.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return e!==void 0?Ue({sender:t,videoTrack:r,codec:o,resolution:e},c):k({sender:t,videoTrack:r,codec:o},c);default:return k({sender:t,videoTrack:r,codec:o},c)}},x={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},$=async({mainCam:n,resolutionMainCam:e,connection:t,onSetParameters:r,ignoreForCodec:o})=>{const c=t.getSenders(),i=_e(c);if(!(i!=null&&i.track))return x;const a=await X(i);return j(a,o)?x:Le({mainCam:n,resolutionMainCam:e,sender:i,codec:a,videoTrack:i.track},r)},Ve=(n,{ignoreForCodec:e,onSetParameters:t}={})=>{const r=async()=>{const{connection:u}=n;if(!u)throw new Error("connection is not exist");return $({connection:u,onSetParameters:t,ignoreForCodec:e})};let o=r;const c=async u=>(o=async()=>{const{mainCam:g,resolutionMainCam:C}=u,{connection:S}=n;if(!S)throw new Error("connection is not exist");return $({mainCam:g,resolutionMainCam:C,connection:S,onSetParameters:t,ignoreForCodec:e})},o());return{subscribe:()=>{n.onSession("main-cam-control",c)},unsubscribe:()=>{n.offSession("main-cam-control",c)},balanceByTrack:r,resetMainCamControl(){o=r},async reBalance(){return o()}}},xe=n=>n.getVideoTracks()[0],N=({mediaStream:n,simulcastEncodings:e,sendEncodings:t})=>{if(e&&e.length>0){const r=t??[],o=xe(n);return e.forEach((c,i)=>{const a=r[i]??{};a.active=!0,c.rid!==void 0&&(a.rid=c.rid),c.scalabilityMode!==void 0&&(a.scalabilityMode=c.scalabilityMode);const{maxBitrate:u,scaleResolutionDownBy:g}=Y({videoTrack:o,targetSize:{width:c.width,height:c.height}});a.maxBitrate=u,a.scaleResolutionDownBy=g,r[i]=a}),r}return t},$e=(n,e)=>[...n,...e].filter((o,c,i)=>c===i.findIndex(a=>a.clockRate===o.clockRate&&a.mimeType===o.mimeType&&a.channels===o.channels&&a.sdpFmtpLine===o.sdpFmtpLine)),qe=n=>{const e=RTCRtpSender.getCapabilities(n),t=RTCRtpReceiver.getCapabilities(n),r=e===null?[]:e.codecs,o=t===null?[]:t.codecs;return $e(r,o)},He=(n,e)=>e===void 0||e.length===0?n:n.sort((t,r)=>{const o=e.indexOf(t.mimeType),c=e.indexOf(r.mimeType),i=o===-1?Number.MAX_VALUE:o,a=c===-1?Number.MAX_VALUE:c;return i-a}),Xe=(n,e)=>e===void 0||e.length===0?n:n.filter(t=>!e.includes(t.mimeType)),P=(n,{preferredMimeTypesVideoCodecs:e,excludeMimeTypesVideoCodecs:t})=>async r=>{var o;if(typeof r.setCodecPreferences=="function"&&((o=r.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)){const c=qe("video"),i=Xe(c,t),a=He(i,e);r.setCodecPreferences(a)}Object.keys(n).length>0&&await s.setParametersToSender(r.sender,n)},U=n=>{if(!ne.isCanceledError(n)&&!te.hasCanceledError(n))throw n;return{isSuccessful:!1}},je=({kind:n,readyState:e})=>n==="video"&&e==="live";class We{constructor(e,{preferredMimeTypesVideoCodecs:t,excludeMimeTypesVideoCodecs:r}={}){l(this,"sipConnector");l(this,"preferredMimeTypesVideoCodecs");l(this,"excludeMimeTypesVideoCodecs");l(this,"connectToServer",async e=>{const{userAgent:t,sipWebSocketServerURL:r,sipServerUrl:o,remoteAddress:c,displayName:i,name:a,password:u,isRegisteredUser:g,isDisconnectOnFail:C}=e;return s.logger("connectToServer",e),this.sipConnector.connect({userAgent:t,sipWebSocketServerURL:r,sipServerUrl:o,remoteAddress:c,displayName:i,password:u,user:a,register:g}).then(S=>(s.logger("connectToServer then"),{ua:S,isSuccessful:!0})).catch(async S=>(s.logger("connectToServer catch: error",S),C===!0?this.sipConnector.disconnect().then(()=>U(S)).catch(()=>U(S)):U(S)))});l(this,"callToServer",async e=>{const{conference:t,mediaStream:r,extraHeaders:o,iceServers:c,contentHint:i,simulcastEncodings:a,degradationPreference:u,sendEncodings:g,setRemoteStreams:C,onBeforeProgressCall:S,onSuccessProgressCall:T,onEnterPurgatory:h,onEnterConference:m,onFailProgressCall:R,onFinishProgressCall:E,onEndedCall:M}=e,_=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:C}),A=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:_}),v=P({degradationPreference:u},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});s.logger("callToServer",e);const O=async()=>(s.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:o,iceServers:c,contentHint:i,sendEncodings:N({mediaStream:r,simulcastEncodings:a,sendEncodings:g}),number:t,onAddedTransceiver:v,ontrack:A}));let p=!1,y;const b=(s.logger("subscribeEnterConference: onEnterConference",m),h??m?this.sipConnector.onSession("enterRoom",({room:d})=>{s.logger("enterRoom",{_room:d,isSuccessProgressCall:p}),y=d,B(y)?h&&h():m&&m({isSuccessProgressCall:p})}):()=>{}),I=d=>(s.logger("onSuccess"),p=!0,_(),T&&T({isPurgatory:B(y)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{b(),M&&M()}),d),w=d=>{throw s.logger("onFail"),R&&R(),b(),d},F=()=>{s.logger("onFinish"),E&&E()};return s.logger("onBeforeProgressCall"),S&&S(t),O().then(I).catch(d=>w(d)).finally(F)});l(this,"disconnectFromServer",async()=>this.sipConnector.disconnect().then(()=>(s.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(s.logger("disconnectFromServer: catch",e),{isSuccessful:!1})));l(this,"answerIncomingCall",async e=>{const{mediaStream:t,extraHeaders:r,iceServers:o,contentHint:c,simulcastEncodings:i,degradationPreference:a,sendEncodings:u,setRemoteStreams:g,onBeforeProgressCall:C,onSuccessProgressCall:S,onEnterPurgatory:T,onEnterConference:h,onFailProgressCall:m,onFinishProgressCall:R,onEndedCall:E}=e,M=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:g}),_=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:M}),A=P({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});s.logger("answerIncomingCall",e);const v=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:r,iceServers:o,contentHint:c,sendEncodings:N({mediaStream:t,simulcastEncodings:i,sendEncodings:u}),onAddedTransceiver:A,ontrack:_}),O=()=>{const{remoteCallerData:d}=this.sipConnector;return d.incomingNumber};let p=!1,y;const b=(s.logger("subscribeEnterConference: onEnterConference",h),T??h?this.sipConnector.onSession("enterRoom",d=>{s.logger("enterRoom",{_room:d,isSuccessProgressCall:p}),y=d,B(y)?T&&T():h&&h({isSuccessProgressCall:p})}):()=>{}),I=d=>(s.logger("onSuccess"),p=!0,M(),S&&S({isPurgatory:B(y)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{b(),E&&E()}),d),w=d=>{throw s.logger("onFail"),m&&m(),b(),d},F=()=>{s.logger("onFinish"),R&&R()};if(s.logger("onBeforeProgressCall"),C){const d=O();C(d)}return v().then(I).catch(d=>w(d)).finally(F)});l(this,"updatePresentation",async({mediaStream:e,isP2P:t,maxBitrate:r,contentHint:o,simulcastEncodings:c,degradationPreference:i,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g})=>{const C=P({degradationPreference:i},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return s.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,maxBitrate:r,contentHint:o,sendEncodings:N({mediaStream:e,simulcastEncodings:c,sendEncodings:a}),onAddedTransceiver:C})});l(this,"startPresentation",async({mediaStream:e,isP2P:t,maxBitrate:r,contentHint:o,simulcastEncodings:c,degradationPreference:i,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g},C)=>{const S=P({degradationPreference:i},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return s.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,maxBitrate:r,contentHint:o,sendEncodings:N({mediaStream:e,simulcastEncodings:c,sendEncodings:a}),onAddedTransceiver:S},C)});l(this,"stopShareSipConnector",async({isP2P:e=!1}={})=>(s.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{s.logger(t)})));l(this,"sendRefusalToTurnOnMic",async()=>{if(this.sipConnector.isCallActive)return s.logger("sendRefusalToTurnOnMic"),this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{s.logger("sendRefusalToTurnOnMic: error",e)})});l(this,"sendRefusalToTurnOnCam",async()=>{if(this.sipConnector.isCallActive)return s.logger("sendRefusalToTurnOnCam"),this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{s.logger("sendRefusalToTurnOnCam: error",e)})});l(this,"sendMediaState",async({isEnabledCam:e,isEnabledMic:t})=>{if(this.sipConnector.isCallActive)return s.logger("sendMediaState"),this.sipConnector.sendMediaState({cam:e,mic:t})});l(this,"replaceMediaStream",async(e,{deleteExisting:t,addMissing:r,forceRenegotiation:o,contentHint:c,simulcastEncodings:i,degradationPreference:a,sendEncodings:u}={})=>{const g=P({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});return s.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:r,forceRenegotiation:o,contentHint:c,sendEncodings:N({mediaStream:e,simulcastEncodings:i,sendEncodings:u}),onAddedTransceiver:g})});l(this,"askPermissionToEnableCam",async()=>{if(this.sipConnector.isCallActive)return s.logger("askPermissionToEnableCam"),this.sipConnector.askPermissionToEnableCam()});l(this,"resolveHandleReadyRemoteStreamsDebounced",({onReadyRemoteStreams:e})=>re.debounce(()=>{const t=this.sipConnector.getRemoteStreams();s.logger("remoteStreams",t),t&&e(t)},200));l(this,"resolveHandleReadyRemoteStreams",({onReadyRemoteStreams:e})=>({track:t})=>{je(t)&&e()});l(this,"getRemoteStreams",()=>(s.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams()));l(this,"onUseLicense",e=>(s.logger("onUseLicense"),this.sipConnector.onSession("useLicense",e)));l(this,"onMustStopPresentation",e=>(s.logger("onMustStopPresentation"),this.sipConnector.onSession("mustStopPresentation",e)));l(this,"onMoveToSpectators",e=>(s.logger("onMoveToSpectators"),this.sipConnector.onSession(s.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS,e)));l(this,"onMoveToParticipants",e=>(s.logger("onMoveToParticipants"),this.sipConnector.onSession(s.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS,e)));this.sipConnector=e,this.preferredMimeTypesVideoCodecs=t,this.excludeMimeTypesVideoCodecs=r}}exports.EEventsMainCAM=s.EEventsMainCAM;exports.EEventsMic=s.EEventsMic;exports.EEventsSyncMediaState=s.EEventsSyncMediaState;exports.EMimeTypesVideoCodecs=s.EMimeTypesVideoCodecs;exports.EUseLicense=s.EUseLicense;exports.causes=s.causes;exports.constants=s.constants;exports.default=s.SipConnector;exports.disableDebug=s.disableDebug;exports.enableDebug=s.enableDebug;exports.eventNames=s.eventNames;exports.hasCanceledCallError=s.hasCanceledCallError;exports.setParametersToSender=s.setParametersToSender;exports.debug=se;exports.SipConnectorFacade=We;exports.getCodecFromSender=X;exports.resolveVideoSendingBalancer=Ve;exports.tools=Te;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var Z = Object.defineProperty;
2
2
  var ee = (n, e, t) => e in n ? Z(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var l = (n, e, t) => ee(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { B as X, N as j, l as i, E as k, s as ne, a as te, P as se, b as re, S as Je } from "./SipConnector-BxDInUHC.js";
4
+ import { B as X, N as j, l as a, E as k, s as ne, a as te, P as se, b as re, S as Je } from "./SipConnector-BxDInUHC.js";
5
5
  import { i as ln, j as dn, m as Sn, k as mn, c as Cn, d as fn, f as hn, g as Rn, e as gn, h as pn } from "./SipConnector-BxDInUHC.js";
6
6
  import { sequentPromises as oe } from "sequent-promises";
7
7
  import { createStackPromises as ce } from "stack-promises";
@@ -41,7 +41,7 @@ const le = (n = new Error()) => {
41
41
  try {
42
42
  e = JSON.stringify(n);
43
43
  } catch (t) {
44
- i("failed to stringify message", t);
44
+ a("failed to stringify message", t);
45
45
  }
46
46
  return e;
47
47
  }, Se = (n = new Error()) => {
@@ -61,8 +61,8 @@ const le = (n = new Error()) => {
61
61
  isRegistered: r,
62
62
  isPresentationCall: o
63
63
  }) => {
64
- const c = [], a = t ? "0" : "1", u = s ? "0" : "1";
65
- return c.push(`X-Vinteo-Mic-State: ${a}`, `X-Vinteo-MainCam-State: ${u}`), r || c.push("X-Vinteo-Purgatory-Call: yes"), n && c.push(`X-Vinteo-Session: ${n}`), o && c.push("X-Vinteo-Presentation-Call: yes"), e && c.push(`X-Vinteo-Remote: ${e}`), c;
64
+ const c = [], i = t ? "0" : "1", u = s ? "0" : "1";
65
+ return c.push(`X-Vinteo-Mic-State: ${i}`, `X-Vinteo-MainCam-State: ${u}`), r || c.push("X-Vinteo-Purgatory-Call: yes"), n && c.push(`X-Vinteo-Session: ${n}`), o && c.push("X-Vinteo-Presentation-Call: yes"), e && c.push(`X-Vinteo-Remote: ${e}`), c;
66
66
  }, fe = "[@*!|]", he = "_", Re = (n) => {
67
67
  let e = n;
68
68
  return e = e.replaceAll(new RegExp(fe, "g"), he), e;
@@ -87,7 +87,7 @@ const le = (n = new Error()) => {
87
87
  }) => {
88
88
  const r = ye(e)(n);
89
89
  return oe(r, t);
90
- }, Te = (n) => (t) => (i("onStartMainCam"), n.onSession("admin-start-main-cam", t)), be = (n) => (t) => (i("onStartMic"), n.onSession("admin-start-mic", t)), Me = (n) => (t) => (i("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), _e = (n) => (t) => (i("onStopMic"), n.onSession("admin-stop-mic", t)), Ae = ({ sipConnector: n }) => {
90
+ }, Te = (n) => (t) => (a("onStartMainCam"), n.onSession("admin-start-main-cam", t)), be = (n) => (t) => (a("onStartMic"), n.onSession("admin-start-mic", t)), Me = (n) => (t) => (a("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), _e = (n) => (t) => (a("onStopMic"), n.onSession("admin-stop-mic", t)), Ae = ({ sipConnector: n }) => {
91
91
  const e = (f, g) => ({ isSyncForced: p = !1 }) => {
92
92
  if (p) {
93
93
  f();
@@ -96,7 +96,7 @@ const le = (n = new Error()) => {
96
96
  g();
97
97
  }, t = Te(n), s = Me(n), r = be(n), o = _e(n);
98
98
  let c = () => {
99
- }, a = () => {
99
+ }, i = () => {
100
100
  }, u = () => {
101
101
  }, S = () => {
102
102
  };
@@ -107,8 +107,8 @@ const le = (n = new Error()) => {
107
107
  onStopMainCamNotForced: b,
108
108
  onStartMicForced: _,
109
109
  onStartMicNotForced: A,
110
- onStopMicForced: O,
111
- onStopMicNotForced: v
110
+ onStopMicForced: v,
111
+ onStopMicNotForced: O
112
112
  }) => {
113
113
  const y = e(
114
114
  f,
@@ -119,13 +119,13 @@ const le = (n = new Error()) => {
119
119
  p,
120
120
  b
121
121
  );
122
- a = s(E);
122
+ i = s(E);
123
123
  const w = e(_, A);
124
124
  u = r(w);
125
- const M = e(O, v);
125
+ const M = e(v, O);
126
126
  S = o(M);
127
127
  }, m = () => {
128
- c(), a(), u(), S();
128
+ c(), i(), u(), S();
129
129
  };
130
130
  return {
131
131
  start: (f) => {
@@ -144,8 +144,8 @@ const le = (n = new Error()) => {
144
144
  getUserAgent: pe,
145
145
  hasPurgatory: P,
146
146
  sendDTMFAccumulated: Ee
147
- }, Symbol.toStringTag, { value: "Module" })), Oe = (n) => [...n.keys()].map((e) => n.get(e)), ve = (n, e) => Oe(n).find((t) => t.type === e), Ne = async (n) => n.getStats().then((e) => {
148
- const t = ve(e, "codec");
147
+ }, Symbol.toStringTag, { value: "Module" })), ve = (n) => [...n.keys()].map((e) => n.get(e)), Oe = (n, e) => ve(n).find((t) => t.type === e), Ne = async (n) => n.getStats().then((e) => {
148
+ const t = Oe(e, "codec");
149
149
  return t == null ? void 0 : t.mimeType;
150
150
  }), Be = (n) => n.find((e) => {
151
151
  var t;
@@ -158,10 +158,10 @@ const le = (n = new Error()) => {
158
158
  targetSize: e,
159
159
  codec: t
160
160
  }) => {
161
- const s = n.getSettings(), r = s.width, o = s.height, c = r / e.width, a = o / e.height, u = Math.max(c, a, Le), S = z(e.width, t);
161
+ const s = n.getSettings(), r = s.width, o = s.height, c = r / e.width, i = o / e.height, u = Math.max(c, i, Le), S = z(e.width, t);
162
162
  return { scaleResolutionDownBy: u, maxBitrate: S };
163
163
  }, J = ce(), xe = async () => J().catch((n) => {
164
- i("videoSendingBalancer: error", n);
164
+ a("videoSendingBalancer: error", n);
165
165
  }), Ve = async (n) => (J.add(n), xe()), V = async ({
166
166
  sender: n,
167
167
  scaleResolutionDownBy: e,
@@ -180,10 +180,10 @@ const le = (n = new Error()) => {
180
180
  videoTrack: e,
181
181
  codec: t
182
182
  }, s) => {
183
- const c = e.getSettings().width, a = z(c, t);
183
+ const c = e.getSettings().width, i = z(c, t);
184
184
  return V({
185
185
  sender: n,
186
- maxBitrate: a,
186
+ maxBitrate: i,
187
187
  onSetParameters: s,
188
188
  scaleResolutionDownBy: 1
189
189
  });
@@ -193,7 +193,7 @@ const le = (n = new Error()) => {
193
193
  resolution: t,
194
194
  codec: s
195
195
  }, r) => {
196
- const [o, c] = t.split("x"), { maxBitrate: a, scaleResolutionDownBy: u } = Q({
196
+ const [o, c] = t.split("x"), { maxBitrate: i, scaleResolutionDownBy: u } = Q({
197
197
  videoTrack: e,
198
198
  codec: s,
199
199
  targetSize: {
@@ -203,7 +203,7 @@ const le = (n = new Error()) => {
203
203
  });
204
204
  return V({
205
205
  sender: n,
206
- maxBitrate: a,
206
+ maxBitrate: i,
207
207
  onSetParameters: r,
208
208
  scaleResolutionDownBy: u
209
209
  });
@@ -246,13 +246,13 @@ const le = (n = new Error()) => {
246
246
  const o = t.getSenders(), c = Be(o);
247
247
  if (!(c != null && c.track))
248
248
  return $;
249
- const a = await Ne(c);
250
- return K(a, r) ? $ : Xe(
249
+ const i = await Ne(c);
250
+ return K(i, r) ? $ : Xe(
251
251
  {
252
252
  mainCam: n,
253
253
  resolutionMainCam: e,
254
254
  sender: c,
255
- codec: a,
255
+ codec: i,
256
256
  videoTrack: c.track
257
257
  },
258
258
  s
@@ -307,31 +307,33 @@ const le = (n = new Error()) => {
307
307
  if (e && e.length > 0) {
308
308
  const s = t ?? [], r = je(n);
309
309
  return e.forEach((o, c) => {
310
- const a = s[c] ?? {}, { maxBitrate: u, scaleResolutionDownBy: S } = Q({
310
+ const i = s[c] ?? {};
311
+ i.active = !0, o.rid !== void 0 && (i.rid = o.rid), o.scalabilityMode !== void 0 && (i.scalabilityMode = o.scalabilityMode);
312
+ const { maxBitrate: u, scaleResolutionDownBy: S } = Q({
311
313
  videoTrack: r,
312
314
  targetSize: {
313
315
  width: o.width,
314
316
  height: o.height
315
317
  }
316
318
  });
317
- a.maxBitrate = u, a.scaleResolutionDownBy = S, s[c] = a;
319
+ i.maxBitrate = u, i.scaleResolutionDownBy = S, s[c] = i;
318
320
  }), s;
319
321
  }
320
322
  return t;
321
- }, We = (n, e) => [...n, ...e].filter((r, o, c) => o === c.findIndex((a) => a.clockRate === r.clockRate && a.mimeType === r.mimeType && a.channels === r.channels && a.sdpFmtpLine === r.sdpFmtpLine)), Ge = (n) => {
323
+ }, We = (n, e) => [...n, ...e].filter((r, o, c) => o === c.findIndex((i) => i.clockRate === r.clockRate && i.mimeType === r.mimeType && i.channels === r.channels && i.sdpFmtpLine === r.sdpFmtpLine)), Ge = (n) => {
322
324
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, r = t === null ? [] : t.codecs;
323
325
  return We(s, r);
324
326
  }, Ke = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
325
- const r = e.indexOf(t.mimeType), o = e.indexOf(s.mimeType), c = r === -1 ? Number.MAX_VALUE : r, a = o === -1 ? Number.MAX_VALUE : o;
326
- return c - a;
327
+ const r = e.indexOf(t.mimeType), o = e.indexOf(s.mimeType), c = r === -1 ? Number.MAX_VALUE : r, i = o === -1 ? Number.MAX_VALUE : o;
328
+ return c - i;
327
329
  }), qe = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), B = (n, {
328
330
  preferredMimeTypesVideoCodecs: e,
329
331
  excludeMimeTypesVideoCodecs: t
330
332
  }) => async (s) => {
331
333
  var r;
332
334
  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)) {
333
- const o = Ge("video"), c = qe(o, t), a = Ke(c, e);
334
- s.setCodecPreferences(a);
335
+ const o = Ge("video"), c = qe(o, t), i = Ke(c, e);
336
+ s.setCodecPreferences(i);
335
337
  }
336
338
  Object.keys(n).length > 0 && await te(s.sender, n);
337
339
  }, L = (n) => {
@@ -354,21 +356,21 @@ class cn {
354
356
  sipServerUrl: r,
355
357
  remoteAddress: o,
356
358
  displayName: c,
357
- name: a,
359
+ name: i,
358
360
  password: u,
359
361
  isRegisteredUser: S,
360
362
  isDisconnectOnFail: C
361
363
  } = e;
362
- return i("connectToServer", e), this.sipConnector.connect({
364
+ return a("connectToServer", e), this.sipConnector.connect({
363
365
  userAgent: t,
364
366
  sipWebSocketServerURL: s,
365
367
  sipServerUrl: r,
366
368
  remoteAddress: o,
367
369
  displayName: c,
368
370
  password: u,
369
- user: a,
371
+ user: i,
370
372
  register: S
371
- }).then((m) => (i("connectToServer then"), { ua: m, isSuccessful: !0 })).catch(async (m) => (i("connectToServer catch: error", m), C === !0 ? this.sipConnector.disconnect().then(() => L(m)).catch(() => L(m)) : L(m)));
373
+ }).then((m) => (a("connectToServer then"), { ua: m, isSuccessful: !0 })).catch(async (m) => (a("connectToServer catch: error", m), C === !0 ? this.sipConnector.disconnect().then(() => L(m)).catch(() => L(m)) : L(m)));
372
374
  });
373
375
  l(this, "callToServer", async (e) => {
374
376
  const {
@@ -377,7 +379,7 @@ class cn {
377
379
  extraHeaders: r,
378
380
  iceServers: o,
379
381
  contentHint: c,
380
- simulcastEncodings: a,
382
+ simulcastEncodings: i,
381
383
  degradationPreference: u,
382
384
  sendEncodings: S,
383
385
  setRemoteStreams: C,
@@ -392,7 +394,7 @@ class cn {
392
394
  onReadyRemoteStreams: C
393
395
  }), A = this.resolveHandleReadyRemoteStreams({
394
396
  onReadyRemoteStreams: _
395
- }), O = B(
397
+ }), v = B(
396
398
  {
397
399
  degradationPreference: u
398
400
  },
@@ -401,35 +403,35 @@ class cn {
401
403
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
402
404
  }
403
405
  );
404
- i("callToServer", e);
405
- const v = async () => (i("startCall"), this.sipConnector.call({
406
+ a("callToServer", e);
407
+ const O = async () => (a("startCall"), this.sipConnector.call({
406
408
  mediaStream: s,
407
409
  extraHeaders: r,
408
410
  iceServers: o,
409
411
  contentHint: c,
410
412
  sendEncodings: N({
411
413
  mediaStream: s,
412
- simulcastEncodings: a,
414
+ simulcastEncodings: i,
413
415
  sendEncodings: S
414
416
  }),
415
417
  number: t,
416
- onAddedTransceiver: O,
418
+ onAddedTransceiver: v,
417
419
  ontrack: A
418
420
  }));
419
421
  let y = !1, E;
420
- const M = (i("subscribeEnterConference: onEnterConference", f), R ?? f ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
421
- i("enterRoom", { _room: d, isSuccessProgressCall: y }), E = d, P(E) ? R && R() : f && f({ isSuccessProgressCall: y });
422
+ const M = (a("subscribeEnterConference: onEnterConference", f), R ?? f ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
423
+ a("enterRoom", { _room: d, isSuccessProgressCall: y }), E = d, P(E) ? R && R() : f && f({ isSuccessProgressCall: y });
422
424
  }) : () => {
423
- }), D = (d) => (i("onSuccess"), y = !0, _(), T && T({ isPurgatory: P(E) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
425
+ }), D = (d) => (a("onSuccess"), y = !0, _(), T && T({ isPurgatory: P(E) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
424
426
  M(), b && b();
425
427
  }), d), I = (d) => {
426
- throw i("onFail"), g && g(), M(), d;
428
+ throw a("onFail"), g && g(), M(), d;
427
429
  }, F = () => {
428
- i("onFinish"), p && p();
430
+ a("onFinish"), p && p();
429
431
  };
430
- return i("onBeforeProgressCall"), m && m(t), v().then(D).catch((d) => I(d)).finally(F);
432
+ return a("onBeforeProgressCall"), m && m(t), O().then(D).catch((d) => I(d)).finally(F);
431
433
  });
432
- l(this, "disconnectFromServer", async () => this.sipConnector.disconnect().then(() => (i("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (i("disconnectFromServer: catch", e), { isSuccessful: !1 })));
434
+ l(this, "disconnectFromServer", async () => this.sipConnector.disconnect().then(() => (a("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (a("disconnectFromServer: catch", e), { isSuccessful: !1 })));
433
435
  l(this, "answerIncomingCall", async (e) => {
434
436
  const {
435
437
  mediaStream: t,
@@ -437,7 +439,7 @@ class cn {
437
439
  iceServers: r,
438
440
  contentHint: o,
439
441
  simulcastEncodings: c,
440
- degradationPreference: a,
442
+ degradationPreference: i,
441
443
  sendEncodings: u,
442
444
  setRemoteStreams: S,
443
445
  onBeforeProgressCall: C,
@@ -453,15 +455,15 @@ class cn {
453
455
  onReadyRemoteStreams: b
454
456
  }), A = B(
455
457
  {
456
- degradationPreference: a
458
+ degradationPreference: i
457
459
  },
458
460
  {
459
461
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
460
462
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
461
463
  }
462
464
  );
463
- i("answerIncomingCall", e);
464
- const O = async () => this.sipConnector.answerToIncomingCall({
465
+ a("answerIncomingCall", e);
466
+ const v = async () => this.sipConnector.answerToIncomingCall({
465
467
  mediaStream: t,
466
468
  extraHeaders: s,
467
469
  iceServers: r,
@@ -473,26 +475,26 @@ class cn {
473
475
  }),
474
476
  onAddedTransceiver: A,
475
477
  ontrack: _
476
- }), v = () => {
478
+ }), O = () => {
477
479
  const { remoteCallerData: d } = this.sipConnector;
478
480
  return d.incomingNumber;
479
481
  };
480
482
  let y = !1, E;
481
- const M = (i("subscribeEnterConference: onEnterConference", R), T ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
482
- i("enterRoom", { _room: d, isSuccessProgressCall: y }), E = d, P(E) ? T && T() : R && R({ isSuccessProgressCall: y });
483
+ const M = (a("subscribeEnterConference: onEnterConference", R), T ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
484
+ a("enterRoom", { _room: d, isSuccessProgressCall: y }), E = d, P(E) ? T && T() : R && R({ isSuccessProgressCall: y });
483
485
  }) : () => {
484
- }), D = (d) => (i("onSuccess"), y = !0, b(), m && m({ isPurgatory: P(E) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
486
+ }), D = (d) => (a("onSuccess"), y = !0, b(), m && m({ isPurgatory: P(E) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
485
487
  M(), p && p();
486
488
  }), d), I = (d) => {
487
- throw i("onFail"), f && f(), M(), d;
489
+ throw a("onFail"), f && f(), M(), d;
488
490
  }, F = () => {
489
- i("onFinish"), g && g();
491
+ a("onFinish"), g && g();
490
492
  };
491
- if (i("onBeforeProgressCall"), C) {
492
- const d = v();
493
+ if (a("onBeforeProgressCall"), C) {
494
+ const d = O();
493
495
  C(d);
494
496
  }
495
- return O().then(D).catch((d) => I(d)).finally(F);
497
+ return v().then(D).catch((d) => I(d)).finally(F);
496
498
  });
497
499
  l(this, "updatePresentation", async ({
498
500
  mediaStream: e,
@@ -501,7 +503,7 @@ class cn {
501
503
  contentHint: r,
502
504
  simulcastEncodings: o,
503
505
  degradationPreference: c,
504
- sendEncodings: a,
506
+ sendEncodings: i,
505
507
  preferredMimeTypesVideoCodecs: u,
506
508
  excludeMimeTypesVideoCodecs: S
507
509
  }) => {
@@ -514,14 +516,14 @@ class cn {
514
516
  excludeMimeTypesVideoCodecs: S
515
517
  }
516
518
  );
517
- return i("updatePresentation"), this.sipConnector.updatePresentation(e, {
519
+ return a("updatePresentation"), this.sipConnector.updatePresentation(e, {
518
520
  isP2P: t,
519
521
  maxBitrate: s,
520
522
  contentHint: r,
521
523
  sendEncodings: N({
522
524
  mediaStream: e,
523
525
  simulcastEncodings: o,
524
- sendEncodings: a
526
+ sendEncodings: i
525
527
  }),
526
528
  onAddedTransceiver: C
527
529
  });
@@ -533,7 +535,7 @@ class cn {
533
535
  contentHint: r,
534
536
  simulcastEncodings: o,
535
537
  degradationPreference: c,
536
- sendEncodings: a,
538
+ sendEncodings: i,
537
539
  preferredMimeTypesVideoCodecs: u,
538
540
  excludeMimeTypesVideoCodecs: S
539
541
  }, C) => {
@@ -546,7 +548,7 @@ class cn {
546
548
  excludeMimeTypesVideoCodecs: S
547
549
  }
548
550
  );
549
- return i("startPresentation"), this.sipConnector.startPresentation(
551
+ return a("startPresentation"), this.sipConnector.startPresentation(
550
552
  e,
551
553
  {
552
554
  isP2P: t,
@@ -555,28 +557,28 @@ class cn {
555
557
  sendEncodings: N({
556
558
  mediaStream: e,
557
559
  simulcastEncodings: o,
558
- sendEncodings: a
560
+ sendEncodings: i
559
561
  }),
560
562
  onAddedTransceiver: m
561
563
  },
562
564
  C
563
565
  );
564
566
  });
565
- l(this, "stopShareSipConnector", async ({ isP2P: e = !1 } = {}) => (i("stopShareSipConnector"), this.sipConnector.stopPresentation({
567
+ l(this, "stopShareSipConnector", async ({ isP2P: e = !1 } = {}) => (a("stopShareSipConnector"), this.sipConnector.stopPresentation({
566
568
  isP2P: e
567
569
  }).catch((t) => {
568
- i(t);
570
+ a(t);
569
571
  })));
570
572
  l(this, "sendRefusalToTurnOnMic", async () => {
571
573
  if (this.sipConnector.isCallActive)
572
- return i("sendRefusalToTurnOnMic"), this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
573
- i("sendRefusalToTurnOnMic: error", e);
574
+ return a("sendRefusalToTurnOnMic"), this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
575
+ a("sendRefusalToTurnOnMic: error", e);
574
576
  });
575
577
  });
576
578
  l(this, "sendRefusalToTurnOnCam", async () => {
577
579
  if (this.sipConnector.isCallActive)
578
- return i("sendRefusalToTurnOnCam"), this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
579
- i("sendRefusalToTurnOnCam: error", e);
580
+ return a("sendRefusalToTurnOnCam"), this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
581
+ a("sendRefusalToTurnOnCam: error", e);
580
582
  });
581
583
  });
582
584
  l(this, "sendMediaState", async ({
@@ -584,7 +586,7 @@ class cn {
584
586
  isEnabledMic: t
585
587
  }) => {
586
588
  if (this.sipConnector.isCallActive)
587
- return i("sendMediaState"), this.sipConnector.sendMediaState({ cam: e, mic: t });
589
+ return a("sendMediaState"), this.sipConnector.sendMediaState({ cam: e, mic: t });
588
590
  });
589
591
  l(this, "replaceMediaStream", async (e, {
590
592
  deleteExisting: t,
@@ -592,19 +594,19 @@ class cn {
592
594
  forceRenegotiation: r,
593
595
  contentHint: o,
594
596
  simulcastEncodings: c,
595
- degradationPreference: a,
597
+ degradationPreference: i,
596
598
  sendEncodings: u
597
599
  } = {}) => {
598
600
  const S = B(
599
601
  {
600
- degradationPreference: a
602
+ degradationPreference: i
601
603
  },
602
604
  {
603
605
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
604
606
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
605
607
  }
606
608
  );
607
- return i("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
609
+ return a("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
608
610
  deleteExisting: t,
609
611
  addMissing: s,
610
612
  forceRenegotiation: r,
@@ -619,24 +621,24 @@ class cn {
619
621
  });
620
622
  l(this, "askPermissionToEnableCam", async () => {
621
623
  if (this.sipConnector.isCallActive)
622
- return i("askPermissionToEnableCam"), this.sipConnector.askPermissionToEnableCam();
624
+ return a("askPermissionToEnableCam"), this.sipConnector.askPermissionToEnableCam();
623
625
  });
624
626
  l(this, "resolveHandleReadyRemoteStreamsDebounced", ({
625
627
  onReadyRemoteStreams: e
626
628
  }) => ue(() => {
627
629
  const t = this.sipConnector.getRemoteStreams();
628
- i("remoteStreams", t), t && e(t);
630
+ a("remoteStreams", t), t && e(t);
629
631
  }, 200));
630
632
  l(this, "resolveHandleReadyRemoteStreams", ({
631
633
  onReadyRemoteStreams: e
632
634
  }) => ({ track: t }) => {
633
635
  Ye(t) && e();
634
636
  });
635
- l(this, "getRemoteStreams", () => (i("getRemoteStreams"), this.sipConnector.getRemoteStreams()));
636
- l(this, "onUseLicense", (e) => (i("onUseLicense"), this.sipConnector.onSession("useLicense", e)));
637
- l(this, "onMustStopPresentation", (e) => (i("onMustStopPresentation"), this.sipConnector.onSession("mustStopPresentation", e)));
638
- l(this, "onMoveToSpectators", (e) => (i("onMoveToSpectators"), this.sipConnector.onSession(se, e)));
639
- l(this, "onMoveToParticipants", (e) => (i("onMoveToParticipants"), this.sipConnector.onSession(re, e)));
637
+ l(this, "getRemoteStreams", () => (a("getRemoteStreams"), this.sipConnector.getRemoteStreams()));
638
+ l(this, "onUseLicense", (e) => (a("onUseLicense"), this.sipConnector.onSession("useLicense", e)));
639
+ l(this, "onMustStopPresentation", (e) => (a("onMustStopPresentation"), this.sipConnector.onSession("mustStopPresentation", e)));
640
+ l(this, "onMoveToSpectators", (e) => (a("onMoveToSpectators"), this.sipConnector.onSession(se, e)));
641
+ l(this, "onMoveToParticipants", (e) => (a("onMoveToParticipants"), this.sipConnector.onSession(re, e)));
640
642
  this.sipConnector = e, this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s;
641
643
  }
642
644
  }
@@ -1,7 +1,7 @@
1
- import { TSimulcastEncodings } from '../types';
1
+ import { TSimulcastEncoding } from '../types';
2
2
  declare const generateSimulcastEncodings: ({ mediaStream, simulcastEncodings, sendEncodings, }: {
3
3
  mediaStream: MediaStream;
4
- simulcastEncodings?: TSimulcastEncodings;
4
+ simulcastEncodings?: TSimulcastEncoding[];
5
5
  sendEncodings?: RTCRtpEncodingParameters[];
6
6
  }) => RTCRtpEncodingParameters[] | undefined;
7
7
  export default generateSimulcastEncodings;
package/dist/types.d.ts CHANGED
@@ -53,7 +53,10 @@ export type TSize = {
53
53
  width: number;
54
54
  height: number;
55
55
  };
56
- export type TSimulcastEncodings = TSize[];
56
+ export type TSimulcastEncoding = TSize & {
57
+ rid?: string;
58
+ scalabilityMode?: string;
59
+ };
57
60
  export declare enum EMimeTypesVideoCodecs {
58
61
  VP8 = "video/VP8",
59
62
  VP9 = "video/VP9",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-connector",
3
- "version": "12.1.0",
3
+ "version": "12.2.0",
4
4
  "description": "Module for connect to Vinteo server",
5
5
  "keywords": [
6
6
  "webrtc",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@krivega/cancelable-promise": "^1.1.3",
66
- "@krivega/jssip": "^5.0.3",
66
+ "@krivega/jssip": "^5.0.4",
67
67
  "debug": "^4.3.7",
68
68
  "events-constructor": "^1.3.0",
69
69
  "repeated-calls": "^2.3.0",
@@ -74,9 +74,9 @@
74
74
  },
75
75
  "devDependencies": {
76
76
  "@babel/preset-typescript": "^7.26.0",
77
- "@commitlint/cli": "^19.5.0",
78
- "@commitlint/config-conventional": "^19.5.0",
79
- "@nabla/vite-plugin-eslint": "^2.0.4",
77
+ "@commitlint/cli": "^19.6.0",
78
+ "@commitlint/config-conventional": "^19.6.0",
79
+ "@nabla/vite-plugin-eslint": "^2.0.5",
80
80
  "@types/debug": "^4.1.12",
81
81
  "@types/dom-mediacapture-transform": "^0.1.10",
82
82
  "@types/jest": "^29.5.14",
@@ -92,26 +92,26 @@
92
92
  "eslint-plugin-import": "^2.31.0",
93
93
  "eslint-plugin-jest": "^28.9.0",
94
94
  "eslint-plugin-prettier": "^5.2.1",
95
- "eslint-plugin-unicorn": "^56.0.0",
96
- "husky": "^9.1.6",
95
+ "eslint-plugin-unicorn": "^56.0.1",
96
+ "husky": "^9.1.7",
97
97
  "jest": "^29.7.0",
98
98
  "jest-environment-jsdom": "^29.7.0",
99
99
  "jest-extended": "^4.0.2",
100
100
  "jest-junit": "^16.0.0",
101
101
  "lint-staged": "^15.2.10",
102
- "prettier": "^3.3.3",
102
+ "prettier": "^3.4.1",
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
- "typescript": "^5.6.3",
108
- "vite": "^5.4.11",
107
+ "typescript": "^5.7.2",
108
+ "vite": "^6.0.1",
109
109
  "vite-plugin-dts": "^4.3.0",
110
- "vite-tsconfig-paths": "^5.1.2"
110
+ "vite-tsconfig-paths": "^5.1.3"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "@krivega/cancelable-promise": "^1.1.3",
114
- "@krivega/jssip": "^5.0.3",
114
+ "@krivega/jssip": "^5.0.4",
115
115
  "debug": "^4.3.7",
116
116
  "events-constructor": "^1.3.0",
117
117
  "repeated-calls": "^2.2.1",