@vonage/media-processor 1.0.0 → 1.0.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.
@@ -1209,7 +1209,7 @@ class EmptyOptional extends Optional {
1209
1209
  return null;
1210
1210
  }
1211
1211
  }
1212
- const version = "1.0.0";
1212
+ const version = "1.0.1";
1213
1213
  let _metadata;
1214
1214
  function setMetadata(metadata) {
1215
1215
  _metadata = metadata;
@@ -1,2 +1,2 @@
1
1
  (function(w,A){typeof exports=="object"&&typeof module!="undefined"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(w=typeof globalThis!="undefined"?globalThis:w||self,A(w["media-processor"]={}))})(this,function(w){"use strict";function A(){return new Promise((t,e)=>{typeof MediaStreamTrackProcessor=="undefined"||typeof MediaStreamTrackGenerator=="undefined"?e("Your browser does not support the MediaStreamTrack API for Insertable Streams of Media."):t()})}class P{}P.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},P.errors={transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer"};var q={exports:{}},te=function(e,r){return function(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];return e.apply(r,n)}},Ae=te,S=Object.prototype.toString;function J(t){return Array.isArray(t)}function W(t){return typeof t=="undefined"}function Me(t){return t!==null&&!W(t)&&t.constructor!==null&&!W(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function ne(t){return S.call(t)==="[object ArrayBuffer]"}function $e(t){return S.call(t)==="[object FormData]"}function Ue(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&ne(t.buffer),e}function ke(t){return typeof t=="string"}function De(t){return typeof t=="number"}function se(t){return t!==null&&typeof t=="object"}function $(t){if(S.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Le(t){return S.call(t)==="[object Date]"}function He(t){return S.call(t)==="[object File]"}function Be(t){return S.call(t)==="[object Blob]"}function ie(t){return S.call(t)==="[object Function]"}function Fe(t){return se(t)&&ie(t.pipe)}function Ie(t){return S.call(t)==="[object URLSearchParams]"}function je(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function qe(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function V(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),J(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}function z(){var t={};function e(n,i){$(t[i])&&$(n)?t[i]=z(t[i],n):$(n)?t[i]=z({},n):J(n)?t[i]=n.slice():t[i]=n}for(var r=0,s=arguments.length;r<s;r++)V(arguments[r],e);return t}function Je(t,e,r){return V(e,function(n,i){r&&typeof n=="function"?t[i]=Ae(n,r):t[i]=n}),t}function We(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var p={isArray:J,isArrayBuffer:ne,isBuffer:Me,isFormData:$e,isArrayBufferView:Ue,isString:ke,isNumber:De,isObject:se,isPlainObject:$,isUndefined:W,isDate:Le,isFile:He,isBlob:Be,isFunction:ie,isStream:Fe,isURLSearchParams:Ie,isStandardBrowserEnv:qe,forEach:V,merge:z,extend:Je,trim:je,stripBOM:We},N=p;function ae(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var oe=function(e,r,s){if(!r)return e;var n;if(s)n=s(r);else if(N.isURLSearchParams(r))n=r.toString();else{var i=[];N.forEach(r,function(l,y){l===null||typeof l=="undefined"||(N.isArray(l)?y=y+"[]":l=[l],N.forEach(l,function(d){N.isDate(d)?d=d.toISOString():N.isObject(d)&&(d=JSON.stringify(d)),i.push(ae(y)+"="+ae(d))}))}),n=i.join("&")}if(n){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+n}return e},Ve=p;function U(){this.handlers=[]}U.prototype.use=function(e,r,s){return this.handlers.push({fulfilled:e,rejected:r,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1},U.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},U.prototype.forEach=function(e){Ve.forEach(this.handlers,function(s){s!==null&&e(s)})};var ze=U,Qe=p,Ge=function(e,r){Qe.forEach(e,function(n,i){i!==r&&i.toUpperCase()===r.toUpperCase()&&(e[r]=n,delete e[i])})},ue=function(e,r,s,n,i){return e.config=r,s&&(e.code=s),e.request=n,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e},Xe=ue,le=function(e,r,s,n,i){var o=new Error(e);return Xe(o,r,s,n,i)},Ke=le,Ye=function(e,r,s){var n=s.config.validateStatus;!s.status||!n||n(s.status)?e(s):r(Ke("Request failed with status code "+s.status,s.config,null,s.request,s))},k=p,Ze=k.isStandardBrowserEnv()?function(){return{write:function(r,s,n,i,o,u){var l=[];l.push(r+"="+encodeURIComponent(s)),k.isNumber(n)&&l.push("expires="+new Date(n).toGMTString()),k.isString(i)&&l.push("path="+i),k.isString(o)&&l.push("domain="+o),u===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(r){var s=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return s?decodeURIComponent(s[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),er=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},rr=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},tr=er,nr=rr,sr=function(e,r){return e&&!tr(r)?nr(e,r):r},Q=p,ir=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],ar=function(e){var r={},s,n,i;return e&&Q.forEach(e.split(`
2
- `),function(u){if(i=u.indexOf(":"),s=Q.trim(u.substr(0,i)).toLowerCase(),n=Q.trim(u.substr(i+1)),s){if(r[s]&&ir.indexOf(s)>=0)return;s==="set-cookie"?r[s]=(r[s]?r[s]:[]).concat([n]):r[s]=r[s]?r[s]+", "+n:n}}),r},fe=p,or=fe.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),s;function n(i){var o=i;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return s=n(window.location.href),function(o){var u=fe.isString(o)?n(o):o;return u.protocol===s.protocol&&u.host===s.host}}():function(){return function(){return!0}}();function G(t){this.message=t}G.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},G.prototype.__CANCEL__=!0;var D=G,L=p,ur=Ye,lr=Ze,fr=oe,dr=sr,cr=ar,hr=or,X=le,pr=B,mr=D,de=function(e){return new Promise(function(s,n){var i=e.data,o=e.headers,u=e.responseType,l;function y(){e.cancelToken&&e.cancelToken.unsubscribe(l),e.signal&&e.signal.removeEventListener("abort",l)}L.isFormData(i)&&delete o["Content-Type"];var a=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",E=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(d+":"+E)}var m=dr(e.baseURL,e.url);a.open(e.method.toUpperCase(),fr(m,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function Oe(){if(!!a){var _="getAllResponseHeaders"in a?cr(a.getAllResponseHeaders()):null,x=!u||u==="text"||u==="json"?a.responseText:a.response,R={data:x,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};ur(function(re){s(re),y()},function(re){n(re),y()},R),a=null}}if("onloadend"in a?a.onloadend=Oe:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(Oe)},a.onabort=function(){!a||(n(X("Request aborted",e,"ECONNABORTED",a)),a=null)},a.onerror=function(){n(X("Network Error",e,null,a)),a=null},a.ontimeout=function(){var x=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",R=e.transitional||pr.transitional;e.timeoutErrorMessage&&(x=e.timeoutErrorMessage),n(X(x,e,R.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",a)),a=null},L.isStandardBrowserEnv()){var xe=(e.withCredentials||hr(m))&&e.xsrfCookieName?lr.read(e.xsrfCookieName):void 0;xe&&(o[e.xsrfHeaderName]=xe)}"setRequestHeader"in a&&L.forEach(o,function(x,R){typeof i=="undefined"&&R.toLowerCase()==="content-type"?delete o[R]:a.setRequestHeader(R,x)}),L.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),u&&u!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(l=function(_){!a||(n(!_||_&&_.type?new mr("canceled"):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(l),e.signal&&(e.signal.aborted?l():e.signal.addEventListener("abort",l))),i||(i=null),a.send(i)})},c=p,ce=Ge,vr=ue,yr={"Content-Type":"application/x-www-form-urlencoded"};function he(t,e){!c.isUndefined(t)&&c.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function _r(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=de),t}function wr(t,e,r){if(c.isString(t))try{return(e||JSON.parse)(t),c.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(r||JSON.stringify)(t)}var H={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:_r(),transformRequest:[function(e,r){return ce(r,"Accept"),ce(r,"Content-Type"),c.isFormData(e)||c.isArrayBuffer(e)||c.isBuffer(e)||c.isStream(e)||c.isFile(e)||c.isBlob(e)?e:c.isArrayBufferView(e)?e.buffer:c.isURLSearchParams(e)?(he(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):c.isObject(e)||r&&r["Content-Type"]==="application/json"?(he(r,"application/json"),wr(e)):e}],transformResponse:[function(e){var r=this.transitional||H.transitional,s=r&&r.silentJSONParsing,n=r&&r.forcedJSONParsing,i=!s&&this.responseType==="json";if(i||n&&c.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?vr(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};c.forEach(["delete","get","head"],function(e){H.headers[e]={}}),c.forEach(["post","put","patch"],function(e){H.headers[e]=c.merge(yr)});var B=H,br=p,Tr=B,gr=function(e,r,s){var n=this||Tr;return br.forEach(s,function(o){e=o.call(n,e,r)}),e},pe=function(e){return!!(e&&e.__CANCEL__)},me=p,K=gr,Er=pe,Sr=B,Pr=D;function Y(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Pr("canceled")}var Rr=function(e){Y(e),e.headers=e.headers||{},e.data=K.call(e,e.data,e.headers,e.transformRequest),e.headers=me.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),me.forEach(["delete","get","head","post","put","patch","common"],function(n){delete e.headers[n]});var r=e.adapter||Sr.adapter;return r(e).then(function(n){return Y(e),n.data=K.call(e,n.data,n.headers,e.transformResponse),n},function(n){return Er(n)||(Y(e),n&&n.response&&(n.response.data=K.call(e,n.response.data,n.response.headers,e.transformResponse))),Promise.reject(n)})},v=p,ve=function(e,r){r=r||{};var s={};function n(a,d){return v.isPlainObject(a)&&v.isPlainObject(d)?v.merge(a,d):v.isPlainObject(d)?v.merge({},d):v.isArray(d)?d.slice():d}function i(a){if(v.isUndefined(r[a])){if(!v.isUndefined(e[a]))return n(void 0,e[a])}else return n(e[a],r[a])}function o(a){if(!v.isUndefined(r[a]))return n(void 0,r[a])}function u(a){if(v.isUndefined(r[a])){if(!v.isUndefined(e[a]))return n(void 0,e[a])}else return n(void 0,r[a])}function l(a){if(a in r)return n(e[a],r[a]);if(a in e)return n(void 0,e[a])}var y={url:o,method:o,data:o,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l};return v.forEach(Object.keys(e).concat(Object.keys(r)),function(d){var E=y[d]||i,m=E(d);v.isUndefined(m)&&E!==l||(s[d]=m)}),s},ye={version:"0.25.0"},Nr=ye.version,Z={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){Z[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}});var _e={};Z.transitional=function(e,r,s){function n(i,o){return"[Axios v"+Nr+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return function(i,o,u){if(e===!1)throw new Error(n(o," has been removed"+(r?" in "+r:"")));return r&&!_e[o]&&(_e[o]=!0,console.warn(n(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,o,u):!0}};function Cr(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var s=Object.keys(t),n=s.length;n-- >0;){var i=s[n],o=e[i];if(o){var u=t[i],l=u===void 0||o(u,i,t);if(l!==!0)throw new TypeError("option "+i+" must be "+l);continue}if(r!==!0)throw Error("Unknown option "+i)}}var Or={assertOptions:Cr,validators:Z},we=p,xr=oe,be=ze,Te=Rr,F=ve,ge=Or,C=ge.validators;function M(t){this.defaults=t,this.interceptors={request:new be,response:new be}}M.prototype.request=function(e,r){if(typeof e=="string"?(r=r||{},r.url=e):r=e||{},!r.url)throw new Error("Provided config url is not valid");r=F(this.defaults,r),r.method?r.method=r.method.toLowerCase():this.defaults.method?r.method=this.defaults.method.toLowerCase():r.method="get";var s=r.transitional;s!==void 0&&ge.assertOptions(s,{silentJSONParsing:C.transitional(C.boolean),forcedJSONParsing:C.transitional(C.boolean),clarifyTimeoutError:C.transitional(C.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(r)===!1||(i=i&&m.synchronous,n.unshift(m.fulfilled,m.rejected))});var o=[];this.interceptors.response.forEach(function(m){o.push(m.fulfilled,m.rejected)});var u;if(!i){var l=[Te,void 0];for(Array.prototype.unshift.apply(l,n),l=l.concat(o),u=Promise.resolve(r);l.length;)u=u.then(l.shift(),l.shift());return u}for(var y=r;n.length;){var a=n.shift(),d=n.shift();try{y=a(y)}catch(E){d(E);break}}try{u=Te(y)}catch(E){return Promise.reject(E)}for(;o.length;)u=u.then(o.shift(),o.shift());return u},M.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=F(this.defaults,e),xr(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},we.forEach(["delete","get","head","options"],function(e){M.prototype[e]=function(r,s){return this.request(F(s||{},{method:e,url:r,data:(s||{}).data}))}}),we.forEach(["post","put","patch"],function(e){M.prototype[e]=function(r,s,n){return this.request(F(n||{},{method:e,url:r,data:s}))}});var Ar=M,Mr=D;function O(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(n){e=n});var r=this;this.promise.then(function(s){if(!!r._listeners){var n,i=r._listeners.length;for(n=0;n<i;n++)r._listeners[n](s);r._listeners=null}}),this.promise.then=function(s){var n,i=new Promise(function(o){r.subscribe(o),n=o}).then(s);return i.cancel=function(){r.unsubscribe(n)},i},t(function(n){r.reason||(r.reason=new Mr(n),e(r.reason))})}O.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},O.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]},O.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}},O.source=function(){var e,r=new O(function(n){e=n});return{token:r,cancel:e}};var $r=O,Ur=function(e){return function(s){return e.apply(null,s)}},kr=p,Dr=function(e){return kr.isObject(e)&&e.isAxiosError===!0},Ee=p,Lr=te,I=Ar,Hr=ve,Br=B;function Se(t){var e=new I(t),r=Lr(I.prototype.request,e);return Ee.extend(r,I.prototype,e),Ee.extend(r,e),r.create=function(n){return Se(Hr(t,n))},r}var b=Se(Br);b.Axios=I,b.Cancel=D,b.CancelToken=$r,b.isCancel=pe,b.VERSION=ye.version,b.all=function(e){return Promise.all(e)},b.spread=Ur,b.isAxiosError=Dr,q.exports=b,q.exports.default=b;var Fr=q.exports;class f{isEmpty(){return!this.isPresent()}static of(e){if(e!=null)return new Pe(e);throw new TypeError("The passed value was null or undefined.")}static ofNonNull(e){return f.of(e)}static ofNullable(e){return e!=null?new Pe(e):new Re}static empty(){return new Re}static from(e){switch(e.kind){case"present":return f.of(e.value);case"empty":return f.empty();default:throw new TypeError("The passed value was not an Option type.")}}}class Pe extends f{constructor(e){super();this.payload=e}isPresent(){return!0}get(){return this.payload}ifPresent(e){e(this.payload)}ifPresentOrElse(e,r){e(this.payload)}filter(e){return e(this.payload)?this:f.empty()}map(e){const r=e(this.payload);return f.ofNullable(r)}flatMap(e){return e(this.payload)}or(e){return this}orElse(e){return this.payload}orElseGet(e){return this.payload}orElseThrow(e){return this.payload}orNull(){return this.payload}orUndefined(){return this.payload}toOption(){return{kind:"present",value:this.payload}}matches(e){return e.present(this.payload)}toJSON(e){return this.payload}}class Re extends f{isPresent(){return!1}constructor(){super()}get(){throw new TypeError("The optional is not present.")}ifPresent(e){}ifPresentOrElse(e,r){r()}filter(e){return this}map(e){return f.empty()}flatMap(e){return f.empty()}or(e){return e()}orElse(e){return e}orElseGet(e){return this.orElse(e())}orElseThrow(e){throw e()}orNull(){return null}orUndefined(){}toOption(){return{kind:"empty"}}matches(e){return e.empty()}toJSON(e){return null}}const Ir="1.0.0";let Ne;function jr(t){Ne=t}function qr(){return Ne}class T{constructor(){const e=qr();this._report={action:f.empty(),applicationId:f.ofNullable(e!==void 0?e.appId:null),timestamp:Date.now(),fps:f.empty(),framesTransformed:f.empty(),guid:f.empty(),highestFrameTransformCpu:f.empty(),message:f.empty(),source:f.ofNullable(e!==void 0?e.sourceType:null),transformedFps:f.empty(),transformerType:f.empty(),variation:f.empty(),videoHeight:f.empty(),videoWidth:f.empty(),version:Ir}}action(e){return this._report.action=f.ofNullable(e),this}framesTransformed(e){return this._report.framesTransformed=f.ofNullable(e),this}fps(e){return this._report.fps=f.ofNullable(e),this}guid(e){return this._report.guid=f.ofNullable(e),this}message(e){return this._report.message=f.ofNullable(e),this}transformedFps(e){return this._report.transformedFps=f.ofNullable(e),this}transformerType(e){return this._report.transformerType=f.ofNullable(e),this}variation(e){return this._report.variation=f.ofNullable(e),this}videoHeight(e){return this._report.videoHeight=f.ofNullable(e),this}videoWidth(e){return this._report.videoWidth=f.ofNullable(e),this}build(){return this._report}}const Jr=t=>JSON.stringify(t,(e,r)=>{if(r!==null)return r});class g{static report(e){return new Promise((r,s)=>{let n=Fr.create(),i={timeout:1e4,timeoutErrorMessage:"Request timeout",headers:{"Content-Type":"application/json"}};const o="https://hlg.tokbox.com/prod/logging/vcp_webrtc";n.post(o,Jr(e),i).then(u=>{console.log(u),r("success")}).catch(u=>{console.log(u),s(u)})})}}var j,Wr=new Uint8Array(16);function Vr(){if(!j&&(j=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!j))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return j(Wr)}var zr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Qr(t){return typeof t=="string"&&zr.test(t)}for(var h=[],ee=0;ee<256;++ee)h.push((ee+256).toString(16).substr(1));function Gr(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase();if(!Qr(r))throw TypeError("Stringified UUID is invalid");return r}function Ce(t,e,r){t=t||{};var s=t.random||(t.rng||Vr)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=s[n];return e}return Gr(s)}const Xr=500;class Kr{constructor(e){this.uuid_=Ce(),this.framesTransformed_=0,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.framesFromSource_=0,this.fps_=0,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType());const r=new T().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Create").build();g.report(r)}async start(e){if(this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch{const s=new T().action("MediaTransformer").guid(this.uuid_).message(P.errors.transformer_start).transformerType(this.transformerType_).variation("Error").build();g.report(s)}}async transform(e,r){var s,n,i,o;if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),this.videoHeight_=(s=e==null?void 0:e.displayHeight)!=null?s:0,this.videoWidth_=(n=e==null?void 0:e.displayWidth)!=null?n:0,++this.framesFromSource_,this.transformer_)if(this.shouldStop_)e.close(),this.flush(r),r.terminate();else try{await((o=(i=this.transformer_).transform)==null?void 0:o.call(i,e,r)),++this.framesTransformed_,this.framesTransformed_===Xr&&this.mediaTransformerQosReport()}catch{const l=new T().action("MediaTransformer").guid(this.uuid_).message(P.errors.transformer_transform).transformerType(this.transformerType_).variation("Error").build();g.report(l)}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch{const n=new T().action("MediaTransformer").guid(this.uuid_).message(P.errors.transformer_transform).transformerType(this.transformerType_).variation("Error").build();g.report(n)}}this.mediaTransformerQosReport();const r=new T().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Delete").build();g.report(r)}stop(){console.log("[Pipeline] Stop stream."),this.shouldStop_=!0}mediaTransformerQosReport(){let e=(Date.now()-this.mediaTransformerQosReportStartTimestamp_)/1e3,r=this.framesFromSource_/e,s=this.framesTransformed_/e;const n=new T().action("MediaTransformer").fps(r).transformedFps(s).framesTransformed(this.framesTransformed_).guid(this.uuid_).transformerType(this.transformerType_).videoHeight(this.videoHeight_).videoWidth(this.videoWidth_).variation("QoS").build();g.report(n),this.mediaTransformerQosReportStartTimestamp_=0,this.framesFromSource_=0,this.framesTransformed_=0}}class Yr{constructor(e){this.transformers_=[];for(let r of e)this.transformers_.push(new Kr(r))}async start(e,r){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let s=e;for(let n of this.transformers_)e=e.pipeThrough(new TransformStream(n));e.pipeTo(r).then(async()=>{console.log("[Pipeline] Setup."),await r.abort(),await s.cancel()}).catch(async n=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(i=>{console.error("[Pipeline] Error from stream transform:",i)}),await r.abort(n),await s.cancel(n)})}catch{this.destroy();return}console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Zr{constructor(){this.uuid_=Ce();const e=new T().action("MediaProcessor").guid(this.uuid_).variation("Create").build();g.report(e)}transform(e,r){return this.readable_=e,this.writable_=r,this.transformInternal()}transformInternal(){return new Promise((e,r)=>{if(!this.transformers_||this.transformers_.length===0){const s=new T().action("MediaProcessor").guid(this.uuid_).message(P.errors.transformer_none).variation("Error").build();g.report(s),r("[MediaProcessor] Need to set transformers.")}this.pipeline_&&this.pipeline_.destroy(),this.pipeline_=new Yr(this.transformers_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(s=>{r(s)})})}setTransformers(e){const r=new T().action("MediaProcessor").guid(this.uuid_).message(P.updates.transformer_new).variation("Update").build();return g.report(r),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(e=>{this.pipeline_&&this.pipeline_.destroy();const r=new T().action("MediaProcessor").guid(this.uuid_).variation("Delete").build();g.report(r),e()})}}class et{constructor(){this.processor_=null,this.generator_=null}init(e){return new Promise((r,s)=>{try{this.processor_=new MediaStreamTrackProcessor(e)}catch(n){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${n}`),s(n)}try{e.kind==="audio"?this.generator_=new MediaStreamTrackGenerator({kind:"audio"}):e.kind==="video"?this.generator_=new MediaStreamTrackGenerator({kind:"video"}):s("kind not supported")}catch(n){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${n}`),s(n)}r()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class rt{constructor(e){this.insertableStreamHelper_=new et,this.mediaProcessor_=e}setTrack(e){return new Promise((r,s)=>{this.insertableStreamHelper_.init(e).then(()=>{this.mediaProcessor_.transform(this.insertableStreamHelper_.getReadable(),this.insertableStreamHelper_.getWriteable()).then(()=>{r(this.insertableStreamHelper_.getProccesorTrack())}).catch(n=>{s(n)})}).catch(n=>{s(n)})})}destroy(){return new Promise((e,r)=>{this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>{e()}).catch(s=>{r(s)}):r("no processor")})}}w.MediaProcessor=Zr,w.MediaProcessorConnector=rt,w.isSupported=A,w.setMetadata=jr,Object.defineProperty(w,"__esModule",{value:!0}),w[Symbol.toStringTag]="Module"});
2
+ `),function(u){if(i=u.indexOf(":"),s=Q.trim(u.substr(0,i)).toLowerCase(),n=Q.trim(u.substr(i+1)),s){if(r[s]&&ir.indexOf(s)>=0)return;s==="set-cookie"?r[s]=(r[s]?r[s]:[]).concat([n]):r[s]=r[s]?r[s]+", "+n:n}}),r},fe=p,or=fe.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),s;function n(i){var o=i;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return s=n(window.location.href),function(o){var u=fe.isString(o)?n(o):o;return u.protocol===s.protocol&&u.host===s.host}}():function(){return function(){return!0}}();function G(t){this.message=t}G.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},G.prototype.__CANCEL__=!0;var D=G,L=p,ur=Ye,lr=Ze,fr=oe,dr=sr,cr=ar,hr=or,X=le,pr=B,mr=D,de=function(e){return new Promise(function(s,n){var i=e.data,o=e.headers,u=e.responseType,l;function y(){e.cancelToken&&e.cancelToken.unsubscribe(l),e.signal&&e.signal.removeEventListener("abort",l)}L.isFormData(i)&&delete o["Content-Type"];var a=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",E=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(d+":"+E)}var m=dr(e.baseURL,e.url);a.open(e.method.toUpperCase(),fr(m,e.params,e.paramsSerializer),!0),a.timeout=e.timeout;function Oe(){if(!!a){var _="getAllResponseHeaders"in a?cr(a.getAllResponseHeaders()):null,x=!u||u==="text"||u==="json"?a.responseText:a.response,R={data:x,status:a.status,statusText:a.statusText,headers:_,config:e,request:a};ur(function(re){s(re),y()},function(re){n(re),y()},R),a=null}}if("onloadend"in a?a.onloadend=Oe:a.onreadystatechange=function(){!a||a.readyState!==4||a.status===0&&!(a.responseURL&&a.responseURL.indexOf("file:")===0)||setTimeout(Oe)},a.onabort=function(){!a||(n(X("Request aborted",e,"ECONNABORTED",a)),a=null)},a.onerror=function(){n(X("Network Error",e,null,a)),a=null},a.ontimeout=function(){var x=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",R=e.transitional||pr.transitional;e.timeoutErrorMessage&&(x=e.timeoutErrorMessage),n(X(x,e,R.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",a)),a=null},L.isStandardBrowserEnv()){var xe=(e.withCredentials||hr(m))&&e.xsrfCookieName?lr.read(e.xsrfCookieName):void 0;xe&&(o[e.xsrfHeaderName]=xe)}"setRequestHeader"in a&&L.forEach(o,function(x,R){typeof i=="undefined"&&R.toLowerCase()==="content-type"?delete o[R]:a.setRequestHeader(R,x)}),L.isUndefined(e.withCredentials)||(a.withCredentials=!!e.withCredentials),u&&u!=="json"&&(a.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&a.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&a.upload&&a.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(l=function(_){!a||(n(!_||_&&_.type?new mr("canceled"):_),a.abort(),a=null)},e.cancelToken&&e.cancelToken.subscribe(l),e.signal&&(e.signal.aborted?l():e.signal.addEventListener("abort",l))),i||(i=null),a.send(i)})},c=p,ce=Ge,vr=ue,yr={"Content-Type":"application/x-www-form-urlencoded"};function he(t,e){!c.isUndefined(t)&&c.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function _r(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=de),t}function wr(t,e,r){if(c.isString(t))try{return(e||JSON.parse)(t),c.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(r||JSON.stringify)(t)}var H={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:_r(),transformRequest:[function(e,r){return ce(r,"Accept"),ce(r,"Content-Type"),c.isFormData(e)||c.isArrayBuffer(e)||c.isBuffer(e)||c.isStream(e)||c.isFile(e)||c.isBlob(e)?e:c.isArrayBufferView(e)?e.buffer:c.isURLSearchParams(e)?(he(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):c.isObject(e)||r&&r["Content-Type"]==="application/json"?(he(r,"application/json"),wr(e)):e}],transformResponse:[function(e){var r=this.transitional||H.transitional,s=r&&r.silentJSONParsing,n=r&&r.forcedJSONParsing,i=!s&&this.responseType==="json";if(i||n&&c.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?vr(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};c.forEach(["delete","get","head"],function(e){H.headers[e]={}}),c.forEach(["post","put","patch"],function(e){H.headers[e]=c.merge(yr)});var B=H,br=p,Tr=B,gr=function(e,r,s){var n=this||Tr;return br.forEach(s,function(o){e=o.call(n,e,r)}),e},pe=function(e){return!!(e&&e.__CANCEL__)},me=p,K=gr,Er=pe,Sr=B,Pr=D;function Y(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Pr("canceled")}var Rr=function(e){Y(e),e.headers=e.headers||{},e.data=K.call(e,e.data,e.headers,e.transformRequest),e.headers=me.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),me.forEach(["delete","get","head","post","put","patch","common"],function(n){delete e.headers[n]});var r=e.adapter||Sr.adapter;return r(e).then(function(n){return Y(e),n.data=K.call(e,n.data,n.headers,e.transformResponse),n},function(n){return Er(n)||(Y(e),n&&n.response&&(n.response.data=K.call(e,n.response.data,n.response.headers,e.transformResponse))),Promise.reject(n)})},v=p,ve=function(e,r){r=r||{};var s={};function n(a,d){return v.isPlainObject(a)&&v.isPlainObject(d)?v.merge(a,d):v.isPlainObject(d)?v.merge({},d):v.isArray(d)?d.slice():d}function i(a){if(v.isUndefined(r[a])){if(!v.isUndefined(e[a]))return n(void 0,e[a])}else return n(e[a],r[a])}function o(a){if(!v.isUndefined(r[a]))return n(void 0,r[a])}function u(a){if(v.isUndefined(r[a])){if(!v.isUndefined(e[a]))return n(void 0,e[a])}else return n(void 0,r[a])}function l(a){if(a in r)return n(e[a],r[a]);if(a in e)return n(void 0,e[a])}var y={url:o,method:o,data:o,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l};return v.forEach(Object.keys(e).concat(Object.keys(r)),function(d){var E=y[d]||i,m=E(d);v.isUndefined(m)&&E!==l||(s[d]=m)}),s},ye={version:"0.25.0"},Nr=ye.version,Z={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){Z[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}});var _e={};Z.transitional=function(e,r,s){function n(i,o){return"[Axios v"+Nr+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return function(i,o,u){if(e===!1)throw new Error(n(o," has been removed"+(r?" in "+r:"")));return r&&!_e[o]&&(_e[o]=!0,console.warn(n(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,o,u):!0}};function Cr(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var s=Object.keys(t),n=s.length;n-- >0;){var i=s[n],o=e[i];if(o){var u=t[i],l=u===void 0||o(u,i,t);if(l!==!0)throw new TypeError("option "+i+" must be "+l);continue}if(r!==!0)throw Error("Unknown option "+i)}}var Or={assertOptions:Cr,validators:Z},we=p,xr=oe,be=ze,Te=Rr,F=ve,ge=Or,C=ge.validators;function M(t){this.defaults=t,this.interceptors={request:new be,response:new be}}M.prototype.request=function(e,r){if(typeof e=="string"?(r=r||{},r.url=e):r=e||{},!r.url)throw new Error("Provided config url is not valid");r=F(this.defaults,r),r.method?r.method=r.method.toLowerCase():this.defaults.method?r.method=this.defaults.method.toLowerCase():r.method="get";var s=r.transitional;s!==void 0&&ge.assertOptions(s,{silentJSONParsing:C.transitional(C.boolean),forcedJSONParsing:C.transitional(C.boolean),clarifyTimeoutError:C.transitional(C.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(r)===!1||(i=i&&m.synchronous,n.unshift(m.fulfilled,m.rejected))});var o=[];this.interceptors.response.forEach(function(m){o.push(m.fulfilled,m.rejected)});var u;if(!i){var l=[Te,void 0];for(Array.prototype.unshift.apply(l,n),l=l.concat(o),u=Promise.resolve(r);l.length;)u=u.then(l.shift(),l.shift());return u}for(var y=r;n.length;){var a=n.shift(),d=n.shift();try{y=a(y)}catch(E){d(E);break}}try{u=Te(y)}catch(E){return Promise.reject(E)}for(;o.length;)u=u.then(o.shift(),o.shift());return u},M.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=F(this.defaults,e),xr(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},we.forEach(["delete","get","head","options"],function(e){M.prototype[e]=function(r,s){return this.request(F(s||{},{method:e,url:r,data:(s||{}).data}))}}),we.forEach(["post","put","patch"],function(e){M.prototype[e]=function(r,s,n){return this.request(F(n||{},{method:e,url:r,data:s}))}});var Ar=M,Mr=D;function O(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(n){e=n});var r=this;this.promise.then(function(s){if(!!r._listeners){var n,i=r._listeners.length;for(n=0;n<i;n++)r._listeners[n](s);r._listeners=null}}),this.promise.then=function(s){var n,i=new Promise(function(o){r.subscribe(o),n=o}).then(s);return i.cancel=function(){r.unsubscribe(n)},i},t(function(n){r.reason||(r.reason=new Mr(n),e(r.reason))})}O.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},O.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]},O.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}},O.source=function(){var e,r=new O(function(n){e=n});return{token:r,cancel:e}};var $r=O,Ur=function(e){return function(s){return e.apply(null,s)}},kr=p,Dr=function(e){return kr.isObject(e)&&e.isAxiosError===!0},Ee=p,Lr=te,I=Ar,Hr=ve,Br=B;function Se(t){var e=new I(t),r=Lr(I.prototype.request,e);return Ee.extend(r,I.prototype,e),Ee.extend(r,e),r.create=function(n){return Se(Hr(t,n))},r}var b=Se(Br);b.Axios=I,b.Cancel=D,b.CancelToken=$r,b.isCancel=pe,b.VERSION=ye.version,b.all=function(e){return Promise.all(e)},b.spread=Ur,b.isAxiosError=Dr,q.exports=b,q.exports.default=b;var Fr=q.exports;class f{isEmpty(){return!this.isPresent()}static of(e){if(e!=null)return new Pe(e);throw new TypeError("The passed value was null or undefined.")}static ofNonNull(e){return f.of(e)}static ofNullable(e){return e!=null?new Pe(e):new Re}static empty(){return new Re}static from(e){switch(e.kind){case"present":return f.of(e.value);case"empty":return f.empty();default:throw new TypeError("The passed value was not an Option type.")}}}class Pe extends f{constructor(e){super();this.payload=e}isPresent(){return!0}get(){return this.payload}ifPresent(e){e(this.payload)}ifPresentOrElse(e,r){e(this.payload)}filter(e){return e(this.payload)?this:f.empty()}map(e){const r=e(this.payload);return f.ofNullable(r)}flatMap(e){return e(this.payload)}or(e){return this}orElse(e){return this.payload}orElseGet(e){return this.payload}orElseThrow(e){return this.payload}orNull(){return this.payload}orUndefined(){return this.payload}toOption(){return{kind:"present",value:this.payload}}matches(e){return e.present(this.payload)}toJSON(e){return this.payload}}class Re extends f{isPresent(){return!1}constructor(){super()}get(){throw new TypeError("The optional is not present.")}ifPresent(e){}ifPresentOrElse(e,r){r()}filter(e){return this}map(e){return f.empty()}flatMap(e){return f.empty()}or(e){return e()}orElse(e){return e}orElseGet(e){return this.orElse(e())}orElseThrow(e){throw e()}orNull(){return null}orUndefined(){}toOption(){return{kind:"empty"}}matches(e){return e.empty()}toJSON(e){return null}}const Ir="1.0.1";let Ne;function jr(t){Ne=t}function qr(){return Ne}class T{constructor(){const e=qr();this._report={action:f.empty(),applicationId:f.ofNullable(e!==void 0?e.appId:null),timestamp:Date.now(),fps:f.empty(),framesTransformed:f.empty(),guid:f.empty(),highestFrameTransformCpu:f.empty(),message:f.empty(),source:f.ofNullable(e!==void 0?e.sourceType:null),transformedFps:f.empty(),transformerType:f.empty(),variation:f.empty(),videoHeight:f.empty(),videoWidth:f.empty(),version:Ir}}action(e){return this._report.action=f.ofNullable(e),this}framesTransformed(e){return this._report.framesTransformed=f.ofNullable(e),this}fps(e){return this._report.fps=f.ofNullable(e),this}guid(e){return this._report.guid=f.ofNullable(e),this}message(e){return this._report.message=f.ofNullable(e),this}transformedFps(e){return this._report.transformedFps=f.ofNullable(e),this}transformerType(e){return this._report.transformerType=f.ofNullable(e),this}variation(e){return this._report.variation=f.ofNullable(e),this}videoHeight(e){return this._report.videoHeight=f.ofNullable(e),this}videoWidth(e){return this._report.videoWidth=f.ofNullable(e),this}build(){return this._report}}const Jr=t=>JSON.stringify(t,(e,r)=>{if(r!==null)return r});class g{static report(e){return new Promise((r,s)=>{let n=Fr.create(),i={timeout:1e4,timeoutErrorMessage:"Request timeout",headers:{"Content-Type":"application/json"}};const o="https://hlg.tokbox.com/prod/logging/vcp_webrtc";n.post(o,Jr(e),i).then(u=>{console.log(u),r("success")}).catch(u=>{console.log(u),s(u)})})}}var j,Wr=new Uint8Array(16);function Vr(){if(!j&&(j=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!j))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return j(Wr)}var zr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Qr(t){return typeof t=="string"&&zr.test(t)}for(var h=[],ee=0;ee<256;++ee)h.push((ee+256).toString(16).substr(1));function Gr(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase();if(!Qr(r))throw TypeError("Stringified UUID is invalid");return r}function Ce(t,e,r){t=t||{};var s=t.random||(t.rng||Vr)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){r=r||0;for(var n=0;n<16;++n)e[r+n]=s[n];return e}return Gr(s)}const Xr=500;class Kr{constructor(e){this.uuid_=Ce(),this.framesTransformed_=0,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.framesFromSource_=0,this.fps_=0,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType());const r=new T().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Create").build();g.report(r)}async start(e){if(this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch{const s=new T().action("MediaTransformer").guid(this.uuid_).message(P.errors.transformer_start).transformerType(this.transformerType_).variation("Error").build();g.report(s)}}async transform(e,r){var s,n,i,o;if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),this.videoHeight_=(s=e==null?void 0:e.displayHeight)!=null?s:0,this.videoWidth_=(n=e==null?void 0:e.displayWidth)!=null?n:0,++this.framesFromSource_,this.transformer_)if(this.shouldStop_)e.close(),this.flush(r),r.terminate();else try{await((o=(i=this.transformer_).transform)==null?void 0:o.call(i,e,r)),++this.framesTransformed_,this.framesTransformed_===Xr&&this.mediaTransformerQosReport()}catch{const l=new T().action("MediaTransformer").guid(this.uuid_).message(P.errors.transformer_transform).transformerType(this.transformerType_).variation("Error").build();g.report(l)}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch{const n=new T().action("MediaTransformer").guid(this.uuid_).message(P.errors.transformer_transform).transformerType(this.transformerType_).variation("Error").build();g.report(n)}}this.mediaTransformerQosReport();const r=new T().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Delete").build();g.report(r)}stop(){console.log("[Pipeline] Stop stream."),this.shouldStop_=!0}mediaTransformerQosReport(){let e=(Date.now()-this.mediaTransformerQosReportStartTimestamp_)/1e3,r=this.framesFromSource_/e,s=this.framesTransformed_/e;const n=new T().action("MediaTransformer").fps(r).transformedFps(s).framesTransformed(this.framesTransformed_).guid(this.uuid_).transformerType(this.transformerType_).videoHeight(this.videoHeight_).videoWidth(this.videoWidth_).variation("QoS").build();g.report(n),this.mediaTransformerQosReportStartTimestamp_=0,this.framesFromSource_=0,this.framesTransformed_=0}}class Yr{constructor(e){this.transformers_=[];for(let r of e)this.transformers_.push(new Kr(r))}async start(e,r){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let s=e;for(let n of this.transformers_)e=e.pipeThrough(new TransformStream(n));e.pipeTo(r).then(async()=>{console.log("[Pipeline] Setup."),await r.abort(),await s.cancel()}).catch(async n=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(i=>{console.error("[Pipeline] Error from stream transform:",i)}),await r.abort(n),await s.cancel(n)})}catch{this.destroy();return}console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Zr{constructor(){this.uuid_=Ce();const e=new T().action("MediaProcessor").guid(this.uuid_).variation("Create").build();g.report(e)}transform(e,r){return this.readable_=e,this.writable_=r,this.transformInternal()}transformInternal(){return new Promise((e,r)=>{if(!this.transformers_||this.transformers_.length===0){const s=new T().action("MediaProcessor").guid(this.uuid_).message(P.errors.transformer_none).variation("Error").build();g.report(s),r("[MediaProcessor] Need to set transformers.")}this.pipeline_&&this.pipeline_.destroy(),this.pipeline_=new Yr(this.transformers_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(s=>{r(s)})})}setTransformers(e){const r=new T().action("MediaProcessor").guid(this.uuid_).message(P.updates.transformer_new).variation("Update").build();return g.report(r),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(e=>{this.pipeline_&&this.pipeline_.destroy();const r=new T().action("MediaProcessor").guid(this.uuid_).variation("Delete").build();g.report(r),e()})}}class et{constructor(){this.processor_=null,this.generator_=null}init(e){return new Promise((r,s)=>{try{this.processor_=new MediaStreamTrackProcessor(e)}catch(n){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${n}`),s(n)}try{e.kind==="audio"?this.generator_=new MediaStreamTrackGenerator({kind:"audio"}):e.kind==="video"?this.generator_=new MediaStreamTrackGenerator({kind:"video"}):s("kind not supported")}catch(n){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${n}`),s(n)}r()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class rt{constructor(e){this.insertableStreamHelper_=new et,this.mediaProcessor_=e}setTrack(e){return new Promise((r,s)=>{this.insertableStreamHelper_.init(e).then(()=>{this.mediaProcessor_.transform(this.insertableStreamHelper_.getReadable(),this.insertableStreamHelper_.getWriteable()).then(()=>{r(this.insertableStreamHelper_.getProccesorTrack())}).catch(n=>{s(n)})}).catch(n=>{s(n)})})}destroy(){return new Promise((e,r)=>{this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>{e()}).catch(s=>{r(s)}):r("no processor")})}}w.MediaProcessor=Zr,w.MediaProcessorConnector=rt,w.isSupported=A,w.setMetadata=jr,Object.defineProperty(w,"__esModule",{value:!0}),w[Symbol.toStringTag]="Module"});
package/package.json CHANGED
@@ -1,11 +1,20 @@
1
1
  {
2
2
  "name": "@vonage/media-processor",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "author": "Guy Mininberg <guy.mininberg@vonage.com>",
5
5
  "contributors": [
6
6
  "Guy Mininberg <guy.mininberg@vonage.com>",
7
7
  "Jose Olivera <joseantonio.oliveraortega@vonage.com>"
8
8
  ],
9
+ "keywords": [
10
+ "vonage",
11
+ "vonage api",
12
+ "client",
13
+ "media processing",
14
+ "insertable streams",
15
+ "opentok",
16
+ "nexmo"
17
+ ],
9
18
  "scripts": {
10
19
  "build": "npm-run-all build:js doc",
11
20
  "build:js": "node ./scripts/package-json.js && tsc && vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types",