How can I create a SIP connecton using Liblinphone interface class?

1.5k views Asked by At

Want to develop a SIP client for Android using Liblinphone library. There is a LinphoneAuthInfo class that accepts authentication. And a LinphoneCore.addAuthInfo() That adds authentication info to the core.

The problem is that I cannot initialize LinphoneAuthInfo and LinphoneCore classes because they are interface classes and I don't know how to use theme.

If they was not interface classes I would do this:

// Create Authentication object
LinphoneAuthInfo authInfos;
authInfos.setDomain(id);
authInfos.setUserId(username);
authInfos.setPassword(password);

// Config Core
LinphoneCore linCore;
linCore.addAuthInfo(authInfos);

And finaly, this is the Liblinphone reference page:

http://www.linphone.org/docs/liblinphone-javadoc/org/linphone/core/LinphoneCore.html http://www.linphone.org/docs/liblinphone-javadoc/org/linphone/core/LinphoneAuthInfo.html

2

There are 2 answers

0
rostamiani On BEST ANSWER

Absolutely an interface cannot be initialized. Because it has no method implementation. It's not a class!

I should use classes that implement these methods.

In fact I should use org.linphone.core (Library) instead of LinphoneCore (Intreface)

3
Collin On

I've found this on the java website. This is a way to use interfaces:

public interface OperateCar {
   // constant declarations, if any
   // method signatures

   // An enum with values RIGHT, LEFT
   int turn(Direction direction,
            double radius,
            double startSpeed,
            double endSpeed);
   int changeLanes(Direction direction,
                   double startSpeed,
                   double endSpeed);
   int signalTurn(Direction direction,
                  boolean signalOn);
   int getRadarFront(double distanceToCar,
                     double speedOfCar);
   int getRadarRear(double distanceToCar,
                    double speedOfCar);
         ......
   // more method signatures
}


public class OperateBMW760i implements OperateCar {

    // the OperateCar method signatures, with implementation --
    // for example:
    int signalTurn(Direction direction, boolean signalOn) {
       // code to turn BMW's LEFT turn indicator lights on
       // code to turn BMW's LEFT turn indicator lights off
       // code to turn BMW's RIGHT turn indicator lights on
       // code to turn BMW's RIGHT turn indicator lights off
    }

    // other members, as needed -- for example, helper classes not 
    // visible to clients of the interface
}

More information can be found here: https://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html

I hope this helps