diff --git a/common/src/main/java/com/yunbao/common/event/LivePushRyEvent.java b/common/src/main/java/com/yunbao/common/event/LivePushRyEvent.java new file mode 100644 index 000000000..7ead2123a --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/LivePushRyEvent.java @@ -0,0 +1,6 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +public class LivePushRyEvent extends BaseModel { +} diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 782aa7d2e..1c07161e5 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -212,27 +212,27 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl Bus.getOn(this); Intent intent = getIntent(); initFaceManager(); -// RCRTCEngine.getInstance().registerStatusReportListener(new IRCRTCStatusReportListener() { -// -// @Override -// public void onConnectionStats(StatusReport statusReport) { -// //视频发送信息 -// for (Map.Entry entry : statusReport.statusVideoSends.entrySet()) { -// StatusBean statusBean = entry.getValue(); -// //获取userID -// String userId = statusBean.uid; -// //获取视频 宽x高@帧率 -// String resolution = statusBean.frameWidth + "x" + statusBean.frameHeight + "@" + statusBean.frameRate; -// //获取码率 -// long bitRate = statusBean.bitRate; -// //丢包率 -// long lossRate = statusBean.packetLostRate; -// //带宽 -// String googAvailableSendBandwidth = statusReport.googAvailableSendBandwidth; -// Log.e("网速和内存", "码率:" +bitRate+ " 丢包率:" + lossRate+" 带宽:"+googAvailableSendBandwidth); -// } -// } -// }); + RCRTCEngine.getInstance().registerStatusReportListener(new IRCRTCStatusReportListener() { + + @Override + public void onConnectionStats(StatusReport statusReport) { + //视频发送信息 + for (Map.Entry entry : statusReport.statusVideoSends.entrySet()) { + StatusBean statusBean = entry.getValue(); + //获取userID + String userId = statusBean.uid; + //获取视频 宽x高@帧率 + String resolution = statusBean.frameWidth + "x" + statusBean.frameHeight + "@" + statusBean.frameRate; + //获取码率 + long bitRate = statusBean.bitRate; + //丢包率 + long lossRate = statusBean.packetLostRate; + //带宽 + String googAvailableSendBandwidth = statusReport.googAvailableSendBandwidth; + Log.e("网速和内存", "获取视频:" +resolution+ " 丢包率:" + lossRate+" 带宽:"+googAvailableSendBandwidth); + } + } + }); leave_img = findViewById(R.id.leave_img); mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY); mLiveKsyConfigBean = intent.getParcelableExtra(Constants.LIVE_KSY_CONFIG); diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java index d99df4d6f..9312232bc 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java @@ -9,7 +9,6 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; -import android.text.format.Formatter; import android.util.Log; import android.view.View; import android.view.ViewGroup; @@ -29,12 +28,13 @@ import com.yunbao.common.Constants; import com.yunbao.common.bean.LiveClassBean; import com.yunbao.common.bean.LiveRoomTypeBean; import com.yunbao.common.bean.UserBean; +import com.yunbao.common.event.LivePushRyEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.ImageResultCallback; import com.yunbao.common.manager.IMLoginManager; -import com.yunbao.common.utils.DeviceUtils; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.L; import com.yunbao.common.utils.ProcessImageUtil; @@ -63,12 +63,8 @@ import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.io.File; -import java.util.Map; import cn.rongcloud.rtc.api.RCRTCEngine; -import cn.rongcloud.rtc.api.callback.IRCRTCStatusReportListener; -import cn.rongcloud.rtc.api.report.StatusBean; -import cn.rongcloud.rtc.api.report.StatusReport; import cn.rongcloud.rtc.api.stream.RCRTCCameraOutputStream; import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig; import cn.rongcloud.rtc.base.RCRTCParamsType; @@ -215,8 +211,8 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl // DeviceUtils.getNetSpeed(mContext);//获取当前上传网速 // Log.e("网速和内存", "内存:" + + " 网速:" + DeviceUtils.getNetSpeed(mContext)); - selectClarity = IMLoginManager.get(mContext).getSelectClarity(); - setSelectClarity(selectClarity); + IMLoginManager.get(mContext).setSelectClarity(selectClarity); + setSelectClarity(IMLoginManager.get(mContext).getSelectClarity()); ViewClicksAntiShake .clicksAntiShake( findViewById(R.id.btn_live_clarity), () -> { @@ -327,6 +323,9 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl .setVideoResolution(rcrtcVideoResolution) .build(); RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config); + Log.e("切换分辨率", "时间戳" + System.currentTimeMillis()); + //重新发布一下流 + Bus.get().post(new LivePushRyEvent()); } public void setManager(FaceManager manager) { @@ -334,7 +333,6 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl } - @Override public void onClick(View v) { if (!canClick()) { @@ -364,7 +362,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl return; } // startLive(); - liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, selectClarity, classBean, liveRoomTypeBean) + liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, IMLoginManager.get(mContext).getSelectClarity(), classBean, liveRoomTypeBean) .setCallBack(new LiveOpenCustomPopup.LiveOpenCallBack() { @Override @@ -384,7 +382,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, IMLoginManager.get(mContext).getSelectClarity(), - IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false); + IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false); new XPopup.Builder(mContext) .setPopupCallback(new XPopupCallback() { @Override @@ -821,7 +819,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl return; } String title = mEditTitle.getText().toString().trim(); - LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, selectClarity + 1, new HttpCallback() { + LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, IMLoginManager.get(mContext).getSelectClarity() + 1, new HttpCallback() { @Override public void onSuccess(int code, String msg, final String[] info) { if (code == 0 && info.length > 0) { diff --git a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java index abe5d0ef7..e4c2af532 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java @@ -34,6 +34,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.event.AnchorInfoEvent; +import com.yunbao.common.event.LivePushRyEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; @@ -41,6 +42,7 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.RandomPkManager; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.L; @@ -71,14 +73,12 @@ import cn.rongcloud.rtc.api.RCRTCRoomConfig; import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback; import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener; -import cn.rongcloud.rtc.api.callback.IRCRTCVideoOutputFrameListener; import cn.rongcloud.rtc.api.stream.RCRTCInputStream; import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo; import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig; import cn.rongcloud.rtc.api.stream.RCRTCVideoView; import cn.rongcloud.rtc.base.RCRTCParamsType; import cn.rongcloud.rtc.base.RCRTCRoomType; -import cn.rongcloud.rtc.base.RCRTCVideoFrame; import cn.rongcloud.rtc.base.RTCErrorCode; import cn.rongcloud.rtc.core.CameraVideoCapturer; import cn.rongcloud.rtc.core.RendererCommon; @@ -396,6 +396,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX @Override public void init() { super.init(); + Bus.getOn(this); mPreView = (FrameLayout) findViewById(R.id.camera_preview); mPreView1 = (FrameLayout) findViewById(R.id.camera_preview1); dr1_preview = (FrameLayout) findViewById(R.id.dr1_preview); @@ -775,17 +776,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX videoLayout1.setY(0); //Y 坐标 videoLayout1.setWidth(720); // 视频窗口的宽 videoLayout1.setHeight(1280); // 视频窗口的高 - //不能设置setVideoFrameListener,会影响到美颜 - /* RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(new IRCRTCVideoOutputFrameListener() { - @Override - public RCRTCVideoFrame processVideoFrame(RCRTCVideoFrame rtcVideoFrame) { - // 使用数据进行美颜/录像等处理后,需要把数据再返回给 SDK 做发送。 -// rtcVideoFrame.setTextureId(tencentTRTCBeautyManager.renderWithTexture(rtcVideoFrame.getTextureId(), rtcVideoFrame.getWidth(), rtcVideoFrame.getHeight(), false)); - Log.e("视频流", "Width---------------------" + rtcVideoFrame.getWidth()); - Log.e("视频流", "Height---------------------" + rtcVideoFrame.getHeight()); - return rtcVideoFrame; - } - });*/ //2. 合流画布设置 rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { @Override @@ -858,6 +848,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX @Override public void release() { super.release(); + Bus.getOff(this); LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM); rtcRoom = null; } @@ -913,4 +904,19 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX return ((LiveActivity) mContext).getTxAppId(); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void setSelectClarity(LivePushRyEvent event) { + if (rtcRoom != null) + rtcRoom.getLocalUser().publishDefaultLiveStreams(new IRCRTCResultDataCallback() { + @Override + public void onSuccess(RCRTCLiveInfo rcrtcLiveInfo1) { + rcrtcLiveInfo = rcrtcLiveInfo1; + } + + @Override + public void onFailed(RTCErrorCode rtcErrorCode) { + Log.e("ry", "rtcErrorCode" + rtcErrorCode); + } + }); + } }