企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
1.设定自定义采集 (Configure custom collection) ~~~ private void setupLocalVideo(FrameLayout frameLayout,boolean top) { if(mTextureCamera == null){ mTextureCamera = new TextureCamera(this, 640, 480); mTextureCamera.setOnCaptureListener(new TextureCamera.OnCaptureListener() { @Override public int onTextureBufferAvailable(int textureId, byte[] buffer, int width, int height) { int newTexture = textureId; try { if (mhBeautyManager == null) { mhBeautyManager = new MHBeautyManager(getApplicationContext(),true); mhBeautyManager.setBeautyDataModel(BeautyDataModel.getInstance()); if (beautyViewHolder != null) { beautyViewHolder.setMhBeautyManager(mhBeautyManager); } }else{ if (mCameraFacing == Camera.CameraInfo.CAMERA_FACING_FRONT){ newTexture = mhBeautyManager.render10(textureId, width, height); }else{ newTexture = mhBeautyManager.render11(textureId, width, height); } } } catch (Exception e) { e.printStackTrace(); } return newTexture; } @Override public void onCapturerStarted() { Log.d(TAG, "onCapturerStarted() called"); } @Override public void onCapturerStopped() { Log.d(TAG, "onCapturerStopped() called"); } @Override public void onCameraSwitched(int facing, int orientation) { Log.d(TAG, "onCameraSwitched() called with: facing = [" + facing + "], orientation = [" + orientation + "]"); mCameraFacing = facing; } }); } mLocalView = new AgoraSurfaceView(VideoLineActivity.this); mLocalView.init(mTextureCamera.getEglContext()); mLocalView.setBufferType(MediaIO.BufferType.TEXTURE); mLocalView.setPixelFormat(MediaIO.PixelFormat.TEXTURE_2D); mLocalView.setZOrderOnTop(top); mLocalView.setZOrderMediaOverlay(top); frameLayout.addView(mLocalView); mRtcEngine.setLocalVideoRenderer(mLocalView); mRtcEngine.setVideoSource(mTextureCamera); mTextureCamera.onResume(); } ~~~ 2.切换大小屏的时候销毁资源(Destroying resources while switching screens) ~~~ mTextureCamera.onPause(); mTextureCamera.release(); mTextureCamera = null; mhBeautyManager.destroy(); mhBeautyManager = null; ~~~ 3. 设置本地渲染(Setting up local render) 大屏(Big Screen) ~~~ setupLocalVideo(video_chat_big,false); ~~~ 小屏(Small screen) ~~~ setupLocalVideo(video_chat_small,true); ~~~