Giter Site home page Giter Site logo

easylinphone's Introduction

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!

easylinphone's People

Contributors

forever4313 avatar xcy396 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.