.aar
文件,将 SDK 中 libs 目录下的.aar
文件拷贝进 xmagic 模块中 libs 目录下。assets/
目录下的全部资源拷贝到 xmagic 模块../src/main/assets
目录下,如果 SDK 包中的 MotionRes 文件夹内有资源,将此文件夹也拷贝到../src/main/assets
目录下 。.so
文件在压缩包中,所以需要先解压),拷贝到 xmagic 模块中的../src/main/jniLibs
目录下。configurations {all*.exclude group: 'com.google.code.gson'}
//鉴权注意事项及错误码详情,请参考 https://www.tencentcloud.com/document/product/616/65891?from_cn_redirect=1#.E6.AD.A5.E9.AA.A4.E4.B8.80.EF.BC.9A.E9.89.B4.E6.9D.83XMagicImpl.checkAuth((errorCode, msg) -> {if (errorCode == TELicenseCheck.ERROR_OK) {showLoadResourceView();} else {TXCLog.e(TAG, "鉴权失败,请检查鉴权url和key" + errorCode + " " + msg);}});
private void showLoadResourceView() {if (XmagicLoadAssetsView.isCopyedRes) {XmagicResParser.parseRes(getApplicationContext());initXMagic();} else {XmagicLoadAssetsView loadAssetsView = new XmagicLoadAssetsView(this);loadAssetsView.setOnAssetsLoadFinishListener(() -> {XmagicResParser.parseRes(getApplicationContext());initXMagic();});}}
String userId = String.valueOf(new Random().nextInt(10000));String pushUrl = AddressUtils.generatePushUrl(streamId, userId, 0);mLivePusher = new V2TXLivePusherImpl(this, V2TXLiveDef.V2TXLiveMode.TXLiveMode_RTC);mLivePusher.enableCustomVideoProcess(true, V2TXLivePixelFormatTexture2D, V2TXLiveBufferTypeTexture);mLivePusher.setObserver(new V2TXLivePusherObserver() {@Overridepublic void onGLContextCreated() {}@Overridepublic int onProcessVideoFrame(V2TXLiveDef.V2TXLiveVideoFrame srcFrame, V2TXLiveDef.V2TXLiveVideoFrame dstFrame) {if (mXMagic != null) {dstFrame.texture.textureId = mXMagic.process(srcFrame.texture.textureId, srcFrame.width, srcFrame.height);}return srcFrame.texture.textureId;}@Overridepublic void onGLContextDestroyed() {if (mXMagic != null) {mXMagic.onDestroy();}}});mLivePusher.setRenderView(mPushRenderView);mLivePusher.startCamera(true);int ret = mLivePusher.startPush(pushUrl);mLivePusher.startMicrophone();
onProcessVideoFrame(V2TXLiveDef.V2TXLiveVideoFrame srcFrame, V2TXLiveDef.V2TXLiveVideoFrame dstFrame)
方法中添加如下代码。if (mXMagic != null) {dstFrame.texture.textureId = mXMagic.process(srcFrame.texture.textureId, srcFrame.width,srcFrame.height);}return srcFrame.texture.textureId;
onPause()
用于暂停美颜效果,可以在 Activity/Fragment 生命周期方法中执行, onDestroy 方法需要在 GL 线程调用(可以在 onTextureDestroyed 方法中调用 XMagicImpl 对象的onDestroy()
) ,更多使用请参考 Demo。 mXMagic.onPause(); //暂停,与Activity的onPause方法绑定mXMagic.onDestroy(); // //销毁,需要在GL线程中调用
<RelativeLayoutandroid:id="@+id/livepusher_bp_beauty_pannel"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_above="@+id/ll_edit_info" />
private void initXMagic() {if (mXMagic == null) {mXMagic = new XMagicImpl(this, mBeautyPanelView);}else {mXMagic.onResume();}}
ThirdBeautyActivity.initXMagic();
⽅法。
本页内容是否解决了您的问题?