PJSip on Android

I am trying to create a Sip client for android using pjsip like CSipSimple for example. However, I really don't know much about pjsip . Does anyone have a tutorial on pjsip or something like that to create a Sip softphone in android using PJsip lib? Any suggestion is welcome!

+6
source share
4 answers

You do not need to use third-party libraries to create SIP client functions in Android. Android includes a full SIP API . You can take a look at the SIP demo to understand how to use the SIP interfaces to implement walkie-talkie type.

+3
source

The accepted answer is not entirely accurate. There are many desirable features missing from the Android SIP API that you might want to achieve through a third-party library.

Regarding the aforementioned pjsip, I spent a lot of time experimenting with building Android pjsip, and frankly, the only way to get reliable instant registration for work, as documented, is to build the OpenSSL 1.0.2a library and pass it on during setup. Then in Java you need to try (and fail) to enable TLS communication, as you can see, for UDP and TCP. Here is what I mean:

  /* Create transports. */ try { transports.add( ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_TLS, transportConfig) ); } catch (Throwable t2) { SipManager.log().e(t2); } try { transports.add( ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, transportConfig) ); } catch (Throwable t) { SipManager.log().e(t); } try { transports.add( ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_TCP, transportConfig) ); } catch (Throwable t) { SipManager.log().e(t); } 

Replace the SipManager.log() calls for the native application.

I do not quite understand why, but it is necessary for me. Otherwise, the registration process is semi-deterministic, in the sense that it will work after failure several times or will not work for 5 minutes, and then unexpectedly succeed, etc. He seems confused after the first registration.

Here is how I set up:

 TARGET_ABI=arm64-v8a ./configure-android --use-ndk-cflags --with-ssl=`pwd`/../3rd-party/openssl-1.0.2a 

And that was after the following correct instructions for Android , exrtacting the OpenSSL tarball to the folder above pjsip ../3rd-party/ and the first building there. I described this process in detail in a previous post .

+1
source

If you want to develop only a sip client, then you can use the sroid API for Android, but, as mentioned above, this will limit your application capabilities. But if you want to create chat or calls in your application, you can use pjsip, which provides many rich features. Regarding the construction of pjsip for android, you can find out here (android) and for ios, learn from here (iOS) . Basically, pjsip gives you many rich-featured APIs that you can use to suit your requirements, such as pjlib, pjsip, PJ media, pjsua, etc. Pjsua (or pjsua2 for android) is a higher-level API that helps you get the most performance with the least complexity. You can see directly here. You can learn about pjsua from here . They also provided a demo application (pjsua CLI) , Pjsua CLI and its source, which will help you understand the basic structure of an application to build using pjsip with chat and call functions.

for Android, you can see the demo app on github .

-1
source

Source: https://habr.com/ru/post/915380/


All Articles