Closed ChristopheI closed 2 years ago
The correct approach would be to improve the IAudioEncoder interface by adding a sample rate parmeter so that it can deal with both 8kHz and 16kHz inputs.
And as you've noticed the audio resampling logic in the sipsorcery library is as crude as it can possibly get. For example to downsample from 16kHz to 8kHz every second sample is dropped.
Today, this library is working well with PCMU Audio Codec.
If I change to G722 a crash occur in FFmpegAudioSource.AudioDecoder_OnAudioFrame when _audioEncoder.EncodeAudio() is called. I'm using the sample FFmpegFileAndDevicesTest with AudioCodecsEnum AudioCodec = AudioCodecsEnum.G722;
So I tried to add support to this codec and I succeeded but:
How I modify the code:
Then is use this code (in FFmpegAudioSource.AudioDecoder_OnAudioFrame):
instead of
It's working but I feel very lucky because I'm not sure that this line is correct if another codec is used:
I also think that the final audio quality is not greater because we asked FFmpeg to change first the format and rate to AVSampleFormat.AV_SAMPLE_FMT_S16 and Helper.AUDIO_SAMPLING_RATE in FFmpegAudioDecoder.InitialiseSource
So do you have any idea to add support of G722 ? and G729 later ?
Thanks