我怎么能正确地用restcomm唱歌?

时间:2016-05-10 08:05:23

标签: restcomm

我已经几周时间尝试使用restcomm为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(); 

1 个答案:

答案 0 :(得分: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 Quick Start