Android SIP没有来电事件(doubango)

时间:2014-08-04 06:41:31

标签: android events sip phone-call

我一直试图整合Doubango Sip Stack。

首先,我尝试使用手册和测试呼叫示例。

但是我没有在我的广播接收器中收到ACTION_INVITE事件,虽然我已经添加了所有过滤器等。我收到了注册事件没有任何问题。

最后,我检查了IMSDroid架构并做了同样的事 - NativeService和Engine,扩展了ngn类。为清单等添加了服务。

但我还没有收到来电活动,虽然我收到了注册活动。

我在这里做错了什么?什么是方法?

P.S。我的代码看起来很像底部列出的代码: http://kehers.github.io/2014/06/04/sip-on-android.html(参见doubango示例)

1 个答案:

答案 0 :(得分:1)

我写了你问题中引用的博文。可能有几个原因导致您没有收到来电事件。您是否为来电注册了接收方?

@Override
public void onCreate() {  
  // Get engines
  mEngine = NgnEngine.getInstance();
  mSipService = mEngine.getSipService();

  // ...code blocks

  // Incoming call broadcast receiver
  final IntentFilter intentRFilter = new IntentFilter();
  callStateReceiver = new CallStateReceiver();
  intentRFilter.addAction(NgnInviteEventArgs.ACTION_INVITE_EVENT);
  registerReceiver(callStateReceiver, intentRFilter);
}

接收者:

public class CallStateReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context context, Intent intent) {

    final String action = intent.getAction();

    if(NgnInviteEventArgs.ACTION_INVITE_EVENT.equals(action)){
      NgnInviteEventArgs args = 
                intent.getParcelableExtra(NgnEventArgs.EXTRA_EMBEDDED);
      if(args == null){
        Log.d("DEBUG", "Invalid event args");
        return;
      }

      NgnAVSession avSession
                = NgnAVSession.getSession(args.getSessionId());
      if (avSession == null) {
        return;
      }

      final InviteState callState = avSession.getState();
      NgnEngine mEngine = NgnEngine.getInstance();

      switch(callState){
        case NONE:
        default:
        break;
        case INCOMING:
          Log.i("DEBUG", "Incoming call");
          // Ring
          mEngine.getSoundService().startRingTone();
          break;
        case INCALL:
          Log.i("DEBUG", "Call connected");
          mEngine.getSoundService().stopRingTone();
          break;
        case TERMINATED:
          Log.i("DEBUG", "Call terminated");
          mEngine.getSoundService().stopRingTone();
          mEngine.getSoundService().stopRingBackTone();
          break;
      }
    }
  }
}

其次,您是否使用了正确的SIP帐户详细信息进行配置?确保使用有效详细信息替换 sip_username sip_domain sip_password sip_server_port sip_server_host

NgnEngine mEngine = NgnEngine.getInstance();
INgnConfigurationService mConfigurationService
            = mEngine.getConfigurationService();
mConfigurationService.putString(NgnConfigurationEntry.IDENTITY_IMPI,
                                    "sip_username");
mConfigurationService.putString(NgnConfigurationEntry.IDENTITY_IMPU, 
        String.format("sip:%s@%s", "sip_username", "sip_domain"));
mConfigurationService.putString(NgnConfigurationEntry.IDENTITY_PASSWORD,
                                    "sip_password");
mConfigurationService.putString(NgnConfigurationEntry.NETWORK_PCSCF_HOST, 
                                    "sip_server_host");
mConfigurationService.putInt(NgnConfigurationEntry.NETWORK_PCSCF_PORT, 
                                    "sip_server_port");
mConfigurationService.putString(NgnConfigurationEntry.NETWORK_REALM,
                                    "sip_domain");
mConfigurationService.commit();

希望这有帮助。