(config: VideoDecoderConfig)
| 191 | } |
| 192 | |
| 193 | private async configureInternal(config: VideoDecoderConfig) { |
| 194 | const currentConfigId = this.currentConfigId; |
| 195 | |
| 196 | using lock = this.mutex.lock(); |
| 197 | if (lock.pending) await lock.ready; |
| 198 | |
| 199 | // Check if reset/close happened while waiting for lock |
| 200 | if (this.currentConfigId !== currentConfigId) { |
| 201 | return; |
| 202 | } |
| 203 | |
| 204 | // Spec 4.5: If supported is false, queue a task to run the Close VideoDecoder algorithm with NotSupportedError. |
| 205 | // This is simulated by just trying to open the codec. |
| 206 | |
| 207 | if (this.codecContext) { |
| 208 | this.codecContext.freeContext(); |
| 209 | this.codecContext = null; |
| 210 | } |
| 211 | |
| 212 | this.codecContext = VideoDecoderPolyfill.createCodecContext(config); |
| 213 | if (!this.codecContext) { |
| 214 | throw new DOMException('Unsupported configuration', 'NotSupportedError'); |
| 215 | } |
| 216 | |
| 217 | const ret = await this.codecContext.open2(); |
| 218 | if (ret < 0) { |
| 219 | throw new DOMException('Failed to open codec', 'NotSupportedError'); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Queues an encoded video chunk to be decoded. |
no test coverage detected