[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Linphone-developers] Understand better what I need to setup and use Lib

From: Giacomo Furlan
Subject: [Linphone-developers] Understand better what I need to setup and use LibLinphone on Android
Date: Mon, 05 Oct 2015 15:29:04 +0200
User-agent: Mailbird/


I have to create a SIP client which must has to reply as an interphone (so only incoming audio/video calls). To be honest I saw a lack of documentation, because all I was able to find are pieces of code here and there... and I find really difficult to navigate in a so big library as liblinphone.

Now, what I've done so far: in theory I configured the proxy, added it and set as default and started the service via (myLinphoneCoreInstance).iterate(). In details:

1. created a class which handles LinPhone with the following code as construct:

    SIPHandler (Context context) {
        ctx = context;
        enabled = true;


        LinphoneCoreListener listener = null;
        try {
            listener = new SIPListener(ctx);
            lc = LinphoneCoreFactory.instance().createLinphoneCore(listener, context);

            LinphoneCore.Transports transports = new LinphoneCore.Transports();
            transports.udp = 8888; // is this in order to LISTEN on port 8888?

        } catch (LinphoneCoreException e) {

    public void register(String username, String domain) {
        LinphoneCoreFactory lcFactory = LinphoneCoreFactory.instance();

        String identity = "sip:" + username + "@" + domain;

        RelativeLayout mainLayout = (RelativeLayout) ((Activity) ctx).findViewById(;

        try {
            LinphoneProxyConfig proxyCfg = lc.createProxyConfig(identity, domain, null, true);


            Snackbar.make(mainLayout, "LibLinphone correctly setup", Snackbar.LENGTH_LONG).show();
        } catch (LinphoneCoreException e) {
            Snackbar.make(mainLayout, "LibLinphone error was thrown", Snackbar.LENGTH_LONG).show();

So far, so good: all goes fine without any error.

Then I start the loop in a separate thread:

callHandler.register("1050", "");
Runnable loop = new LinPhoneLooper(callHandler);
new Thread(loop).start();

This is the code of LinPhoneLooper:

public class LinPhoneLooper implements Runnable {
    LinphoneCore lc;
    SIPHandler handler;

    public LinPhoneLooper(SIPHandler handler) {
        this.handler = handler; = handler.getCore();

    public void run() {
        while (handler.isEnabled()) {
            if (lc != null) {
            try {
            } catch (InterruptedException e) {

Eventually this is the LinphoneCoreListener implementation (SIPListener), which extends LinphoneCoreListenerBase:

    SIPListener(Context context) {
        ctx = context;
        mainLayout = (RelativeLayout) ((Activity) ctx).findViewById(;

    public void registrationState(LinphoneCore linphoneCore, LinphoneProxyConfig linphoneProxyConfig, LinphoneCore.RegistrationState registrationState, String s) {
        if (registrationState == LinphoneCore.RegistrationState.RegistrationOk) {
            Snackbar.make(mainLayout, "Registered to SIP service", Snackbar.LENGTH_LONG).show();
        } else {
            Snackbar.make(mainLayout, "" + registrationState, Snackbar.LENGTH_LONG).show();

As I previously wrote, I expected to see the registration work... but I get no registrationState procs (and thus no registration at all). Wireshark even confirms me that there is no network activity at all, so LinPhone is actually stopped.

When I'll figure out how to register, I'll need to know how to receive a call (and setup a View accordingly in order to see and view the streams), but one step per time.

Can you please help me?

Thank you very much!

Giacomo Furlan
Software developer
Software Solutions Designs

reply via email to

[Prev in Thread] Current Thread [Next in Thread]