Skip to content

A library make it easy to use Linphone Android SDK !

Notifications You must be signed in to change notification settings

forever4313/EasyLinphone

Repository files navigation

EasyLinphone

EasyLinphone make it easy to import Linphone Android SDK to your project.

中文文档

Import

Download the EasyLinphone aar at Latest release, and the Linphone Android SDK at Linphone offical website.

Then copy EasyLinPhone aar and Linphone aar to your project's libs folder, and import them in your app buid.gradle as below:

android {
	...
	repositories {
	    flatDir {
	        dirs 'libs' //this way we can find the .aar file in libs folder
	    }
	}
}

dependencies {
	...
	compile(name:'liblinphone-android-sdk', ext:'aar')
	compile(name:'easylinphone-release', ext:'aar')
}

Usage

1. Init LinphoneService

// Start service
EasyLinphone.startService(mContext);
// Add callback
EasyLinphone.addCallback(new RegistrationCallback() {
    @Override
    public void registrationOk() {
        super.registrationOk();
        // do something
    }

    @Override
    public void registrationFailed() {
        super.registrationFailed();
        // do something
    }
}, new PhoneCallback() {
    @Override
    public void incomingCall(LinphoneCall linphoneCall) {
        super.incomingCall(linphoneCall);
        // do something
    }

    @Override
    public void callConnected() {
        super.callConnected();
        // do something
    }

    @Override
    public void callEnd() {
        super.callEnd();
        // do something
    }
});

You can add registrationCallback and phoneCallback in different place in your project, this depending on your logic.

2. Login

// Configure sip account
EasyLinphone.setAccount("1003", "123456", "192.168.9.60");
// Register to sip server
EasyLinphone.login();

3. Manage the voice call

// Make a call
EasyLinphone.callTo("1001");
// Hang up the current call
EasyLinphone.hangUp();
// Answer the current call
EasyLinphone.acceptCall();
// Toggle the mute function
EasyLinphone.toggleMicro(!EasyLinphone.getLC().isMicMuted());
// Toggle the handsfree function
EasyLinphone.toggleSpeaker(!EasyLinphone.getLC().isSpeakerEnabled());

4. Manage the video call

Your video call activity or fragment may like below:

public class VideoActivity extends AppCompatActivity {
    @BindView(R.id.video_rendering) SurfaceView mRenderingView;
    @BindView(R.id.video_preview) SurfaceView mPreviewView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video);
        ButterKnife.bind(this);
        EasyLinphone.setAndroidVideoWindow(new SurfaceView[]{mRenderingView}, new SurfaceView[]{mPreviewView});
    }

    @Override
    protected void onResume() {
        super.onResume();
        EasyLinphone.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        EasyLinphone.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EasyLinphone.onDestroy();
    }

    @OnClick(R.id.video_hang)
    public void hang() {
        EasyLinphone.hangUp();
        finish();
    }
}

That's all, Enjoy it!

About

A library make it easy to use Linphone Android SDK !

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages