From dc0ae1124fa7a43c642c894b350c1f49466a527f Mon Sep 17 00:00:00 2001 From: Martin <13046765170@163.com> Date: Wed, 22 May 2024 13:32:05 +0800 Subject: [PATCH] =?UTF-8?q?add[=E5=A3=B0=E6=9C=9B=E5=8D=87=E7=BA=A7-?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=88=BF=E5=88=A4=E6=96=AD=E5=A3=B0=E7=BD=91?= =?UTF-8?q?=E6=88=96=E8=80=85=E8=9E=8D=E4=BA=91]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/shayu/phonelive/AppContext.java | 1 - .../yunbao/common/bean/CheckLiveModel.java | 1 + .../com/yunbao/common/bean/ConfigBean.java | 23 +- .../common/views/SudGameListViewHolder.java | 4 +- .../beautyapi/faceunity/agora/SWManager.java | 72 ++- .../live/activity/SudRyGameActivity.java | 3 +- .../live/activity/SudSwGameActivity.java | 1 - .../presenter/LiveSwLinkMicPkPresenter.java | 493 ++---------------- .../yunbao/live/socket/SocketRyClient.java | 10 +- .../live/views/PortraitLiveManager.java | 8 +- .../src/main/res/layout/view_live_push_sw.xml | 46 +- .../main/dialog/MainStartDialogFragment.java | 2 +- 12 files changed, 135 insertions(+), 529 deletions(-) diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index b49b1b844..4a8c1ec77 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -129,7 +129,6 @@ public class AppContext extends CommonAppContext { public void onActivityStarted(@NonNull Activity activity) { } - } @Override diff --git a/common/src/main/java/com/yunbao/common/bean/CheckLiveModel.java b/common/src/main/java/com/yunbao/common/bean/CheckLiveModel.java index 2d7d00c3e..4b4f7ca30 100644 --- a/common/src/main/java/com/yunbao/common/bean/CheckLiveModel.java +++ b/common/src/main/java/com/yunbao/common/bean/CheckLiveModel.java @@ -2,6 +2,7 @@ package com.yunbao.common.bean; import com.google.gson.Gson; import com.google.gson.annotations.SerializedName; +import com.yunbao.common.BuildConfig; public class CheckLiveModel extends BaseModel { diff --git a/common/src/main/java/com/yunbao/common/bean/ConfigBean.java b/common/src/main/java/com/yunbao/common/bean/ConfigBean.java index 12fc45d1f..ec6d14242 100644 --- a/common/src/main/java/com/yunbao/common/bean/ConfigBean.java +++ b/common/src/main/java/com/yunbao/common/bean/ConfigBean.java @@ -2,6 +2,7 @@ package com.yunbao.common.bean; import com.alibaba.fastjson.annotation.JSONField; import com.google.gson.annotations.SerializedName; +import com.yunbao.common.BuildConfig; import com.yunbao.common.utils.StringUtil; import java.util.Arrays; @@ -60,8 +61,8 @@ public class ConfigBean extends BaseModel { private String txPlayUgcLicenceUrl;//腾讯短视频鉴权 private String txVideoUgcKey; private String google_isup; - @SerializedName("sud_game_speech")//(0否,1是) - private String sudGameSpeech; + + private String sud_game_speech; @SerializedName("is_return_user")//是否需要弹窗(0否,1是) private String isReturnUser=""; @@ -186,22 +187,18 @@ public class ConfigBean extends BaseModel { '}'; } + public boolean isSw(){ - if(StringUtil.isEmpty(sudGameSpeech)){ - return false; - }else if(sudGameSpeech.equals("1")){ - return true; - }else{ - return false; - } + return getSud_game_speech().equals("1"); } - public String getSudGameSpeech() { - return sudGameSpeech; + @JSONField(name = "sud_game_speech") + public String getSud_game_speech() { + return sud_game_speech; } - public void setSudGameSpeech(String sudGameSpeech) { - this.sudGameSpeech = sudGameSpeech; + public void setSud_game_speech(String sud_game_speech) { + this.sud_game_speech = sud_game_speech; } @JSONField(name = "apk_ver") diff --git a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java index a3b89ce13..b2c36f106 100644 --- a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java @@ -108,9 +108,9 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder { if (isHome) { if (TextUtils.equals(model.getLiveUid(), "0")) { if(CommonAppConfig.getInstance().getConfig().isSw()){ - RouteUtil.forwardSwSudGameActivity(new Gson().toJson(data),true,isHome); + RouteUtil.forwardSwSudGameActivity(new Gson().toJson(createSudRoomModel),true,isHome); }else{ - RouteUtil.forwardRySudGameActivity(new Gson().toJson(data),true,isHome); + RouteUtil.forwardRySudGameActivity(new Gson().toJson(createSudRoomModel),true,isHome); } } else { String yes = "是"; diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWManager.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWManager.java index 1b7e3ebff..93ba3273d 100644 --- a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWManager.java +++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWManager.java @@ -33,6 +33,7 @@ import io.agora.rtc2.IRtcEngineEventHandler; import io.agora.rtc2.RtcConnection; import io.agora.rtc2.RtcEngineConfig; import io.agora.rtc2.RtcEngineEx; +import io.agora.rtc2.video.ContentInspectConfig; import io.agora.rtc2.video.VideoCanvas; import io.agora.rtc2.video.VideoEncoderConfiguration; @@ -66,6 +67,7 @@ public class SWManager extends BaseCacheManager { /** * 获取单列 + * * @return */ public static SWManager get() { @@ -123,7 +125,7 @@ public class SWManager extends BaseCacheManager { // 创建一个 SurfaceView 对象,并将其作为 FrameLayout 的子对象 SurfaceView surfaceView = new SurfaceView(mContext); anchorContainer.addView(surfaceView); - Config config = new Config(mContext, mRtcEngine, FURenderer.INSTANCE.mFURenderKit, null, CaptureMode.Agora, 0, false, new CameraConfig(MirrorMode.MIRROR_NONE,MirrorMode.MIRROR_NONE)); + Config config = new Config(mContext, mRtcEngine, FURenderer.INSTANCE.mFURenderKit, null, CaptureMode.Agora, 0, false, new CameraConfig(MirrorMode.MIRROR_NONE, MirrorMode.MIRROR_NONE)); faceUnityBeautyAPI.initialize(config); faceUnityBeautyAPI.enable(false); @@ -135,17 +137,19 @@ public class SWManager extends BaseCacheManager { //faceUnityBeautyAPI.updateCameraConfig(new CameraConfig(MirrorMode.MIRROR_NONE,MirrorMode.MIRROR_NONE)); //mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid)); setEnableBeauty(true); //默认开启美颜 - + setContentInspect(); //开启视频截图上传 } - public void setEnableBeauty(boolean flag){ - if(faceUnityBeautyAPI!=null){ + + public void setEnableBeauty(boolean flag) { + if (faceUnityBeautyAPI != null) { faceUnityBeautyAPI.enable(flag); } } /** * 设置清晰度 + * * @param selectClarity */ public void setDimensions(int selectClarity) { @@ -175,12 +179,12 @@ public class SWManager extends BaseCacheManager { /** * 设置镜像模式 */ - public void setMirrorMode(){ - if(cfg!=null&&mRtcEngine!=null){ - L.eSw("setMirrorMode设置镜像"+cfg.mirrorMode); - if(cfg.mirrorMode==VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED){ + public void setMirrorMode() { + if (cfg != null && mRtcEngine != null) { + L.eSw("setMirrorMode设置镜像" + cfg.mirrorMode); + if (cfg.mirrorMode == VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED) { cfg.mirrorMode = VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_DISABLED; //取消镜像 - }else{ + } else { cfg.mirrorMode = VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED; //设置镜像 } mRtcEngine.setVideoEncoderConfiguration(cfg); @@ -190,11 +194,23 @@ public class SWManager extends BaseCacheManager { } } + public void setContentInspect() { + ContentInspectConfig config = new ContentInspectConfig(); + config.extraInfo = "YourExtraInfo"; + config.moduleCount = 1; + // 功能模块的类型为视频截图上传 + config.modules[0].type = ContentInspectConfig.CONTENT_INSPECT_TYPE_SUPERVISE; + // 视频截图上传的频率为 2 秒一次 + config.modules[0].interval = 2; + mRtcEngine.enableContentInspect(true, config); + } + + /** - * 设置镜像模式 + * 设置前後攝像頭 */ - public void switchCamera(){ - if(mRtcEngine!=null){ + public void switchCamera() { + if (mRtcEngine != null) { mRtcEngine.switchCamera(); } } @@ -212,6 +228,7 @@ public class SWManager extends BaseCacheManager { /** * 更新主播视图 + * * @param frameLayout */ public void updateMyChannelView(FrameLayout frameLayout) { @@ -220,13 +237,14 @@ public class SWManager extends BaseCacheManager { surfaceView.setZOrderMediaOverlay(true); frameLayout.addView(surfaceView); - VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN , uid); + VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid); mRtcEngine.setupLocalVideo(videoCanvas); } /** * PK-加入对方主播直播间 + * * @param strUid * @param token * @param toUid @@ -264,7 +282,7 @@ public class SWManager extends BaseCacheManager { SurfaceView surfaceView = new SurfaceView(mContext); surfaceView.setZOrderMediaOverlay(true); pkContainer.addView(surfaceView); - VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN ,Integer.parseInt(toUid)); + VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, Integer.parseInt(toUid)); mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); } }); @@ -286,12 +304,13 @@ public class SWManager extends BaseCacheManager { /** * PK-加入对方主播直播间 + * * @param strUid * @param token * @param toUid * @param channelName */ - public void joinChannelDrEx(FrameLayout frameLayout,String strUid, String token, String toUid, String channelName) { + public void joinChannelDrEx(FrameLayout frameLayout, String strUid, String token, String toUid, String channelName) { int tempUid; if (StringUtil.isEmpty(strUid)) { tempUid = 0; @@ -324,7 +343,7 @@ public class SWManager extends BaseCacheManager { SurfaceView surfaceView = new SurfaceView(mContext); surfaceView.setZOrderMediaOverlay(true); frameLayout.addView(surfaceView); - VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN ,Integer.parseInt(toUid)); + VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, Integer.parseInt(toUid)); mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); } }); @@ -345,10 +364,11 @@ public class SWManager extends BaseCacheManager { /** * 退出对方直播间 - * @param uid 自己的ID + * + * @param uid 自己的ID * @param liveUid 对方直播间号 */ - public void exitChannelToUid(int uid, String liveUid){ + public void exitChannelToUid(int uid, String liveUid) { RtcConnection rtcConnection = new RtcConnection(); rtcConnection.channelId = getChannelName(liveUid); //對方主播的頻道 rtcConnection.localUid = uid;//自己的ID @@ -358,8 +378,8 @@ public class SWManager extends BaseCacheManager { /** * 退出所有频道 */ - public void exitChannelAll(){ - if(mRtcEngine!=null){ + public void exitChannelAll() { + if (mRtcEngine != null) { mRtcEngine.leaveChannel(); } } @@ -367,6 +387,7 @@ public class SWManager extends BaseCacheManager { public void setAnchorContainer(FrameLayout anchorContainer) { this.anchorContainer = anchorContainer; } + //远程监听 private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() { @Override @@ -384,7 +405,7 @@ public class SWManager extends BaseCacheManager { @Override public void onJoinChannelSuccess(String channel, int uid, int elapsed) { super.onJoinChannelSuccess(channel, uid, elapsed); - L.eSw("onJoinChannelSuccess 加入频道:channel"+channel+" uid:"+uid+" elapsed:"+elapsed); + L.eSw("onJoinChannelSuccess 加入频道:channel" + channel + " uid:" + uid + " elapsed:" + elapsed); if (onRtcEngineListener != null) { onRtcEngineListener.onOpenSuccess(channel, uid); } @@ -393,7 +414,7 @@ public class SWManager extends BaseCacheManager { @Override public void onError(int err) { super.onError(err); - L.eSw("onError 错误码:"+err); + L.eSw("onError 错误码:" + err); ToastUtil.show("onError:" + err); } @@ -420,7 +441,7 @@ public class SWManager extends BaseCacheManager { @Override public void onLocalVideoStateChanged(Constants.VideoSourceType source, int state, int error) { super.onLocalVideoStateChanged(source, state, error); - L.eSw("onLocalVideoStateChanged_source"+source+" state_"+state+" error_"+error); + L.eSw("onLocalVideoStateChanged_source" + source + " state_" + state + " error_" + error); } }; @@ -452,10 +473,11 @@ public class SWManager extends BaseCacheManager { public void setLinkUserContainer(FrameLayout linkUserContainer) { this.linkUserContainer = linkUserContainer; } + public static String getChannelName(String liveUid) { - if(liveUid.contains("g")){ + if (liveUid.contains("g")) { return liveUid; - }else{ + } else { return CommonAppConfig.SWChannelPrefix + liveUid; } } diff --git a/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java index 176330831..7ec1b109a 100644 --- a/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java @@ -19,6 +19,7 @@ import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.lxj.xpopup.XPopup; +import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.R; import com.yunbao.common.activity.AbsActivity; @@ -106,7 +107,7 @@ public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.M private List customSidebarChildModels = new ArrayList<>(); private void initDate() { - + CommonAppConfig.getInstance().getConfig().isSw(); LiveNetManager.get(mContext) .getCustomSidebarInfo("1", new HttpCallback>() { @Override diff --git a/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java index eb6ee8efd..baa056c48 100644 --- a/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java @@ -196,7 +196,6 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M }); } - private void onJoinSuccess() { RongChatRoomClient.getInstance().joinChatRoom("v" + mLiveUid, -1, new IRongCoreCallback.OperationCallback() { @Override diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java index 0eefc39f1..8dc363a62 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java @@ -10,10 +10,7 @@ import static com.yunbao.live.views.LivePushSwViewHolder.rtcRoom; import android.app.Dialog; import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; import android.graphics.Color; -import android.graphics.Paint; import android.graphics.drawable.ColorDrawable; import android.os.Handler; import android.os.Looper; @@ -85,11 +82,7 @@ import cn.rongcloud.rtc.api.RCRTCOtherRoom; import cn.rongcloud.rtc.api.RCRTCRemoteUser; import cn.rongcloud.rtc.api.callback.IRCRTCOtherRoomEventsListener; import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; -import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback; import cn.rongcloud.rtc.api.stream.RCRTCInputStream; -import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig; -import cn.rongcloud.rtc.base.RCRTCMediaType; -import cn.rongcloud.rtc.base.RCRTCRoomType; import cn.rongcloud.rtc.base.RTCErrorCode; import io.agora.beautyapi.faceunity.agora.SWManager; import io.rong.imlib.IRongCallback; @@ -150,7 +143,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { private TextView textGrade1, textGrade2, textGrade3, textGrade4; private ImageView imageGrade1, imageGrade2, imageGrade3, imageGrade4; - public LivePushSwViewHolder livePushRyViewHolder; + public LivePushSwViewHolder livePushSwViewHolder; public static List inputStreamList = new ArrayList<>(); public static List inputStreamList1 = new ArrayList<>(); @@ -253,7 +246,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { mIsAnchor = isAnchor; mRoot = root; mPkContainer = linkMicViewHolder.getPkContainer(); - livePushRyViewHolder = linkMicViewHolder; + livePushSwViewHolder = linkMicViewHolder; mPkTimeString1 = ""; mPkTimeString2 = mContext.getString(R.string.live_pk_time_2); //从本地取数据 @@ -385,8 +378,8 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960); params.weight = 1; params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); - livePushRyViewHolder.camera.setLayoutParams(params); - livePushRyViewHolder.mPreView1.setLayoutParams(params); + livePushSwViewHolder.camera.setLayoutParams(params); + livePushSwViewHolder.mPreView1.setLayoutParams(params); } Log.i("tts2", s1); @@ -509,8 +502,8 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { public void onLinkDRMicPkApplyOk(UserBean u) { L.eSw("onLinkDRMicPkApplyOk(UserBean u) " + u.getUserNiceName()); int index = 0; - if (livePushRyViewHolder != null) { - livePushRyViewHolder.setAnDrPkRtc(String.valueOf(u.getId()), -1); + if (livePushSwViewHolder != null) { + livePushSwViewHolder.setAnDrPkRtc(String.valueOf(u.getId()), -1); } final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK) .param("action", 3) @@ -577,7 +570,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START); LivePushSwViewHolder.btn_close.setVisibility(View.VISIBLE); LiveSwAnchorActivity.isDRPK = 1; - livePushRyViewHolder.setAnPkRtc(u);//设置对方主播视图 + livePushSwViewHolder.setAnPkRtc(u);//设置对方主播视图 final SocketSendBean msg1 = new SocketSendBean() .param("_method_", SOCKET_LINK_MIC_PK).param("action", 4) @@ -595,9 +588,9 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960); params.weight = 1; params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); - livePushRyViewHolder.camera.setLayoutParams(params); - livePushRyViewHolder.mPreView1.setLayoutParams(params); - livePushRyViewHolder.mPreView1.setVisibility(View.VISIBLE); + livePushSwViewHolder.camera.setLayoutParams(params); + livePushSwViewHolder.mPreView1.setLayoutParams(params); + livePushSwViewHolder.mPreView1.setVisibility(View.VISIBLE); LivePushSwViewHolder.btn_close.setVisibility(View.VISIBLE); LiveSwAnchorActivity.isDRPK = 1; @@ -640,7 +633,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { }); // TODO: 2024/4/12 视图渲染 - livePushRyViewHolder.setAnPkRtc(bean); + livePushSwViewHolder.setAnPkRtc(bean); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.UN_LEAVELIVE)); @@ -653,71 +646,6 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { }); } - //与用户连麦 - public void setUserMic(String liveid) { - JSONObject msg1 = new JSONObject(); - msg1.put("uid", CommonAppConfig.getInstance().getUid()); - msg1.put("pkuid", CommonAppConfig.getInstance().getUid()); - msg1.put("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatarThumb()); - msg1.put("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); - - rtcRoom.getLocalUser().responseJoinOtherRoom(liveid, liveid, true, true, msg1.toString(), new IRCRTCResultCallback() { - @Override - public void onSuccess() { - RCRTCEngine.getInstance().joinOtherRoom(liveid, new IRCRTCResultDataCallback() { - @Override - public void onSuccess(RCRTCOtherRoom rcrtcOtherRoom) { - rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener); - ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success"); - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - Log.e("ry", liveid + "来了!!!!" + rcrtcOtherRoom.getRemoteUsers().size()); - for (int i = 0; i < rcrtcOtherRoom.getRemoteUsers().size(); i++) { - //遍历远端用户发布的资源列表 - for (RCRTCInputStream stream : rcrtcOtherRoom.getRemoteUsers().get(i).getStreams()) { - Log.e("ry", stream.getMediaType() + "rcrtcOtherRoom成功 :" + rcrtcOtherRoom.getRemoteUsers().size()); - if (stream.getMediaType() == RCRTCMediaType.AUDIO) { - //音频只需要订阅 - inputStreamList.add(stream); - } - } - } - - Log.e("ry", "asa" + inputStreamList.size()); - //开始订阅资源 - rtcRoom.getLocalUser().subscribeStreams(inputStreamList, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - - - } - - @Override - public void onFailed(RTCErrorCode rtcErrorCode) { - Log.e("ry", "订阅资源失败: " + rtcErrorCode); - ToastUtil.show(mContext.getString(R.string.live_pk_link_error)); - } - }); - } - }); - } - - @Override - public void onFailed(RTCErrorCode rtcErrorCode) { - Log.e("ry", liveid + "加入其他房间失败 :" + rtcErrorCode); - Log.i("ry", liveid + "加入其他房间失败 :" + rtcErrorCode); - } - }); - - } - - @Override - public void onFailed(RTCErrorCode errorCode) { - ToastUtil.show("接受失败"); - } - }); - } - /** * 显示申请PK的弹窗 */ @@ -800,25 +728,6 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { } } - - public static Bitmap fromText(float textSize, String text) { - Paint paint = new Paint(); - paint.setTextSize(textSize); - paint.setTextAlign(Paint.Align.LEFT); - paint.setColor(Color.BLACK); - - Paint.FontMetricsInt fm = paint.getFontMetricsInt(); - int width = (int) paint.measureText(text); - int height = fm.descent - fm.ascent; - - Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - canvas.drawText(text, 0, fm.leading - fm.ascent, paint); - canvas.save(); - - return bitmap; - } - private String TAG = "多人PK"; /** @@ -834,11 +743,11 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { public void run() { if (btn_close != null) { btn_close.setVisibility(View.GONE); - livePushRyViewHolder.timeTitle.setVisibility(View.GONE); + livePushSwViewHolder.timeTitle.setVisibility(View.GONE); } } }); - livePushRyViewHolder.exitChannelDrPk(drPkbeans); + livePushSwViewHolder.exitChannelDrPk(drPkbeans); leaveHandler.removeCallbacks(leaveRunnable); } @@ -847,17 +756,17 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { @Override public void run() { //恢复全屏画面 - livePushRyViewHolder.dr_pk_view.setVisibility(View.GONE); + livePushSwViewHolder.dr_pk_view.setVisibility(View.GONE); //删除之前其他主播的画面 - livePushRyViewHolder.dr1_preview.removeAllViews(); - livePushRyViewHolder.dr2_preview.removeAllViews(); - livePushRyViewHolder.dr3_preview.removeAllViews(); - livePushRyViewHolder.dr4_preview.removeAllViews(); - livePushRyViewHolder.cameraPreview3.removeAllViews(); + livePushSwViewHolder.dr1_preview.removeAllViews(); + livePushSwViewHolder.dr2_preview.removeAllViews(); + livePushSwViewHolder.dr3_preview.removeAllViews(); + livePushSwViewHolder.dr4_preview.removeAllViews(); + livePushSwViewHolder.cameraPreview3.removeAllViews(); leaveHandler.removeCallbacks(leaveRunnable); - livePushRyViewHolder.timeTitle.setVisibility(View.GONE); - livePushRyViewHolder.mPreView.removeView(detailsView1); - livePushRyViewHolder.cameraPreview3.setVisibility(View.GONE); + livePushSwViewHolder.timeTitle.setVisibility(View.GONE); + livePushSwViewHolder.mPreView.removeView(detailsView1); + livePushSwViewHolder.cameraPreview3.setVisibility(View.GONE); } }; @@ -1083,7 +992,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { }); // - int index = livePushRyViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1); + int index = livePushSwViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1); L.eSw("onLinkDRMicPkApplyOk(UserBean u)-点击接收 1 " + u.getUserNiceName()); L.eSw("發送action = 2"); @@ -1308,7 +1217,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { public void setMyDrPkDetailsView() { if (detailsView1 != null) { - livePushRyViewHolder.dr1_preview.removeView(detailsView1); + livePushSwViewHolder.dr1_preview.removeView(detailsView1); } detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1); @@ -1317,7 +1226,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { textGrade1 = detailsView1.findViewById(R.id.text_grade1); textPkName1 = detailsView1.findViewById(R.id.text_pk_name1); imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); - livePushRyViewHolder.dr1_preview.addView(detailsView1); + livePushSwViewHolder.dr1_preview.addView(detailsView1); detailsLinearLayout1.setVisibility(View.GONE); linearGrade1.setVisibility(View.GONE); } @@ -1361,7 +1270,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { L.eSw("j == 0:" + j); //设置多人PK数据 if (detailsView2 != null) { - livePushRyViewHolder.dr2_preview.removeView(detailsView2); + livePushSwViewHolder.dr2_preview.removeView(detailsView2); } detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2); @@ -1371,13 +1280,13 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { textGrade2 = detailsView2.findViewById(R.id.text_grade2); imageGrade2.setTag(String.valueOf(drPkbeanList.get(0).getId())); textPkName2.setText(drPkbeanList.get(0).getUser_nicename()); - livePushRyViewHolder.dr2_preview.addView(detailsView2); + livePushSwViewHolder.dr2_preview.addView(detailsView2); detailsLinearLayout2.setVisibility(View.GONE); linearGrade2.setVisibility(View.GONE); } else if (j == 1) { L.eSw("j == 1:" + j); if (detailsView4 != null) { - livePushRyViewHolder.dr4_preview.removeView(detailsView4); + livePushSwViewHolder.dr4_preview.removeView(detailsView4); } detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4); @@ -1387,14 +1296,14 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { textGrade4 = detailsView4.findViewById(R.id.text_grade4); imageGrade4.setTag(String.valueOf(drPkbeanList.get(1).getId())); textPkName4.setText(drPkbeanList.get(1).getUser_nicename()); - livePushRyViewHolder.dr4_preview.addView(detailsView4); + livePushSwViewHolder.dr4_preview.addView(detailsView4); detailsLinearLayout4.setVisibility(View.GONE); linearGrade4.setVisibility(View.GONE); } else if (j == 2) { L.eSw("j == 2:" + j); if (detailsView4 != null) { - livePushRyViewHolder.dr4_preview.removeView(detailsView4); + livePushSwViewHolder.dr4_preview.removeView(detailsView4); } detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4); @@ -1404,12 +1313,12 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { textGrade4 = detailsView4.findViewById(R.id.text_grade4); imageGrade4.setTag(String.valueOf(drPkbeanList.get(2).getId())); textPkName4.setText(drPkbeanList.get(2).getUser_nicename()); - livePushRyViewHolder.dr4_preview.addView(detailsView4); + livePushSwViewHolder.dr4_preview.addView(detailsView4); detailsLinearLayout4.setVisibility(View.GONE); linearGrade4.setVisibility(View.GONE); if (detailsView3 != null) { - livePushRyViewHolder.dr3_preview.removeView(detailsView3); + livePushSwViewHolder.dr3_preview.removeView(detailsView3); } detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3); @@ -1419,7 +1328,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { textGrade3 = detailsView3.findViewById(R.id.text_grade3); imageGrade3.setTag(String.valueOf(drPkbeanList.get(1).getId())); textPkName3.setText(drPkbeanList.get(1).getUser_nicename()); - livePushRyViewHolder.dr3_preview.addView(detailsView3); + livePushSwViewHolder.dr3_preview.addView(detailsView3); detailsLinearLayout3.setVisibility(View.GONE); linearGrade3.setVisibility(View.GONE); @@ -1434,326 +1343,6 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { } - /** - * 多人PK PK主播发过来的已经接受 - */ - public void onDRLinkMicToPk(String u) { - Log.e("eve", u + ""); - /** - * 加入副房间 - * - * 前提必须已经 通过 {@link RCRTCEngine#joinRoom(String, RCRTCRoomType, IRCRTCResultDataCallback)} 或 {@link RCRTCEngine#joinRoom(String, IRCRTCResultDataCallback)} 加入了主房间 - * - * @param roomId 房间 ID ,长度 64 个字符,可包含:`A-Z`、`a-z`、`0-9`、`+`、`=`、`-`、`_` - * @param callBack 加入房间回调 - * @group 房间管理 - */ - - /*RCRTCEngine.getInstance().joinOtherRoom(u, new IRCRTCResultDataCallback() { - @Override - public void onSuccess(RCRTCOtherRoom rcrtcOtherRoom) { - rcrtcOtherRoom.registerOtherRoomEventsListener(otherRoomEventsListener); - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - - if (livePushRyViewHolder.dr_pk_view.getVisibility() == View.GONE) { - ScreenDimenUtil util = ScreenDimenUtil.getInstance(); - int mScreenWdith = util.getScreenWdith(); - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960); - params.weight = 1; - params.topMargin = DpUtil.dp2px(123); - livePushRyViewHolder.dr_pk_view.setLayoutParams(params); - livePushRyViewHolder.camera.setLayoutParams(params); - livePushRyViewHolder.dr_pk_view.setVisibility(View.VISIBLE); - livePushRyViewHolder.dr1_preview.setVisibility(View.GONE); - livePushRyViewHolder.dr2_preview.setVisibility(View.GONE); - livePushRyViewHolder.dr3_preview.setVisibility(View.GONE); - livePushRyViewHolder.dr4_preview.setVisibility(View.GONE); - detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); - detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1); - linearGrade1 = detailsView1.findViewById(R.id.linear_grade1); - imageGrade1 = detailsView1.findViewById(R.id.image_grade1); - textGrade1 = detailsView1.findViewById(R.id.text_grade1); - imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); - livePushRyViewHolder.mPreView.addView(detailsView1); - detailsLinearLayout1.setVisibility(View.VISIBLE); - linearGrade1.setVisibility(View.GONE); - } - - //遍历远端用户列表 - for (int i = 0; i < rcrtcOtherRoom.getRemoteUsers().size(); i++) { - //遍历远端用户发布的资源列表 - for (RCRTCInputStream stream : rcrtcOtherRoom.getRemoteUsers().get(i).getStreams()) { - Log.e("ry111", stream.getMediaType() + ""); - if (stream.getMediaType() == RCRTCMediaType.VIDEO) { - if (inputStreamList.size() == 0) { - livePushRyViewHolder.dr1_preview.setVisibility(View.VISIBLE); - //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 - RCRTCVideoView remoteView = new RCRTCVideoView(contexts); - ((RCRTCVideoInputStream) stream).setVideoView(remoteView); - //todo 本demo只演示添加1个远端用户的视图 - livePushRyViewHolder.dr1_preview.removeAllViews(); - remoteView.setScalingType(SCALE_ASPECT_FILL); - livePushRyViewHolder.dr1_preview.addView(remoteView); - LiveNetManager.get(mContext).getLiveInfo(u, new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(LiveInfoModel data) { - detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); - detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2); - linearGrade2 = detailsView2.findViewById(R.id.linear_grade2); - textPkName2 = detailsView2.findViewById(R.id.text_pk_name2); - imageGrade2 = detailsView2.findViewById(R.id.image_grade2); - textGrade2 = detailsView2.findViewById(R.id.text_grade2); - imageGrade2.setTag(String.valueOf(u)); - textPkName2.setText(data.getUserNicename()); - livePushRyViewHolder.dr1_preview.addView(detailsView2); - detailsLinearLayout2.setVisibility(View.VISIBLE); - linearGrade2.setVisibility(View.GONE); - } - - @Override - public void onError(String error) { - - } - }); - } else if (inputStreamList.size() == 1) { - livePushRyViewHolder.dr3_preview.setVisibility(View.VISIBLE); - //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 - RCRTCVideoView remoteView = new RCRTCVideoView(contexts); - ((RCRTCVideoInputStream) stream).setVideoView(remoteView); - //todo 本demo只演示添加1个远端用户的视图 - livePushRyViewHolder.dr3_preview.removeAllViews(); - remoteView.setScalingType(SCALE_ASPECT_FILL); - livePushRyViewHolder.dr3_preview.addView(remoteView); - LiveNetManager.get(mContext).getLiveInfo(u, new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(LiveInfoModel data) { - detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); - detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4); - linearGrade4 = detailsView4.findViewById(R.id.linear_grade4); - textPkName4 = detailsView4.findViewById(R.id.text_pk_name4); - imageGrade4 = detailsView4.findViewById(R.id.image_grade4); - textGrade4 = detailsView4.findViewById(R.id.text_grade4); - imageGrade4.setTag(u); - textPkName4.setText(data.getUserNicename()); - livePushRyViewHolder.dr3_preview.addView(detailsView4); - detailsLinearLayout4.setVisibility(View.VISIBLE); - linearGrade4.setVisibility(View.GONE); - } - - @Override - public void onError(String error) { - - } - }); - } else if (inputStreamList.size() == 2) { - livePushRyViewHolder.cameraPreview3.setVisibility(View.VISIBLE); - //如果远端用户发布的是视频流,创建显示视图RCRTCVideoView,并添加到布局中显示 - RCRTCVideoView remoteView = new RCRTCVideoView(contexts); - ((RCRTCVideoInputStream) stream).setVideoView(remoteView); - //todo 本demo只演示添加1个远端用户的视图 - livePushRyViewHolder.cameraPreview3.removeAllViews(); - remoteView.setScalingType(SCALE_ASPECT_FILL); - livePushRyViewHolder.cameraPreview3.addView(remoteView); - - LiveNetManager.get(mContext).getLiveInfo(u, new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(LiveInfoModel data) { - detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); - detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3); - linearGrade3 = detailsView3.findViewById(R.id.linear_grade3); - textPkName3 = detailsView3.findViewById(R.id.text_pk_name3); - imageGrade3 = detailsView3.findViewById(R.id.image_grade3); - textGrade3 = detailsView3.findViewById(R.id.text_grade3); - imageGrade3.setTag(u); - textPkName3.setText(data.getUserNicename()); - livePushRyViewHolder.cameraPreview3.addView(detailsView3); - detailsLinearLayout3.setVisibility(View.VISIBLE); - linearGrade3.setVisibility(View.GONE); - } - - @Override - public void onError(String error) { - - } - }); - } - inputStreamList.add(stream); - - } - inputStreamList1.add(stream); - - - } - - //开始订阅资源 - rtcRoom.getLocalUser().subscribeStreams(inputStreamList1, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.i("ry", "订阅资源成功"); - } - - @Override - public void onFailed(RTCErrorCode rtcErrorCode) { - Log.i("ry", "订阅资源失败: " + rtcErrorCode.getReason()); - ToastUtil.show(mContext.getString(R.string.live_pk_link_error)); - } - }); - - //2. 合流画布设置 - rcrtcLiveInfo.setMixConfig(create_Custom_MixConfig(false, inputStreamList), new IRCRTCResultCallback() { - @Override - public void onSuccess() { - Log.e("ry", inputStreamList.size() + "混成功" + u); - } - - @Override - public void onFailed(RTCErrorCode errorCode) { - Log.e("ry", "混失败" + errorCode); - - } - }); - } - - } - }); - } - - @Override - public void onFailed(RTCErrorCode rtcErrorCode) { - Log.i("ry", "加入其他房间失败 :" + rtcErrorCode.getReason()); - } - });*/ - - } - - - /** - * 创建自定义合流布局配置 - * - * @param isCrop 是否裁减画布 - * @param streams 必须为视频流列表 - * @return - */ - private RCRTCMixConfig create_Custom_MixConfig(boolean isCrop, List streams) { - Log.e("视频合流", streams.toString()); - Log.e("视频合流", "视频长度:" + streams.size()); - RCRTCMixConfig config = new RCRTCMixConfig(); - //1. 设置自定义合流布局模式 - config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.CUSTOM); - RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig(); - config.setMediaConfig(mediaConfig); - //视频输出配置 - RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig(); - mediaConfig.setVideoConfig(videoConfig); - //大流视频的输出参数 - RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout normal = new RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout(); - videoConfig.setVideoLayout(normal); - //推荐宽、高、帧率参数值可以通过默认视频流的配置获取,也可以根据实际需求来自定义设置 - //如不设置宽高值则服务端将使用默认宽高 360 * 640 - //例:发布的视频分辨率为720 * 1280,如果不设置则观众端看到的视频分辨率为 360 * 640, - //所以如果想让观众端看到的视频分辨率和发布视频分辨率一致,则应从发布的视频流中获取分辨率配置并设置到 mediaConfig 中 - RCRTCVideoStreamConfig defaultVideoConfig = RCRTCEngine.getInstance().getDefaultVideoStream().getVideoConfig(); - int fps = defaultVideoConfig.getVideoFps().getFps(); - int width = 960; - int height = 720; - normal.setWidth(width); //视频宽 - normal.setHeight(height); //视频高 - normal.setFps(fps); //视频帧率 - - //2. 合流画布设置 - //(请参照画布和声音配置示例代码) - //3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准),设置每个视频流小窗口的坐标及宽高 - ArrayList list = new ArrayList<>(); - - if (streams.size() == 1) { - //user1的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video - videoLayout1.setX(0); //X 坐标 - videoLayout1.setY(0); //Y 坐标 - videoLayout1.setWidth(480); // 视频窗口的宽 - videoLayout1.setHeight(720); // 视频窗口的高 - list.add(videoLayout1); - - //user2的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - videoLayout2.setVideoStream(streams.get(0)); // RCRTCStream#MediaType 必须是Video - videoLayout2.setX(480); //X 坐标 - videoLayout2.setY(0); //Y 坐标 - videoLayout2.setWidth(480); // 视频窗口的宽 - videoLayout2.setHeight(720); // 视频窗口的高 - list.add(videoLayout2); - - } else if (streams.size() == 2) { - //user1的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - list.add(videoLayout1); - videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video - videoLayout1.setX(0); //X 坐标 - videoLayout1.setY(0); //Y 坐标 - videoLayout1.setWidth(480); // 视频窗口的宽 - videoLayout1.setHeight(720); // 视频窗口的高 - - //user2的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - videoLayout2.setVideoStream(streams.get(0)); // RCRTCStream#MediaType 必须是Video - videoLayout2.setX(480); //X 坐标 - videoLayout2.setY(0); //Y 坐标 - videoLayout2.setWidth(480); // 视频窗口的宽 - videoLayout2.setHeight(360); // 视频窗口的高 - list.add(videoLayout2); - - //user3的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout3 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - videoLayout3.setVideoStream(streams.get(1)); // RCRTCStream#MediaType 必须是Video - videoLayout3.setX(480); //X 坐标 - videoLayout3.setY(360); //Y 坐标 - videoLayout3.setWidth(480); // 视频窗口的宽 - videoLayout3.setHeight(360); // 视频窗口的高 - list.add(videoLayout3); - - } else if (streams.size() == 3) { - //user1的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout1 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - videoLayout1.setVideoStream(RCRTCEngine.getInstance().getDefaultVideoStream()); // RCRTCStream#MediaType 必须是Video - videoLayout1.setX(0); //X 坐标 - videoLayout1.setY(0); //Y 坐标 - videoLayout1.setWidth(480); // 视频窗口的宽 - videoLayout1.setHeight(720); // 视频窗口的高 - list.add(videoLayout1); - - //user2的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout2 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - videoLayout2.setVideoStream(streams.get(0)); // RCRTCStream#MediaType 必须是Video - videoLayout2.setX(480); //X 坐标 - videoLayout2.setY(0); //Y 坐标 - videoLayout2.setWidth(480); // 视频窗口的宽 - videoLayout2.setHeight(360); // 视频窗口的高 - list.add(videoLayout2); - - //user3的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout3 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - videoLayout3.setVideoStream(streams.get(1)); // RCRTCStream#MediaType 必须是Video - videoLayout3.setX(480); //X 坐标 - videoLayout3.setY(360); //Y 坐标 - videoLayout3.setWidth(480); // 视频窗口的宽 - videoLayout3.setHeight(360); // 视频窗口的高 - list.add(videoLayout3); - - //user3的视频流 - RCRTCMixConfig.CustomLayoutList.CustomLayout videoLayout4 = new RCRTCMixConfig.CustomLayoutList.CustomLayout(); - videoLayout4.setVideoStream(streams.get(2)); // RCRTCStream#MediaType 必须是Video - videoLayout4.setX(0); //X 坐标 - videoLayout4.setY(360); //Y 坐标 - videoLayout4.setWidth(480); // 视频窗口的宽 - videoLayout4.setHeight(360); // 视频窗口的高 - list.add(videoLayout4); - } - config.setCustomLayouts(list); - return config; - } - @Override public void onClick(View v) { int i = v.getId(); @@ -2092,18 +1681,18 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { String userID1 = (String) imageGrade1.getTag(); String userID2 = (String) imageGrade2.getTag(); String userID4 = (String) imageGrade4.getTag(); - if (livePushRyViewHolder.timeTitle.getVisibility() == View.GONE) { + if (livePushSwViewHolder.timeTitle.getVisibility() == View.GONE) { mHandler.removeMessages(WHAT_PK_TIME2); - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) livePushRyViewHolder.timeTitle.getLayoutParams(); + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) livePushSwViewHolder.timeTitle.getLayoutParams(); layoutParams.topMargin = DpUtil.dp2px(123); - livePushRyViewHolder.timeTitle.setLayoutParams(layoutParams); - livePushRyViewHolder.timeTitle.setVisibility(View.VISIBLE); + livePushSwViewHolder.timeTitle.setLayoutParams(layoutParams); + livePushSwViewHolder.timeTitle.setVisibility(View.VISIBLE); String pkTime = StringUtil.getDurationText(time * 1000); - livePushRyViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), pkTime)); + livePushSwViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), pkTime)); mPkTimeCount = time; if (time > 0) { String s1 = StringUtil.getDurationText(mPkTimeCount * 1000); - livePushRyViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1)); + livePushSwViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1)); mHandler.sendEmptyMessage(WHAT_PK_TIME2); } } @@ -2304,11 +1893,11 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener { if (mPkTimeCount > 0) {// if (mHandler != null) { String s1 = StringUtil.getDurationText(mPkTimeCount * 1000); - livePushRyViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1)); + livePushSwViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1)); mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME2, getNextSecondTime()); } } else { - livePushRyViewHolder.timeTitle.setVisibility(View.GONE); + livePushSwViewHolder.timeTitle.setVisibility(View.GONE); if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); } diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index 57e2d62ae..26be83560 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -73,7 +73,7 @@ import com.yunbao.live.event.LiveAnchorEvent; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.views.LiveEndViewHolder; import com.yunbao.live.views.LivePlayKsyViewHolder; -import com.yunbao.live.views.LivePlaySwViewHolder; +import com.yunbao.live.views.LivePlayRyViewHolder; import com.yunbao.live.views.LivePushRyViewHolder; import com.yunbao.live.views.LiveRoomViewHolder; @@ -277,15 +277,15 @@ public class SocketRyClient { if (LivePlayKsyViewHolder.leave != null) { LivePlayKsyViewHolder.leave.setVisibility(View.VISIBLE); } - if (LivePlaySwViewHolder.leave != null) { - LivePlaySwViewHolder.leave.setVisibility(View.VISIBLE); + if (LivePlayRyViewHolder.leave != null) { + LivePlayRyViewHolder.leave.setVisibility(View.VISIBLE); } } else if (action21 == 13 && map.getString("ct").contains("回來")) { if (LivePlayKsyViewHolder.leave != null) { LivePlayKsyViewHolder.leave.setVisibility(View.GONE); } - if (LivePlaySwViewHolder.leave != null) { - LivePlaySwViewHolder.leave.setVisibility(View.GONE); + if (LivePlayRyViewHolder.leave != null) { + LivePlayRyViewHolder.leave.setVisibility(View.GONE); } } break; diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index f0603a13e..51769d176 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -277,14 +277,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe public PortraitLiveManager(Activity context, Intent intent) { this.mContext = context; this.mIntent = intent; - isSw = intent.getBooleanExtra("isSw", false); + isSw = intent.getBooleanExtra(Constants.LIVE_SDK_IS_SW, false); liveImDeletUtil = new LiveImDeletUtil(); portraitLiveManager = this; ininView(); AppManager.runDebugCode(() -> waitShowTopBannerTime = 1000); } - /** * 初始化布局 */ @@ -404,7 +403,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); } - mLivePlayViewHolder.addToParent(); mLivePlayViewHolder.subscribeActivityLifeCycle(); mLivePlayViewHolder.setLoadViewListener(new LiveRoomPlayViewHolder.LoadingListener() { @@ -434,8 +432,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } //去除主播离开画面 - if (LivePlayKsyViewHolder.leave != null) { - LivePlayKsyViewHolder.leave.setVisibility(View.GONE); + if (LivePlayRyViewHolder.leave != null) { + LivePlayRyViewHolder.leave.setVisibility(View.GONE); } if (LivePlaySwViewHolder.leave != null) { LivePlaySwViewHolder.leave.setVisibility(View.GONE); diff --git a/live/src/main/res/layout/view_live_push_sw.xml b/live/src/main/res/layout/view_live_push_sw.xml index d60609cbe..b6d31d27b 100644 --- a/live/src/main/res/layout/view_live_push_sw.xml +++ b/live/src/main/res/layout/view_live_push_sw.xml @@ -115,12 +115,34 @@ android:layout_height="match_parent" /> + + + + + + + + + - - - - - - - - -