JLChen
2021-08-24 357b934aa50e51148d14ff238919868095a45afd
2021-08-24 1.呼叫页面增加震动提醒
5个文件已修改
96 ■■■■ 已修改文件
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/AndroidManifest.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinphoneSDKDemoNew/app/libs/HDLLinphoneSDK-V1.0.1.aar 补丁 | 查看 | 原始文档 | blame | 历史
Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Jars/HDLLinphoneSDK-V1.0.1.aar 补丁 | 查看 | 原始文档 | blame | 历史
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/AndroidManifest.xml
@@ -14,6 +14,8 @@
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java
@@ -5,9 +5,12 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.media.AudioAttributes;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.SystemClock;
import android.os.Vibrator;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -60,11 +63,16 @@
    //参数
    private boolean isAnswer;//是否已经接听了
    private int callTime;//通话时间
    //倒计时
    private CountDownTimer mCountDownTimer;
    /**
     * 手机振动器
     */
    private Vibrator mVibrator;
    //Linphone
    private CoreListenerStub mCoreListener;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -79,6 +87,7 @@
        initCallBack();
        initCountDownTimer();
        initLinphone();
        initVibrator();
    }
@@ -90,17 +99,20 @@
        super.onDestroy();
        //1.挂断
        HDLLinphoneKit.getInstance().hangUp();
        //2.暂停计时
        if (null != timer_lp_calltime) {
            timer_lp_calltime.stop();
        }
        //3.注销callBack
        HDLLinphoneKit.getInstance().setOpenOpenDoorCallBack(null);
        //4.取消震动器
        cancelVibrator();
        //5.
        if (mCountDownTimer != null) {
            mCountDownTimer.cancel();
            mCountDownTimer = null;
        }
        //5.
        onDestroyLinphone();
        HDLLog.i(TAG, "onDestroy");
@@ -127,6 +139,8 @@
        timer_lp_calltime = (Chronometer) findViewById(R.id.timer_lp_calltime);
        tv_lp_calltime = findViewById(R.id.tv_lp_calltime);
        setWidthHeightWithRatio(ll_video_lp_rendering, 16, 9);
    }
    /**
@@ -286,6 +300,9 @@
    private void onClickAnswer() {
        //1.接听
        HDLLinphoneKit.getInstance().acceptCall();
        //2.取消震动
        cancelVibrator();
        //3.修改UI
        isAnswer = true;
        tv_lp_hangUp.setText(getString(R.string.lp_hangupStr));
        setViewGone(rl_lp_answerView);
@@ -389,7 +406,7 @@
    /**
     * onDestroyLinphone
     */
    void onDestroyLinphone(){
    void onDestroyLinphone() {
        Core core = HDLLinphoneKit.getInstance().getCore();
        if (core != null) {
            core.removeListener(mCoreListener);
@@ -401,4 +418,36 @@
    }
    /**
     * 初始化震动器
     */
    void initVibrator() {
        mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        if (mVibrator.hasVibrator()) {
            long[] patern = {0, 1000, 1000};
            AudioAttributes audioAttributes = null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                audioAttributes = new AudioAttributes.Builder()
                        .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                        .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) //key
                        .build();
                mVibrator.vibrate(patern, 1, audioAttributes);
            } else {
                mVibrator.vibrate(patern, 1);
            }
        } else {
            HDLLog.E("当前手机没有震动器");
        }
    }
    /**
     * 关闭震动器
     */
    void cancelVibrator(){
        if(mVibrator != null){
            mVibrator.cancel();
            mVibrator = null;
        }
    }
}
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java
@@ -309,42 +309,39 @@
                HDLLog.E(userCerts + " can't be created.");
            }
        }
        //设置UserAgent
        setUserAgent();
        //1.设置存储用户x509证书的目录的路径
        mCore.setUserCertificatesPath(userCerts);
        //2.设置UserAgent
        setUserAgent();
//        mCore.setNativeRingingEnabled(true);
//        mCore.setRemoteRingbackTone(mRingSoundFile);
//        mCore.setTone(ToneID.CallWaiting, mRingSoundFile);
        mCore.setRing(mRingSoundFile);
//        mCore.setRing(mRingSoundFile);
//        mCore.setPlayFile(mPauseSoundFile);
//        mCore.enableVideoCapture(false);//禁用手机摄像头视频采集
        mCore.setNetworkReachable(true);
        //回声消除
//        boolean isEchoCancellation = (boolean) SPUtils.get(mServiceContext, "echo_cancellation", true);
        //回声消除
        //3.回声消除
        mCore.enableEchoCancellation(true);
        mCore.enableEchoLimiter(true);
        //自适应码率控制
        //4.自适应码率控制
        mCore.enableAdaptiveRateControl(true);
        //audio 码率设置
        //5.audio 码率设置
        mCore.getConfig().setInt("audio", "codec_bitrate_limit", 36);
        //6.视频尺寸偏好设置 默认qvga
        VideoDefinition preferredVideoDefinition =
                Factory.instance().createVideoDefinitionFromName("qvga");
        mCore.setPreferredVideoDefinition(preferredVideoDefinition);
        //7.设置带宽限制,带宽单位为kbits/s, 0表示无限
        mCore.setUploadBandwidth(1536);
        mCore.setDownloadBandwidth(1536);
        //8.设置启用H264编码
        mCore.getConfig().setBool("app", "open_h264_download_enabled", true);
        //9.设置视频的默认策略
        VideoActivationPolicy vap = mCore.getVideoActivationPolicy();
        vap.setAutomaticallyInitiate(true);
        mCore.setVideoActivationPolicy(vap);
        // 设置编码格式
        //10.设置编码格式
        setCodecMime();
    }
@@ -448,10 +445,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);
HDLLinphoneSDKDemoNew/app/libs/HDLLinphoneSDK-V1.0.1.aar
Binary files differ
Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Jars/HDLLinphoneSDK-V1.0.1.aar
Binary files differ