2015-09-05 263 views
1

我在Android应用程序中使用SIP,但我目前的库无法为我提供某些功能。所以我尝试使用android-linphone lib并得到一些困惑。我不明白如何使用此库在Asterisk上进行注册。 机库被加载以及Android Linphone无法注册

I/LinphoneCoreFactoryImpl﹕ Trying to load liblinphone for armeabi-v7a 
I/LinphoneCoreFactoryImpl﹕ Loading done with armeabi-v7a 
Has neon: true 
Has ZRTP: true 

我试图创建的用户在我的代码,例如说这页liblinphone-javadoc

上 活动实现LinphoneCoreListener

LinphoneCoreListener linphoneCoreListener = this; 

    try { 
     mLinphoneCore = LinphoneCoreFactoryImpl.instance().createLinphoneCore(this, this); 
     mLinphoneCore.setNetworkReachable(true); 
    } catch (LinphoneCoreException e) { 
     System.out.println("LinphoneCoreException " + e.toString()); 
    } 

    LinphoneProxyConfig proxy_cfg; 
    LinphoneAuthInfo info; 

    info = LinphoneCoreFactory.instance().createAuthInfo(mUserName, mUserName, mUserPass, null, null, mDomain); /*create authentication structure from identity*/ 
    mLinphoneCore.addAuthInfo(info); /*add authentication info to LinphoneCore*/ 

    /*create proxy config*/ 
    try { 
     proxy_cfg = mLinphoneCore.createProxyConfig(mSipUser, mDomain, mDomain, true); 
     proxy_cfg.setIdentity(mSipUser); /*set identity with user name and domain*/ 
     proxy_cfg.setProxy(mDomain); /* we assume domain = proxy server address*/ 
     proxy_cfg.enableRegister(true); /*activate registration for this proxy config*/ 
     mLinphoneCore.addProxyConfig(proxy_cfg); /*add proxy config to linphone core*/ 
     mLinphoneCore.setDefaultProxyConfig(proxy_cfg); /*set to default proxy*/ 
     mLinphoneCore.addListener(linphoneCoreListener); 
     proxy_cfg.done(); 

     System.out.println("Proxy state is = " + proxy_cfg.getState());/*23838-23838/com.myapplication I/System.out﹕ Proxy state is = RegistrationNone*/ 
    } catch (LinphoneCoreException e) { 
     System.out.println(e.toString()); 
    } 

LinphoneCoreListener消息

I/System.out﹕ globalState Starting up 
I/System.out﹕ configuringStatus null 
I/System.out﹕ displayStatus Ready 
I/System.out﹕ globalState Ready 

在文档中说configuringStatus message错误消息如果状态==失败,但没有任何关于null

我会非常感谢这个图书馆的帮助。

回答

2

配置完成后,您必须定期拨打LinphoneCore.iterate()进行循环。这是主要的应用程序循环。例如,从Linphone应用程序来源:

mLc = LinphoneCoreFactory.instance().createLinphoneCore(...); 

    TimerTask lTask = new TimerTask() { 
     @Override 
     public void run() { 
      UIThreadDispatcher.dispatch(new Runnable() { 
       @Override 
       public void run() { 
        if (mLc != null) { 
         mLc.iterate(); 
        } 
       } 
      }); 
     } 
    }; 
    mTimer = new Timer("Linphone scheduler"); 
    mTimer.schedule(lTask, 0, 20);