@vonage/media-processor 2.0.0 → 2.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.
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/enums/VonageSourceType.html +3 -5
- package/dist/docs/index.html +1 -1
- package/dist/docs/modules.html +4 -4
- package/dist/media-processor.es.js +684 -2004
- package/dist/media-processor.min.js +1 -0
- package/dist/media-processor.static.js +832 -0
- package/dist/media-processor.umd.js +2 -3
- package/dist/types/lib/main.d.ts +10 -0
- package/dist/types/{src → lib/src}/core/InsertableStreamHelper.d.ts +0 -0
- package/dist/types/{src → lib/src}/core/MediaProcessor.d.ts +3 -1
- package/dist/types/{src → lib/src}/core/MediaProcessorConnector.d.ts +0 -0
- package/dist/types/{src → lib/src}/core/MediaProcessorConnectorInterface.d.ts +0 -0
- package/dist/types/{src → lib/src}/core/MediaProcessorInterface.d.ts +0 -0
- package/dist/types/{src → lib/src}/core/pipeline.d.ts +4 -5
- package/dist/types/{src → lib/src}/telemetry/Key.d.ts +0 -0
- package/dist/types/lib/src/telemetry/QosReporter.d.ts +22 -0
- package/dist/types/{src → lib/src}/utils/Tools.d.ts +0 -0
- package/dist/types/{src → lib/src}/utils/package-json.d.ts +0 -0
- package/dist/types/{src → lib/src}/utils/utils.d.ts +0 -0
- package/package.json +72 -62
- package/dist/types/main.d.ts +0 -11
- package/dist/types/src/telemetry/Reporter.d.ts +0 -97
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`),function(a){if(i=a.indexOf(":"),n=ie.trim(a.substr(0,i)).toLowerCase(),s=ie.trim(a.substr(i+1)),n){if(r[n]&&Or.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=m,Mr=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 oe(t){this.message=t}oe.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},oe.prototype.__CANCEL__=!0;var H=oe,F=m,Cr=wr,$r=Er,kr=Te,Ur=xr,Ir=Ar,Lr=Mr,ae=Re,Nr=J,Dr=H,xe=function(e){return new Promise(function(n,s){var i=e.data,o=e.headers,a=e.responseType,f;function y(){e.cancelToken&&e.cancelToken.unsubscribe(f),e.signal&&e.signal.removeEventListener("abort",f)}F.isFormData(i)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",T=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(d+":"+T)}var b=Ur(e.baseURL,e.url);u.open(e.method.toUpperCase(),kr(b,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function Ye(){if(!!u){var w="getAllResponseHeaders"in u?Ir(u.getAllResponseHeaders()):null,U=!a||a==="text"||a==="json"?u.responseText:u.response,O={data:U,status:u.status,statusText:u.statusText,headers:w,config:e,request:u};Cr(function(be){n(be),y()},function(be){s(be),y()},O),u=null}}if("onloadend"in u?u.onloadend=Ye:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(Ye)},u.onabort=function(){!u||(s(ae("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){s(ae("Network Error",e,null,u)),u=null},u.ontimeout=function(){var U=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",O=e.transitional||Nr.transitional;e.timeoutErrorMessage&&(U=e.timeoutErrorMessage),s(ae(U,e,O.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},F.isStandardBrowserEnv()){var Ze=(e.withCredentials||Lr(b))&&e.xsrfCookieName?$r.read(e.xsrfCookieName):void 0;Ze&&(o[e.xsrfHeaderName]=Ze)}"setRequestHeader"in u&&F.forEach(o,function(U,O){typeof i=="undefined"&&O.toLowerCase()==="content-type"?delete o[O]:u.setRequestHeader(O,U)}),F.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)&&(f=function(w){!u||(s(!w||w&&w.type?new Dr("canceled"):w),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(f),e.signal&&(e.signal.aborted?f():e.signal.addEventListener("abort",f))),i||(i=null),u.send(i)})},c=m,Oe=gr,jr=Se,qr={"Content-Type":"application/x-www-form-urlencoded"};function Ae(t,e){!c.isUndefined(t)&&c.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Br(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=xe),t}function Hr(t,e,r){if(c.isString(t))try{return(e||JSON.parse)(t),c.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:Br(),transformRequest:[function(e,r){return Oe(r,"Accept"),Oe(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)?(Ae(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):c.isObject(e)||r&&r["Content-Type"]==="application/json"?(Ae(r,"application/json"),Hr(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&&c.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?jr(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){W.headers[e]={}}),c.forEach(["post","put","patch"],function(e){W.headers[e]=c.merge(qr)});var J=W,Fr=m,Wr=J,Jr=function(e,r,n){var s=this||Wr;return Fr.forEach(n,function(o){e=o.call(s,e,r)}),e},Me=function(e){return!!(e&&e.__CANCEL__)},Ce=m,ue=Jr,zr=Me,Vr=J,Gr=H;function le(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Gr("canceled")}var Qr=function(e){le(e),e.headers=e.headers||{},e.data=ue.call(e,e.data,e.headers,e.transformRequest),e.headers=Ce.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ce.forEach(["delete","get","head","post","put","patch","common"],function(s){delete e.headers[s]});var r=e.adapter||Vr.adapter;return r(e).then(function(s){return le(e),s.data=ue.call(e,s.data,s.headers,e.transformResponse),s},function(s){return zr(s)||(le(e),s&&s.response&&(s.response.data=ue.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})},g=m,$e=function(e,r){r=r||{};var n={};function s(u,d){return g.isPlainObject(u)&&g.isPlainObject(d)?g.merge(u,d):g.isPlainObject(d)?g.merge({},d):g.isArray(d)?d.slice():d}function i(u){if(g.isUndefined(r[u])){if(!g.isUndefined(e[u]))return s(void 0,e[u])}else return s(e[u],r[u])}function o(u){if(!g.isUndefined(r[u]))return s(void 0,r[u])}function a(u){if(g.isUndefined(r[u])){if(!g.isUndefined(e[u]))return s(void 0,e[u])}else return s(void 0,r[u])}function f(u){if(u in r)return s(e[u],r[u]);if(u in e)return s(void 0,e[u])}var y={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:f};return g.forEach(Object.keys(e).concat(Object.keys(r)),function(d){var T=y[d]||i,b=T(d);g.isUndefined(b)&&T!==f||(n[d]=b)}),n},ke={version:"0.25.0"},Xr=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 Ue={};fe.transitional=function(e,r,n){function s(i,o){return"[Axios v"+Xr+"] 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&&!Ue[o]&&(Ue[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 Kr(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],f=a===void 0||o(a,i,t);if(f!==!0)throw new TypeError("option "+i+" must be "+f);continue}if(r!==!0)throw Error("Unknown option "+i)}}var Yr={assertOptions:Kr,validators:fe},Ie=m,Zr=Te,Le=yr,Ne=Qr,z=$e,De=Yr,M=De.validators;function L(t){this.defaults=t,this.interceptors={request:new Le,response:new Le}}L.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&&De.assertOptions(n,{silentJSONParsing:M.transitional(M.boolean),forcedJSONParsing:M.transitional(M.boolean),clarifyTimeoutError:M.transitional(M.boolean)},!1);var s=[],i=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(r)===!1||(i=i&&b.synchronous,s.unshift(b.fulfilled,b.rejected))});var o=[];this.interceptors.response.forEach(function(b){o.push(b.fulfilled,b.rejected)});var a;if(!i){var f=[Ne,void 0];for(Array.prototype.unshift.apply(f,s),f=f.concat(o),a=Promise.resolve(r);f.length;)a=a.then(f.shift(),f.shift());return a}for(var y=r;s.length;){var u=s.shift(),d=s.shift();try{y=u(y)}catch(T){d(T);break}}try{a=Ne(y)}catch(T){return Promise.reject(T)}for(;o.length;)a=a.then(o.shift(),o.shift());return a},L.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=z(this.defaults,e),Zr(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},Ie.forEach(["delete","get","head","options"],function(e){L.prototype[e]=function(r,n){return this.request(z(n||{},{method:e,url:r,data:(n||{}).data}))}}),Ie.forEach(["post","put","patch"],function(e){L.prototype[e]=function(r,n,s){return this.request(z(s||{},{method:e,url:r,data:n}))}});var et=L,rt=H;function C(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 rt(s),e(r.reason))})}C.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},C.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]},C.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}},C.source=function(){var e,r=new C(function(s){e=s});return{token:r,cancel:e}};var tt=C,nt=function(e){return function(n){return e.apply(null,n)}},st=m,it=function(e){return st.isObject(e)&&e.isAxiosError===!0},je=m,ot=ge,V=et,at=$e,ut=J;function qe(t){var e=new V(t),r=ot(V.prototype.request,e);return je.extend(r,V.prototype,e),je.extend(r,e),r.create=function(s){return qe(at(t,s))},r}var E=qe(ut);E.Axios=V,E.Cancel=H,E.CancelToken=tt,E.isCancel=Me,E.VERSION=ke.version,E.all=function(e){return Promise.all(e)},E.spread=nt,E.isAxiosError=it,ee.exports=E,ee.exports.default=E;var lt=ee.exports;class l{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 l.of(e)}static ofNullable(e){return e!=null?new Be(e):new He}static empty(){return new He}static from(e){switch(e.kind){case"present":return l.of(e.value);case"empty":return l.empty();default:throw new TypeError("The passed value was not an Option type.")}}}class Be extends l{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:l.empty()}map(e){const r=e(this.payload);return l.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 He extends l{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 l.empty()}flatMap(e){return l.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 ft="2.0.0";var Fe=(t=>(t.automation="automation",t.test="test",t.vbc="vbc",t.video="video",t.voice="voice",t))(Fe||{});function dt(t){globalThis._vonageMediaProcessorMetadata=t}function We(){return globalThis._vonageMediaProcessorMetadata}class _{constructor(){const e=We();this._report={action:l.empty(),applicationId:l.ofNullable(e!==void 0&&e!=null?e.appId:null),timestamp:Date.now(),fps:l.empty(),framesTransformed:l.empty(),guid:l.empty(),highestFrameTransformCpu:l.empty(),message:l.empty(),source:l.ofNullable(e!==void 0&&e!=null?e.sourceType:null),transformedFps:l.empty(),transformerType:l.empty(),variation:l.empty(),videoHeight:l.empty(),videoWidth:l.empty(),version:ft,error:l.empty(),proxyUrl:l.ofNullable(e!==void 0&&e!=null?e.proxyUrl:null)}}action(e){return this._report.action=l.ofNullable(e),this}framesTransformed(e){return this._report.framesTransformed=l.ofNullable(e),this}fps(e){return this._report.fps=l.ofNullable(e),this}guid(e){return this._report.guid=l.ofNullable(e),this}message(e){return this._report.message=l.ofNullable(e),this}transformedFps(e){return this._report.transformedFps=l.ofNullable(e),this}transformerType(e){return this._report.transformerType=l.ofNullable(e),this}variation(e){return this._report.variation=l.ofNullable(e),this}videoHeight(e){return this._report.videoHeight=l.ofNullable(e),this}videoWidth(e){return this._report.videoWidth=l.ofNullable(e),this}error(e){return this._report.error=l.ofNullable(e),this}build(){return this._report}}const ct=t=>JSON.stringify(t,(e,r)=>{if(r!==null)return r});class v{static report(e){return new Promise((r,n)=>{if(e.applicationId.isEmpty()||e.source.isEmpty()){r("success");return}let s=lt.create(),i={timeout:1e4,timeoutErrorMessage:"Request timeout",headers:{"Content-Type":"application/json"}},o="hlg.tokbox.com/prod/logging/vcp_webrtc";if(e.proxyUrl.isEmpty())o="https://"+o;else{let a;e.proxyUrl.get().slice(e.proxyUrl.get().length-1)!=="/"?a=e.proxyUrl.get()+"/":a=e.proxyUrl.get(),o=a+o}s.post(o,ct(e),i).then(a=>{console.log(a),r("success")}).catch(a=>{console.log(a),n(a)})})}}var G,ht=new Uint8Array(16);function pt(){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(ht)}var mt=/^(?:[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 yt(t){return typeof t=="string"&&mt.test(t)}for(var h=[],de=0;de<256;++de)h.push((de+256).toString(16).substr(1));function bt(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(!yt(r))throw TypeError("Stringified UUID is invalid");return r}function Je(t,e,r){t=t||{};var n=t.random||(t.rng||pt)();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 bt(n)}const P=new WeakMap,Q=new WeakMap,N=new WeakMap,ce=Symbol("anyProducer"),ze=Promise.resolve(),X=Symbol("listenerAdded"),K=Symbol("listenerRemoved");let he=!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 D(t,e){const r=typeof e=="string"||typeof e=="symbol"?e:ce,n=N.get(t);return n.has(r)||n.set(r,new Set),n.get(r)}function gt(t,e,r){const n=N.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)D(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)D(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 pe=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 he;const{env:e}=process||{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||he}static set isDebugEnabled(e){he=e}constructor(e={}){P.set(this,new Set),Q.set(this,new Map),N.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),pe(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),pe(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),gt(this,e,r);const n=k(this,e),s=P.get(this),i=[...n],o=pe(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=P.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),P.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}),P.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=D(this,r);for(const s of n)s.finish();n.clear()}else{P.get(this).clear();for(const n of Q.get(this).values())n.clear();for(const n of N.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+=P.get(this).size+k(this,n).size+D(this,n).size+D(this).size;continue}typeof n!="undefined"&&$(n),r+=P.get(this).size;for(const s of Q.get(this).values())r+=s.size;for(const s of N.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 me=x;function _t(t){return typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"}function vt(t){if(_t(t))return t;try{return new Error(JSON.stringify(t))}catch{return new Error(String(t))}}function ye(t){return vt(t).message}var Xe=(t=>(t.FPS_DROP="fps_drop",t))(Xe||{}),Ke=(t=>(t.start="start",t.transform="transform",t.flush="flush",t))(Ke||{}),Z=(t=>(t.pipeline_ended="pipeline_ended",t.pipeline_ended_with_error="pipeline_ended_with_error",t.pipeline_started="pipeline_started",t.pipeline_started_with_error="pipeline_started_with_error",t.pipeline_restarted="pipeline_restarted",t.pipeline_restarted_with_error="pipeline_restarted_with_error",t))(Z||{});const wt=500,Et=.8;class Tt extends me{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();v.report(n)}setTrackExpectedRate(e){this.trackExpectedRate_=e}async start(e){if(this.controller_=e,this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch(r){const n=new _().action("MediaTransformer").guid(this.uuid_).message(S.errors.transformer_start).transformerType(this.transformerType_).variation("Error").error(ye(r)).build();v.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()),e instanceof VideoFrame&&(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_)console.warn("[Pipeline] flush from transform"),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_===wt&&this.mediaTransformerQosReport()}catch(a){const f=new _().action("MediaTransformer").guid(this.uuid_).message(S.errors.transformer_transform).transformerType(this.transformerType_).variation("Error").error(ye(a)).build();v.report(f);const y={eventMetaData:{transformerIndex:this.index_},error:a,function:"transform"};this.emit("error",y)}}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(S.errors.transformer_flush).transformerType(this.transformerType_).variation("Error").error(ye(n)).build();v.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();v.report(r)}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),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_*Et>r){const i={eventMetaData:{transformerIndex:this.index_},warningType:"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();v.report(s),this.mediaTransformerQosReportStartTimestamp_=0,this.framesFromSource_=0,this.framesTransformed_=0}}class St extends me{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let r=0;r<e.length;r++){let n=new Tt(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(),this.emit("pipelineInfo","pipeline_ended")}).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),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{this.emit("pipelineInfo","pipeline_started_with_error"),this.destroy();return}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Rt extends me{constructor(){super(),this.uuid_=Je(),this.trackExpectedRate_=-1;const e=new _().action("MediaProcessor").guid(this.uuid_).variation("Create").build();v.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 s=new _().action("MediaProcessor").guid(this.uuid_).message(S.errors.transformer_none).variation("Error").build();v.report(s),r("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){const s=new _().action("MediaProcessor").guid(this.uuid_).message(S.errors.readable_null).variation("Error").build();v.report(s),r("[MediaProcessor] Readable is null.");return}if(!this.writable_){const s=new _().action("MediaProcessor").guid(this.uuid_).message(S.errors.writable_null).variation("Error").build();v.report(s),r("[MediaProcessor] Writable is null.");return}let n=!1;this.pipeline_&&(n=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new St(this.transformers_),this.pipeline_.on("warn",s=>{this.emit("warn",s)}),this.pipeline_.on("error",s=>{this.emit("error",s)}),this.pipeline_.on("pipelineInfo",s=>{n&&(s==="pipeline_started"?s=Z.pipeline_restarted:s==="pipeline_started_with_error"&&(s=Z.pipeline_restarted_with_error)),this.emit("pipelineInfo",s)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(s=>{r(s)})})}setTransformers(e){const r=new _().action("MediaProcessor").guid(this.uuid_).message(S.updates.transformer_new).variation("Update").build();return v.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();v.report(r),e()})}}class Pt{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 xt{constructor(e){this.insertableStreamHelper_=new Pt,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")})}}p.ErrorFunction=Ke,p.MediaProcessor=Rt,p.MediaProcessorConnector=xt,p.PipelineInfoData=Z,p.VonageSourceType=Fe,p.WarningType=Xe,p.getVonageMetadata=We,p.isSupported=I,p.setVonageMetadata=dt,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module"});
|
|
1
|
+
(function(f,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(f=typeof globalThis<"u"?globalThis:f||self,h(f["media-processor"]={}))})(this,function(f){"use strict";var Ce=Object.defineProperty;var Oe=(f,h,u)=>h in f?Ce(f,h,{enumerable:!0,configurable:!0,writable:!0,value:u}):f[h]=u;var a=(f,h,u)=>(Oe(f,typeof h!="symbol"?h+"":h,u),u);function h(){return new Promise((t,e)=>{typeof MediaStreamTrackProcessor>"u"||typeof MediaStreamTrackGenerator>"u"?e("Your browser does not support the MediaStreamTrack API for Insertable Streams of Media."):t()})}class u{}a(u,"updates",{transformer_new:"New transformer",transformer_null:"Null transformer"}),a(u,"errors",{transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer",readable_null:"Readable is null",writable_null:"Writable is null"});const d=new WeakMap,E=new WeakMap,w=new WeakMap,C=Symbol("anyProducer"),H=Promise.resolve(),R=Symbol("listenerAdded"),P=Symbol("listenerRemoved");let O=!1;function y(t){if(typeof t!="string"&&typeof t!="symbol")throw new TypeError("eventName must be a string or a symbol")}function k(t){if(typeof t!="function")throw new TypeError("listener must be a function")}function b(t,e){const r=E.get(t);return r.has(e)||r.set(e,new Set),r.get(e)}function T(t,e){const r=typeof e=="string"||typeof e=="symbol"?e:C,s=w.get(t);return s.has(r)||s.set(r,new Set),s.get(r)}function X(t,e,r){const s=w.get(t);if(s.has(e))for(const o of s.get(e))o.enqueue(r);if(s.has(C)){const o=Promise.all([e,r]);for(const i of s.get(C))i.enqueue(o)}}function $(t,e){e=Array.isArray(e)?e:[e];let r=!1,s=()=>{},o=[];const i={enqueue(n){o.push(n),s()},finish(){r=!0,s()}};for(const n of e)T(t,n).add(i);return{async next(){return o?o.length===0?r?(o=void 0,this.next()):(await new Promise(n=>{s=n}),this.next()):{done:!1,value:await o.shift()}:{done:!0}},async return(n){o=void 0;for(const c of e)T(t,c).delete(i);return s(),arguments.length>0?{done:!0,value:await n}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Q(t){if(t===void 0)return j;if(!Array.isArray(t))throw new TypeError("`methodNames` must be an array of strings");for(const e of t)if(!j.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return t}const F=t=>t===R||t===P;class _{static mixin(e,r){return r=Q(r),s=>{if(typeof s!="function")throw new TypeError("`target` must be function");for(const n of r)if(s.prototype[n]!==void 0)throw new Error(`The property \`${n}\` already exists on \`target\``);function o(){return Object.defineProperty(this,e,{enumerable:!1,value:new _}),this[e]}Object.defineProperty(s.prototype,e,{enumerable:!1,get:o});const i=n=>function(...c){return this[e][n](...c)};for(const n of r)Object.defineProperty(s.prototype,n,{enumerable:!1,value:i(n)});return s}}static get isDebugEnabled(){if(typeof process!="object")return O;const{env:e}=process||{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||O}static set isDebugEnabled(e){O=e}constructor(e={}){d.set(this,new Set),E.set(this,new Map),w.set(this,new Map),this.debug=e.debug||{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(r,s,o,i)=>{try{i=JSON.stringify(i)}catch{i=`Object with the following keys failed to stringify: ${Object.keys(i).join(",")}`}typeof o=="symbol"&&(o=o.toString());const n=new Date,c=`${n.getHours()}:${n.getMinutes()}:${n.getSeconds()}.${n.getMilliseconds()}`;console.log(`[${c}][emittery:${r}][${s}] Event Name: ${o}
|
|
2
|
+
data: ${i}`)})}logIfDebugEnabled(e,r,s){(_.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,r,s)}on(e,r){k(r),e=Array.isArray(e)?e:[e];for(const s of e)y(s),b(this,s).add(r),this.logIfDebugEnabled("subscribe",s,void 0),F(s)||this.emit(R,{eventName:s,listener:r});return this.off.bind(this,e,r)}off(e,r){k(r),e=Array.isArray(e)?e:[e];for(const s of e)y(s),b(this,s).delete(r),this.logIfDebugEnabled("unsubscribe",s,void 0),F(s)||this.emit(P,{eventName:s,listener:r})}once(e){return new Promise(r=>{const s=this.on(e,o=>{s(),r(o)})})}events(e){e=Array.isArray(e)?e:[e];for(const r of e)y(r);return $(this,e)}async emit(e,r){y(e),this.logIfDebugEnabled("emit",e,r),X(this,e,r);const s=b(this,e),o=d.get(this),i=[...s],n=F(e)?[]:[...o];await H,await Promise.all([...i.map(async c=>{if(s.has(c))return c(r)}),...n.map(async c=>{if(o.has(c))return c(e,r)})])}async emitSerial(e,r){y(e),this.logIfDebugEnabled("emitSerial",e,r);const s=b(this,e),o=d.get(this),i=[...s],n=[...o];await H;for(const c of i)s.has(c)&&await c(r);for(const c of n)o.has(c)&&await c(e,r)}onAny(e){return k(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),d.get(this).add(e),this.emit(R,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return $(this)}offAny(e){k(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),this.emit(P,{listener:e}),d.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"){b(this,r).clear();const s=T(this,r);for(const o of s)o.finish();s.clear()}else{d.get(this).clear();for(const s of E.get(this).values())s.clear();for(const s of w.get(this).values()){for(const o of s)o.finish();s.clear()}}}listenerCount(e){e=Array.isArray(e)?e:[e];let r=0;for(const s of e){if(typeof s=="string"){r+=d.get(this).size+b(this,s).size+T(this,s).size+T(this).size;continue}typeof s<"u"&&y(s),r+=d.get(this).size;for(const o of E.get(this).values())r+=o.size;for(const o of w.get(this).values())r+=o.size}return r}bindMethods(e,r){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");r=Q(r);for(const s of r){if(e[s]!==void 0)throw new Error(`The property \`${s}\` already exists on \`target\``);Object.defineProperty(e,s,{enumerable:!1,value:this[s].bind(this)})}}}const j=Object.getOwnPropertyNames(_.prototype).filter(t=>t!=="constructor");Object.defineProperty(_,"listenerAdded",{value:R,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(_,"listenerRemoved",{value:P,writable:!1,enumerable:!0,configurable:!1});var L=_;function Z(t){return typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"}function K(t){if(Z(t))return t;try{return new Error(JSON.stringify(t))}catch{return new Error(String(t))}}function W(t){return K(t).message}var N=Object.defineProperty,ee=(t,e,r)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,re=(t,e,r)=>(ee(t,typeof e!="symbol"?e+"":e,r),r),G=(t=>(t.automation="automation",t.test="test",t.vbc="vbc",t.video="video",t.voice="voice",t))(G||{});const te="hlg.tokbox.com/prod/logging/vcp_webrtc",se="https://",oe=1e4;let A;const ie=new Uint8Array(16);function ne(){if(!A&&(A=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!A))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return A(ie)}const l=[];for(let t=0;t<256;++t)l.push((t+256).toString(16).slice(1));function ae(t,e=0){return(l[t[e+0]]+l[t[e+1]]+l[t[e+2]]+l[t[e+3]]+"-"+l[t[e+4]]+l[t[e+5]]+"-"+l[t[e+6]]+l[t[e+7]]+"-"+l[t[e+8]]+l[t[e+9]]+"-"+l[t[e+10]]+l[t[e+11]]+l[t[e+12]]+l[t[e+13]]+l[t[e+14]]+l[t[e+15]]).toLowerCase()}const ce=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),z={randomUUID:ce};function fe(t,e,r){if(z.randomUUID&&!e&&!t)return z.randomUUID();t=t||{};const s=t.random||(t.rng||ne)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=s[o];return e}return ae(s)}const p={};var g=(t=>(t.INIT="INIT",t.FORWARD="FORWARD",t.TERMINATE="TERMINATE",t.GLOBALS_SYNC="GLOBALS_SYNC",t))(g||{});function B(t){return[ImageBitmap,ReadableStream,WritableStream].some(e=>t instanceof e)}let le=0;function ue(t,e,r,s,o){const i=le++;return t.postMessage({id:i,type:e,functionName:r,args:s},s.filter(n=>B(n))),new Promise(n=>{o==null||o.set(i,n)})}function S(t,e){const{id:r,type:s}=t,o=Array.isArray(e)?e:[e];postMessage({id:r,type:s,result:e},o.filter(i=>B(i)))}const V={};function Y(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function he(){if(Y())S({type:g.GLOBALS_SYNC},p);else{const t=[];for(const e in V){const{worker:r,resolvers:s}=V[e].workerContext;r&&t.push(ue(r,g.GLOBALS_SYNC,"",[p],s))}await Promise.all(t)}}function M(t,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const r in e)delete e[r];for(const r in t)Array.isArray(t[r])?(e[r]=[],M(t[r],e[r])):typeof t[r]=="object"?(e[r]={},M(t[r],e[r])):e[r]=t[r]}async function de(t,e){const{functionName:r,args:s}=t;if(!e.instance)throw"instance not initialized";if(!r)throw"missing function name to call";if(!e.instance[r])throw`undefined function [${r}] in class ${e.instance.constructor.workerId}`;S(t,await e.instance[r](...s!=null?s:[]))}const pe={};function me(t,e){if(!t.args)throw"Missing className while initializing worker";const[r,s]=t.args,o=pe[r];if(o)e.instance=new o(t.args.slice(1));else throw`unknown worker class ${r}`;M(s,p),S(t,typeof e.instance!==void 0)}async function _e(t,e){const{args:r}=t;if(!e.instance)throw"instance not initialized";let s;e.instance.terminate&&(s=await e.instance.terminate(...r!=null?r:[])),S(t,s)}function ge(t){if(!t.args)throw"Missing globals while syncing";M(t.args[0],p),S(t,{})}function ye(){const t={};onmessage=async e=>{const r=e.data;switch(r.type){case g.INIT:me(r,t);break;case g.FORWARD:de(r,t);break;case g.TERMINATE:_e(r,t);break;case g.GLOBALS_SYNC:ge(r);break}}}Y()&&ye();function be(t,e){return p[t]||(p[t]=e),[()=>p[t],async r=>{p[t]=r,await he()}]}function we(t,e){return be(t,e)}const[Te,Se]=we("metadata");function Ee(t){Se(t)}function I(){return Te()}class D{constructor(e){re(this,"uuid",fe()),this.config=e}async send(e){var r,s,o;const{appId:i,sourceType:n}=(r=I())!=null?r:{};if(!i||!n)return"metadata missing";const c=new AbortController,m=setTimeout(()=>c.abort(),oe);return await((o=(s=this.config)==null?void 0:s.fetch)!=null?o:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:c.signal}),clearTimeout(m),"success"}getUrl(){var e;let r=(e=I().proxyUrl)!=null?e:se;return r+=(r.at(-1)==="/"?"":"/")+te,r}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const r=I();return{guid:this.uuid,...e,applicationId:r.appId,timestamp:Date.now(),proxyUrl:r.proxyUrl,source:r.sourceType}}}const x="2.0.1";class Re{constructor(e){a(this,"frameTransformedCount",0);a(this,"frameFromSourceCount",0);a(this,"startAt",0);a(this,"reporter");this.config=e,this.reporter=new D(e)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:r}=this,o=(Date.now()-e)/1e3;return r/o}async onFrameTransformed(e={},r=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:s,frameTransformedCount:o,frameFromSourceCount:i}=this,n=Date.now(),c=(n-s)/1e3,m=o/c,U=i/c;return r||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=n,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:U,transformedFps:m,framesTransformed:o,...e})):"success"}}var q=(t=>(t.FPS_DROP="fps_drop",t))(q||{}),J=(t=>(t.start="start",t.transform="transform",t.flush="flush",t))(J||{}),v=(t=>(t.pipeline_ended="pipeline_ended",t.pipeline_ended_with_error="pipeline_ended_with_error",t.pipeline_started="pipeline_started",t.pipeline_started_with_error="pipeline_started_with_error",t.pipeline_restarted="pipeline_restarted",t.pipeline_restarted_with_error="pipeline_restarted_with_error",t))(v||{});const Pe=500,ke=.8;class Ae extends L{constructor(r,s){super();a(this,"reporter_",new D);a(this,"reporterQos_",new Re({loggingIntervalFrameCount:Pe,report:{version:x}}));a(this,"transformerType_");a(this,"transformer_");a(this,"shouldStop_");a(this,"isFlashed_");a(this,"mediaTransformerQosReportStartTimestamp_");a(this,"videoHeight_");a(this,"videoWidth_");a(this,"trackExpectedRate_");a(this,"index_");a(this,"controller_");this.index_=s,this.transformer_=r,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in r&&(this.transformerType_=r.getTransformerType()),this.report({variation:"Create"})}setTrackExpectedRate(r){this.trackExpectedRate_=r}async start(r){if(this.controller_=r,this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(r)}catch(s){this.report({message:u.errors.transformer_start,variation:"Error",error:W(s)});const o={eventMetaData:{transformerIndex:this.index_},error:s,function:"start"};this.emit("error",o)}}async transform(r,s){var o,i,n,c;if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),r instanceof VideoFrame&&(this.videoHeight_=(o=r==null?void 0:r.displayHeight)!=null?o:0,this.videoWidth_=(i=r==null?void 0:r.displayWidth)!=null?i:0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),r.close(),this.flush(s),s.terminate();else{try{await((c=(n=this.transformer_).transform)==null?void 0:c.call(n,r,s)),this.reportQos()}catch(m){this.report({message:u.errors.transformer_transform,variation:"Error",error:W(m)});const U={eventMetaData:{transformerIndex:this.index_},error:m,function:"transform"};this.emit("error",U)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*ke>this.reporterQos_.fps){const m={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",m)}}}async flush(r){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(r)}catch(s){this.report({message:u.errors.transformer_flush,variation:"Error",error:W(s)});const o={eventMetaData:{transformerIndex:this.index_},error:s,function:"flush"};this.emit("error",o)}}this.reportQos(!0),this.report({variation:"Delete"})}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),this.shouldStop_=!0}report(r){this.reporter_.send({version:x,action:"MediaTransformer",transformerType:this.transformerType_,...r})}reportQos(r=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:x,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},r)}}class Me extends L{constructor(r){super();a(this,"transformers_");a(this,"trackExpectedRate_");this.transformers_=[],this.trackExpectedRate_=-1;for(let s=0;s<r.length;s++){let o=new Ae(r[s],s);o.on("error",i=>{this.emit("error",i)}),o.on("warn",i=>{this.emit("warn",i)}),this.transformers_.push(o)}}setTrackExpectedRate(r){this.trackExpectedRate_=r;for(let s of this.transformers_)s.setTrackExpectedRate(this.trackExpectedRate_)}async start(r,s){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let o=r;for(let i of this.transformers_)r=r.pipeThrough(new TransformStream(i));r.pipeTo(s).then(async()=>{console.log("[Pipeline] Setup."),await s.abort(),await o.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async i=>{r.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(n=>{console.error("[Pipeline] Error from stream transform:",n)}),await s.abort(i),await o.cancel(i),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{this.emit("pipelineInfo","pipeline_started_with_error"),this.destroy();return}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let r of this.transformers_)r.stop()}}class Ie extends L{constructor(){super();a(this,"reporter_");a(this,"pipeline_");a(this,"transformers_");a(this,"readable_");a(this,"writable_");a(this,"trackExpectedRate_");this.reporter_=new D,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(r){this.trackExpectedRate_=r,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}transform(r,s){return this.readable_=r,this.writable_=s,this.transformInternal()}transformInternal(){return new Promise(async(r,s)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:u.errors.transformer_none,variation:"Error"}),s("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:u.errors.readable_null}),s("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:u.errors.writable_null}),s("[MediaProcessor] Writable is null.");return}let o=!1;this.pipeline_&&(o=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Me(this.transformers_),this.pipeline_.on("warn",i=>{this.emit("warn",i)}),this.pipeline_.on("error",i=>{this.emit("error",i)}),this.pipeline_.on("pipelineInfo",i=>{o&&(i==="pipeline_started"?i=v.pipeline_restarted:i==="pipeline_started_with_error"&&(i=v.pipeline_restarted_with_error)),this.emit("pipelineInfo",i)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{r()}).catch(i=>{s(i)})})}setTransformers(r){return this.report({variation:"Update",message:u.updates.transformer_new}),this.transformers_=r,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async r=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),r()})}report(r){this.reporter_.send({version:x,action:"MediaProcessor",...r})}}class xe{constructor(){a(this,"processor_");a(this,"generator_");this.processor_=null,this.generator_=null}init(e){return new Promise((r,s)=>{try{this.processor_=new MediaStreamTrackProcessor(e)}catch(o){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${o}`),s(o)}try{e.kind==="audio"?this.generator_=new MediaStreamTrackGenerator({kind:"audio"}):e.kind==="video"?this.generator_=new MediaStreamTrackGenerator({kind:"video"}):s("kind not supported")}catch(o){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${o}`),s(o)}r()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class ve{constructor(e){a(this,"insertableStreamHelper_");a(this,"mediaProcessor_");this.insertableStreamHelper_=new xe,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(o=>{s(o)})}).catch(o=>{s(o)})})}destroy(){return new Promise((e,r)=>{this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>{e()}).catch(s=>{r(s)}):r("no processor")})}}f.ErrorFunction=J,f.MediaProcessor=Ie,f.MediaProcessorConnector=ve,f.PipelineInfoData=v,f.VonageSourceType=G,f.WarningType=q,f.getVonageMetadata=I,f.isSupported=h,f.setVonageMetadata=Ee,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isSupported } from "./src/utils/utils";
|
|
2
|
+
import MediaProcessor from "./src/core/MediaProcessor";
|
|
3
|
+
import MediaProcessorConnector from "./src/core/MediaProcessorConnector";
|
|
4
|
+
import { WarningType, PipelineInfoData, ErrorFunction } from "./src/core/pipeline";
|
|
5
|
+
import { setVonageMetadata, getVonageMetadata, SourceType as VonageSourceType } from "@vonage/js-onewebrtc-telemetry";
|
|
6
|
+
export type { VonageMetadata } from "@vonage/js-onewebrtc-telemetry";
|
|
7
|
+
export type { MediaProcessorConnectorInterface } from "./src/core/MediaProcessorConnectorInterface";
|
|
8
|
+
export type { MediaProcessorInterface } from "./src/core/MediaProcessorInterface";
|
|
9
|
+
export type { EventDataMap, WarnData, ErrorData, EventMetaData, DropInfo, } from "./src/core/pipeline";
|
|
10
|
+
export { isSupported, MediaProcessor, MediaProcessorConnector, VonageSourceType, WarningType, PipelineInfoData, ErrorFunction, setVonageMetadata, getVonageMetadata, };
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Pipeline, { EventDataMap } from './pipeline';
|
|
2
2
|
import Emittery from 'emittery';
|
|
3
3
|
import { MediaProcessorInterface } from './MediaProcessorInterface';
|
|
4
|
+
import { Reporter } from "@vonage/js-onewebrtc-telemetry";
|
|
4
5
|
/**
|
|
5
6
|
* Media processor class holding and running insertable streams pipeline.
|
|
6
7
|
* The class should be created on the proper thread.
|
|
@@ -12,7 +13,7 @@ declare class MediaProcessor extends Emittery<EventDataMap> implements MediaProc
|
|
|
12
13
|
/**
|
|
13
14
|
* @private
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
reporter_: Reporter;
|
|
16
17
|
/**
|
|
17
18
|
* @private
|
|
18
19
|
*/
|
|
@@ -76,5 +77,6 @@ declare class MediaProcessor extends Emittery<EventDataMap> implements MediaProc
|
|
|
76
77
|
* @returns
|
|
77
78
|
*/
|
|
78
79
|
destroy(): Promise<void>;
|
|
80
|
+
private report;
|
|
79
81
|
}
|
|
80
82
|
export default MediaProcessor;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -134,14 +134,12 @@ export declare type EventDataMap = {
|
|
|
134
134
|
pipelineInfo: PipelineInfoData;
|
|
135
135
|
};
|
|
136
136
|
declare class InternalTransformer extends Emittery<EventDataMap> implements Transformer {
|
|
137
|
-
|
|
137
|
+
private reporter_;
|
|
138
|
+
private reporterQos_;
|
|
138
139
|
transformerType_: string;
|
|
139
|
-
fps_: number;
|
|
140
|
-
framesTransformed_: number;
|
|
141
140
|
transformer_: Transformer;
|
|
142
141
|
shouldStop_: boolean;
|
|
143
142
|
isFlashed_: boolean;
|
|
144
|
-
framesFromSource_: number;
|
|
145
143
|
mediaTransformerQosReportStartTimestamp_: number;
|
|
146
144
|
videoHeight_: number;
|
|
147
145
|
videoWidth_: number;
|
|
@@ -154,7 +152,8 @@ declare class InternalTransformer extends Emittery<EventDataMap> implements Tran
|
|
|
154
152
|
transform(data: VideoFrame | AudioData, controller: TransformStreamDefaultController): Promise<void>;
|
|
155
153
|
flush(controller: TransformStreamDefaultController): Promise<void>;
|
|
156
154
|
stop(): void;
|
|
157
|
-
|
|
155
|
+
private report;
|
|
156
|
+
private reportQos;
|
|
158
157
|
}
|
|
159
158
|
declare class Pipeline extends Emittery<EventDataMap> {
|
|
160
159
|
transformers_: Array<InternalTransformer>;
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReporterConfig, SendableReport } from "@vonage/js-onewebrtc-telemetry";
|
|
2
|
+
export interface QosReporterConfig extends ReporterConfig {
|
|
3
|
+
/**
|
|
4
|
+
* Amount of frame to receive before logging the qos telemetry
|
|
5
|
+
*/
|
|
6
|
+
loggingIntervalFrameCount: number;
|
|
7
|
+
/**
|
|
8
|
+
* Report template use to construct all telemetry sent
|
|
9
|
+
*/
|
|
10
|
+
report: SendableReport;
|
|
11
|
+
}
|
|
12
|
+
export declare class QosReporter {
|
|
13
|
+
config: QosReporterConfig;
|
|
14
|
+
private frameTransformedCount;
|
|
15
|
+
private frameFromSourceCount;
|
|
16
|
+
private startAt;
|
|
17
|
+
private reporter;
|
|
18
|
+
constructor(config: QosReporterConfig);
|
|
19
|
+
onFrameFromSource(): Promise<void>;
|
|
20
|
+
get fps(): number;
|
|
21
|
+
onFrameTransformed(report?: Partial<SendableReport>, forceSend?: boolean): Promise<string>;
|
|
22
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,65 +1,75 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
"name": "@vonage/media-processor",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"author": "Guy Mininberg <guy.mininberg@vonage.com>",
|
|
5
|
+
"contributors": [
|
|
6
|
+
"Guy Mininberg <guy.mininberg@vonage.com>",
|
|
7
|
+
"Jose Olivera <joseantonio.oliveraortega@vonage.com>"
|
|
8
|
+
],
|
|
9
|
+
"keywords": [
|
|
10
|
+
"vonage",
|
|
11
|
+
"vonage api",
|
|
12
|
+
"client",
|
|
13
|
+
"media processing",
|
|
14
|
+
"insertable streams",
|
|
15
|
+
"opentok",
|
|
16
|
+
"nexmo"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "npm-run-all build:js build:static doc",
|
|
20
|
+
"build:js": "vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types",
|
|
21
|
+
"build:dev": "vite build --mode development && tsc --declaration --emitDeclarationOnly --outDir dist/types",
|
|
22
|
+
"build:static": "node ./scripts/build-static.js && minify ./dist/media-processor.static.js > ./dist/media-processor.min.js ",
|
|
23
|
+
"doc": "typedoc --excludePrivate --excludeProtected --disableSources --out dist/docs lib/main.ts",
|
|
24
|
+
"dev": "vite",
|
|
25
|
+
"preview": "vite preview",
|
|
26
|
+
"test": "vitest --run --threads false"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@types/dom-mediacapture-transform": "^0.1.2",
|
|
30
|
+
"@types/emscripten": "^1.39.6",
|
|
31
|
+
"@types/node": "^17.0.10",
|
|
32
|
+
"@types/offscreencanvas": "^2019.6.4",
|
|
33
|
+
"@types/uuid": "^8.3.4",
|
|
34
|
+
"@vonage/js-onewebrtc-telemetry": "1.1.0",
|
|
35
|
+
"axios": "^0.25.0",
|
|
36
|
+
"emittery": "^0.10.1",
|
|
37
|
+
"typescript-optional": "3.0.0-alpha.3",
|
|
38
|
+
"uuid": "~8.3.2"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"types": "./dist/types/main.d.ts",
|
|
44
|
+
"main": "./dist/media-processor.umd.js",
|
|
45
|
+
"module": "./dist/media-processor.es.js",
|
|
46
|
+
"exports": {
|
|
47
|
+
".": {
|
|
48
|
+
"import": "./dist/media-processor.es.js",
|
|
49
|
+
"require": "./dist/media-processor.umd.js"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@tsconfig/node12": "^1.0.1",
|
|
54
|
+
"@types/chai": "^4.3.3",
|
|
55
|
+
"@types/mocha": "^10.0.0",
|
|
56
|
+
"@types/puppeteer": "^5.4.7",
|
|
57
|
+
"@types/rimraf": "^3.0.2",
|
|
58
|
+
"@vitest/ui": "^0.24.3",
|
|
59
|
+
"chai": "^4.3.6",
|
|
60
|
+
"chai-image": "file:./lib/libs/chai-image-3.0.0.tgz",
|
|
61
|
+
"minify": "^9.1.0",
|
|
62
|
+
"mocha": "^10.1.0",
|
|
63
|
+
"npm-run-all": "^4.1.5",
|
|
64
|
+
"puppeteer": "^19.0.0",
|
|
65
|
+
"rimraf": "^3.0.2",
|
|
66
|
+
"typedoc": "^0.22.12",
|
|
67
|
+
"typescript": "^4.6.2",
|
|
68
|
+
"vite": "^3.1.8",
|
|
69
|
+
"vitest": "^0.24.3"
|
|
70
|
+
},
|
|
71
|
+
"repository": "https://github.com/Vonage/vonage-media-transformers-samples",
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"registry": "https://registry.npmjs.org"
|
|
49
74
|
}
|
|
50
|
-
},
|
|
51
|
-
"devDependencies": {
|
|
52
|
-
"@tsconfig/node12": "^1.0.1",
|
|
53
|
-
"@types/cypress-image-snapshot": "3.1.6",
|
|
54
|
-
"cypress": "9.5.2",
|
|
55
|
-
"cypress-image-snapshot": "4.0.1",
|
|
56
|
-
"npm-run-all": "^4.1.5",
|
|
57
|
-
"typedoc": "^0.22.12",
|
|
58
|
-
"typescript": "^4.6.2",
|
|
59
|
-
"vite": "^2.7.2"
|
|
60
|
-
},
|
|
61
|
-
"repository": "https://github.com/Vonage/vonage-media-transformers-samples",
|
|
62
|
-
"publishConfig": {
|
|
63
|
-
"registry": "https://registry.npmjs.org"
|
|
64
|
-
}
|
|
65
75
|
}
|
package/dist/types/main.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isSupported } from './src/utils/utils';
|
|
2
|
-
import MediaProcessor from './src/core/MediaProcessor';
|
|
3
|
-
import MediaProcessorConnector from './src/core/MediaProcessorConnector';
|
|
4
|
-
import { getVonageMetadata, setVonageMetadata } from './src/telemetry/Reporter';
|
|
5
|
-
import { VonageSourceType } from './src/telemetry/Reporter';
|
|
6
|
-
import { WarningType, PipelineInfoData, ErrorFunction } from './src/core/pipeline';
|
|
7
|
-
export type { MediaProcessorConnectorInterface } from './src/core/MediaProcessorConnectorInterface';
|
|
8
|
-
export type { MediaProcessorInterface } from './src/core/MediaProcessorInterface';
|
|
9
|
-
export type { VonageMetadata } from './src/telemetry/Reporter';
|
|
10
|
-
export type { EventDataMap, WarnData, ErrorData, EventMetaData, DropInfo } from './src/core/pipeline';
|
|
11
|
-
export { isSupported, MediaProcessor, MediaProcessorConnector, getVonageMetadata, setVonageMetadata, VonageSourceType, WarningType, PipelineInfoData, ErrorFunction };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { Optional } from 'typescript-optional';
|
|
2
|
-
/**
|
|
3
|
-
* Enumeration listing all possible users or consumers of this library.
|
|
4
|
-
*/
|
|
5
|
-
export declare enum VonageSourceType {
|
|
6
|
-
/**
|
|
7
|
-
* @private
|
|
8
|
-
*/
|
|
9
|
-
automation = "automation",
|
|
10
|
-
/**
|
|
11
|
-
* @private
|
|
12
|
-
*/
|
|
13
|
-
test = "test",
|
|
14
|
-
/**
|
|
15
|
-
* @private
|
|
16
|
-
*/
|
|
17
|
-
vbc = "vbc",
|
|
18
|
-
/**
|
|
19
|
-
* For Vonage Video SDK users.
|
|
20
|
-
*/
|
|
21
|
-
video = "video",
|
|
22
|
-
/**
|
|
23
|
-
* For Vonage Voice SDK users.
|
|
24
|
-
*/
|
|
25
|
-
voice = "voice"
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Specifies the addional information being sent with the telemetry collected by the library.
|
|
29
|
-
*/
|
|
30
|
-
export declare type VonageMetadata = {
|
|
31
|
-
/**
|
|
32
|
-
* Type of source using the library.
|
|
33
|
-
*/
|
|
34
|
-
sourceType: VonageSourceType;
|
|
35
|
-
/**
|
|
36
|
-
* Some string identifier identifying the application using the library.
|
|
37
|
-
*/
|
|
38
|
-
appId: string;
|
|
39
|
-
/**
|
|
40
|
-
* The proxy URL to route all internet traffic generated by this library. This field is optional.
|
|
41
|
-
*/
|
|
42
|
-
proxyUrl?: string;
|
|
43
|
-
};
|
|
44
|
-
declare global {
|
|
45
|
-
var _vonageMediaProcessorMetadata: VonageMetadata;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Sets some metadata for telemetry.
|
|
49
|
-
* An example can be found [here](/docs/intro.md#statistics).
|
|
50
|
-
*
|
|
51
|
-
* @param metadata Specifies the addional information being sent with the telemetry collected by the library.
|
|
52
|
-
* If metadata is either undefined or not set the library will not collect/send any telemetry.
|
|
53
|
-
*/
|
|
54
|
-
export declare function setVonageMetadata(metadata: VonageMetadata): void;
|
|
55
|
-
/**
|
|
56
|
-
* @private
|
|
57
|
-
*/
|
|
58
|
-
export declare function getVonageMetadata(): VonageMetadata;
|
|
59
|
-
interface Report {
|
|
60
|
-
action: Optional<string>;
|
|
61
|
-
applicationId: Optional<string>;
|
|
62
|
-
timestamp: number;
|
|
63
|
-
fps: Optional<number>;
|
|
64
|
-
framesTransformed: Optional<number>;
|
|
65
|
-
guid: Optional<string>;
|
|
66
|
-
highestFrameTransformCpu: Optional<number>;
|
|
67
|
-
message: Optional<string>;
|
|
68
|
-
source: Optional<string>;
|
|
69
|
-
transformedFps: Optional<number>;
|
|
70
|
-
transformerType: Optional<string>;
|
|
71
|
-
variation: Optional<string>;
|
|
72
|
-
videoHeight: Optional<number>;
|
|
73
|
-
videoWidth: Optional<number>;
|
|
74
|
-
version: string;
|
|
75
|
-
error: Optional<string>;
|
|
76
|
-
proxyUrl: Optional<string>;
|
|
77
|
-
}
|
|
78
|
-
declare class ReportBuilder {
|
|
79
|
-
private readonly _report;
|
|
80
|
-
constructor();
|
|
81
|
-
action(action: string): this;
|
|
82
|
-
framesTransformed(framesTransformed: number): this;
|
|
83
|
-
fps(fps: number): this;
|
|
84
|
-
guid(guid: string): this;
|
|
85
|
-
message(message: string): this;
|
|
86
|
-
transformedFps(transformedFps: number): this;
|
|
87
|
-
transformerType(transformerType: string): this;
|
|
88
|
-
variation(variation: string): this;
|
|
89
|
-
videoHeight(videoHeight: number): this;
|
|
90
|
-
videoWidth(videoWidth: number): this;
|
|
91
|
-
error(error: string): this;
|
|
92
|
-
build(): Report;
|
|
93
|
-
}
|
|
94
|
-
declare class Reporter {
|
|
95
|
-
static report(report: Report): Promise<any>;
|
|
96
|
-
}
|
|
97
|
-
export { Report, ReportBuilder, Reporter };
|