* Checks if the decoder can support the given configuration.
(config: AudioDecoderConfig)
| 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. |
nothing calls this directly
no test coverage detected