2

我遵循了 PJSIP教程,并成功构建了 apjsua示例应用程序。

当我尝试通过 +a 添加帐户时,它会询问我 Sip Url、注册商的 Url、Auth Realm、用户名、密码

我进入了

  • 小口网址:sip:140@122.252.232.5
  • 注册商:sip:122.252.232.5
  • 授权领域:*
  • 用户名:1​​40
  • 密码:示例

之后它给了我以下错误

    10-17 19:57:27.165: I/apjsua(920): 19:57:27.165  sip_resolve.c  ...Failed to resolve '122.252.232.532.5'. Err=70018 (gethostbyname() has returned error (PJ_ERESOLVE))
10-17 19:57:27.174: I/apjsua(920): 19:57:27.174    tsx0x223a5c  ...Failed to send Request msg REGISTER/cseq=54907 (tdta0x1eb9a0)! err=70018 (gethostbyname() has returned error (PJ_ERESOLVE))
10-17 19:57:27.185: I/apjsua(920): 19:57:27.185    pjsua_acc.c  .....SIP registration failed, status=502 (gethostbyname() has returned error (PJ_ERESOLVE))
10-17 19:57:27.199: I/apjsua(920): 19:57:27.199    pjsua_acc.c  .....Scheduling re-registration retry for acc 2 in 6 seconds..
10-17 19:57:27.212: I/apjsua(920): 19:57:27.212      sip_reg.c  ..Error sending request, status=70018
10-17 19:57:27.226: I/apjsua(920): 19:57:27.226    pjsua_acc.c  ..Unable to create/send REGISTER: gethostbyname() has returned error (PJ_ERESOLVE) [status=70018]

有谁知道我哪里错了???

或者有没有人知道任何其他方式为 android 使用 pjsip 库???

4

1 回答 1

10

You're in luck. I was sitting with this problem a few days ago and it just looked like a simple initialization error. You should really get to grips with debugging c code else you're gonna have a hard time understanding the pjsip stack. Anyway here's what you do:

Make the "setInput" method under /pjsip-apps/src/pjsua/main_android.c look like this:

void setInput(char *s)
{
  int i = 0;

  for (i = 0; i < sizeof(app_var.line); i++)
  {
      app_var.line[i]=NULL;
  }

  /* app_var.line[0] = 0; */

  if (strlen(s) < sizeof(app_var.line))
      strncpy(app_var.line, s, strlen(s));
  pj_sem_post(app_var.input_sem);
}

Looking at the code changes, you should be able to see that the app_var.line char variable was not being cleared properly. Now go to the /pjsip-apps/build/ folder and execute "make". Then go to the /pjsip-apps/src/apjsua/ folder and execute "make". Thereafter refresh your eclipse project and run. That should do the trick.

于 2012-10-18T14:58:08.390 回答