@vonage/media-processor 3.0.0-alpha.2 → 3.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.
@@ -658,7 +658,7 @@ class V {
658
658
  };
659
659
  }
660
660
  }
661
- const A = "3.0.0-alpha.2", W = class W {
661
+ const A = "3.0.0", W = class W {
662
662
  };
663
663
  W.updates = {
664
664
  transformer_new: "New transformer",
@@ -1,2 +1,2 @@
1
1
  const{keys:_a}=Object;const{defineProperty:_b}=Object;var T,O=r=>typeof r=='string'||typeof r=='symbol'||typeof r=='number',Y=Object.getOwnPropertyNames(h.prototype).filter(r=>r!=='constructor'),M,p=z('globals',{}),g=(r=>(r.INIT='INIT',r.FORWARD='FORWARD',r.TERMINATE='TERMINATE',r.GLOBALS_SYNC='GLOBALS_SYNC',r))(g||{}),B=z('workerized',{}),[aX,aY]=aW('metadata'),{isArray:_c}=Array;self.MediaStreamTrackProcessor||(self.MediaStreamTrackProcessor=T=class{constructor(e){let t=e.track??e;t.kind=='video'?this.readable=new ReadableStream({async start(s){t.addEventListener('ended',()=>s.close(),{once:!0}),this.video=document.createElement('video'),this.video.srcObject=new MediaStream([t]),await Promise.all([this.video.play(),new Promise(i=>this.video.onloadedmetadata=i)]),this.track=t,this.canvas=new OffscreenCanvas(this.video.videoWidth, this.video.videoHeight),this.ctx=this.canvas.getContext('2d',{desynchronized:!0}),this.t1=performance.now()},async pull(s){if(t.readyState=='ended')return s.close();let i=t.getSettings().frameRate||30;for(;performance.now()-this.t1<1e3/i;)if(await new Promise(n=>requestAnimationFrame(n)),t.readyState=='ended')return s.close();this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,this.t1=performance.now(),this.ctx.drawImage(this.video,0,0),s.enqueue(new VideoFrame(this.canvas, {timestamp:this.t1}))}}):t.kind=='audio'&&(this.readable=new ReadableStream({async start(s){t.addEventListener('ended',()=>s.close(),{once:!0}),this.ac=new AudioContext,this.arrays=[];function i(){registerProcessor('mstp-shim',class extends AudioWorkletProcessor{process(o){return this.port.postMessage(o),!0}})}await this.ac.audioWorklet.addModule(`data:text/javascript,(${`${i}`})()`),this.node=new AudioWorkletNode(this.ac, 'mstp-shim'),this.ac.createMediaStreamSource(new MediaStream([t])).connect(this.node),this.node.port.addEventListener('message',({data:n})=>n[0][0]&&this.arrays.push(n))},async pull(s){if(t.readyState=='ended')return s.close();for(;!this.arrays.length;)if(await new Promise(o=>this.node.port.onmessage=o),t.readyState=='ended')return s.close();const[i]=this.arrays.shift(),n=new Float32Array(i.reduce((o,a)=>o+a.length,0));i.reduce((o,a)=>(n.set(a,o),o+a.length),0),s.enqueue(new AudioData({format:'f32-planar',sampleRate:this.ac.sampleRate,numberOfFrames:i[0].length,numberOfChannels:i.length,timestamp:this.ac.currentTime*1e6|0,data:n,transfer:[n.buffer]}))}}))}},T.__POLYFILLED=!0,T);var S;self.MediaStreamTrackGenerator||(self.MediaStreamTrackGenerator=S=class{constructor({kind:e}){if(e=='video'){const t=document.createElement('canvas'),s=t.getContext('2d',{desynchronized:!0}),i=t.captureStream().getVideoTracks()[0];return i.writable=new WritableStream({write(n){t.width=n.displayWidth,t.height=n.displayHeight,s.drawImage(n,0,0,t.width,t.height),n.close()}}),i}if(e=='audio'){const t=new AudioContext,s=t.createMediaStreamDestination(),[i]=s.stream.getAudioTracks();return i.writable=new WritableStream({async start(n){this.arrays=[];function o(){registerProcessor('mstg-shim',class extends AudioWorkletProcessor{constructor(){super(),this.arrays=[],this.arrayOffset=0,this.port.onmessage=({data:l})=>this.arrays.push(l),this.emptyArray=new Float32Array(0)}process(l,[[w]]){for(let F=0;F<w.length;F++)(!this.array||this.arrayOffset>=this.array.length)&&(this.array=this.arrays.shift()||this.emptyArray,this.arrayOffset=0),w[F]=this.array[this.arrayOffset++]||0;return!0}})}return await t.audioWorklet.addModule(`data:text/javascript,(${`${o}`})()`),this.node=new AudioWorkletNode(t, 'mstg-shim'),this.node.connect(s),i},write(n){let o=new Float32Array(n.numberOfFrames*n.numberOfChannels);n.copyTo(o,{planeIndex:0}),this.node.port.postMessage(o,[o.buffer]),n.close()}}),i}}},S.__POLYFILLED=!0,S);async function _f(){return new Promise(async (r,e)=>await X()||J()?r():e('Your browser does not support the MediaStreamTrack API for Insertable Streams of Media.'))}function J(){return self.MediaStreamTrackProcessor!==void 0&&self.MediaStreamTrackGenerator!==void 0&&(!(self.MediaStreamTrackProcessor.hasOwnProperty('__POLYFILLED')||self.MediaStreamTrackGenerator.hasOwnProperty('__POLYFILLED'))||N())}function N(){return [self.ReadableStream,self.WritableStream,self.MediaStream,self.OffscreenCanvas,self.VideoFrame,self.AudioContext,self.AudioWorkletNode].filter(r=>r===void 0).length===0}function X(){return new Promise(r=>{function e(){self.postMessage(typeof MediaStreamTrackProcessor<'u'&&typeof VideoTrackGenerator<'u')}let t=new Worker(`data:text/javascript,(${`${e}`})()`);t.onmessage=({data:s})=>r(s)})}const u=new WeakMap,m=new WeakMap,d=new WeakMap,R=Symbol('anyProducer'),j=Promise.resolve(),I=Symbol('listenerAdded'),x=Symbol('listenerRemoved');let C=!1,G=!1;function y(r){if(!O(r))throw TypeError('`eventName` must be a string, symbol, or number')}function v(r){if(typeof r!='function')throw TypeError('listener must be a function')}function _(r,e){let t=m.get(r);if(t.has(e))return t.get(e)}function E(r,e){const t=O(e)?e:R,s=d.get(r);if(s.has(t))return s.get(t)}function _x(r,e,t){let s=d.get(r);if(s.has(e))for(const i of s.get(e))i.enqueue(t);if(s.has(R)){let i=Promise.all([e,t]);for(const n of s.get(R))n.enqueue(i)}}function H(r,e){!_c(e)&&(e=[e]);let t=!1,s=()=>{},i=[];let n={enqueue(o){i.push(o),s()},finish(){t=!0,s()}};for(const o of e){let a=E(r,o);a||(a=new Set,d.get(r).set(o,a)),a.add(n)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>s=o),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){let l=E(r,a);l&&(l.delete(n),l.size===0&&d.get(r).delete(a))}return s(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Q(r){if(r===void 0)return Y;if(!_c(r))throw TypeError('`methodNames` must be an array of strings');for(const e of r)if(!Y.includes(e))throw typeof e!='string'?TypeError('`methodNames` element must be a string'):Error(`${e} is not Emittery method`);return r}let b=r=>r===I||r===x;function P(r,e,t){if(b(e))try{C=!0,r.emit(e,t)}finally{C=!1}}class h{static mixin(e,t){return t=Q(t),s=>{if(typeof s!='function')throw TypeError('`target` must be function');for(const o of t)if(s.prototype[o]!==void 0)throw Error(`The property \`${o}\` already exists on \`target\``);function i(){return _b(this,e,{enumerable:!1,value:new h}),this[e]}_b(s.prototype,e,{enumerable:!1,get:i});let n=o=>function(...a){return this[e][o](...a)};for(const o of t)_b(s.prototype,o,{enumerable:!1,value:n(o)});return s}}static get isDebugEnabled(){if(typeof globalThis.process?.env!='object')return G;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==='emittery'||e.DEBUG==='*'||G}static set isDebugEnabled(e){G=e}constructor(e={}){u.set(this,new Set),m.set(this,new Map),d.set(this,new Map),d.get(this).set(R,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,s,i,n)=>{try{n=JSON.stringify(n)}catch{n=`Object with the following keys failed to stringify: ${_a(n).join(',')}`}(typeof i=='symbol'||typeof i=='number')&&(i=`${i}`);const o=new Date,a=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${s}] Event Name: ${i}
2
- data: ${n}`)})}logIfDebugEnabled(e,t,s){(h.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,s)}on(e,t,{signal:s}={}){v(t),e=_c(e)?e:[e];for(const n of e){y(n);let o=_(this,n);o||(o=new Set,m.get(this).set(n,o)),o.add(t),this.logIfDebugEnabled('subscribe',n,void 0),b(n)||P(this,I,{eventName:n,listener:t})}let i=()=>(this.off(e,t),s?.removeEventListener('abort',i));return s?.addEventListener('abort',i,{once:!0}),s?.aborted&&i(),i}off(e,t){v(t),e=_c(e)?e:[e];for(const s of e){y(s);let i=_(this,s);i&&(i.delete(t),i.size===0&&m.get(this).delete(s)),this.logIfDebugEnabled('unsubscribe',s,void 0),b(s)||P(this,x,{eventName:s,listener:t})}}once(e,t){if(t!==void 0&&typeof t!='function')throw TypeError('predicate must be a function');let s;let i=new Promise(n=>s=this.on(e,o=>t&&!t(o)||(s(),n(o))));return i.off=s,i}events(e){!_c(e)&&(e=[e]);for(const t of e)y(t);return H(this,e)}async emit(e,t){if(y(e),b(e)&&!C)throw TypeError('`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`');this.logIfDebugEnabled('emit',e,t),_x(this,e,t);const s=_(this,e)??new Set,i=u.get(this),n=[...s],o=b(e)?[]:[...i];await j,await Promise.all([...n.map(a=>{if(s.has(a))return a(t)}),...o.map(a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(y(e),b(e)&&!C)throw TypeError('`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`');this.logIfDebugEnabled('emitSerial',e,t);const s=_(this,e)??new Set,i=u.get(this),n=[...s],o=[...i];await j;for(const a of n)s.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){v(e),this.logIfDebugEnabled('subscribeAny',void 0,void 0),u.get(this).add(e),P(this,I,{listener:e});let s=()=>(this.offAny(e),t?.removeEventListener('abort',s));return t?.addEventListener('abort',s,{once:!0}),t?.aborted&&s(),s}anyEvent(){return H(this)}offAny(e){v(e),this.logIfDebugEnabled('unsubscribeAny',void 0,void 0),P(this,x,{listener:e}),u.get(this).delete(e)}clearListeners(e){!_c(e)&&(e=[e]);for(const t of e)if(this.logIfDebugEnabled('clear',t,void 0),O(t)){let s=_(this,t);s?.clear();let i=E(this,t);if(i){for(const n of i)n.finish();i.clear()}}else{u.get(this).clear();for(const[s,i] of m.get(this).entries())i.clear(),m.get(this).delete(s);for(const[s,i] of d.get(this).entries()){for(const n of i)n.finish();i.clear(),d.get(this).delete(s)}}}listenerCount(e){!_c(e)&&(e=[e]);let t=0;for(const s of e){if(O(s)){t+=u.get(this).size+(_(this,s)?.size??0)+(E(this,s)?.size??0)+(E(this)?.size??0);continue}s!==void 0&&y(s),t+=u.get(this).size;for(const i of m.get(this).values())t+=i.size;for(const i of d.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!='object'||e===null)throw TypeError('`target` must be an object');t=Q(t);for(const s of t){if(e[s]!==void 0)throw Error(`The property \`${s}\` already exists on \`target\``);_b(e,s,{enumerable:!1,value:this[s].bind(this)})}}}_b(h,'listenerAdded',{value:I,writable:!1,enumerable:!0,configurable:!1});_b(h,'listenerRemoved',{value:x,writable:!1,enumerable:!0,configurable:!1});var aA=Object.defineProperty,aB=(r,e,t)=>e in r?aA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,aC=(r,e,t)=>(aB(r,`${e}`,t),t),aD=(r=>(r.automation='automation',r.test='test',r.vbc='vbc',r.video='video',r.voice='voice',r))(aD||{});const aE='hlg.tokbox.com/prod/logging/vcp_webrtc',aF='https://',aG=1e4;let aH=new Uint8Array(16);function aI(){if(!M&&(M=typeof crypto<'u'&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!M))throw Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');return M(aH)}let c=[];for(let r=0;r<256;++r)c.push((r+256).toString(16).slice(1));function aJ(r,e=0){return (c[r[e+0]]+c[r[e+1]]+c[r[e+2]]+c[r[e+3]]+'-'+c[r[e+4]]+c[r[e+5]]+'-'+c[r[e+6]]+c[r[e+7]]+'-'+c[r[e+8]]+c[r[e+9]]+'-'+c[r[e+10]]+c[r[e+11]]+c[r[e+12]]+c[r[e+13]]+c[r[e+14]]+c[r[e+15]]).toLowerCase()}const aK=typeof crypto<'u'&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),q={randomUUID:aK};function aL(r,e,t){if(q.randomUUID&&!r)return q.randomUUID();r=r||{};let s=r.random||(r.rng||aI)();return s[6]=s[6]&15|64,s[8]=s[8]&63|128,aJ(s)}function z(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}function Z(r){return [ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}let aM=0;function aN(r,e,t,s,i){let n=aM++;return r.postMessage({id:n,type:e,functionName:t,args:s},s.filter(a=>Z(a))),new Promise(a=>i?.set(n,a))}function k(r,e){const{id:t,type:s}=r,i=_c(e)?e:[e];postMessage({id:t,type:s,result:e},i.filter(n=>Z(n)))}function K(){return typeof WorkerGlobalScope<'u'&&self instanceof WorkerGlobalScope}async function aO(){if(K())k({type:g.GLOBALS_SYNC},p);else{let r=[];for(const e in B){const{worker:t,resolvers:s}=B[e].workerContext;t&&r.push(aN(t,g.GLOBALS_SYNC,'',[p],s))}await Promise.all(r)}}function L(r,e){if(_c(e))e.splice(0,e.length);else if(typeof e=='object')for(const t in e)delete e[t];for(const t in r)_c(r[t])?(e[t]=[],L(r[t],e[t])):typeof r[t]=='object'?(e[t]={},L(r[t],e[t])):e[t]=r[t]}async function aP(r,e){const{functionName:t,args:s}=r;if(!e.instance)throw 'instance not initialized';if(!t)throw 'missing function name to call';if(!e.instance[t])throw `undefined function [${t}] in class ${e.instance.constructor.workerId}`;k(r,await e.instance[t](...s??[]))}let aQ=z('registeredWorkers',{});function aR(r,e){if(!r.args)throw 'Missing className while initializing worker';const[t,s]=r.args,i=aQ[t];if(i)e.instance=new i(r.args.slice(1));else throw `unknown worker class ${t}`;L(s,p),k(r,typeof e.instance!==void 0)}async function aS(r,e){const{args:t}=r;if(!e.instance)throw 'instance not initialized';let s;e.instance.terminate&&(s=await e.instance.terminate(...t??[])),k(r,s)}function aT(r){if(!r.args)throw 'Missing globals while syncing';L(r.args[0],p),k(r,{})}function aU(){let r={};onmessage=e=>{let t=e.data;switch(t.type) {case g.INIT:aR(t,r);break;case g.FORWARD:aP(t,r);break;case g.TERMINATE:aS(t,r);break;case g.GLOBALS_SYNC:aT(t);break}}}K()&&aU();function aV(r,e){return p[r]||(p[r]=e),[()=>p[r],async t=>(p[r]=t,await aO())]}function aW(r,e){return aV(r,e)}function aZ(r){aY(r)}function D(){return aX()}class V{constructor(e,t){aC(this,'uuid'),this.config=e,this.uuid=t??aL()}async send(e){var t,s,i;const{appId:n,sourceType:o}=(t=D())!=null?t:{};if(!n||!o)return'metadata missing';const a=new AbortController;return await ((i=(s=this.config)==null?void 0:s.fetch)!=null?i:fetch)(this.getUrl(),{method:'POST',headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(setTimeout(()=>a.abort(),aG)),'success'}getUrl(){var e,t=(e=D().proxyUrl)!=null?e:aF;return t+=(t.at(-1)==='/'?'':'/')+aE,t}getHeaders(){return{'Content-Type':'application/json'}}buildReport(e){let t=D();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const A='3.0.0-alpha.2',W=class W{};W.updates={transformer_new:'New transformer',transformer_null:'Null transformer'},W.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'};let f=W;function bA(r){return typeof r=='object'&&r!==null&&'message' in r&&typeof r.message=='string'}function bB(r){if(bA(r))return r;try{return Error(JSON.stringify(r))}catch{return Error(`${r}`)}}function $(r){return bB(r).message}class Ae{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new V(e, t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,i=(Date.now()-e)/1e3;return t/i}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:s,frameTransformedCount:i,frameFromSourceCount:n}=this,o=Date.now(),a=(o-s)/1e3,l=i/a,w=n/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:'QoS',fps:w,transformedFps:l,framesTransformed:i,...e})):'success'}}var bC=(r=>(r.FPS_DROP='fps_drop',r))(bC||{}),bD=(r=>(r.start='start',r.transform='transform',r.flush='flush',r))(bD||{}),U=(r=>(r.pipeline_ended='pipeline_ended',r.pipeline_ended_with_error='pipeline_ended_with_error',r.pipeline_started='pipeline_started',r.pipeline_started_with_error='pipeline_started_with_error',r.pipeline_restarted='pipeline_restarted',r.pipeline_restarted_with_error='pipeline_restarted_with_error',r))(U||{});const bE=500,bF=0.8;class Oe extends h{constructor(e,t){super(),this.reporter_=new V,this.reporterQos_=new Ae({loggingIntervalFrameCount:bE,report:{version:A}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_='Custom','getTransformerType' in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:'Create'})}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(t){this.report({message:f.errors.transformer_start,variation:'Error',error:$(t)});this.emit('error',{eventMetaData:{transformerIndex:this.index_},error:t,function:'start'})}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn('[Pipeline] flush from transform'),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(s){this.report({message:f.errors.transformer_transform,variation:'Error',error:$(s)});this.emit('error',{eventMetaData:{transformerIndex:this.index_},error:s,function:'transform'})}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*bF>this.reporterQos_.fps){this.emit('warn',{eventMetaData:{transformerIndex:this.index_},warningType:'fps_drop',dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}})}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=='function'&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:f.errors.transformer_flush,variation:'Error',error:$(t)});this.emit('error',{eventMetaData:{transformerIndex:this.index_},error:t,function:'flush'})}}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(e){this.reporter_.send({version:A,action:'MediaTransformer',transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:A,action:'MediaTransformer',transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class Le extends h{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let s=new Oe(e[t], t);s.on('error',i=>this.emit('error',i)),s.on('warn',i=>this.emit('warn',i)),this.transformers_.push(s)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log('[Pipeline] No transformers.');return}try{let s=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async ()=>(console.log('[Pipeline] Setup.'),await t.abort(),await s.cancel(),this.emit('pipelineInfo','pipeline_ended'))).catch(async i=>(e.cancel().then(()=>console.log('[Pipeline] Shutting down streams after abort.')).catch(n=>console.error('[Pipeline] Error from stream transform:',n)),await t.abort(i),await s.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 e of this.transformers_)e.stop()}}class We extends h{constructor(){super(),this.reporter_=new V,this.trackExpectedRate_=-1,this.report({variation:'Create'})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_?.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==='video'){const s=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=s.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error('Cannot process audio tracks inside a web worker when passing a track to transform')}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise((e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:f.errors.transformer_none,variation:'Error'}),t('[MediaProcessor] Need to set transformers.');return}if(!this.readable_){this.report({variation:'Error',message:f.errors.readable_null}),t('[MediaProcessor] Readable is null.');return}if(!this.writable_){this.report({variation:'Error',message:f.errors.writable_null}),t('[MediaProcessor] Writable is null.');return}let s=!1;this.pipeline_&&(s=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Le(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=>(s&&(i==='pipeline_started'?i=U.pipeline_restarted:i==='pipeline_started_with_error'&&(i=U.pipeline_restarted_with_error)),this.emit('pipelineInfo',i))),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>e()).catch(i=>t(i))})}setTransformers(e){return this.report({variation:'Update',message:f.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(e=>(this.pipeline_?.destroy(),this.report({variation:'Delete'}),e()))}report(e){this.reporter_.send({version:A,action:'MediaProcessor',...e})}isTrack(e){return 'kind' in e}}class Fe{constructor(){this.processor_=null,this.generator_=null}init(e){return new Promise((t,s)=>{try{this.processor_=new MediaStreamTrackProcessor(e)}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${i}`),s(i)}try{e.kind==='audio'?this.generator_=new MediaStreamTrackGenerator({kind:'audio'}):e.kind==='video'?this.generator_=new MediaStreamTrackGenerator({kind:'video'}):s('kind not supported')}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${i}`),s(i)}t()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class ze{constructor(e){this.mediaProcessor_=e}async setTrack(e){if(!(this.mediaProcessor_ instanceof We)&&await X()){if(e.kind==='audio')throw Error('Cannot process audio tracks inside a web worker when passing a track to transform');return await this.mediaProcessor_.transform(e)}if(J()){let t=new Fe;return await t.init(e),await this.mediaProcessor_.transform(t.getReadable(),t.getWriteable()),t.getProccesorTrack()}throw Error('MediaStreamTrack API for Insertable Streams of Media is not supported')}destroy(){return new Promise((e,t)=>this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>e()).catch(s=>t(s)):t('no processor'))}}export{bD as ErrorFunction,We as MediaProcessor,ze as MediaProcessorConnector,U as PipelineInfoData,aD as VonageSourceType,bC as WarningType,D as getVonageMetadata,_f as isSupported,aZ as setVonageMetadata};
2
+ data: ${n}`)})}logIfDebugEnabled(e,t,s){(h.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,s)}on(e,t,{signal:s}={}){v(t),e=_c(e)?e:[e];for(const n of e){y(n);let o=_(this,n);o||(o=new Set,m.get(this).set(n,o)),o.add(t),this.logIfDebugEnabled('subscribe',n,void 0),b(n)||P(this,I,{eventName:n,listener:t})}let i=()=>(this.off(e,t),s?.removeEventListener('abort',i));return s?.addEventListener('abort',i,{once:!0}),s?.aborted&&i(),i}off(e,t){v(t),e=_c(e)?e:[e];for(const s of e){y(s);let i=_(this,s);i&&(i.delete(t),i.size===0&&m.get(this).delete(s)),this.logIfDebugEnabled('unsubscribe',s,void 0),b(s)||P(this,x,{eventName:s,listener:t})}}once(e,t){if(t!==void 0&&typeof t!='function')throw TypeError('predicate must be a function');let s;let i=new Promise(n=>s=this.on(e,o=>t&&!t(o)||(s(),n(o))));return i.off=s,i}events(e){!_c(e)&&(e=[e]);for(const t of e)y(t);return H(this,e)}async emit(e,t){if(y(e),b(e)&&!C)throw TypeError('`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`');this.logIfDebugEnabled('emit',e,t),_x(this,e,t);const s=_(this,e)??new Set,i=u.get(this),n=[...s],o=b(e)?[]:[...i];await j,await Promise.all([...n.map(a=>{if(s.has(a))return a(t)}),...o.map(a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(y(e),b(e)&&!C)throw TypeError('`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`');this.logIfDebugEnabled('emitSerial',e,t);const s=_(this,e)??new Set,i=u.get(this),n=[...s],o=[...i];await j;for(const a of n)s.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){v(e),this.logIfDebugEnabled('subscribeAny',void 0,void 0),u.get(this).add(e),P(this,I,{listener:e});let s=()=>(this.offAny(e),t?.removeEventListener('abort',s));return t?.addEventListener('abort',s,{once:!0}),t?.aborted&&s(),s}anyEvent(){return H(this)}offAny(e){v(e),this.logIfDebugEnabled('unsubscribeAny',void 0,void 0),P(this,x,{listener:e}),u.get(this).delete(e)}clearListeners(e){!_c(e)&&(e=[e]);for(const t of e)if(this.logIfDebugEnabled('clear',t,void 0),O(t)){let s=_(this,t);s?.clear();let i=E(this,t);if(i){for(const n of i)n.finish();i.clear()}}else{u.get(this).clear();for(const[s,i] of m.get(this).entries())i.clear(),m.get(this).delete(s);for(const[s,i] of d.get(this).entries()){for(const n of i)n.finish();i.clear(),d.get(this).delete(s)}}}listenerCount(e){!_c(e)&&(e=[e]);let t=0;for(const s of e){if(O(s)){t+=u.get(this).size+(_(this,s)?.size??0)+(E(this,s)?.size??0)+(E(this)?.size??0);continue}s!==void 0&&y(s),t+=u.get(this).size;for(const i of m.get(this).values())t+=i.size;for(const i of d.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!='object'||e===null)throw TypeError('`target` must be an object');t=Q(t);for(const s of t){if(e[s]!==void 0)throw Error(`The property \`${s}\` already exists on \`target\``);_b(e,s,{enumerable:!1,value:this[s].bind(this)})}}}_b(h,'listenerAdded',{value:I,writable:!1,enumerable:!0,configurable:!1});_b(h,'listenerRemoved',{value:x,writable:!1,enumerable:!0,configurable:!1});var aA=Object.defineProperty,aB=(r,e,t)=>e in r?aA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,aC=(r,e,t)=>(aB(r,`${e}`,t),t),aD=(r=>(r.automation='automation',r.test='test',r.vbc='vbc',r.video='video',r.voice='voice',r))(aD||{});const aE='hlg.tokbox.com/prod/logging/vcp_webrtc',aF='https://',aG=1e4;let aH=new Uint8Array(16);function aI(){if(!M&&(M=typeof crypto<'u'&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!M))throw Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');return M(aH)}let c=[];for(let r=0;r<256;++r)c.push((r+256).toString(16).slice(1));function aJ(r,e=0){return (c[r[e+0]]+c[r[e+1]]+c[r[e+2]]+c[r[e+3]]+'-'+c[r[e+4]]+c[r[e+5]]+'-'+c[r[e+6]]+c[r[e+7]]+'-'+c[r[e+8]]+c[r[e+9]]+'-'+c[r[e+10]]+c[r[e+11]]+c[r[e+12]]+c[r[e+13]]+c[r[e+14]]+c[r[e+15]]).toLowerCase()}const aK=typeof crypto<'u'&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),q={randomUUID:aK};function aL(r,e,t){if(q.randomUUID&&!r)return q.randomUUID();r=r||{};let s=r.random||(r.rng||aI)();return s[6]=s[6]&15|64,s[8]=s[8]&63|128,aJ(s)}function z(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}function Z(r){return [ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}let aM=0;function aN(r,e,t,s,i){let n=aM++;return r.postMessage({id:n,type:e,functionName:t,args:s},s.filter(a=>Z(a))),new Promise(a=>i?.set(n,a))}function k(r,e){const{id:t,type:s}=r,i=_c(e)?e:[e];postMessage({id:t,type:s,result:e},i.filter(n=>Z(n)))}function K(){return typeof WorkerGlobalScope<'u'&&self instanceof WorkerGlobalScope}async function aO(){if(K())k({type:g.GLOBALS_SYNC},p);else{let r=[];for(const e in B){const{worker:t,resolvers:s}=B[e].workerContext;t&&r.push(aN(t,g.GLOBALS_SYNC,'',[p],s))}await Promise.all(r)}}function L(r,e){if(_c(e))e.splice(0,e.length);else if(typeof e=='object')for(const t in e)delete e[t];for(const t in r)_c(r[t])?(e[t]=[],L(r[t],e[t])):typeof r[t]=='object'?(e[t]={},L(r[t],e[t])):e[t]=r[t]}async function aP(r,e){const{functionName:t,args:s}=r;if(!e.instance)throw 'instance not initialized';if(!t)throw 'missing function name to call';if(!e.instance[t])throw `undefined function [${t}] in class ${e.instance.constructor.workerId}`;k(r,await e.instance[t](...s??[]))}let aQ=z('registeredWorkers',{});function aR(r,e){if(!r.args)throw 'Missing className while initializing worker';const[t,s]=r.args,i=aQ[t];if(i)e.instance=new i(r.args.slice(1));else throw `unknown worker class ${t}`;L(s,p),k(r,typeof e.instance!==void 0)}async function aS(r,e){const{args:t}=r;if(!e.instance)throw 'instance not initialized';let s;e.instance.terminate&&(s=await e.instance.terminate(...t??[])),k(r,s)}function aT(r){if(!r.args)throw 'Missing globals while syncing';L(r.args[0],p),k(r,{})}function aU(){let r={};onmessage=e=>{let t=e.data;switch(t.type) {case g.INIT:aR(t,r);break;case g.FORWARD:aP(t,r);break;case g.TERMINATE:aS(t,r);break;case g.GLOBALS_SYNC:aT(t);break}}}K()&&aU();function aV(r,e){return p[r]||(p[r]=e),[()=>p[r],async t=>(p[r]=t,await aO())]}function aW(r,e){return aV(r,e)}function aZ(r){aY(r)}function D(){return aX()}class V{constructor(e,t){aC(this,'uuid'),this.config=e,this.uuid=t??aL()}async send(e){var t,s,i;const{appId:n,sourceType:o}=(t=D())!=null?t:{};if(!n||!o)return'metadata missing';const a=new AbortController;return await ((i=(s=this.config)==null?void 0:s.fetch)!=null?i:fetch)(this.getUrl(),{method:'POST',headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(setTimeout(()=>a.abort(),aG)),'success'}getUrl(){var e,t=(e=D().proxyUrl)!=null?e:aF;return t+=(t.at(-1)==='/'?'':'/')+aE,t}getHeaders(){return{'Content-Type':'application/json'}}buildReport(e){let t=D();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const A='3.0.0',W=class W{};W.updates={transformer_new:'New transformer',transformer_null:'Null transformer'},W.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'};let f=W;function bA(r){return typeof r=='object'&&r!==null&&'message' in r&&typeof r.message=='string'}function bB(r){if(bA(r))return r;try{return Error(JSON.stringify(r))}catch{return Error(`${r}`)}}function $(r){return bB(r).message}class Ae{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new V(e, t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,i=(Date.now()-e)/1e3;return t/i}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:s,frameTransformedCount:i,frameFromSourceCount:n}=this,o=Date.now(),a=(o-s)/1e3,l=i/a,w=n/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:'QoS',fps:w,transformedFps:l,framesTransformed:i,...e})):'success'}}var bC=(r=>(r.FPS_DROP='fps_drop',r))(bC||{}),bD=(r=>(r.start='start',r.transform='transform',r.flush='flush',r))(bD||{}),U=(r=>(r.pipeline_ended='pipeline_ended',r.pipeline_ended_with_error='pipeline_ended_with_error',r.pipeline_started='pipeline_started',r.pipeline_started_with_error='pipeline_started_with_error',r.pipeline_restarted='pipeline_restarted',r.pipeline_restarted_with_error='pipeline_restarted_with_error',r))(U||{});const bE=500,bF=0.8;class Oe extends h{constructor(e,t){super(),this.reporter_=new V,this.reporterQos_=new Ae({loggingIntervalFrameCount:bE,report:{version:A}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_='Custom','getTransformerType' in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:'Create'})}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(t){this.report({message:f.errors.transformer_start,variation:'Error',error:$(t)});this.emit('error',{eventMetaData:{transformerIndex:this.index_},error:t,function:'start'})}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn('[Pipeline] flush from transform'),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(s){this.report({message:f.errors.transformer_transform,variation:'Error',error:$(s)});this.emit('error',{eventMetaData:{transformerIndex:this.index_},error:s,function:'transform'})}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*bF>this.reporterQos_.fps){this.emit('warn',{eventMetaData:{transformerIndex:this.index_},warningType:'fps_drop',dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}})}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=='function'&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:f.errors.transformer_flush,variation:'Error',error:$(t)});this.emit('error',{eventMetaData:{transformerIndex:this.index_},error:t,function:'flush'})}}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(e){this.reporter_.send({version:A,action:'MediaTransformer',transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:A,action:'MediaTransformer',transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class Le extends h{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let s=new Oe(e[t], t);s.on('error',i=>this.emit('error',i)),s.on('warn',i=>this.emit('warn',i)),this.transformers_.push(s)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log('[Pipeline] No transformers.');return}try{let s=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async ()=>(console.log('[Pipeline] Setup.'),await t.abort(),await s.cancel(),this.emit('pipelineInfo','pipeline_ended'))).catch(async i=>(e.cancel().then(()=>console.log('[Pipeline] Shutting down streams after abort.')).catch(n=>console.error('[Pipeline] Error from stream transform:',n)),await t.abort(i),await s.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 e of this.transformers_)e.stop()}}class We extends h{constructor(){super(),this.reporter_=new V,this.trackExpectedRate_=-1,this.report({variation:'Create'})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_?.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==='video'){const s=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=s.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error('Cannot process audio tracks inside a web worker when passing a track to transform')}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise((e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:f.errors.transformer_none,variation:'Error'}),t('[MediaProcessor] Need to set transformers.');return}if(!this.readable_){this.report({variation:'Error',message:f.errors.readable_null}),t('[MediaProcessor] Readable is null.');return}if(!this.writable_){this.report({variation:'Error',message:f.errors.writable_null}),t('[MediaProcessor] Writable is null.');return}let s=!1;this.pipeline_&&(s=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Le(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=>(s&&(i==='pipeline_started'?i=U.pipeline_restarted:i==='pipeline_started_with_error'&&(i=U.pipeline_restarted_with_error)),this.emit('pipelineInfo',i))),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>e()).catch(i=>t(i))})}setTransformers(e){return this.report({variation:'Update',message:f.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(e=>(this.pipeline_?.destroy(),this.report({variation:'Delete'}),e()))}report(e){this.reporter_.send({version:A,action:'MediaProcessor',...e})}isTrack(e){return 'kind' in e}}class Fe{constructor(){this.processor_=null,this.generator_=null}init(e){return new Promise((t,s)=>{try{this.processor_=new MediaStreamTrackProcessor(e)}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${i}`),s(i)}try{e.kind==='audio'?this.generator_=new MediaStreamTrackGenerator({kind:'audio'}):e.kind==='video'?this.generator_=new MediaStreamTrackGenerator({kind:'video'}):s('kind not supported')}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${i}`),s(i)}t()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class ze{constructor(e){this.mediaProcessor_=e}async setTrack(e){if(!(this.mediaProcessor_ instanceof We)&&await X()){if(e.kind==='audio')throw Error('Cannot process audio tracks inside a web worker when passing a track to transform');return await this.mediaProcessor_.transform(e)}if(J()){let t=new Fe;return await t.init(e),await this.mediaProcessor_.transform(t.getReadable(),t.getWriteable()),t.getProccesorTrack()}throw Error('MediaStreamTrack API for Insertable Streams of Media is not supported')}destroy(){return new Promise((e,t)=>this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>e()).catch(s=>t(s)):t('no processor'))}}export{bD as ErrorFunction,We as MediaProcessor,ze as MediaProcessorConnector,U as PipelineInfoData,aD as VonageSourceType,bC as WarningType,D as getVonageMetadata,_f as isSupported,aZ as setVonageMetadata};
@@ -658,7 +658,7 @@ class V {
658
658
  };
659
659
  }
660
660
  }
