script-audio-transform-worker.js (740B)
1 class MockRTCRtpTransformer { 2 constructor(transformer) { 3 this.context = transformer; 4 this.start(); 5 } 6 start() 7 { 8 this.reader = this.context.readable.getReader(); 9 this.writer = this.context.writable.getWriter(); 10 this.process(); 11 this.context.options.port.postMessage("started " + this.context.options.mediaType + " " + this.context.options.side); 12 } 13 14 process() 15 { 16 this.reader.read().then(chunk => { 17 if (chunk.done) 18 return; 19 20 this.writer.write(chunk.value); 21 this.process(); 22 }); 23 } 24 }; 25 26 onrtctransform = (event) => { 27 new MockRTCRtpTransformer(event.transformer); 28 }; 29 30 self.postMessage("registered");