Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G729 encode problem #707

Open
z791382465 opened this issue Mar 30, 2022 · 9 comments
Open

G729 encode problem #707

z791382465 opened this issue Mar 30, 2022 · 9 comments

Comments

@z791382465
Copy link

I use sipsorcery to answer a sip audio call with G729 codec.
On sipsorcery side listen audio normally, but on caller side hear the noise(can hear volume change on speaking).

@z791382465
Copy link
Author

https://github.com/sipsorcery-org/SIPSorceryMedia.Windows/blob/master/src/WindowsAudioEndPoint.cs#L280
OnAudioSourceEncodedSample?.Invoke((uint)encodedSample.Length, encodedSample);

Follow this code the first parameter will be 20, but it shold be 160.
Maybe can fix like this, but i think this is not a good solution.
OnAudioSourceEncodedSample?.Invoke((uint)_audioFormatManager.SelectedFormat.RtpClockRate / 1000 * AUDIO_SAMPLE_PERIOD_MILLISECONDS, encodedSample);

@ChristopheI
Copy link
Collaborator

hi @z791382465 ,

Which library are you using to Encode / Decode sound ?
Which library are you using to manage Audio Input and Audio Output ?

@z791382465
Copy link
Author

Which library are you using to Encode / Decode sound ?

SIPSorcery.Media.AudioEncoder

Which library are you using to manage Audio Input and Audio Output ?

SIPSorceryMedia.Windows.WindowsAudioEndPoint

@ChristopheI
Copy link
Collaborator

I never used SIPSorceryMedia.Windows.WindowsAudioEndPoint.

I created recently a new package SIPSorceryMedia.SDL2 which should work with G729

I'm sure this library is working with PCMU (G711), PCMA (G711), G722 and Opus since I have tested them in a real WebRTC context. (using Edge / Chrome browser as remote peer - the sound was good in both direction)

G729 is not used in WebRTC context so I cannot test it in real context. I have just tested it using an Audio Input source (from a file or a Microphone) then I encode it and decode it to finally check the result in an Audio Output

@z791382465
Copy link
Author

Thank you for your help.
Sorry, I should definition my problem correctly.

SIPSorcery.Media.AudioEncoder is working.
I think SIPSorceryMedia.Windows.WindowsAudioEndPoint pass wrong length encoded data.

@ChristopheI
Copy link
Collaborator

ChristopheI commented May 5, 2022

SIPSorcery.Media.AudioEncoder is working.

Yes, I confirm. I use it correctly for PCMU (G711), PCMA (G711), G722 and G729

I think SIPSorceryMedia.Windows.WindowsAudioEndPoint pass wrong length encoded data.

It could also be linked to the way to deal with "frame size". Perhaps you have to take "frame" by "frame" the audio raw received before to encode it and then call OnAudioSourceEncodedSample

@z791382465
Copy link
Author

I succeed in sip call with G711, G722, G729 codec.
I think WindowsAudioEndPoint have two problems.

  1. Can't correctly set parameter durationRtpUnits where call OnAudioSourceEncodedSample.
    Maybe can fix like this.
    OnAudioSourceEncodedSample?.Invoke((uint)(pcm.Length * _audioFormatManager.SelectedFormat.RtpClockRate / _audioFormatManager.SelectedFormat.ClockRate), encodedSample);

  2. Use fixed sample rate(8KHz) to open audio capture device.
    If use G722, it should be 16KHz.
    I hardcode it for test. I don't have an elegant solution for now.

@ChristopheI
Copy link
Collaborator

I succeed in sip call with G711, G722, G729 codec. I think WindowsAudioEndPoint have two problems.

Using which packages ? SIPSorceryMedia.SDL2 or SIPSorceryMedia.Windows ? Both ?

  1. Can't correctly set parameter durationRtpUnits where call OnAudioSourceEncodedSample.
    Maybe can fix like this.
    OnAudioSourceEncodedSample?.Invoke((uint)(pcm.Length * _audioFormatManager.SelectedFormat.RtpClockRate / _audioFormatManager.SelectedFormat.ClockRate), encodedSample);
  2. Use fixed sample rate(8KHz) to open audio capture device.
    If use G722, it should be 16KHz.
    I hardcode it for test. I don't have an elegant solution for now.

Sorry but I don't use / manage these packages. So I can't help more.

@z791382465
Copy link
Author

Using which packages ? SIPSorceryMedia.SDL2 or SIPSorceryMedia.Windows ? Both ?

I only use SIPSorceryMedia.Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants