@moq/publish 0.1.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 +100 -0
- package/audio/capture-worklet.d.ts +2 -0
- package/audio/capture-worklet.d.ts.map +1 -0
- package/audio/capture.d.ts +6 -0
- package/audio/capture.d.ts.map +1 -0
- package/audio/encoder.d.ts +31 -0
- package/audio/encoder.d.ts.map +1 -0
- package/audio/index.d.ts +3 -0
- package/audio/index.d.ts.map +1 -0
- package/audio/types.d.ts +18 -0
- package/audio/types.d.ts.map +1 -0
- package/broadcast.d.ts +36 -0
- package/broadcast.d.ts.map +1 -0
- package/chat/index.d.ts +19 -0
- package/chat/index.d.ts.map +1 -0
- package/chat/message.d.ts +19 -0
- package/chat/message.d.ts.map +1 -0
- package/chat/typing.d.ts +19 -0
- package/chat/typing.d.ts.map +1 -0
- package/element.d.ts +32 -0
- package/element.d.ts.map +1 -0
- package/element.js +141 -0
- package/element.js.map +1 -0
- package/index.d.ts +9 -0
- package/index.d.ts.map +1 -0
- package/index.js +24 -0
- package/index.js.map +1 -0
- package/libav-opus-af-BlMWboA7.js +368 -0
- package/libav-opus-af-BlMWboA7.js.map +1 -0
- package/location/index.d.ts +33 -0
- package/location/index.d.ts.map +1 -0
- package/location/peers.d.ts +26 -0
- package/location/peers.d.ts.map +1 -0
- package/location/window.d.ts +35 -0
- package/location/window.d.ts.map +1 -0
- package/main-DGBFe0O7.js +2301 -0
- package/main-DGBFe0O7.js.map +1 -0
- package/package.json +41 -0
- package/preview.d.ts +21 -0
- package/preview.d.ts.map +1 -0
- package/screen-BCioRZHS.js +6579 -0
- package/screen-BCioRZHS.js.map +1 -0
- package/source/camera.d.ts +19 -0
- package/source/camera.d.ts.map +1 -0
- package/source/device.d.ts +19 -0
- package/source/device.d.ts.map +1 -0
- package/source/file.d.ts +20 -0
- package/source/file.d.ts.map +1 -0
- package/source/index.d.ts +6 -0
- package/source/index.d.ts.map +1 -0
- package/source/microphone.d.ts +19 -0
- package/source/microphone.d.ts.map +1 -0
- package/source/screen.d.ts +22 -0
- package/source/screen.d.ts.map +1 -0
- package/support/element.d.ts +22 -0
- package/support/element.d.ts.map +1 -0
- package/support/element.js +184 -0
- package/support/element.js.map +1 -0
- package/support/index.d.ts +29 -0
- package/support/index.d.ts.map +1 -0
- package/support/index.js +63 -0
- package/support/index.js.map +1 -0
- package/ui/components/CameraSourceButton.d.ts +2 -0
- package/ui/components/CameraSourceButton.d.ts.map +1 -0
- package/ui/components/FileSourceButton.d.ts +2 -0
- package/ui/components/FileSourceButton.d.ts.map +1 -0
- package/ui/components/MediaSourceSelector.d.ts +8 -0
- package/ui/components/MediaSourceSelector.d.ts.map +1 -0
- package/ui/components/MicrophoneSourceButton.d.ts +2 -0
- package/ui/components/MicrophoneSourceButton.d.ts.map +1 -0
- package/ui/components/NothingSourceButton.d.ts +2 -0
- package/ui/components/NothingSourceButton.d.ts.map +1 -0
- package/ui/components/PublishControls.d.ts +2 -0
- package/ui/components/PublishControls.d.ts.map +1 -0
- package/ui/components/PublishStatusIndicator.d.ts +2 -0
- package/ui/components/PublishStatusIndicator.d.ts.map +1 -0
- package/ui/components/ScreenSourceButton.d.ts +2 -0
- package/ui/components/ScreenSourceButton.d.ts.map +1 -0
- package/ui/context.d.ts +25 -0
- package/ui/context.d.ts.map +1 -0
- package/ui/element.d.ts +5 -0
- package/ui/element.d.ts.map +1 -0
- package/ui/hooks/use-publish-ui.d.ts +15 -0
- package/ui/hooks/use-publish-ui.d.ts.map +1 -0
- package/ui/index.d.ts +7 -0
- package/ui/index.d.ts.map +1 -0
- package/ui/index.js +974 -0
- package/ui/index.js.map +1 -0
- package/user.d.ts +25 -0
- package/user.d.ts.map +1 -0
- package/video/encoder.d.ts +31 -0
- package/video/encoder.d.ts.map +1 -0
- package/video/index.d.ts +85 -0
- package/video/index.d.ts.map +1 -0
- package/video/polyfill.d.ts +3 -0
- package/video/polyfill.d.ts.map +1 -0
- package/video/types.d.ts +20 -0
- package/video/types.d.ts.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-DGBFe0O7.js","sources":["../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/encoded-audio-chunk.js","../../../node_modules/.bun/@ungap+global-this@0.4.4/node_modules/@ungap/global-this/esm/index.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/audio-data.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/event-target.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/avloader.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/misc.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/audio-decoder.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/audio-encoder.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/encoded-video-chunk.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/video-frame.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/video-decoder.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/video-encoder.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/rendering.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/config.js","../../../node_modules/.bun/@kixelated+libavjs-webcodecs-polyfill@0.5.5/node_modules/@kixelated/libavjs-webcodecs-polyfill/dist/main.js"],"sourcesContent":["/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nexport class EncodedAudioChunk {\n constructor(init) {\n /* 1. If init.transfer contains more than one reference to the same\n * ArrayBuffer, then throw a DataCloneError DOMException. */\n // 2. For each transferable in init.transfer:\n /* 1. If [[Detached]] internal slot is true, then throw a\n * DataCloneError DOMException. */\n // (not worth checking in a polyfill)\n /* 3. Let chunk be a new EncodedAudioChunk object, initialized as\n * follows */\n {\n // 1. Assign init.type to [[type]].\n this.type = init.type;\n // 2. Assign init.timestamp to [[timestamp]].\n this.timestamp = init.timestamp;\n /* 3. If init.duration exists, assign it to [[duration]], or assign\n * null otherwise. */\n if (typeof init.duration === \"number\")\n this.duration = init.duration;\n else\n this.duration = null;\n // 4. Assign init.data.byteLength to [[byte length]];\n this.byteLength = init.data.byteLength;\n /* 5. If init.transfer contains an ArrayBuffer referenced by\n * init.data the User Agent MAY choose to: */\n let transfer = false;\n if (init.transfer) {\n /* 1. Let resource be a new media resource referencing sample\n * data in init.data. */\n let inBuffer;\n if (init.data.buffer)\n inBuffer = init.data.buffer;\n else\n inBuffer = init.data;\n let t;\n if (init.transfer instanceof Array)\n t = init.transfer;\n else\n t = Array.from(init.transfer);\n for (const b of t) {\n if (b === inBuffer) {\n transfer = true;\n break;\n }\n }\n }\n // 6. Otherwise:\n // 1. Assign a copy of init.data to [[internal data]].\n const data = new Uint8Array(init.data.buffer || init.data, init.data.byteOffset || 0, init.data.BYTES_PER_ELEMENT\n ? (init.data.BYTES_PER_ELEMENT * init.data.length)\n : init.data.byteLength);\n if (transfer)\n this._data = data;\n else\n this._data = data.slice(0);\n }\n // 4. For each transferable in init.transfer:\n // 1. Perform DetachArrayBuffer on transferable\n // (already done by transferring)\n // 5. Return chunk.\n }\n // Internal\n _libavGetData() { return this._data; }\n copyTo(destination) {\n (new Uint8Array(destination.buffer || destination, destination.byteOffset || 0)).set(this._data);\n }\n}\n","(function (Object) {\n typeof globalThis !== 'object' && (\n this ?\n get() :\n (Object.defineProperty(Object.prototype, '_T_', {\n configurable: true,\n get: get\n }), _T_)\n );\n function get() {\n var global = this || self;\n global.globalThis = global;\n delete Object.prototype._T_;\n }\n}(Object));\nexport default globalThis;\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nimport \"@ungap/global-this\";\nexport class AudioData {\n constructor(init) {\n // 1. If init is not a valid AudioDataInit, throw a TypeError.\n AudioData._checkValidAudioDataInit(init);\n /* 2. If init.transfer contains more than one reference to the same\n * ArrayBuffer, then throw a DataCloneError DOMException. */\n // 3. For each transferable in init.transfer:\n // 1. If [[Detached]] internal slot is true, then throw a DataCloneError DOMException.\n // (Not worth doing in polyfill)\n // 4. Let frame be a new AudioData object, initialized as follows:\n {\n // 1. Assign false to [[Detached]].\n // (not doable in polyfill)\n // 2. Assign init.format to [[format]].\n this.format = init.format;\n // 3. Assign init.sampleRate to [[sample rate]].\n this.sampleRate = init.sampleRate;\n // 4. Assign init.numberOfFrames to [[number of frames]].\n this.numberOfFrames = init.numberOfFrames;\n // 5. Assign init.numberOfChannels to [[number of channels]].\n this.numberOfChannels = init.numberOfChannels;\n // 6. Assign init.timestamp to [[timestamp]].\n this.timestamp = init.timestamp;\n /* 7. If init.transfer contains an ArrayBuffer referenced by\n * init.data the User Agent MAY choose to: */\n let transfer = false;\n if (init.transfer) {\n // 1. Let resource be a new media resource referencing sample data in data.\n let inBuffer;\n if (init.data.buffer)\n inBuffer = init.data.buffer;\n else\n inBuffer = init.data;\n let t;\n if (init.transfer instanceof Array)\n t = init.transfer;\n else\n t = Array.from(init.transfer);\n for (const b of t) {\n if (b === inBuffer) {\n transfer = true;\n break;\n }\n }\n }\n // 8. Otherwise:\n // 1. Let resource be a media resource containing a copy of init.data.\n // 9. Let resourceReference be a reference to resource.\n let inData, byteOffset = 0;\n if (transfer) {\n inData = init.data;\n byteOffset = init.data.byteOffset || 0;\n }\n else {\n inData = init.data.slice(0);\n }\n const resourceReference = audioView(init.format, inData.buffer || inData, byteOffset);\n // 10. Assign resourceReference to [[resource reference]].\n this._data = resourceReference;\n }\n // 5. For each transferable in init.transfer:\n // 1. Perform DetachArrayBuffer on transferable\n // (Already done by transferring)\n // 6. Return frame.\n // Duration not calculated in spec?\n this.duration = init.numberOfFrames / init.sampleRate * 1000000;\n }\n /**\n * Convert a polyfill AudioData to a native AudioData.\n * @param opts Conversion options\n */\n toNative(opts = {}) {\n const ret = new globalThis.AudioData({\n data: this._data,\n format: this.format,\n sampleRate: this.sampleRate,\n numberOfFrames: this.numberOfFrames,\n numberOfChannels: this.numberOfChannels,\n timestamp: this.timestamp,\n transfer: opts.transfer ? [this._data.buffer] : []\n });\n if (opts.transfer)\n this.close();\n return ret;\n }\n /**\n * Convert a native AudioData to a polyfill AudioData. WARNING: Inefficient,\n * as the data cannot be transferred out.\n * @param from AudioData to copy in\n */\n static fromNative(from /* native AudioData */) {\n const ad = from;\n const isInterleaved_ = isInterleaved(ad.format);\n const planes = isInterleaved_ ? 1 : ad.numberOfChannels;\n const sizePerPlane = ad.allocationSize({\n format: ad.format,\n planeIndex: 0\n });\n const data = new Uint8Array(sizePerPlane * planes);\n for (let p = 0; p < planes; p++) {\n ad.copyTo(data.subarray(p * sizePerPlane), {\n format: ad.format,\n planeIndex: p\n });\n }\n return new AudioData({\n data,\n format: ad.format,\n sampleRate: ad.sampleRate,\n numberOfFrames: ad.numberOfFrames,\n numberOfChannels: ad.numberOfChannels,\n timestamp: ad.timestamp,\n transfer: [data.buffer]\n });\n }\n // Internal\n _libavGetData() { return this._data; }\n static _checkValidAudioDataInit(init) {\n // 1. If sampleRate less than or equal to 0, return false.\n if (init.sampleRate <= 0)\n throw new TypeError(`Invalid sample rate ${init.sampleRate}`);\n // 2. If numberOfFrames = 0, return false.\n if (init.numberOfFrames <= 0)\n throw new TypeError(`Invalid number of frames ${init.numberOfFrames}`);\n // 3. If numberOfChannels = 0, return false.\n if (init.numberOfChannels <= 0)\n throw new TypeError(`Invalid number of channels ${init.numberOfChannels}`);\n // 4. Verify data has enough data by running the following steps:\n {\n // 1. Let totalSamples be the product of multiplying numberOfFrames by numberOfChannels.\n const totalSamples = init.numberOfFrames * init.numberOfChannels;\n // 2. Let bytesPerSample be the number of bytes per sample, as defined by the format.\n const bytesPerSample_ = bytesPerSample(init.format);\n // 3. Let totalSize be the product of multiplying bytesPerSample with totalSamples.\n const totalSize = bytesPerSample_ * totalSamples;\n // 4. Let dataSize be the size in bytes of data.\n const dataSize = init.data.byteLength;\n // 5. If dataSize is less than totalSize, return false.\n if (dataSize < totalSize)\n throw new TypeError(`This audio data must be at least ${totalSize} bytes`);\n }\n // 5. Return true.\n }\n allocationSize(options) {\n // 1. If [[Detached]] is true, throw an InvalidStateError DOMException.\n if (this._data === null)\n throw new DOMException(\"Detached\", \"InvalidStateError\");\n /* 2. Let copyElementCount be the result of running the Compute Copy\n * Element Count algorithm with options. */\n const copyElementCount = this._computeCopyElementCount(options);\n // 3. Let destFormat be the value of [[format]].\n let destFormat = this.format;\n // 4. If options.format exists, assign options.format to destFormat.\n if (options.format)\n destFormat = options.format;\n /* 5. Let bytesPerSample be the number of bytes per sample, as defined\n * by the destFormat. */\n const bytesPerSample_ = bytesPerSample(destFormat);\n /* 6. Return the product of multiplying bytesPerSample by\n * copyElementCount. */\n return bytesPerSample_ * copyElementCount;\n }\n _computeCopyElementCount(options) {\n // 1. Let destFormat be the value of [[format]].\n let destFormat = this.format;\n // 2. If options.format exists, assign options.format to destFormat.\n if (options.format)\n destFormat = options.format;\n /* 3. If destFormat describes an interleaved AudioSampleFormat and\n * options.planeIndex is greater than 0, throw a RangeError. */\n const isInterleaved_ = isInterleaved(destFormat);\n if (isInterleaved_) {\n if (options.planeIndex > 0)\n throw new RangeError(\"Invalid plane\");\n }\n /* 4. Otherwise, if destFormat describes a planar AudioSampleFormat and\n * if options.planeIndex is greater or equal to [[number of channels]],\n * throw a RangeError. */\n else if (options.planeIndex >= this.numberOfChannels)\n throw new RangeError(\"Invalid plane\");\n /* 5. If [[format]] does not equal destFormat and the User Agent does\n * not support the requested AudioSampleFormat conversion, throw a\n * NotSupportedError DOMException. Conversion to f32-planar MUST always\n * be supported. */\n if (this.format !== destFormat &&\n destFormat !== \"f32-planar\")\n throw new DOMException(\"Only conversion to f32-planar is supported\", \"NotSupportedError\");\n /* 6. Let frameCount be the number of frames in the plane identified by\n * options.planeIndex. */\n const frameCount = this.numberOfFrames; // All planes have the same number of frames\n /* 7. If options.frameOffset is greater than or equal to frameCount,\n * throw a RangeError. */\n const frameOffset = options.frameOffset || 0;\n if (frameOffset >= frameCount)\n throw new RangeError(\"Frame offset out of range\");\n /* 8. Let copyFrameCount be the difference of subtracting\n * options.frameOffset from frameCount. */\n let copyFrameCount = frameCount - frameOffset;\n // 9. If options.frameCount exists:\n if (typeof options.frameCount === \"number\") {\n /* 1. If options.frameCount is greater than copyFrameCount, throw a\n * RangeError. */\n if (options.frameCount >= copyFrameCount)\n throw new RangeError(\"Frame count out of range\");\n // 2. Otherwise, assign options.frameCount to copyFrameCount.\n copyFrameCount = options.frameCount;\n }\n // 10. Let elementCount be copyFrameCount.\n let elementCount = copyFrameCount;\n /* 11. If destFormat describes an interleaved AudioSampleFormat,\n * mutliply elementCount by [[number of channels]] */\n if (isInterleaved_)\n elementCount *= this.numberOfChannels;\n // 12. return elementCount.\n return elementCount;\n }\n copyTo(destination, options) {\n // 1. If [[Detached]] is true, throw an InvalidStateError DOMException.\n if (this._data === null)\n throw new DOMException(\"Detached\", \"InvalidStateError\");\n /* 2. Let copyElementCount be the result of running the Compute Copy\n * Element Count algorithm with options. */\n const copyElementCount = this._computeCopyElementCount(options);\n // 3. Let destFormat be the value of [[format]].\n let destFormat = this.format;\n // 4. If options.format exists, assign options.format to destFormat.\n if (options.format)\n destFormat = options.format;\n /* 5. Let bytesPerSample be the number of bytes per sample, as defined\n * by the destFormat. */\n const bytesPerSample_ = bytesPerSample(destFormat);\n /* 6. If the product of multiplying bytesPerSample by copyElementCount\n * is greater than destination.byteLength, throw a RangeError. */\n if (bytesPerSample_ * copyElementCount > destination.byteLength)\n throw new RangeError(\"Buffer too small\");\n /* 7. Let resource be the media resource referenced by [[resource\n * reference]]. */\n const resource = this._data;\n /* 8. Let planeFrames be the region of resource corresponding to\n * options.planeIndex. */\n const planeFrames = resource.subarray(options.planeIndex * this.numberOfFrames);\n const frameOffset = options.frameOffset || 0;\n const numberOfChannels = this.numberOfChannels;\n /* 9. Copy elements of planeFrames into destination, starting with the\n * frame positioned at options.frameOffset and stopping after\n * copyElementCount samples have been copied. If destFormat does not\n * equal [[format]], convert elements to the destFormat\n * AudioSampleFormat while making the copy. */\n if (this.format === destFormat) {\n const dest = audioView(destFormat, destination.buffer || destination, destination.byteOffset || 0);\n if (isInterleaved(destFormat)) {\n dest.set(planeFrames.subarray(frameOffset * numberOfChannels, frameOffset * numberOfChannels + copyElementCount));\n }\n else {\n dest.set(planeFrames.subarray(frameOffset, frameOffset + copyElementCount));\n }\n }\n else {\n // Actual conversion necessary. Always to f32-planar.\n const out = audioView(destFormat, destination.buffer || destination, destination.byteOffset || 0);\n // First work out the conversion\n let sub = 0;\n let div = 1;\n switch (this.format) {\n case \"u8\":\n case \"u8-planar\":\n sub = 0x80;\n div = 0x80;\n break;\n case \"s16\":\n case \"s16-planar\":\n div = 0x8000;\n break;\n case \"s32\":\n case \"s32-planar\":\n div = 0x80000000;\n break;\n }\n // Then do it\n if (isInterleaved(this.format)) {\n for (let i = options.planeIndex + frameOffset * numberOfChannels, o = 0; o < copyElementCount; i += numberOfChannels, o++)\n out[o] = (planeFrames[i] - sub) / div;\n }\n else {\n for (let i = frameOffset, o = 0; o < copyElementCount; i++, o++)\n out[o] = (planeFrames[i] - sub) / div;\n }\n }\n }\n clone() {\n // 1. If [[Detached]] is true, throw an InvalidStateError DOMException.\n if (this._data === null)\n throw new DOMException(\"Detached\", \"InvalidStateError\");\n /* 2. Return the result of running the Clone AudioData algorithm with\n * this. */\n return new AudioData({\n format: this.format,\n sampleRate: this.sampleRate,\n numberOfFrames: this.numberOfFrames,\n numberOfChannels: this.numberOfChannels,\n timestamp: this.timestamp,\n data: this._data\n });\n }\n close() {\n this._data = null;\n }\n}\n/**\n * Construct the appropriate type of ArrayBufferView for the given sample\n * format and buffer.\n * @param format Sample format\n * @param buffer ArrayBuffer (NOT view)\n * @param byteOffset Offset into the buffer\n */\nfunction audioView(format, buffer, byteOffset) {\n switch (format) {\n case \"u8\":\n case \"u8-planar\":\n return new Uint8Array(buffer, byteOffset);\n case \"s16\":\n case \"s16-planar\":\n return new Int16Array(buffer, byteOffset);\n case \"s32\":\n case \"s32-planar\":\n return new Int32Array(buffer, byteOffset);\n case \"f32\":\n case \"f32-planar\":\n return new Float32Array(buffer, byteOffset);\n default:\n throw new TypeError(\"Invalid AudioSampleFormat\");\n }\n}\n/**\n * Number of bytes per sample of this format.\n * @param format Sample format\n */\nfunction bytesPerSample(format) {\n switch (format) {\n case \"u8\":\n case \"u8-planar\":\n return 1;\n case \"s16\":\n case \"s16-planar\":\n return 2;\n case \"s32\":\n case \"s32-planar\":\n case \"f32\":\n case \"f32-planar\":\n return 4;\n default:\n throw new TypeError(\"Invalid AudioSampleFormat\");\n }\n}\n/**\n * Is this format interleaved?\n * @param format Sample format\n */\nexport function isInterleaved(format) {\n switch (format) {\n case \"u8\":\n case \"s16\":\n case \"s32\":\n case \"f32\":\n return true;\n case \"u8-planar\":\n case \"s16-planar\":\n case \"s32-planar\":\n case \"f32-planar\":\n return false;\n default:\n throw new TypeError(\"Invalid AudioSampleFormat\");\n }\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n/* Unfortunately, browsers don't let us extend EventTarget. So, we implement an\n * EventTarget interface with a “has-a” relationship instead of an “is-a”\n * relationship. We have an event target, and expose its event functions as our\n * own. */\nexport class HasAEventTarget {\n constructor() {\n const ev = this._eventer = new EventTarget();\n this.addEventListener = ev.addEventListener.bind(ev);\n this.removeEventListener = ev.removeEventListener.bind(ev);\n this.dispatchEvent = ev.dispatchEvent.bind(ev);\n }\n}\nexport class DequeueEventTarget extends HasAEventTarget {\n constructor() {\n super();\n this.addEventListener(\"dequeue\", ev => {\n if (this.ondequeue)\n this.ondequeue(ev);\n });\n }\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n// Wrapper function to use\nexport let LibAVWrapper = null;\n// Currently available libav instances\nconst libavs = [];\n// Options required to create a LibAV instance\nlet libavOptions = {};\n/**\n * Supported decoders.\n */\nexport let decoders = null;\n/**\n * Supported encoders.\n */\nexport let encoders = null;\n/**\n * Set the libav wrapper to use.\n */\nexport function setLibAV(to) {\n LibAVWrapper = to;\n}\n/**\n * Set the libav loading options.\n */\nexport function setLibAVOptions(to) {\n libavOptions = to;\n}\n/**\n * Get a libav instance.\n */\nexport function get() {\n return __awaiter(this, void 0, void 0, function* () {\n if (libavs.length)\n return libavs.shift();\n return yield LibAVWrapper.LibAV(libavOptions);\n });\n}\n/**\n * Free a libav instance for later reuse.\n */\nexport function free(libav) {\n libavs.push(libav);\n}\n/**\n * Get the list of encoders/decoders supported by libav (which are also\n * supported by this polyfill)\n * @param encoders Check for encoders instead of decoders\n */\nfunction codecs(encoders) {\n return __awaiter(this, void 0, void 0, function* () {\n const libav = yield get();\n const ret = [];\n for (const [avname, codec] of [\n [\"flac\", \"flac\"],\n [\"libopus\", \"opus\"],\n [\"libvorbis\", \"vorbis\"],\n [\"libaom-av1\", \"av01\"],\n [\"libvpx-vp9\", \"vp09\"],\n [\"libvpx\", \"vp8\"]\n ]) {\n if (encoders) {\n if (yield libav.avcodec_find_encoder_by_name(avname))\n ret.push(codec);\n }\n else {\n if (yield libav.avcodec_find_decoder_by_name(avname))\n ret.push(codec);\n }\n }\n free(libav);\n return ret;\n });\n}\n/**\n * Load the lists of supported decoders and encoders.\n */\nexport function load() {\n return __awaiter(this, void 0, void 0, function* () {\n LibAVWrapper = LibAVWrapper || LibAV;\n decoders = yield codecs(false);\n encoders = yield codecs(true);\n });\n}\n/**\n * Convert a decoder from the codec registry (or libav.js-specific parameters)\n * to libav.js. Returns null if unsupported.\n */\nexport function decoder(codec, config) {\n if (typeof codec === \"string\") {\n codec = codec.replace(/\\..*/, \"\");\n let outCodec = codec;\n switch (codec) {\n // Audio\n case \"flac\":\n if (typeof config.description === \"undefined\") {\n // description is required per spec, but one can argue, if this limitation makes sense\n return null;\n }\n break;\n case \"opus\":\n if (typeof config.description !== \"undefined\") {\n // ogg bitstream is not supported by the current implementation\n return null;\n }\n outCodec = \"libopus\";\n break;\n case \"vorbis\":\n if (typeof config.description === \"undefined\") {\n // description is required per spec, but one can argue, if this limitation makes sense\n return null;\n }\n outCodec = \"libvorbis\";\n break;\n // Video\n case \"av01\":\n outCodec = \"libaom-av1\";\n break;\n case \"vp09\":\n outCodec = \"libvpx-vp9\";\n break;\n case \"vp8\":\n outCodec = \"libvpx\";\n break;\n // Unsupported\n case \"mp3\":\n case \"mp4a\":\n case \"ulaw\":\n case \"alaw\":\n case \"avc1\":\n case \"avc3\":\n case \"hev1\":\n case \"hvc1\":\n return null;\n // Unrecognized\n default:\n throw new TypeError(\"Unrecognized codec\");\n }\n // Check whether we actually support this codec\n if (!(decoders.indexOf(codec) >= 0))\n return null;\n return { codec: outCodec };\n }\n else {\n return codec.libavjs;\n }\n}\n/**\n * Convert an encoder from the codec registry (or libav.js-specific parameters)\n * to libav.js. Returns null if unsupported.\n */\nexport function encoder(codec, config) {\n if (typeof codec === \"string\") {\n const codecParts = codec.split(\".\");\n codec = codecParts[0];\n let outCodec = codec;\n const ctx = {};\n const options = {};\n let video = false;\n switch (codec) {\n // Audio\n case \"flac\":\n ctx.sample_fmt = 2 /* S32 */;\n ctx.bit_rate = 0;\n if (typeof config.flac === \"object\" &&\n config.flac !== null) {\n const flac = config.flac;\n // FIXME: Check block size\n if (typeof flac.blockSize === \"number\")\n ctx.frame_size = flac.blockSize;\n if (typeof flac.compressLevel === \"number\") {\n // Not supported\n return null;\n }\n }\n break;\n case \"opus\":\n outCodec = \"libopus\";\n ctx.sample_fmt = 3 /* FLT */;\n ctx.sample_rate = 48000;\n if (typeof config.opus === \"object\" &&\n config.opus !== null) {\n const opus = config.opus;\n // FIXME: Check frame duration\n if (typeof opus.frameDuration === \"number\")\n options.frame_duration = \"\" + (opus.frameDuration / 1000);\n if (typeof opus.complexity !== \"undefined\") {\n // We don't support the complexity option\n return null;\n }\n if (typeof opus.packetlossperc === \"number\") {\n if (opus.packetlossperc < 0 || opus.packetlossperc > 100)\n return null;\n options.packet_loss = \"\" + opus.packetlossperc;\n }\n if (typeof opus.useinbandfec === \"boolean\")\n options.fec = opus.useinbandfec ? \"1\" : \"0\";\n if (typeof opus.usedtx === \"boolean\") {\n // We don't support the usedtx option\n return null;\n }\n if (typeof opus.format === \"string\") {\n // ogg bitstream is not supported\n if (opus.format !== \"opus\")\n return null;\n }\n }\n break;\n case \"vorbis\":\n outCodec = \"libvorbis\";\n ctx.sample_fmt = 8 /* FLTP */;\n break;\n // Video\n case \"av01\":\n video = true;\n outCodec = \"libaom-av1\";\n if (config.latencyMode === \"realtime\") {\n options.usage = \"realtime\";\n options[\"cpu-used\"] = \"8\";\n }\n // Check for advanced options\n if (!av1Advanced(codecParts, ctx))\n return null;\n break;\n case \"vp09\":\n video = true;\n outCodec = \"libvpx-vp9\";\n if (config.latencyMode === \"realtime\") {\n options.quality = \"realtime\";\n options[\"cpu-used\"] = \"8\";\n }\n // Check for advanced options\n if (!vp9Advanced(codecParts, ctx))\n return null;\n break;\n case \"vp8\":\n video = true;\n outCodec = \"libvpx\";\n if (config.latencyMode === \"realtime\") {\n options.quality = \"realtime\";\n options[\"cpu-used\"] = \"8\";\n }\n break;\n // Unsupported\n case \"mp3\":\n case \"mp4a\":\n case \"ulaw\":\n case \"alaw\":\n case \"avc1\":\n return null;\n // Unrecognized\n default:\n throw new TypeError(\"Unrecognized codec\");\n }\n // Check whether we actually support this codec\n if (!(encoders.indexOf(codec) >= 0))\n return null;\n if (video) {\n if (typeof ctx.pix_fmt !== \"number\")\n ctx.pix_fmt = 0 /* YUV420P */;\n const width = ctx.width = config.width;\n const height = ctx.height = config.height;\n if (config.framerate) {\n /* FIXME: We need this as a rational, not a floating point, and\n * this is obviously not the right way to do it */\n ctx.framerate_num = Math.round(config.framerate);\n ctx.framerate_den = 1;\n }\n // Check for non-square pixels\n const dWidth = config.displayWidth || config.width;\n const dHeight = config.displayHeight || config.height;\n if (dWidth !== width || dHeight !== height) {\n ctx.sample_aspect_ratio_num = dWidth * height;\n ctx.sample_aspect_ratio_den = dHeight * width;\n }\n }\n else {\n if (!ctx.sample_rate)\n ctx.sample_rate = config.sampleRate || 48000;\n if (config.numberOfChannels) {\n const n = config.numberOfChannels;\n ctx.channel_layout = (n === 1) ? 4 : ((1 << n) - 1);\n }\n }\n if (typeof ctx.bit_rate !== \"number\" && config.bitrate) {\n // NOTE: CBR requests are, quite rightly, ignored\n ctx.bit_rate = config.bitrate;\n }\n return {\n codec: outCodec,\n ctx, options\n };\n }\n else {\n return codec.libavjs;\n }\n}\n/**\n * Handler for advanced options for AV1.\n * @param codecParts .-separated parts of the codec string.\n * @param ctx Context to populate with advanced options.\n */\nfunction av1Advanced(codecParts, ctx) {\n if (codecParts[1]) {\n const profile = +codecParts[1];\n if (profile >= 0 && profile <= 2)\n ctx.profile = profile;\n else\n throw new TypeError(\"Invalid AV1 profile\");\n }\n if (codecParts[2]) {\n const level = +codecParts[2];\n if (level >= 0 && level <= 23)\n ctx.level = level;\n else\n throw new TypeError(\"Invalid AV1 level\");\n }\n if (codecParts[3]) {\n switch (codecParts[3]) {\n case \"M\":\n // Default\n break;\n case \"H\":\n if (ctx.level && ctx.level >= 8) {\n // Valid but unsupported\n return false;\n }\n else {\n throw new TypeError(\"The AV1 high tier is only available for level 4.0 and up\");\n }\n break;\n default:\n throw new TypeError(\"Invalid AV1 tier\");\n }\n }\n if (codecParts[4]) {\n const depth = +codecParts[3];\n if (depth === 10 || depth === 12) {\n // Valid but unsupported\n return false;\n }\n else if (depth !== 8) {\n throw new TypeError(\"Invalid AV1 bit depth\");\n }\n }\n if (codecParts[5]) {\n // Monochrome\n switch (codecParts[5]) {\n case \"0\":\n // Default\n break;\n case \"1\":\n // Valid but unsupported\n return false;\n default:\n throw new TypeError(\"Invalid AV1 monochrome flag\");\n }\n }\n if (codecParts[6]) {\n // Subsampling mode\n switch (codecParts[6]) {\n case \"000\": // YUV444\n ctx.pix_fmt = 5 /* YUV444P */;\n break;\n case \"100\": // YUV422\n ctx.pix_fmt = 4 /* YUV422P */;\n break;\n case \"110\": // YUV420P (default)\n ctx.pix_fmt = 0 /* YUV420P */;\n break;\n case \"111\": // Monochrome\n return false;\n default:\n throw new TypeError(\"Invalid AV1 subsampling mode\");\n }\n }\n /* The remaining values have to do with color formats, which we don't\n * support correctly anyway */\n return true;\n}\n/**\n * Handler for advanced options for VP9.\n * @param codecParts .-separated parts of the codec string.\n * @param ctx Context to populate with advanced options.\n */\nfunction vp9Advanced(codecParts, ctx) {\n if (codecParts[1]) {\n const profile = +codecParts[1];\n if (profile >= 0 && profile <= 3)\n ctx.profile = profile;\n else\n throw new TypeError(\"Invalid VP9 profile\");\n }\n if (codecParts[2]) {\n const level = [+codecParts[2][0], +codecParts[2][1]];\n if (level[0] >= 1 && level[0] <= 4) {\n if (level[1] >= 0 && level[1] <= 1) {\n // OK\n }\n else {\n throw new TypeError(\"Invalid VP9 level\");\n }\n }\n else if (level[0] >= 5 && level[0] <= 6) {\n if (level[1] >= 0 && level[1] <= 2) {\n // OK\n }\n else {\n throw new TypeError(\"Invalid VP9 level\");\n }\n }\n else {\n throw new TypeError(\"Invalid VP9 level\");\n }\n ctx.level = +codecParts[2];\n }\n if (codecParts[3]) {\n const depth = +codecParts[3];\n if (depth === 10 || depth === 12) {\n // Valid but unsupported\n return false;\n }\n else if (depth !== 8) {\n throw new TypeError(\"Invalid VP9 bit depth\");\n }\n }\n if (codecParts[4]) {\n const chromaMode = +codecParts[4];\n switch (chromaMode) {\n case 0:\n case 1:\n // FIXME: These are subtly different YUV420P modes, but we treat them the same\n ctx.pix_fmt = 0 /* YUV420P */;\n break;\n case 2: // YUV422\n ctx.pix_fmt = 4 /* YUV422P */;\n break;\n case 3: // YUV444\n ctx.pix_fmt = 5 /* YUV444P */;\n break;\n default:\n throw new TypeError(\"Invalid VP9 chroma subsampling format\");\n }\n }\n /* The remaining values have to do with color formats, which we don't\n * support correctly anyway */\n return true;\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n/**\n * Clone this configuration. Just copies over the supported/recognized fields.\n */\nexport function cloneConfig(config, fields) {\n const ret = {};\n for (const field of fields) {\n if (field in config)\n ret[field] = config[field];\n }\n return ret;\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport * as ad from \"./audio-data\";\nimport * as et from \"./event-target\";\nimport * as libavs from \"./avloader\";\nimport * as misc from \"./misc\";\nexport class AudioDecoder extends et.DequeueEventTarget {\n constructor(init) {\n super();\n // 1. Let d be a new AudioDecoder object.\n // 2. Assign a new queue to [[control message queue]].\n this._p = Promise.all([]);\n // 3. Assign false to [[message queue blocked]].\n // (unused in polyfill)\n // 4. Assign null to [[codec implementation]].\n this._libav = null;\n this._codec = this._c = this._pkt = this._frame = 0;\n // 5. Assign the result of starting a new parallel queue to [[codec work queue]].\n // (shared with control message queue)\n // 6. Assign false to [[codec saturated]].\n // (codec is never saturated)\n // 7. Assign init.output to [[output callback]].\n this._output = init.output;\n // 8. Assign init.error to [[error callback]].\n this._error = init.error;\n // 9. Assign true to [[key chunk required]].\n // (implicit part of the underlying codec)\n // 10. Assign \"unconfigured\" to [[state]]\n this.state = \"unconfigured\";\n // 11. Assign 0 to [[decodeQueueSize]].\n this.decodeQueueSize = 0;\n // 12. Assign a new list to [[pending flush promises]].\n // (shared with control message queue)\n // 13. Assign false to [[dequeue event scheduled]].\n // (shared with control message queue)\n // 14. Return d.\n }\n configure(config) {\n // 1. If config is not a valid AudioDecoderConfig, throw a TypeError.\n // NOTE: We don't support sophisticated codec string parsing (yet)\n // 2. If [[state]] is “closed”, throw an InvalidStateError DOMException.\n if (this.state === \"closed\")\n throw new DOMException(\"Decoder is closed\", \"InvalidStateError\");\n // Free any internal state\n if (this._libav)\n this._p = this._p.then(() => this._free());\n // 3. Set [[state]] to \"configured\".\n this.state = \"configured\";\n // 4. Set [[key chunk required]] to true.\n // (implicit part of underlying codecs)\n // 5. Queue a control message to configure the decoder with config.\n this._p = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n /* 1. Let supported be the result of running the Check\n * Configuration Support algorithm with config. */\n let udesc = void 0;\n if (config.description) {\n if (ArrayBuffer.isView(config.description)) {\n const descView = config.description;\n udesc = new Uint8Array(descView.buffer, descView.byteOffset, descView.byteLength);\n }\n else {\n const descBuf = config.description;\n udesc = new Uint8Array(descBuf);\n }\n }\n const supported = libavs.decoder(config.codec, config);\n /* 2. If supported is false, queue a task to run the Close\n * AudioDecoder algorithm with NotSupportedError and abort these\n * steps. */\n if (!supported) {\n this._closeAudioDecoder(new DOMException(\"Unsupported codec\", \"NotSupportedError\"));\n return;\n }\n /* 3. If needed, assign [[codec implementation]] with an\n * implementation supporting config. */\n const libav = this._libav = yield libavs.get();\n const codecpara = yield libav.avcodec_parameters_alloc();\n const ps = [\n libav.AVCodecParameters_channels_s(codecpara, config.numberOfChannels),\n libav.AVCodecParameters_sample_rate_s(codecpara, config.sampleRate),\n libav.AVCodecParameters_codec_type_s(codecpara, 1 /* AVMEDIA_TYPE_AUDIO */)\n ];\n let extraDataPtr = 0;\n if (!udesc) {\n ps.push(libav.AVCodecParameters_extradata_s(codecpara, 0));\n ps.push(libav.AVCodecParameters_extradata_size_s(codecpara, 0));\n }\n else {\n ps.push(libav.AVCodecParameters_extradata_size_s(codecpara, udesc.byteLength));\n extraDataPtr = yield libav.calloc(udesc.byteLength + 64 /* AV_INPUT_BUFFER_PADDING_SIZE */, 1);\n ps.push(libav.copyin_u8(extraDataPtr, udesc));\n ps.push(libav.AVCodecParameters_extradata_s(codecpara, extraDataPtr));\n }\n yield Promise.all(ps);\n // 4. Configure [[codec implementation]] with config.\n [this._codec, this._c, this._pkt, this._frame] =\n yield libav.ff_init_decoder(supported.codec, codecpara);\n const fps = [\n libav.AVCodecContext_time_base_s(this._c, 1, 1000),\n libav.avcodec_parameters_free_js(codecpara)\n ];\n if (extraDataPtr)\n fps.push(libav.free(extraDataPtr));\n yield Promise.all(fps);\n // 5. queue a task to run the following steps:\n // 1. Assign false to [[message queue blocked]].\n // 2. Queue a task to Process the control message queue.\n // (shared queue)\n })).catch(this._error);\n }\n // Our own algorithm, close libav\n _free() {\n return __awaiter(this, void 0, void 0, function* () {\n if (this._c) {\n yield this._libav.ff_free_decoder(this._c, this._pkt, this._frame);\n this._codec = this._c = this._pkt = this._frame = 0;\n }\n if (this._libav) {\n libavs.free(this._libav);\n this._libav = null;\n }\n });\n }\n _closeAudioDecoder(exception) {\n // 1. Run the Reset AudioDecoder algorithm with exception.\n this._resetAudioDecoder(exception);\n // 2. Set [[state]] to \"closed\".\n this.state = \"closed\";\n /* 3. Clear [[codec implementation]] and release associated system\n * resources. */\n this._p = this._p.then(() => this._free());\n /* 4. If exception is not an AbortError DOMException, queue a task on\n * the control thread event loop to invoke the [[error callback]] with\n * exception. */\n if (exception.name !== \"AbortError\")\n this._p = this._p.then(() => { this._error(exception); });\n }\n _resetAudioDecoder(exception) {\n // 1. If [[state]] is \"closed\", throw an InvalidStateError.\n if (this.state === \"closed\")\n throw new DOMException(\"Decoder closed\", \"InvalidStateError\");\n // 2. Set [[state]] to \"unconfigured\".\n this.state = \"unconfigured\";\n // ... really, we're just going to free it now\n this._p = this._p.then(() => this._free());\n }\n decode(chunk) {\n // 1. If [[state]] is not \"configured\", throw an InvalidStateError.\n if (this.state !== \"configured\")\n throw new DOMException(\"Unconfigured\", \"InvalidStateError\");\n // 2. If [[key chunk required]] is true:\n // 1. If chunk.[[type]] is not key, throw a DataError.\n /* 2. Implementers SHOULD inspect the chunk’s [[internal data]] to\n * verify that it is truly a key chunk. If a mismatch is detected,\n * throw a DataError. */\n // 3. Otherwise, assign false to [[key chunk required]].\n // (handled within the codec)\n // 3. Increment [[decodeQueueSize]].\n this.decodeQueueSize++;\n // 4. Queue a control message to decode the chunk.\n this._p = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n const libav = this._libav;\n const c = this._c;\n const pkt = this._pkt;\n const frame = this._frame;\n let decodedOutputs = null;\n // (1. and 2. relate to saturation)\n // 3. Decrement [[decodeQueueSize]] and run the Schedule Dequeue Event algorithm.\n this.decodeQueueSize--;\n this.dispatchEvent(new CustomEvent(\"dequeue\"));\n // 1. Attempt to use [[codec implementation]] to decode the chunk.\n try {\n // Convert to a libav packet\n const ptsFull = Math.floor(chunk.timestamp / 1000);\n const [pts, ptshi] = libav.f64toi64(ptsFull);\n const packet = {\n data: chunk._libavGetData(),\n pts,\n ptshi,\n dts: pts,\n dtshi: ptshi\n };\n if (chunk.duration) {\n packet.duration = Math.floor(chunk.duration / 1000);\n packet.durationhi = 0;\n }\n decodedOutputs = yield libav.ff_decode_multi(c, pkt, frame, [packet]);\n /* 2. If decoding results in an error, queue a task to run the Close\n * AudioDecoder algorithm with EncodingError and return. */\n }\n catch (ex) {\n this._p = this._p.then(() => {\n this._closeAudioDecoder(ex);\n });\n return;\n }\n /* 3. If [[codec saturated]] equals true and\n * [[codec implementation]] is no longer saturated, queue a task\n * to perform the following steps: */\n // 1. Assign false to [[codec saturated]].\n // 2. Process the control message queue.\n // (no saturation)\n /* 4. Let decoded outputs be a list of decoded audio data outputs\n * emitted by [[codec implementation]]. */\n /* 5. If decoded outputs is not empty, queue a task to run the\n * Output AudioData algorithm with decoded outputs. */\n if (decodedOutputs)\n this._outputAudioData(decodedOutputs);\n })).catch(this._error);\n }\n _outputAudioData(outputs) {\n const libav = this._libav;\n for (const frame of outputs) {\n // 1. format\n let format;\n let planar = false;\n switch (frame.format) {\n case libav.AV_SAMPLE_FMT_U8:\n format = \"u8\";\n break;\n case libav.AV_SAMPLE_FMT_S16:\n format = \"s16\";\n break;\n case libav.AV_SAMPLE_FMT_S32:\n format = \"s32\";\n break;\n case libav.AV_SAMPLE_FMT_FLT:\n format = \"f32\";\n break;\n case libav.AV_SAMPLE_FMT_U8P:\n format = \"u8\";\n planar = true;\n break;\n case libav.AV_SAMPLE_FMT_S16P:\n format = \"s16\";\n planar = true;\n break;\n case libav.AV_SAMPLE_FMT_S32P:\n format = \"s32\";\n planar = true;\n break;\n case libav.AV_SAMPLE_FMT_FLTP:\n format = \"f32\";\n planar = true;\n break;\n default:\n throw new DOMException(\"Unsupported libav format!\", \"EncodingError\");\n }\n // 2. sampleRate\n const sampleRate = frame.sample_rate;\n // 3. numberOfFrames\n const numberOfFrames = frame.nb_samples;\n // 4. numberOfChannels\n const numberOfChannels = frame.channels;\n // 5. timestamp\n const timestamp = libav.i64tof64(frame.pts, frame.ptshi) * 1000;\n // 6. data\n let raw;\n if (planar) {\n let ct = 0;\n for (let i = 0; i < frame.data.length; i++)\n ct += frame.data[i].length;\n raw = new (frame.data[0].constructor)(ct);\n ct = 0;\n for (let i = 0; i < frame.data.length; i++) {\n const part = frame.data[i];\n raw.set(part, ct);\n ct += part.length;\n }\n }\n else {\n raw = frame.data;\n }\n const data = new ad.AudioData({\n format, sampleRate, numberOfFrames, numberOfChannels,\n timestamp, data: raw\n });\n this._output(data);\n }\n }\n flush() {\n /* 1. If [[state]] is not \"configured\", return a promise rejected with\n * InvalidStateError DOMException. */\n if (this.state !== \"configured\")\n throw new DOMException(\"Invalid state\", \"InvalidStateError\");\n // 2. Set [[key chunk required]] to true.\n // (part of the codec)\n // 3. Let promise be a new Promise.\n // 4. Append promise to [[pending flush promises]].\n // 5. Queue a control message to flush the codec with promise.\n // 6. Process the control message queue.\n // 7. Return promise.\n const ret = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n // 1. Signal [[codec implementation]] to emit all internal pending outputs.\n if (!this._c)\n return;\n // Make sure any last data is flushed\n const libav = this._libav;\n const c = this._c;\n const pkt = this._pkt;\n const frame = this._frame;\n let decodedOutputs = null;\n try {\n decodedOutputs = yield libav.ff_decode_multi(c, pkt, frame, [], true);\n }\n catch (ex) {\n this._p = this._p.then(() => {\n this._closeAudioDecoder(ex);\n });\n }\n /* 2. Let decoded outputs be a list of decoded audio data outputs\n * emitted by [[codec implementation]]. */\n // 3. Queue a task to perform these steps:\n {\n /* 1. If decoded outputs is not empty, run the Output AudioData\n * algorithm with decoded outputs. */\n if (decodedOutputs)\n this._outputAudioData(decodedOutputs);\n // 2. Remove promise from [[pending flush promises]].\n // 3. Resolve promise.\n }\n }));\n this._p = ret;\n return ret;\n }\n reset() {\n this._resetAudioDecoder(new DOMException(\"Reset\", \"AbortError\"));\n }\n close() {\n this._closeAudioDecoder(new DOMException(\"Close\", \"AbortError\"));\n }\n static isConfigSupported(config) {\n return __awaiter(this, void 0, void 0, function* () {\n const dec = libavs.decoder(config.codec, config);\n let supported = false;\n if (dec) {\n const libav = yield libavs.get();\n try {\n const [, c, pkt, frame] = yield libav.ff_init_decoder(dec.codec);\n yield libav.ff_free_decoder(c, pkt, frame);\n supported = true;\n }\n catch (ex) { }\n yield libavs.free(libav);\n }\n return {\n supported,\n config: misc.cloneConfig(config, [\"codec\", \"sampleRate\", \"numberOfChannels\"])\n };\n });\n }\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport * as ad from \"./audio-data\";\nimport * as eac from \"./encoded-audio-chunk\";\nimport * as et from \"./event-target\";\nimport * as libavs from \"./avloader\";\nimport * as misc from \"./misc\";\nexport class AudioEncoder extends et.DequeueEventTarget {\n constructor(init) {\n super();\n // Metadata argument for output\n this._outputMetadata = null;\n this._outputMetadataFilled = false;\n this._pts = null;\n // 1. Let e be a new AudioEncoder object.\n // 2. Assign a new queue to [[control message queue]].\n this._p = Promise.all([]);\n // 3. Assign false to [[message queue blocked]].\n // (unused in polyfill)\n // 4. Assign null to [[codec implementation]].\n this._libav = null;\n this._codec = this._c = this._frame = this._pkt = 0;\n this._filter_in_ctx = this._filter_out_ctx = null;\n this._filter_graph = this._buffersrc_ctx = this._buffersink_ctx = 0;\n /* 5. Assign the result of starting a new parallel queue to\n * [[codec work queue]]. */\n // (shared queue)\n // 6. Assign false to [[codec saturated]].\n // (saturation unneeded in the polyfill)\n // 7. Assign init.output to [[output callback]].\n this._output = init.output;\n // 8. Assign init.error to [[error callback]].\n this._error = init.error;\n // 9. Assign null to [[active encoder config]].\n // 10. Assign null to [[active output config]].\n // (both part of the codec)\n // 11. Assign \"unconfigured\" to [[state]]\n this.state = \"unconfigured\";\n // 12. Assign 0 to [[encodeQueueSize]].\n this.encodeQueueSize = 0;\n // 13. Assign a new list to [[pending flush promises]].\n // 14. Assign false to [[dequeue event scheduled]].\n // (shared queue)\n // 15. Return e.\n }\n configure(config) {\n const self = this;\n // 1. If config is not a valid AudioEncoderConfig, throw a TypeError.\n // NOTE: We don't support sophisticated codec string parsing (yet)\n // 2. If [[state]] is \"closed\", throw an InvalidStateError.\n if (this.state === \"closed\")\n throw new DOMException(\"Encoder is closed\", \"InvalidStateError\");\n // Free any internal state\n if (this._libav)\n this._p = this._p.then(() => this._free());\n // 3. Set [[state]] to \"configured\".\n this.state = \"configured\";\n // 4. Queue a control message to configure the encoder using config.\n this._p = this._p.then(function () {\n return __awaiter(this, void 0, void 0, function* () {\n /* 1. Let supported be the result of running the Check\n * Configuration Support algorithm with config. */\n const supported = libavs.encoder(config.codec, config);\n // Get the output metadata now\n self._outputMetadata = { decoderConfig: {\n codec: config.codec,\n // Rest will be filled in when we get data\n sampleRate: 0,\n numberOfChannels: 0\n } };\n self._outputMetadataFilled = false;\n /* 2. If supported is false, queue a task to run the Close\n * AudioEncoder algorithm with NotSupportedError and abort these\n * steps. */\n if (!supported) {\n self._closeAudioEncoder(new DOMException(\"Unsupported codec\", \"NotSupportedError\"));\n return;\n }\n /* 3. If needed, assign [[codec implementation]] with an\n * implementation supporting config. */\n // 4. Configure [[codec implementation]] with config.\n const libav = self._libav = yield libavs.get();\n // And initialize\n let frame_size;\n [self._codec, self._c, self._frame, self._pkt, frame_size] =\n yield libav.ff_init_encoder(supported.codec, supported);\n self._pts = null;\n yield libav.AVCodecContext_time_base_s(self._c, 1, supported.ctx.sample_rate);\n // Be ready to set up the filter\n self._filter_out_ctx = {\n sample_rate: supported.ctx.sample_rate,\n sample_fmt: supported.ctx.sample_fmt,\n channel_layout: supported.ctx.channel_layout,\n frame_size\n };\n // 5. queue a task to run the following steps:\n // 1. Assign false to [[message queue blocked]].\n // 2. Queue a task to Process the control message queue.\n // (shared queue)\n });\n }).catch(this._error);\n }\n // Our own algorithm, close libav\n _free() {\n return __awaiter(this, void 0, void 0, function* () {\n if (this._filter_graph) {\n yield this._libav.avfilter_graph_free_js(this._filter_graph);\n this._filter_in_ctx = this._filter_out_ctx = null;\n this._filter_graph = this._buffersrc_ctx = this._buffersink_ctx =\n 0;\n }\n if (this._c) {\n yield this._libav.ff_free_encoder(this._c, this._frame, this._pkt);\n this._codec = this._c = this._frame = this._pkt = 0;\n }\n if (this._libav) {\n libavs.free(this._libav);\n this._libav = null;\n }\n });\n }\n _closeAudioEncoder(exception) {\n // 1. Run the Reset AudioEncoder algorithm with exception.\n this._resetAudioEncoder(exception);\n // 2. Set [[state]] to \"closed\".\n this.state = \"closed\";\n /* 3. Clear [[codec implementation]] and release associated system\n * resources. */\n this._p = this._p.then(() => this._free());\n /* 4. If exception is not an AbortError DOMException, invoke the\n * [[error callback]] with exception. */\n if (exception.name !== \"AbortError\")\n this._p = this._p.then(() => { this._error(exception); });\n }\n _resetAudioEncoder(exception) {\n // 1. If [[state]] is \"closed\", throw an InvalidStateError.\n if (this.state === \"closed\")\n throw new DOMException(\"Encoder closed\", \"InvalidStateError\");\n // 2. Set [[state]] to \"unconfigured\".\n this.state = \"unconfigured\";\n // ... really, we're just going to free it now\n this._p = this._p.then(() => this._free());\n }\n encode(data) {\n /* 1. If the value of data’s [[Detached]] internal slot is true, throw\n * a TypeError. */\n if (data._libavGetData() === null)\n throw new TypeError(\"Detached\");\n // 2. If [[state]] is not \"configured\", throw an InvalidStateError.\n if (this.state !== \"configured\")\n throw new DOMException(\"Unconfigured\", \"InvalidStateError\");\n /* 3. Let dataClone hold the result of running the Clone AudioData\n * algorithm with data. */\n const dataClone = data.clone();\n // 4. Increment [[encodeQueueSize]].\n this.encodeQueueSize++;\n // 5. Queue a control message to encode dataClone.\n this._p = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n const libav = this._libav;\n const c = this._c;\n const pkt = this._pkt;\n const framePtr = this._frame;\n let encodedOutputs = null;\n /* 3. Decrement [[encodeQueueSize]] and run the Schedule Dequeue\n * Event algorithm. */\n this.encodeQueueSize--;\n this.dispatchEvent(new CustomEvent(\"dequeue\"));\n /* 1. Attempt to use [[codec implementation]] to encode the media\n * resource described by dataClone. */\n try {\n // Arrange the data\n let raw = dataClone._libavGetData();\n const nb_samples = dataClone.numberOfFrames;\n if (!ad.isInterleaved(dataClone.format)) {\n let split = [];\n for (let i = 0; i < dataClone.numberOfChannels; i++)\n split.push(raw.subarray(i * nb_samples, (i + 1) * nb_samples));\n raw = split;\n }\n // Convert the format\n let format;\n switch (dataClone.format) {\n case \"u8\":\n format = libav.AV_SAMPLE_FMT_U8;\n break;\n case \"s16\":\n format = libav.AV_SAMPLE_FMT_S16;\n break;\n case \"s32\":\n format = libav.AV_SAMPLE_FMT_S32;\n break;\n case \"f32\":\n format = libav.AV_SAMPLE_FMT_FLT;\n break;\n case \"u8-planar\":\n format = libav.AV_SAMPLE_FMT_U8P;\n break;\n case \"s16-planar\":\n format = libav.AV_SAMPLE_FMT_S16P;\n break;\n case \"s32-planar\":\n format = libav.AV_SAMPLE_FMT_S32P;\n break;\n case \"f32-planar\":\n format = libav.AV_SAMPLE_FMT_FLTP;\n break;\n default:\n throw new TypeError(\"Invalid AudioSampleFormat\");\n }\n // Convert the timestamp\n const ptsFull = Math.floor(dataClone.timestamp / 1000);\n const [pts, ptshi] = libav.f64toi64(ptsFull);\n // Convert the channel layout\n const cc = dataClone.numberOfChannels;\n const channel_layout = (cc === 1) ? 4 : ((1 << cc) - 1);\n // Make the frame\n const sample_rate = dataClone.sampleRate;\n const frame = {\n data: raw,\n format, pts, ptshi, channel_layout, sample_rate\n };\n // Check if the filter needs to be reconfigured\n let preOutputs = null;\n if (this._filter_in_ctx) {\n const filter_ctx = this._filter_in_ctx;\n if (filter_ctx.sample_fmt !== frame.format ||\n filter_ctx.channel_layout !== frame.channel_layout ||\n filter_ctx.sample_rate !== frame.sample_rate) {\n // Need a new filter! First, get anything left in the filter\n let fframes = yield this._filter([], true);\n // Can't send partial frames through the encoder\n fframes = fframes.filter(x => {\n let frame_size;\n if (x.data[0].length) {\n // Planar\n frame_size = x.data[0].length;\n }\n else {\n frame_size = x.data.length / x.channels;\n }\n return frame_size === this._filter_out_ctx.frame_size;\n });\n if (fframes.length) {\n preOutputs =\n yield libav.ff_encode_multi(c, framePtr, pkt, fframes);\n }\n yield libav.avfilter_graph_free_js(this._filter_graph);\n this._filter_in_ctx = null;\n this._filter_graph = this._buffersrc_ctx =\n this._buffersink_ctx = 0;\n }\n }\n // Set up the filter\n if (!this._filter_graph) {\n const filter_ctx = this._filter_in_ctx = {\n sample_rate: frame.sample_rate,\n sample_fmt: frame.format,\n channel_layout: frame.channel_layout\n };\n [this._filter_graph, this._buffersrc_ctx, this._buffersink_ctx] =\n yield libav.ff_init_filter_graph(\"aresample\", filter_ctx, this._filter_out_ctx);\n }\n // Filter\n const fframes = yield this._filter([frame]);\n // And encode\n encodedOutputs =\n yield libav.ff_encode_multi(c, framePtr, pkt, fframes);\n if (preOutputs)\n encodedOutputs = preOutputs.concat(encodedOutputs);\n if (encodedOutputs.length && !this._outputMetadataFilled &&\n fframes && fframes.length)\n yield this._getOutputMetadata(fframes[0]);\n /* 2. If encoding results in an error, queue a task on the control\n * thread event loop to run the Close AudioEncoder algorithm with\n * EncodingError. */\n }\n catch (ex) {\n this._p = this._p.then(() => {\n this._closeAudioEncoder(ex);\n });\n }\n /* 3. If [[codec saturated]] equals true and\n * [[codec implementation]] is no longer saturated, queue a task\n * to perform the following steps: */\n // 1. Assign false to [[codec saturated]].\n // 2. Process the control message queue.\n // (no saturation)\n /* 4. Let encoded outputs be a list of encoded audio data outputs\n * emitted by [[codec implementation]]. */\n /* 5. If encoded outputs is not empty, queue a task to run the\n * Output EncodedAudioChunks algorithm with encoded outputs. */\n if (encodedOutputs)\n this._outputEncodedAudioChunks(encodedOutputs);\n })).catch(this._error);\n }\n // Internal: Filter the given audio\n _filter(frames, fin = false) {\n return __awaiter(this, void 0, void 0, function* () {\n /* The specification does not state how timestamps should be related\n * between input and output. It's obvious that the timestamps should\n * increase at the appropriate rate based on the number of samples seen,\n * but where they should start is not stated. Google Chrome starts with\n * the timestamp of the first input frame, and ignores all other input\n * frame timestamps. We follow that convention as well. */\n if (frames.length && this._pts === null)\n this._pts = (frames[0].pts || 0);\n const fframes = yield this._libav.ff_filter_multi(this._buffersrc_ctx, this._buffersink_ctx, this._frame, frames, fin);\n for (const frame of fframes) {\n frame.pts = this._pts;\n frame.ptshi = 0;\n this._pts += frame.nb_samples;\n }\n return fframes;\n });\n }\n // Internal: Get output metadata\n _getOutputMetadata(frame) {\n return __awaiter(this, void 0, void 0, function* () {\n const libav = this._libav;\n const c = this._c;\n const extradataPtr = yield libav.AVCodecContext_extradata(c);\n const extradata_size = yield libav.AVCodecContext_extradata_size(c);\n let extradata = null;\n if (extradataPtr && extradata_size)\n extradata = yield libav.copyout_u8(extradataPtr, extradata_size);\n this._outputMetadata.decoderConfig.sampleRate = frame.sample_rate;\n this._outputMetadata.decoderConfig.numberOfChannels = frame.channels;\n if (extradata)\n this._outputMetadata.decoderConfig.description = extradata;\n this._outputMetadataFilled = true;\n });\n }\n _outputEncodedAudioChunks(packets) {\n const libav = this._libav;\n const sampleRate = this._filter_out_ctx.sample_rate;\n for (const packet of packets) {\n // 1. data\n const data = packet.data;\n // 2. type\n const type = (packet.flags & 1) ? \"key\" : \"delta\";\n // 3. timestamp\n let timestamp = libav.i64tof64(packet.pts, packet.ptshi);\n timestamp = Math.floor(timestamp / sampleRate * 1000000);\n // 4. duration\n let duration;\n if (typeof packet.duration !== \"undefined\") {\n duration = libav.i64tof64(packet.duration, packet.durationhi || 0);\n duration = Math.floor(duration / sampleRate * 1000000);\n }\n const chunk = new eac.EncodedAudioChunk({\n data, type, timestamp, duration\n });\n if (this._outputMetadataFilled)\n this._output(chunk, this._outputMetadata || void 0);\n else\n this._output(chunk);\n }\n }\n flush() {\n /* 1. If [[state]] is not \"configured\", return a promise rejected with\n * InvalidStateError DOMException. */\n if (this.state !== \"configured\")\n throw new DOMException(\"Invalid state\", \"InvalidStateError\");\n // 2. Let promise be a new Promise.\n // 3. Append promise to [[pending flush promises]].\n // 4. Queue a control message to flush the codec with promise.\n // 5. Process the control message queue.\n // 6. Return promise.\n const ret = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n if (!this._c)\n return;\n /* 1. Signal [[codec implementation]] to emit all internal pending\n * outputs. */\n // Make sure any last data is flushed\n const libav = this._libav;\n const c = this._c;\n const frame = this._frame;\n const pkt = this._pkt;\n const buffersrc_ctx = this._buffersrc_ctx;\n const buffersink_ctx = this._buffersink_ctx;\n let encodedOutputs = null;\n try {\n let fframes = null;\n if (buffersrc_ctx)\n fframes = yield this._filter([], true);\n encodedOutputs =\n yield libav.ff_encode_multi(c, frame, pkt, fframes || [], true);\n if (!this._outputMetadataFilled && fframes && fframes.length)\n yield this._getOutputMetadata(fframes[0]);\n }\n catch (ex) {\n this._p = this._p.then(() => {\n this._closeAudioEncoder(ex);\n });\n }\n /* 2. Let encoded outputs be a list of encoded audio data outputs\n * emitted by [[codec implementation]]. */\n // 3. Queue a task to perform these steps:\n {\n /* 1. If encoded outputs is not empty, run the Output\n * EncodedAudioChunks algorithm with encoded outputs. */\n if (encodedOutputs)\n this._outputEncodedAudioChunks(encodedOutputs);\n // 2. Remove promise from [[pending flush promises]].\n // 3. Resolve promise.\n // (shared queue)\n }\n }));\n this._p = ret;\n return ret;\n }\n reset() {\n this._resetAudioEncoder(new DOMException(\"Reset\", \"AbortError\"));\n }\n close() {\n this._closeAudioEncoder(new DOMException(\"Close\", \"AbortError\"));\n }\n static isConfigSupported(config) {\n return __awaiter(this, void 0, void 0, function* () {\n const enc = libavs.encoder(config.codec, config);\n let supported = false;\n if (enc) {\n const libav = yield libavs.get();\n try {\n const [, c, frame, pkt] = yield libav.ff_init_encoder(enc.codec, enc);\n yield libav.ff_free_encoder(c, frame, pkt);\n supported = true;\n }\n catch (ex) { }\n yield libavs.free(libav);\n }\n return {\n supported,\n config: misc.cloneConfig(config, [\"codec\", \"sampleRate\", \"numberOfChannels\", \"bitrate\"])\n };\n });\n }\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nimport * as eac from \"./encoded-audio-chunk\";\nexport const EncodedVideoChunk = eac.EncodedAudioChunk;\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport \"@ungap/global-this\";\n// A canvas element used to convert CanvasImageSources to buffers\nlet offscreenCanvas = null;\nexport class VideoFrame {\n constructor(data, init) {\n /* NOTE: These should all be readonly, but the constructor style above\n * doesn't work with that */\n this.format = \"I420\";\n this.codedWidth = 0;\n this.codedHeight = 0;\n this.codedRect = null;\n this.visibleRect = null;\n this.displayWidth = 0;\n this.displayHeight = 0;\n this.timestamp = 0; // microseconds\n this._layout = null;\n this._data = null;\n /**\n * (Internal) Does this use non-square pixels?\n */\n this._nonSquarePixels = false;\n /**\n * (Internal) If non-square pixels, the SAR (sample/pixel aspect ratio)\n */\n this._sar_num = 1;\n this._sar_den = 1;\n if (data instanceof ArrayBuffer ||\n data.buffer instanceof ArrayBuffer) {\n this._constructBuffer(data, init);\n }\n else if (data instanceof VideoFrame ||\n (globalThis.VideoFrame && data instanceof globalThis.VideoFrame)) {\n const array = new Uint8Array(data.allocationSize());\n data.copyTo(array);\n this._constructBuffer(array, {\n transfer: [array.buffer],\n // 1. Let format be otherFrame.format.\n /* 2. FIXME: If init.alpha is discard, assign\n * otherFrame.format's equivalent opaque format format. */\n format: data.format,\n /* 3. Let validInit be the result of running the Validate\n * VideoFrameInit algorithm with format and otherFrame’s\n * [[coded width]] and [[coded height]]. */\n // 4. If validInit is false, throw a TypeError.\n /* 7. Assign the following attributes from otherFrame to frame:\n * codedWidth, codedHeight, colorSpace. */\n codedHeight: data.codedHeight,\n codedWidth: data.codedWidth,\n colorSpace: data.colorSpace,\n /* 8. Let defaultVisibleRect be the result of performing the\n * getter steps for visibleRect on otherFrame. */\n /* 9. Let defaultDisplayWidth, and defaultDisplayHeight be\n * otherFrame’s [[display width]], and [[display height]]\n * respectively. */\n /* 10. Run the Initialize Visible Rect and Display Size\n * algorithm with init, frame, defaultVisibleRect,\n * defaultDisplayWidth, and defaultDisplayHeight. */\n visibleRect: (init === null || init === void 0 ? void 0 : init.visibleRect) || data.visibleRect,\n displayHeight: (init === null || init === void 0 ? void 0 : init.displayHeight) || data.displayHeight,\n displayWidth: (init === null || init === void 0 ? void 0 : init.displayWidth) || data.displayWidth,\n /* 11. If duration exists in init, assign it to frame’s\n * [[duration]]. Otherwise, assign otherFrame.duration to\n * frame’s [[duration]]. */\n duration: (init === null || init === void 0 ? void 0 : init.duration) || data.duration,\n /* 12. If timestamp exists in init, assign it to frame’s\n * [[timestamp]]. Otherwise, assign otherFrame’s timestamp to\n * frame’s [[timestamp]]. */\n timestamp: (init === null || init === void 0 ? void 0 : init.timestamp) || data.timestamp,\n /* Assign the result of calling Copy VideoFrame metadata with\n * init’s metadata to frame.[[metadata]]. */\n metadata: JSON.parse(JSON.stringify(init === null || init === void 0 ? void 0 : init.metadata))\n });\n }\n else if (data instanceof HTMLVideoElement) {\n /* Check the usability of the image argument. If this throws an\n * exception or returns bad, then throw an InvalidStateError\n * DOMException. */\n if (data.readyState === HTMLVideoElement.prototype.HAVE_NOTHING\n || data.readyState === HTMLVideoElement.prototype.HAVE_METADATA) {\n throw new DOMException(\"Video is not ready for reading frames\", \"InvalidStateError\");\n }\n // If image’s networkState attribute is NETWORK_EMPTY, then throw an InvalidStateError DOMException.\n if (data.networkState === data.NETWORK_EMPTY) {\n throw new DOMException(\"Video network state is empty\", \"InvalidStateError\");\n }\n this._constructCanvas(data, Object.assign(Object.assign({}, init), { timestamp: (init === null || init === void 0 ? void 0 : init.timestamp) || data.currentTime * 1e6 }));\n }\n else {\n this._constructCanvas(data, init);\n }\n }\n _constructCanvas(image, init) {\n /* The spec essentially re-specifies “draw it”, and has specific\n * instructions for each sort of thing it might be. So, we don't\n * document all the steps here, we just... draw it. */\n // Get the width and height\n let width = 0, height = 0;\n if (image.naturalWidth) {\n width = image.naturalWidth;\n height = image.naturalHeight;\n }\n else if (image.videoWidth) {\n width = image.videoWidth;\n height = image.videoHeight;\n }\n else if (image.width) {\n width = image.width;\n height = image.height;\n }\n if (!width || !height)\n throw new DOMException(\"Could not determine dimensions\", \"InvalidStateError\");\n if (offscreenCanvas === null) {\n if (typeof OffscreenCanvas !== \"undefined\") {\n offscreenCanvas = new OffscreenCanvas(width, height);\n }\n else {\n offscreenCanvas = document.createElement(\"canvas\");\n offscreenCanvas.style.display = \"none\";\n document.body.appendChild(offscreenCanvas);\n }\n }\n offscreenCanvas.width = width;\n offscreenCanvas.height = height;\n const options = { desynchronized: true, willReadFrequently: true };\n const ctx = offscreenCanvas.getContext(\"2d\", options);\n ctx.clearRect(0, 0, width, height);\n ctx.drawImage(image, 0, 0);\n this._constructBuffer(ctx.getImageData(0, 0, width, height).data, {\n format: \"RGBA\",\n codedWidth: width,\n codedHeight: height,\n timestamp: (init === null || init === void 0 ? void 0 : init.timestamp) || 0,\n duration: (init === null || init === void 0 ? void 0 : init.duration) || 0,\n layout: [{ offset: 0, stride: width * 4 }],\n displayWidth: (init === null || init === void 0 ? void 0 : init.displayWidth) || width,\n displayHeight: (init === null || init === void 0 ? void 0 : init.displayHeight) || height\n });\n }\n _constructBuffer(data, init) {\n // 1. If init is not a valid VideoFrameBufferInit, throw a TypeError.\n VideoFrame._checkValidVideoFrameBufferInit(init);\n /* 2. Let defaultRect be «[ \"x:\" → 0, \"y\" → 0, \"width\" →\n * init.codedWidth, \"height\" → init.codedWidth ]». */\n const defaultRect = new DOMRect(0, 0, init.codedWidth, init.codedHeight);\n // 3. Let overrideRect be undefined.\n let overrideRect = void 0;\n // 4. If init.visibleRect exists, assign its value to overrideRect.\n if (init.visibleRect)\n overrideRect = DOMRect.fromRect(init.visibleRect);\n /* 5. Let parsedRect be the result of running the Parse Visible Rect\n * algorithm with defaultRect, overrideRect, init.codedWidth,\n * init.codedHeight, and init.format. */\n // 6. If parsedRect is an exception, return parsedRect.\n this.codedWidth = init.codedWidth; // (for _parseVisibleRect)\n this.codedHeight = init.codedHeight;\n const parsedRect = this._parseVisibleRect(defaultRect, overrideRect || null);\n // 7. Let optLayout be undefined.\n let optLayout = void 0;\n // 8. If init.layout exists, assign its value to optLayout.\n if (init.layout) {\n if (init.layout instanceof Array)\n optLayout = init.layout;\n else\n optLayout = Array.from(init.layout);\n }\n /* 9. Let combinedLayout be the result of running the Compute Layout\n * and Allocation Size algorithm with parsedRect, init.format, and\n * optLayout. */\n // 10. If combinedLayout is an exception, throw combinedLayout.\n this.format = init.format; // (needed for _computeLayoutAndAllocationSize)\n const combinedLayout = this._computeLayoutAndAllocationSize(parsedRect, optLayout || null);\n /* 11. If data.byteLength is less than combinedLayout’s allocationSize,\n * throw a TypeError. */\n if (data.byteLength < combinedLayout.allocationSize)\n throw new TypeError(\"data is too small for layout\");\n /* 12. If init.transfer contains more than one reference to the same\n * ArrayBuffer, then throw a DataCloneError DOMException. */\n // 13. For each transferable in init.transfer:\n // 1. If [[Detached]] internal slot is true, then throw a DataCloneError DOMException.\n // (not checked in polyfill)\n /* 14. If init.transfer contains an ArrayBuffer referenced by data the\n * User Agent MAY choose to: */\n let transfer = false;\n if (init.transfer) {\n /* 1. Let resource be a new media resource referencing pixel data\n * in data. */\n let inBuffer;\n if (data.buffer)\n inBuffer = data.buffer;\n else\n inBuffer = data;\n let t;\n if (init.transfer instanceof Array)\n t = init.transfer;\n else\n t = Array.from(init.transfer);\n for (const b of t) {\n if (b === inBuffer) {\n transfer = true;\n break;\n }\n }\n }\n // 15. Otherwise:\n /* 1. Let resource be a new media resource containing a copy of\n * data. Use visibleRect and layout to determine where in data\n * the pixels for each plane reside. */\n /* The User Agent MAY choose to allocate resource with a larger\n * coded size and plane strides to improve memory alignment.\n * Increases will be reflected by codedWidth and codedHeight.\n * Additionally, the User Agent MAY use visibleRect to copy only\n * the visible rectangle. It MAY also reposition the visible\n * rectangle within resource. The final position will be\n * reflected by visibleRect. */\n /* NOTE: The spec seems to be missing the step where you actually use\n * the resource to define the [[resource reference]]. */\n const format = init.format;\n if (init.layout) {\n // FIXME: Make sure it's the right size\n if (init.layout instanceof Array)\n this._layout = init.layout;\n else\n this._layout = Array.from(init.layout);\n }\n else {\n const numPlanes_ = numPlanes(format);\n const layout = [];\n let offset = 0;\n for (let i = 0; i < numPlanes_; i++) {\n const sampleWidth = horizontalSubSamplingFactor(format, i);\n const sampleHeight = verticalSubSamplingFactor(format, i);\n const stride = ~~(this.codedWidth / sampleWidth);\n layout.push({ offset, stride });\n offset += stride * (~~(this.codedHeight / sampleHeight));\n }\n this._layout = layout;\n }\n this._data = new Uint8Array(data.buffer || data, data.byteOffset || 0);\n if (!transfer) {\n const numPlanes_ = numPlanes(format);\n // Only copy the relevant part\n let layout = this._layout;\n let lo = 1 / 0;\n let hi = 0;\n for (let i = 0; i < numPlanes_; i++) {\n const plane = layout[i];\n let offset = plane.offset;\n if (offset < lo)\n lo = offset;\n const sampleHeight = verticalSubSamplingFactor(format, i);\n offset += plane.stride * (~~(this.codedHeight / sampleHeight));\n if (offset > hi)\n hi = offset;\n }\n // Fix the layout to compensate\n if (lo !== 0) {\n layout = this._layout = layout.map(x => ({\n offset: x.offset - lo,\n stride: x.stride\n }));\n }\n this._data = this._data.slice(lo, hi);\n }\n // 16. For each transferable in init.transfer:\n // 1. Perform DetachArrayBuffer on transferable\n // (not doable in polyfill)\n // 17. Let resourceCodedWidth be the coded width of resource.\n const resourceCodedWidth = init.codedWidth;\n // 18. Let resourceCodedHeight be the coded height of resource.\n const resourceCodedHeight = init.codedHeight;\n /* 19. Let resourceVisibleLeft be the left offset for the visible\n * rectangle of resource. */\n const resourceVisibleLeft = parsedRect.left;\n /* 20. Let resourceVisibleTop be the top offset for the visible\n * rectangle of resource. */\n const resourceVisibleTop = parsedRect.top;\n // 21. Let frame be a new VideoFrame object initialized as follows:\n {\n /* 1. Assign resourceCodedWidth, resourceCodedHeight,\n * resourceVisibleLeft, and resourceVisibleTop to\n * [[coded width]], [[coded height]], [[visible left]], and\n * [[visible top]] respectively. */\n // (codedWidth/codedHeight done earlier)\n this.codedRect = new DOMRect(0, 0, resourceCodedWidth, resourceCodedHeight);\n this.visibleRect = parsedRect;\n // 2. If init.visibleRect exists:\n if (init.visibleRect) {\n // 1. Let truncatedVisibleWidth be the value of visibleRect.width after truncating.\n // 2. Assign truncatedVisibleWidth to [[visible width]].\n // 3. Let truncatedVisibleHeight be the value of visibleRect.height after truncating.\n // 4. Assign truncatedVisibleHeight to [[visible height]].\n this.visibleRect = DOMRect.fromRect(init.visibleRect);\n // 3. Otherwise:\n }\n else {\n // 1. Assign [[coded width]] to [[visible width]].\n // 2. Assign [[coded height]] to [[visible height]].\n this.visibleRect = new DOMRect(0, 0, resourceCodedWidth, resourceCodedHeight);\n }\n /* 4. If init.displayWidth exists, assign it to [[display width]].\n * Otherwise, assign [[visible width]] to [[display width]]. */\n if (typeof init.displayWidth === \"number\")\n this.displayWidth = init.displayWidth;\n else\n this.displayWidth = this.visibleRect.width;\n /* 5. If init.displayHeight exists, assign it to [[display height]].\n * Otherwise, assign [[visible height]] to [[display height]]. */\n if (typeof init.displayHeight === \"number\")\n this.displayHeight = init.displayHeight;\n else\n this.displayHeight = this.visibleRect.height;\n // Account for non-square pixels\n if (this.displayWidth !== this.visibleRect.width ||\n this.displayHeight !== this.visibleRect.height) {\n // Dubious (but correct) SAR calculation\n this._nonSquarePixels = true;\n this._sar_num = this.displayWidth * this.visibleRect.width;\n this._sar_den = this.displayHeight * this.visibleRect.height;\n }\n else {\n this._nonSquarePixels = false;\n this._sar_num = this._sar_den = 1;\n }\n /* 6. Assign init’s timestamp and duration to [[timestamp]] and\n * [[duration]] respectively. */\n this.timestamp = init.timestamp;\n this.duration = init.duration;\n // 7. Let colorSpace be undefined.\n // 8. If init.colorSpace exists, assign its value to colorSpace.\n // (color spaces not supported)\n // 9. Assign init’s format to [[format]].\n // (done earlier)\n /* 10. Assign the result of running the Pick Color Space algorithm,\n * with colorSpace and [[format]], to [[color space]]. */\n // (color spaces not supported)\n /* 11. Assign the result of calling Copy VideoFrame metadata with\n * init’s metadata to frame.[[metadata]]. */\n // (no actual metadata is yet described by the spec)\n }\n // 22. Return frame.\n }\n /**\n * Convert a polyfill VideoFrame to a native VideoFrame.\n * @param opts Conversion options\n */\n toNative(opts = {}) {\n const ret = new globalThis.VideoFrame(this._data, {\n layout: this._layout,\n format: this.format,\n codedWidth: this.codedWidth,\n codedHeight: this.codedHeight,\n visibleRect: this.visibleRect,\n displayWidth: this.displayWidth,\n displayHeight: this.displayHeight,\n duration: this.duration,\n timestamp: this.timestamp,\n transfer: opts.transfer ? [this._data.buffer] : []\n });\n if (opts.transfer)\n this.close();\n return ret;\n }\n /**\n * Convert a native VideoFrame to a polyfill VideoFrame. WARNING: Inefficient,\n * as the data cannot be transferred out.\n * @param from VideoFrame to copy in\n */\n static fromNative(from /* native VideoFrame */) {\n const vf = from;\n const data = new Uint8Array(vf.allocationSize());\n vf.copyTo(data);\n return new VideoFrame(data, {\n format: vf.format,\n codedWidth: vf.codedWidth,\n codedHeight: vf.codedHeight,\n visibleRect: vf.visibleRect,\n displayWidth: vf.displayWidth,\n displayHeight: vf.displayHeight,\n duration: vf.duration,\n timestamp: vf.timestamp\n });\n }\n // Internal\n _libavGetData() { return this._data; }\n _libavGetLayout() { return this._layout; }\n static _checkValidVideoFrameBufferInit(init) {\n // 1. If codedWidth = 0 or codedHeight = 0,return false.\n if (!init.codedWidth || !init.codedHeight)\n throw new TypeError(\"Invalid coded dimensions\");\n if (init.visibleRect) {\n /* 2. If any attribute of visibleRect is negative or not finite, return\n * false. */\n const vr = DOMRect.fromRect(init.visibleRect);\n if (vr.x < 0 || !Number.isFinite(vr.x) ||\n vr.y < 0 || !Number.isFinite(vr.y) ||\n vr.width < 0 || !Number.isFinite(vr.width) ||\n vr.height < 0 || !Number.isFinite(vr.height)) {\n throw new TypeError(\"Invalid visible rectangle\");\n }\n // 3. If visibleRect.y + visibleRect.height > codedHeight, return false.\n if (vr.y + vr.height > init.codedHeight)\n throw new TypeError(\"Visible rectangle outside of coded height\");\n // 4. If visibleRect.x + visibleRect.width > codedWidth, return false.\n if (vr.x + vr.width > init.codedWidth)\n throw new TypeError(\"Visible rectangle outside of coded width\");\n // 5. If only one of displayWidth or displayHeight exists, return false.\n // 6. If displayWidth = 0 or displayHeight = 0, return false.\n if ((init.displayWidth && !init.displayHeight) ||\n (!init.displayWidth && !init.displayHeight) ||\n (init.displayWidth === 0 || init.displayHeight === 0))\n throw new TypeError(\"Invalid display dimensions\");\n }\n // 7. Return true.\n }\n metadata() {\n // 1. If [[Detached]] is true, throw an InvalidStateError DOMException.\n if (this._data === null)\n throw new DOMException(\"Detached\", \"InvalidStateError\");\n /* 2. Return the result of calling Copy VideoFrame metadata with\n * [[metadata]]. */\n // No actual metadata is yet defined in the spec\n return null;\n }\n allocationSize(options = {}) {\n // 1. If [[Detached]] is true, throw an InvalidStateError DOMException.\n if (this._data === null)\n throw new DOMException(\"Detached\", \"InvalidStateError\");\n // 2. If [[format]] is null, throw a NotSupportedError DOMException.\n if (this.format === null)\n throw new DOMException(\"Not supported\", \"NotSupportedError\");\n /* 3. Let combinedLayout be the result of running the Parse\n * VideoFrameCopyToOptions algorithm with options. */\n // 4. If combinedLayout is an exception, throw combinedLayout.\n const combinedLayout = this._parseVideoFrameCopyToOptions(options);\n // 5. Return combinedLayout’s allocationSize.\n return combinedLayout.allocationSize;\n }\n _parseVideoFrameCopyToOptions(options) {\n /* 1. Let defaultRect be the result of performing the getter steps for\n * visibleRect. */\n const defaultRect = this.visibleRect;\n // 2. Let overrideRect be undefined.\n // 3. If options.rect exists, assign its value to overrideRect.\n let overrideRect = options.rect ?\n new DOMRect(options.rect.x, options.rect.y, options.rect.width, options.rect.height)\n : null;\n /* 4. Let parsedRect be the result of running the Parse Visible Rect\n * algorithm with defaultRect, overrideRect, [[coded width]], [[coded\n * height]], and [[format]]. */\n // 5. If parsedRect is an exception, return parsedRect.\n const parsedRect = this._parseVisibleRect(defaultRect, overrideRect);\n // 6. Let optLayout be undefined.\n // 7. If options.layout exists, assign its value to optLayout.\n let optLayout = null;\n if (options.layout) {\n if (options.layout instanceof Array)\n optLayout = options.layout;\n else\n optLayout = Array.from(options.layout);\n }\n /* 8. Let combinedLayout be the result of running the Compute Layout\n * and Allocation Size algorithm with parsedRect, [[format]], and\n * optLayout. */\n const combinedLayout = this._computeLayoutAndAllocationSize(parsedRect, optLayout);\n // 9. Return combinedLayout.\n return combinedLayout;\n }\n _parseVisibleRect(defaultRect, overrideRect) {\n // 1. Let sourceRect be defaultRect\n let sourceRect = defaultRect;\n // 2. If overrideRect is not undefined:\n if (overrideRect) {\n /* 1. If either of overrideRect.width or height is 0, return a\n * TypeError. */\n if (overrideRect.width === 0 || overrideRect.height === 0)\n throw new TypeError(\"Invalid rectangle\");\n /* 2. If the sum of overrideRect.x and overrideRect.width is\n * greater than [[coded width]], return a TypeError. */\n if (overrideRect.x + overrideRect.width > this.codedWidth)\n throw new TypeError(\"Invalid rectangle\");\n /* 3. If the sum of overrideRect.y and overrideRect.height is\n * greater than [[coded height]], return a TypeError. */\n if (overrideRect.y + overrideRect.height > this.codedHeight)\n throw new TypeError(\"Invalid rectangle\");\n // 4. Assign overrideRect to sourceRect.\n sourceRect = overrideRect;\n }\n /* 3. Let validAlignment be the result of running the Verify Rect Offset\n * Alignment algorithm with format and sourceRect. */\n const validAlignment = this._verifyRectOffsetAlignment(sourceRect);\n // 4. If validAlignment is false, throw a TypeError.\n if (!validAlignment)\n throw new TypeError(\"Invalid alignment\");\n // 5. Return sourceRect.\n return sourceRect;\n }\n _computeLayoutAndAllocationSize(parsedRect, layout) {\n // 1. Let numPlanes be the number of planes as defined by format.\n let numPlanes_ = numPlanes(this.format);\n /* 2. If layout is not undefined and its length does not equal\n * numPlanes, throw a TypeError. */\n if (layout && layout.length !== numPlanes_)\n throw new TypeError(\"Invalid layout\");\n // 3. Let minAllocationSize be 0.\n let minAllocationSize = 0;\n // 4. Let computedLayouts be a new list.\n let computedLayouts = [];\n // 5. Let endOffsets be a new list.\n let endOffsets = [];\n // 6. Let planeIndex be 0.\n let planeIndex = 0;\n // 7. While planeIndex < numPlanes:\n while (planeIndex < numPlanes_) {\n /* 1. Let plane be the Plane identified by planeIndex as defined by\n * format. */\n // 2. Let sampleBytes be the number of bytes per sample for plane.\n const sampleBytes_ = sampleBytes(this.format, planeIndex);\n /* 3. Let sampleWidth be the horizontal sub-sampling factor of each\n * subsample for plane. */\n const sampleWidth = horizontalSubSamplingFactor(this.format, planeIndex);\n /* 4. Let sampleHeight be the vertical sub-sampling factor of each\n * subsample for plane. */\n const sampleHeight = verticalSubSamplingFactor(this.format, planeIndex);\n // 5. Let computedLayout be a new computed plane layout.\n const computedLayout = {\n destinationOffset: 0,\n destinationStride: 0,\n /* 6. Set computedLayout’s sourceTop to the result of the division\n * of truncated parsedRect.y by sampleHeight, rounded up to the\n * nearest integer. */\n sourceTop: Math.ceil(~~parsedRect.y / sampleHeight),\n /* 7. Set computedLayout’s sourceHeight to the result of the\n * division of truncated parsedRect.height by sampleHeight,\n * rounded up to the nearest integer. */\n sourceHeight: Math.ceil(~~parsedRect.height / sampleHeight),\n /* 8. Set computedLayout’s sourceLeftBytes to the result of the\n * integer division of truncated parsedRect.x by sampleWidth,\n * multiplied by sampleBytes. */\n sourceLeftBytes: ~~(parsedRect.x / sampleWidth * sampleBytes_),\n /* 9. Set computedLayout’s sourceWidthBytes to the result of the\n * integer division of truncated parsedRect.width by\n * sampleHeight, multiplied by sampleBytes. */\n sourceWidthBytes: ~~(parsedRect.width / sampleWidth * sampleBytes_)\n };\n // 10. If layout is not undefined:\n if (layout) {\n /* 1. Let planeLayout be the PlaneLayout in layout at position\n * planeIndex. */\n const planeLayout = layout[planeIndex];\n /* 2. If planeLayout.stride is less than computedLayout’s\n * sourceWidthBytes, return a TypeError. */\n if (planeLayout.stride < computedLayout.sourceWidthBytes)\n throw new TypeError(\"Invalid stride\");\n /* 3. Assign planeLayout.offset to computedLayout’s\n * destinationOffset. */\n computedLayout.destinationOffset = planeLayout.offset;\n /* 4. Assign planeLayout.stride to computedLayout’s\n * destinationStride. */\n computedLayout.destinationStride = planeLayout.stride;\n // 11. Otherwise:\n }\n else {\n /* 1. Assign minAllocationSize to computedLayout’s\n * destinationOffset. */\n computedLayout.destinationOffset = minAllocationSize;\n /* 2. Assign computedLayout’s sourceWidthBytes to\n * computedLayout’s destinationStride. */\n computedLayout.destinationStride = computedLayout.sourceWidthBytes;\n }\n /* 12. Let planeSize be the product of multiplying computedLayout’s\n * destinationStride and sourceHeight. */\n const planeSize = computedLayout.destinationStride * computedLayout.sourceHeight;\n /* 13. Let planeEnd be the sum of planeSize and computedLayout’s\n * destinationOffset. */\n const planeEnd = planeSize + computedLayout.destinationOffset;\n /* 14. If planeSize or planeEnd is greater than maximum range of\n * unsigned long, return a TypeError. */\n if (planeSize >= 0x100000000 ||\n planeEnd >= 0x100000000)\n throw new TypeError(\"Plane too large\");\n // 15. Append planeEnd to endOffsets.\n endOffsets.push(planeEnd);\n /* 16. Assign the maximum of minAllocationSize and planeEnd to\n * minAllocationSize. */\n if (planeEnd > minAllocationSize)\n minAllocationSize = planeEnd;\n // 17. Let earlierPlaneIndex be 0.\n let earlierPlaneIndex = 0;\n // 18. While earlierPlaneIndex is less than planeIndex.\n while (earlierPlaneIndex < planeIndex) {\n // 1. Let earlierLayout be computedLayouts[earlierPlaneIndex].\n const earlierLayout = computedLayouts[earlierPlaneIndex];\n /* 2. If endOffsets[planeIndex] is less than or equal to\n * earlierLayout’s destinationOffset or if\n * endOffsets[earlierPlaneIndex] is less than or equal to\n * computedLayout’s destinationOffset, continue. */\n if (planeEnd <= earlierLayout.destinationOffset ||\n endOffsets[earlierPlaneIndex] <= computedLayout.destinationOffset) {\n // 3. Otherwise, return a TypeError.\n }\n else\n throw new TypeError(\"Invalid plane layout\");\n // 4. Increment earlierPlaneIndex by 1.\n earlierPlaneIndex++;\n }\n // 19. Append computedLayout to computedLayouts.\n computedLayouts.push(computedLayout);\n // 20. Increment planeIndex by 1.\n planeIndex++;\n }\n /* 8. Let combinedLayout be a new combined buffer layout, initialized\n * as follows: */\n const combinedLayout = {\n // 1. Assign computedLayouts to computedLayouts.\n computedLayouts,\n // 2. Assign minAllocationSize to allocationSize.\n allocationSize: minAllocationSize\n };\n // 9. Return combinedLayout.\n return combinedLayout;\n }\n _verifyRectOffsetAlignment(rect) {\n // 1. If format is null, return true.\n if (!this.format)\n return true;\n // 2. Let planeIndex be 0.\n let planeIndex = 0;\n // 3. Let numPlanes be the number of planes as defined by format.\n const numPlanes_ = numPlanes(this.format);\n // 4. While planeIndex is less than numPlanes:\n while (planeIndex < numPlanes_) {\n /* 1. Let plane be the Plane identified by planeIndex as defined by\n * format. */\n /* 2. Let sampleWidth be the horizontal sub-sampling factor of each\n * subsample for plane. */\n const sampleWidth = horizontalSubSamplingFactor(this.format, planeIndex);\n /* 3. Let sampleHeight be the vertical sub-sampling factor of each\n * subsample for plane. */\n const sampleHeight = verticalSubSamplingFactor(this.format, planeIndex);\n // 4. If rect.x is not a multiple of sampleWidth, return false.\n const xw = rect.x / sampleWidth;\n if (xw !== ~~xw)\n return false;\n // 5. If rect.y is not a multiple of sampleHeight, return false.\n const yh = rect.y / sampleHeight;\n if (yh !== ~~yh)\n return false;\n // 6. Increment planeIndex by 1.\n planeIndex++;\n }\n // 5. Return true.\n return true;\n }\n copyTo(destination, options = {}) {\n return __awaiter(this, void 0, void 0, function* () {\n const destBuf = new Uint8Array(destination.buffer || destination, destination.byteOffset || 0);\n // 1. If [[Detached]] is true, throw an InvalidStateError DOMException.\n if (this._data === null)\n throw new DOMException(\"Detached\", \"InvalidStateError\");\n // 2. If [[format]] is null, throw a NotSupportedError DOMException.\n if (!this.format)\n throw new DOMException(\"No format\", \"NotSupportedError\");\n /* 3. Let combinedLayout be the result of running the Parse\n * VideoFrameCopyToOptions algorithm with options. */\n /* 4. If combinedLayout is an exception, return a promise rejected with\n * combinedLayout. */\n const combinedLayout = this._parseVideoFrameCopyToOptions(options);\n /* 5. If destination.byteLength is less than combinedLayout’s\n * allocationSize, return a promise rejected with a TypeError. */\n if (destination.byteLength < combinedLayout.allocationSize)\n throw new TypeError(\"Insufficient space\");\n // 6. Let p be a new Promise.\n /* 7. Let copyStepsQueue be the result of starting a new parallel\n * queue. */\n // 8. Let planeLayouts be a new list.\n let planeLayouts = [];\n // 9. Enqueue the following steps to copyStepsQueue:\n {\n /* 1. Let resource be the media resource referenced by [[resource\n * reference]]. */\n /* 2. Let numPlanes be the number of planes as defined by\n * [[format]]. */\n const numPlanes_ = numPlanes(this.format);\n // 3. Let planeIndex be 0.\n let planeIndex = 0;\n // 4. While planeIndex is less than combinedLayout’s numPlanes:\n while (planeIndex < combinedLayout.computedLayouts.length) {\n /* 1. Let sourceStride be the stride of the plane in resource as\n * identified by planeIndex. */\n const sourceStride = this._layout[planeIndex].stride;\n /* 2. Let computedLayout be the computed plane layout in\n * combinedLayout’s computedLayouts at the position of planeIndex */\n const computedLayout = combinedLayout.computedLayouts[planeIndex];\n /* 3. Let sourceOffset be the product of multiplying\n * computedLayout’s sourceTop by sourceStride */\n let sourceOffset = computedLayout.sourceTop * sourceStride;\n // 4. Add computedLayout’s sourceLeftBytes to sourceOffset.\n sourceOffset += computedLayout.sourceLeftBytes;\n // 5. Let destinationOffset be computedLayout’s destinationOffset.\n let destinationOffset = computedLayout.destinationOffset;\n // 6. Let rowBytes be computedLayout’s sourceWidthBytes.\n const rowBytes = computedLayout.sourceWidthBytes;\n /* 7. Let layout be a new PlaneLayout, with offset set to\n * destinationOffset and stride set to rowBytes. */\n const layout = {\n offset: computedLayout.destinationOffset,\n stride: computedLayout.destinationStride\n };\n // 8. Let row be 0.\n let row = 0;\n // 9. While row is less than computedLayout’s sourceHeight:\n while (row < computedLayout.sourceHeight) {\n /* 1. Copy rowBytes bytes from resource starting at\n * sourceOffset to destination starting at destinationOffset. */\n destBuf.set(this._data.subarray(sourceOffset, sourceOffset + rowBytes), destinationOffset);\n // 2. Increment sourceOffset by sourceStride.\n sourceOffset += sourceStride;\n /* 3. Increment destinationOffset by computedLayout’s\n * destinationStride. */\n destinationOffset += computedLayout.destinationStride;\n // 4. Increment row by 1.\n row++;\n }\n // 10. Increment planeIndex by 1.\n planeIndex++;\n // 11. Append layout to planeLayouts.\n planeLayouts.push(layout);\n }\n // 5. Queue a task to resolve p with planeLayouts.\n }\n // 10. Return p.\n return planeLayouts;\n });\n }\n clone() {\n return new VideoFrame(this._data, {\n format: this.format,\n codedWidth: this.codedWidth,\n codedHeight: this.codedHeight,\n timestamp: this.timestamp,\n duration: this.duration,\n layout: this._layout,\n transfer: [this._data.buffer]\n });\n }\n close() {\n this._data = null;\n }\n}\n/**\n * Convert a WebCodecs pixel format to a libav pixel format.\n * @param libav LibAV instance for constants\n * @param wcFormat WebCodecs format\n */\nexport function wcFormatToLibAVFormat(libav, wcFormat) {\n let format = libav.AV_PIX_FMT_RGBA;\n switch (wcFormat) {\n case \"I420\":\n format = libav.AV_PIX_FMT_YUV420P;\n break;\n case \"I420P10\":\n format = 0x3E; /* AV_PIX_FMT_YUV420P10 */\n break;\n case \"I420P12\":\n format = 0x7B; /* AV_PIX_FMT_YUV420P12 */\n break;\n case \"I420A\":\n format = libav.AV_PIX_FMT_YUVA420P;\n break;\n case \"I420AP10\":\n format = 0x57; /* AV_PIX_FMT_YUVA420P10 */\n break;\n case \"I420AP12\":\n throw new TypeError(\"YUV420P12 is not supported by libav\");\n break;\n case \"I422\":\n format = libav.AV_PIX_FMT_YUV422P;\n break;\n case \"I422P10\":\n format = 0x40; /* AV_PIX_FMT_YUV422P10 */\n break;\n case \"I422P12\":\n format = 0x7F; /* AV_PIX_FMT_YUV422P12 */\n break;\n case \"I422A\":\n format = 0x4E; /* AV_PIX_FMT_YUVA422P */\n break;\n case \"I422AP10\":\n format = 0x59; /* AV_PIX_FMT_YUVA422P10 */\n break;\n case \"I422AP10\":\n format = 0xBA; /* AV_PIX_FMT_YUVA422P12 */\n break;\n case \"I444\":\n format = libav.AV_PIX_FMT_YUV444P;\n break;\n case \"I444P10\":\n format = 0x44; /* AV_PIX_FMT_YUV444P10 */\n break;\n case \"I444P12\":\n format = 0x83; /* AV_PIX_FMT_YUV444P12 */\n break;\n case \"I444A\":\n format = 0x4F; /* AV_PIX_FMT_YUVA444P */\n break;\n case \"I444AP10\":\n format = 0x5B; /* AV_PIX_FMT_YUVA444P10 */\n break;\n case \"I444AP12\":\n format = 0xBC; /* AV_PIX_FMT_YUVA444P10 */\n break;\n case \"NV12\":\n format = libav.AV_PIX_FMT_NV12;\n break;\n case \"RGBA\":\n format = libav.AV_PIX_FMT_RGBA;\n break;\n case \"RGBX\":\n format = 0x77; /* AV_PIX_FMT_RGB0 */\n break;\n case \"BGRA\":\n format = libav.AV_PIX_FMT_BGRA;\n break;\n case \"BGRX\":\n format = 0x79; /* AV_PIX_FMT_BGR0 */\n break;\n default:\n throw new TypeError(\"Invalid VideoPixelFormat\");\n }\n return format;\n}\n/**\n * Number of planes in the given format.\n * @param format The format\n */\nexport function numPlanes(format) {\n switch (format) {\n case \"I420\":\n case \"I420P10\":\n case \"I420P12\":\n case \"I422\":\n case \"I422P10\":\n case \"I422P12\":\n case \"I444\":\n case \"I444P10\":\n case \"I444P12\":\n return 3;\n case \"I420A\":\n case \"I420AP10\":\n case \"I420AP12\":\n case \"I422A\":\n case \"I422AP10\":\n case \"I422AP12\":\n case \"I444A\":\n case \"I444AP10\":\n case \"I444AP12\":\n return 4;\n case \"NV12\":\n return 2;\n case \"RGBA\":\n case \"RGBX\":\n case \"BGRA\":\n case \"BGRX\":\n return 1;\n default:\n throw new DOMException(\"Unsupported video pixel format\", \"NotSupportedError\");\n }\n}\n/**\n * Number of bytes per sample in the given format and plane.\n * @param format The format\n * @param planeIndex The plane index\n */\nexport function sampleBytes(format, planeIndex) {\n switch (format) {\n case \"I420\":\n case \"I420A\":\n case \"I422\":\n case \"I422A\":\n case \"I444\":\n case \"I444A\":\n return 1;\n case \"I420P10\":\n case \"I420AP10\":\n case \"I422P10\":\n case \"I422AP10\":\n case \"I444P10\":\n case \"I444AP10\":\n case \"I420P12\":\n case \"I420AP12\":\n case \"I422P12\":\n case \"I422AP12\":\n case \"I444P12\":\n case \"I444AP12\":\n return 2;\n case \"NV12\":\n if (planeIndex === 1)\n return 2;\n else\n return 1;\n case \"RGBA\":\n case \"RGBX\":\n case \"BGRA\":\n case \"BGRX\":\n return 4;\n default:\n throw new DOMException(\"Unsupported video pixel format\", \"NotSupportedError\");\n }\n}\n/**\n * Horizontal sub-sampling factor for the given format and plane.\n * @param format The format\n * @param planeIndex The plane index\n */\nexport function horizontalSubSamplingFactor(format, planeIndex) {\n // First plane (often luma) is always full\n if (planeIndex === 0)\n return 1;\n // Plane 3 (alpha if present) is always full\n if (planeIndex === 3)\n return 1;\n switch (format) {\n case \"I420\":\n case \"I420P10\":\n case \"I420P12\":\n case \"I420A\":\n case \"I420AP10\":\n case \"I420AP12\":\n case \"I422\":\n case \"I422P10\":\n case \"I422P12\":\n case \"I422A\":\n case \"I422AP10\":\n case \"I422AP12\":\n return 2;\n case \"I444\":\n case \"I444P10\":\n case \"I444P12\":\n case \"I444A\":\n case \"I444AP10\":\n case \"I444AP12\":\n return 1;\n case \"NV12\":\n return 2;\n case \"RGBA\":\n case \"RGBX\":\n case \"BGRA\":\n case \"BGRX\":\n return 1;\n default:\n throw new DOMException(\"Unsupported video pixel format\", \"NotSupportedError\");\n }\n}\n/**\n * Vertical sub-sampling factor for the given format and plane.\n * @param format The format\n * @param planeIndex The plane index\n */\nexport function verticalSubSamplingFactor(format, planeIndex) {\n // First plane (often luma) is always full\n if (planeIndex === 0)\n return 1;\n // Plane 3 (alpha if present) is always full\n if (planeIndex === 3)\n return 1;\n switch (format) {\n case \"I420\":\n case \"I420P10\":\n case \"I420P12\":\n case \"I420A\":\n case \"I420AP10\":\n case \"I420AP12\":\n return 2;\n case \"I422\":\n case \"I422P10\":\n case \"I422P12\":\n case \"I422A\":\n case \"I422AP10\":\n case \"I422AP12\":\n case \"I444\":\n case \"I444P10\":\n case \"I444P12\":\n case \"I444A\":\n case \"I444AP10\":\n case \"I444AP12\":\n return 1;\n case \"NV12\":\n return 2;\n case \"RGBA\":\n case \"RGBX\":\n case \"BGRA\":\n case \"BGRX\":\n return 1;\n default:\n throw new DOMException(\"Unsupported video pixel format\", \"NotSupportedError\");\n }\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport * as et from \"./event-target\";\nimport * as libavs from \"./avloader\";\nimport * as misc from \"./misc\";\nimport * as vf from \"./video-frame\";\nexport class VideoDecoder extends et.DequeueEventTarget {\n constructor(init) {\n super();\n // 1. Let d be a new VideoDecoder object.\n // 2. Assign a new queue to [[control message queue]].\n this._p = Promise.all([]);\n // 3. Assign false to [[message queue blocked]].\n // (unneeded in polyfill)\n // 4. Assign null to [[codec implementation]].\n this._libav = null;\n this._codec = this._c = this._pkt = this._frame = 0;\n /* 5. Assign the result of starting a new parallel queue to\n * [[codec work queue]]. */\n // (shared queue)\n // 6. Assign false to [[codec saturated]].\n // (saturation not needed)\n // 7. Assign init.output to [[output callback]].\n this._output = init.output;\n // 8. Assign init.error to [[error callback]].\n this._error = init.error;\n // 9. Assign null to [[active decoder config]].\n // (part of codec)\n // 10. Assign true to [[key chunk required]].\n // (part of codec)\n // 11. Assign \"unconfigured\" to [[state]]\n this.state = \"unconfigured\";\n // 12. Assign 0 to [[decodeQueueSize]].\n this.decodeQueueSize = 0;\n // 13. Assign a new list to [[pending flush promises]].\n // (shared queue)\n // 14. Assign false to [[dequeue event scheduled]].\n // (not needed in polyfill)\n // 15. Return d.\n }\n configure(config) {\n // 1. If config is not a valid VideoDecoderConfig, throw a TypeError.\n // NOTE: We don't support sophisticated codec string parsing (yet)\n // 2. If [[state]] is “closed”, throw an InvalidStateError DOMException.\n if (this.state === \"closed\")\n throw new DOMException(\"Decoder is closed\", \"InvalidStateError\");\n // Free any internal state\n if (this._libav)\n this._p = this._p.then(() => this._free());\n // 3. Set [[state]] to \"configured\".\n this.state = \"configured\";\n // 4. Set [[key chunk required]] to true.\n // (part of the codec)\n // 5. Queue a control message to configure the decoder with config.\n this._p = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n /* 1. Let supported be the result of running the Check\n * Configuration Support algorithm with config. */\n const supported = libavs.decoder(config.codec, config);\n /* 2. If supported is false, queue a task to run the Close\n * VideoDecoder algorithm with NotSupportedError and abort these\n * steps. */\n if (!supported) {\n this._closeVideoDecoder(new DOMException(\"Unsupported codec\", \"NotSupportedError\"));\n return;\n }\n /* 3. If needed, assign [[codec implementation]] with an\n * implementation supporting config. */\n // 4. Configure [[codec implementation]] with config.\n const libav = this._libav = yield libavs.get();\n // Initialize\n [this._codec, this._c, this._pkt, this._frame] =\n yield libav.ff_init_decoder(supported.codec);\n yield libav.AVCodecContext_time_base_s(this._c, 1, 1000);\n // 5. queue a task to run the following steps:\n // 1. Assign false to [[message queue blocked]].\n // 2. Queue a task to Process the control message queue.\n })).catch(this._error);\n }\n // Our own algorithm, close libav\n _free() {\n return __awaiter(this, void 0, void 0, function* () {\n if (this._c) {\n yield this._libav.ff_free_decoder(this._c, this._pkt, this._frame);\n this._codec = this._c = this._pkt = this._frame = 0;\n }\n if (this._libav) {\n libavs.free(this._libav);\n this._libav = null;\n }\n });\n }\n _closeVideoDecoder(exception) {\n // 1. Run the Reset VideoDecoder algorithm with exception.\n this._resetVideoDecoder(exception);\n // 2. Set [[state]] to \"closed\".\n this.state = \"closed\";\n /* 3. Clear [[codec implementation]] and release associated system\n * resources. */\n this._p = this._p.then(() => this._free());\n /* 4. If exception is not an AbortError DOMException, invoke the\n * [[error callback]] with exception. */\n if (exception.name !== \"AbortError\")\n this._p = this._p.then(() => { this._error(exception); });\n }\n _resetVideoDecoder(exception) {\n // 1. If [[state]] is \"closed\", throw an InvalidStateError.\n if (this.state === \"closed\")\n throw new DOMException(\"Decoder closed\", \"InvalidStateError\");\n // 2. Set [[state]] to \"unconfigured\".\n this.state = \"unconfigured\";\n // ... really, we're just going to free it now\n this._p = this._p.then(() => this._free());\n }\n decode(chunk) {\n const self = this;\n // 1. If [[state]] is not \"configured\", throw an InvalidStateError.\n if (this.state !== \"configured\")\n throw new DOMException(\"Unconfigured\", \"InvalidStateError\");\n // 2. If [[key chunk required]] is true:\n // 1. If chunk.[[type]] is not key, throw a DataError.\n /* 2. Implementers SHOULD inspect the chunk’s [[internal data]] to\n * verify that it is truly a key chunk. If a mismatch is detected,\n * throw a DataError. */\n // 3. Otherwise, assign false to [[key chunk required]].\n // 3. Increment [[decodeQueueSize]].\n this.decodeQueueSize++;\n // 4. Queue a control message to decode the chunk.\n this._p = this._p.then(function () {\n return __awaiter(this, void 0, void 0, function* () {\n const libav = self._libav;\n const c = self._c;\n const pkt = self._pkt;\n const frame = self._frame;\n let decodedOutputs = null;\n /* 3. Decrement [[decodeQueueSize]] and run the Schedule Dequeue\n * Event algorithm. */\n self.decodeQueueSize--;\n self.dispatchEvent(new CustomEvent(\"dequeue\"));\n // 1. Attempt to use [[codec implementation]] to decode the chunk.\n try {\n // Convert to a libav packet\n const ptsFull = Math.floor(chunk.timestamp / 1000);\n const [pts, ptshi] = libav.f64toi64(ptsFull);\n const packet = {\n data: chunk._libavGetData(),\n pts,\n ptshi,\n dts: pts,\n dtshi: ptshi\n };\n if (chunk.duration) {\n packet.duration = Math.floor(chunk.duration / 1000);\n packet.durationhi = 0;\n }\n decodedOutputs = yield libav.ff_decode_multi(c, pkt, frame, [packet]);\n /* 2. If decoding results in an error, queue a task on the control\n * thread event loop to run the Close VideoDecoder algorithm with\n * EncodingError. */\n }\n catch (ex) {\n self._p = self._p.then(() => {\n self._closeVideoDecoder(ex);\n });\n }\n /* 3. If [[codec saturated]] equals true and\n * [[codec implementation]] is no longer saturated, queue a task\n * to perform the following steps: */\n // 1. Assign false to [[codec saturated]].\n // 2. Process the control message queue.\n // (unneeded)\n /* 4. Let decoded outputs be a list of decoded video data outputs\n * emitted by [[codec implementation]] in presentation order. */\n /* 5. If decoded outputs is not empty, queue a task to run the\n * Output VideoFrame algorithm with decoded outputs. */\n if (decodedOutputs)\n self._outputVideoFrames(decodedOutputs);\n });\n }).catch(this._error);\n }\n _outputVideoFrames(frames) {\n const libav = this._libav;\n for (const frame of frames) {\n // 1. format\n let format;\n switch (frame.format) {\n case libav.AV_PIX_FMT_YUV420P:\n format = \"I420\";\n break;\n case 0x3E: /* AV_PIX_FMT_YUV420P10 */\n format = \"I420P10\";\n break;\n case 0x7B: /* AV_PIX_FMT_YUV420P12 */\n format = \"I420P12\";\n break;\n case libav.AV_PIX_FMT_YUVA420P:\n format = \"I420A\";\n break;\n case 0x57: /* AV_PIX_FMT_YUVA420P10 */\n format = \"I420AP10\";\n break;\n case libav.AV_PIX_FMT_YUV422P:\n format = \"I422\";\n break;\n case 0x40: /* AV_PIX_FMT_YUV422P10 */\n format = \"I422P10\";\n break;\n case 0x7F: /* AV_PIX_FMT_YUV422P12 */\n format = \"I422P12\";\n break;\n case 0x4E: /* AV_PIX_FMT_YUVA422P */\n format = \"I422A\";\n break;\n case 0x59: /* AV_PIX_FMT_YUVA422P10 */\n format = \"I422AP10\";\n break;\n case 0xBA: /* AV_PIX_FMT_YUVA422P12 */\n format = \"I422AP12\";\n break;\n case libav.AV_PIX_FMT_YUV444P:\n format = \"I444\";\n break;\n case 0x44: /* AV_PIX_FMT_YUV444P10 */\n format = \"I444P10\";\n break;\n case 0x83: /* AV_PIX_FMT_YUV444P12 */\n format = \"I444P12\";\n break;\n case 0x4F: /* AV_PIX_FMT_YUVA444P */\n format = \"I444A\";\n break;\n case 0x5B: /* AV_PIX_FMT_YUVA444P10 */\n format = \"I444AP10\";\n break;\n case 0xBC: /* AV_PIX_FMT_YUVA444P12 */\n format = \"I444AP12\";\n break;\n case libav.AV_PIX_FMT_NV12:\n format = \"NV12\";\n break;\n case libav.AV_PIX_FMT_RGBA:\n format = \"RGBA\";\n break;\n case 0x77: /* AV_PIX_FMT_RGB0 */\n format = \"RGBX\";\n break;\n case libav.AV_PIX_FMT_BGRA:\n format = \"BGRA\";\n break;\n case 0x79: /* AV_PIX_FMT_BGR0 */\n format = \"BGRX\";\n break;\n default:\n throw new DOMException(\"Unsupported libav format!\", \"EncodingError\");\n }\n // 2. width and height\n const codedWidth = frame.width;\n const codedHeight = frame.height;\n // 3. cropping\n let visibleRect;\n if (frame.crop) {\n visibleRect = new DOMRect(frame.crop.left, frame.crop.top, codedWidth - frame.crop.left - frame.crop.right, codedHeight - frame.crop.top - frame.crop.bottom);\n }\n else {\n visibleRect = new DOMRect(0, 0, codedWidth, codedHeight);\n }\n // Check for non-square pixels\n let displayWidth = codedWidth;\n let displayHeight = codedHeight;\n if (frame.sample_aspect_ratio && frame.sample_aspect_ratio[0]) {\n const sar = frame.sample_aspect_ratio;\n if (sar[0] > sar[1])\n displayWidth = ~~(codedWidth * sar[0] / sar[1]);\n else\n displayHeight = ~~(codedHeight * sar[1] / sar[0]);\n }\n // 3. timestamp\n const timestamp = libav.i64tof64(frame.pts, frame.ptshi) * 1000;\n const data = new vf.VideoFrame(frame.data, {\n layout: frame.layout,\n format, codedWidth, codedHeight, visibleRect, displayWidth, displayHeight,\n timestamp\n });\n this._output(data);\n }\n }\n flush() {\n /* 1. If [[state]] is not \"configured\", return a promise rejected with\n * InvalidStateError DOMException. */\n if (this.state !== \"configured\")\n throw new DOMException(\"Invalid state\", \"InvalidStateError\");\n // 2. Set [[key chunk required]] to true.\n // (handled by codec)\n // 3. Let promise be a new Promise.\n // 4. Append promise to [[pending flush promises]].\n // 5. Queue a control message to flush the codec with promise.\n // 6. Process the control message queue.\n const ret = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n /* 1. Signal [[codec implementation]] to emit all internal pending\n * outputs. */\n if (!this._c)\n return;\n // Make sure any last data is flushed\n const libav = this._libav;\n const c = this._c;\n const pkt = this._pkt;\n const frame = this._frame;\n let decodedOutputs = null;\n try {\n decodedOutputs = yield libav.ff_decode_multi(c, pkt, frame, [], true);\n }\n catch (ex) {\n this._p = this._p.then(() => {\n this._closeVideoDecoder(ex);\n });\n }\n /* 2. Let decoded outputs be a list of decoded video data outputs\n * emitted by [[codec implementation]]. */\n // 3. Queue a task to perform these steps:\n {\n /* 1. If decoded outputs is not empty, run the Output VideoFrame\n * algorithm with decoded outputs. */\n if (decodedOutputs)\n this._outputVideoFrames(decodedOutputs);\n // 2. Remove promise from [[pending flush promises]].\n // 3. Resolve promise.\n }\n }));\n this._p = ret;\n // 7. Return promise.\n return ret;\n }\n reset() {\n this._resetVideoDecoder(new DOMException(\"Reset\", \"AbortError\"));\n }\n close() {\n this._closeVideoDecoder(new DOMException(\"Close\", \"AbortError\"));\n }\n static isConfigSupported(config) {\n return __awaiter(this, void 0, void 0, function* () {\n const dec = libavs.decoder(config.codec, config);\n let supported = false;\n if (dec) {\n const libav = yield libavs.get();\n try {\n const [, c, pkt, frame] = yield libav.ff_init_decoder(dec.codec);\n yield libav.ff_free_decoder(c, pkt, frame);\n supported = true;\n }\n catch (ex) { }\n yield libavs.free(libav);\n }\n return {\n supported,\n config: misc.cloneConfig(config, [\"codec\", \"codedWidth\", \"codedHeight\"])\n };\n });\n }\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport * as evc from \"./encoded-video-chunk\";\nimport * as et from \"./event-target\";\nimport * as libavs from \"./avloader\";\nimport * as misc from \"./misc\";\nimport * as vf from \"./video-frame\";\nexport class VideoEncoder extends et.DequeueEventTarget {\n constructor(init) {\n super();\n this._extradataSet = false;\n this._extradata = null;\n // If our output uses non-square pixels, that information\n this._nonSquarePixels = false;\n this._sar_num = 1;\n this._sar_den = 1;\n // 1. Let e be a new VideoEncoder object.\n // 2. Assign a new queue to [[control message queue]].\n this._p = Promise.all([]);\n // 3. Assign false to [[message queue blocked]].\n // (unneeded in polyfill)\n // 4. Assign null to [[codec implementation]].\n this._libav = null;\n this._codec = this._c = this._frame = this._pkt = 0;\n /* 5. Assign the result of starting a new parallel queue to\n * [[codec work queue]]. */\n // (shared queue)\n // 6. Assign false to [[codec saturated]].\n // (saturation unneeded)\n // 7. Assign init.output to [[output callback]].\n this._output = init.output;\n // 8. Assign init.error to [[error callback]].\n this._error = init.error;\n // 9. Assign null to [[active encoder config]].\n // (part of codec)\n // 10. Assign null to [[active output config]].\n this._metadata = null;\n // 11. Assign \"unconfigured\" to [[state]]\n this.state = \"unconfigured\";\n // 12. Assign 0 to [[encodeQueueSize]].\n this.encodeQueueSize = 0;\n // 13. Assign a new list to [[pending flush promises]].\n // (shared queue)\n // 14. Assign false to [[dequeue event scheduled]].\n // (shared queue)\n // 15. Return e.\n }\n configure(config) {\n // 1. If config is not a valid VideoEncoderConfig, throw a TypeError.\n // NOTE: We don't support sophisticated codec string parsing (yet)\n // 2. If [[state]] is \"closed\", throw an InvalidStateError.\n if (this.state === \"closed\")\n throw new DOMException(\"Encoder is closed\", \"InvalidStateError\");\n // Free any internal state\n if (this._libav)\n this._p = this._p.then(() => this._free());\n // 3. Set [[state]] to \"configured\".\n this.state = \"configured\";\n // 4. Queue a control message to configure the encoder using config.\n this._p = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n /* 1. Let supported be the result of running the Check\n * Configuration Support algorithm with config. */\n const supported = libavs.encoder(config.codec, config);\n /* 2. If supported is false, queue a task to run the Close\n * VideoEncoder algorithm with NotSupportedError and abort these\n * steps. */\n if (!supported) {\n this._closeVideoEncoder(new DOMException(\"Unsupported codec\", \"NotSupportedError\"));\n return;\n }\n /* 3. If needed, assign [[codec implementation]] with an\n * implementation supporting config. */\n // 4. Configure [[codec implementation]] with config.\n const libav = this._libav = yield libavs.get();\n this._metadata = {\n decoderConfig: {\n codec: supported.codec\n }\n };\n // And initialize\n [this._codec, this._c, this._frame, this._pkt] =\n yield libav.ff_init_encoder(supported.codec, supported);\n this._extradataSet = false;\n this._extradata = null;\n yield libav.AVCodecContext_time_base_s(this._c, 1, 1000);\n const width = config.width;\n const height = config.height;\n this._sws = 0;\n this._swsFrame = 0;\n this._swsOut = {\n width, height,\n format: supported.ctx.pix_fmt\n };\n // Check for non-square pixels\n const dWidth = config.displayWidth || width;\n const dHeight = config.displayHeight || height;\n if (dWidth !== width || dHeight !== height) {\n this._nonSquarePixels = true;\n this._sar_num = dWidth * height;\n this._sar_den = dHeight * width;\n }\n else {\n this._nonSquarePixels = false;\n }\n // 5. queue a task to run the following steps:\n // 1. Assign false to [[message queue blocked]].\n // 2. Queue a task to Process the control message queue.\n })).catch(this._error);\n }\n // Our own algorithm, close libav\n _free() {\n return __awaiter(this, void 0, void 0, function* () {\n if (this._sws) {\n yield this._libav.av_frame_free_js(this._swsFrame);\n yield this._libav.sws_freeContext(this._sws);\n this._sws = this._swsFrame = 0;\n this._swsIn = this._swsOut = void 0;\n }\n if (this._c) {\n yield this._libav.ff_free_encoder(this._c, this._frame, this._pkt);\n this._codec = this._c = this._frame = this._pkt = 0;\n }\n if (this._libav) {\n libavs.free(this._libav);\n this._libav = null;\n }\n });\n }\n _closeVideoEncoder(exception) {\n // 1. Run the Reset VideoEncoder algorithm with exception.\n this._resetVideoEncoder(exception);\n // 2. Set [[state]] to \"closed\".\n this.state = \"closed\";\n /* 3. Clear [[codec implementation]] and release associated system\n * resources. */\n this._p = this._p.then(() => this._free());\n /* 4. If exception is not an AbortError DOMException, invoke the\n * [[error callback]] with exception. */\n if (exception.name !== \"AbortError\")\n this._p = this._p.then(() => { this._error(exception); });\n }\n _resetVideoEncoder(exception) {\n // 1. If [[state]] is \"closed\", throw an InvalidStateError.\n if (this.state === \"closed\")\n throw new DOMException(\"Encoder closed\", \"InvalidStateError\");\n // 2. Set [[state]] to \"unconfigured\".\n this.state = \"unconfigured\";\n // ... really, we're just going to free it now\n this._p = this._p.then(() => this._free());\n }\n encode(frame, options = {}) {\n /* 1. If the value of frame’s [[Detached]] internal slot is true, throw\n * a TypeError. */\n if (frame._libavGetData() === null)\n throw new TypeError(\"Detached\");\n // 2. If [[state]] is not \"configured\", throw an InvalidStateError.\n if (this.state !== \"configured\")\n throw new DOMException(\"Unconfigured\", \"InvalidStateError\");\n /* 3. Let frameClone hold the result of running the Clone VideoFrame\n * algorithm with frame. */\n const frameClone = frame.clone();\n // 4. Increment [[encodeQueueSize]].\n this.encodeQueueSize++;\n // 5. Queue a control message to encode frameClone.\n this._p = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n const libav = this._libav;\n const c = this._c;\n const pkt = this._pkt;\n const framePtr = this._frame;\n const swsOut = this._swsOut;\n let encodedOutputs = null;\n /* 3. Decrement [[encodeQueueSize]] and run the Schedule Dequeue\n * Event algorithm. */\n this.encodeQueueSize--;\n this.dispatchEvent(new CustomEvent(\"dequeue\"));\n /* 1. Attempt to use [[codec implementation]] to encode frameClone\n * according to options. */\n try {\n // Convert the format\n const format = vf.wcFormatToLibAVFormat(libav, frameClone.format);\n // Convert the data\n const rawU8 = frameClone._libavGetData();\n const layout = frameClone._libavGetLayout();\n // Convert the timestamp\n const ptsFull = Math.floor(frameClone.timestamp / 1000);\n const [pts, ptshi] = libav.f64toi64(ptsFull);\n // Make the frame\n const frame = {\n data: rawU8, layout,\n format, pts, ptshi,\n width: frameClone.codedWidth,\n height: frameClone.codedHeight,\n crop: {\n left: frameClone.visibleRect.left,\n right: frameClone.visibleRect.right,\n top: frameClone.visibleRect.top,\n bottom: frameClone.visibleRect.bottom\n },\n key_frame: options.keyFrame ? 1 : 0,\n pict_type: options.keyFrame ? 1 : 0\n };\n // Possibly scale\n if (frame.width !== swsOut.width ||\n frame.height !== swsOut.height ||\n frame.format !== swsOut.format) {\n if (frameClone._nonSquarePixels) {\n frame.sample_aspect_ratio = [\n frameClone._sar_num,\n frameClone._sar_den\n ];\n }\n // Need a scaler\n let sws = this._sws, swsIn = this._swsIn, swsFrame = this._swsFrame;\n if (!sws ||\n frame.width !== swsIn.width ||\n frame.height !== swsIn.height ||\n frame.format !== swsIn.format) {\n // Need to allocate the scaler\n if (sws)\n yield libav.sws_freeContext(sws);\n swsIn = {\n width: frame.width,\n height: frame.height,\n format: frame.format\n };\n sws = yield libav.sws_getContext(swsIn.width, swsIn.height, swsIn.format, swsOut.width, swsOut.height, swsOut.format, 2, 0, 0, 0);\n this._sws = sws;\n this._swsIn = swsIn;\n // Maybe need a frame\n if (!swsFrame)\n this._swsFrame = swsFrame = yield libav.av_frame_alloc();\n }\n // Scale and encode the frame\n const [, swsRes, , , , , , encRes] = yield Promise.all([\n libav.ff_copyin_frame(framePtr, frame),\n libav.sws_scale_frame(sws, swsFrame, framePtr),\n this._nonSquarePixels ?\n libav.AVFrame_sample_aspect_ratio_s(swsFrame, this._sar_num, this._sar_den) :\n null,\n libav.AVFrame_pts_s(swsFrame, pts),\n libav.AVFrame_ptshi_s(swsFrame, ptshi),\n libav.AVFrame_key_frame_s(swsFrame, options.keyFrame ? 1 : 0),\n libav.AVFrame_pict_type_s(swsFrame, options.keyFrame ? 1 : 0),\n libav.avcodec_send_frame(c, swsFrame)\n ]);\n if (swsRes < 0 || encRes < 0)\n throw new Error(\"Encoding failed!\");\n encodedOutputs = [];\n while (true) {\n const recv = yield libav.avcodec_receive_packet(c, pkt);\n if (recv === -libav.EAGAIN)\n break;\n else if (recv < 0)\n throw new Error(\"Encoding failed!\");\n encodedOutputs.push(yield libav.ff_copyout_packet(pkt));\n }\n }\n else {\n if (this._nonSquarePixels) {\n frame.sample_aspect_ratio = [\n this._sar_num,\n this._sar_den\n ];\n }\n // Encode directly\n encodedOutputs =\n yield libav.ff_encode_multi(c, framePtr, pkt, [frame]);\n }\n if (encodedOutputs.length && !this._extradataSet)\n yield this._getExtradata();\n /* 2. If encoding results in an error, queue a task to run the\n * Close VideoEncoder algorithm with EncodingError and return. */\n }\n catch (ex) {\n this._p = this._p.then(() => {\n this._closeVideoEncoder(ex);\n });\n return;\n }\n /* 3. If [[codec saturated]] equals true and\n * [[codec implementation]] is no longer saturated, queue a task\n * to perform the following steps: */\n // 1. Assign false to [[codec saturated]].\n // 2. Process the control message queue.\n // (unneeded in polyfill)\n /* 4. Let encoded outputs be a list of encoded video data outputs\n * emitted by [[codec implementation]]. */\n /* 5. If encoded outputs is not empty, queue a task to run the\n * Output EncodedVideoChunks algorithm with encoded outputs. */\n if (encodedOutputs)\n this._outputEncodedVideoChunks(encodedOutputs);\n })).catch(this._error);\n }\n // Internal: Get extradata\n _getExtradata() {\n return __awaiter(this, void 0, void 0, function* () {\n const libav = this._libav;\n const c = this._c;\n const extradata = yield libav.AVCodecContext_extradata(c);\n const extradata_size = yield libav.AVCodecContext_extradata_size(c);\n if (extradata && extradata_size) {\n this._metadata.decoderConfig.description = this._extradata =\n yield libav.copyout_u8(extradata, extradata_size);\n }\n this._extradataSet = true;\n });\n }\n _outputEncodedVideoChunks(packets) {\n const libav = this._libav;\n for (const packet of packets) {\n // 1. type\n const type = (packet.flags & 1) ? \"key\" : \"delta\";\n // 2. timestamp\n const timestamp = libav.i64tof64(packet.pts, packet.ptshi) * 1000;\n const chunk = new evc.EncodedVideoChunk({\n type: type, timestamp,\n data: packet.data\n });\n if (this._extradataSet)\n this._output(chunk, this._metadata || void 0);\n else\n this._output(chunk);\n }\n }\n flush() {\n /* 1. If [[state]] is not \"configured\", return a promise rejected with\n * InvalidStateError DOMException. */\n if (this.state !== \"configured\")\n throw new DOMException(\"Invalid state\", \"InvalidStateError\");\n // 2. Let promise be a new Promise.\n // 3. Append promise to [[pending flush promises]].\n // 4. Queue a control message to flush the codec with promise.\n // 5. Process the control message queue.\n const ret = this._p.then(() => __awaiter(this, void 0, void 0, function* () {\n /* 1. Signal [[codec implementation]] to emit all internal pending\n * outputs. */\n if (!this._c)\n return;\n // Make sure any last data is flushed\n const libav = this._libav;\n const c = this._c;\n const frame = this._frame;\n const pkt = this._pkt;\n let encodedOutputs = null;\n try {\n encodedOutputs =\n yield libav.ff_encode_multi(c, frame, pkt, [], true);\n if (!this._extradataSet)\n yield this._getExtradata();\n }\n catch (ex) {\n this._p = this._p.then(() => {\n this._closeVideoEncoder(ex);\n });\n }\n /* 2. Let encoded outputs be a list of encoded video data outputs\n * emitted by [[codec implementation]]. */\n // 3. Queue a task to perform these steps:\n {\n /* 1. If encoded outputs is not empty, run the Output\n * EncodedVideoChunks algorithm with encoded outputs. */\n if (encodedOutputs)\n this._outputEncodedVideoChunks(encodedOutputs);\n // 2. Remove promise from [[pending flush promises]].\n // 3. Resolve promise.\n }\n }));\n this._p = ret;\n // 6. Return promise.\n return ret;\n }\n reset() {\n this._resetVideoEncoder(new DOMException(\"Reset\", \"AbortError\"));\n }\n close() {\n this._closeVideoEncoder(new DOMException(\"Close\", \"AbortError\"));\n }\n static isConfigSupported(config) {\n return __awaiter(this, void 0, void 0, function* () {\n const enc = libavs.encoder(config.codec, config);\n let supported = false;\n if (enc) {\n const libav = yield libavs.get();\n try {\n const [, c, frame, pkt] = yield libav.ff_init_encoder(enc.codec, enc);\n yield libav.ff_free_encoder(c, frame, pkt);\n supported = true;\n }\n catch (ex) { }\n yield libavs.free(libav);\n }\n return {\n supported,\n config: misc.cloneConfig(config, [\"codec\", \"width\", \"height\", \"bitrate\", \"framerate\", \"latencyMode\"])\n };\n });\n }\n}\n;\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport * as libav from \"./avloader\";\nimport * as vf from \"./video-frame\";\nimport '@ungap/global-this';\n// A non-threaded libav.js instance for scaling.\nlet scalerSync = null;\n// A synchronous libav.js instance for scaling.\nlet scalerAsync = null;\n// The original drawImage\nlet origDrawImage = null;\n// The original drawImage Offscreen\nlet origDrawImageOffscreen = null;\n// The original createImageBitmap\nlet origCreateImageBitmap = null;\n/**\n * Load rendering capability.\n * @param libavOptions Options to use while loading libav\n * @param polyfill Set to polyfill CanvasRenderingContext2D.drawImage\n */\nexport function load(libavOptions, polyfill) {\n return __awaiter(this, void 0, void 0, function* () {\n // Get our scalers\n if (\"importScripts\" in globalThis) {\n // Make sure the worker code doesn't run\n libav.LibAVWrapper.nolibavworker = true;\n }\n scalerSync = (yield libav.LibAVWrapper.LibAV(Object.assign(Object.assign({}, libavOptions), { noworker: true, yesthreads: false })));\n scalerAsync = yield libav.LibAVWrapper.LibAV(libavOptions);\n // Polyfill drawImage\n if ('CanvasRenderingContext2D' in globalThis) {\n origDrawImage = CanvasRenderingContext2D.prototype.drawImage;\n if (polyfill)\n CanvasRenderingContext2D.prototype.drawImage = drawImagePolyfill;\n }\n if ('OffscreenCanvasRenderingContext2D' in globalThis) {\n origDrawImageOffscreen = OffscreenCanvasRenderingContext2D.prototype.drawImage;\n if (polyfill)\n OffscreenCanvasRenderingContext2D.prototype.drawImage = drawImagePolyfillOffscreen;\n }\n // Polyfill createImageBitmap\n origCreateImageBitmap = globalThis.createImageBitmap;\n if (polyfill)\n globalThis.createImageBitmap = createImageBitmap;\n });\n}\n/**\n * Draw this video frame on this canvas, synchronously.\n * @param ctx CanvasRenderingContext2D to draw on\n * @param image VideoFrame (or anything else) to draw\n * @param sx Source X position OR destination X position\n * @param sy Source Y position OR destination Y position\n * @param sWidth Source width OR destination width\n * @param sHeight Source height OR destination height\n * @param dx Destination X position\n * @param dy Destination Y position\n * @param dWidth Destination width\n * @param dHeight Destination height\n */\nexport function canvasDrawImage(ctx, image, ax, ay, sWidth, sHeight, dx, dy, dWidth, dHeight) {\n if (!(image._data)) {\n // Just use the original\n return origDrawImage.apply(ctx, Array.prototype.slice.call(arguments, 1));\n }\n let sx;\n let sy;\n // Normalize the arguments\n if (typeof sWidth === \"undefined\") {\n // dx, dy\n dx = ax;\n dy = ay;\n }\n else if (typeof dx === \"undefined\") {\n // dx, dy, dWidth, dHeight\n dx = ax;\n dy = ay;\n dWidth = sWidth;\n dHeight = sHeight;\n sx = void 0;\n sy = void 0;\n sWidth = void 0;\n sHeight = void 0;\n }\n else {\n sx = ax;\n sy = ay;\n }\n if (typeof dWidth === \"undefined\") {\n dWidth = image.displayWidth;\n dHeight = image.displayHeight;\n }\n // Convert the format to libav.js\n const format = vf.wcFormatToLibAVFormat(scalerSync, image.format);\n // Convert the frame synchronously\n const sctx = scalerSync.sws_getContext_sync(image.visibleRect.width, image.visibleRect.height, format, dWidth, dHeight, scalerSync.AV_PIX_FMT_RGBA, 2, 0, 0, 0);\n const inFrame = scalerSync.av_frame_alloc_sync();\n const outFrame = scalerSync.av_frame_alloc_sync();\n let rawU8;\n let layout;\n if (image._libavGetData) {\n rawU8 = image._libavGetData();\n layout = image._libavGetLayout();\n }\n else {\n // Just have to hope this is a polyfill VideoFrame copied weirdly!\n rawU8 = image._data;\n layout = image._layout;\n }\n // Copy it in\n scalerSync.ff_copyin_frame_sync(inFrame, {\n data: rawU8,\n layout,\n format,\n width: image.codedWidth,\n height: image.codedHeight,\n crop: {\n left: image.visibleRect.left,\n right: image.visibleRect.right,\n top: image.visibleRect.top,\n bottom: image.visibleRect.bottom\n }\n });\n // Rescale\n scalerSync.sws_scale_frame_sync(sctx, outFrame, inFrame);\n // Get the data back out again\n const frameData = scalerSync.ff_copyout_frame_video_imagedata_sync(outFrame);\n // Finally, draw it\n ctx.putImageData(frameData, dx, dy);\n // And clean up\n scalerSync.av_frame_free_js_sync(outFrame);\n scalerSync.av_frame_free_js_sync(inFrame);\n scalerSync.sws_freeContext_sync(sctx);\n}\n/**\n * Polyfill version of canvasDrawImage.\n */\nfunction drawImagePolyfill(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {\n if (image instanceof vf.VideoFrame) {\n return canvasDrawImage(this, image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);\n }\n return origDrawImage.apply(this, arguments);\n}\n/**\n * Polyfill version of offscreenCanvasDrawImage.\n */\nfunction drawImagePolyfillOffscreen(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {\n if (image instanceof vf.VideoFrame) {\n return canvasDrawImage(this, image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);\n }\n return origDrawImageOffscreen.apply(this, arguments);\n}\n/**\n * Create an ImageBitmap from this drawable, asynchronously. NOTE:\n * Sub-rectangles are not implemented for VideoFrames, so only options is\n * available, and there, only scaling is available.\n * @param image VideoFrame (or anything else) to draw\n * @param options Other options\n */\nexport function createImageBitmap(image, opts = {}) {\n if (!(image._data)) {\n // Just use the original\n return origCreateImageBitmap.apply(globalThis, arguments);\n }\n // Convert the format to libav.js\n const format = vf.wcFormatToLibAVFormat(scalerAsync, image.format);\n // Normalize arguments\n const dWidth = (typeof opts.resizeWidth === \"number\")\n ? opts.resizeWidth : image.displayWidth;\n const dHeight = (typeof opts.resizeHeight === \"number\")\n ? opts.resizeHeight : image.displayHeight;\n // Convert the frame\n return (() => __awaiter(this, void 0, void 0, function* () {\n const [sctx, inFrame, outFrame] = yield Promise.all([\n scalerAsync.sws_getContext(image.visibleRect.width, image.visibleRect.height, format, dWidth, dHeight, scalerAsync.AV_PIX_FMT_RGBA, 2, 0, 0, 0),\n scalerAsync.av_frame_alloc(),\n scalerAsync.av_frame_alloc()\n ]);\n // Convert the data\n let rawU8;\n let layout = void 0;\n if (image._libavGetData) {\n rawU8 = image._libavGetData();\n layout = image._libavGetLayout();\n }\n else if (image._data) {\n // Assume a VideoFrame weirdly serialized\n rawU8 = image._data;\n layout = image._layout;\n }\n else {\n rawU8 = new Uint8Array(image.allocationSize());\n yield image.copyTo(rawU8);\n }\n // Copy it in\n yield scalerAsync.ff_copyin_frame(inFrame, {\n data: rawU8,\n layout,\n format,\n width: image.codedWidth,\n height: image.codedHeight,\n crop: {\n left: image.visibleRect.left,\n right: image.visibleRect.right,\n top: image.visibleRect.top,\n bottom: image.visibleRect.bottom\n }\n }),\n // Rescale\n yield scalerAsync.sws_scale_frame(sctx, outFrame, inFrame);\n // Get the data back out again\n const frameData = yield scalerAsync.ff_copyout_frame_video_imagedata(outFrame);\n // And clean up\n yield Promise.all([\n scalerAsync.av_frame_free_js(outFrame),\n scalerAsync.av_frame_free_js(inFrame),\n scalerAsync.sws_freeContext(sctx)\n ]);\n // Make the ImageBitmap\n return yield origCreateImageBitmap(frameData);\n }))();\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport * as eac from \"./encoded-audio-chunk\";\nimport * as ad from \"./audio-data\";\nimport * as adec from \"./audio-decoder\";\nimport * as aenc from \"./audio-encoder\";\nimport * as evc from \"./encoded-video-chunk\";\nimport * as vf from \"./video-frame\";\nimport * as vdec from \"./video-decoder\";\nimport * as venc from \"./video-encoder\";\nimport '@ungap/global-this';\n/**\n * Error thrown to indicate a configuration is unsupported.\n */\nexport class UnsupportedException extends Error {\n constructor() {\n super(\"The requested configuration is not supported\");\n }\n}\n/**\n * Get an AudioDecoder environment that supports this configuration. Throws an\n * UnsupportedException if no environment supports the configuration.\n * @param config Audio decoder configuration\n */\nexport function getAudioDecoder(config) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n if (typeof globalThis.AudioDecoder !== \"undefined\" &&\n (yield globalThis.AudioDecoder.isConfigSupported(config)).supported) {\n return {\n AudioDecoder: globalThis.AudioDecoder,\n EncodedAudioChunk: globalThis.EncodedAudioChunk,\n AudioData: globalThis.AudioData\n };\n }\n }\n catch (ex) { }\n if ((yield adec.AudioDecoder.isConfigSupported(config)).supported) {\n return {\n AudioDecoder: adec.AudioDecoder,\n EncodedAudioChunk: eac.EncodedAudioChunk,\n AudioData: ad.AudioData\n };\n }\n throw new UnsupportedException();\n });\n}\n/**\n * Get an VideoDecoder environment that supports this configuration. Throws an\n * UnsupportedException if no environment supports the configuration.\n * @param config Video decoder configuration\n */\nexport function getVideoDecoder(config) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n if (typeof globalThis.VideoDecoder !== \"undefined\" &&\n (yield globalThis.VideoDecoder.isConfigSupported(config)).supported) {\n return {\n VideoDecoder: globalThis.VideoDecoder,\n EncodedVideoChunk: globalThis.EncodedVideoChunk,\n VideoFrame: globalThis.VideoFrame\n };\n }\n }\n catch (ex) { }\n if ((yield vdec.VideoDecoder.isConfigSupported(config)).supported) {\n return {\n VideoDecoder: vdec.VideoDecoder,\n EncodedVideoChunk: evc.EncodedVideoChunk,\n VideoFrame: vf.VideoFrame\n };\n }\n throw new UnsupportedException();\n });\n}\n/**\n * Get an AudioEncoder environment that supports this configuration. Throws an\n * UnsupportedException if no environment supports the configuration.\n * @param config Audio encoder configuration\n */\nexport function getAudioEncoder(config) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n if (typeof globalThis.AudioEncoder !== \"undefined\" &&\n (yield globalThis.AudioEncoder.isConfigSupported(config)).supported) {\n return {\n AudioEncoder: globalThis.AudioEncoder,\n EncodedAudioChunk: globalThis.EncodedAudioChunk,\n AudioData: globalThis.AudioData\n };\n }\n }\n catch (ex) { }\n if ((yield aenc.AudioEncoder.isConfigSupported(config)).supported) {\n return {\n AudioEncoder: aenc.AudioEncoder,\n EncodedAudioChunk: eac.EncodedAudioChunk,\n AudioData: ad.AudioData\n };\n }\n throw new UnsupportedException();\n });\n}\n/**\n * Get an VideoEncoder environment that supports this configuration. Throws an\n * UnsupportedException if no environment supports the configuration.\n * @param config Video encoder configuration\n */\nexport function getVideoEncoder(config) {\n return __awaiter(this, void 0, void 0, function* () {\n try {\n if (typeof globalThis.VideoEncoder !== \"undefined\" &&\n (yield globalThis.VideoEncoder.isConfigSupported(config)).supported) {\n return {\n VideoEncoder: globalThis.VideoEncoder,\n EncodedVideoChunk: globalThis.EncodedVideoChunk,\n VideoFrame: globalThis.VideoFrame\n };\n }\n }\n catch (ex) { }\n if ((yield venc.VideoEncoder.isConfigSupported(config)).supported) {\n return {\n VideoEncoder: venc.VideoEncoder,\n EncodedVideoChunk: evc.EncodedVideoChunk,\n VideoFrame: vf.VideoFrame\n };\n }\n throw new UnsupportedException();\n });\n}\n","/*\n * This file is part of the libav.js WebCodecs Polyfill implementation. The\n * interface implemented is derived from the W3C standard. No attribution is\n * required when using this library.\n *\n * Copyright (c) 2021-2024 Yahweasel\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport * as eac from \"./encoded-audio-chunk\";\nimport * as ad from \"./audio-data\";\nimport * as adec from \"./audio-decoder\";\nimport * as aenc from \"./audio-encoder\";\nimport * as evc from \"./encoded-video-chunk\";\nimport * as vf from \"./video-frame\";\nimport * as vdec from \"./video-decoder\";\nimport * as venc from \"./video-encoder\";\nimport * as rendering from \"./rendering\";\nimport * as config from \"./config\";\nimport * as libav from \"./avloader\";\nimport '@ungap/global-this';\n/**\n * Load LibAV-WebCodecs-Polyfill.\n */\nexport function load(options = {}) {\n return __awaiter(this, void 0, void 0, function* () {\n // Set up libavOptions\n let libavOptions = {};\n if (options.libavOptions)\n Object.assign(libavOptions, options.libavOptions);\n // Maybe load libav\n if (!options.LibAV && typeof globalThis.LibAV === \"undefined\") {\n yield new Promise((res, rej) => {\n // Can't load workers from another origin\n libavOptions.noworker = true;\n // Load libav\n const libavBase = \"https://cdn.jsdelivr.net/npm/@libav.js/variant-webm-vp9@6.7.7/dist\";\n globalThis.LibAV = { base: libavBase };\n const libavVar = \"libav-6.7.7.1.1-webm-vp9.js\";\n if (typeof importScripts !== \"undefined\") {\n importScripts(`${libavBase}/${libavVar}`);\n res(void 0);\n }\n else {\n const scr = document.createElement(\"script\");\n scr.src = `${libavBase}/${libavVar}`;\n scr.onload = res;\n scr.onerror = rej;\n document.body.appendChild(scr);\n }\n });\n }\n // And load the libav handler\n if (options.LibAV)\n libav.setLibAV(options.LibAV);\n libav.setLibAVOptions(libavOptions);\n yield libav.load();\n if (options.polyfill) {\n for (const exp of [\n [\"EncodedAudioChunk\", eac.EncodedAudioChunk],\n [\"AudioData\", ad.AudioData],\n [\"AudioDecoder\", adec.AudioDecoder],\n [\"AudioEncoder\", aenc.AudioEncoder],\n [\"EncodedVideoChunk\", evc.EncodedVideoChunk],\n [\"VideoFrame\", vf.VideoFrame],\n [\"VideoDecoder\", vdec.VideoDecoder],\n [\"VideoEncoder\", venc.VideoEncoder]\n ]) {\n if (!globalThis[exp[0]])\n globalThis[exp[0]] = exp[1];\n }\n }\n yield rendering.load(libavOptions, !!options.polyfill);\n });\n}\nexport const EncodedAudioChunk = eac.EncodedAudioChunk;\nexport const AudioData = ad.AudioData;\nexport const AudioDecoder = adec.AudioDecoder;\nexport const AudioEncoder = aenc.AudioEncoder;\nexport const EncodedVideoChunk = evc.EncodedVideoChunk;\nexport const VideoFrame = vf.VideoFrame;\nexport const VideoDecoder = vdec.VideoDecoder;\nexport const VideoEncoder = venc.VideoEncoder;\n// Rendering\nexport const canvasDrawImage = rendering.canvasDrawImage;\nexport const createImageBitmap = rendering.createImageBitmap;\nexport const UnsupportedException = config.UnsupportedException;\nexport const getAudioDecoder = config.getAudioDecoder;\nexport const getVideoDecoder = config.getVideoDecoder;\nexport const getAudioEncoder = config.getAudioEncoder;\nexport const getVideoEncoder = config.getVideoEncoder;\n"],"names":["EncodedAudioChunk$1","init","transfer","inBuffer","t","b","data","destination","Object","get","global","AudioData$1","AudioData","inData","byteOffset","resourceReference","audioView","opts","ret","from","ad","planes","isInterleaved","sizePerPlane","p","totalSamples","totalSize","bytesPerSample","options","copyElementCount","destFormat","isInterleaved_","frameCount","frameOffset","copyFrameCount","elementCount","planeFrames","numberOfChannels","dest","out","sub","div","i","o","format","buffer","HasAEventTarget","ev","DequeueEventTarget","__awaiter","thisArg","_arguments","P","generator","adopt","value","resolve","reject","fulfilled","step","e","rejected","result","LibAVWrapper","libavs","libavOptions","decoders","encoders","setLibAV","to","setLibAVOptions","free","libav","codecs","avname","codec","load","decoder","config","outCodec","encoder","codecParts","ctx","video","flac","opus","av1Advanced","vp9Advanced","width","height","dWidth","dHeight","profile","level","depth","cloneConfig","fields","field","et.DequeueEventTarget","udesc","descView","descBuf","supported","libavs.decoder","libavs.get","codecpara","ps","extraDataPtr","fps","libavs.free","exception","chunk","c","pkt","frame","decodedOutputs","ptsFull","pts","ptshi","packet","ex","outputs","planar","sampleRate","numberOfFrames","timestamp","raw","ct","part","ad.AudioData","dec","misc.cloneConfig","self","libavs.encoder","frame_size","dataClone","framePtr","encodedOutputs","nb_samples","ad.isInterleaved","split","cc","channel_layout","sample_rate","preOutputs","filter_ctx","fframes","x","frames","fin","extradataPtr","extradata_size","extradata","packets","type","duration","eac.EncodedAudioChunk","buffersrc_ctx","enc","EncodedVideoChunk","offscreenCanvas","VideoFrame$1","VideoFrame","array","image","defaultRect","overrideRect","parsedRect","optLayout","combinedLayout","numPlanes_","numPlanes","layout","offset","sampleWidth","horizontalSubSamplingFactor","sampleHeight","verticalSubSamplingFactor","stride","lo","hi","plane","resourceCodedWidth","resourceCodedHeight","vf","vr","sourceRect","minAllocationSize","computedLayouts","endOffsets","planeIndex","sampleBytes_","sampleBytes","computedLayout","planeLayout","planeSize","planeEnd","earlierPlaneIndex","earlierLayout","rect","xw","yh","destBuf","planeLayouts","sourceStride","sourceOffset","destinationOffset","rowBytes","row","wcFormatToLibAVFormat","wcFormat","codedWidth","codedHeight","visibleRect","displayWidth","displayHeight","sar","vf.VideoFrame","frameClone","swsOut","vf.wcFormatToLibAVFormat","rawU8","sws","swsIn","swsFrame","swsRes","encRes","recv","evc.EncodedVideoChunk","scalerSync","scalerAsync","origDrawImage","origDrawImageOffscreen","origCreateImageBitmap","polyfill","libav.LibAVWrapper","drawImagePolyfill","drawImagePolyfillOffscreen","createImageBitmap","canvasDrawImage","ax","ay","sWidth","sHeight","dx","dy","sctx","inFrame","outFrame","frameData","sx","sy","getAudioDecoder","adec.AudioDecoder","UnsupportedException","getVideoDecoder","vdec.VideoDecoder","getAudioEncoder","aenc.AudioEncoder","getVideoEncoder","venc.VideoEncoder","res","rej","libavBase","libavVar","scr","libav.setLibAV","libav.setLibAVOptions","libav.load","exp","rendering.load","EncodedAudioChunk","AudioDecoder","AudioEncoder","VideoDecoder","VideoEncoder","rendering.canvasDrawImage","rendering.createImageBitmap","config.UnsupportedException","config.getAudioDecoder","config.getVideoDecoder","config.getAudioEncoder","config.getVideoEncoder"],"mappings":"AAkBO,IAAAA,IAAA,MAAwB;AAAA,EAC3B,YAAYC,GAAM;AASd;AAEI,WAAK,OAAOA,EAAK,MAEjB,KAAK,YAAYA,EAAK,WAGlB,OAAOA,EA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