如何更改PJSIP sip port for android version?

时间:2017-05-08 00:40:03

标签: android pjsip

我正在尝试使用5060以外的其他SIP端口。

我更改了以下代码的端口,但只更改了源端口。 SIP服务器的目标端口仍为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);
    }

有没有人知道怎么做?

提前致谢!

1 个答案:

答案 0 :(得分:0)

您必须修改帐户配置:

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);