From c7f797851aadaeab49a83ce285b6c3fff2971517 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 20 八月 2021 11:03:43 +0800
Subject: [PATCH] 2021-08-20 1.优化更新
---
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLImageUtils.java | 6
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/AndroidManifest.xml | 1
Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Properties/AssemblyInfo.cs | 4
Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Jars/HDLLinphoneSDK-V1.0.1.aar | 0
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/callback/OnHDLLinphoneCallListener.java | 5
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java | 183 +++++++++--
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java | 8
/dev/null | 44 --
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java | 5
HDLLinphoneSDKDemoNew/app/src/main/res/layout/activity_main.xml | 10
HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/MainActivity.java | 104 ++++--
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/KeepAliveHandler.java | 4
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLLog.java | 42 ++
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/HDLLinphoneKit.java | 461 ++++++++++++++++++++----------
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/PhoneCallback.java | 2
HDLLinphoneSDKDemoNew/app/libs/HDLLinphoneSDK-V1.0.1.aar | 0
HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/HDLUtils.java | 2
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/RegistrationCallback.java | 2
18 files changed, 580 insertions(+), 303 deletions(-)
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/libs/liblinphone-android-sdk.aar b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/libs/liblinphone-android-sdk.aar
deleted file mode 100644
index 97bf338..0000000
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/libs/liblinphone-android-sdk.aar
+++ /dev/null
Binary files differ
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/AndroidManifest.xml b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/AndroidManifest.xml
index fa531e0..701ff46 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/AndroidManifest.xml
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/AndroidManifest.xml
@@ -13,6 +13,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/HDLLinphoneKit.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/HDLLinphoneKit.java
index c6d339b..ce44248 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/HDLLinphoneKit.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/HDLLinphoneKit.java
@@ -2,8 +2,6 @@
import android.content.Context;
import android.content.Intent;
-import android.util.Log;
-import android.view.SurfaceView;
import android.view.TextureView;
import android.widget.Toast;
@@ -12,17 +10,20 @@
import com.hdl.hdllinphonesdk.callback.OnLPOpenDoorCallBack;
import com.hdl.hdllinphonesdk.core.callback.PhoneCallback;
import com.hdl.hdllinphonesdk.core.callback.RegistrationCallback;
-import com.hdl.hdllinphonesdk.core.linphone.LinphoneUtils;
import com.hdl.hdllinphonesdk.core.service.HDLLinphoneService;
import com.hdl.hdllinphonesdk.utils.HDLLog;
+import org.linphone.core.AccountCreator;
import org.linphone.core.Address;
+import org.linphone.core.AudioDevice;
+import org.linphone.core.AuthInfo;
import org.linphone.core.Call;
import org.linphone.core.CallParams;
-import org.linphone.core.CallStats;
import org.linphone.core.Core;
import org.linphone.core.CoreException;
+import org.linphone.core.Factory;
import org.linphone.core.ProxyConfig;
+import org.linphone.core.TransportType;
import static java.lang.Thread.sleep;
@@ -31,20 +32,22 @@
*/
public class HDLLinphoneKit {
public static final String KEY_TITLE_NAME = "lpTitleName";
-
public static final String HDLLinphoneKitNAME = "HDLLinphoneKit";
private volatile static HDLLinphoneKit instance;
private Context viewContext;
private ServiceWaitThread mServiceWaitThread;
private String mUsername, mPassword, mServerIP;
- private TextureView mRenderingView, mPreviewView;
-
+// private TextureView mRenderingView, mPreviewView;
private boolean isAutoJumpCallView;//鏄惁鑷姩璺宠浆鍛煎彨椤甸潰
-
private HDLLinphoneKit() {
+
}
+ /**
+ * getInstance
+ * @return HDLLinphoneKit
+ */
public static synchronized HDLLinphoneKit getInstance() {
if (instance == null) {
synchronized (HDLLinphoneKit.class) {
@@ -57,33 +60,53 @@
}
/**
+ * 鑾峰彇 LinphoneCore
+ *
+ * @return Core
+ */
+ public Core getCore() {
+ if(!HDLLinphoneService.isReady()){
+ CheckIfNeedstartService();
+ return null;
+ }else {
+ return HDLLinphoneService.getCore();
+ }
+ }
+
+ /**
* 鍒濆鍖朙inphone
+ * @param context
*/
public void initLinphone(Context context) {
viewContext = context.getApplicationContext();
if (!HDLLinphoneService.isReady()) {
- startService(context);
- addCallback(new RegistrationCallback() {
- @Override
- public void registrationOk() {
- super.registrationOk();
- Log.e(HDLLinphoneKitNAME, "registrationOk: ");
- callBackRegistrationOk(viewContext);
-
- }
-
- @Override
- public void registrationFailed() {
- super.registrationFailed();
- Log.e(HDLLinphoneKitNAME, "registrationFailed: ");
-// Toast.makeText(LoginActivity.this, "鐧诲綍澶辫触锛�", Toast.LENGTH_SHORT).show();
- }
- }, null);
-
+ CheckIfNeedstartService();
} else {
}
+ }
+ /**
+ * startService
+ */
+ private synchronized void CheckIfNeedstartService(){
+ startService(viewContext);
+ addCallback(new RegistrationCallback() {
+ @Override
+ public void registrationOk() {
+ super.registrationOk();
+ HDLLog.e(HDLLinphoneKitNAME, "registrationOk: ");
+ callBackRegistrationOk(viewContext);
+
+ }
+
+ @Override
+ public void registrationFailed() {
+ super.registrationFailed();
+ HDLLog.e(HDLLinphoneKitNAME, "registrationFailed: ");
+// Toast.makeText(LoginActivity.this, "鐧诲綍澶辫触锛�", Toast.LENGTH_SHORT).show();
+ }
+ }, null);
}
/**
@@ -94,9 +117,15 @@
@Override
public void incomingCall(Call linphoneCall) {
super.incomingCall(linphoneCall);
+ if (linphoneCall != null) {
+ String callUsername = linphoneCall.getRemoteAddress().getUsername();
+ HDLLog.I("鏉ョ數鍙风爜锛�" + callUsername);
+// HDLLog.Log("鏉ョ數鍙风爜DisplayName锛�" + linphoneCall.getRemoteAddress().getDisplayName());
+ if (mOnHDLLinphoneCallListener != null) {
+ mOnHDLLinphoneCallListener.onIncomingCall(callUsername);
+ }
+ }
- String callUsername = linphoneCall.getRemoteAddress().getUsername();
- HDLLog.E("鏉ョ數鍙风爜锛�" + callUsername);
if (isAutoJumpCallView) {
//鏄惁闇�瑕佽嚜鍔ㄦ墦寮�鍛煎彨椤甸潰
gotoHDLLinphoneIntercomActivity();
@@ -137,38 +166,48 @@
}
/**
- * showToast
- */
- private void showToast(String text) {
- Toast.makeText(viewContext, text, Toast.LENGTH_SHORT).show();
- }
-
-
- /**
* 寮�鍚湇鍔�
*
* @param context 涓婁笅鏂�
*/
public void startService(Context context) {
- if (!HDLLinphoneService.isReady()) {
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setClass(context, HDLLinphoneService.class);
- context.startService(intent);
+ try {
+ if (!HDLLinphoneService.isReady()) {
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setClass(context, HDLLinphoneService.class);
+ context.startService(intent);
+// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+// context.startForegroundService(intent);//瑙e喅android8.0浠ヤ笂鏃犳硶鍚姩鏈嶅姟鐨勯棶棰�
+// } else {
+// context.startService(intent);
+// }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
-// /**
-// * 璁剧疆 sip 璐︽埛淇℃伅
-// *
-// * @param username sip 璐︽埛
-// * @param password 瀵嗙爜
-// * @param serverIP sip 鏈嶅姟鍣�
-// */
-// public void setAccount(String username, String password, String serverIP) {
-// mUsername = username;
-// mPassword = password;
-// mServerIP = serverIP;
-// }
+ /**
+ * onResume
+ */
+ public void onResume() {
+
+ }
+
+ /**
+ * onPause
+ */
+ public void onPause() {
+
+ }
+
+ /**
+ * onDestroy
+ */
+ public void onDestroy() {
+ removePreviewWindow();
+ removeVideoWindow();
+ }
/**
* 璁剧疆 sip 璐︽埛淇℃伅
@@ -222,6 +261,7 @@
/**
* 閫�鍑烘竻绌鸿处鍙�
+ * enableRegister false
*/
public void logout() {
try {
@@ -235,63 +275,29 @@
config.done();
}
}
- core.clearAllAuthInfo();
- core.clearProxyConfig();
+ core.clearAllAuthInfo();//娓呴櫎鎵�鏈夎璇佷俊鎭��
+
+// core.clearProxyConfig();//浠庨厤缃腑鍒犻櫎鎵�鏈変唬鐞嗐�傛敞鎰忥細鐩墠涓嶈兘鐩存帴鍒犳墍鏈変唬鐞嗭紝鍥犱负鏈嶅姟鍣ㄤ笂杩樻槸鏍囪宸叉敞鍐�
}
} catch (Exception e) {
e.printStackTrace();
}
}
-
/**
- * 鍛煎彨鎸囧畾鍙风爜
- *
- * @param num 鍛煎彨鍙风爜
+ * 娓呴櫎閰嶇疆琛�, 鍒囨崲璐﹀彿鏃朵細鐢ㄥ埌
*/
- public void callTo(String num, boolean isVideoCall) {
- LinphoneUtils.getInstance().callTo(num, isVideoCall);
+ public void clearProxyConfig(){
+ Core core = HDLLinphoneService.getCore();
+ if (core != null) {
+ core.clearAllAuthInfo();//娓呴櫎鎵�鏈夎璇佷俊鎭��
+ core.clearProxyConfig();//浠庨厤缃腑鍒犻櫎鎵�鏈変唬鐞嗐��
+ }
}
/**
- * 鎺ュ惉鏉ョ數
+ * ServiceWaitThread
*/
- public void acceptCall() {
- LinphoneUtils.getInstance().acceptCall();
- }
-
-// /**
-// * 鎺ュ惉鏉ョ數
-// */
-// public void acceptCallWithVideo(boolean enableVideo) {
-// LinphoneUtils.getInstance().acceptCallWithVideo(enableVideo);
-// }
-
- /**
- * 鎸傛柇褰撳墠閫氳瘽
- */
- public void hangUp() {
- LinphoneUtils.getInstance().hangUp();
- }
-
- /**
- * 鍒囨崲闈欓煶
- *
- * @param isMicMuted 鏄惁闈欓煶
- */
- public void toggleMicro(boolean isMicMuted) {
- LinphoneUtils.getInstance().toggleMicro(isMicMuted);
- }
-
- /**
- * 鍒囨崲鍏嶆彁
- *
- * @param isSpeakerEnabled 鏄惁鍏嶆彁
- */
- public void toggleSpeaker(boolean isSpeakerEnabled) {
- LinphoneUtils.getInstance().toggleSpeaker(isSpeakerEnabled);
- }
-
private class ServiceWaitThread extends Thread {
private PhoneCallback mPhoneCallback;
private RegistrationCallback mRegistrationCallback;
@@ -325,83 +331,203 @@
if (mUsername == null || mPassword == null || mServerIP == null) {
throw new RuntimeException("The sip account is not configured.");
}
- LinphoneUtils.getInstance().registerUserAuth(mUsername, mPassword, mServerIP);
+ registerUserAuth(mUsername, mPassword, mServerIP);
} catch (CoreException e) {
e.printStackTrace();
}
}
+ /**
+ * 鎻愪氦璐﹀彿鍜屽瘑鐮佹敞鍐屽埌鏈嶅姟鍣�
+ *
+ * @param name
+ * @param password
+ * @param host
+ * @throws CoreException
+ */
+ public void registerUserAuth(String name, String password, String host) throws CoreException {
+ Core mLinphoneCore = HDLLinphoneService.getCore();
+ if(mLinphoneCore == null) return;
-// public static boolean getVideoEnabled() {
-// CallParams remoteParams = HDLLinphoneService.getCore().getCurrentCall().getRemoteParams();
-// return remoteParams != null && remoteParams.videoEnabled();
-// }
+ AuthInfo authInfo = Factory.instance().createAuthInfo(name, null, password,
+ null, null, host);
+
+ AccountCreator mAccountCreator = mLinphoneCore.createAccountCreator(null);
+ mAccountCreator.setUsername(name);
+ mAccountCreator.setDomain(host);
+ mAccountCreator.setPassword(password);
+ mAccountCreator.setTransport(TransportType.Udp);
+ ProxyConfig prxCfg = mAccountCreator.createProxyConfig();
+
+ prxCfg.enableQualityReporting(false);
+ prxCfg.setQualityReportingCollector(null);
+ prxCfg.setQualityReportingInterval(0);
+ prxCfg.enableRegister(true);
+ mLinphoneCore.addProxyConfig(prxCfg);//娣诲姞浠g悊閰嶇疆銆傚鏋滃惎鐢ㄤ簡娉ㄥ唽锛岃繖灏嗗紑濮嬪湪浠g悊涓婃敞鍐屻��
+ mLinphoneCore.addAuthInfo(authInfo);//娣诲姞璁よ瘉淇℃伅鍒�,璇ヤ俊鎭墖娈靛皢鍦ㄦ墍鏈夐渶瑕佺殑SIP浜嬪姟涓娇鐢ㄨ韩浠介獙璇�
+ mLinphoneCore.setDefaultProxyConfig(prxCfg);//璁剧疆榛樿浠g悊銆�
+ }
/**
- * 璁剧疆 SurfaceView
+ * 鍛煎彨
+ */
+ public Call startSingleCallingTo(String userName, boolean isVideoCall) {
+ Core mLinphoneCore = HDLLinphoneService.getCore();
+ if(mLinphoneCore == null) return null;
+
+ Call call = null;
+ Core core = HDLLinphoneService.getCore();
+ if(core != null) {
+ Address addressToCall = core.interpretUrl(userName);
+ CallParams params = core.createCallParams(null);
+
+ if (isVideoCall) {
+ params.enableVideo(true);
+ params.enableLowBandwidth(false);
+ } else {
+ params.enableVideo(false);
+ }
+
+ if (addressToCall != null) {
+ call = core.inviteAddressWithParams(addressToCall, params);
+ }
+ }
+ return call;
+ }
+
+ /**
+ * 鍛煎彨鎸囧畾鍙风爜
+ *
+ * @param num 鍛煎彨鍙风爜
+ */
+ public void callTo(String num, boolean isVideoCall) {
+ if (!HDLLinphoneService.isReady() || !HDLLinphoneService.getCoreIsNotNull()) {
+ return;
+ }
+ if (!num.equals("")) {
+ startSingleCallingTo(num, isVideoCall);
+ }
+ }
+
+ /**
+ * 鎺ュ惉鏉ョ數
+ */
+ public void acceptCall() {
+ try {
+ if(HDLLinphoneService.getCore() == null) return;
+ Call currentCall = HDLLinphoneService.getCore().getCurrentCall();
+ CallParams params = HDLLinphoneService.getCore().createCallParams(currentCall);
+ params.enableVideo(true);
+ currentCall.acceptWithParams(params);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 鎺ュ惉鏉ョ數
+ */
+ public void acceptCallWithVideo(boolean enableVideo) {
+ try {
+ if(HDLLinphoneService.getCore() == null) return;
+ Call currentCall = HDLLinphoneService.getCore().getCurrentCall();
+ CallParams params = HDLLinphoneService.getCore().createCallParams(currentCall);
+ params.enableVideo(enableVideo);
+ currentCall.acceptWithParams(params);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 鎸傛柇鐢佃瘽
+ */
+ public void hangUp() {
+ Core mLinphoneCore = HDLLinphoneService.getCore();
+ if(mLinphoneCore == null) return;
+ Call currentCall = mLinphoneCore.getCurrentCall();
+ if (currentCall != null) {
+// mLinphoneCore.terminateCall(currentCall);
+ mLinphoneCore.terminateAllCalls();
+ } else if (mLinphoneCore.isInConference()) {
+ mLinphoneCore.terminateConference();
+ } else {
+ mLinphoneCore.terminateAllCalls();
+ }
+ }
+
+ /**
+ * 鏄惁闈欓煶
+ *
+ * @param isMicMuted
+ */
+ public void toggleMicro(boolean isMicMuted) {
+ Core mLinphoneCore = HDLLinphoneService.getCore();
+ if(mLinphoneCore == null) return;
+ mLinphoneCore.enableMic(!isMicMuted);
+ }
+
+ /**
+ * 鏄惁澶栨斁
+ *
+ * @param isSpeakerEnabled
+ */
+ public void toggleSpeaker(boolean isSpeakerEnabled) {
+ routeAudioToSpeakerHelper(isSpeakerEnabled);
+ }
+
+ /**
+ * 璁剧疆澶栨斁璁惧
+ */
+ private void routeAudioToSpeakerHelper(boolean speakerOn) {
+ org.linphone.core.tools.Log.w("[Audio Manager] Routing audio to " + (speakerOn ? "speaker" : "earpiece"));
+ try {
+ if(HDLLinphoneService.getCore() == null) return;
+ if (HDLLinphoneService.getCore().getCallsNb() == 0) return;
+ Call currentCall = HDLLinphoneService.getCore().getCurrentCall();
+ if (currentCall == null) currentCall = HDLLinphoneService.getCore().getCalls()[0];
+ if (currentCall == null) return;
+
+ for (AudioDevice audioDevice : HDLLinphoneService.getCore().getAudioDevices()) {
+ if (speakerOn && audioDevice.getType() == AudioDevice.Type.Speaker) {
+ currentCall.setOutputAudioDevice(audioDevice);
+ return;
+ } else if (!speakerOn && audioDevice.getType() == AudioDevice.Type.Earpiece) {
+ currentCall.setOutputAudioDevice(audioDevice);
+ return;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 璁剧疆 TextureView
*
* @param renderingView 杩滅▼ TextureView
* @param previewView 鏈湴 TextureView
*/
public void setAndroidVideoWindow(final TextureView renderingView, final TextureView previewView) {
- mRenderingView = renderingView;
- mPreviewView = previewView;
+// mRenderingView = renderingView;
+// mPreviewView = previewView;
setVideoWindow(renderingView);
setPreviewWindow(previewView);
}
/**
- * onResume
+ * 璁剧疆鎾斁View
+ * @param o
*/
- public void onResume() {
-// if (mRenderingView != null) {
-// ((TextureView) mRenderingView).onResume();
-// }
-
-// if (mAndroidVideoWindow != null) {
-// synchronized (mAndroidVideoWindow) {
-// LinphoneManager.getLc().setNativeVideoWindowId(mAndroidVideoWindow);
-// }
-// }
- }
-
- /**
- * onPause
- */
- public void onPause() {
-// if (mAndroidVideoWindow != null) {
-// synchronized (mAndroidVideoWindow) {
-// LinphoneManager.getLc().setNativeVideoWindowId(null);
-// }
-// }
-//
-// if (mRenderingView != null) {
-// ((GLSurfaceView) mRenderingView).onPause();
-// }
- }
-
- /**
- * onDestroy
- */
- public void onDestroy() {
- mPreviewView = null;
- mRenderingView = null;
-
- }
-
-// private void fixZOrder(SurfaceView rendering, SurfaceView preview) {
-// rendering.setZOrderOnTop(false);
-// preview.setZOrderOnTop(true);
-// preview.setZOrderMediaOverlay(true); // Needed to be able to display control layout over
-// }
-
private void setVideoWindow(Object o) {
Core linphoneCore = HDLLinphoneService.getCore();
if (linphoneCore != null) {
linphoneCore.setNativeVideoWindowId(o);
}
}
-
+ /**
+ * 绉婚櫎鎾斁View
+ */
private void removeVideoWindow() {
Core linphoneCore = HDLLinphoneService.getCore();
if (linphoneCore != null) {
@@ -409,28 +535,25 @@
}
}
+ /**
+ * 璁剧疆鏈満鎽勫儚澶撮噰闆嗙殑View
+ * @param o
+ */
private void setPreviewWindow(Object o) {
Core linphoneCore = HDLLinphoneService.getCore();
if (linphoneCore != null) {
linphoneCore.setNativePreviewWindowId(o);
}
}
-
+ /**
+ * 绉婚櫎瑙嗛閲囬泦View
+ */
private void removePreviewWindow() {
Core linphoneCore = HDLLinphoneService.getCore();
if (linphoneCore != null) {
linphoneCore.setNativePreviewWindowId(null);
}
}
-
-// /**
-// * 鑾峰彇 LinphoneCore
-// *
-// * @return LinphoneCore
-// */
-// public Core getLC() {
-// return HDLLinphoneService.getCore();
-// }
/**
* 鑾峰彇褰撳墠閫氳瘽鐘舵��
@@ -452,6 +575,11 @@
public boolean isAutoJumpCallView() {
return isAutoJumpCallView;
}
+
+ /**
+ * 璁剧疆鏄惁鑷姩璺宠浆鍛煎彨椤甸潰鏍囧織
+ * @param autoJumpCallView
+ */
public void setAutoJumpCallView(boolean autoJumpCallView) {
isAutoJumpCallView = autoJumpCallView;
}
@@ -491,12 +619,27 @@
*/
private OnHDLLinphoneCallListener mOnHDLLinphoneCallListener;
+ /**
+ * 鑾峰彇onHDLLinphoneCallListener
+ * 鎺ュ惉銆佹寕鏂�佸紑閿佺瓑 Listener瀹炵幇
+ * @return OnHDLLinphoneCallListener
+ */
public OnHDLLinphoneCallListener getOnHDLLinphoneCallListener() {
return mOnHDLLinphoneCallListener;
}
+ /**
+ * 璁剧疆onHDLLinphoneCallListener
+ * @param onHDLLinphoneCallListener
+ */
public void setOnHDLLinphoneCallListener(OnHDLLinphoneCallListener onHDLLinphoneCallListener) {
mOnHDLLinphoneCallListener = onHDLLinphoneCallListener;
}
+ /**
+ * showToast
+ */
+ private void showToast(String text) {
+ Toast.makeText(viewContext, text, Toast.LENGTH_SHORT).show();
+ }
}
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java
index a174b8b..fc949ce 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java
@@ -26,6 +26,7 @@
import com.hdl.hdllinphonesdk.callback.OnLPOpenDoorCallBack;
import com.hdl.hdllinphonesdk.R;
import com.hdl.hdllinphonesdk.utils.HDLImageUtils;
+import com.hdl.hdllinphonesdk.utils.HDLLog;
/**
* Linphone鎺ュ惉椤甸潰
@@ -97,7 +98,7 @@
}
HDLLinphoneKit.getInstance().onDestroy();
- Log.i(TAG,"onDestroy");
+ HDLLog.i(TAG,"onDestroy");
}
@@ -263,7 +264,7 @@
if (isAnswer) {
//濡傛灉涔嬪墠宸茬粡鎺ュ惉浜嗭紝鍥炶皟鏄寕鏂�
callTime = getTimerCallTime();
- Log.i("callTime","callTime"+callTime);
+ HDLLog.i("callTime","callTime"+callTime);
HDLLinphoneKit.getInstance().getOnHDLLinphoneCallListener().onHangUpAction(callTime);
} else {
//濡傛灉涔嬪墠娌℃帴鍚簡锛屽洖璋冩槸鎷掓帴
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java
index cefa1be..a5c8cb3 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java
@@ -25,6 +25,7 @@
import com.hdl.hdllinphonesdk.R;
import com.hdl.hdllinphonesdk.callback.OnLPOpenDoorCallBack;
import com.hdl.hdllinphonesdk.utils.HDLImageUtils;
+import com.hdl.hdllinphonesdk.utils.HDLLog;
/**
*鐩戣椤甸潰
@@ -83,7 +84,7 @@
}
HDLLinphoneKit.getInstance().onDestroy();
- Log.i(TAG,"onDestroy");
+ HDLLog.i(TAG,"onDestroy");
}
@@ -293,14 +294,15 @@
HDLLinphoneKit.getInstance().setAndroidVideoWindow(video_lp_rendering, video_lp_rendering2);
}
-
+ /**
+ * 椤甸潰鍏抽棴骞挎挱鐩戝惉
+ */
public class FinishVideoActivityReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
HDLLinphoneMonitorActivity.this.finish();
}
}
-
private HDLLinphoneMonitorActivity.FinishVideoActivityReceiver mReceiver;
public static final String RECEIVE_FINISH_VIDEO_ACTIVITY = "receive_finish_video_activity";
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/callback/OnHDLLinphoneCallListener.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/callback/OnHDLLinphoneCallListener.java
index 584d059..10ca1db 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/callback/OnHDLLinphoneCallListener.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/callback/OnHDLLinphoneCallListener.java
@@ -27,6 +27,9 @@
*/
void onScreenshotSuccessfulAction(Bitmap image);
-
+ /**
+ * 鏉ョ數涓�
+ */
+ void onIncomingCall(String username);
}
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/PhoneCallback.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/PhoneCallback.java
index fa60b94..62fe585 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/PhoneCallback.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/PhoneCallback.java
@@ -3,7 +3,7 @@
import org.linphone.core.Call;
/**
- * 鐘舵�佸洖璋�
+ * 閫氳瘽鐘舵�佸洖璋�
*/
public abstract class PhoneCallback {
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/RegistrationCallback.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/RegistrationCallback.java
index ca1cfb8..714fbb7 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/RegistrationCallback.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/RegistrationCallback.java
@@ -1,7 +1,7 @@
package com.hdl.hdllinphonesdk.core.callback;
/**
- * RegistrationCallback
+ * 娉ㄥ唽鐘舵�佸洖璋�
*/
public abstract class RegistrationCallback {
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/KeepAliveHandler.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/KeepAliveHandler.java
index 90f243f..c62cb31 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/KeepAliveHandler.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/KeepAliveHandler.java
@@ -6,7 +6,7 @@
import android.util.Log;
import com.hdl.hdllinphonesdk.core.service.HDLLinphoneService;
-
+import com.hdl.hdllinphonesdk.utils.HDLLog;
/**
* KeepAliveHandler
@@ -22,7 +22,7 @@
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
- Log.e(TAG, "Cannot sleep for 2s");
+ HDLLog.e(TAG, "Cannot sleep for 2s");
}
}
}
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/LinphoneManager.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/LinphoneManager.java
deleted file mode 100644
index a12c316..0000000
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/LinphoneManager.java
+++ /dev/null
@@ -1,593 +0,0 @@
-//package com.hdl.hdllinphonesdk.core.linphone;
-//
-//import android.content.Context;
-//import android.content.pm.PackageManager;
-//import android.os.Handler;
-//import android.os.Looper;
-//
-//
-//import com.hdl.hdllinphonesdk.HDLLinphoneKit;
-//import com.hdl.hdllinphonesdk.R;
-//
-//
-//import org.linphone.core.AudioDevice;
-//import org.linphone.core.AuthInfo;
-//import org.linphone.core.AuthMethod;
-//import org.linphone.core.Call;
-//import org.linphone.core.CallLog;
-//import org.linphone.core.CallStats;
-//import org.linphone.core.ChatMessage;
-//import org.linphone.core.ChatRoom;
-//import org.linphone.core.Conference;
-//import org.linphone.core.ConfiguringState;
-//import org.linphone.core.Content;
-//import org.linphone.core.Core;
-//import org.linphone.core.CoreException;
-//import org.linphone.core.CoreListener;
-//import org.linphone.core.EcCalibratorStatus;
-//import org.linphone.core.Event;
-//import org.linphone.core.Factory;
-//import org.linphone.core.Friend;
-//import org.linphone.core.FriendList;
-//import org.linphone.core.GlobalState;
-//import org.linphone.core.InfoMessage;
-//import org.linphone.core.PayloadType;
-//import org.linphone.core.PresenceModel;
-//import org.linphone.core.ProxyConfig;
-//import org.linphone.core.PublishState;
-//import org.linphone.core.RegistrationState;
-//import org.linphone.core.SubscriptionState;
-//import org.linphone.core.ToneID;
-//import org.linphone.core.VersionUpdateCheckResult;
-//import org.linphone.core.VideoActivationPolicy;
-//import org.linphone.core.VideoDefinition;
-//import org.linphone.core.tools.Log;
-//
-//import java.io.File;
-//import java.io.IOException;
-//import java.nio.ByteBuffer;
-//import java.util.Timer;
-//import java.util.TimerTask;
-//
-//import static com.hdl.hdllinphonesdk.HDLLinphoneKit.HDLLinphoneKitNAME;
-//
-///**
-// * Linphone 绠$悊鍣�
-// */
-//
-//public class LinphoneManager implements CoreListener {
-// private static final String TAG = "LinphoneManager";
-// private static LinphoneManager instance;
-// private Context mServiceContext;
-// private Core mLc;
-// private Timer mTimer;
-// private static boolean sExited;
-//
-// private String mLPConfigXsd = null;
-// private String mLinphoneFactoryConfigFile = null;
-// public String mLinphoneConfigFile = null;
-// private String mLinphoneRootCaFile = null;
-// private String mRingSoundFile = null;
-// private String mRingBackSoundFile = null;
-// private String mPauseSoundFile = null;
-// private String mChatDatabaseFile = null;
-//
-//
-//// private String mErrorToneFile = null;
-//
-// public LinphoneManager(Context serviceContext) {
-// mServiceContext = serviceContext;
-// Factory.instance().setDebugMode(true, HDLLinphoneKitNAME);
-// sExited = false;
-//
-// String basePath = mServiceContext.getFilesDir().getAbsolutePath();
-// mLPConfigXsd = basePath + "/lpconfig.xsd";
-// mLinphoneFactoryConfigFile = basePath + "/linphonerc";
-// mLinphoneConfigFile = basePath + "/.linphonerc";
-// mLinphoneRootCaFile = basePath + "/rootca.pem";
-// mRingSoundFile = basePath + "/oldphone_mono.wav";
-// mRingBackSoundFile = basePath + "/ringback.wav";
-// mPauseSoundFile = basePath + "/toy_mono.wav";
-// mChatDatabaseFile = basePath + "/linphone-history.db";
-//// mErrorToneFile = basePath + "/error.wav";
-// }
-//
-// public synchronized static final LinphoneManager createAndStart(Context context) {
-// if (instance != null) {
-// throw new RuntimeException("Linphone Manager is already initialized");
-// }
-// instance = new LinphoneManager(context);
-// instance.startLibLinphone(context);
-// return instance;
-// }
-//
-// public static synchronized Core getLcIfManagerNotDestroyOrNull() {
-// if (sExited || instance == null) {
-// Log.e("Trying to get linphone core while LinphoneManager already destroyed or not created");
-// return null;
-// }
-// return getLc();
-// }
-//
-// public static final boolean isInstanceiated() {
-// return instance != null;
-// }
-//
-// public static synchronized final Core getLc() {
-// return getInstance().mLc;
-// }
-//
-// public static synchronized final LinphoneManager getInstance() {
-// if (instance != null) {
-// return instance;
-// }
-// if (sExited) {
-// throw new RuntimeException("Linphone Manager was already destroyed. "
-// + "Better use getLcIfManagerNotDestroyed and check returned value");
-// }
-// throw new RuntimeException("Linphone Manager should be created before accessed");
-// }
-//
-// private synchronized void startLibLinphone(Context context) {
-// try {
-// copyAssetsFromPackage();
-//// mLc = Factory.instance().createCore(this, mLinphoneConfigFile,
-//// mLinphoneFactoryConfigFile, null, context);
-// mLc = Factory.instance().createCore( mLinphoneConfigFile,
-// mLinphoneFactoryConfigFile, context);
-// mLc.addListener((CoreListener)context);
-//
-// try {
-// initLibLinphone();
-// } catch (CoreException e) {
-// Log.e(e);
-// }
-//
-// TimerTask task = new TimerTask() {
-// @Override
-// public void run() {
-// new Handler(Looper.getMainLooper()).post(new Runnable() {
-// @Override
-// public void run() {
-// if (mLc != null) {
-// mLc.iterate();
-// }
-// }
-// });
-// }
-// };
-// mTimer = new Timer("Linphone Scheduler");
-// mTimer.schedule(task, 0, 20);
-// } catch (Exception e) {
-// e.printStackTrace();
-// Log.e(TAG, "startLibLinphone: cannot start linphone");
-// }
-// }
-//
-// private synchronized void initLibLinphone() throws CoreException {
-//// mLc.setContext(mServiceContext);
-// setUserAgent();
-// mLc.setRemoteRingbackTone(mRingSoundFile);
-// mLc.setTone(ToneID.CallWaiting, mRingSoundFile);
-// mLc.setRing(mRingSoundFile);
-//// mLc.setRootCA(mLinphoneRootCaFile);
-// mLc.setPlayFile(mPauseSoundFile);
-//// mLc.setChatDatabasePath(mChatDatabaseFile);
-// mLc.enableIpv6(true);
-// mLc.enableDnsSrv(true);
-//// mLc.setCallErrorTone(Reason.NotFound, mErrorToneFile);//璁剧疆鍛煎彨閿欒鎾斁鐨勯搩澹�
-//
-// setBackCamAsDefault();
-//
-// int availableCores = Runtime.getRuntime().availableProcessors();
-// Log.w(TAG, "MediaStreamer : " + availableCores + " cores detected and configured");
-//// mLc.setCpuCount(availableCores);
-//
-// int migrationResult = getLc().migrateToMultiTransport();
-// Log.d(TAG, "Migration to multi transport result = " + migrationResult);
-//
-// mLc.setNetworkReachable(true);
-//
-// //鍥炲0娑堥櫎
-//// boolean isEchoCancellation = (boolean) SPUtils.get(mServiceContext, "echo_cancellation", true);
-// mLc.enableEchoCancellation(true);
-// //鑷�傚簲鐮佺巼鎺у埗
-//// boolean isAdaptiveRateControl = (boolean) SPUtils.get(mServiceContext, "adaptive_rate_control", true);
-// mLc.enableAdaptiveRateControl(true);
-//
-// //audio 鐮佺巼璁剧疆
-// LinphoneUtils.getConfig(mServiceContext).setInt("audio", "codec_bitrate_limit", 36);
-//
-//// mLc.setPreferredVideoSizeByName("qvga");
-//
-// VideoDefinition preferredVideoDefinition =
-// Factory.instance().createVideoDefinitionFromName("qvga");
-// getLc().setPreferredVideoDefinition(preferredVideoDefinition);
-//
-// mLc.setUploadBandwidth(1536);
-// mLc.setDownloadBandwidth(1536);
-// mLc.setVideoPreset("custom");
-//
-//// mLc.setVideoPolicy(mLc.getVideoAutoInitiatePolicy(), true);
-//// mLc.setVideoPolicy(true, mLc.getVideoAutoAcceptPolicy());
-//// mLc.enableVideo(true, true);
-//// mLc.enableDownloadOpenH264(true);
-//
-// mLc.enableVideoCapture(true);
-// mLc.enableVideoDisplay(true);
-// mLc.getConfig().setBool("app", "open_h264_download_enabled", true);
-// VideoActivationPolicy vap = getLc().getVideoActivationPolicy();
-// vap.setAutomaticallyInitiate(true);
-// mLc.setVideoActivationPolicy(vap);
-//
-// // 璁剧疆缂栫爜鏍煎紡
-// setCodecMime();
-//
-//// IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
-//// filter.addAction(Intent.ACTION_SCREEN_OFF);
-//// mServiceContext.registerReceiver(mKeepAliveReceiver, filter);
-// }
-//
-// private void setCodecMime() {
-//// for (PayloadType payloadType : mLc.getAudioCodecs()) {
-//// try {
-//// mLc.enablePayloadType(payloadType, true);
-//// } catch (CoreException e) {
-//// e.printStackTrace();
-//// }
-////// android.util.Log.e(TAG, "setCodecMime = " + payloadType.getMime() + " Rate " + payloadType.getRate() + " receviceFmtp " + payloadType.getRecvFmtp());
-////// if (payloadType.getMime().equals("PCMA") && payloadType.getRate() == 8000) {
-////// try {
-////// android.util.Log.e(TAG, "setCodecMime: " + payloadType.getMime() + " " + payloadType.getRate());
-////// mLc.enablePayloadType(payloadType, true);
-////// } catch (CoreException e) {
-////// android.util.Log.e(TAG, "setCodecMime: " + e);
-////// }
-////// } else {
-////// try {
-////// mLc.enablePayloadType(payloadType, false);
-////// } catch (CoreException e) {
-////// e.printStackTrace();
-////// }
-////// }
-//// }
-//// for (PayloadType payloadType : mLc.getVideoCodecs()) {
-//// try {
-//// android.util.Log.e(TAG, "setCodecMime: mime: " + payloadType.getMime() + " rate: " + payloadType.getRate());
-//// mLc.enablePayloadType(payloadType, true);
-//// } catch (CoreException e) {
-//// e.printStackTrace();
-//// }
-//// }
-//
-// PayloadType[] ptList = mLc.getAudioPayloadTypes();
-// for (PayloadType pt : ptList) {
-//
-// org.linphone.mediastream.Log.d("payloadaudio",pt.getMimeType());
-// if (pt.getMimeType().equals("PCMA") && pt.getClockRate() == 8000) {
-// pt.enable(true);
-//
-// } else {
-// pt.enable(false);
-// }
-// }
-// mLc.setAudioPayloadTypes(ptList);
-//
-// PayloadType[] ptVideoList = mLc.getVideoPayloadTypes();
-// for (PayloadType pt : ptVideoList) {
-// pt.enable(true);
-// }
-// mLc.setVideoPayloadTypes(ptVideoList);
-// }
-//
-// private void copyAssetsFromPackage() throws IOException {
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.oldphone_mono, mRingSoundFile);
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.ringback, mRingBackSoundFile);
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.toy_mono, mPauseSoundFile);
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.linphonerc_default, mLinphoneConfigFile);
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.linphonerc_factory, new File(mLinphoneFactoryConfigFile).getName());
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.lpconfig, mLPConfigXsd);
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.rootca, mLinphoneRootCaFile);
-// }
-//
-// private void setUserAgent() {
-// try {
-// String versionName = mServiceContext.getPackageManager().getPackageInfo(mServiceContext.getPackageName(),
-// 0).versionName;
-// if (versionName == null) {
-// versionName = String.valueOf(mServiceContext.getPackageManager().getPackageInfo(mServiceContext.getPackageName(), 0).versionCode);
-// }
-// mLc.setUserAgent(HDLLinphoneKitNAME, versionName);
-// } catch (PackageManager.NameNotFoundException e) {
-// e.printStackTrace();
-// }
-// }
-//
-// public static synchronized void destroy() {
-// if (instance == null) {
-// return;
-// }
-// sExited = true;
-// instance.doDestroy();
-// }
-//
-// private void doDestroy() {
-// try {
-// mTimer.cancel();
-// mLc.stop();
-// } catch (RuntimeException e) {
-// e.printStackTrace();
-// } finally {
-// mLc = null;
-// instance = null;
-// }
-// }
-//
-//
-// private void setBackCamAsDefault() {
-//// int camId = 0;
-//// AndroidCameraConfiguration.AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
-//// for (AndroidCameraConfiguration.AndroidCamera androidCamera :
-//// cameras) {
-//// if (!androidCamera.frontFacing) {
-//// camId = androidCamera.id;
-//// }
-//// }
-//// android.util.Log.e(TAG, "setBackCamAsDefault: cameraId is " + camId);
-//// mLc.setVideoDevice(0);
-// }
-//
-// @Override
-// public void onQrcodeFound(Core core, String result) {
-//
-// }
-//
-// @Override
-// public void onInfoReceived(Core core, Call call, InfoMessage message) {
-//
-// }
-//
-// @Override
-// public void onTransferStateChanged(Core core, Call transfered, Call.State callState) {
-//
-// }
-//
-// @Override
-// public void onCallEncryptionChanged(Core core, Call call, boolean mediaEncryptionEnabled, String authenticationToken) {
-//
-// }
-//
-// @Override
-// public void onEcCalibrationAudioInit(Core core) {
-//
-// }
-//
-// @Override
-// public void onDtmfReceived(Core core, Call call, int dtmf) {
-//
-// }
-//
-// @Override
-// public void onChatRoomStateChanged(Core core, ChatRoom chatRoom, ChatRoom.State state) {
-//
-// }
-//
-// @Override
-// public void onLogCollectionUploadStateChanged(Core core, Core.LogCollectionUploadState state, String info) {
-//
-// }
-//
-// @Override
-// public void onAudioDevicesListUpdated(Core core) {
-//
-// }
-//
-// @Override
-// public void onCallIdUpdated(Core core, String previousCallId, String currentCallId) {
-//
-// }
-//
-// @Override
-// public void onMessageSent(Core core, ChatRoom chatRoom, ChatMessage message) {
-//
-// }
-//
-// @Override
-// public void onFriendListRemoved(Core core, FriendList friendList) {
-//
-// }
-//
-// @Override
-// public void onSubscribeReceived(Core core, Event linphoneEvent, String subscribeEvent, Content body) {
-//
-// }
-//
-// @Override
-// public void onAuthenticationRequested(Core core, AuthInfo authInfo, AuthMethod method) {
-//
-// }
-//
-// @Override
-// public void onEcCalibrationAudioUninit(Core core) {
-//
-// }
-//
-// @Override
-// public void onLogCollectionUploadProgressIndication(Core core, int offset, int total) {
-//
-// }
-//
-// @Override
-// public void onImeeUserRegistration(Core core, boolean status, String userId, String info) {
-//
-// }
-//
-// @Override
-// public void onRegistrationStateChanged(Core core, ProxyConfig proxyConfig, RegistrationState state, String message) {
-//
-// }
-//
-// @Override
-// public void onCallStateChanged(Core core, Call call, Call.State state, String message) {
-//
-// }
-//
-// @Override
-// public void onConfiguringStatus(Core core, ConfiguringState status, String message) {
-//
-// }
-//
-// @Override
-// public void onGlobalStateChanged(Core core, GlobalState state, String message) {
-//
-// }
-//
-// @Override
-// public void onChatRoomEphemeralMessageDeleted(Core core, ChatRoom chatRoom) {
-//
-// }
-//
-// @Override
-// public void onFriendListCreated(Core core, FriendList friendList) {
-//
-// }
-//
-// @Override
-// public void onBuddyInfoUpdated(Core core, Friend linphoneFriend) {
-//
-// }
-//
-// @Override
-// public void onChatRoomSubjectChanged(Core core, ChatRoom chatRoom) {
-//
-// }
-//
-// @Override
-// public void onNotifyReceived(Core core, Event linphoneEvent, String notifiedEvent, Content body) {
-//
-// }
-//
-// @Override
-// public void onLastCallEnded(Core core) {
-//
-// }
-//
-// @Override
-// public void onChatRoomRead(Core core, ChatRoom chatRoom) {
-//
-// }
-//
-// @Override
-// public void onNotifyPresenceReceived(Core core, Friend linphoneFriend) {
-//
-// }
-//
-// @Override
-// public void onConferenceStateChanged(Core core, Conference conference, Conference.State state) {
-//
-// }
-//
-// @Override
-// public void onVersionUpdateCheckResultReceived(Core core, VersionUpdateCheckResult result, String version, String url) {
-//
-// }
-//
-// @Override
-// public void onMessageReceived(Core core, ChatRoom chatRoom, ChatMessage message) {
-//
-// }
-//
-// @Override
-// public void onCallStatsUpdated(Core core, Call call, CallStats callStats) {
-//
-// }
-//
-// @Override
-// public void onFirstCallStarted(Core core) {
-//
-// }
-//
-// @Override
-// public void onSubscriptionStateChanged(Core core, Event linphoneEvent, SubscriptionState state) {
-//
-// }
-//
-// @Override
-// public void onMessageReceivedUnableDecrypt(Core core, ChatRoom chatRoom, ChatMessage message) {
-//
-// }
-//
-// @Override
-// public void onEcCalibrationResult(Core core, EcCalibratorStatus status, int delayMs) {
-//
-// }
-//
-// @Override
-// public void onIsComposingReceived(Core core, ChatRoom chatRoom) {
-//
-// }
-//
-// @Override
-// public void onReferReceived(Core core, String referTo) {
-//
-// }
-//
-// @Override
-// public void onNetworkReachable(Core core, boolean reachable) {
-//
-// }
-//
-// @Override
-// public void onPublishStateChanged(Core core, Event linphoneEvent, PublishState state) {
-//
-// }
-//
-// @Override
-// public void onAudioDeviceChanged(Core core, AudioDevice audioDevice) {
-//
-// }
-//
-// @Override
-// public void onCallLogUpdated(Core core, CallLog callLog) {
-//
-// }
-//
-// @Override
-// public void onCallCreated(Core core, Call call) {
-//
-// }
-//
-// @Override
-// public void onNotifyPresenceReceivedForUriOrTel(Core core, Friend linphoneFriend, String uriOrTel, PresenceModel presenceModel) {
-//
-// }
-//
-// @Override
-// public void onNewSubscriptionRequested(Core core, Friend linphoneFriend, String url) {
-//
-// }
-//
-//// public void resetCameraFromPreferences(boolean useFrontCam) {
-//// Core core = getCore();
-//// if (core == null) return;
-////
-////
-//// String firstDevice = null;
-//// for (String camera : core.getVideoDevicesList()) {
-//// if (firstDevice == null) {
-//// firstDevice = camera;
-//// }
-////
-//// if (useFrontCam) {
-//// if (camera.contains("Front")) {
-//// Log.i("[Manager] Found front facing camera: " + camera);
-//// core.setVideoDevice(camera);
-//// return;
-//// }
-//// }
-//// }
-////
-//// Log.i("[Manager] Using first camera available: " + firstDevice);
-//// core.setVideoDevice(firstDevice);
-//// }
-//}
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/LinphoneUtils.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/LinphoneUtils.java
deleted file mode 100644
index 62df14b..0000000
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/LinphoneUtils.java
+++ /dev/null
@@ -1,267 +0,0 @@
-package com.hdl.hdllinphonesdk.core.linphone;
-
-import android.content.Context;
-
-import com.hdl.hdllinphonesdk.core.service.HDLLinphoneService;
-
-import org.linphone.core.AccountCreator;
-import org.linphone.core.Address;
-import org.linphone.core.AudioDevice;
-import org.linphone.core.AuthInfo;
-import org.linphone.core.Call;
-import org.linphone.core.CallParams;
-import org.linphone.core.Core;
-import org.linphone.core.CoreException;
-import org.linphone.core.Factory;
-import org.linphone.core.ProxyConfig;
-import org.linphone.core.TransportType;
-import org.linphone.core.tools.Log;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * 璇煶閫氳瘽宸ュ叿绫�
- */
-
-public class LinphoneUtils {
-
- private static final String TAG = "LinphoneUtils";
- private static volatile LinphoneUtils sLinphoneUtils;
-
- public static LinphoneUtils getInstance() {
- if (sLinphoneUtils == null) {
- synchronized (LinphoneUtils.class) {
- if (sLinphoneUtils == null) {
- sLinphoneUtils = new LinphoneUtils();
- }
- }
- }
- return sLinphoneUtils;
- }
-
- private LinphoneUtils() {
-
- }
-
- /**
- * 娉ㄥ唽鍒版湇鍔″櫒
- *
- * @param name
- * @param password
- * @param host
- * @throws CoreException
- */
- public void registerUserAuth(String name, String password, String host) throws CoreException {
- Core mLinphoneCore = HDLLinphoneService.getCore();
- if(mLinphoneCore == null) return;
-
- AuthInfo authInfo = Factory.instance().createAuthInfo(name, null, password,
- null, null, host);
-
- AccountCreator mAccountCreator = mLinphoneCore.createAccountCreator(null);
- mAccountCreator.setUsername(name);
- mAccountCreator.setDomain(host);
- mAccountCreator.setPassword(password);
- mAccountCreator.setTransport(TransportType.Udp);
- ProxyConfig prxCfg = mAccountCreator.createProxyConfig();
-
- prxCfg.enableQualityReporting(false);
- prxCfg.setQualityReportingCollector(null);
- prxCfg.setQualityReportingInterval(0);
- prxCfg.enableRegister(true);
-//// mLinphoneCore.enableDnsSrv(true);
- mLinphoneCore.addProxyConfig(prxCfg);
- mLinphoneCore.addAuthInfo(authInfo);
- mLinphoneCore.setDefaultProxyConfig(prxCfg);
- }
-
- public Call startSingleCallingTo(PhoneBean bean, boolean isVideoCall) {
- Core mLinphoneCore = HDLLinphoneService.getCore();
- if(mLinphoneCore == null) return null;
- Address address;
- Call call = null;
- try {
- address = mLinphoneCore.interpretUrl(bean.getUserName() + "@" + bean.getHost());
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- address.setDisplayName(bean.getDisplayName());
- CallParams params = mLinphoneCore.createCallParams(null);
- if (isVideoCall) {
- params.enableVideo(true);
- params.enableLowBandwidth(false);
- } else {
- params.enableVideo(false);
- }
- try {
- call = mLinphoneCore.inviteAddressWithParams(address, params);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return call;
- }
-
- /**
- * 鍛煎彨
- */
- public Call startSingleCallingTo(String userName, boolean isVideoCall) {
- Core mLinphoneCore = HDLLinphoneService.getCore();
- if(mLinphoneCore == null) return null;
-
- Call call = null;
- Core core = HDLLinphoneService.getCore();
- if(core != null) {
- Address addressToCall = core.interpretUrl(userName);
- CallParams params = core.createCallParams(null);
-
- if (isVideoCall) {
- params.enableVideo(true);
- params.enableLowBandwidth(false);
- } else {
- params.enableVideo(false);
- }
-
- if (addressToCall != null) {
- call = core.inviteAddressWithParams(addressToCall, params);
- }
- }
- return call;
- }
-
- /**
- * 鍛煎彨鎸囧畾鍙风爜
- *
- * @param num 鍛煎彨鍙风爜
- */
- public void callTo(String num, boolean isVideoCall) {
- if (!HDLLinphoneService.isReady() || !HDLLinphoneService.getCoreIsNotNull()) {
- return;
- }
- if (!num.equals("")) {
- startSingleCallingTo(num, isVideoCall);
- }
- }
-
- /**
- * 鎺ュ惉鏉ョ數
- */
- public void acceptCall() {
- try {
- if(HDLLinphoneService.getCore() == null) return;
- Call currentCall = HDLLinphoneService.getCore().getCurrentCall();
- CallParams params = HDLLinphoneService.getCore().createCallParams(currentCall);
- params.enableVideo(true);
- currentCall.acceptWithParams(params);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * 鎺ュ惉鏉ョ數
- */
- public void acceptCallWithVideo(boolean enableVideo) {
- try {
- if(HDLLinphoneService.getCore() == null) return;
- Call currentCall = HDLLinphoneService.getCore().getCurrentCall();
- CallParams params = HDLLinphoneService.getCore().createCallParams(currentCall);
- params.enableVideo(enableVideo);
- currentCall.acceptWithParams(params);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * 鎸傛柇鐢佃瘽
- */
- public void hangUp() {
- Core mLinphoneCore = HDLLinphoneService.getCore();
- if(mLinphoneCore == null) return;
- Call currentCall = mLinphoneCore.getCurrentCall();
- if (currentCall != null) {
-// mLinphoneCore.terminateCall(currentCall);
- mLinphoneCore.terminateAllCalls();
- } else if (mLinphoneCore.isInConference()) {
- mLinphoneCore.terminateConference();
- } else {
- mLinphoneCore.terminateAllCalls();
- }
- }
-
- /**
- * 鏄惁闈欓煶
- *
- * @param isMicMuted
- */
- public void toggleMicro(boolean isMicMuted) {
- Core mLinphoneCore = HDLLinphoneService.getCore();
- if(mLinphoneCore == null) return;
- mLinphoneCore.enableMic(!isMicMuted);
- }
-
- /**
- * 鏄惁澶栨斁
- *
- * @param isSpeakerEnabled
- */
- public void toggleSpeaker(boolean isSpeakerEnabled) {
- routeAudioToSpeakerHelper(isSpeakerEnabled);
- }
-
- private void routeAudioToSpeakerHelper(boolean speakerOn) {
- Log.w("[Audio Manager] Routing audio to " + (speakerOn ? "speaker" : "earpiece"));
- try {
- if(HDLLinphoneService.getCore() == null) return;
- if (HDLLinphoneService.getCore().getCallsNb() == 0) return;
- Call currentCall = HDLLinphoneService.getCore().getCurrentCall();
- if (currentCall == null) currentCall = HDLLinphoneService.getCore().getCalls()[0];
- if (currentCall == null) return;
-
- for (AudioDevice audioDevice : HDLLinphoneService.getCore().getAudioDevices()) {
- if (speakerOn && audioDevice.getType() == AudioDevice.Type.Speaker) {
- currentCall.setOutputAudioDevice(audioDevice);
- return;
- } else if (!speakerOn && audioDevice.getType() == AudioDevice.Type.Earpiece) {
- currentCall.setOutputAudioDevice(audioDevice);
- return;
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static void copyIfNotExist(Context context, int resourceId, String target) throws IOException {
- File fileToCopy = new File(target);
- if (!fileToCopy.exists()) {
- copyFromPackage(context, resourceId, fileToCopy.getName());
- }
- }
-
- public static void copyFromPackage(Context context, int resourceId, String target) throws IOException {
- FileOutputStream outputStream = context.openFileOutput(target, 0);
- InputStream inputStream = context.getResources().openRawResource(resourceId);
- int readByte;
- byte[] buff = new byte[8048];
- while ((readByte = inputStream.read(buff)) != -1) {
- outputStream.write(buff, 0, readByte);
- }
- outputStream.flush();
- outputStream.close();
- inputStream.close();
- }
-
- public static void sleep(int time) {
- try {
- Thread.sleep(time);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/PhoneBean.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/PhoneBean.java
deleted file mode 100644
index 2185e9e..0000000
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/linphone/PhoneBean.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.hdl.hdllinphonesdk.core.linphone;
-
-/**
- * sip 璐﹀彿淇℃伅
- */
-
-public class PhoneBean {
- private String displayName;
- private String userName;
- private String host;
- private String password;
-
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-}
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java
index 9472865..8772ac9 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java
@@ -1,6 +1,9 @@
package com.hdl.hdllinphonesdk.core.service;
import android.app.AlarmManager;
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
@@ -11,14 +14,14 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.SystemClock;
+import android.support.v4.app.NotificationCompat;
-import com.hdl.hdllinphonesdk.HDLLinphoneKit;
import com.hdl.hdllinphonesdk.R;
import com.hdl.hdllinphonesdk.core.callback.PhoneCallback;
import com.hdl.hdllinphonesdk.core.callback.RegistrationCallback;
import com.hdl.hdllinphonesdk.core.linphone.KeepAliveHandler;
-import com.hdl.hdllinphonesdk.core.linphone.LinphoneUtils;
+import com.hdl.hdllinphonesdk.utils.HDLLog;
import org.linphone.core.Call;
import org.linphone.core.Core;
@@ -51,7 +54,7 @@
private PendingIntent mKeepAlivePendingIntent;
private static PhoneCallback sPhoneCallback;//閫氳瘽鐘舵�佸洖璋�
private static RegistrationCallback sRegistrationCallback;//璐﹀彿娉ㄥ唽鐧诲綍鐘舵�佸洖璋�
- private String mRingSoundFile,mPauseSoundFile = null;
+ private String mRingSoundFile, mPauseSoundFile = null;
private Handler mHandler;
private Timer mTimer;
@@ -73,6 +76,9 @@
}
public static Core getCore() {
+ if(sInstance == null){
+ return null;
+ }
return sInstance.mCore;
}
@@ -82,26 +88,35 @@
return null;
}
+ /**
+ * 娣诲姞閫氳瘽鐘舵�佸洖璋�
+ * @param phoneCallback
+ */
public static void addPhoneCallback(PhoneCallback phoneCallback) {
sPhoneCallback = phoneCallback;
}
-
public static void removePhoneCallback() {
if (sPhoneCallback != null) {
sPhoneCallback = null;
}
}
+ /**
+ * 娣诲姞娉ㄥ唽鐘舵�佸洖璋�
+ * @param registrationCallback
+ */
public static void addRegistrationCallback(RegistrationCallback registrationCallback) {
sRegistrationCallback = registrationCallback;
}
-
public static void removeRegistrationCallback() {
if (sRegistrationCallback != null) {
sRegistrationCallback = null;
}
}
+ /**
+ * 绉婚櫎鎵�浠allback
+ */
public void removeAllCallback() {
removePhoneCallback();
removeRegistrationCallback();
@@ -110,16 +125,13 @@
@Override
public void onCreate() {
super.onCreate();
-
+ hdlStartForeground();
initLinphone();
-
Intent intent = new Intent(this, KeepAliveHandler.class);
mKeepAlivePendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
((AlarmManager) this.getSystemService(Context.ALARM_SERVICE)).setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + 60000, 60000, mKeepAlivePendingIntent);
-
}
-
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
@@ -162,7 +174,7 @@
@Override
public void onDestroy() {
removeAllCallback();
-
+ logout();
mCore.removeListener(mCoreListener);
mTimer.cancel();
mCore.stop();
@@ -174,6 +186,7 @@
((AlarmManager) this.getSystemService(Context.ALARM_SERVICE)).cancel(mKeepAlivePendingIntent);
+ hdlStopForeground();
super.onDestroy();
}
@@ -189,21 +202,18 @@
* 鍒濆鍖朙inphone
*/
private void initLinphone() {
-
String basePath = getFilesDir().getAbsolutePath();
Factory.instance().setLogCollectionPath(basePath);
Factory.instance().enableLogCollection(LogCollectionState.Enabled);
Factory.instance().setDebugMode(false, getString(R.string.app_name));
// Dump some useful information about the device we're running on
- Log.i(START_LINPHONE_LOGS);
- dumpDeviceInformation();
- dumpInstalledLinphoneInformation();
+// HDLLog.I(START_LINPHONE_LOGS);
+// dumpDeviceInformation();
+// dumpInstalledLinphoneInformation();
mHandler = new Handler();
// This will be our main Core listener, it will change activities depending on events
initCoreListener();
-
copyAssetsFromPackage(basePath);
-
// Create the Core and add our listener
mCore = Factory.instance()
.createCore(basePath + "/.linphonerc", basePath + "/linphonerc", this);
@@ -212,11 +222,14 @@
configureCore();
}
+ /**
+ * 鍒濆鍖朇oreListener鐩戝惉
+ */
private void initCoreListener() {
mCoreListener = new CoreListenerStub() {
@Override
public void onCallStateChanged(Core core, Call linphoneCall, Call.State state, String message) {
- Log.e(START_LINPHONE_LOGS, "callState: " + state.toString());
+ HDLLog.e(START_LINPHONE_LOGS, "callState: " + state.toString());
currentCallState = state;
if (sPhoneCallback != null) {
if (state == Call.State.IncomingReceived) {
@@ -237,20 +250,28 @@
@Override
public void onRegistrationStateChanged(Core core, ProxyConfig proxyConfig, RegistrationState registrationState, String message) {
-
String state = registrationState.toString();
- Log.i(START_LINPHONE_LOGS, "registrationState: " + state);
- if (sRegistrationCallback != null) {
+ HDLLog.i(START_LINPHONE_LOGS, "registrationState: " + state);
- if (state.equals(RegistrationState.None.toString())) {
+ if (state.equals(RegistrationState.None.toString())) {
+ if (sRegistrationCallback != null){
sRegistrationCallback.registrationNone();
- } else if (state.equals(RegistrationState.Progress.toString())) {
+ }
+ } else if (state.equals(RegistrationState.Progress.toString())) {
+ if (sRegistrationCallback != null){
sRegistrationCallback.registrationProgress();
- } else if (state.equals(RegistrationState.Ok.toString())) {
+ }
+ } else if (state.equals(RegistrationState.Ok.toString())) {
+ if (sRegistrationCallback != null) {
sRegistrationCallback.registrationOk();
- } else if (state.equals(RegistrationState.Cleared.toString())) {
+ }
+ } else if (state.equals(RegistrationState.Cleared.toString())) {
+ removeProxyConfig(core, proxyConfig);
+ if (sRegistrationCallback != null) {
sRegistrationCallback.registrationCleared();
- } else if (state.equals(RegistrationState.Failed.toString())) {
+ }
+ } else if (state.equals(RegistrationState.Failed.toString())) {
+ if (sRegistrationCallback != null) {
sRegistrationCallback.registrationFailed();
}
}
@@ -258,6 +279,26 @@
};
}
+ /**
+ * 鏀跺埌娉ㄩ攢鎴愬姛鍚庣Щ闄ゅ綋鍓嶄唬鐞�
+ * @param core
+ * @param proxyConfig
+ */
+ void removeProxyConfig(Core core, ProxyConfig proxyConfig) {
+ try {
+ HDLLog.i(START_LINPHONE_LOGS, "registrationState: 娉ㄩ攢鎴愬姛绉婚櫎璐﹀彿锛�" + proxyConfig.getIdentityAddress().getUsername());
+ //鏀跺埌娉ㄩ攢鎴愬姛鍚庣Щ闄ゅ綋鍓嶄唬鐞�
+ if (core != null) {
+ core.removeProxyConfig(proxyConfig);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * mCore鍚姩榛樿鍙傛暟閰嶇疆
+ */
private void configureCore() {
// We will create a directory for user signed certificates if needed
String basePath = getFilesDir().getAbsolutePath();
@@ -265,19 +306,18 @@
File f = new File(userCerts);
if (!f.exists()) {
if (!f.mkdir()) {
- Log.e(userCerts + " can't be created.");
+ HDLLog.E(userCerts + " can't be created.");
}
}
+ //璁剧疆UserAgent
setUserAgent();
mCore.setUserCertificatesPath(userCerts);
// mCore.setNativeRingingEnabled(true);
-//
// mCore.setRemoteRingbackTone(mRingSoundFile);
// mCore.setTone(ToneID.CallWaiting, mRingSoundFile);
mCore.setRing(mRingSoundFile);
// mCore.setPlayFile(mPauseSoundFile);
-
// mCore.enableVideoCapture(false);//绂佺敤鎵嬫満鎽勫儚澶磋棰戦噰闆�
mCore.setNetworkReachable(true);
@@ -288,7 +328,6 @@
mCore.enableEchoLimiter(true);
//鑷�傚簲鐮佺巼鎺у埗
-// boolean isAdaptiveRateControl = (boolean) SPUtils.get(mServiceContext, "adaptive_rate_control", true);
mCore.enableAdaptiveRateControl(true);
//audio 鐮佺巼璁剧疆
mCore.getConfig().setInt("audio", "codec_bitrate_limit", 36);
@@ -309,6 +348,9 @@
setCodecMime();
}
+ /**
+ * 璁剧疆缂栫爜鏍煎紡
+ */
private void setCodecMime() {
PayloadType[] ptList = mCore.getAudioPayloadTypes();
for (PayloadType pt : ptList) {
@@ -330,6 +372,10 @@
mCore.setVideoPayloadTypes(ptVideoList);
}
+ /**
+ * 璁剧疆鏄惁鍚敤閾冨0锛岀洰鍓嶅彂鐜拌缃棤鏁堝緟鍒嗘瀽鍘熷洜
+ * @param use
+ */
public void enableDeviceRingtone(boolean use) {
if (use) {
mCore.setRing(null);
@@ -338,6 +384,9 @@
}
}
+ /**
+ * 璁剧疆UserAgent
+ */
private void setUserAgent() {
try {
String versionName = this.getPackageManager().getPackageInfo(this.getPackageName(),
@@ -351,6 +400,9 @@
}
}
+ /**
+ * 鎵撳嵃鐩稿叧淇℃伅
+ */
private void dumpDeviceInformation() {
StringBuilder sb = new StringBuilder();
sb.append("DEVICE=").append(Build.DEVICE).append("\n");
@@ -362,9 +414,12 @@
sb.append(abi).append(", ");
}
sb.append("\n");
- Log.i(sb.toString());
+ HDLLog.I(sb.toString());
}
+ /**
+ * 鎵撳嵃鐗堟湰鍙蜂俊鎭�
+ */
private void dumpInstalledLinphoneInformation() {
PackageInfo info = null;
try {
@@ -374,11 +429,11 @@
}
if (info != null) {
- Log.i(
+ HDLLog.i(
"[Service] Linphone version is ",
info.versionName + " (" + info.versionCode + ")");
} else {
- Log.i("[Service] Linphone version is unknown");
+ HDLLog.I("[Service] Linphone version is unknown");
}
}
@@ -393,18 +448,10 @@
// The factory config is used to override any other setting, let's copy it each time
copyFromPackage(R.raw.linphonerc_factory, "linphonerc");
mRingSoundFile = basePath + "/oldphone_mono.wav";
- copyIfNotExist(R.raw.oldphone_mono, basePath + "/oldphone_mono.wav");
+ copyIfNotExist(R.raw.oldphone_mono, basePath + "/oldphone_mono.wav");
copyIfNotExist(R.raw.ringback, basePath + "/ringback.wav");
mPauseSoundFile = basePath + "/toy_mono.wav";
- copyIfNotExist( R.raw.toy_mono, basePath + "/toy_mono.wav");
-
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.ringback, mRingBackSoundFile);
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.toy_mono, mPauseSoundFile);
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.linphonerc_default, mLinphoneConfigFile);
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.linphonerc_factory, new File(mLinphoneFactoryConfigFile).getName());
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.lpconfig, mLPConfigXsd);
-// LinphoneUtils.copyIfNotExist(mServiceContext, R.raw.rootca, mLinphoneRootCaFile);
-
+ copyIfNotExist(R.raw.toy_mono, basePath + "/toy_mono.wav");
} catch (IOException ioe) {
Log.e(ioe);
@@ -412,6 +459,12 @@
}
+ /**
+ * copyIfNotExist
+ * @param ressourceId
+ * @param target
+ * @throws IOException
+ */
private void copyIfNotExist(int ressourceId, String target) throws IOException {
File lFileToCopy = new File(target);
if (!lFileToCopy.exists()) {
@@ -419,6 +472,12 @@
}
}
+ /**
+ * copyFromPackage
+ * @param ressourceId
+ * @param target
+ * @throws IOException
+ */
private void copyFromPackage(int ressourceId, String target) throws IOException {
FileOutputStream lOutputStream = openFileOutput(target, 0);
InputStream lInputStream = getResources().openRawResource(ressourceId);
@@ -438,4 +497,44 @@
public Call.State getCurrentCallState() {
return currentCallState;
}
+
+ /**
+ * 娉ㄩ攢鎵�鏈夎处鍙�
+ */
+ void logout() {
+ try {
+ if (mCore != null) {
+ ProxyConfig[] configs = mCore.getProxyConfigList();
+ for (ProxyConfig config : configs) {
+ if (config != null) {
+ config.edit();
+ config.enableRegister(false);
+ config.done();
+ }
+ }
+ HDLLog.E("娉ㄩ攢鎵�鏈夎处鍙�");
+// core.clearAllAuthInfo();
+// core.clearProxyConfig();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ //閫氱煡ID
+ public static final int NOTIFICATION_ID = 2;
+ /**
+ * 瑙e喅android8.0浠ヤ笂鏃犳硶鍚姩鏈嶅姟鐨勯棶棰�
+ */
+ void hdlStartForeground() {
+
+ }
+ /**
+ * stopForeground
+ */
+ void hdlStopForeground() {
+// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+// stopForeground(true);
+// }
+ }
}
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLImageUtils.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLImageUtils.java
index 2acaa72..4896f19 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLImageUtils.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLImageUtils.java
@@ -81,15 +81,15 @@
}
} catch (FileNotFoundException e) {
- Log.e("FileNotFoundException", "FileNotFoundException:" + e.getMessage().toString());
+ HDLLog.e("FileNotFoundException", "FileNotFoundException:" + e.getMessage().toString());
e.printStackTrace();
return false;
} catch (IOException e) {
- Log.e("IOException", "IOException:" + e.getMessage().toString());
+ HDLLog.e("IOException", "IOException:" + e.getMessage().toString());
e.printStackTrace();
return false;
} catch (Exception e) {
- Log.e("IOException", "IOException:" + e.getMessage().toString());
+ HDLLog.e("IOException", "IOException:" + e.getMessage().toString());
e.printStackTrace();
return false;
diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLLog.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLLog.java
index 5cedce7..9a7d629 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLLog.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLLog.java
@@ -4,11 +4,36 @@
import static com.hdl.hdllinphonesdk.HDLLinphoneKit.HDLLinphoneKitNAME;
+/**
+ * 鎵撳嵃宸ュ叿
+ */
public class HDLLog {
- private static boolean isOpen = true;
- public static void Log(String message){
- if(isOpen){
+ /**
+ * 鏄惁鍚敤鎵撳嵃
+ */
+ private static boolean enableLog = true;
+
+ public static boolean isEnableLog() {
+ return enableLog;
+ }
+
+ public static void setEnableLog(boolean enableLog) {
+ HDLLog.enableLog = enableLog;
+ }
+
+ public static void I(String message){
+ if(enableLog){
Log.i(HDLLinphoneKitNAME, message);
+ }
+ }
+ /**
+ * 鎵撳嵃
+ * @param tag
+ * @param msg
+ */
+ public static void i(String tag, String msg){
+ if(enableLog){
+ Log.i(tag, msg);
}
}
@@ -17,9 +42,18 @@
* @param message
*/
public static void E(String message){
- if(isOpen){
+ if(enableLog){
Log.e(HDLLinphoneKitNAME, message);
}
}
+ /**
+ * Error 鎵撳嵃绾㈣壊鐨勯敊璇俊鎭�
+ */
+ public static void e(String tag, String msg){
+ if(enableLog){
+ Log.e(tag, msg);
+ }
+ }
+
}
diff --git a/HDLLinphoneSDKDemoNew/app/libs/HDLLinphoneSDK-V1.0.1.aar b/HDLLinphoneSDKDemoNew/app/libs/HDLLinphoneSDK-V1.0.1.aar
index 34ae179..f9b1d2e 100644
--- a/HDLLinphoneSDKDemoNew/app/libs/HDLLinphoneSDK-V1.0.1.aar
+++ b/HDLLinphoneSDKDemoNew/app/libs/HDLLinphoneSDK-V1.0.1.aar
Binary files differ
diff --git a/HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/HDLUtils.java b/HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/HDLUtils.java
index 9111da8..abb81fd 100644
--- a/HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/HDLUtils.java
+++ b/HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/HDLUtils.java
@@ -23,7 +23,7 @@
//// mAudioPlayUtil.playAudioFile(AudioPlayUtil.CAPTURE_SOUND);
//
// final String strCaptureFile = context.getCapturesFolder() + "/" + System.currentTimeMillis() + ".jpg";
-// Log.e(TAG, "captured picture file path is " + strCaptureFile);
+// HDLLog.e(TAG, "captured picture file path is " + strCaptureFile);
//
// if (TextUtils.isEmpty(strCaptureFile)) {
// bmp.recycle();
diff --git a/HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/MainActivity.java b/HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/MainActivity.java
index c316c7a..f17663c 100644
--- a/HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/MainActivity.java
+++ b/HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/MainActivity.java
@@ -13,8 +13,9 @@
import com.hdl.hdllinphonesdk.HDLLinphoneKit;
import com.hdl.hdllinphonesdk.activity.HDLLinphoneMonitorActivity;
import com.hdl.hdllinphonesdk.callback.OnHDLLinphoneCallListener;
-import com.hdl.hdllinphonesdk.core.EasyLinphone;
+//import com.hdl.hdllinphonesdk.core.EasyLinphone;
import com.hdl.hdllinphonesdk.core.service.HDLLinphoneService;
+import com.hdl.hdllinphonesdk.utils.HDLLog;
import org.linphone.core.Address;
import org.linphone.core.Call;
@@ -25,7 +26,7 @@
public class MainActivity extends Activity {
private static final String TAG = "MainActivity";
- private TextView mTextView,mTextView2,mTextView3;
+ private TextView mTextView,mTextView2,mTextView3,mTextView4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -34,7 +35,7 @@
mTextView = findViewById(R.id.tv_hello);
mTextView2 = findViewById(R.id.mTextView2);
mTextView3 = findViewById(R.id.mTextView3);
-
+ mTextView4 = findViewById(R.id.mTextView4);
mTextView.setOnClickListener(new View.OnClickListener() {
@Override
@@ -49,73 +50,95 @@
// HDLLinphoneKit.getInstance().setAccountAndLogin("61723164995710", "8ec02ce0", "sipproxy.ucpaas.com:25060");
// HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "116.62.26.215:5060");
+// HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "test-gz.hdlcontrol.com:5060");
+// HDLLinphoneKit.getInstance().setAccountAndLogin("6666", "85521566", "test-gz.hdlcontrol.com:5060");
+
+ HDLLinphoneKit.getInstance().setAccountAndLogin("7777", "85521566", "test-gz.hdlcontrol.com:5060");
+//
+// HDLLinphoneKit.getInstance().setAccountAndLogin("8888", "85521566", "test-gz.hdlcontrol.com:5060");
+//
+// HDLLinphoneKit.getInstance().setAccountAndLogin("4444", "85521566", "test-gz.hdlcontrol.com:5060");
+
+
+ }
+ });
+
+ mTextView4.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "test-gz.hdlcontrol.com:5060");
-
-
-
}
});
mTextView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
-// HDLLinphoneKit.getInstance().callTo("61723164995779",true);
-// HDLcallTo("61723164995779",true);
- HDLcallTo("1427186301744910338",true);
- startActivity(HDLLinphoneMonitorActivity.class);
+
+ logoutLog();
+ return;
+//// HDLLinphoneKit.getInstance().callTo("61723164995779",true);
+//// HDLcallTo("61723164995779",true);
+// HDLLinphoneKit.getInstance().callTo("1427186301744910338",true);
+// startActivity(HDLLinphoneMonitorActivity.class);
+
+
}
});
mTextView3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- logout();
+ HDLLinphoneKit.getInstance().logout();
}
});
HDLLinphoneKit.getInstance().initLinphone(this);
+ HDLLinphoneKit.getInstance().setAutoJumpCallView(true);
setOnHDLLinphoneCallListener();
}
+
+
+ /**
+ * 閫�鍑烘竻绌鸿处鍙�
+ * enableRegister false
+ */
public void logout() {
try {
Core core = HDLLinphoneService.getCore();
- ProxyConfig[] configs = core.getProxyConfigList();
- for (ProxyConfig config : configs) {
- if (config != null) {
- config.edit();
- config.enableRegister(false);
- config.done();
+ if (core != null) {
+ ProxyConfig[] configs = core.getProxyConfigList();
+ for (ProxyConfig config : configs) {
+ if (config != null) {
+ config.edit();
+ config.enableRegister(false);
+ config.done();
+ }
}
+ core.clearAllAuthInfo();//娓呴櫎鎵�鏈夎璇佷俊鎭��
+// core.clearProxyConfig();//浠庨厤缃腑鍒犻櫎鎵�鏈変唬鐞嗐��
}
-// core.clearAllAuthInfo();
-// core.clearProxyConfig();
-
} catch (Exception e) {
e.printStackTrace();
}
}
- public Call HDLcallTo(String userName, boolean isVideoCall) {
- Call call = null;
- Core core = HDLLinphoneService.getCore();
- Address addressToCall = core.interpretUrl(userName);
- CallParams params = core.createCallParams(null);
+ public void logoutLog() {
+ try {
+ Core core = HDLLinphoneService.getCore();
+ ProxyConfig[] configs = core.getProxyConfigList();
+ if(configs != null) {
+ HDLLog.E("registrationState璐︽埛length" + configs.length);
+ }
- if (isVideoCall) {
- params.enableVideo(true);
- params.enableLowBandwidth(false);
- } else {
- params.enableVideo(false);
+ for (ProxyConfig config : configs) {
+ HDLLog.E("registrationState璐︽埛"+config.getIdentityAddress().getUsername());
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
}
-
- if (addressToCall != null) {
- call = core.inviteAddressWithParams(addressToCall, params);
- }
-
- return call;
}
-
boolean openSuccess;
void setOnHDLLinphoneCallListener(){
@@ -156,7 +179,12 @@
public void onScreenshotSuccessfulAction(Bitmap image) {
showToast("鎴浘");
}
- });
+
+ @Override
+ public void onIncomingCall(String s) {
+
+ }
+ });
}
/**
diff --git a/HDLLinphoneSDKDemoNew/app/src/main/res/layout/activity_main.xml b/HDLLinphoneSDKDemoNew/app/src/main/res/layout/activity_main.xml
index 23f37d8..5032524 100644
--- a/HDLLinphoneSDKDemoNew/app/src/main/res/layout/activity_main.xml
+++ b/HDLLinphoneSDKDemoNew/app/src/main/res/layout/activity_main.xml
@@ -16,6 +16,16 @@
android:background="@android:color/holo_blue_light"
android:text="鐧诲綍" ></TextView>
+ <TextView
+ android:id="@+id/mTextView4"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:layout_marginTop="30dp"
+ android:gravity="center"
+ android:textColor="@android:color/white"
+ android:background="@android:color/holo_blue_light"
+
+ android:text="鐧诲綍2" ></TextView>
<TextView
android:id="@+id/mTextView2"
diff --git a/Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Jars/HDLLinphoneSDK-V1.0.1.aar b/Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Jars/HDLLinphoneSDK-V1.0.1.aar
index 34ae179..f9b1d2e 100644
--- a/Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Jars/HDLLinphoneSDK-V1.0.1.aar
+++ b/Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Jars/HDLLinphoneSDK-V1.0.1.aar
Binary files differ
diff --git a/Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Properties/AssemblyInfo.cs b/Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Properties/AssemblyInfo.cs
index c044a7a..b8df56d 100644
--- a/Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Properties/AssemblyInfo.cs
+++ b/Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Properties/AssemblyInfo.cs
@@ -22,5 +22,5 @@
// Minor Version
// Build Number
// Revision
-[assembly: AssemblyVersion("1.0.1.2")]
-[assembly: AssemblyFileVersion("1.0.1.2")]
+[assembly: AssemblyVersion("1.0.1.3")]
+[assembly: AssemblyFileVersion("1.0.1.3")]
--
Gitblit v1.8.0