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

Method createCodecContext

src/audio_decoder.ts:71–94  ·  view source on GitHub ↗
(config: AudioDecoderConfig)

Source from the content-addressed store, hash-verified

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.

Callers 2

isConfigSupportedMethod · 0.95
configureInternalMethod · 0.45

Calls 3

getChannelLayoutFunction · 0.85
toUint8ArrayFunction · 0.85

Tested by

no test coverage detected