2015-09-05 44 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);