Android Question Native VoIP/SIP Stack Codec selection (G711, AMR, GSM)

Discussion in 'Android Questions' started by echapeta, Oct 8, 2013.

  1. echapeta

    echapeta Member Licensed User

    I found at http://developer.android.com/reference/android/net/rtp/AudioCodec.html that the native stack has 3 codecs, G711, AMR and GSM

    How I can set the priority for the codecs used ?

    Is any way to interface with this option, can be added to the Library ?

    Thank You!

    More info:


    public class
    AudioCodec
    extends Object

    java.lang.Object
    ↳android.net.rtp.AudioCodec
    Class Overview
    This class defines a collection of audio codecs to be used with AudioStreams. Their parameters are designed to be exchanged using Session Description Protocol (SDP). Most of the values listed here can be found in RFC 3551, while others are described in separated standards.

    Few simple configurations are defined as public static instances for the convenience of direct uses. More complicated ones could be obtained using getCodec(int, String, String). For example, one can use the following snippet to create a mode-1-only AMR codec.

    AudioCodec codec =AudioCodec.getCodec(100,"AMR/8000","mode-set=1");


    See Also

    Summary

    Fields
    public static final AudioCodecAMRAdaptive Multi-Rate narrowband audio codec, also known as AMR or AMR-NB.
    public static final AudioCodecGSMGSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.
    public static final AudioCodecGSM_EFRGSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR.
    public static final AudioCodecPCMAG.711 a-law audio codec.
    public static final AudioCodecPCMUG.711 u-law audio codec.
    public final StringfmtpThe format parameters to be used in the corresponding SDP attribute.
    public final StringrtpmapThe encoding parameters to be used in the corresponding SDP attribute.
    public final inttypeThe RTP payload type of the encoding.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The native SIP API doesn't allow you to change or set the codec.
     
  3. luke2012

    luke2012 Well-Known Member Licensed User

    So the codec selection is done by the client / server (SIP) handshaking ?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    luke2012 likes this.
  5. echapeta

    echapeta Member Licensed User

    At the Session Initiation stage (INVITE), the clients (sip/voip stack) exposes to the SIP Proxy or Gateway what codecs it can use, in this case, the Android Native SIP/RTP stack can use, G711, AMR, GSM, in a prioritized list, the SIP Proxy negotiates the most desirable common codec for both legs.
    I a call, the RTP flow can go peer to peer directly or through the SIP Proxy.
    If the SIP Proxy can't establish a common codec, and has the capability can TRANSCODE, that is allow a different codec for each leg.

    Is important to be able to prioritize the codecs because they are designed for very different scenarios, the G711 for standard PSTN communication, 64KBps, and the ARM and GSM for wireless data, high latency, high packet losses, jitter, etc, etc.
     
  6. echapeta

    echapeta Member Licensed User

    The codec change is done at the Android RTP library level android.net.rtp.AudioCodec...
     
    luke2012 likes this.
  7. echapeta

    echapeta Member Licensed User

    UPDATE
    We sniffed a call between Android Native Stacks and found that offer the following codecs in this order or prioritization:
    a=rtpmap:9 6 GSM-EF R/8000..
    a=rtpmap:97 AMR/ 8000..
    a=rtpmap:3 GSM/800 0..
    a=rtp map:0 PC MU/8000..
    a=rtpma p:8 PCMA /8000..

    In the call, using a neutral SIP Proxy, that is, a proxy that not changes the client's choices, they use the first one....
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice