@vonage/media-processor 1.2.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/docs/assets/highlight.css +13 -27
- package/dist/docs/assets/main.js +2 -2
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/assets/style.css +3 -2
- package/dist/docs/classes/MediaProcessor.html +51 -43
- package/dist/docs/classes/MediaProcessorConnector.html +12 -12
- package/dist/docs/enums/ErrorFunction.html +9 -0
- package/dist/docs/enums/PipelineInfoData.html +19 -0
- package/dist/docs/enums/VonageSourceType.html +7 -0
- package/dist/docs/enums/WarningType.html +5 -0
- package/dist/docs/index.html +4 -3
- package/dist/docs/interfaces/MediaProcessorConnectorInterface.html +4 -10
- package/dist/docs/interfaces/MediaProcessorInterface.html +17 -7
- package/dist/docs/modules.html +41 -34
- package/dist/media-processor.es.js +121 -29
- package/dist/media-processor.umd.js +3 -3
- package/dist/types/main.d.ts +5 -3
- package/dist/types/src/core/MediaProcessor.d.ts +21 -18
- package/dist/types/src/core/MediaProcessorConnector.d.ts +12 -52
- package/dist/types/src/core/MediaProcessorConnectorInterface.d.ts +4 -1
- package/dist/types/src/core/MediaProcessorInterface.d.ts +7 -0
- package/dist/types/src/core/pipeline.d.ts +89 -37
- package/dist/types/src/telemetry/Reporter.d.ts +30 -13
- package/package.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(
|
|
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]&&Rr.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,xr=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 B=ie,H=p,Or=br,Ar=vr,Cr=Te,Mr=Sr,$r=Pr,kr=xr,oe=Re,Ur=J,Ir=B,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=Mr(e.baseURL,e.url);u.open(e.method.toUpperCase(),Cr(y,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function Qe(){if(!!u){var v="getAllResponseHeaders"in u?$r(u.getAllResponseHeaders()):null,U=!a||a==="text"||a==="json"?u.responseText:u.response,O={data:U,status:u.status,statusText:u.statusText,headers:v,config:e,request:u};Or(function(ge){n(ge),m()},function(ge){s(ge),m()},O),u=null}}if("onloadend"in u?u.onloadend=Qe:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(Qe)},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 U=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",O=e.transitional||Ur.transitional;e.timeoutErrorMessage&&(U=e.timeoutErrorMessage),s(oe(U,e,O.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},H.isStandardBrowserEnv()){var Xe=(e.withCredentials||kr(y))&&e.xsrfCookieName?Ar.read(e.xsrfCookieName):void 0;Xe&&(o[e.xsrfHeaderName]=Xe)}"setRequestHeader"in u&&H.forEach(o,function(U,O){typeof i=="undefined"&&O.toLowerCase()==="content-type"?delete o[O]:u.setRequestHeader(O,U)}),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=mr,Dr=Se,Lr={"Content-Type":"application/x-www-form-urlencoded"};function Ae(t,e){!d.isUndefined(t)&&d.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Nr(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=xe),t}function jr(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:Nr(),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"),jr(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"?Dr(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(Lr)});var J=W,Fr=p,qr=J,Br=function(e,r,n){var s=this||qr;return Fr.forEach(n,function(o){e=o.call(s,e,r)}),e},Ce=function(e){return!!(e&&e.__CANCEL__)},Me=p,ae=Br,Hr=Ce,Wr=J,Jr=B;function ue(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Jr("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||Wr.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 Hr(s)||(ue(e),s&&s.response&&(s.response.data=ae.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})},g=p,$e=function(e,r){r=r||{};var n={};function s(u,c){return g.isPlainObject(u)&&g.isPlainObject(c)?g.merge(u,c):g.isPlainObject(c)?g.merge({},c):g.isArray(c)?c.slice():c}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 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 g.forEach(Object.keys(e).concat(Object.keys(r)),function(c){var T=m[c]||i,y=T(c);g.isUndefined(y)&&T!==l||(n[c]=y)}),n},ke={version:"0.25.0"},zr=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"+zr+"] 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 Gr(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 Qr={assertOptions:Gr,validators:fe},Ie=p,Xr=Te,De=hr,Le=Vr,V=$e,Ne=Qr,C=Ne.validators;function D(t){this.defaults=t,this.interceptors={request:new De,response:new De}}D.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=V(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},D.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=V(this.defaults,e),Xr(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},Ie.forEach(["delete","get","head","options"],function(e){D.prototype[e]=function(r,n){return this.request(V(n||{},{method:e,url:r,data:(n||{}).data}))}}),Ie.forEach(["post","put","patch"],function(e){D.prototype[e]=function(r,n,s){return this.request(V(s||{},{method:e,url:r,data:n}))}});var Kr=D,Yr=B;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 Yr(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 Zr=M,et=function(e){return function(n){return e.apply(null,n)}},rt=p,tt=function(e){return rt.isObject(e)&&e.isAxiosError===!0},je=p,nt=be,z=Kr,st=$e,it=J;function Fe(t){var e=new z(t),r=nt(z.prototype.request,e);return je.extend(r,z.prototype,e),je.extend(r,e),r.create=function(s){return Fe(st(t,s))},r}var w=Fe(it);w.Axios=z,w.Cancel=B,w.CancelToken=Zr,w.isCancel=Ce,w.VERSION=ke.version,w.all=function(e){return Promise.all(e)},w.spread=et,w.isAxiosError=tt,Z.exports=w,Z.exports.default=w;var ot=Z.exports;class f{isEmpty(){return!this.isPresent()}static of(e){if(e!=null)return new qe(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 qe(e):new Be}static empty(){return new Be}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 qe 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 Be 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 at="1.2.5";function ut(t){globalThis._vonageMediaProcessorMetadata=t}function He(){return globalThis._vonageMediaProcessorMetadata}class _{constructor(){const e=He();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:at,error:f.empty(),proxyUrl:f.ofNullable(e!==void 0&&e!=null?e.proxyUrl:null)}}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 ft=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=ot.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,ft(e),i).then(a=>{console.log(a),r("success")}).catch(a=>{console.log(a),n(a)})})}}var G,lt=new Uint8Array(16);function ct(){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(lt)}var dt=/^(?:[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 ht(t){return typeof t=="string"&&dt.test(t)}for(var h=[],le=0;le<256;++le)h.push((le+256).toString(16).substr(1));function pt(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(!ht(r))throw TypeError("Stringified UUID is invalid");return r}function We(t,e,r){t=t||{};var n=t.random||(t.rng||ct)();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 pt(n)}const R=new WeakMap,Q=new WeakMap,L=new WeakMap,ce=Symbol("anyProducer"),Je=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 mt(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 ze(t){if(t===void 0)return Ge;if(!Array.isArray(t))throw new TypeError("`methodNames` must be an array of strings");for(const e of t)if(!Ge.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=ze(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),mt(this,e,r);const n=k(this,e),s=R.get(this),i=[...n],o=he(e)?[]:[...s];await Je,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 Je;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=ze(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 Ge=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 yt(t){return typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"}function gt(t){if(yt(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 bt=500,vt=.8;class wt extends pe{constructor(e,r){super();this.index_=r,this.uuid_=We(),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()),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_)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_===bt&&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_*vt>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 _t extends pe{constructor(e){super();this.transformers_=[],this.trackExpectedRate_=-1;for(let r=0;r<e.length;r++){let n=new wt(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",{message:"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",{message:"pipeline_ended_with_error"})})}catch{this.emit("pipelineInfo",{message:"pipeline_started_with_error"}),this.destroy();return}this.emit("pipelineInfo",{message:"pipeline_started"}),console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Et extends pe{constructor(){super();this.uuid_=We(),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 _t(this.transformers_),this.pipeline_.on("warn",n=>{this.emit("warn",n)}),this.pipeline_.on("error",n=>{this.emit("error",n)}),this.pipeline_.on("pipelineInfo",n=>{this.emit("pipelineInfo",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 Tt{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 St{constructor(e){this.insertableStreamHelper_=new Tt,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")})}}b.MediaProcessor=Et,b.MediaProcessorConnector=St,b.getVonageMetadata=He,b.isSupported=I,b.setVonageMetadata=ut,Object.defineProperty(b,"__esModule",{value:!0}),b[Symbol.toStringTag]="Module"});
|
|
1
|
+
(function(p,I){typeof exports=="object"&&typeof module!="undefined"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(p=typeof globalThis!="undefined"?globalThis:p||self,I(p["media-processor"]={}))})(this,function(p){"use strict";function I(){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 S{}S.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},S.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"};var ee={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)}},er=ge,R=Object.prototype.toString;function re(t){return Array.isArray(t)}function te(t){return typeof t=="undefined"}function rr(t){return t!==null&&!te(t)&&t.constructor!==null&&!te(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function _e(t){return R.call(t)==="[object ArrayBuffer]"}function tr(t){return R.call(t)==="[object FormData]"}function nr(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&_e(t.buffer),e}function sr(t){return typeof t=="string"}function ir(t){return typeof t=="number"}function ve(t){return t!==null&&typeof t=="object"}function j(t){if(R.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function or(t){return R.call(t)==="[object Date]"}function ar(t){return R.call(t)==="[object File]"}function ur(t){return R.call(t)==="[object Blob]"}function we(t){return R.call(t)==="[object Function]"}function lr(t){return ve(t)&&we(t.pipe)}function fr(t){return R.call(t)==="[object URLSearchParams]"}function dr(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function cr(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function ne(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),re(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 se(){var t={};function e(s,i){j(t[i])&&j(s)?t[i]=se(t[i],s):j(s)?t[i]=se({},s):re(s)?t[i]=s.slice():t[i]=s}for(var r=0,n=arguments.length;r<n;r++)ne(arguments[r],e);return t}function hr(t,e,r){return ne(e,function(s,i){r&&typeof s=="function"?t[i]=er(s,r):t[i]=s}),t}function pr(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var m={isArray:re,isArrayBuffer:_e,isBuffer:rr,isFormData:tr,isArrayBufferView:nr,isString:sr,isNumber:ir,isObject:ve,isPlainObject:j,isUndefined:te,isDate:or,isFile:ar,isBlob:ur,isFunction:we,isStream:lr,isURLSearchParams:fr,isStandardBrowserEnv:cr,forEach:ne,merge:se,extend:hr,trim:dr,stripBOM:pr},A=m;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(f,y){f===null||typeof f=="undefined"||(A.isArray(f)?y=y+"[]":f=[f],A.forEach(f,function(d){A.isDate(d)?d=d.toISOString():A.isObject(d)&&(d=JSON.stringify(d)),i.push(Ee(y)+"="+Ee(d))}))}),s=i.join("&")}if(s){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e},mr=m;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){mr.forEach(this.handlers,function(n){n!==null&&e(n)})};var yr=q,br=m,gr=function(e,r){br.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},_r=Se,Re=function(e,r,n,s,i){var o=new Error(e);return _r(o,r,n,s,i)},vr=Re,wr=function(e,r,n){var s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):r(vr("Request failed with status code "+n.status,n.config,null,n.request,n))},B=m,Er=B.isStandardBrowserEnv()?function(){return{write:function(r,n,s,i,o,a){var f=[];f.push(r+"="+encodeURIComponent(n)),B.isNumber(s)&&f.push("expires="+new Date(s).toGMTString()),B.isString(i)&&f.push("path="+i),B.isString(o)&&f.push("domain="+o),a===!0&&f.push("secure"),document.cookie=f.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(){}}}(),Tr=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},Sr=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},Rr=Tr,Pr=Sr,xr=function(e,r){return e&&!Rr(r)?Pr(e,r):r},ie=m,Or=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],Ar=function(e){var r={},n,s,i;return e&&ie.forEach(e.split(`
|
|
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"});
|
package/dist/types/main.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { isSupported } from './src/utils/utils';
|
|
|
2
2
|
import MediaProcessor from './src/core/MediaProcessor';
|
|
3
3
|
import MediaProcessorConnector from './src/core/MediaProcessorConnector';
|
|
4
4
|
import { getVonageMetadata, setVonageMetadata } from './src/telemetry/Reporter';
|
|
5
|
+
import { VonageSourceType } from './src/telemetry/Reporter';
|
|
6
|
+
import { WarningType, PipelineInfoData, ErrorFunction } from './src/core/pipeline';
|
|
5
7
|
export type { MediaProcessorConnectorInterface } from './src/core/MediaProcessorConnectorInterface';
|
|
6
8
|
export type { MediaProcessorInterface } from './src/core/MediaProcessorInterface';
|
|
7
|
-
export type { VonageMetadata
|
|
8
|
-
export type { EventDataMap, WarnData, ErrorData,
|
|
9
|
-
export { isSupported, MediaProcessor, MediaProcessorConnector, getVonageMetadata, setVonageMetadata };
|
|
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,21 +1,14 @@
|
|
|
1
1
|
import Pipeline, { EventDataMap } from './pipeline';
|
|
2
2
|
import Emittery from 'emittery';
|
|
3
|
+
import { MediaProcessorInterface } from './MediaProcessorInterface';
|
|
3
4
|
/**
|
|
4
|
-
* Media processor class holding and running
|
|
5
|
-
* The class
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* let mediaProcessor: MediaProcessor = new MediaProcessor();
|
|
11
|
-
* let transformers: Array<Transformer> = [];
|
|
12
|
-
* transformers.push(new CanvasTransform());
|
|
13
|
-
* mediaProcessor.setTransformers(transformers);
|
|
14
|
-
* mediaProcessor.on('error',(ErrorData => {}))
|
|
15
|
-
* mediaProcessor.on('warn',(WarnData => {}))
|
|
16
|
-
* ```
|
|
5
|
+
* Media processor class holding and running insertable streams pipeline.
|
|
6
|
+
* The class should be created on the proper thread.
|
|
7
|
+
* Options are:
|
|
8
|
+
* - Application main thread when media processing wants to be performed in the main thread.
|
|
9
|
+
* - Worker thread when media processing wants to be performed in a Web worker thread.
|
|
17
10
|
*/
|
|
18
|
-
declare class MediaProcessor extends Emittery<EventDataMap> {
|
|
11
|
+
declare class MediaProcessor extends Emittery<EventDataMap> implements MediaProcessorInterface {
|
|
19
12
|
/**
|
|
20
13
|
* @private
|
|
21
14
|
*/
|
|
@@ -23,19 +16,19 @@ declare class MediaProcessor extends Emittery<EventDataMap> {
|
|
|
23
16
|
/**
|
|
24
17
|
* @private
|
|
25
18
|
*/
|
|
26
|
-
pipeline_
|
|
19
|
+
pipeline_?: Pipeline;
|
|
27
20
|
/**
|
|
28
21
|
* @private
|
|
29
22
|
*/
|
|
30
|
-
transformers_
|
|
23
|
+
transformers_?: Array<Transformer>;
|
|
31
24
|
/**
|
|
32
25
|
* @private
|
|
33
26
|
*/
|
|
34
|
-
readable_
|
|
27
|
+
readable_?: ReadableStream;
|
|
35
28
|
/**
|
|
36
29
|
* @private
|
|
37
30
|
*/
|
|
38
|
-
writable_
|
|
31
|
+
writable_?: WritableStream;
|
|
39
32
|
/**
|
|
40
33
|
* @private
|
|
41
34
|
*/
|
|
@@ -49,14 +42,20 @@ declare class MediaProcessor extends Emittery<EventDataMap> {
|
|
|
49
42
|
* Mostly:
|
|
50
43
|
* Video: 30 frames per second
|
|
51
44
|
* Audio: 50 audio data per second for OPUS
|
|
45
|
+
* In case of increased frame dropping rate a warning will be emitted according to info [here](/docs/intro#errors-and-warnings-listener).
|
|
46
|
+
* ***This is an optional method.***
|
|
52
47
|
* @param trackExpectedRate - number holds the predicted track rate.
|
|
53
48
|
*/
|
|
54
49
|
setTrackExpectedRate(trackExpectedRate: number): void;
|
|
55
50
|
/**
|
|
56
51
|
* Starts running the tranformation logic performed by the media processor instance.
|
|
52
|
+
* When running an instance of this class on a Web worker thread the call for this function should be made by the user. See example [here](/docs/intro#webworker-code).
|
|
53
|
+
* When running an instance of this class on the application main thread there is no need to call this method given it will be called by the `MediaProcessorConnector` instance.
|
|
57
54
|
*
|
|
58
55
|
* @param readable Readable stream associated to the media source being processed.
|
|
59
56
|
* @param writable Writable stream associated to the resulting media once processed.
|
|
57
|
+
*
|
|
58
|
+
* @returns
|
|
60
59
|
*/
|
|
61
60
|
transform(readable: ReadableStream, writable: WritableStream): Promise<void>;
|
|
62
61
|
/**
|
|
@@ -65,12 +64,16 @@ declare class MediaProcessor extends Emittery<EventDataMap> {
|
|
|
65
64
|
transformInternal(): Promise<void>;
|
|
66
65
|
/**
|
|
67
66
|
* Sets an array of transfromer instances that will be hold and ran by the media processor instance.
|
|
67
|
+
* See example [here](/docs/intro#main-code)
|
|
68
68
|
*
|
|
69
69
|
* @param transformers An array of transformer instances.
|
|
70
|
+
*
|
|
71
|
+
* @returns
|
|
70
72
|
*/
|
|
71
73
|
setTransformers(transformers: Array<Transformer>): Promise<void>;
|
|
72
74
|
/**
|
|
73
75
|
* Stops running the tranformation logic performed by the media processor instance.
|
|
76
|
+
* @returns
|
|
74
77
|
*/
|
|
75
78
|
destroy(): Promise<void>;
|
|
76
79
|
}
|
|
@@ -2,56 +2,9 @@ import InsertableStreamHelper from './InsertableStreamHelper';
|
|
|
2
2
|
import { MediaProcessorConnectorInterface } from './MediaProcessorConnectorInterface';
|
|
3
3
|
import { MediaProcessorInterface } from './MediaProcessorInterface';
|
|
4
4
|
/**
|
|
5
|
-
* Helper class implementing the media
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* let mediaProcessor: MediaProcessor = new MediaProcessor();
|
|
11
|
-
* let transformers: Array<Transformer> = [];
|
|
12
|
-
* transformers.push(new CanvasTransform());
|
|
13
|
-
* mediaProcessor.setTransformers(transformers);
|
|
14
|
-
*
|
|
15
|
-
* let connector: MediaProcessorConnector = new MediaProcessorConnector(mediaProcessor);
|
|
16
|
-
* source_.setMediaProcessorConnector(connector);
|
|
17
|
-
*
|
|
18
|
-
* // ...
|
|
19
|
-
*
|
|
20
|
-
* setMediaProcessorConnector(mediaProcessorConnector: MediaProcessorConnectorInterface): Promise<void> {
|
|
21
|
-
* return new Promise<void>(async (resolve, reject) => {
|
|
22
|
-
* this.mediaProcessorConnector_ = mediaProcessorConnector;
|
|
23
|
-
* if (!this.stream_)
|
|
24
|
-
* {
|
|
25
|
-
* console.log('[CameraSource] Requesting camera.');
|
|
26
|
-
* reject("no stream")
|
|
27
|
-
* }
|
|
28
|
-
* this.mediaProcessorConnector_.setTrack(this.videoTrack_).then(newTrack => {
|
|
29
|
-
* let processedStream = new MediaStream();
|
|
30
|
-
* processedStream.addTrack(newTrack);
|
|
31
|
-
* this.sink_.setMediaStream(processedStream);
|
|
32
|
-
* resolve();
|
|
33
|
-
* })
|
|
34
|
-
* .catch(e => {
|
|
35
|
-
* reject(e)
|
|
36
|
-
* })
|
|
37
|
-
* });
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* // ...
|
|
41
|
-
*
|
|
42
|
-
* async stopMediaProcessorConnector() {
|
|
43
|
-
* if(this.mediaProcessorConnector_){
|
|
44
|
-
* this.mediaProcessorConnector_.destroy().then(() => {
|
|
45
|
-
* let processedStream = new MediaStream();
|
|
46
|
-
* processedStream.addTrack(this.videoTrack_);
|
|
47
|
-
* this.sink_.setMediaStream(processedStream);
|
|
48
|
-
* })
|
|
49
|
-
* .catch(e => {
|
|
50
|
-
* console.error(e);
|
|
51
|
-
* });
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
5
|
+
* Helper class implementing the media Media Processor Connector Interface.
|
|
6
|
+
* This class should always be created on the application main thread and it should be used by Vonage SDKs.
|
|
7
|
+
* An example can be found [here](/docs/intro.md#using-the-transformer-on-main-process).
|
|
55
8
|
*/
|
|
56
9
|
declare class MediaProcessorConnector implements MediaProcessorConnectorInterface {
|
|
57
10
|
/**
|
|
@@ -62,16 +15,23 @@ declare class MediaProcessorConnector implements MediaProcessorConnectorInterfac
|
|
|
62
15
|
* @private
|
|
63
16
|
*/
|
|
64
17
|
mediaProcessor_: MediaProcessorInterface;
|
|
18
|
+
/**
|
|
19
|
+
* - When running insertable streams on the main `MediaProcessorInterface` should be instance of `MediaProcessor` class.
|
|
20
|
+
* - When running insertable streams on WebWorker `MediaProcessorInterface` should be instance of bridge calss created by the user. Example can be found [here](/docs/intro.md#using-the-transformer-on-webworker)
|
|
21
|
+
* @param vonageMediaProcessor - MediaProcessorInterface.
|
|
22
|
+
*/
|
|
65
23
|
constructor(vonageMediaProcessor: MediaProcessorInterface);
|
|
66
24
|
/**
|
|
25
|
+
* @private
|
|
67
26
|
* Sets the media stream track instance to be processed.
|
|
68
27
|
*
|
|
69
|
-
* @param track
|
|
28
|
+
* @param track MediaStreamTrack (audio or video) to be processed.
|
|
70
29
|
*
|
|
71
|
-
* @returns
|
|
30
|
+
* @returns New track to be used.
|
|
72
31
|
*/
|
|
73
32
|
setTrack(track: MediaStreamTrack): Promise<MediaStreamTrack>;
|
|
74
33
|
/**
|
|
34
|
+
* @private
|
|
75
35
|
* Stops the media processing being performed.
|
|
76
36
|
*/
|
|
77
37
|
destroy(): Promise<void>;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Interface definition for media processor connector instances.
|
|
3
|
+
* This interface is used for the integration for this library with the Vonage SDKs.
|
|
3
4
|
*/
|
|
4
5
|
export interface MediaProcessorConnectorInterface {
|
|
5
6
|
/**
|
|
7
|
+
* @private
|
|
6
8
|
* Sets the media stream track instance to be processed.
|
|
7
9
|
*
|
|
8
10
|
* @param track MeadiaStreamTrack (audio or video) to be processed.
|
|
9
11
|
*
|
|
10
|
-
* @returns
|
|
12
|
+
* @returns New track to be used.
|
|
11
13
|
*/
|
|
12
14
|
setTrack(track: MediaStreamTrack): Promise<MediaStreamTrack>;
|
|
13
15
|
/**
|
|
16
|
+
* @private
|
|
14
17
|
* Stops the media processing being performed.
|
|
15
18
|
*/
|
|
16
19
|
destroy(): Promise<void>;
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Interface definition for media processor instances.
|
|
3
|
+
* When using Web workers the application should define and use a bridge class that implements this interface.
|
|
4
|
+
* See an example of using the library this way [here](/docs/intro.md#library-usage).
|
|
3
5
|
*/
|
|
4
6
|
export interface MediaProcessorInterface {
|
|
5
7
|
/**
|
|
6
8
|
* Starts running the tranformation logic performed by the media processor instance.
|
|
9
|
+
* In case of bridging to WebWorker the function should post message to the Worker with the `readable` and `writable`.
|
|
7
10
|
*
|
|
8
11
|
* @param readable Readable stream associated to the media source being processed.
|
|
9
12
|
* @param writable Writable stream associated to the resulting media once processed.
|
|
13
|
+
* @returns - In case of using a Web worker the promise should be completed only after the worker was completed.
|
|
10
14
|
*/
|
|
11
15
|
transform(readable: ReadableStream, writable: WritableStream): Promise<void>;
|
|
12
16
|
/**
|
|
13
17
|
* Stops running the tranformation logic performed by the media processor instance.
|
|
18
|
+
* In case of using a Web worker the method should post a message to the Worker with the destroy message.
|
|
19
|
+
*
|
|
20
|
+
* @returns - In case of using a Web worker the promise should be completed only after the worker was completed.
|
|
14
21
|
*/
|
|
15
22
|
destroy(): Promise<void>;
|
|
16
23
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
/// <reference types="dom-webcodecs" />
|
|
2
2
|
import Emittery from 'emittery';
|
|
3
|
+
/**
|
|
4
|
+
* EventMetaData. Some metadata of the event.
|
|
5
|
+
*/
|
|
6
|
+
export declare type EventMetaData = {
|
|
7
|
+
/**
|
|
8
|
+
* The transformer index in the array of transformers.
|
|
9
|
+
*/
|
|
10
|
+
transformerIndex: number;
|
|
11
|
+
};
|
|
3
12
|
/**
|
|
4
13
|
* WarningType specifies the type of warning from the transformer
|
|
5
14
|
*/
|
|
@@ -23,63 +32,105 @@ export declare type DropInfo = {
|
|
|
23
32
|
current: number;
|
|
24
33
|
};
|
|
25
34
|
/**
|
|
26
|
-
*
|
|
35
|
+
* WarnData - MediaProcessor warning event defintion
|
|
27
36
|
*/
|
|
28
|
-
export declare type
|
|
29
|
-
/**
|
|
30
|
-
* EventMetaData the meta data of the event.
|
|
31
|
-
*/
|
|
32
|
-
export declare type EventMetaData = {
|
|
37
|
+
export declare type WarnData = {
|
|
33
38
|
/**
|
|
34
|
-
*
|
|
39
|
+
* Meta data of the event
|
|
35
40
|
*/
|
|
36
|
-
transformerIndex: number;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* WarnData the warning data type
|
|
40
|
-
* ```ts
|
|
41
|
-
* {
|
|
42
|
-
* eventMetaData: { transformerIndex: 0},
|
|
43
|
-
* warningType: WarningType.FPS_DROP
|
|
44
|
-
* dropInfo: {requested: 30, current:20}
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare type WarnData = {
|
|
49
41
|
eventMetaData: EventMetaData;
|
|
42
|
+
/**
|
|
43
|
+
* The waring type
|
|
44
|
+
*/
|
|
50
45
|
warningType: WarningType;
|
|
51
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Optional - FPS drop info.
|
|
48
|
+
*/
|
|
49
|
+
dropInfo?: DropInfo;
|
|
52
50
|
};
|
|
53
51
|
/**
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
* ErrorFunction. It specifies the transformer function in which the error occurred.
|
|
53
|
+
*/
|
|
54
|
+
export declare enum ErrorFunction {
|
|
55
|
+
/**
|
|
56
|
+
* start function exception.
|
|
57
|
+
*/
|
|
58
|
+
start = "start",
|
|
59
|
+
/**
|
|
60
|
+
* transform function exception.
|
|
61
|
+
*/
|
|
62
|
+
transform = "transform",
|
|
63
|
+
/**
|
|
64
|
+
* flush function exception.
|
|
65
|
+
*/
|
|
66
|
+
flush = "flush"
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* ErrorData. MediaProcessor error data definition.
|
|
62
70
|
*/
|
|
63
71
|
export declare type ErrorData = {
|
|
72
|
+
/**
|
|
73
|
+
* Metadata of the event.
|
|
74
|
+
*/
|
|
64
75
|
eventMetaData: EventMetaData;
|
|
76
|
+
/**
|
|
77
|
+
* The function in which the error occurred.
|
|
78
|
+
*/
|
|
65
79
|
function: ErrorFunction;
|
|
80
|
+
/**
|
|
81
|
+
* Type of unknown but moslty will be string
|
|
82
|
+
*/
|
|
66
83
|
error: unknown;
|
|
67
84
|
};
|
|
68
85
|
/**
|
|
69
|
-
* PipelineInfolData
|
|
86
|
+
* PipelineInfolData. Life cycle information of insertable streams pipeline.
|
|
70
87
|
*/
|
|
71
|
-
export declare
|
|
72
|
-
|
|
73
|
-
|
|
88
|
+
export declare enum PipelineInfoData {
|
|
89
|
+
/**
|
|
90
|
+
* Notify the app that the pipeline has ended.
|
|
91
|
+
*/
|
|
92
|
+
pipeline_ended = "pipeline_ended",
|
|
93
|
+
/**
|
|
94
|
+
* Notify the app that the pipeline has ended with an error.
|
|
95
|
+
*/
|
|
96
|
+
pipeline_ended_with_error = "pipeline_ended_with_error",
|
|
97
|
+
/**
|
|
98
|
+
* Notify the app that the pipeline has started.
|
|
99
|
+
*/
|
|
100
|
+
pipeline_started = "pipeline_started",
|
|
101
|
+
/**
|
|
102
|
+
* Notify the app that the pipeline has started with an error.
|
|
103
|
+
*/
|
|
104
|
+
pipeline_started_with_error = "pipeline_started_with_error",
|
|
105
|
+
/**
|
|
106
|
+
* Notify the app that the pipeline has restarted.
|
|
107
|
+
* This message is fired after changing track in the middle of the process.
|
|
108
|
+
* For example switching camera source.
|
|
109
|
+
*/
|
|
110
|
+
pipeline_restarted = "pipeline_restarted",
|
|
111
|
+
/**
|
|
112
|
+
* Notify the app that the pipeline has restarted with an error.
|
|
113
|
+
* This message is fired after changing track in the middle of the process.
|
|
114
|
+
* For example switching camera source.
|
|
115
|
+
*/
|
|
116
|
+
pipeline_restarted_with_error = "pipeline_restarted_with_error"
|
|
117
|
+
}
|
|
74
118
|
/**
|
|
75
|
-
* EventDataMap
|
|
76
|
-
*
|
|
77
|
-
* @error - see `ErrorData`
|
|
78
|
-
* @pipelineInfo - see `pipelineInfo`
|
|
119
|
+
* EventDataMap. A map type for all event options from MediaProcessor.
|
|
120
|
+
* Each event will include only one type.
|
|
79
121
|
*/
|
|
80
122
|
export declare type EventDataMap = {
|
|
123
|
+
/**
|
|
124
|
+
* Warnings from the insertable streams pipeline.
|
|
125
|
+
*/
|
|
81
126
|
warn: WarnData;
|
|
127
|
+
/**
|
|
128
|
+
* Errors from the insertable streams pipeline.
|
|
129
|
+
*/
|
|
82
130
|
error: ErrorData;
|
|
131
|
+
/**
|
|
132
|
+
* Info from the insertable streams pipeline life cycle.
|
|
133
|
+
*/
|
|
83
134
|
pipelineInfo: PipelineInfoData;
|
|
84
135
|
};
|
|
85
136
|
declare class InternalTransformer extends Emittery<EventDataMap> implements Transformer {
|
|
@@ -96,6 +147,7 @@ declare class InternalTransformer extends Emittery<EventDataMap> implements Tran
|
|
|
96
147
|
videoWidth_: number;
|
|
97
148
|
trackExpectedRate_: number;
|
|
98
149
|
index_: number;
|
|
150
|
+
controller_?: TransformStreamDefaultController;
|
|
99
151
|
constructor(transformer: Transformer, index: number);
|
|
100
152
|
setTrackExpectedRate(trackExpectedRate: number): void;
|
|
101
153
|
start(controller: TransformStreamDefaultController): Promise<void>;
|