精简版SDK文档

1.环境配置

1.将i22call-sdk-release.aar文件放入libs文件夹下

2.在build.gradle中引用lib文件

implementation files('libs/i22call-sdk-release.aar')

3.在manifest.xml中添加所需权限

<uses-permission android:name="android.permission.INTERNET" /> <!-- 语音通话权限 -->
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <!-- 免提权限 -->
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

2.使用方法

1.初始化Core对象,这是主要操作对象

Core mLinPhoneCore;Factory lcFactory = Factory.instance();lcFactory.setDebugMode(true, "lilinaini 34>>");String basePath = mContext.getFilesDir().getAbsolutePath();mLinPhoneCore = lcFactory.createCore(basePath + "/.linphonerc", basePath + "/linphonerc", mContext);mLinPhoneCore.enableAdaptiveRateControl(false);
mLinPhoneCore.start();

2.注册登录

使用时注意先清空之前的资源

AccountBuilder builder = new AccountBuilder(mLinPhoneCore)        .setUsername(username)        .setDomain(domain + ":" + port)        .setHa1(null)        .setUserid(username)        .setDisplayName("")//显示名        .setPassword(password);  builder.setAvpfEnabled(false);

        if (prefix != null) {
            builder.setPrefix(prefix);
        }

        String forcedProxy = "";//
        if (!TextUtils.isEmpty(forcedProxy)) {
            builder.setServerAddr(forcedProxy).setOutboundProxyEnabled(true);// .setAvpfRrInterval(5);
        }

        if (transport != null) {
            builder.setTransport(transport);
        }

        try {
            builder.saveNewAccount();
        } catch (CoreException e) {
            Log.e("tishi", ">>>>" + e.getMessage());
        }

3.拨号呼叫

Call.inviteAddressWithParams() //使用可以参考public void callOut(String username, String host, boolean isVideoCall) {
        if (mLinPhoneCore == null) {
            return;
        }
        Address address = mLinPhoneCore.interpretUrl(username + "@" + host);

        address.setDisplayName(username);
        CallParams params = mLinPhoneCore.createCallParams(null);
        //params.enableLowBandwidth(true);
        //   params.setAudioBandwidthLimit(0);//
        params.enableVideo(isVideoCall);
        Call call = mLinPhoneCore.inviteAddressWithParams(address, params);
        if (call == null) {
            Log.e("lilin error", "Could not place call to " + username);
            return;
        }
    }

4.DTMF

Call.sendDtmf()//注意这里的Call对象要拿到当前呼叫的Call对象//可以参考mLinPhoneCore.getLC().setUseInfoForDtmf(true);
Call currentCall = instance.getLC().getCurrentCall();
 if (currentCall != null && !TextUtils.isEmpty(input)) {
    char a = input.charAt(0);
      currentCall.sendDtmf(msg);
}

5.挂断

Call.terminateAllCalls();

3.状态返回

在初始化时注册CoreListener监听,并注意其中的onRegistrationStateChanged()和onCallStateChanged()回调方法

onRegistrationStateChanged主要返回注册信息的回调

onCallStateChanged主要返回呼叫状态的回调