From 589eb3ae9f309dd7adaac7b5ee48f4a9259855f8 Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期四, 14 十一月 2024 14:16:24 +0800
Subject: [PATCH] 对接海康可视对讲,禁用vp8

---
 HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java |   61 ++++++++++++++++++++++--------
 1 files changed, 45 insertions(+), 16 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 6462798..45cd9df 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
@@ -6,17 +6,22 @@
 import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.app.Service;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.ServiceConnection;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
+import android.os.Binder;
 import android.os.Build;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.SystemClock;
 import android.support.v4.app.NotificationCompat;
+import android.telecom.ConnectionService;
 
 
+import com.google.gson.Gson;
 import com.hdl.hdllinphonesdk.R;
 import com.hdl.hdllinphonesdk.activity.HDLLinphoneIntercomActivity;
 import com.hdl.hdllinphonesdk.activity.HDLLinphoneReverseCallActivity;
@@ -51,7 +56,7 @@
 public class HDLLinphoneService extends Service {
     private static final String START_LINPHONE_LOGS = " ==== HDLLinphoneService ====";
     // Keep a static reference to the Service so we can access it from anywhere in the app
-    private static HDLLinphoneService sInstance;
+    private volatile static HDLLinphoneService sInstance;
 
     private PendingIntent mKeepAlivePendingIntent;
     private static PhoneCallback sPhoneCallback;//閫氳瘽鐘舵�佸洖璋�
@@ -84,9 +89,18 @@
         return sInstance.mCore;
     }
 
+    public class LinphoneBinder extends Binder {
+
+        public HDLLinphoneService getService() {
+            return HDLLinphoneService.this;
+        }
+    }
+
+    private final IBinder binder = new LinphoneBinder();
+
     @Override
     public IBinder onBind(Intent intent) {
-        return null;
+        return binder;
     }
 
     /**
@@ -141,11 +155,17 @@
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
         super.onStartCommand(intent, flags, startId);
+       /* if (sInstance != null) {
+            return START_STICKY;
+        }*/
+        return START_STICKY;
+    }
+
+
+    public void initCore() {
 
         // If our Service is already running, no need to continue
-        if (sInstance != null) {
-            return START_STICKY;
-        }
+
 
         // Our Service has been started, we can keep our reference on it
         // From now one the Launcher will be able to call onServiceReady()
@@ -169,7 +189,6 @@
         mTimer = new Timer("Linphone scheduler");
         mTimer.schedule(lTask, 0, 20);
 
-        return START_STICKY;
     }
 
     @Override
@@ -213,7 +232,7 @@
         String basePath = getFilesDir().getAbsolutePath();
         Factory.instance().setLogCollectionPath(basePath);
         Factory.instance().enableLogCollection(LogCollectionState.Enabled);
-        Factory.instance().setDebugMode(false, getString(R.string.app_name));
+        Factory.instance().setDebugMode(true, "HDLLinphone");
         // Dump some useful information about the device we're running on
 //        HDLLog.I(START_LINPHONE_LOGS);
 //        dumpDeviceInformation();
@@ -260,8 +279,9 @@
             @Override
             public void onRegistrationStateChanged(Core core, ProxyConfig proxyConfig, RegistrationState registrationState, String message) {
                 String state = registrationState.toString();
-                HDLLog.i(START_LINPHONE_LOGS, "registrationState: " + state);
+                HDLLog.i(START_LINPHONE_LOGS, "registrationState: " + state + ",message:" + message);
 
+                HDLLog.i(START_LINPHONE_LOGS, "Registration info=" + new Gson().toJson(proxyConfig));
                 if (state.equals(RegistrationState.None.toString())) {
                     if (sRegistrationCallback != null) {
                         sRegistrationCallback.registrationNone();
@@ -326,11 +346,11 @@
         //2.璁剧疆UserAgent
         setUserAgent();
         //3.璁剧疆鎾斁閾冨0
-//        mCore.setNativeRingingEnabled(true);
-//        mCore.setRemoteRingbackTone(mRingSoundFile);
-//        mCore.setTone(ToneID.CallWaiting, mRingSoundFile);
-//        mCore.setRing(mRingSoundFile);
-//        mCore.setPlayFile(mPauseSoundFile);
+        mCore.setNativeRingingEnabled(true);
+        mCore.setRemoteRingbackTone(mRingSoundFile);
+        mCore.setTone(ToneID.CallWaiting, mRingSoundFile);
+        mCore.setRing(mRingSoundFile);
+        mCore.setPlayFile(mPauseSoundFile);
         //4.绂佺敤鎵嬫満鎽勫儚澶磋棰戦噰闆�
 //        mCore.enableVideoCapture(false);//绂佺敤鎵嬫満鎽勫儚澶磋棰戦噰闆�
 //        mCore.setNetworkReachable(true);
@@ -357,6 +377,9 @@
         //11.璁剧疆缂栫爜鏍煎紡
         setCodecMime();
 
+//        mCore.setRing(mRingSoundFile);
+
+
         // 鍏ㄨ閫歴ip璁剧疆ca璇佷功
         //mCore.setRootCa(basePath + "/rootca.pem");
     }
@@ -368,7 +391,6 @@
         //1.鍚敤PCMA PCMU 8000Hz
         PayloadType[] ptList = mCore.getAudioPayloadTypes();
         for (PayloadType pt : ptList) {
-//           HDLLog.i("payloadaudio", pt.getMimeType());
             if ((pt.getMimeType().equals("PCMA") || pt.getMimeType().equals("PCMU")) && pt.getClockRate() == 8000) {
                 pt.enable(true);
             } else {
@@ -379,8 +401,11 @@
         //2.璁剧疆VP8銆丠264銆丠265 绛夊惎鐢�
         PayloadType[] ptVideoList = mCore.getVideoPayloadTypes();
         for (PayloadType pt : ptVideoList) {
-//            HDLLog.i("VideoPayload", pt.getMimeType());
-            pt.enable(true);
+            if ("VP8".equals(pt.getMimeType())){
+                pt.enable(false);
+            }else {
+                pt.enable(true);
+            }
         }
         mCore.setVideoPayloadTypes(ptVideoList);
     }
@@ -479,6 +504,10 @@
 
     }
 
+    public void pddd (){
+//        RingtoneManager.GetDefaultUri
+    }
+
     /**
      * copyIfNotExist
      *

--
Gitblit v1.8.0