@vonage/media-processor 1.0.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/assets/highlight.css +30 -16
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/classes/MediaProcessor.html +95 -5
- package/dist/docs/classes/MediaProcessorConnector.html +1 -1
- package/dist/docs/index.html +1 -1
- package/dist/docs/modules.html +22 -5
- package/dist/media-processor.es.js +452 -14
- package/dist/media-processor.umd.js +3 -2
- package/dist/types/main.d.ts +3 -2
- package/dist/types/src/core/MediaProcessor.d.ts +21 -2
- package/dist/types/src/core/pipeline.d.ts +81 -3
- package/dist/types/src/telemetry/Reporter.d.ts +5 -1
- package/dist/types/src/utils/Tools.d.ts +1 -0
- package/package.json +3 -2
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
(function(
|
|
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"});
|
|
1
|
+
(function(g,U){typeof exports=="object"&&typeof module!="undefined"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(g=typeof globalThis!="undefined"?globalThis:g||self,U(g["media-processor"]={}))})(this,function(g){"use strict";function U(){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 Z={exports:{}},ge=function(e,r){return function(){for(var s=new Array(arguments.length),i=0;i<s.length;i++)s[i]=arguments[i];return e.apply(r,s)}},Ye=ge,S=Object.prototype.toString;function ee(t){return Array.isArray(t)}function re(t){return typeof t=="undefined"}function Ze(t){return t!==null&&!re(t)&&t.constructor!==null&&!re(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function ve(t){return S.call(t)==="[object ArrayBuffer]"}function er(t){return S.call(t)==="[object FormData]"}function rr(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&ve(t.buffer),e}function tr(t){return typeof t=="string"}function nr(t){return typeof t=="number"}function we(t){return t!==null&&typeof t=="object"}function j(t){if(S.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function sr(t){return S.call(t)==="[object Date]"}function ir(t){return S.call(t)==="[object File]"}function or(t){return S.call(t)==="[object Blob]"}function _e(t){return S.call(t)==="[object Function]"}function ar(t){return we(t)&&_e(t.pipe)}function ur(t){return S.call(t)==="[object URLSearchParams]"}function fr(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function lr(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function te(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),ee(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.call(null,t[s],s,t)}function ne(){var t={};function e(s,i){j(t[i])&&j(s)?t[i]=ne(t[i],s):j(s)?t[i]=ne({},s):ee(s)?t[i]=s.slice():t[i]=s}for(var r=0,n=arguments.length;r<n;r++)te(arguments[r],e);return t}function cr(t,e,r){return te(e,function(s,i){r&&typeof s=="function"?t[i]=Ye(s,r):t[i]=s}),t}function dr(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var p={isArray:ee,isArrayBuffer:ve,isBuffer:Ze,isFormData:er,isArrayBufferView:rr,isString:tr,isNumber:nr,isObject:we,isPlainObject:j,isUndefined:re,isDate:sr,isFile:ir,isBlob:or,isFunction:_e,isStream:ar,isURLSearchParams:ur,isStandardBrowserEnv:lr,forEach:te,merge:ne,extend:cr,trim:fr,stripBOM:dr},A=p;function Ee(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Te=function(e,r,n){if(!r)return e;var s;if(n)s=n(r);else if(A.isURLSearchParams(r))s=r.toString();else{var i=[];A.forEach(r,function(l,m){l===null||typeof l=="undefined"||(A.isArray(l)?m=m+"[]":l=[l],A.forEach(l,function(c){A.isDate(c)?c=c.toISOString():A.isObject(c)&&(c=JSON.stringify(c)),i.push(Ee(m)+"="+Ee(c))}))}),s=i.join("&")}if(s){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e},hr=p;function q(){this.handlers=[]}q.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1},q.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},q.prototype.forEach=function(e){hr.forEach(this.handlers,function(n){n!==null&&e(n)})};var pr=q,mr=p,yr=function(e,r){mr.forEach(e,function(s,i){i!==r&&i.toUpperCase()===r.toUpperCase()&&(e[r]=s,delete e[i])})},Se=function(e,r,n,s,i){return e.config=r,n&&(e.code=n),e.request=s,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},br=Se,Re=function(e,r,n,s,i){var o=new Error(e);return br(o,r,n,s,i)},gr=Re,vr=function(e,r,n){var s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):r(gr("Request failed with status code "+n.status,n.config,null,n.request,n))},B=p,wr=B.isStandardBrowserEnv()?function(){return{write:function(r,n,s,i,o,a){var l=[];l.push(r+"="+encodeURIComponent(n)),B.isNumber(s)&&l.push("expires="+new Date(s).toGMTString()),B.isString(i)&&l.push("path="+i),B.isString(o)&&l.push("domain="+o),a===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),_r=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},Er=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},Tr=_r,Sr=Er,Rr=function(e,r){return e&&!Tr(r)?Sr(e,r):r},se=p,Pr=["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"],xr=function(e){var r={},n,s,i;return e&&se.forEach(e.split(`
|
|
2
|
+
`),function(a){if(i=a.indexOf(":"),n=se.trim(a.substr(0,i)).toLowerCase(),s=se.trim(a.substr(i+1)),n){if(r[n]&&Pr.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([s]):r[n]=r[n]?r[n]+", "+s:s}}),r},Pe=p,Or=Pe.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function s(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 n=s(window.location.href),function(o){var a=Pe.isString(o)?s(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}();function ie(t){this.message=t}ie.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},ie.prototype.__CANCEL__=!0;var F=ie,H=p,Ar=vr,Cr=wr,Mr=Te,$r=Rr,kr=xr,Dr=Or,oe=Re,Ur=J,Ir=F,xe=function(e){return new Promise(function(n,s){var i=e.data,o=e.headers,a=e.responseType,l;function m(){e.cancelToken&&e.cancelToken.unsubscribe(l),e.signal&&e.signal.removeEventListener("abort",l)}H.isFormData(i)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",T=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(c+":"+T)}var y=$r(e.baseURL,e.url);u.open(e.method.toUpperCase(),Mr(y,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function Xe(){if(!!u){var v="getAllResponseHeaders"in u?kr(u.getAllResponseHeaders()):null,D=!a||a==="text"||a==="json"?u.responseText:u.response,O={data:D,status:u.status,statusText:u.statusText,headers:v,config:e,request:u};Ar(function(be){n(be),m()},function(be){s(be),m()},O),u=null}}if("onloadend"in u?u.onloadend=Xe:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(Xe)},u.onabort=function(){!u||(s(oe("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){s(oe("Network Error",e,null,u)),u=null},u.ontimeout=function(){var D=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",O=e.transitional||Ur.transitional;e.timeoutErrorMessage&&(D=e.timeoutErrorMessage),s(oe(D,e,O.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},H.isStandardBrowserEnv()){var Ke=(e.withCredentials||Dr(y))&&e.xsrfCookieName?Cr.read(e.xsrfCookieName):void 0;Ke&&(o[e.xsrfHeaderName]=Ke)}"setRequestHeader"in u&&H.forEach(o,function(D,O){typeof i=="undefined"&&O.toLowerCase()==="content-type"?delete o[O]:u.setRequestHeader(O,D)}),H.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),a&&a!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(l=function(v){!u||(s(!v||v&&v.type?new Ir("canceled"):v),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(l),e.signal&&(e.signal.aborted?l():e.signal.addEventListener("abort",l))),i||(i=null),u.send(i)})},d=p,Oe=yr,Lr=Se,Nr={"Content-Type":"application/x-www-form-urlencoded"};function Ae(t,e){!d.isUndefined(t)&&d.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function jr(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=xe),t}function qr(t,e,r){if(d.isString(t))try{return(e||JSON.parse)(t),d.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var W={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:jr(),transformRequest:[function(e,r){return Oe(r,"Accept"),Oe(r,"Content-Type"),d.isFormData(e)||d.isArrayBuffer(e)||d.isBuffer(e)||d.isStream(e)||d.isFile(e)||d.isBlob(e)?e:d.isArrayBufferView(e)?e.buffer:d.isURLSearchParams(e)?(Ae(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):d.isObject(e)||r&&r["Content-Type"]==="application/json"?(Ae(r,"application/json"),qr(e)):e}],transformResponse:[function(e){var r=this.transitional||W.transitional,n=r&&r.silentJSONParsing,s=r&&r.forcedJSONParsing,i=!n&&this.responseType==="json";if(i||s&&d.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?Lr(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, */*"}}};d.forEach(["delete","get","head"],function(e){W.headers[e]={}}),d.forEach(["post","put","patch"],function(e){W.headers[e]=d.merge(Nr)});var J=W,Br=p,Fr=J,Hr=function(e,r,n){var s=this||Fr;return Br.forEach(n,function(o){e=o.call(s,e,r)}),e},Ce=function(e){return!!(e&&e.__CANCEL__)},Me=p,ae=Hr,Wr=Ce,Jr=J,zr=F;function ue(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new zr("canceled")}var Vr=function(e){ue(e),e.headers=e.headers||{},e.data=ae.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(s){delete e.headers[s]});var r=e.adapter||Jr.adapter;return r(e).then(function(s){return ue(e),s.data=ae.call(e,s.data,s.headers,e.transformResponse),s},function(s){return Wr(s)||(ue(e),s&&s.response&&(s.response.data=ae.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})},b=p,$e=function(e,r){r=r||{};var n={};function s(u,c){return b.isPlainObject(u)&&b.isPlainObject(c)?b.merge(u,c):b.isPlainObject(c)?b.merge({},c):b.isArray(c)?c.slice():c}function i(u){if(b.isUndefined(r[u])){if(!b.isUndefined(e[u]))return s(void 0,e[u])}else return s(e[u],r[u])}function o(u){if(!b.isUndefined(r[u]))return s(void 0,r[u])}function a(u){if(b.isUndefined(r[u])){if(!b.isUndefined(e[u]))return s(void 0,e[u])}else return s(void 0,r[u])}function l(u){if(u in r)return s(e[u],r[u]);if(u in e)return s(void 0,e[u])}var m={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:l};return b.forEach(Object.keys(e).concat(Object.keys(r)),function(c){var T=m[c]||i,y=T(c);b.isUndefined(y)&&T!==l||(n[c]=y)}),n},ke={version:"0.25.0"},Gr=ke.version,fe={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){fe[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var De={};fe.transitional=function(e,r,n){function s(i,o){return"[Axios v"+Gr+"] Transitional option '"+i+"'"+o+(n?". "+n:"")}return function(i,o,a){if(e===!1)throw new Error(s(o," has been removed"+(r?" in "+r:"")));return r&&!De[o]&&(De[o]=!0,console.warn(s(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,o,a):!0}};function Qr(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),s=n.length;s-- >0;){var i=n[s],o=e[i];if(o){var a=t[i],l=a===void 0||o(a,i,t);if(l!==!0)throw new TypeError("option "+i+" must be "+l);continue}if(r!==!0)throw Error("Unknown option "+i)}}var Xr={assertOptions:Qr,validators:fe},Ue=p,Kr=Te,Ie=pr,Le=Vr,z=$e,Ne=Xr,C=Ne.validators;function I(t){this.defaults=t,this.interceptors={request:new Ie,response:new Ie}}I.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=z(this.defaults,r),r.method?r.method=r.method.toLowerCase():this.defaults.method?r.method=this.defaults.method.toLowerCase():r.method="get";var n=r.transitional;n!==void 0&&Ne.assertOptions(n,{silentJSONParsing:C.transitional(C.boolean),forcedJSONParsing:C.transitional(C.boolean),clarifyTimeoutError:C.transitional(C.boolean)},!1);var s=[],i=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(r)===!1||(i=i&&y.synchronous,s.unshift(y.fulfilled,y.rejected))});var o=[];this.interceptors.response.forEach(function(y){o.push(y.fulfilled,y.rejected)});var a;if(!i){var l=[Le,void 0];for(Array.prototype.unshift.apply(l,s),l=l.concat(o),a=Promise.resolve(r);l.length;)a=a.then(l.shift(),l.shift());return a}for(var m=r;s.length;){var u=s.shift(),c=s.shift();try{m=u(m)}catch(T){c(T);break}}try{a=Le(m)}catch(T){return Promise.reject(T)}for(;o.length;)a=a.then(o.shift(),o.shift());return a},I.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=z(this.defaults,e),Kr(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},Ue.forEach(["delete","get","head","options"],function(e){I.prototype[e]=function(r,n){return this.request(z(n||{},{method:e,url:r,data:(n||{}).data}))}}),Ue.forEach(["post","put","patch"],function(e){I.prototype[e]=function(r,n,s){return this.request(z(s||{},{method:e,url:r,data:n}))}});var Yr=I,Zr=F;function M(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(s){e=s});var r=this;this.promise.then(function(n){if(!!r._listeners){var s,i=r._listeners.length;for(s=0;s<i;s++)r._listeners[s](n);r._listeners=null}}),this.promise.then=function(n){var s,i=new Promise(function(o){r.subscribe(o),s=o}).then(n);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s){r.reason||(r.reason=new Zr(s),e(r.reason))})}M.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},M.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]},M.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}},M.source=function(){var e,r=new M(function(s){e=s});return{token:r,cancel:e}};var et=M,rt=function(e){return function(n){return e.apply(null,n)}},tt=p,nt=function(e){return tt.isObject(e)&&e.isAxiosError===!0},je=p,st=ge,V=Yr,it=$e,ot=J;function qe(t){var e=new V(t),r=st(V.prototype.request,e);return je.extend(r,V.prototype,e),je.extend(r,e),r.create=function(s){return qe(it(t,s))},r}var w=qe(ot);w.Axios=V,w.Cancel=F,w.CancelToken=et,w.isCancel=Ce,w.VERSION=ke.version,w.all=function(e){return Promise.all(e)},w.spread=rt,w.isAxiosError=nt,Z.exports=w,Z.exports.default=w;var at=Z.exports;class f{isEmpty(){return!this.isPresent()}static of(e){if(e!=null)return new Be(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 Be(e):new Fe}static empty(){return new Fe}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 Be 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 Fe 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 ut="1.1.3";let He;function ft(t){He=t}function We(){return He}class _{constructor(){const e=We();this._report={action:f.empty(),applicationId:f.ofNullable(e!==void 0&&e!=null?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!=null?e.sourceType:null),transformedFps:f.empty(),transformerType:f.empty(),variation:f.empty(),videoHeight:f.empty(),videoWidth:f.empty(),version:ut,error:f.empty()}}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}error(e){return this._report.error=f.ofNullable(e),this}build(){return this._report}}const lt=t=>JSON.stringify(t,(e,r)=>{if(r!==null)return r});class E{static report(e){return new Promise((r,n)=>{if(e.applicationId.isEmpty()||e.source.isEmpty()){r("success");return}let s=at.create(),i={timeout:1e4,timeoutErrorMessage:"Request timeout",headers:{"Content-Type":"application/json"}};const o="https://hlg.tokbox.com/prod/logging/vcp_webrtc";s.post(o,lt(e),i).then(a=>{console.log(a),r("success")}).catch(a=>{console.log(a),n(a)})})}}var G,ct=new Uint8Array(16);function dt(){if(!G&&(G=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!G))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return G(ct)}var ht=/^(?:[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 pt(t){return typeof t=="string"&&ht.test(t)}for(var h=[],le=0;le<256;++le)h.push((le+256).toString(16).substr(1));function mt(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(!pt(r))throw TypeError("Stringified UUID is invalid");return r}function Je(t,e,r){t=t||{};var n=t.random||(t.rng||dt)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(var s=0;s<16;++s)e[r+s]=n[s];return e}return mt(n)}const R=new WeakMap,Q=new WeakMap,L=new WeakMap,ce=Symbol("anyProducer"),ze=Promise.resolve(),X=Symbol("listenerAdded"),K=Symbol("listenerRemoved");let de=!1;function $(t){if(typeof t!="string"&&typeof t!="symbol")throw new TypeError("eventName must be a string or a symbol")}function Y(t){if(typeof t!="function")throw new TypeError("listener must be a function")}function k(t,e){const r=Q.get(t);return r.has(e)||r.set(e,new Set),r.get(e)}function N(t,e){const r=typeof e=="string"||typeof e=="symbol"?e:ce,n=L.get(t);return n.has(r)||n.set(r,new Set),n.get(r)}function yt(t,e,r){const n=L.get(t);if(n.has(e))for(const s of n.get(e))s.enqueue(r);if(n.has(ce)){const s=Promise.all([e,r]);for(const i of n.get(ce))i.enqueue(s)}}function Ve(t,e){e=Array.isArray(e)?e:[e];let r=!1,n=()=>{},s=[];const i={enqueue(o){s.push(o),n()},finish(){r=!0,n()}};for(const o of e)N(t,o).add(i);return{async next(){return s?s.length===0?r?(s=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await s.shift()}:{done:!0}},async return(o){s=void 0;for(const a of e)N(t,a).delete(i);return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Ge(t){if(t===void 0)return Qe;if(!Array.isArray(t))throw new TypeError("`methodNames` must be an array of strings");for(const e of t)if(!Qe.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return t}const he=t=>t===X||t===K;class x{static mixin(e,r){return r=Ge(r),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of r)if(n.prototype[o]!==void 0)throw new Error(`The property \`${o}\` already exists on \`target\``);function s(){return Object.defineProperty(this,e,{enumerable:!1,value:new x}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:s});const i=o=>function(...a){return this[e][o](...a)};for(const o of r)Object.defineProperty(n.prototype,o,{enumerable:!1,value:i(o)});return n}}static get isDebugEnabled(){if(typeof process!="object")return de;const{env:e}=process||{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||de}static set isDebugEnabled(e){de=e}constructor(e={}){R.set(this,new Set),Q.set(this,new Map),L.set(this,new Map),this.debug=e.debug||{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(r,n,s,i)=>{i=JSON.stringify(i),typeof s=="symbol"&&(s=s.toString());const o=new Date,a=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;console.log(`[${a}][emittery:${r}][${n}] Event Name: ${s}
|
|
3
|
+
data: ${i}`)})}logIfDebugEnabled(e,r,n){(x.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,r,n)}on(e,r){Y(r),e=Array.isArray(e)?e:[e];for(const n of e)$(n),k(this,n).add(r),this.logIfDebugEnabled("subscribe",n,void 0),he(n)||this.emit(X,{eventName:n,listener:r});return this.off.bind(this,e,r)}off(e,r){Y(r),e=Array.isArray(e)?e:[e];for(const n of e)$(n),k(this,n).delete(r),this.logIfDebugEnabled("unsubscribe",n,void 0),he(n)||this.emit(K,{eventName:n,listener:r})}once(e){return new Promise(r=>{const n=this.on(e,s=>{n(),r(s)})})}events(e){e=Array.isArray(e)?e:[e];for(const r of e)$(r);return Ve(this,e)}async emit(e,r){$(e),this.logIfDebugEnabled("emit",e,r),yt(this,e,r);const n=k(this,e),s=R.get(this),i=[...n],o=he(e)?[]:[...s];await ze,await Promise.all([...i.map(async a=>{if(n.has(a))return a(r)}),...o.map(async a=>{if(s.has(a))return a(e,r)})])}async emitSerial(e,r){$(e),this.logIfDebugEnabled("emitSerial",e,r);const n=k(this,e),s=R.get(this),i=[...n],o=[...s];await ze;for(const a of i)n.has(a)&&await a(r);for(const a of o)s.has(a)&&await a(e,r)}onAny(e){return Y(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),R.get(this).add(e),this.emit(X,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Ve(this)}offAny(e){Y(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),this.emit(K,{listener:e}),R.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const r of e)if(this.logIfDebugEnabled("clear",r,void 0),typeof r=="string"||typeof r=="symbol"){k(this,r).clear();const n=N(this,r);for(const s of n)s.finish();n.clear()}else{R.get(this).clear();for(const n of Q.get(this).values())n.clear();for(const n of L.get(this).values()){for(const s of n)s.finish();n.clear()}}}listenerCount(e){e=Array.isArray(e)?e:[e];let r=0;for(const n of e){if(typeof n=="string"){r+=R.get(this).size+k(this,n).size+N(this,n).size+N(this).size;continue}typeof n!="undefined"&&$(n),r+=R.get(this).size;for(const s of Q.get(this).values())r+=s.size;for(const s of L.get(this).values())r+=s.size}return r}bindMethods(e,r){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");r=Ge(r);for(const n of r){if(e[n]!==void 0)throw new Error(`The property \`${n}\` already exists on \`target\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const Qe=Object.getOwnPropertyNames(x.prototype).filter(t=>t!=="constructor");Object.defineProperty(x,"listenerAdded",{value:X,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(x,"listenerRemoved",{value:K,writable:!1,enumerable:!0,configurable:!1});var pe=x;function bt(t){return typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"}function gt(t){if(bt(t))return t;try{return new Error(JSON.stringify(t))}catch{return new Error(String(t))}}function me(t){return gt(t).message}var ye;(function(t){t.FPS_DROP="fps_drop"})(ye||(ye={}));const vt=500,wt=.8;class _t extends pe{constructor(e,r){super();this.index_=r,this.uuid_=Je(),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.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType());const n=new _().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Create").build();E.report(n)}setTrackExpectedRate(e){this.trackExpectedRate_=e}async start(e){if(this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch(r){const n=new _().action("MediaTransformer").guid(this.uuid_).message(P.errors.transformer_start).transformerType(this.transformerType_).variation("Error").error(me(r)).build();E.report(n);const s={eventMetaData:{transformerIndex:this.index_},error:r,function:"start"};this.emit("error",s)}}async transform(e,r){var n,s,i,o;if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),this.videoHeight_=(n=e==null?void 0:e.displayHeight)!=null?n:0,this.videoWidth_=(s=e==null?void 0:e.displayWidth)!=null?s: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_===vt&&this.mediaTransformerQosReport()}catch(a){const l=new _().action("MediaTransformer").guid(this.uuid_).message(P.errors.transformer_transform).transformerType(this.transformerType_).variation("Error").error(me(a)).build();E.report(l);const m={eventMetaData:{transformerIndex:this.index_},error:a,function:"transform"};this.emit("error",m)}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(n){const s=new _().action("MediaTransformer").guid(this.uuid_).message(P.errors.transformer_flush).transformerType(this.transformerType_).variation("Error").error(me(n)).build();E.report(s);const i={eventMetaData:{transformerIndex:this.index_},error:n,function:"flush"};this.emit("error",i)}}this.mediaTransformerQosReport();const r=new _().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Delete").build();E.report(r)}stop(){console.log("[Pipeline] Stop stream."),this.shouldStop_=!0}mediaTransformerQosReport(){let e=(Date.now()-this.mediaTransformerQosReportStartTimestamp_)/1e3,r=this.framesFromSource_/e,n=this.framesTransformed_/e;if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*wt>r){const i={eventMetaData:{transformerIndex:this.index_},warningType:ye.FPS_DROP,dropInfo:{requested:this.trackExpectedRate_,current:r}};this.emit("warn",i)}const s=new _().action("MediaTransformer").fps(r).transformedFps(n).framesTransformed(this.framesTransformed_).guid(this.uuid_).transformerType(this.transformerType_).videoHeight(this.videoHeight_).videoWidth(this.videoWidth_).variation("QoS").build();E.report(s),this.mediaTransformerQosReportStartTimestamp_=0,this.framesFromSource_=0,this.framesTransformed_=0}}class Et extends pe{constructor(e){super();this.transformers_=[],this.trackExpectedRate_=-1;for(let r=0;r<e.length;r++){let n=new _t(e[r],r);n.on("error",s=>{this.emit("error",s)}),n.on("warn",s=>{this.emit("warn",s)}),this.transformers_.push(n)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let r of this.transformers_)r.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,r){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let n=e;for(let s of this.transformers_)e=e.pipeThrough(new TransformStream(s));e.pipeTo(r).then(async()=>{console.log("[Pipeline] Setup."),await r.abort(),await n.cancel()}).catch(async s=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(i=>{console.error("[Pipeline] Error from stream transform:",i)}),await r.abort(s),await n.cancel(s)})}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 Tt extends pe{constructor(){super();this.uuid_=Je(),this.trackExpectedRate_=-1;const e=new _().action("MediaProcessor").guid(this.uuid_).variation("Create").build();E.report(e)}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}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 n=new _().action("MediaProcessor").guid(this.uuid_).message(P.errors.transformer_none).variation("Error").build();E.report(n),r("[MediaProcessor] Need to set transformers.")}this.pipeline_&&this.pipeline_.destroy(),this.pipeline_=new Et(this.transformers_),this.pipeline_.on("warn",n=>{this.emit("warn",n)}),this.pipeline_.on("error",n=>{this.emit("error",n)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(n=>{r(n)})})}setTransformers(e){const r=new _().action("MediaProcessor").guid(this.uuid_).message(P.updates.transformer_new).variation("Update").build();return E.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 _().action("MediaProcessor").guid(this.uuid_).variation("Delete").build();E.report(r),e()})}}class St{constructor(){this.processor_=null,this.generator_=null}init(e){return new Promise((r,n)=>{try{this.processor_=new MediaStreamTrackProcessor(e)}catch(s){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${s}`),n(s)}try{e.kind==="audio"?this.generator_=new MediaStreamTrackGenerator({kind:"audio"}):e.kind==="video"?this.generator_=new MediaStreamTrackGenerator({kind:"video"}):n("kind not supported")}catch(s){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${s}`),n(s)}r()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class Rt{constructor(e){this.insertableStreamHelper_=new St,this.mediaProcessor_=e}setTrack(e){return new Promise((r,n)=>{this.insertableStreamHelper_.init(e).then(()=>{this.mediaProcessor_.transform(this.insertableStreamHelper_.getReadable(),this.insertableStreamHelper_.getWriteable()).then(()=>{r(this.insertableStreamHelper_.getProccesorTrack())}).catch(s=>{n(s)})}).catch(s=>{n(s)})})}destroy(){return new Promise((e,r)=>{this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>{e()}).catch(n=>{r(n)}):r("no processor")})}}g.MediaProcessor=Tt,g.MediaProcessorConnector=Rt,g.getMetadata=We,g.isSupported=U,g.setMetadata=ft,Object.defineProperty(g,"__esModule",{value:!0}),g[Symbol.toStringTag]="Module"});
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isSupported } from './src/utils/utils';
|
|
2
2
|
import MediaProcessor from './src/core/MediaProcessor';
|
|
3
3
|
import MediaProcessorConnector from './src/core/MediaProcessorConnector';
|
|
4
|
-
import { setMetadata } from './src/telemetry/Reporter';
|
|
4
|
+
import { setMetadata, getMetadata } from './src/telemetry/Reporter';
|
|
5
5
|
export type { MediaProcessorConnectorInterface } from './src/core/MediaProcessorConnectorInterface';
|
|
6
6
|
export type { MediaProcessorInterface } from './src/core/MediaProcessorInterface';
|
|
7
7
|
export type { VonageMetadata, VonageSourceType } from './src/telemetry/Reporter';
|
|
8
|
-
export {
|
|
8
|
+
export type { EventDataMap, WarnData, ErrorData, ErrorFunction, EventMetaData } from './src/core/pipeline';
|
|
9
|
+
export { isSupported, MediaProcessor, MediaProcessorConnector, setMetadata, getMetadata };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import Pipeline from './pipeline';
|
|
1
|
+
import Pipeline, { EventDataMap } from './pipeline';
|
|
2
|
+
import Emittery from 'emittery';
|
|
2
3
|
/**
|
|
3
4
|
* Media processor class holding and running the media processing logic.
|
|
5
|
+
* The class implements an async event emitter pattern
|
|
4
6
|
*
|
|
5
7
|
* @example
|
|
6
8
|
*
|
|
@@ -9,9 +11,11 @@ import Pipeline from './pipeline';
|
|
|
9
11
|
* let transformers: Array<Transformer> = [];
|
|
10
12
|
* transformers.push(new CanvasTransform());
|
|
11
13
|
* mediaProcessor.setTransformers(transformers);
|
|
14
|
+
* mediaProcessor.on('error',(ErrorData => {}))
|
|
15
|
+
* mediaProcessor.on('warn',(WarnData => {}))
|
|
12
16
|
* ```
|
|
13
17
|
*/
|
|
14
|
-
declare class MediaProcessor {
|
|
18
|
+
declare class MediaProcessor extends Emittery<EventDataMap> {
|
|
15
19
|
/**
|
|
16
20
|
* @private
|
|
17
21
|
*/
|
|
@@ -32,7 +36,22 @@ declare class MediaProcessor {
|
|
|
32
36
|
* @private
|
|
33
37
|
*/
|
|
34
38
|
writable_: WritableStream;
|
|
39
|
+
/**
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
trackExpectedRate_: number;
|
|
35
43
|
constructor();
|
|
44
|
+
/**
|
|
45
|
+
* Sets the expected rate of the track per second.
|
|
46
|
+
* The media processor will use this number for calculating drops in the rate.
|
|
47
|
+
* This could happen when the transformation will take more time than expected.
|
|
48
|
+
* This will not cause an error, just warning to the client.
|
|
49
|
+
* Mostly:
|
|
50
|
+
* Video: 30 frames per second
|
|
51
|
+
* Audio: 50 audio data per second for OPUS
|
|
52
|
+
* @param trackExpectedRate - number holds the predicted track rate.
|
|
53
|
+
*/
|
|
54
|
+
setTrackExpectedRate(trackExpectedRate: number): void;
|
|
36
55
|
/**
|
|
37
56
|
* Starts running the tranformation logic performed by the media processor instance.
|
|
38
57
|
*
|
|
@@ -1,4 +1,77 @@
|
|
|
1
|
-
|
|
1
|
+
import Emittery from 'emittery';
|
|
2
|
+
/**
|
|
3
|
+
* WarningType specifies the type of warning from the transformer
|
|
4
|
+
*/
|
|
5
|
+
export declare enum WarningType {
|
|
6
|
+
/**
|
|
7
|
+
* Warning about change in process rate
|
|
8
|
+
*/
|
|
9
|
+
FPS_DROP = "fps_drop"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* DropInfo gives info about the frame rate of the transformer
|
|
13
|
+
*/
|
|
14
|
+
export declare type DropInfo = {
|
|
15
|
+
/**
|
|
16
|
+
* The rate predicted rate of the track
|
|
17
|
+
*/
|
|
18
|
+
requested: number;
|
|
19
|
+
/**
|
|
20
|
+
* The actual rate of the track
|
|
21
|
+
*/
|
|
22
|
+
current: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* ErrorFunction specifies the function which the error (exception) happened
|
|
26
|
+
*/
|
|
27
|
+
export declare type ErrorFunction = 'start' | 'transform' | 'flush';
|
|
28
|
+
/**
|
|
29
|
+
* EventMetaData the meta data of the event.
|
|
30
|
+
*/
|
|
31
|
+
export declare type EventMetaData = {
|
|
32
|
+
/**
|
|
33
|
+
* The transformer index in the array of transformers.
|
|
34
|
+
*/
|
|
35
|
+
transformerIndex: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* WarnData the warning data type
|
|
39
|
+
* ```ts
|
|
40
|
+
* {
|
|
41
|
+
* eventMetaData: { transformerIndex: 0},
|
|
42
|
+
* warningType: WarningType.FPS_DROP
|
|
43
|
+
* dropInfo: {requested: 30, current:20}
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare type WarnData = {
|
|
48
|
+
eventMetaData: EventMetaData;
|
|
49
|
+
warningType: WarningType;
|
|
50
|
+
dropInfo: DropInfo;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* ErrorData the error data type
|
|
54
|
+
* ```ts
|
|
55
|
+
* {
|
|
56
|
+
* eventMetaData: { transformerIndex: 0},
|
|
57
|
+
* ErrorData: 'start',
|
|
58
|
+
* error: e (the exception in the catch)
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare type ErrorData = {
|
|
63
|
+
eventMetaData: EventMetaData;
|
|
64
|
+
function: ErrorFunction;
|
|
65
|
+
error: unknown;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* EventDataMap the options of event data
|
|
69
|
+
*/
|
|
70
|
+
export declare type EventDataMap = {
|
|
71
|
+
warn: WarnData;
|
|
72
|
+
error: ErrorData;
|
|
73
|
+
};
|
|
74
|
+
declare class InternalTransformer extends Emittery<EventDataMap> implements Transformer {
|
|
2
75
|
uuid_: string;
|
|
3
76
|
transformerType_: string;
|
|
4
77
|
fps_: number;
|
|
@@ -10,16 +83,21 @@ declare class InternalTransformer implements Transformer {
|
|
|
10
83
|
mediaTransformerQosReportStartTimestamp_: number;
|
|
11
84
|
videoHeight_: number;
|
|
12
85
|
videoWidth_: number;
|
|
13
|
-
|
|
86
|
+
trackExpectedRate_: number;
|
|
87
|
+
index_: number;
|
|
88
|
+
constructor(transformer: Transformer, index: number);
|
|
89
|
+
setTrackExpectedRate(trackExpectedRate: number): void;
|
|
14
90
|
start(controller: TransformStreamDefaultController): Promise<void>;
|
|
15
91
|
transform(frame: any, controller: TransformStreamDefaultController): Promise<void>;
|
|
16
92
|
flush(controller: TransformStreamDefaultController): Promise<void>;
|
|
17
93
|
stop(): void;
|
|
18
94
|
mediaTransformerQosReport(): void;
|
|
19
95
|
}
|
|
20
|
-
declare class Pipeline {
|
|
96
|
+
declare class Pipeline extends Emittery<EventDataMap> {
|
|
21
97
|
transformers_: Array<InternalTransformer>;
|
|
98
|
+
trackExpectedRate_: number;
|
|
22
99
|
constructor(transformers: Array<Transformer>);
|
|
100
|
+
setTrackExpectedRate(trackExpectedRate: number): void;
|
|
23
101
|
start(readable: ReadableStream, writeable: WritableStream): Promise<void>;
|
|
24
102
|
destroy(): Promise<void>;
|
|
25
103
|
}
|
|
@@ -16,7 +16,8 @@ export declare type VonageMetadata = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Sets some metadata for telemetry.
|
|
18
18
|
*
|
|
19
|
-
* @param metadata
|
|
19
|
+
* @param metadata Specifies the addional information being sent with the telemetry collected by the library.
|
|
20
|
+
* If metadata is either undefined or not set the library will not collect/send any telemetry.
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
22
23
|
*
|
|
@@ -29,6 +30,7 @@ export declare type VonageMetadata = {
|
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
31
32
|
export declare function setMetadata(metadata: VonageMetadata): void;
|
|
33
|
+
export declare function getMetadata(): VonageMetadata;
|
|
32
34
|
interface Report {
|
|
33
35
|
action: Optional<string>;
|
|
34
36
|
applicationId: Optional<string>;
|
|
@@ -45,6 +47,7 @@ interface Report {
|
|
|
45
47
|
videoHeight: Optional<number>;
|
|
46
48
|
videoWidth: Optional<number>;
|
|
47
49
|
version: string;
|
|
50
|
+
error: Optional<string>;
|
|
48
51
|
}
|
|
49
52
|
declare class ReportBuilder {
|
|
50
53
|
private readonly _report;
|
|
@@ -59,6 +62,7 @@ declare class ReportBuilder {
|
|
|
59
62
|
variation(variation: string): this;
|
|
60
63
|
videoHeight(videoHeight: number): this;
|
|
61
64
|
videoWidth(videoWidth: number): this;
|
|
65
|
+
error(error: string): this;
|
|
62
66
|
build(): Report;
|
|
63
67
|
}
|
|
64
68
|
declare class Reporter {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getErrorMessage(error: unknown): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonage/media-processor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"author": "Guy Mininberg <guy.mininberg@vonage.com>",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Guy Mininberg <guy.mininberg@vonage.com>",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"@types/dom-mediacapture-transform": "^0.1.2",
|
|
32
32
|
"axios": "^0.25.0",
|
|
33
33
|
"typescript-optional": "3.0.0-alpha.3",
|
|
34
|
-
"uuid": "~8.3.2"
|
|
34
|
+
"uuid": "~8.3.2",
|
|
35
|
+
"emittery": "^0.10.1"
|
|
35
36
|
},
|
|
36
37
|
"files": [
|
|
37
38
|
"dist"
|