From daca4f973aeda5b816f0160eb121c5f3c7a6e66c Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期三, 01 九月 2021 15:40:49 +0800 Subject: [PATCH] 2021-09-01 1.监视页面禁用麦克风 --- HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java | 69 +++++++++++++++++++++++++--------- 1 files changed, 50 insertions(+), 19 deletions(-) diff --git a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java index cefa1be..cc91875 100644 --- a/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java +++ b/HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java @@ -25,6 +25,11 @@ import com.hdl.hdllinphonesdk.R; import com.hdl.hdllinphonesdk.callback.OnLPOpenDoorCallBack; import com.hdl.hdllinphonesdk.utils.HDLImageUtils; +import com.hdl.hdllinphonesdk.utils.HDLLog; + +import org.linphone.core.Call; +import org.linphone.core.Core; +import org.linphone.core.CoreListenerStub; /** *鐩戣椤甸潰 @@ -46,6 +51,9 @@ private TextureView video_lp_rendering2; private CountDownTimer mCountDownTimer; + + //Linphone + private CoreListenerStub mCoreListener; @Override protected void onCreate(Bundle savedInstanceState) { @@ -70,6 +78,8 @@ @Override protected void onDestroy() { super.onDestroy(); + //1.鎸傛柇 + HDLLinphoneKit.getInstance().hangUp(); HDLLinphoneKit.getInstance().setOpenOpenDoorCallBack(null); @@ -78,12 +88,9 @@ mCountDownTimer = null; } - if (mReceiver != null) { - unregisterReceiver(mReceiver); - } - HDLLinphoneKit.getInstance().onDestroy(); + onDestroyLinphone(); - Log.i(TAG,"onDestroy"); + HDLLog.i(TAG,"onDestroy"); } @@ -286,22 +293,46 @@ } /**********LinPhone**********/ - void initLinphone(){ - IntentFilter intentFilter = new IntentFilter(RECEIVE_FINISH_VIDEO_ACTIVITY); - mReceiver = new HDLLinphoneMonitorActivity.FinishVideoActivityReceiver(); - registerReceiver(mReceiver, intentFilter); - HDLLinphoneKit.getInstance().setAndroidVideoWindow(video_lp_rendering, video_lp_rendering2); - } + /** + * initLinphone + */ + void initLinphone() { + mCoreListener = new CoreListenerStub() { + @Override + public void onCallStateChanged(Core core, Call call, Call.State state, String message) { + if (state == Call.State.End || state == Call.State.Released) { + // Once call is finished (end state), terminate the activity + // We also check for released state (called a few seconds later) just in case + // we missed the first one + showToast(getString(R.string.lp_endMonitoringStr)); + finish(); + } + } + }; - - public class FinishVideoActivityReceiver extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - HDLLinphoneMonitorActivity.this.finish(); + Core core = HDLLinphoneKit.getInstance().getCore(); + // We need to tell the core in which to display what + if (core != null) { + core.setNativeVideoWindowId(video_lp_rendering); + core.setNativePreviewWindowId(video_lp_rendering2); + // Listen for call state changes + core.addListener(mCoreListener); + core.enableMic(false);//鍏抽棴楹﹀厠椋� } + } - private HDLLinphoneMonitorActivity.FinishVideoActivityReceiver mReceiver; - public static final String RECEIVE_FINISH_VIDEO_ACTIVITY = "receive_finish_video_activity"; - + /** + * onDestroyLinphone + */ + void onDestroyLinphone(){ + Core core = HDLLinphoneKit.getInstance().getCore(); + if (core != null) { + core.removeListener(mCoreListener); + core.setNativeVideoWindowId(null); + core.setNativePreviewWindowId(null); + } + video_lp_rendering = null; + video_lp_rendering2 = null; + } } \ No newline at end of file -- Gitblit v1.8.0