private void InitializeDecoder(AudioFormat audioFormat) { if (_decoder != null) { return; } if (audioFormat == AudioFormat.ALAC) { // RTP info: 96 AppleLossless, 96 352 0 16 40 10 14 2 255 0 0 44100 // (ALAC -> PCM) var frameLength = 352; var numChannels = 2; var bitDepth = 16; var sampleRate = 44100; _decoder = new ALACDecoder(_clConfig.ALACLibPath); _decoder.Config(sampleRate, numChannels, bitDepth, frameLength); } else if (audioFormat == AudioFormat.AAC) { // RTP info: 96 mpeg4-generic/44100/2, 96 mode=AAC-main; constantDuration=1024 // (AAC-MAIN -> PCM) var frameLength = 1024; var numChannels = 2; var bitDepth = 16; var sampleRate = 44100; _decoder = new AACDecoder(_clConfig.AACLibPath, TransportType.TT_MP4_RAW, AudioObjectType.AOT_AAC_MAIN, 1); _decoder.Config(sampleRate, numChannels, bitDepth, frameLength); } else if (audioFormat == AudioFormat.AAC_ELD) { // RTP info: 96 mpeg4-generic/44100/2, 96 mode=AAC-eld; constantDuration=480 // (AAC-ELD -> PCM) var frameLength = 480; var numChannels = 2; var bitDepth = 16; var sampleRate = 44100; _decoder = new AACDecoder(_clConfig.AACLibPath, TransportType.TT_MP4_RAW, AudioObjectType.AOT_ER_AAC_ELD, 1); _decoder.Config(sampleRate, numChannels, bitDepth, frameLength); } else { // (PCM -> PCM) // Not used _decoder = new PCMDecoder(); } }