Reputation: 6275
I'm using SIP in android application but my current library can't provide some functions for me. So i try to use android-linphone lib and get some confusion. I do not understand how to make registration on Asterisk with this library. Native library is loaded well
I/LinphoneCoreFactoryImpl﹕ Trying to load liblinphone for armeabi-v7a
I/LinphoneCoreFactoryImpl﹕ Loading done with armeabi-v7a
Has neon: true
Has ZRTP: true
i'm trying to create user as saying on this page liblinphone-javadoc
in my code example
activity implements 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
messages
I/System.out﹕ globalState Starting up
I/System.out﹕ configuringStatus null
I/System.out﹕ displayStatus Ready
I/System.out﹕ globalState Ready
In docs says that configuringStatus message
the error message if state == Failed, but nothing about null
.
I'll be really greatful for help with this library.
Upvotes: 1
Views: 1920
Reputation: 21
After configuration, you have to call LinphoneCore.iterate()
periodically in loop. This is main application loop. For example, from Linphone app sources:
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);
Upvotes: 2