| | |
| | | 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; |
| | |
| | | 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. |
| | |
| | | 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; |
| | |
| | | mAccountCreator.setUsername(name); |
| | | mAccountCreator.setDomain(host); |
| | | mAccountCreator.setPassword(password); |
| | | mAccountCreator.setTransport(TransportType.Udp); |
| | | mAccountCreator.setTransport(TransportType.Tcp); |
| | | ProxyConfig prxCfg = mAccountCreator.createProxyConfig(); |
| | | |
| | | prxCfg.enableQualityReporting(false); |
| | |
| | | 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事务中使用身份验证 |
| | |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 是否静音 |
| | | * |