panlili2024
2024-11-13 848cbfebefab08cc49b0285155edb84463aed862
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/HDLLinphoneKit.java
@@ -1,17 +1,17 @@
package com.hdl.hdllinphonesdk;
import static java.lang.Thread.sleep;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;
import android.view.TextureView;
import android.widget.Toast;
import com.hdl.hdllinphonesdk.activity.HDLLinphoneIntercomActivity;
import com.hdl.hdllinphonesdk.activity.HDLLinphoneReverseCallActivity;
import com.hdl.hdllinphonesdk.callback.OnHDLLinphoneCallListener;
import com.hdl.hdllinphonesdk.callback.OnLPOpenDoorCallBack;
import com.hdl.hdllinphonesdk.core.callback.PhoneCallback;
@@ -25,16 +25,13 @@
import org.linphone.core.AuthInfo;
import org.linphone.core.Call;
import org.linphone.core.CallParams;
import org.linphone.core.ChatMessage;
import org.linphone.core.ChatRoom;
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 java.io.FileOutputStream;
import java.io.InputStream;
import static java.lang.Thread.sleep;
/**
 * Created by jlchen on 2021/8/4.
@@ -64,6 +61,7 @@
    public static final String KEY_TITLE_NAME = "lpTitleName";
    public static final String KEY_SIP_ACCOUNT = "lpSipAccount";
    public static final String HDLLinphoneKitNAME = "HDLLinphoneKit";
    public static final String KEY_CALL_ALL_REJECTION = "callAllRejection";
    private volatile static HDLLinphoneKit instance;
    private Context viewContext;
    private ServiceWaitThread mServiceWaitThread;
@@ -411,7 +409,7 @@
        mAccountCreator.setUsername(name);
        mAccountCreator.setDomain(host);
        mAccountCreator.setPassword(password);
        mAccountCreator.setTransport(TransportType.Udp);
        mAccountCreator.setTransport(TransportType.Tcp);
        ProxyConfig prxCfg = mAccountCreator.createProxyConfig();
        prxCfg.enableQualityReporting(false);
@@ -446,7 +444,7 @@
        prxCfg.setQualityReportingInterval(0);
        prxCfg.enableRegister(true);
        //全视通需要设置固定代理服务器ip
        prxCfg.setServerAddr("sip:139.159.157.75:46000;transport=udp");
        prxCfg.setServerAddr("sip:" + domain + ";transport=udp");
        mLinphoneCore.addProxyConfig(prxCfg);//添加代理配置。如果启用了注册,这将开始在代理上注册。
        mLinphoneCore.addAuthInfo(authInfo);//添加认证信息到,该信息片段将在所有需要的SIP事务中使用身份验证
@@ -478,10 +476,12 @@
            if (addressToCall != null) {
                call = core.inviteAddressWithParams(addressToCall, params);
                if (call != null) {
                // 设置外放
                for (AudioDevice audioDevice : HDLLinphoneService.getCore().getAudioDevices()) {
                    if (audioDevice.getType() == AudioDevice.Type.Speaker) {
                        call.setOutputAudioDevice(audioDevice);
                        }
                    }
                }
            }
@@ -555,6 +555,28 @@
        }
    }
    public void sendSipMessage(String sipAccount, String sipAddress, String message) {
        try {
            Core mLinphoneCore = HDLLinphoneService.getCore();
            if (mLinphoneCore == null) return;
            //对方的sip地址,sipAddress:"sip:对方账号@服务器地址"
            Address address = mLinphoneCore.interpretUrl("sip:" + sipAccount + "@" + sipAddress);
            //建立对话
            ChatRoom chatRoom = mLinphoneCore.getChatRoom(address);
            //创建消息
            ChatMessage chatMessage = chatRoom.createMessageFromUtf8(message);
            //发送消息
            chatMessage.send();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 是否静音
     *