简体   繁体   中英

How to change PJSIP sip port for android version?

I am trying to use the different SIP port other than 5060.

I change the port of following code, but only the source port is changed. The destination port of SIP server is still 5060.

        // Create SIP transport. Error handling sample is shown
    TransportConfig sipTpConfig = new TransportConfig();
    sipTpConfig.setPort(Long.parseLong(port, 10));
            /* Create transports. */
    try {
        ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, sipTpConfig);
    }catch(Exception e){
        System.out.println(e);
    }

Does anyone have the idea how to do?

Thanks in advance!

You have to modify the account configuration:

final String acc_id    = String.format(Locale.ENGLISH, "sip:%s@%s", username, domain);
final String registrar = String.format(Locale.ENGLISH, "sip:%s", domain);
final String proxy     = String.format(Locale.ENGLISH, "sip:%s:%d;transport=%s;port=%d", domainip, port, protocol, port);


accCfg.setIdUri(acc_id);
accCfg.getRegConfig().setRegistrarUri(registrar);
AuthCredInfoVector creds = accCfg.getSipConfig().getAuthCreds();
creds.clear();
if (username.length() != 0) {
  creds.add(new AuthCredInfo("Digest", "*", username, 0, password));
}
StringVector proxies = accCfg.getSipConfig().getProxies();
proxies.clear();
if (proxy.length() != 0) {
  proxies.add(proxy);
}

accCfg.getNatConfig().setIceEnabled(true);  // Enable ICE

lastRegStatus = null;
account.modify(accCfg);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM