0

我在 Xamarin.forms 项目中使用 Linphone SDK 进行 sip 调用。我可以使用以下代码建立连接:

           var authInfo = Factory.Instance.CreateAuthInfo(username.Text, 
           null, password.Text, null, null,domain.Text);
            LinphoneCore.AddAuthInfo(authInfo);
            String proxyAddress ="sip:"+username.Text+"@192.168.1.180:5160";
            var identity = Factory.Instance.CreateAddress(proxyAddress);
            var proxyConfig = LinphoneCore.CreateProxyConfig();
            identity.Username = username.Text;
            identity.Domain = domain.Text;
            identity.Transport = TransportType.Udp;
            proxyConfig.Edit();
            proxyConfig.IdentityAddress = identity;
            proxyConfig.ServerAddr = domain.Text + ":5160;transport=udp";
            proxyConfig.Route = domain.Text;
            proxyConfig.RegisterEnabled = true;

            proxyConfig.Done();

            LinphoneCore.AddProxyConfig(proxyConfig);
            LinphoneCore.DefaultProxyConfig = proxyConfig;

            LinphoneCore.RefreshRegisters();

成功连接后,我正在使用代码放置代码。

        if (LinphoneCore.CallsNb == 0)
        {
            string phoneCall = "sip:"+address.Text+ "@192.168.1.180:5160";
            var addr = LinphoneCore.InterpretUrl(phoneCall);
            LinphoneCore.InviteAddress(addr);
        }
        else
        {
            Call call = LinphoneCore.CurrentCall;
            if (call.State == CallState.IncomingReceived)
            {
                LinphoneCore.AcceptCall(call);
            }
            else
            {
                LinphoneCore.TerminateAllCalls();
            }
        }

监听调用状态改变事件的监听器如下:

   private void OnCall(Core lc, Call lcall, CallState state, stringmessage)
   {
        call_status.Text = "Call state changed: " + state;

        if (lc.CallsNb > 0)
        {
            if (state == CallState.IncomingReceived)
            {
                call.Text = "Answer Call (" + lcall.RemoteAddressAsString + ")";
            }
            else
            {
                call.Text = "Terminate Call";
            }
            if (lcall.CurrentParams.VideoEnabled) {
                video.Text = "Stop Video";
            } else {
                video.Text = "Start Video";
            }
        }
        else
        {
            call.Text = "Start Call";
            call_stats.Text = "";
        }
    }

呼叫状态为“内部服务器错误”。我可以在我的代码中使用 Linphone 或 X-lite Soft Phone 接听电话,但我无法拨打电话。我不知道这个问题是与服务器有关还是与我的代码有关。请建议。

4

1 回答 1

0

内部服务器错误HTTP 状态代码 500)表示服务器发生意外错误。所以我怀疑问题出在你的应用程序代码上。

500 - 一般错误消息,当遇到意外情况且没有更具体的消息适合时给出。

可能是您的请求不满足您正在调用的端点的期望,但即便如此,服务器应该响应一个更有意义的错误,而不是崩溃 500。

于 2018-10-04T10:14:07.327 回答