1

几周前,我尝试使用 restcomm for android 建立 SIP 服务。我检查了与第三方应用程序 (cSipSimple) 的连接,一切正常。但是当我尝试与 restcomm 演示应用程序连接时,连接每次 4 秒后都会下降。我的 sdk 有什么问题,或者我怎么能唱得好?

SipProfile sipProfile = new SipProfile();

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("pref_proxy_ip", "my.server.ip");
        params.put("pref_proxy_port", "5060");
        params.put("pref_sip_user", "7879114");
        params.put("pref_sip_password", "EeFei2Fa");
        for (String key : params.keySet()) {
            if (key.equals("pref_proxy_ip")) {
                sipProfile.setRemoteIp((String) params.get(key));
            } else if (key.equals("pref_proxy_port")) {
                sipProfile.setRemotePort(Integer.parseInt((String) params.get(key)));
            } else if (key.equals("pref_sip_user")) {
                sipProfile.setSipUserName((String) params.get(key));
            } else if (key.equals("pref_sip_password")) {
                sipProfile.setSipPassword((String) params.get(key));
            }
        }

        final SipManager sipManager = new SipManager(sipProfile, true);

        Register registerRequest = new Register();

        final Request r = registerRequest.MakeRequest(sipManager, 100000, null);
            // Send the request statefully, through the client transaction.
        Thread thread = new Thread() {
            public void run() {
                try {
                    final ClientTransaction transaction = sipManager.sipProvider.getNewClientTransaction(r);
                    transaction.sendRequest();
                } catch (SipException e) {
                    e.printStackTrace();
                }
            }
        };
        thread.start(); 
4

1 回答 1

1

@Vladislav,您正在使用 SDK 的低级设施,这些设施已过时且不应直接使用。我建议您使用 SDK 直接公开的 RestCommClient API。它更易于使用并提供相同的功能等等。

有关如何使用它的示例,请查看:

https://github.com/RestComm/restcomm-android-sdk/blob/master/Examples/restcomm-helloworld/app/src/main/java/com/telestax/restcomm_helloworld/MainActivity.java

您需要从以下位置更改 SIP 服务器设置:

https://github.com/RestComm/restcomm-android-sdk/blob/master/Examples/restcomm-helloworld/app/src/main/java/com/telestax/restcomm_helloworld/MainActivity.java#L99

被叫方来自:

https://github.com/RestComm/restcomm-android-sdk/blob/master/Examples/restcomm-helloworld/app/src/main/java/com/telestax/restcomm_helloworld/MainActivity.java#L174

请记住,对于媒体,使用 Webrtc 以便正确处理 NAT。这意味着接收方也需要能够处理 Webrtc。除非中间有服务器处理中介,例如Restcomm-Connect

更多信息请查看RestComm Client Android SDK 快速入门

于 2016-05-10T09:20:58.647 回答