MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / encode

Method encode

src/audio_encoder.ts:234–249  ·  view source on GitHub ↗

* Queues audio data to be encoded.

(data: AudioData)

Source from the content-addressed store, hash-verified

232 * Queues audio data to be encoded.
233 */
234 encode(data: AudioData) {
235 // Spec: If [[state]] is not "configured", throw an InvalidStateError.
236 if (this._state !== 'configured') {
237 throw new DOMException('Encoder is not configured', 'InvalidStateError');
238 }
239
240 // Spec: Clone the AudioData
241 const clonedData = data.clone();
242
243 // Spec: Increment [[encodeQueueSize]].
244 this._encodeQueueSize++;
245
246 // Spec: Queue a control message to encode the data.
247 this.encodeInternal(clonedData)
248 .catch(e => this.handleAsyncError(e));
249 }
250
251 private outputChunk(currentConfigId: number) {
252 if (this.currentConfigId !== currentConfigId) {

Callers

nothing calls this directly

Calls 3

encodeInternalMethod · 0.95
handleAsyncErrorMethod · 0.95
cloneMethod · 0.45

Tested by

no test coverage detected