JLChen
2021-08-28 27e9f729fa9532ebc22afea84aa80434b8765fa5
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java
@@ -202,6 +202,7 @@
     * 初始化Linphone
     */
    private void initLinphone() {
        currentCallState = Call.State.Idle;
        String basePath = getFilesDir().getAbsolutePath();
        Factory.instance().setLogCollectionPath(basePath);
        Factory.instance().enableLogCollection(LogCollectionState.Enabled);
@@ -309,42 +310,42 @@
                HDLLog.E(userCerts + " can't be created.");
            }
        }
        //设置UserAgent
        setUserAgent();
        //1.设置存储用户x509证书的目录的路径
        mCore.setUserCertificatesPath(userCerts);
        //2.设置UserAgent
        setUserAgent();
        //3.设置播放铃声
//        mCore.setNativeRingingEnabled(true);
//        mCore.setRemoteRingbackTone(mRingSoundFile);
//        mCore.setTone(ToneID.CallWaiting, mRingSoundFile);
        mCore.setRing(mRingSoundFile);
//        mCore.setRing(mRingSoundFile);
//        mCore.setPlayFile(mPauseSoundFile);
        //4.禁用手机摄像头视频采集
//        mCore.enableVideoCapture(false);//禁用手机摄像头视频采集
        mCore.setNetworkReachable(true);
        //回声消除
//        boolean isEchoCancellation = (boolean) SPUtils.get(mServiceContext, "echo_cancellation", true);
        //回声消除
//        mCore.setNetworkReachable(true);
        //5.回声消除
        mCore.enableEchoCancellation(true);
        mCore.enableEchoLimiter(true);
        //自适应码率控制
        mCore.enableMic(true);//启用麦克风
        //6.自适应码率控制
        mCore.enableAdaptiveRateControl(true);
        //audio 码率设置
        mCore.getConfig().setInt("audio", "codec_bitrate_limit", 36);
        //7.audio 码率设置
//        mCore.getConfig().setInt("audio", "codec_bitrate_limit", 36);
        //8.视频相关设置
        mCore.setVideoPreset("custom");//视频预设为custom
        mCore.setPreferredFramerate(5);//FPS优先设置为5
        VideoDefinition preferredVideoDefinition =
                Factory.instance().createVideoDefinitionFromName("qvga");
        mCore.setPreferredVideoDefinition(preferredVideoDefinition);
        mCore.setUploadBandwidth(1536);
        mCore.setDownloadBandwidth(1536);
        mCore.getConfig().setBool("app", "open_h264_download_enabled", true);
        mCore.setPreferredVideoDefinition(preferredVideoDefinition);//视频尺寸偏好默认qvga
        //9.设置带宽限制,带宽单位为kbits/s, 0表示无限
//        mCore.setUploadBandwidth(1536);
//        mCore.setDownloadBandwidth(1536);
        //10.设置视频的默认策略
        VideoActivationPolicy vap = mCore.getVideoActivationPolicy();
        vap.setAutomaticallyInitiate(true);
        mCore.setVideoActivationPolicy(vap);
        // 设置编码格式
        //11.设置编码格式
        setCodecMime();
    }
@@ -352,21 +353,21 @@
     * 设置编码格式
     */
    private void setCodecMime() {
        //1.启用PCMA PCMU 8000Hz
        PayloadType[] ptList = mCore.getAudioPayloadTypes();
        for (PayloadType pt : ptList) {
            org.linphone.mediastream.Log.d("payloadaudio", pt.getMimeType());
            if (pt.getMimeType().equals("PCMA") && pt.getClockRate() == 8000) {
//           HDLLog.i("payloadaudio", pt.getMimeType());
            if ((pt.getMimeType().equals("PCMA") || pt.getMimeType().equals("PCMU")) && pt.getClockRate() == 8000) {
                pt.enable(true);
            } else {
                pt.enable(false);
            }
        }
        mCore.setAudioPayloadTypes(ptList);
        //2.设置VP8、H264、H265 等启用
        PayloadType[] ptVideoList = mCore.getVideoPayloadTypes();
        for (PayloadType pt : ptVideoList) {
//            HDLLog.i("VideoPayload", pt.getMimeType());
            pt.enable(true);
        }
        mCore.setVideoPayloadTypes(ptVideoList);
@@ -448,10 +449,10 @@
            // The factory config is used to override any other setting, let's copy it each time
            copyFromPackage(R.raw.linphonerc_factory, "linphonerc");
            mRingSoundFile = basePath + "/oldphone_mono.wav";
            copyIfNotExist(R.raw.oldphone_mono, basePath + "/oldphone_mono.wav");
            copyIfNotExist(R.raw.ringback, basePath + "/ringback.wav");
            mPauseSoundFile = basePath + "/toy_mono.wav";
            copyIfNotExist(R.raw.toy_mono, basePath + "/toy_mono.wav");
            copyIfNotExist(R.raw.oldphone_mono, mRingSoundFile);
//            copyIfNotExist(R.raw.ringback, basePath + "/ringback.wav");
//            mPauseSoundFile = basePath + "/toy_mono.wav";
//            copyIfNotExist(R.raw.toy_mono, basePath + "/toy_mono.wav");
        } catch (IOException ioe) {
            Log.e(ioe);