661
- const A = "3.0.0-alpha.2", W = class W {
661
+ const A = "3.0.0", W = class W {
662
662
  };
663
663
  W.updates = {
664
664
  transformer_new: "New transformer",
@@ -1,2 +1,2 @@
1
1
  (function(l,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(l=typeof globalThis<"u"?globalThis:l||self,k(l["media-processor"]={}))})(this,(function(l){"use strict";var T,S;self.MediaStreamTrackProcessor||(self.MediaStreamTrackProcessor=(T=class{constructor(e){const t=e.track??e;t.kind=="video"?this.readable=new ReadableStream({async start(s){t.addEventListener("ended",()=>s.close(),{once:!0}),this.video=document.createElement("video"),this.video.srcObject=new MediaStream([t]),await Promise.all([this.video.play(),new Promise(i=>this.video.onloadedmetadata=i)]),this.track=t,this.canvas=new OffscreenCanvas(this.video.videoWidth,this.video.videoHeight),this.ctx=this.canvas.getContext("2d",{desynchronized:!0}),this.t1=performance.now()},async pull(s){if(t.readyState=="ended")return s.close();const i=t.getSettings().frameRate||30;for(;performance.now()-this.t1<1e3/i;)if(await new Promise(n=>requestAnimationFrame(n)),t.readyState=="ended")return s.close();this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,this.t1=performance.now(),this.ctx.drawImage(this.video,0,0),s.enqueue(new VideoFrame(this.canvas,{timestamp:this.t1}))}}):t.kind=="audio"&&(this.readable=new ReadableStream({async start(s){t.addEventListener("ended",()=>s.close(),{once:!0}),this.ac=new AudioContext,this.arrays=[];function i(){registerProcessor("mstp-shim",class extends AudioWorkletProcessor{process(o){return this.port.postMessage(o),!0}})}await this.ac.audioWorklet.addModule(`data:text/javascript,(${i.toString()})()`),this.node=new AudioWorkletNode(this.ac,"mstp-shim"),this.ac.createMediaStreamSource(new MediaStream([t])).connect(this.node),this.node.port.addEventListener("message",({data:n})=>n[0][0]&&this.arrays.push(n))},async pull(s){if(t.readyState=="ended")return s.close();for(;!this.arrays.length;)if(await new Promise(o=>this.node.port.onmessage=o),t.readyState=="ended")return s.close();const[i]=this.arrays.shift(),n=new Float32Array(i.reduce((o,a)=>o+a.length,0));i.reduce((o,a)=>(n.set(a,o),o+a.length),0),s.enqueue(new AudioData({format:"f32-planar",sampleRate:this.ac.sampleRate,numberOfFrames:i[0].length,numberOfChannels:i.length,timestamp:this.ac.currentTime*1e6|0,data:n,transfer:[n.buffer]}))}}))}},T.__POLYFILLED=!0,T)),self.MediaStreamTrackGenerator||(self.MediaStreamTrackGenerator=(S=class{constructor({kind:e}){if(e=="video"){const t=document.createElement("canvas"),s=t.getContext("2d",{desynchronized:!0}),i=t.captureStream().getVideoTracks()[0];return i.writable=new WritableStream({write(n){t.width=n.displayWidth,t.height=n.displayHeight,s.drawImage(n,0,0,t.width,t.height),n.close()}}),i}else if(e=="audio"){const t=new AudioContext,s=t.createMediaStreamDestination(),[i]=s.stream.getAudioTracks();return i.writable=new WritableStream({async start(n){this.arrays=[];function o(){registerProcessor("mstg-shim",class extends AudioWorkletProcessor{constructor(){super(),this.arrays=[],this.arrayOffset=0,this.port.onmessage=({data:d})=>this.arrays.push(d),this.emptyArray=new Float32Array(0)}process(d,[[E]]){for(let H=0;H<E.length;H++)(!this.array||this.arrayOffset>=this.array.length)&&(this.array=this.arrays.shift()||this.emptyArray,this.arrayOffset=0),E[H]=this.array[this.arrayOffset++]||0;return!0}})}return await t.audioWorklet.addModule(`data:text/javascript,(${o.toString()})()`),this.node=new AudioWorkletNode(t,"mstg-shim"),this.node.connect(s),i},write(n){const o=new Float32Array(n.numberOfFrames*n.numberOfChannels);n.copyTo(o,{planeIndex:0}),this.node.port.postMessage(o,[o.buffer]),n.close()}}),i}}},S.__POLYFILLED=!0,S));async function k(){return new Promise(async(r,e)=>{await Y()||Q()?r():e("Your browser does not support the MediaStreamTrack API for Insertable Streams of Media.")})}function Q(){return self.MediaStreamTrackProcessor!==void 0&&self.MediaStreamTrackGenerator!==void 0&&(!(self.MediaStreamTrackProcessor.hasOwnProperty("__POLYFILLED")||self.MediaStreamTrackGenerator.hasOwnProperty("__POLYFILLED"))||ne())}function ne(){return[self.ReadableStream,self.WritableStream,self.MediaStream,self.OffscreenCanvas,self.VideoFrame,self.AudioContext,self.AudioWorkletNode].filter(r=>r===void 0).length===0}function Y(){return new Promise(r=>{function e(){self.postMessage(typeof MediaStreamTrackProcessor<"u"&&typeof VideoTrackGenerator<"u")}const t=new Worker(`data:text/javascript,(${e.toString()})()`);t.onmessage=({data:s})=>r(s)})}const p=new WeakMap,g=new WeakMap,f=new WeakMap,M=Symbol("anyProducer"),q=Promise.resolve(),A=Symbol("listenerAdded"),R=Symbol("listenerRemoved");let I=!1,$=!1;const x=r=>typeof r=="string"||typeof r=="symbol"||typeof r=="number";function w(r){if(!x(r))throw new TypeError("`eventName` must be a string, symbol, or number")}function C(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function _(r,e){const t=g.get(r);if(t.has(e))return t.get(e)}function v(r,e){const t=x(e)?e:M,s=f.get(r);if(s.has(t))return s.get(t)}function oe(r,e,t){const s=f.get(r);if(s.has(e))for(const i of s.get(e))i.enqueue(t);if(s.has(M)){const i=Promise.all([e,t]);for(const n of s.get(M))n.enqueue(i)}}function B(r,e){e=Array.isArray(e)?e:[e];let t=!1,s=()=>{},i=[];const n={enqueue(o){i.push(o),s()},finish(){t=!0,s()}};for(const o of e){let a=v(r,o);a||(a=new Set,f.get(r).set(o,a)),a.add(n)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{s=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const d=v(r,a);d&&(d.delete(n),d.size===0&&f.get(r).delete(a))}return s(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function J(r){if(r===void 0)return X;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!X.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const b=r=>r===A||r===R;function O(r,e,t){if(b(e))try{I=!0,r.emit(e,t)}finally{I=!1}}class h{static mixin(e,t){return t=J(t),s=>{if(typeof s!="function")throw new TypeError("`target` must be function");for(const o of t)if(s.prototype[o]!==void 0)throw new Error(`The property \`${o}\` already exists on \`target\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new h}),this[e]}Object.defineProperty(s.prototype,e,{enumerable:!1,get:i});const n=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(s.prototype,o,{enumerable:!1,value:n(o)});return s}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return $;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||$}static set isDebugEnabled(e){$=e}constructor(e={}){p.set(this,new Set),g.set(this,new Map),f.set(this,new Map),f.get(this).set(M,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,s,i,n)=>{try{n=JSON.stringify(n)}catch{n=`Object with the following keys failed to stringify: ${Object.keys(n).join(",")}`}(typeof i=="symbol"||typeof i=="number")&&(i=i.toString());const o=new Date,a=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${s}] Event Name: ${i}
2
- data: ${n}`)})}logIfDebugEnabled(e,t,s){(h.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,s)}on(e,t,{signal:s}={}){C(t),e=Array.isArray(e)?e:[e];for(const n of e){w(n);let o=_(this,n);o||(o=new Set,g.get(this).set(n,o)),o.add(t),this.logIfDebugEnabled("subscribe",n,void 0),b(n)||O(this,A,{eventName:n,listener:t})}const i=()=>{this.off(e,t),s?.removeEventListener("abort",i)};return s?.addEventListener("abort",i,{once:!0}),s?.aborted&&i(),i}off(e,t){C(t),e=Array.isArray(e)?e:[e];for(const s of e){w(s);const i=_(this,s);i&&(i.delete(t),i.size===0&&g.get(this).delete(s)),this.logIfDebugEnabled("unsubscribe",s,void 0),b(s)||O(this,R,{eventName:s,listener:t})}}once(e,t){if(t!==void 0&&typeof t!="function")throw new TypeError("predicate must be a function");let s;const i=new Promise(n=>{s=this.on(e,o=>{t&&!t(o)||(s(),n(o))})});return i.off=s,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)w(t);return B(this,e)}async emit(e,t){if(w(e),b(e)&&!I)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),oe(this,e,t);const s=_(this,e)??new Set,i=p.get(this),n=[...s],o=b(e)?[]:[...i];await q,await Promise.all([...n.map(async a=>{if(s.has(a))return a(t)}),...o.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(w(e),b(e)&&!I)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const s=_(this,e)??new Set,i=p.get(this),n=[...s],o=[...i];await q;for(const a of n)s.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){C(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),p.get(this).add(e),O(this,A,{listener:e});const s=()=>{this.offAny(e),t?.removeEventListener("abort",s)};return t?.addEventListener("abort",s,{once:!0}),t?.aborted&&s(),s}anyEvent(){return B(this)}offAny(e){C(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),O(this,R,{listener:e}),p.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),x(t)){const s=_(this,t);s&&s.clear();const i=v(this,t);if(i){for(const n of i)n.finish();i.clear()}}else{p.get(this).clear();for(const[s,i]of g.get(this).entries())i.clear(),g.get(this).delete(s);for(const[s,i]of f.get(this).entries()){for(const n of i)n.finish();i.clear(),f.get(this).delete(s)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const s of e){if(x(s)){t+=p.get(this).size+(_(this,s)?.size??0)+(v(this,s)?.size??0)+(v(this)?.size??0);continue}s!==void 0&&w(s),t+=p.get(this).size;for(const i of g.get(this).values())t+=i.size;for(const i of f.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=J(t);for(const s of t){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 X=Object.getOwnPropertyNames(h.prototype).filter(r=>r!=="constructor");Object.defineProperty(h,"listenerAdded",{value:A,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(h,"listenerRemoved",{value:R,writable:!1,enumerable:!0,configurable:!1});var ae=Object.defineProperty,ce=(r,e,t)=>e in r?ae(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,le=(r,e,t)=>(ce(r,e+"",t),t),Z=(r=>(r.automation="automation",r.test="test",r.vbc="vbc",r.video="video",r.voice="voice",r))(Z||{});const de="hlg.tokbox.com/prod/logging/vcp_webrtc",fe="https://",he=1e4;let L;const ue=new Uint8Array(16);function pe(){if(!L&&(L=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!L))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return L(ue)}const c=[];for(let r=0;r<256;++r)c.push((r+256).toString(16).slice(1));function me(r,e=0){return(c[r[e+0]]+c[r[e+1]]+c[r[e+2]]+c[r[e+3]]+"-"+c[r[e+4]]+c[r[e+5]]+"-"+c[r[e+6]]+c[r[e+7]]+"-"+c[r[e+8]]+c[r[e+9]]+"-"+c[r[e+10]]+c[r[e+11]]+c[r[e+12]]+c[r[e+13]]+c[r[e+14]]+c[r[e+15]]).toLowerCase()}const K={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ge(r,e,t){if(K.randomUUID&&!r)return K.randomUUID();r=r||{};const s=r.random||(r.rng||pe)();return s[6]=s[6]&15|64,s[8]=s[8]&63|128,me(s)}function V(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const m=V("globals",{});var y=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(y||{});function N(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}let ye=0;function we(r,e,t,s,i){const n=ye++;return r.postMessage({id:n,type:e,functionName:t,args:s},s.filter(a=>N(a))),new Promise(a=>{i?.set(n,a)})}function P(r,e){const{id:t,type:s}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:s,result:e},i.filter(n=>N(n)))}const ee=V("workerized",{});function te(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function _e(){if(te())P({type:y.GLOBALS_SYNC},m);else{const r=[];for(const e in ee){const{worker:t,resolvers:s}=ee[e].workerContext;t&&r.push(we(t,y.GLOBALS_SYNC,"",[m],s))}await Promise.all(r)}}function W(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],W(r[t],e[t])):typeof r[t]=="object"?(e[t]={},W(r[t],e[t])):e[t]=r[t]}async function be(r,e){const{functionName:t,args:s}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;P(r,await e.instance[t](...s??[]))}const Te=V("registeredWorkers",{});function Se(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,s]=r.args,i=Te[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;W(s,m),P(r,typeof e.instance!==void 0)}async function Ee(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let s;e.instance.terminate&&(s=await e.instance.terminate(...t??[])),P(r,s)}function ke(r){if(!r.args)throw"Missing globals while syncing";W(r.args[0],m),P(r,{})}function ve(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case y.INIT:Se(t,r);break;case y.FORWARD:be(t,r);break;case y.TERMINATE:Ee(t,r);break;case y.GLOBALS_SYNC:ke(t);break}}}te()&&ve();function Pe(r,e){return m[r]||(m[r]=e),[()=>m[r],async t=>{m[r]=t,await _e()}]}function Me(r,e){return Pe(r,e)}const[Ae,Re]=Me("metadata");function Ie(r){Re(r)}function F(){return Ae()}class z{constructor(e,t){le(this,"uuid"),this.config=e,this.uuid=t??ge()}async send(e){var t,s,i;const{appId:n,sourceType:o}=(t=F())!=null?t:{};if(!n||!o)return"metadata missing";const a=new AbortController,d=setTimeout(()=>a.abort(),he);return await((i=(s=this.config)==null?void 0:s.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(d),"success"}getUrl(){var e;let t=(e=F().proxyUrl)!=null?e:fe;return t+=(t.at(-1)==="/"?"":"/")+de,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=F();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const D="3.0.0-alpha.2",U=class U{};U.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},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"};let u=U;function xe(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function Ce(r){if(xe(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function j(r){return Ce(r).message}class Oe{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new z(e,t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,i=(Date.now()-e)/1e3;return t/i}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:s,frameTransformedCount:i,frameFromSourceCount:n}=this,o=Date.now(),a=(o-s)/1e3,d=i/a,E=n/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:E,transformedFps:d,framesTransformed:i,...e})):"success"}}var re=(r=>(r.FPS_DROP="fps_drop",r))(re||{}),se=(r=>(r.start="start",r.transform="transform",r.flush="flush",r))(se||{}),G=(r=>(r.pipeline_ended="pipeline_ended",r.pipeline_ended_with_error="pipeline_ended_with_error",r.pipeline_started="pipeline_started",r.pipeline_started_with_error="pipeline_started_with_error",r.pipeline_restarted="pipeline_restarted",r.pipeline_restarted_with_error="pipeline_restarted_with_error",r))(G||{});const Le=500,We=.8;class Fe extends h{constructor(e,t){super(),this.reporter_=new z,this.reporterQos_=new Oe({loggingIntervalFrameCount:Le,report:{version:D}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:"Create"})}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(t){this.report({message:u.errors.transformer_start,variation:"Error",error:j(t)});const s={eventMetaData:{transformerIndex:this.index_},error:t,function:"start"};this.emit("error",s)}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(s){this.report({message:u.errors.transformer_transform,variation:"Error",error:j(s)});const i={eventMetaData:{transformerIndex:this.index_},error:s,function:"transform"};this.emit("error",i)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*We>this.reporterQos_.fps){const s={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",s)}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:u.errors.transformer_flush,variation:"Error",error:j(t)});const s={eventMetaData:{transformerIndex:this.index_},error:t,function:"flush"};this.emit("error",s)}}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(e){this.reporter_.send({version:D,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:D,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class De extends h{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let s=new Fe(e[t],t);s.on("error",i=>{this.emit("error",i)}),s.on("warn",i=>{this.emit("warn",i)}),this.transformers_.push(s)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let s=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async()=>{console.log("[Pipeline] Setup."),await t.abort(),await s.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async i=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(n=>{console.error("[Pipeline] Error from stream transform:",n)}),await t.abort(i),await s.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 e of this.transformers_)e.stop()}}class ie extends h{constructor(){super(),this.reporter_=new z,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==="video"){const s=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=s.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise(async(e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:u.errors.transformer_none,variation:"Error"}),t("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:u.errors.readable_null}),t("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:u.errors.writable_null}),t("[MediaProcessor] Writable is null.");return}let s=!1;this.pipeline_&&(s=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new De(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=>{s&&(i==="pipeline_started"?i=G.pipeline_restarted:i==="pipeline_started_with_error"&&(i=G.pipeline_restarted_with_error)),this.emit("pipelineInfo",i)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(i=>{t(i)})})}setTransformers(e){return this.report({variation:"Update",message:u.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async e=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),e()})}report(e){this.reporter_.send({version:D,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}class Ge{constructor(){this.processor_=null,this.generator_=null}init(e){return new Promise((t,s)=>{try{this.processor_=new MediaStreamTrackProcessor(e)}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${i}`),s(i)}try{e.kind==="audio"?this.generator_=new MediaStreamTrackGenerator({kind:"audio"}):e.kind==="video"?this.generator_=new MediaStreamTrackGenerator({kind:"video"}):s("kind not supported")}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${i}`),s(i)}t()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class Ue{constructor(e){this.mediaProcessor_=e}async setTrack(e){if(!(this.mediaProcessor_ instanceof ie)&&await Y()){if(e.kind==="audio")throw Error("Cannot process audio tracks inside a web worker when passing a track to transform");return await this.mediaProcessor_.transform(e)}if(Q()){const t=new Ge;return await t.init(e),await this.mediaProcessor_.transform(t.getReadable(),t.getWriteable()),t.getProccesorTrack()}throw Error("MediaStreamTrack API for Insertable Streams of Media is not supported")}destroy(){return new Promise((e,t)=>{this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>{e()}).catch(s=>{t(s)}):t("no processor")})}}l.ErrorFunction=se,l.MediaProcessor=ie,l.MediaProcessorConnector=Ue,l.PipelineInfoData=G,l.VonageSourceType=Z,l.WarningType=re,l.getVonageMetadata=F,l.isSupported=k,l.setVonageMetadata=Ie,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
2
+ data: ${n}`)})}logIfDebugEnabled(e,t,s){(h.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,s)}on(e,t,{signal:s}={}){C(t),e=Array.isArray(e)?e:[e];for(const n of e){w(n);let o=_(this,n);o||(o=new Set,g.get(this).set(n,o)),o.add(t),this.logIfDebugEnabled("subscribe",n,void 0),b(n)||O(this,A,{eventName:n,listener:t})}const i=()=>{this.off(e,t),s?.removeEventListener("abort",i)};return s?.addEventListener("abort",i,{once:!0}),s?.aborted&&i(),i}off(e,t){C(t),e=Array.isArray(e)?e:[e];for(const s of e){w(s);const i=_(this,s);i&&(i.delete(t),i.size===0&&g.get(this).delete(s)),this.logIfDebugEnabled("unsubscribe",s,void 0),b(s)||O(this,R,{eventName:s,listener:t})}}once(e,t){if(t!==void 0&&typeof t!="function")throw new TypeError("predicate must be a function");let s;const i=new Promise(n=>{s=this.on(e,o=>{t&&!t(o)||(s(),n(o))})});return i.off=s,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)w(t);return B(this,e)}async emit(e,t){if(w(e),b(e)&&!I)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),oe(this,e,t);const s=_(this,e)??new Set,i=p.get(this),n=[...s],o=b(e)?[]:[...i];await q,await Promise.all([...n.map(async a=>{if(s.has(a))return a(t)}),...o.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(w(e),b(e)&&!I)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const s=_(this,e)??new Set,i=p.get(this),n=[...s],o=[...i];await q;for(const a of n)s.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){C(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),p.get(this).add(e),O(this,A,{listener:e});const s=()=>{this.offAny(e),t?.removeEventListener("abort",s)};return t?.addEventListener("abort",s,{once:!0}),t?.aborted&&s(),s}anyEvent(){return B(this)}offAny(e){C(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),O(this,R,{listener:e}),p.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),x(t)){const s=_(this,t);s&&s.clear();const i=v(this,t);if(i){for(const n of i)n.finish();i.clear()}}else{p.get(this).clear();for(const[s,i]of g.get(this).entries())i.clear(),g.get(this).delete(s);for(const[s,i]of f.get(this).entries()){for(const n of i)n.finish();i.clear(),f.get(this).delete(s)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const s of e){if(x(s)){t+=p.get(this).size+(_(this,s)?.size??0)+(v(this,s)?.size??0)+(v(this)?.size??0);continue}s!==void 0&&w(s),t+=p.get(this).size;for(const i of g.get(this).values())t+=i.size;for(const i of f.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=J(t);for(const s of t){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 X=Object.getOwnPropertyNames(h.prototype).filter(r=>r!=="constructor");Object.defineProperty(h,"listenerAdded",{value:A,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(h,"listenerRemoved",{value:R,writable:!1,enumerable:!0,configurable:!1});var ae=Object.defineProperty,ce=(r,e,t)=>e in r?ae(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,le=(r,e,t)=>(ce(r,e+"",t),t),Z=(r=>(r.automation="automation",r.test="test",r.vbc="vbc",r.video="video",r.voice="voice",r))(Z||{});const de="hlg.tokbox.com/prod/logging/vcp_webrtc",fe="https://",he=1e4;let L;const ue=new Uint8Array(16);function pe(){if(!L&&(L=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!L))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return L(ue)}const c=[];for(let r=0;r<256;++r)c.push((r+256).toString(16).slice(1));function me(r,e=0){return(c[r[e+0]]+c[r[e+1]]+c[r[e+2]]+c[r[e+3]]+"-"+c[r[e+4]]+c[r[e+5]]+"-"+c[r[e+6]]+c[r[e+7]]+"-"+c[r[e+8]]+c[r[e+9]]+"-"+c[r[e+10]]+c[r[e+11]]+c[r[e+12]]+c[r[e+13]]+c[r[e+14]]+c[r[e+15]]).toLowerCase()}const K={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ge(r,e,t){if(K.randomUUID&&!r)return K.randomUUID();r=r||{};const s=r.random||(r.rng||pe)();return s[6]=s[6]&15|64,s[8]=s[8]&63|128,me(s)}function V(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const m=V("globals",{});var y=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(y||{});function N(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}let ye=0;function we(r,e,t,s,i){const n=ye++;return r.postMessage({id:n,type:e,functionName:t,args:s},s.filter(a=>N(a))),new Promise(a=>{i?.set(n,a)})}function P(r,e){const{id:t,type:s}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:s,result:e},i.filter(n=>N(n)))}const ee=V("workerized",{});function te(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function _e(){if(te())P({type:y.GLOBALS_SYNC},m);else{const r=[];for(const e in ee){const{worker:t,resolvers:s}=ee[e].workerContext;t&&r.push(we(t,y.GLOBALS_SYNC,"",[m],s))}await Promise.all(r)}}function W(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],W(r[t],e[t])):typeof r[t]=="object"?(e[t]={},W(r[t],e[t])):e[t]=r[t]}async function be(r,e){const{functionName:t,args:s}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;P(r,await e.instance[t](...s??[]))}const Te=V("registeredWorkers",{});function Se(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,s]=r.args,i=Te[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;W(s,m),P(r,typeof e.instance!==void 0)}async function Ee(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let s;e.instance.terminate&&(s=await e.instance.terminate(...t??[])),P(r,s)}function ke(r){if(!r.args)throw"Missing globals while syncing";W(r.args[0],m),P(r,{})}function ve(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case y.INIT:Se(t,r);break;case y.FORWARD:be(t,r);break;case y.TERMINATE:Ee(t,r);break;case y.GLOBALS_SYNC:ke(t);break}}}te()&&ve();function Pe(r,e){return m[r]||(m[r]=e),[()=>m[r],async t=>{m[r]=t,await _e()}]}function Me(r,e){return Pe(r,e)}const[Ae,Re]=Me("metadata");function Ie(r){Re(r)}function F(){return Ae()}class z{constructor(e,t){le(this,"uuid"),this.config=e,this.uuid=t??ge()}async send(e){var t,s,i;const{appId:n,sourceType:o}=(t=F())!=null?t:{};if(!n||!o)return"metadata missing";const a=new AbortController,d=setTimeout(()=>a.abort(),he);return await((i=(s=this.config)==null?void 0:s.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(d),"success"}getUrl(){var e;let t=(e=F().proxyUrl)!=null?e:fe;return t+=(t.at(-1)==="/"?"":"/")+de,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=F();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const D="3.0.0",U=class U{};U.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},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"};let u=U;function xe(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function Ce(r){if(xe(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function j(r){return Ce(r).message}class Oe{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new z(e,t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,i=(Date.now()-e)/1e3;return t/i}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:s,frameTransformedCount:i,frameFromSourceCount:n}=this,o=Date.now(),a=(o-s)/1e3,d=i/a,E=n/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:E,transformedFps:d,framesTransformed:i,...e})):"success"}}var re=(r=>(r.FPS_DROP="fps_drop",r))(re||{}),se=(r=>(r.start="start",r.transform="transform",r.flush="flush",r))(se||{}),G=(r=>(r.pipeline_ended="pipeline_ended",r.pipeline_ended_with_error="pipeline_ended_with_error",r.pipeline_started="pipeline_started",r.pipeline_started_with_error="pipeline_started_with_error",r.pipeline_restarted="pipeline_restarted",r.pipeline_restarted_with_error="pipeline_restarted_with_error",r))(G||{});const Le=500,We=.8;class Fe extends h{constructor(e,t){super(),this.reporter_=new z,this.reporterQos_=new Oe({loggingIntervalFrameCount:Le,report:{version:D}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:"Create"})}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(t){this.report({message:u.errors.transformer_start,variation:"Error",error:j(t)});const s={eventMetaData:{transformerIndex:this.index_},error:t,function:"start"};this.emit("error",s)}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(s){this.report({message:u.errors.transformer_transform,variation:"Error",error:j(s)});const i={eventMetaData:{transformerIndex:this.index_},error:s,function:"transform"};this.emit("error",i)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*We>this.reporterQos_.fps){const s={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",s)}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:u.errors.transformer_flush,variation:"Error",error:j(t)});const s={eventMetaData:{transformerIndex:this.index_},error:t,function:"flush"};this.emit("error",s)}}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(e){this.reporter_.send({version:D,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:D,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class De extends h{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let s=new Fe(e[t],t);s.on("error",i=>{this.emit("error",i)}),s.on("warn",i=>{this.emit("warn",i)}),this.transformers_.push(s)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let s=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async()=>{console.log("[Pipeline] Setup."),await t.abort(),await s.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async i=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(n=>{console.error("[Pipeline] Error from stream transform:",n)}),await t.abort(i),await s.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 e of this.transformers_)e.stop()}}class ie extends h{constructor(){super(),this.reporter_=new z,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==="video"){const s=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=s.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise(async(e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:u.errors.transformer_none,variation:"Error"}),t("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:u.errors.readable_null}),t("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:u.errors.writable_null}),t("[MediaProcessor] Writable is null.");return}let s=!1;this.pipeline_&&(s=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new De(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=>{s&&(i==="pipeline_started"?i=G.pipeline_restarted:i==="pipeline_started_with_error"&&(i=G.pipeline_restarted_with_error)),this.emit("pipelineInfo",i)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(i=>{t(i)})})}setTransformers(e){return this.report({variation:"Update",message:u.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async e=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),e()})}report(e){this.reporter_.send({version:D,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}class Ge{constructor(){this.processor_=null,this.generator_=null}init(e){return new Promise((t,s)=>{try{this.processor_=new MediaStreamTrackProcessor(e)}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${i}`),s(i)}try{e.kind==="audio"?this.generator_=new MediaStreamTrackGenerator({kind:"audio"}):e.kind==="video"?this.generator_=new MediaStreamTrackGenerator({kind:"video"}):s("kind not supported")}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${i}`),s(i)}t()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class Ue{constructor(e){this.mediaProcessor_=e}async setTrack(e){if(!(this.mediaProcessor_ instanceof ie)&&await Y()){if(e.kind==="audio")throw Error("Cannot process audio tracks inside a web worker when passing a track to transform");return await this.mediaProcessor_.transform(e)}if(Q()){const t=new Ge;return await t.init(e),await this.mediaProcessor_.transform(t.getReadable(),t.getWriteable()),t.getProccesorTrack()}throw Error("MediaStreamTrack API for Insertable Streams of Media is not supported")}destroy(){return new Promise((e,t)=>{this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>{e()}).catch(s=>{t(s)}):t("no processor")})}}l.ErrorFunction=se,l.MediaProcessor=ie,l.MediaProcessorConnector=Ue,l.PipelineInfoData=G,l.VonageSourceType=Z,l.WarningType=re,l.getVonageMetadata=F,l.isSupported=k,l.setVonageMetadata=Ie,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonage/media-processor",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0",
4
4
  "author": "Vonage <vcp_webrtc@vonage.com>",
5
5
  "keywords": [
6
6
  "vonage",