//主屏activity内privateMediaRouter mMediaRouter;privateSecondDisplay secondDisplay;//控制副屏显隐publicvoidonSecondChange(View view){if(secondDisplay ==null){showSecondScreen();}else{closeSecondScreen();}}//====================================privatevoidshowSecondScreen(){if(secondDisplay !=null){return;}mMediaRouter =(MediaRouter)getSystemService(Context.MEDIA_ROUTER_SERVICE);updatePresentation();}privatevoidcloseSecondScreen(){if(secondDisplay !=null){secondDisplay.release();secondDisplay.dismiss();secondDisplay =null;}}privatevoidupdatePresentation(){// Get the current route and its presentation display.MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);Display presentationDisplay = route !=null? route.getPresentationDisplay():null;// Dismiss the current presentation if the display has changed.if(secondDisplay !=null&& secondDisplay.getDisplay()!= presentationDisplay){secondDisplay.dismiss();secondDisplay =null;}// Show a new presentation if needed.if(secondDisplay ==null&& presentationDisplay !=null){secondDisplay =newSecondDisplay(this, presentationDisplay);secondDisplay.setOnDismissListener(mOnDismissListener);try{secondDisplay.show();}catch(WindowManager.InvalidDisplayException ex){secondDisplay =null;ex.printStackTrace();}}}//副屏关闭监听privatefinalDialogInterface.OnDismissListener mOnDismissListener =newDialogInterface.OnDismissListener(){@OverridepublicvoidonDismiss(DialogInterface dialog){if(dialog == secondDisplay){secondDisplay =null;}}};
XDP(eXpress Data Path)是 Linux 中的一项强大新网络功能,它允许在数据包进入网络栈之前以高性能可编程的方式访问这些数据包。然而,XDP 的学习曲线较高。许多开发者已经为这项功能撰写了入门博客,例如 Paolo Abeni 的…