g711.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. class G711 extends AudioCoder
  2. {
  3. constructor(wasm, importObj)
  4. {
  5. super(wasm, importObj);
  6. }
  7. decodeA(data)
  8. {
  9. this._copyToMemory(data);
  10. this._wasm.instance.exports._decodeG711a(data.byteLength, 0, data.byteLength);
  11. return new Int16Array(this._memory.buffer, data.byteLength, data.byteLength);
  12. }
  13. decodeU(data)
  14. {
  15. this._copyToMemory(data);
  16. this._wasm.instance.exports._decodeG711u(data.byteLength, 0, data.byteLength);
  17. return new Int16Array(this._memory.buffer, data.byteLength, data.byteLength);
  18. }
  19. encodeA(data)
  20. {
  21. this._copyToMemory(data);
  22. this._wasm.instance.exports._encodeG711a(data.byteLength, 0, data.byteLength >>> 1);
  23. return new Uint8Array(this._memory.buffer, data.byteLength, data.byteLength >>> 1);
  24. }
  25. encodeU(data)
  26. {
  27. this._copyToMemory(data);
  28. this._wasm.instance.exports._encodeG711u(data.byteLength, 0, data.byteLength >>> 1);
  29. return new Uint8Array(this._memory.buffer, data.byteLength, data.byteLength >>> 1);
  30. }
  31. }