From 1cb86d56496996975585f5dff9678b7c6009691d Mon Sep 17 00:00:00 2001
From: 562935844@qq.com
Date: 星期二, 28 六月 2022 17:08:05 +0800
Subject: [PATCH] 代码同步
---
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java | 115 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 71 insertions(+), 44 deletions(-)
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 04b9089..6462798 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
@@ -18,6 +18,8 @@
import com.hdl.hdllinphonesdk.R;
+import com.hdl.hdllinphonesdk.activity.HDLLinphoneIntercomActivity;
+import com.hdl.hdllinphonesdk.activity.HDLLinphoneReverseCallActivity;
import com.hdl.hdllinphonesdk.core.callback.PhoneCallback;
import com.hdl.hdllinphonesdk.core.callback.RegistrationCallback;
import com.hdl.hdllinphonesdk.core.linphone.KeepAliveHandler;
@@ -76,12 +78,11 @@
}
public static Core getCore() {
- if(sInstance == null){
+ if (sInstance == null) {
return null;
}
return sInstance.mCore;
}
-
@Override
public IBinder onBind(Intent intent) {
@@ -90,11 +91,13 @@
/**
* 娣诲姞閫氳瘽鐘舵�佸洖璋�
+ *
* @param phoneCallback
*/
public static void addPhoneCallback(PhoneCallback phoneCallback) {
sPhoneCallback = phoneCallback;
}
+
public static void removePhoneCallback() {
if (sPhoneCallback != null) {
sPhoneCallback = null;
@@ -103,11 +106,13 @@
/**
* 娣诲姞娉ㄥ唽鐘舵�佸洖璋�
+ *
* @param registrationCallback
*/
public static void addRegistrationCallback(RegistrationCallback registrationCallback) {
sRegistrationCallback = registrationCallback;
}
+
public static void removeRegistrationCallback() {
if (sRegistrationCallback != null) {
sRegistrationCallback = null;
@@ -154,15 +159,11 @@
new TimerTask() {
@Override
public void run() {
- mHandler.post(
- new Runnable() {
- @Override
- public void run() {
- if (mCore != null) {
- mCore.iterate();
- }
- }
- });
+ mHandler.post(() -> {
+ if (mCore != null) {
+ mCore.iterate();
+ }
+ });
}
};
mTimer = new Timer("Linphone scheduler");
@@ -175,12 +176,18 @@
public void onDestroy() {
removeAllCallback();
logout();
- mCore.removeListener(mCoreListener);
- mTimer.cancel();
- mCore.stop();
- // A stopped Core can be started again
- // To ensure resources are freed, we must ensure it will be garbage collected
- mCore = null;
+
+ if (mTimer != null) {
+ mTimer.cancel();
+ }
+
+ if (mCore != null) {
+ mCore.removeListener(mCoreListener);
+ mCore.stop();
+ // A stopped Core can be started again
+ // To ensure resources are freed, we must ensure it will be garbage collected
+ mCore = null;
+ }
// Don't forget to free the singleton as well
sInstance = null;
@@ -202,6 +209,7 @@
* 鍒濆鍖朙inphone
*/
private void initLinphone() {
+ currentCallState = Call.State.Idle;
String basePath = getFilesDir().getAbsolutePath();
Factory.instance().setLogCollectionPath(basePath);
Factory.instance().enableLogCollection(LogCollectionState.Enabled);
@@ -215,8 +223,8 @@
initCoreListener();
copyAssetsFromPackage(basePath);
// Create the Core and add our listener
- mCore = Factory.instance()
- .createCore(basePath + "/.linphonerc", basePath + "/linphonerc", this);
+ mCore = Factory.instance().createCore(basePath + "/.linphonerc",
+ basePath + "/linphonerc", this);
mCore.addListener(mCoreListener);
// Core is ready to be configured
configureCore();
@@ -230,6 +238,7 @@
@Override
public void onCallStateChanged(Core core, Call linphoneCall, Call.State state, String message) {
HDLLog.e(START_LINPHONE_LOGS, "callState: " + state.toString());
+ HDLLog.e(START_LINPHONE_LOGS, "state.toInt()=" + state.toInt() + "==============message=========: " + message);
currentCallState = state;
if (sPhoneCallback != null) {
if (state == Call.State.IncomingReceived) {
@@ -239,7 +248,7 @@
} else if (state == Call.State.Connected) {
sPhoneCallback.callConnected();
} else if (state == Call.State.Error) {
- sPhoneCallback.error();
+ sPhoneCallback.error(message);
} else if (state == Call.State.End) {
sPhoneCallback.callEnd();
} else if (state == Call.State.Released) {
@@ -254,11 +263,11 @@
HDLLog.i(START_LINPHONE_LOGS, "registrationState: " + state);
if (state.equals(RegistrationState.None.toString())) {
- if (sRegistrationCallback != null){
+ if (sRegistrationCallback != null) {
sRegistrationCallback.registrationNone();
}
} else if (state.equals(RegistrationState.Progress.toString())) {
- if (sRegistrationCallback != null){
+ if (sRegistrationCallback != null) {
sRegistrationCallback.registrationProgress();
}
} else if (state.equals(RegistrationState.Ok.toString())) {
@@ -281,6 +290,7 @@
/**
* 鏀跺埌娉ㄩ攢鎴愬姛鍚庣Щ闄ゅ綋鍓嶄唬鐞�
+ *
* @param core
* @param proxyConfig
*/
@@ -311,59 +321,65 @@
}
//1.璁剧疆瀛樺偍鐢ㄦ埛x509璇佷功鐨勭洰褰曠殑璺緞
- mCore.setUserCertificatesPath(userCerts);
+ //mCore.setUserCertificatesPath(userCerts);
+ mCore.setUserCertificatesPath(basePath);
//2.璁剧疆UserAgent
setUserAgent();
+ //3.璁剧疆鎾斁閾冨0
// mCore.setNativeRingingEnabled(true);
// mCore.setRemoteRingbackTone(mRingSoundFile);
// mCore.setTone(ToneID.CallWaiting, mRingSoundFile);
// mCore.setRing(mRingSoundFile);
// mCore.setPlayFile(mPauseSoundFile);
+ //4.绂佺敤鎵嬫満鎽勫儚澶磋棰戦噰闆�
// mCore.enableVideoCapture(false);//绂佺敤鎵嬫満鎽勫儚澶磋棰戦噰闆�
- mCore.setNetworkReachable(true);
- //3.鍥炲0娑堥櫎
+// mCore.setNetworkReachable(true);
+ //5.鍥炲0娑堥櫎
mCore.enableEchoCancellation(true);
- mCore.enableEchoLimiter(true);
- //4.鑷�傚簲鐮佺巼鎺у埗
+// mCore.enableEchoLimiter(false);
+ mCore.enableMic(true);//鍚敤楹﹀厠椋�
+ //6.鑷�傚簲鐮佺巼鎺у埗
mCore.enableAdaptiveRateControl(true);
- //5.audio 鐮佺巼璁剧疆
+ //7.audio 鐮佺巼璁剧疆
mCore.getConfig().setInt("audio", "codec_bitrate_limit", 36);
- //6.瑙嗛灏哄鍋忓ソ璁剧疆 榛樿qvga
- VideoDefinition preferredVideoDefinition =
- Factory.instance().createVideoDefinitionFromName("qvga");
- mCore.setPreferredVideoDefinition(preferredVideoDefinition);
- //7.璁剧疆甯﹀闄愬埗锛屽甫瀹藉崟浣嶄负kbits/s, 0琛ㄧず鏃犻檺
- mCore.setUploadBandwidth(1536);
- mCore.setDownloadBandwidth(1536);
- //8.璁剧疆鍚敤H264缂栫爜
- mCore.getConfig().setBool("app", "open_h264_download_enabled", true);
- //9.璁剧疆瑙嗛鐨勯粯璁ょ瓥鐣�
+ //8.瑙嗛鐩稿叧璁剧疆
+ mCore.setVideoPreset("custom");//瑙嗛棰勮涓篶ustom
+ mCore.setPreferredFramerate(5);//FPS浼樺厛璁剧疆涓�5
+ VideoDefinition preferredVideoDefinition = Factory.instance().createVideoDefinitionFromName("qvga");
+ mCore.setPreferredVideoDefinition(preferredVideoDefinition);//瑙嗛灏哄鍋忓ソ榛樿qvga
+ //9.璁剧疆甯﹀闄愬埗锛屽甫瀹藉崟浣嶄负kbits/s, 0琛ㄧず鏃犻檺
+// mCore.setUploadBandwidth(1536);
+// mCore.setDownloadBandwidth(1536);
+ //10.璁剧疆瑙嗛鐨勯粯璁ょ瓥鐣�
VideoActivationPolicy vap = mCore.getVideoActivationPolicy();
vap.setAutomaticallyInitiate(true);
mCore.setVideoActivationPolicy(vap);
- //10.璁剧疆缂栫爜鏍煎紡
+ //11.璁剧疆缂栫爜鏍煎紡
setCodecMime();
+
+ // 鍏ㄨ閫歴ip璁剧疆ca璇佷功
+ //mCore.setRootCa(basePath + "/rootca.pem");
}
/**
* 璁剧疆缂栫爜鏍煎紡
*/
private void setCodecMime() {
+ //1.鍚敤PCMA PCMU 8000Hz
PayloadType[] ptList = mCore.getAudioPayloadTypes();
for (PayloadType pt : ptList) {
-
- org.linphone.mediastream.Log.d("payloadaudio", pt.getMimeType());
- if (pt.getMimeType().equals("PCMA") && pt.getClockRate() == 8000) {
+// HDLLog.i("payloadaudio", pt.getMimeType());
+ if ((pt.getMimeType().equals("PCMA") || pt.getMimeType().equals("PCMU")) && pt.getClockRate() == 8000) {
pt.enable(true);
-
} else {
pt.enable(false);
}
}
mCore.setAudioPayloadTypes(ptList);
-
+ //2.璁剧疆VP8銆丠264銆丠265 绛夊惎鐢�
PayloadType[] ptVideoList = mCore.getVideoPayloadTypes();
for (PayloadType pt : ptVideoList) {
+// HDLLog.i("VideoPayload", pt.getMimeType());
pt.enable(true);
}
mCore.setVideoPayloadTypes(ptVideoList);
@@ -371,6 +387,7 @@
/**
* 璁剧疆鏄惁鍚敤閾冨0锛岀洰鍓嶅彂鐜拌缃棤鏁堝緟鍒嗘瀽鍘熷洜
+ *
* @param use
*/
public void enableDeviceRingtone(boolean use) {
@@ -450,6 +467,12 @@
// mPauseSoundFile = basePath + "/toy_mono.wav";
// copyIfNotExist(R.raw.toy_mono, basePath + "/toy_mono.wav");
+// String mRootca = basePath + "/rootca.pem"; // 2022-05-23 瀵规帴鍏ㄨ閫氬彲瑙嗗璁叉坊鍔犵殑璇佷功
+// copyIfNotExist(R.raw.freeview_rootca, mRootca);
+
+ String mLPConfigXsd = basePath + "/lpconfig.xsd";
+ copyIfNotExist(R.raw.lpconfig, mLPConfigXsd);
+
} catch (IOException ioe) {
Log.e(ioe);
}
@@ -458,6 +481,7 @@
/**
* copyIfNotExist
+ *
* @param ressourceId
* @param target
* @throws IOException
@@ -471,6 +495,7 @@
/**
* copyFromPackage
+ *
* @param ressourceId
* @param target
* @throws IOException
@@ -520,12 +545,14 @@
//閫氱煡ID
public static final int NOTIFICATION_ID = 2;
+
/**
* 瑙e喅android8.0浠ヤ笂鏃犳硶鍚姩鏈嶅姟鐨勯棶棰�
*/
void hdlStartForeground() {
}
+
/**
* stopForeground
*/
--
Gitblit v1.8.0