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

Method isConfigSupported

src/video_encoder.ts:233–255  ·  view source on GitHub ↗

* Checks if the encoder can support the given configuration.

(config: VideoEncoderConfig)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 3

createCodecContextMethod · 0.95
configToCacheKeyFunction · 0.70

Tested by

no test coverage detected