0
votes

I am using Pjsip Library for the call and as I am changing codec from my code and its getting change with the new priority but it not updating in FreeSWITCH call logs as it showing me older codec. Not updating with new priority codec. For suppose i have change Codec priority from PCMU 8 kHz to G729 8 kHz. but it showing me logs with PCMU only not with G729.

I have used following PJSIP inbuilt method to change CodecPriority as it changes internally in the device but not reflecting to FreeSWITCH logs.

 public short getCodecPriority(String codecName, String type, String defaultValue) {
    String key = SipConfigManager.getCodecKey(codecName, type);
    if (key != null) {
        String val = getPreferenceStringValue(key, defaultValue);
        if (!TextUtils.isEmpty(val)) {
            try {
                return (short) Integer.parseInt(val);
            } catch (NumberFormatException e) {
                Log.e(THIS_FILE, "Impossible to parse " + val);
            }
        }
    }
    return (short) Integer.parseInt(defaultValue);
}

/**
 * Set the priority for the codec for a given bandwidth type
 * 
 * @param codecName the name of the codec as announced by codec
 * @param type bandwidth type <br/>
 *            For now, valid constants are :
 *            {@link SipConfigManager#CODEC_NB} and
 *            {@link SipConfigManager#CODEC_WB}
 * @param newValue Short value for preference as a string.
 */
public void setCodecPriority(String codecName, String type, String newValue) {
    String key = SipConfigManager.getCodecKey(codecName, type);
    if (key != null) {
        setPreferenceStringValue(key, newValue);
    }
    // TODO : else raise error
}

I have used reference code from CSipSimple GitHub code.

If anyone has an idea about changing codec priority in FreeSWITCH call logs then please share Your answer.

Thanks.

1

1 Answers

3
votes

Codec Priority is just arranging our List of available codecs. switch / other parties will choose the codec, based on which codec is matched by sent priority codec list with them in ascending order.

If PCMU codec is only available codec on answerer side, then they will choose only PCMU even after you set the priority list. i.e. PCMU will selected for the call even we placed PCMU codec on the last row in the priority list.

If you want to disable PCMU/Any codec on PJSIP library side, then set the default value as 0 when setting the priority.

Did you check codec priority value like below? The codec priority will be arranged like below,

CODEC_NAME/CODEC_TYPE        PRIORITY_VALUE      
G729/8000/1                        133        
GSM/8000/1                         132      
speex/8000/1                       131      
speex/16000/1                      131     
speex/48000/1                      130      
PCMU/8000/1                        128      
iLBC/8000/1                        127

So try with disabling PCMU codec. If then freeswitch chooses G729 codec, sure the priority value is wrongly assigned.

The higher priority value is takes first place. so try with high value for G729 codec than other codecs.

I put my observation above, kindly try this and ask your queries on comments!