├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── modules.xml └── runConfigurations.xml ├── README.md ├── README_CN.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xuchongyang │ │ └── easylinphone │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── xuchongyang │ │ │ └── easylinphone │ │ │ ├── LoginActivity.java │ │ │ ├── MainActivity.java │ │ │ └── VideoActivity.java │ └── res │ │ ├── layout │ │ ├── activity_login.xml │ │ ├── activity_main.xml │ │ └── activity_video.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── xuchongyang │ └── easylinphone │ └── ExampleUnitTest.java ├── build.gradle ├── easylinphone ├── .gitignore ├── build.gradle ├── libs │ └── liblinphone-android-sdk.aar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xuchongyang │ │ └── easyphone │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── xuchongyang │ │ │ └── easyphone │ │ │ ├── EasyLinphone.java │ │ │ ├── callback │ │ │ ├── PhoneCallback.java │ │ │ └── RegistrationCallback.java │ │ │ ├── linphone │ │ │ ├── KeepAliveHandler.java │ │ │ ├── LinphoneManager.java │ │ │ ├── LinphoneUtils.java │ │ │ └── PhoneBean.java │ │ │ └── service │ │ │ └── LinphoneService.java │ └── res │ │ ├── raw │ │ ├── incoming_chat.wav │ │ ├── linphonerc_default │ │ ├── linphonerc_factory │ │ ├── lpconfig.xsd │ │ ├── oldphone_mono.wav │ │ ├── ringback.wav │ │ ├── rootca.pem │ │ └── toy_mono.wav │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── xuchongyang │ └── easyphone │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/libraries 41 | .idea/misc.xml 42 | .idea/vcs.xml 43 | .idea/codeStyleSettings.xml 44 | .idea/dictionaries/ 45 | 46 | # Keystore files 47 | *.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EasyLinphone 2 | EasyLinphone make it easy to import Linphone Android SDK to your project. 3 | 4 | [中文文档](https://github.com/forever4313/EasyLinphone/blob/master/README_CN.md) 5 | 6 | ## Import 7 | Download the EasyLinphone aar at [Latest release](https://github.com/xcy396/EasyLinphone/releases), and the Linphone Android SDK at [Linphone offical website](http://www.linphone.org/technical-corner/liblinphone/downloads). 8 | 9 | Then 10 | copy EasyLinPhone aar and Linphone aar to your project's `libs` folder, and import them in your app buid.gradle as below: 11 | 12 | ```groovy 13 | android { 14 | ... 15 | repositories { 16 | flatDir { 17 | dirs 'libs' //this way we can find the .aar file in libs folder 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | ... 24 | compile(name:'liblinphone-android-sdk', ext:'aar') 25 | compile(name:'easylinphone-release', ext:'aar') 26 | } 27 | ``` 28 | 29 | ## Usage 30 | ### 1. Init LinphoneService 31 | 32 | ```java 33 | // Start service 34 | EasyLinphone.startService(mContext); 35 | // Add callback 36 | EasyLinphone.addCallback(new RegistrationCallback() { 37 | @Override 38 | public void registrationOk() { 39 | super.registrationOk(); 40 | // do something 41 | } 42 | 43 | @Override 44 | public void registrationFailed() { 45 | super.registrationFailed(); 46 | // do something 47 | } 48 | }, new PhoneCallback() { 49 | @Override 50 | public void incomingCall(LinphoneCall linphoneCall) { 51 | super.incomingCall(linphoneCall); 52 | // do something 53 | } 54 | 55 | @Override 56 | public void callConnected() { 57 | super.callConnected(); 58 | // do something 59 | } 60 | 61 | @Override 62 | public void callEnd() { 63 | super.callEnd(); 64 | // do something 65 | } 66 | }); 67 | ``` 68 | 69 | You can add registrationCallback and phoneCallback in different place in your project, this depending on your logic. 70 | 71 | ### 2. Login 72 | 73 | ```java 74 | // Configure sip account 75 | EasyLinphone.setAccount("1003", "123456", "192.168.9.60"); 76 | // Register to sip server 77 | EasyLinphone.login(); 78 | ``` 79 | 80 | ### 3. Manage the voice call 81 | 82 | ```java 83 | // Make a call 84 | EasyLinphone.callTo("1001"); 85 | // Hang up the current call 86 | EasyLinphone.hangUp(); 87 | // Answer the current call 88 | EasyLinphone.acceptCall(); 89 | // Toggle the mute function 90 | EasyLinphone.toggleMicro(!EasyLinphone.getLC().isMicMuted()); 91 | // Toggle the handsfree function 92 | EasyLinphone.toggleSpeaker(!EasyLinphone.getLC().isSpeakerEnabled()); 93 | ``` 94 | 95 | ### 4. Manage the video call 96 | 97 | Your video call activity or fragment may like below: 98 | 99 | ```java 100 | public class VideoActivity extends AppCompatActivity { 101 | @BindView(R.id.video_rendering) SurfaceView mRenderingView; 102 | @BindView(R.id.video_preview) SurfaceView mPreviewView; 103 | 104 | @Override 105 | protected void onCreate(Bundle savedInstanceState) { 106 | super.onCreate(savedInstanceState); 107 | setContentView(R.layout.activity_video); 108 | ButterKnife.bind(this); 109 | EasyLinphone.setAndroidVideoWindow(new SurfaceView[]{mRenderingView}, new SurfaceView[]{mPreviewView}); 110 | } 111 | 112 | @Override 113 | protected void onResume() { 114 | super.onResume(); 115 | EasyLinphone.onResume(); 116 | } 117 | 118 | @Override 119 | protected void onPause() { 120 | super.onPause(); 121 | EasyLinphone.onPause(); 122 | } 123 | 124 | @Override 125 | protected void onDestroy() { 126 | super.onDestroy(); 127 | EasyLinphone.onDestroy(); 128 | } 129 | 130 | @OnClick(R.id.video_hang) 131 | public void hang() { 132 | EasyLinphone.hangUp(); 133 | finish(); 134 | } 135 | } 136 | ``` 137 | 138 | That's all, Enjoy it! 139 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # EasyLinphone 2 | EasyLinphone 可以帮助你在项目中很轻松的使用 Linphone Android SDK。 3 | 4 | [English document](https://github.com/forever4313/EasyLinphone/blob/master/README.md) 5 | 6 | ## 导入 7 | * 在 [Release](https://github.com/forever4313/EasyLinphone/releases) 页面下载最新的 EasyLinphone aar 包 8 | * 在 [Linphone 官网](http://www.linphone.org/technical-corner/liblinphone/downloads) 下载最新的 LinPhone Android aar 包 9 | * 将刚才下载的两个 aar 包放到项目 app 的 libs 文件夹下,在 app 的 build.gradle 添加以下引用: 10 | 11 | ```groovy 12 | android { 13 | ... 14 | repositories { 15 | flatDir { 16 | dirs 'libs' //this way we can find the .aar file in libs folder 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | ... 23 | compile(name:'liblinphone-android-sdk', ext:'aar') 24 | compile(name:'easylinphone-release', ext:'aar') 25 | } 26 | ``` 27 | 28 | ## 使用 29 | ### 1. 初始化 LinphoneService 30 | 31 | ```java 32 | // 开启服务 33 | EasyLinphone.startService(mContext); 34 | // 添加登录状态回调和通话回调 35 | EasyLinphone.addCallback(new RegistrationCallback() { 36 | @Override 37 | public void registrationOk() { 38 | super.registrationOk(); 39 | // do something 40 | } 41 | 42 | @Override 43 | public void registrationFailed() { 44 | super.registrationFailed(); 45 | // do something 46 | } 47 | }, new PhoneCallback() { 48 | @Override 49 | public void incomingCall(LinphoneCall linphoneCall) { 50 | super.incomingCall(linphoneCall); 51 | // do something 52 | } 53 | 54 | @Override 55 | public void callConnected() { 56 | super.callConnected(); 57 | // do something 58 | } 59 | 60 | @Override 61 | public void callEnd() { 62 | super.callEnd(); 63 | // do something 64 | } 65 | }); 66 | ``` 67 | 68 | 可以根据实际情况,在不同的地方分别添加登录状态回调和通话状态回调。 69 | 70 | ### 2. 登录 71 | 72 | ```java 73 | // 配置 Sip 账户信息 74 | EasyLinphone.setAccount("1003", "123456", "192.168.9.60"); 75 | // 注册到 Sip 服务器 76 | EasyLinphone.login(); 77 | ``` 78 | 79 | ### 3. 管理音频通话 80 | 81 | ```java 82 | // 呼叫指定号码 83 | EasyLinphone.callTo("1001"); 84 | // 挂断当前通话 85 | EasyLinphone.hangUp(); 86 | // 接听当前来电 87 | EasyLinphone.acceptCall(); 88 | // 切换静音 89 | EasyLinphone.toggleMicro(!EasyLinphone.getLC().isMicMuted()); 90 | // 切换免提 91 | EasyLinphone.toggleSpeaker(!EasyLinphone.getLC().isSpeakerEnabled()); 92 | ``` 93 | 94 | ### 4. 管理视频通话 95 | 96 | 视频通话示例如下: 97 | 98 | ```java 99 | public class VideoActivity extends AppCompatActivity { 100 | @BindView(R.id.video_rendering) SurfaceView mRenderingView; 101 | @BindView(R.id.video_preview) SurfaceView mPreviewView; 102 | 103 | @Override 104 | protected void onCreate(Bundle savedInstanceState) { 105 | super.onCreate(savedInstanceState); 106 | setContentView(R.layout.activity_video); 107 | ButterKnife.bind(this); 108 | EasyLinphone.setAndroidVideoWindow(new SurfaceView[]{mRenderingView}, new SurfaceView[]{mPreviewView}); 109 | } 110 | 111 | @Override 112 | protected void onResume() { 113 | super.onResume(); 114 | EasyLinphone.onResume(); 115 | } 116 | 117 | @Override 118 | protected void onPause() { 119 | super.onPause(); 120 | EasyLinphone.onPause(); 121 | } 122 | 123 | @Override 124 | protected void onDestroy() { 125 | super.onDestroy(); 126 | EasyLinphone.onDestroy(); 127 | } 128 | 129 | @OnClick(R.id.video_hang) 130 | public void hang() { 131 | EasyLinphone.hangUp(); 132 | finish(); 133 | } 134 | } 135 | ``` 136 | 137 | 可以看到,通过本库可以很简单的使用 Linphone Android SDK。代码质量不高,还有很多疵漏之处,还请大家多多指教。 138 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.3" 6 | defaultConfig { 7 | applicationId "com.xuchongyang.easylinphone" 8 | minSdkVersion 19 9 | targetSdkVersion 22 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | lintOptions { 21 | checkReleaseBuilds false 22 | // Or, if you prefer, you can continue to check for errors in release builds, 23 | // but continue the build even when errors are found: 24 | abortOnError false 25 | } 26 | } 27 | 28 | 29 | dependencies { 30 | compile fileTree(include: ['*.jar'], dir: 'libs') 31 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 32 | exclude group: 'com.android.support', module: 'support-annotations' 33 | }) 34 | compile project(':easylinphone') 35 | compile 'com.android.support:appcompat-v7:25.3.1' 36 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 37 | compile 'com.jakewharton:butterknife:8.8.1' 38 | testCompile 'junit:junit:4.12' 39 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' 40 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/markxu/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xuchongyang/easylinphone/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.xuchongyang.easylinphone; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.xuchongyang.easylinphone", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/xuchongyang/easylinphone/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.xuchongyang.easylinphone; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.util.Log; 7 | import android.widget.EditText; 8 | import android.widget.Toast; 9 | 10 | import com.xuchongyang.easyphone.EasyLinphone; 11 | import com.xuchongyang.easyphone.callback.RegistrationCallback; 12 | import com.xuchongyang.easyphone.service.LinphoneService; 13 | 14 | import butterknife.BindView; 15 | import butterknife.ButterKnife; 16 | import butterknife.OnClick; 17 | 18 | public class LoginActivity extends AppCompatActivity { 19 | private static final String TAG = "LoginActivity"; 20 | @BindView(R.id.sip_account) EditText mAccount; 21 | @BindView(R.id.sip_password) EditText mPassword; 22 | @BindView(R.id.sip_server) EditText mServer; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_login); 28 | ButterKnife.bind(this); 29 | 30 | if (!LinphoneService.isReady()) { 31 | EasyLinphone.startService(this); 32 | EasyLinphone.addCallback(new RegistrationCallback() { 33 | @Override 34 | public void registrationOk() { 35 | super.registrationOk(); 36 | Log.e(TAG, "registrationOk: "); 37 | Toast.makeText(LoginActivity.this, "登录成功!", Toast.LENGTH_SHORT).show(); 38 | goToMainActivity(); 39 | } 40 | 41 | @Override 42 | public void registrationFailed() { 43 | super.registrationFailed(); 44 | Log.e(TAG, "registrationFailed: "); 45 | Toast.makeText(LoginActivity.this, "登录失败!", Toast.LENGTH_SHORT).show(); 46 | } 47 | }, null); 48 | } else { 49 | goToMainActivity(); 50 | } 51 | } 52 | 53 | @OnClick(R.id.press_login) 54 | public void login() { 55 | String account = mAccount.getText().toString(); 56 | String password = mPassword.getText().toString(); 57 | String serverIP = mServer.getText().toString(); 58 | EasyLinphone.setAccount(account, password, serverIP); 59 | EasyLinphone.login(); 60 | } 61 | 62 | private void goToMainActivity() { 63 | startActivity(new Intent(LoginActivity.this, MainActivity.class)); 64 | finish(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/xuchongyang/easylinphone/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.xuchongyang.easylinphone; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.util.Log; 9 | import android.view.View; 10 | import android.widget.Button; 11 | import android.widget.EditText; 12 | 13 | import com.xuchongyang.easyphone.EasyLinphone; 14 | import com.xuchongyang.easyphone.callback.PhoneCallback; 15 | 16 | import org.linphone.core.LinphoneCall; 17 | 18 | import butterknife.BindView; 19 | import butterknife.ButterKnife; 20 | import butterknife.OnClick; 21 | 22 | public class MainActivity extends AppCompatActivity { 23 | private static final String TAG = "MainActivity"; 24 | @BindView(R.id.dial_num) EditText mDialNum; 25 | @BindView(R.id.hang_up) Button mHangUp; 26 | @BindView(R.id.accept_call) Button mCallIn; 27 | @BindView(R.id.toggle_speaker) Button mToggleSpeaker; 28 | @BindView(R.id.toggle_mute) Button mToggleMute; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_main); 34 | ButterKnife.bind(this); 35 | 36 | EasyLinphone.addCallback(null, new PhoneCallback() { 37 | @Override 38 | public void incomingCall(LinphoneCall linphoneCall) { 39 | super.incomingCall(linphoneCall); 40 | // 开启铃声免提 41 | EasyLinphone.toggleSpeaker(true); 42 | mCallIn.setVisibility(View.VISIBLE); 43 | mHangUp.setVisibility(View.VISIBLE); 44 | } 45 | 46 | @Override 47 | public void outgoingInit() { 48 | super.outgoingInit(); 49 | mHangUp.setVisibility(View.VISIBLE); 50 | } 51 | 52 | @Override 53 | public void callConnected() { 54 | super.callConnected(); 55 | // 视频通话默认免提,语音通话默认非免提 56 | EasyLinphone.toggleSpeaker(EasyLinphone.getVideoEnabled()); 57 | // 所有通话默认非静音 58 | EasyLinphone.toggleMicro(false); 59 | mCallIn.setVisibility(View.GONE); 60 | mToggleSpeaker.setVisibility(View.VISIBLE); 61 | mToggleMute.setVisibility(View.VISIBLE); 62 | } 63 | 64 | @Override 65 | public void callEnd() { 66 | super.callEnd(); 67 | sendBroadcast(new Intent(VideoActivity.RECEIVE_FINISH_VIDEO_ACTIVITY)); 68 | mCallIn.setVisibility(View.GONE); 69 | mHangUp.setVisibility(View.GONE); 70 | mToggleMute.setVisibility(View.GONE); 71 | mToggleSpeaker.setVisibility(View.GONE); 72 | } 73 | }); 74 | } 75 | 76 | @OnClick(R.id.audio_call) 77 | public void audioCall() { 78 | String dialNum = mDialNum.getText().toString(); 79 | EasyLinphone.callTo(dialNum, false); 80 | } 81 | 82 | @OnClick(R.id.video_call) 83 | public void videoCall() { 84 | String dialNum = mDialNum.getText().toString(); 85 | EasyLinphone.callTo(dialNum, true); 86 | startActivity(new Intent(MainActivity.this, VideoActivity.class)); 87 | } 88 | 89 | @OnClick(R.id.hang_up) 90 | public void hangUp() { 91 | EasyLinphone.hangUp(); 92 | } 93 | 94 | @OnClick(R.id.accept_call) 95 | public void acceptCall() { 96 | EasyLinphone.acceptCall(); 97 | if (EasyLinphone.getVideoEnabled()) { 98 | startActivity(new Intent(MainActivity.this, VideoActivity.class)); 99 | } 100 | } 101 | 102 | @OnClick(R.id.toggle_mute) 103 | public void toggleMute() { 104 | EasyLinphone.toggleMicro(!EasyLinphone.getLC().isMicMuted()); 105 | } 106 | 107 | @OnClick(R.id.toggle_speaker) 108 | public void toggleSpeaker() { 109 | EasyLinphone.toggleSpeaker(!EasyLinphone.getLC().isSpeakerEnabled()); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/java/com/xuchongyang/easylinphone/VideoActivity.java: -------------------------------------------------------------------------------- 1 | package com.xuchongyang.easylinphone; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.IntentFilter; 7 | import android.os.Bundle; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.view.SurfaceView; 10 | 11 | import com.xuchongyang.easyphone.EasyLinphone; 12 | 13 | import butterknife.BindView; 14 | import butterknife.ButterKnife; 15 | import butterknife.OnClick; 16 | 17 | public class VideoActivity extends AppCompatActivity { 18 | @BindView(R.id.video_rendering) SurfaceView mRenderingView; 19 | @BindView(R.id.video_preview) SurfaceView mPreviewView; 20 | 21 | private FinishVideoActivityReceiver mReceiver; 22 | public static final String RECEIVE_FINISH_VIDEO_ACTIVITY = "receive_finish_video_activity"; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_video); 28 | ButterKnife.bind(this); 29 | IntentFilter intentFilter = new IntentFilter(RECEIVE_FINISH_VIDEO_ACTIVITY); 30 | mReceiver = new FinishVideoActivityReceiver(); 31 | registerReceiver(mReceiver, intentFilter); 32 | EasyLinphone.setAndroidVideoWindow(new SurfaceView[]{mRenderingView}, new SurfaceView[]{mPreviewView}); 33 | } 34 | 35 | @Override 36 | protected void onResume() { 37 | super.onResume(); 38 | EasyLinphone.onResume(); 39 | } 40 | 41 | @Override 42 | protected void onPause() { 43 | super.onPause(); 44 | EasyLinphone.onPause(); 45 | } 46 | 47 | @Override 48 | protected void onDestroy() { 49 | super.onDestroy(); 50 | if (mReceiver != null) { 51 | unregisterReceiver(mReceiver); 52 | } 53 | EasyLinphone.onDestroy(); 54 | } 55 | 56 | @OnClick(R.id.video_hang) 57 | public void hang() { 58 | EasyLinphone.hangUp(); 59 | finish(); 60 | } 61 | 62 | @OnClick(R.id.video_mute) 63 | public void mute() { 64 | EasyLinphone.toggleMicro(!EasyLinphone.getLC().isMicMuted()); 65 | } 66 | 67 | @OnClick(R.id.video_speaker) 68 | public void speaker() { 69 | EasyLinphone.toggleSpeaker(!EasyLinphone.getLC().isSpeakerEnabled()); 70 | } 71 | 72 | public class FinishVideoActivityReceiver extends BroadcastReceiver { 73 | @Override 74 | public void onReceive(Context context, Intent intent) { 75 | VideoActivity.this.finish(); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 25 | 26 | 34 | 35 |