修改融云合流不成功的问题,退出画面有问题

This commit is contained in:
18142669586 2023-08-09 14:13:52 +08:00
parent d899975495
commit 7a26e81f67
2 changed files with 272 additions and 196 deletions

View File

@ -1,5 +1,6 @@
package com.yunbao.live.presenter;
import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
@ -36,6 +37,7 @@ import android.widget.TextView;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.ViewUtils;
import com.tencent.trtc.TRTCCloud;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.LiveInfoModel;
@ -594,46 +596,46 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void onSuccess() {
Log.i("ry", "订阅资源成功");
RCRTCMixConfig config = new RCRTCMixConfig();
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); //视频帧率
RCRTCMixConfig config = new RCRTCMixConfig();
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); //视频帧率
//1. 设置自适应合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
//2. 合流画布设置
if (rcrtcLiveInfo != null) {
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功" + u.getId());
}
//1. 设置自适应合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
//2. 合流画布设置
if (rcrtcLiveInfo != null) {
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功" + u.getId());
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
}
});
} else {
Log.w("PkDebug", "PK合流失败,rcrtcLiveInfo为空");
}
}
});
} else {
Log.w("PkDebug", "PK合流失败,rcrtcLiveInfo为空");
}
}
@Override
@ -714,46 +716,45 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
inputStreamList.add(stream);
RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig);
RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig);
//视频输出配置
RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig();
mediaConfig.setVideoConfig(videoConfig);
RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig();
mediaConfig.setVideoConfig(videoConfig);
//大流视频的输出参数
RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout normal = new RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout();
videoConfig.setVideoLayout(normal);
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); //视频帧率
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); //视频帧率
//1. 设置自适应合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
//2. 合流画布设置
if (rcrtcLiveInfo == null) {
Log.w("PkDebug", "PK合流失败,rcrtcLiveInfo为空");
//1. 设置自适应合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
//2. 合流画布设置
if (rcrtcLiveInfo == null) {
Log.w("PkDebug", "PK合流失败,rcrtcLiveInfo为空");
}
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功13");
}
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功13");
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
}
});
}
});
}
}
//开始订阅资源
@ -881,42 +882,42 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
Log.i("ry", "订阅资源成功");
List<RCRTCStream> streams = new ArrayList<>();
streams.add(RCRTCEngine.getInstance().getDefaultVideoStream());
RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig);
RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig);
//视频输出配置
RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig();
mediaConfig.setVideoConfig(videoConfig);
RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig();
mediaConfig.setVideoConfig(videoConfig);
//大流视频的输出参数
RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout normal = new RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout();
videoConfig.setVideoLayout(normal);
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); //视频帧率
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); //视频帧率
//1. 设置自适应合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
//2. 合流画布设置
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功14");
}
//1. 设置自适应合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
//2. 合流画布设置
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功14");
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
}
});
}
});
}
@Override
@ -1128,76 +1129,84 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void leaveDRRoom() {
//清理PK上面对方的头像
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
Log.e("ry", "退出多人OKKK" + inputStreamList.size());
isDRPK = 0;
if (btn_close != null) {
btn_close.setVisibility(View.GONE);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
if (btn_close != null) {
btn_close.setVisibility(View.GONE);
}
}
});
for (int i = 0; i < inputStreamList.size(); i++) {
Log.e("ry", "退出多人ID" + inputStreamList.get(i).getUserId());
//退出副房间
RCRTCEngine.getInstance().leaveOtherRoom(inputStreamList.get(i).getUserId(), true, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "退出多人成功");
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
Log.e("ry", "退出多人失败" + rtcErrorCode);
}
});
}
RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig);
RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig);
//视频输出配置
RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig();
mediaConfig.setVideoConfig(videoConfig);
RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig();
mediaConfig.setVideoConfig(videoConfig);
//大流视频的输出参数
RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout normal = new RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout();
videoConfig.setVideoLayout(normal);
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 = 720;
int height = 1280;
normal.setWidth(width); //视频宽
normal.setHeight(height); //视频高
normal.setFps(fps); //视频帧率
RCRTCVideoStreamConfig defaultVideoConfig = RCRTCEngine.getInstance().getDefaultVideoStream().getVideoConfig();
int fps = defaultVideoConfig.getVideoFps().getFps();
int width = 720;
int height = 1280;
normal.setWidth(width); //视频宽
normal.setHeight(height); //视频高
normal.setFps(fps); //视频帧率
//2. 合流画布设置
//(请参照画布和声音配置示例代码)
//3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准)设置每个视频流小窗口的坐标及宽高
ArrayList<RCRTCMixConfig.CustomLayoutList.CustomLayout> list = new ArrayList<>();
config.setCustomLayouts(list);
//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(720); // 视频窗口的宽
videoLayout1.setHeight(1280); // 视频窗口的高
//2. 合流画布设置
if (rcrtcLiveInfo != null) {
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功15");
}
//2. 合流画布设置
//(请参照画布和声音配置示例代码)
//3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准)设置每个视频流小窗口的坐标及宽高
ArrayList<RCRTCMixConfig.CustomLayoutList.CustomLayout> list = new ArrayList<>();
config.setCustomLayouts(list);
//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(720); // 视频窗口的宽
videoLayout1.setHeight(1280); // 视频窗口的高
//2. 合流画布设置
if (rcrtcLiveInfo != null) {
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功15");
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
}
});
}
});
}
@ -1943,32 +1952,32 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}
//开始订阅资源
rtcRoom.getLocalUser().subscribeStreams(inputStreamList1, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.i("ry", "订阅资源成功");
}
//开始订阅资源
rtcRoom.getLocalUser().subscribeStreams(inputStreamList1, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.i("ry", "订阅资源成功");
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
Log.i("ry", "订阅资源失败: " + rtcErrorCode.getReason());
}
});
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
Log.i("ry", "订阅资源失败: " + rtcErrorCode.getReason());
}
});
//2. 合流画布设置
rcrtcLiveInfo.setMixConfig(create_Custom_MixConfig(false, inputStreamList), new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", inputStreamList.size() + "混成功" + u);
}
//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 errorCode) {
Log.e("ry", "混失败" + errorCode);
}
});
}
});
}
}
@ -2179,11 +2188,12 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
/**
* 修改最终PK数据
* @param leftGift 左边数据
*
* @param leftGift 左边数据
* @param rightGift 右边数据
* @param bean 排位数据
* @param bean 排位数据
*/
public void onPkProgressEnd(long leftGift, long rightGift,LivePKUserListBean bean) {
public void onPkProgressEnd(long leftGift, long rightGift, LivePKUserListBean bean) {
if (mLiveLinkMicPkViewHolder != null) {
mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean, true);
}
@ -2321,44 +2331,44 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
btn_close.setVisibility(View.GONE);
}
// inputStreamList.clear();
RCRTCMixConfig config = new RCRTCMixConfig();
RCRTCMixConfig.MediaConfig mediaConfig = new RCRTCMixConfig.MediaConfig();
config.setMediaConfig(mediaConfig);
//视频输出配置
RCRTCMixConfig.MediaConfig.VideoConfig videoConfig = new RCRTCMixConfig.MediaConfig.VideoConfig();
mediaConfig.setVideoConfig(videoConfig);
RCRTCMixConfig config = new RCRTCMixConfig();
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);
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 = 720;
int height = 1280;
normal.setWidth(width); //视频宽
normal.setHeight(height); //视频高
normal.setFps(fps); //视频帧率
RCRTCVideoStreamConfig defaultVideoConfig = RCRTCEngine.getInstance().getDefaultVideoStream().getVideoConfig();
int fps = defaultVideoConfig.getVideoFps().getFps();
int width = 720;
int height = 1280;
normal.setWidth(width); //视频宽
normal.setHeight(height); //视频高
normal.setFps(fps); //视频帧率
//1. 设置自适应合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
//2. 合流画布设置
if (rcrtcLiveInfo != null) {
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功16");
}
//1. 设置自适应合流布局模式
config.setLayoutMode(RCRTCMixConfig.MixLayoutMode.ADAPTIVE);
//2. 合流画布设置
if (rcrtcLiveInfo != null) {
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "混成功16");
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "混失败" + errorCode);
}
});
}
}
});
}
runOnUiThread(new Runnable() {
public void run() {

View File

@ -1,6 +1,7 @@
package com.yunbao.live.views;
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
import static com.yunbao.live.activity.LiveActivity.mLiveRyLinkMicPkPresenter;
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList;
@ -55,6 +56,7 @@ import com.yunbao.live.http.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.momo.TencentTRTCBeautyManager;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSendBean;
import org.greenrobot.eventbus.EventBus;
@ -82,6 +84,10 @@ import cn.rongcloud.rtc.base.RCRTCRoomType;
import cn.rongcloud.rtc.base.RTCErrorCode;
import cn.rongcloud.rtc.core.CameraVideoCapturer;
import cn.rongcloud.rtc.core.RendererCommon;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.message.TextMessage;
/**
* Created by cxf on 2018/10/7.
@ -116,7 +122,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
//修改上面主播的头像
@Subscribe(threadMode = ThreadMode.MAIN)
public void onUPAnchorInfo(AnchorInfoEvent e) {
Log.i(TAG, "onUPAnchorInfo: "+e);
Log.i(TAG, "onUPAnchorInfo: " + e);
if (e != null) {
if (!e.isClear()) {
tv_avatarOther_name.setText(e.getUserNiceName());
@ -218,10 +224,54 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override
public void run() {
Log.e("ry", inviterRoomId + extra + "Request");
UserBean userBean = new UserBean();
userBean.setId(inviterRoomId);
if (extra.equals(SOCKET_LIVE_DRPK)) {
//收到邀请这个时候正在PK或连麦中 自动拒绝对方
if (isPking() == true) {
rtcRoom.getLocalUser().responseJoinOtherRoom(userBean.getId(), userBean.getId(), false, false, "extra", new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode errorCode) {
}
@Override
public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LINK_MIC_PK)
.param("action", 8);
msg1.create();
String targetId = userBean.getId();
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(io.rong.imlib.model.Message message) {
}
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("ry", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
}
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("ry", "发送失敗" + userBean.getId());
}
});
}
});
}else if (extra.equals(SOCKET_LIVE_DRPK)) {
//收到多人PK申请
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean);
@ -354,7 +404,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override
public void onError(String error) {
ToastUtil.show( R.string.net_error);
ToastUtil.show(R.string.net_error);
}
});
@ -381,6 +431,22 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override
public void onFinishOtherRoom(String roomId, String userId) {
super.onFinishOtherRoom(roomId, userId);
Log.e("ry",roomId+"房间是"+userId);
RCRTCEngine.getInstance().leaveOtherRoom(roomId, true, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry",roomId+"退出啊房间成功"+userId);
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry",roomId+"退出啊房间失败"+userId);
}
});
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.leaveDRRoom();
}