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/HDLLinphoneKit.java |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

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 29227e3..37ef91b 100644
--- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/HDLLinphoneKit.java
+++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/HDLLinphoneKit.java
@@ -144,6 +144,7 @@
             @Override
             public void incomingCall(Call linphoneCall) {
                 super.incomingCall(linphoneCall);
+                Log.d("HDLLinphoneKit","------incomingCall------");
                 if (linphoneCall != null) {
                     String callUsername = linphoneCall.getRemoteAddress().getUsername();
                     HDLLog.I("鏉ョ數鍙风爜锛�" + callUsername);
@@ -162,21 +163,22 @@
             @Override
             public void outgoingInit() {
                 super.outgoingInit();
-
+                Log.d("HDLLinphoneKit","------outgoingInit------");
             }
 
             @Override
             public void callConnected() {
                 super.callConnected();
                 // 瑙嗛閫氳瘽榛樿鍏嶆彁锛岃闊抽�氳瘽榛樿闈炲厤鎻�
+                Log.d("HDLLinphoneKit","------callConnected------");
                 toggleSpeaker(true);
             }
 
             @Override
             public void callEnd() {
                 super.callEnd();
+                Log.d("HDLLinphoneKit","------callEnd------");
 //                context.sendBroadcast(new Intent(HDLLinphoneIntercomActivity.RECEIVE_FINISH_VIDEO_ACTIVITY));
-
             }
         });
     }
@@ -449,6 +451,12 @@
 
             if (addressToCall != null) {
                 call = core.inviteAddressWithParams(addressToCall, params);
+                // 璁剧疆澶栨斁
+                for (AudioDevice audioDevice : HDLLinphoneService.getCore().getAudioDevices()) {
+                    if (audioDevice.getType() == AudioDevice.Type.Speaker) {
+                        call.setOutputAudioDevice(audioDevice);
+                    }
+                }
             }
         }
         return call;
@@ -477,8 +485,11 @@
             Call currentCall = HDLLinphoneService.getCore().getCurrentCall();
             CallParams params = HDLLinphoneService.getCore().createCallParams(currentCall);
             params.enableVideo(true);
+            params.enableLowBandwidth(false);
             params.setAudioBandwidthLimit(0); // disable limitation
             currentCall.acceptWithParams(params);
+            Log.d("HDLLinphoneKit","---acceptCall= ");
+
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -541,7 +552,7 @@
      * 璁剧疆澶栨斁璁惧
      */
     private void routeAudioToSpeakerHelper(boolean speakerOn) {
-        org.linphone.core.tools.Log.w("[Audio Manager] Routing audio to " + (speakerOn ? "speaker" : "earpiece"));
+        Log.d("HDLLinphoneKit","璁剧疆澶栨斁璁惧[Audio Manager] Routing audio to " + (speakerOn ? "speaker" : "earpiece"));
         try {
             if (HDLLinphoneService.getCore() == null) return;
             if (HDLLinphoneService.getCore().getCallsNb() == 0) return;
@@ -550,14 +561,22 @@
             if (currentCall == null) return;
 
             for (AudioDevice audioDevice : HDLLinphoneService.getCore().getAudioDevices()) {
+                Log.d("HDLLinphoneKit","audioDevice.getType()= " + audioDevice.getType());
+            }
+
+            for (AudioDevice audioDevice : HDLLinphoneService.getCore().getAudioDevices()) {
+                Log.d("HDLLinphoneKit","璁剧疆澶栨斁璁惧speakerOn=" + speakerOn + " audioDevice.getType()=" + audioDevice.getType());
                 if (speakerOn && audioDevice.getType() == AudioDevice.Type.Speaker) {
                     currentCall.setOutputAudioDevice(audioDevice);
+                    Log.d("HDLLinphoneKit","AudioDevice.Type.Speaker");
                     return;
                 } else if (!speakerOn && audioDevice.getType() == AudioDevice.Type.Earpiece) {
                     currentCall.setOutputAudioDevice(audioDevice);
                     return;
                 }
             }
+            currentCall.setSpeakerVolumeGain(1.0f);
+            currentCall.setSpeakerMuted(speakerOn);
         } catch (Exception e) {
             e.printStackTrace();
         }

--
Gitblit v1.8.0