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

Method isConfigSupported

src/audio_decoder.ts:99–121  ·  view source on GitHub ↗

* Checks if the decoder can support the given configuration.

(config: AudioDecoderConfig)

Source from the content-addressed store, hash-verified

97 * Checks if the decoder can support the given configuration.
98 */
99 static async isConfigSupported(config: AudioDecoderConfig): Promise<AudioDecoderSupport> {
100 const inferred = inferCodecFromCodecString(config.codec);
101 if (!inferred) {
102 return { config, supported: false };
103 }
104
105 const cacheKey = configToCacheKey(inferred, config.sampleRate, config.numberOfChannels);
106 if (configSupportCache.has(cacheKey)) {
107 return { config, supported: configSupportCache.get(cacheKey)! };
108 }
109
110 using codecContext = this.createCodecContext(config);
111 if (!codecContext) {
112 return { config, supported: false };
113 }
114
115 const ret = await codecContext.open2();
116 const supported = ret >= 0;
117
118 configSupportCache.set(cacheKey, supported);
119
120 return { config, supported };
121 }
122
123 /**
124 * 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