* Queues a video frame to be encoded.
(frame: VideoFrame, options?: VideoEncoderEncodeOptions)
| 307 | * Queues a video frame to be encoded. |
| 308 | */ |
| 309 | encode(frame: VideoFrame, options?: VideoEncoderEncodeOptions) { |
| 310 | // Spec 6.5: If the value of frame's [[Detached]] internal slot is true, throw a TypeError. |
| 311 | // (VideoFramePolyfill usually throws on access if detached, but explicit check is good) |
| 312 | |
| 313 | // Spec 6.5: If [[state]] is not "configured", throw an InvalidStateError. |
| 314 | if (this._state !== 'configured') { |
| 315 | throw new DOMException('Encoder is not configured', 'InvalidStateError'); |
| 316 | } |
| 317 | |
| 318 | // Spec 6.5: Let frameClone hold the result of running the Clone VideoFrame algorithm with frame. |
| 319 | const clonedFrame = frame.clone(); |
| 320 | |
| 321 | // Spec 6.5: Increment [[encodeQueueSize]]. |
| 322 | this._encodeQueueSize++; |
| 323 | |
| 324 | // Spec 6.5: Queue a control message to encode frameClone. |
| 325 | this.encodeInternal(clonedFrame, options) |
| 326 | .catch(e => this.handleAsyncError(e)); |
| 327 | } |
| 328 | |
| 329 | private outputChunk(currentConfigId: number) { |
| 330 | if (this.currentConfigId !== currentConfigId) { |
no test coverage detected