* Checks if the decoder can support the given configuration.
(config: VideoDecoderConfig)
| 148 | * Checks if the decoder can support the given configuration. |
| 149 | */ |
| 150 | static async isConfigSupported(config: VideoDecoderConfig): Promise<VideoDecoderSupport> { |
| 151 | const inferred = inferCodecFromCodecString(config.codec); |
| 152 | if (!inferred) { |
| 153 | return { config, supported: false }; |
| 154 | } |
| 155 | |
| 156 | const cacheKey = configToCacheKey(inferred, config.codedWidth!, config.codedHeight!); |
| 157 | if (configSupportCache.has(cacheKey)) { |
| 158 | return { config, supported: configSupportCache.get(cacheKey)! }; |
| 159 | } |
| 160 | |
| 161 | using codecContext = this.createCodecContext(config); |
| 162 | if (!codecContext) { |
| 163 | return { config, supported: false }; |
| 164 | } |
| 165 | |
| 166 | const ret = await codecContext.open2(); |
| 167 | const supported = ret >= 0; |
| 168 | |
| 169 | configSupportCache.set(cacheKey, supported); |
| 170 | |
| 171 | return { config, supported }; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Configures the decoder with the given configuration. |
nothing calls this directly
no test coverage detected