fix[声望升级-设置竖屏]

This commit is contained in:
Martin 2024-06-01 15:21:23 +08:00
parent 6132338c6c
commit efce2ad93c
4 changed files with 23 additions and 48 deletions

View File

@ -91,7 +91,7 @@ public class SWManager extends BaseCacheManager {
uid = Integer.parseInt(strUid); uid = Integer.parseInt(strUid);
} }
try { try {
if(mRtcEngine==null){ if (mRtcEngine == null) {
// 创建 RtcEngineConfig 对象并进行配置 // 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig(); RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext; config.mContext = mContext;
@ -111,21 +111,20 @@ public class SWManager extends BaseCacheManager {
mRtcEngine.startPreview(); mRtcEngine.startPreview();
cfg = new VideoEncoderConfiguration(); cfg = new VideoEncoderConfiguration();
//设置默认分辨率 //设置默认分辨率
switch (IMLoginManager.get(mContext).getSelectClarity()) { VideoEncoderConfiguration.VideoDimensions videoDimensions = new VideoEncoderConfiguration.VideoDimensions();
case 0: videoDimensions.width = 720;
cfg.dimensions = VideoEncoderConfiguration.VD_840x480; videoDimensions.height = 1280;
break; cfg.dimensions = videoDimensions;
case 1:
cfg.dimensions = VideoEncoderConfiguration.VD_1280x720;
break;
case 2:
cfg.dimensions = VideoEncoderConfiguration.VD_1920x1080;
break;
}
cfg.frameRate = 20; cfg.frameRate = 20;
cfg.bitrate = 0; cfg.bitrate = 0;
cfg.mirrorMode = VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED; //镜像 //镜像
cfg.mirrorMode = VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED;
//设置竖屏
cfg.orientationMode = VideoEncoderConfiguration.ORIENTATION_MODE.ORIENTATION_MODE_FIXED_PORTRAIT;
mRtcEngine.setVideoEncoderConfiguration(cfg); mRtcEngine.setVideoEncoderConfiguration(cfg);
// 创建一个 SurfaceView 对象并将其作为 FrameLayout 的子对象 // 创建一个 SurfaceView 对象并将其作为 FrameLayout 的子对象
@ -158,33 +157,9 @@ public class SWManager extends BaseCacheManager {
* 2人连麦PK:360x640 * 2人连麦PK:360x640
* 3人连麦PK:左侧主播 360x640,右侧两个主播 360x320 * 3人连麦PK:左侧主播 360x640,右侧两个主播 360x320
* 4人连麦PK:360X320 * 4人连麦PK:360X320
*
* @param selectClarity * @param selectClarity
*/ */
public void setDimensions(int selectClarity) {
if (cfg != null && mRtcEngine != null) {
switch (selectClarity) {
case 0:
cfg.dimensions = VideoEncoderConfiguration.VD_840x480;
L.eSw("VideoEncoderConfiguration.VD_840x480");
break;
case 1:
cfg.dimensions = VideoEncoderConfiguration.VD_1280x720;
L.eSw("VideoEncoderConfiguration.VD_1280x720");
break;
case 2:
cfg.dimensions = VideoEncoderConfiguration.VD_1920x1080;
L.eSw("VideoEncoderConfiguration.VD_1920x1080");
break;
case 3:
cfg.dimensions = VideoEncoderConfiguration.VD_320x240;
L.eSw("VideoEncoderConfiguration.VD_320x240");
break;
}
mRtcEngine.setVideoEncoderConfiguration(cfg);
}
}
public void setDrPkNumClarity(int selectClarity) { public void setDrPkNumClarity(int selectClarity) {
if (cfg != null && mRtcEngine != null) { if (cfg != null && mRtcEngine != null) {
VideoEncoderConfiguration.VideoDimensions videoDimensions = new VideoEncoderConfiguration.VideoDimensions(); VideoEncoderConfiguration.VideoDimensions videoDimensions = new VideoEncoderConfiguration.VideoDimensions();
@ -211,9 +186,6 @@ public class SWManager extends BaseCacheManager {
} }
/** /**
* 设置镜像模式 * 设置镜像模式
*/ */
@ -344,7 +316,7 @@ public class SWManager extends BaseCacheManager {
@Override @Override
public void onVideoSizeChanged(Constants.VideoSourceType source, int uid, int width, int height, int rotation) { public void onVideoSizeChanged(Constants.VideoSourceType source, int uid, int width, int height, int rotation) {
super.onVideoSizeChanged(source, uid, width, height, rotation); super.onVideoSizeChanged(source, uid, width, height, rotation);
L.eSw("uid:"+uid+"\nwidth:"+width+"\nheight:"+height); L.eSw("uid:" + uid + "\nwidth:" + width + "\nheight:" + height);
} }
}); });
} }
@ -358,7 +330,7 @@ public class SWManager extends BaseCacheManager {
* @param toUid * @param toUid
* @param channelName * @param channelName
*/ */
public void joinChannelDrEx(FrameLayout frameLayout, String strUid, String token, String toUid, String channelName,int position) { public void joinChannelDrEx(FrameLayout frameLayout, String strUid, String token, String toUid, String channelName, int position) {
int tempUid; int tempUid;
if (StringUtil.isEmpty(strUid)) { if (StringUtil.isEmpty(strUid)) {
tempUid = 0; tempUid = 0;
@ -532,10 +504,13 @@ public class SWManager extends BaseCacheManager {
} }
} }
public interface onDrPkJoinSuccessListener{ public interface onDrPkJoinSuccessListener {
void joinSuccess1(); void joinSuccess1();
void joinSuccess2(); void joinSuccess2();
void joinSuccess3(); void joinSuccess3();
void joinSuccess4(); void joinSuccess4();
} }

View File

@ -1010,7 +1010,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
} }
JSONObject obj = JSONObject.parseObject(info[0]); JSONObject obj = JSONObject.parseObject(info[0]);
drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class); drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
SWManager.get().setDimensions(3);//加入成功后将分别率设置为 VD_320x240 SWManager.get().setDrPkNumClarity(3);//加入成功后将分别率设置为 VD_320x240
//将自己从多人pk列表里剔除 //将自己从多人pk列表里剔除
int removeIndex = -1; int removeIndex = -1;
for (int i = 0; i < drPkbeans.size(); i++) { for (int i = 0; i < drPkbeans.size(); i++) {

View File

@ -345,7 +345,7 @@ public class SocketSwClient {
// LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview(); // LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW)); Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW));
} }
SWManager.get().setDimensions(0);//退出直播间将分别率设置为 VD_840x480 SWManager.get().setDrPkNumClarity(1);//退出直播间将分别率设置为 VD_840x480
//創建了多人房間 //創建了多人房間
} else if (action3 == 3) { } else if (action3 == 3) {
L.eSw("創建了多人房間action3 == 3"); L.eSw("創建了多人房間action3 == 3");

View File

@ -230,7 +230,7 @@ public class LiveNewReadySwViewHolder extends AbsViewHolder implements View.OnCl
// Log.e("网速和内存", "内存:" + + " 网速:" + DeviceUtils.getNetSpeed(mContext)); // Log.e("网速和内存", "内存:" + + " 网速:" + DeviceUtils.getNetSpeed(mContext));
IMLoginManager.get(mContext).setSelectClarity(selectClarity); IMLoginManager.get(mContext).setSelectClarity(selectClarity);
setSelectClarity(IMLoginManager.get(mContext).getSelectClarity()); //setSelectClarity(IMLoginManager.get(mContext).getSelectClarity());
ViewClicksAntiShake ViewClicksAntiShake
.clicksAntiShake( .clicksAntiShake(
findViewById(R.id.btn_live_clarity), () -> { findViewById(R.id.btn_live_clarity), () -> {
@ -324,7 +324,7 @@ public class LiveNewReadySwViewHolder extends AbsViewHolder implements View.OnCl
if (liveOpenCustomPopup != null) { if (liveOpenCustomPopup != null) {
liveOpenCustomPopup.setSelectClarity(selectClarity); liveOpenCustomPopup.setSelectClarity(selectClarity);
} }
SWManager.get().setDimensions(selectClarity); //SWManager.get().setDimensions(selectClarity);
Log.e("切换分辨率", "时间戳" + System.currentTimeMillis()); Log.e("切换分辨率", "时间戳" + System.currentTimeMillis());
//重新发布一下流 //重新发布一下流
Bus.get().post(new LivePushRyEvent()); Bus.get().post(new LivePushRyEvent());