diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java index 43960605d..1d89d03ad 100644 --- a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java +++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java @@ -2,8 +2,16 @@ package io.agora.beautyapi.faceunity.agora; import android.app.Activity; import android.content.Context; +import android.opengl.EGL14; +import android.opengl.EGLConfig; +import android.opengl.EGLContext; +import android.opengl.EGLDisplay; +import android.opengl.EGLSurface; +import android.opengl.GLES20; import android.util.Log; +import android.view.Surface; import android.view.TextureView; +import android.view.View; import android.widget.FrameLayout; @@ -98,7 +106,7 @@ public class SWAuManager extends BaseCacheManager { */ public void initRtcEngine(Activity mContext) { this.mContext = mContext; - if(mRtcEngine==null){ + if (mRtcEngine == null) { try { // 创建 RtcEngineConfig 对象,并进行配置 RtcEngineConfig config = new RtcEngineConfig(); @@ -122,7 +130,7 @@ public class SWAuManager extends BaseCacheManager { public void initRtcEngineAudio(Activity mContext) { this.mContext = mContext; try { - if(mRtcEngine==null){ + if (mRtcEngine == null) { RtcEngineConfig config = new RtcEngineConfig(); config.mContext = mContext; config.mAppId = CommonAppConfig.getSwAppId(); @@ -354,7 +362,7 @@ public class SWAuManager extends BaseCacheManager { } public static String getChannelName(String liveUid) { - if ( liveUid != null &&liveUid.contains("g")) { + if (liveUid != null && liveUid.contains("g")) { return liveUid; } else { return CommonAppConfig.SWChannelPrefix + liveUid; @@ -416,14 +424,26 @@ public class SWAuManager extends BaseCacheManager { this.linkUserContainer = linkUserContainer; } + public void release() { + if (audienceContainer != null) { + TextureView childAt = (TextureView) audienceContainer.getChildAt(0); + if (childAt != null && childAt.getSurfaceTexture() != null) { + childAt.setVisibility(View.GONE); + childAt.invalidate(); + audienceContainer.removeAllViews(); + } + + } + } + public interface SwListener { void onUserOffline(int liveUid); } - public void preloadChannel(List uids){ - for (int i = 0; i uids) { + for (int i = 0; i < uids.size(); i++) { + int code = mRtcEngine.preloadChannel(CommonAppConfig.SWToken, getChannelName(uids.get(i).getUid()), Integer.parseInt(CommonAppConfig.getInstance().getUid())); + L.eSw("设置秒开数据 uid" + uids.get(i).getUid() + " --- userName:" + uids.get(i).getUserNiceName() + " code " + code); } } } diff --git a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java index 8ce62f8a6..4e028112b 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java @@ -630,6 +630,7 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder { mEnd = true; mStarted = false; Bus.getOff(this); + swAuManager.release(); EventBus.getDefault().unregister(this); //swAuManager.exitChannelAll(); L.e(TAG, "release------->"); diff --git a/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java index 2c124fad2..c3daf1d31 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java @@ -549,6 +549,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX public void release() { super.release(); Bus.getOff(this); + onDestroy(); LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM); rtcRoom = null; }