(config: AudioDecoderConfig)
| 69 | } |
| 70 | |
| 71 | private static createCodecContext(config: AudioDecoderConfig) { |
| 72 | const inferred = inferCodecFromCodecString(config.codec); |
| 73 | if (!inferred) { |
| 74 | return null; |
| 75 | } |
| 76 | |
| 77 | const codec = Codec.findDecoder(inferred); |
| 78 | if (!codec) { |
| 79 | return null; |
| 80 | } |
| 81 | |
| 82 | const codecContext = new CodecContext(); |
| 83 | codecContext.allocContext3(codec); |
| 84 | |
| 85 | codecContext.sampleRate = config.sampleRate; |
| 86 | codecContext.channelLayout = getChannelLayout(config.numberOfChannels); |
| 87 | codecContext.codecType = AVMEDIA_TYPE_AUDIO; |
| 88 | codecContext.codecId = inferred; |
| 89 | codecContext.extraData = config.description |
| 90 | ? Buffer.from(toUint8Array(config.description)) |
| 91 | : null; |
| 92 | |
| 93 | return codecContext; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Checks if the decoder can support the given configuration. |
no test coverage detected