| | |
| | | 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; |
| | | |
| | | /** |
| | | *监视页面 |
| | | */ |
| | |
| | | private TextureView video_lp_rendering2; |
| | | |
| | | private CountDownTimer mCountDownTimer; |
| | | |
| | | //Linphone |
| | | private CoreListenerStub mCoreListener; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | mCountDownTimer = null; |
| | | } |
| | | |
| | | if (mReceiver != null) { |
| | | unregisterReceiver(mReceiver); |
| | | } |
| | | HDLLinphoneKit.getInstance().onDestroy(); |
| | | onDestroyLinphone(); |
| | | |
| | | HDLLog.i(TAG,"onDestroy"); |
| | | |
| | |
| | | } |
| | | |
| | | /**********LinPhone**********/ |
| | | /** |
| | | * initLinphone |
| | | */ |
| | | 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); |
| | | 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(); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 页面关闭广播监听 |
| | | * onDestroyLinphone |
| | | */ |
| | | public class FinishVideoActivityReceiver extends BroadcastReceiver { |
| | | @Override |
| | | public void onReceive(Context context, Intent intent) { |
| | | HDLLinphoneMonitorActivity.this.finish(); |
| | | 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; |
| | | } |
| | | private HDLLinphoneMonitorActivity.FinishVideoActivityReceiver mReceiver; |
| | | public static final String RECEIVE_FINISH_VIDEO_ACTIVITY = "receive_finish_video_activity"; |
| | | |
| | | } |