I'm new in this area...I need to create SIP client for android... I fallow demo at developer's site and i created some app that is working. Now i need to find some way how ti change audio codec... Default codec is g711...how can i change it??? Can you provide some instruction, code or tutorial??? Any help is appreciated... Thanks in advance... In this class i cannot find anything that will help me: http://developer.android.com/reference/android/net/sip/package-summary.html
2 Answers
G711 actually is another name for PCM codec, which has 2 compression algorithms (same compression rate) - known as PCMA and PCMU. These are the most standard and widely used audio codecs, supported out-of-the-box from almost any Sip Server. They are pretty old and do not offer good compression compared to Speex for example.
The audio codecs in SIP communication are negotiated in the INVITE messages, via the SDP protocol. Changing the audio codec would require the following steps:
Have an implementation of the audio codec.
Incorporate (at application level) this codec in your sip-client. High-level speaking- you have the network-layer (UDP most likely), than the data-layer (where you handle RTP packets) and SIP messages.
You need a mechanism to connect the RTP packets to the Audio Codec you would like to use. On the other hand, you need to use the SDP protocol to negotiate audio codecs with all participants.
There are some examples out there like: imsdroid, csipsimple, sipdroid etc, but they use external sip-stack implementations (doubango,mjsip). AFAIK the Android sip-stack is not very versatile for now.
Perhaps you could use the APIs related to the SIP ones: android.net.rtp contains the AudioStream, AudioGroup and AudioCodec classes that are easy to use. The last of these allows you to choose the codec which you want. http://developer.android.com/reference/android/net/rtp/AudioStream.html
Caveat: These were only introduced after Honeycomb, so if you use it you can only target devices that have this version or later installed. Considering that you are already using android.net.sip (Gingerbread onwards), this should not be much of a problem.