From 48e3ff46ab43ca7a551455545cd86968be757297 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 18 Jun 2024 17:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=89=E5=8D=93=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=B8=BB=E6=92=AD=E5=85=B3=E6=92=AD=E5=90=8E=E5=9C=A8?= =?UTF-8?q?=E5=85=B3=E6=92=AD=E9=A1=B6=E9=9D=A2=E6=98=BE=E7=A4=BA=E4=B8=BB?= =?UTF-8?q?=E6=92=AD=E6=9C=80=E5=90=8E=E4=B8=80=E7=9C=9F=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E3=80=82=20=E4=BF=AE=E5=A4=8D=E5=AE=89=E5=8D=93=E4=B8=BB?= =?UTF-8?q?=E6=92=AD=E5=85=B3=E6=92=AD=E5=90=8E=E8=BF=98=E5=9C=A8=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E6=8E=A8=E6=B5=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faceunity/agora/SWAuManager.java | 34 +++++++++++++++---- .../live/views/LivePlaySwViewHolder.java | 1 + .../live/views/LivePushSwViewHolder.java | 1 + 3 files changed, 29 insertions(+), 7 deletions(-) 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; }