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

Method isConfigSupported

src/video_decoder.ts:150–172  ·  view source on GitHub ↗

* Checks if the decoder can support the given configuration.

(config: VideoDecoderConfig)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 3

createCodecContextMethod · 0.95
configToCacheKeyFunction · 0.70

Tested by

no test coverage detected