* Checks if the encoder can support the given configuration.
(config: VideoEncoderConfig)
| 231 | * Checks if the encoder can support the given configuration. |
| 232 | */ |
| 233 | static async isConfigSupported(config: VideoEncoderConfig): Promise<VideoEncoderSupport> { |
| 234 | const inferred = inferCodecFromCodecString(config.codec); |
| 235 | if (!inferred) { |
| 236 | return { config, supported: false }; |
| 237 | } |
| 238 | |
| 239 | const cacheKey = configToCacheKey(inferred, config.width, config.height, config.bitrate); |
| 240 | if (configSupportCache.has(cacheKey)) { |
| 241 | return { config, supported: configSupportCache.get(cacheKey)! }; |
| 242 | } |
| 243 | |
| 244 | using codecContext = this.createCodecContext(config); |
| 245 | if (!codecContext) { |
| 246 | return { config, supported: false }; |
| 247 | } |
| 248 | |
| 249 | const ret = await codecContext.open2(); |
| 250 | const supported = ret >= 0; |
| 251 | |
| 252 | configSupportCache.set(cacheKey, supported); |
| 253 | |
| 254 | return { config, supported }; |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Configures the encoder with the given configuration. |
nothing calls this directly
no test coverage detected