From 8b357233c2de9ea04bc192959e252749d039c3e9 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Fri, 30 Dec 2022 14:47:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=96=8B=E6=92=AD=E8=A8=AD=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=96=8B=E6=92=AD=E6=8E=A5=E5=8F=A3=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=88=86=E8=BE=A8=E7=8E=87=E8=A8=AD=E7=BD=AE=E5=8F=83?= =?UTF-8?q?=E6=95=B8,=E7=B6=B2=E7=B5=A1=E5=85=A7=E5=AD=98=E6=AA=A2?= =?UTF-8?q?=E6=B8=AC=E5=92=8C=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/utils/DeviceUtils.java | 2 + .../yunbao/common/views/HintCustomPopup.java | 70 +++++++++++ .../common/views/LiveClarityCustomPopup.java | 88 ++++++++++++-- .../src/main/res/layout/hint_custom_popup.xml | 71 +++++++++++ .../main/res/layout/input_custom_popup.xml | 4 +- common/src/main/res/values-en/strings.xml | 60 ++++++++++ common/src/main/res/values/strings.xml | 89 +++++++------- .../live/activity/LiveRyAnchorActivity.java | 25 ++++ .../live/views/LiveNewReadyRyViewHolder.java | 47 +++++++- .../live/views/LivePushRyViewHolder.java | 111 ++++++++++++------ 10 files changed, 477 insertions(+), 90 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/views/HintCustomPopup.java create mode 100644 common/src/main/res/layout/hint_custom_popup.xml diff --git a/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java b/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java index b80cfd3cb..d298abdac 100644 --- a/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java @@ -136,4 +136,6 @@ public class DeviceUtils { lastTotalRxBytes = nowTotalRxBytes; return speed; } + + } \ No newline at end of file diff --git a/common/src/main/java/com/yunbao/common/views/HintCustomPopup.java b/common/src/main/java/com/yunbao/common/views/HintCustomPopup.java new file mode 100644 index 000000000..874c3d1db --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/HintCustomPopup.java @@ -0,0 +1,70 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.text.TextUtils; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.core.CenterPopupView; +import com.yunbao.common.R; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +public class HintCustomPopup extends CenterPopupView { + private String title, contest; + + public HintCustomPopup(@NonNull Context context, String title, String contest) { + super(context); + this.title = title; + this.contest = contest; + } + + public HintCustomPopup(@NonNull Context context) { + super(context); + } + + // 返回自定义弹窗的布局 + @Override + protected int getImplLayoutId() { + return R.layout.hint_custom_popup; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + TextView titleText = findViewById(R.id.title); + TextView contestText = findViewById(R.id.contest); + if (!TextUtils.isEmpty(title)) { + titleText.setText(title); + } + if (!TextUtils.isEmpty(contest)) { + contestText.setText(contest); + } + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_ok), () -> { + if (callBack != null) { + callBack.onSure(); + } + dismiss(); + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_cancel), () -> { + if (callBack != null) { + callBack.onCancel(); + } + dismiss(); + }); + } + + private HintCustomCallBack callBack; + + public HintCustomPopup setCallBack(HintCustomCallBack callBack) { + this.callBack = callBack; + return this; + } + + public interface HintCustomCallBack { + void onSure(); + + void onCancel(); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java b/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java index 57e701de3..66c537258 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java @@ -1,20 +1,27 @@ package com.yunbao.common.views; import android.content.Context; +import android.os.Handler; +import android.text.format.Formatter; +import android.util.Log; import android.view.View; -import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.annotation.NonNull; +import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.BottomPopupView; import com.yunbao.common.R; -import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.views.weight.ViewClicksAntiShake; +import java.util.ArrayList; +import java.util.Collections; +import java.util.DoubleSummaryStatistics; +import java.util.List; + public class LiveClarityCustomPopup extends BottomPopupView implements View.OnClickListener { public static final int BAN_720 = 1; public static final int BAN_1080 = 2; @@ -91,16 +98,51 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl }); //高清 ViewClicksAntiShake.clicksAntiShake(lineHd, () -> { - selectClarity = 1; - selectClarity(selectClarity); - dismiss(); + String memorg = formateFileSize(Long.parseLong(DeviceUtils.getMemory(getContext()))); + if (Double.parseDouble(memorg) > 7 && netAverage > 100) { + selectClarity = 1; + selectClarity(selectClarity); + dismiss(); + } else { + new XPopup.Builder(getContext()) + .asCustom(new HintCustomPopup(getContext(), getContext().getString(R.string.net_hint), getContext().getString(R.string.net_hint2)).setCallBack(new HintCustomPopup.HintCustomCallBack() { + @Override + public void onSure() { + selectClarity = 1; + selectClarity(selectClarity); + dismiss(); + } + + @Override + public void onCancel() { + + } + })) + .show(); + } + }); //超高清 ViewClicksAntiShake.clicksAntiShake(lineFhd, () -> { - selectClarity = 2; - selectClarity(selectClarity); - dismiss(); + + new XPopup.Builder(getContext()) + .asCustom(new HintCustomPopup(getContext()).setCallBack(new HintCustomPopup.HintCustomCallBack() { + @Override + public void onSure() { + selectClarity = 2; + selectClarity(selectClarity); + dismiss(); + } + + @Override + public void onCancel() { + + } + })) + .show(); + + }); if (banSelect == BAN_720) { lineFhd.setEnabled(false); @@ -116,6 +158,12 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl } } + //调用系统函数,字符串转换 long -String KB/MB + private String formateFileSize(long size) { + String fileSize = Formatter.formatFileSize(getContext(), size); + return fileSize.substring(0, fileSize.length() - 3); + } + /** * 状态选择 * @@ -150,6 +198,28 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl } } + private Handler netHandler = new Handler(); + private Runnable netRunnable = new Runnable() { + @Override + public void run() { + if (netSpeeds.size() < 11) { + netSpeeds.add(DeviceUtils.getNetSpeed(getContext())); + netHandler.postDelayed(netRunnable, 100); + } else { + long min = Collections.min(netSpeeds); + long max = Collections.max(netSpeeds); + + DoubleSummaryStatistics statistics = netSpeeds.stream().mapToDouble(Number::doubleValue).summaryStatistics(); + netAverage = statistics.getAverage(); + Log.e("网络速度", "最大值:" + max + " 最小值:" + min + " 平均值:" + netAverage); + } + + } + }; + private List netSpeeds = new ArrayList<>(); + private double netAverage = 0; + private void initDate() { + netHandler.postDelayed(netRunnable, 100); } } diff --git a/common/src/main/res/layout/hint_custom_popup.xml b/common/src/main/res/layout/hint_custom_popup.xml new file mode 100644 index 000000000..8b7059e50 --- /dev/null +++ b/common/src/main/res/layout/hint_custom_popup.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/input_custom_popup.xml b/common/src/main/res/layout/input_custom_popup.xml index a7d7aeabb..82ed67cb9 100644 --- a/common/src/main/res/layout/input_custom_popup.xml +++ b/common/src/main/res/layout/input_custom_popup.xml @@ -46,10 +46,10 @@ android:layout_width="87dp" android:layout_height="33dp" android:layout_marginRight="7dp" - android:background="@mipmap/tipbox_btn_gray" + android:background="@drawable/backgroud_live_open_lfet" android:gravity="center" android:text="@string/cancel" - android:textColor="#B1B1B1" + android:textColor="#FFC621" android:textSize="14sp" /> diff --git a/common/src/main/res/values-en/strings.xml b/common/src/main/res/values-en/strings.xml index 6dda75eff..be4a81f99 100644 --- a/common/src/main/res/values-en/strings.xml +++ b/common/src/main/res/values-en/strings.xml @@ -934,4 +934,64 @@ Limited ride And limited avatar frame Blocking gift effects Blocking seat effects If you want to Minimize Play,\nYou can go to set the license. + + + In a batch + Chat + Congratulations %s have won %s in the Lucky Angel! The next lucky angel will be you! + Guardian group %s people + receive + 去完成 + 已領取 + 畫質選擇 + 更多設置 + 查看更多 + 礼物正在获取中... + 開始PK + 剩餘次數:%s + 是否確認進行多人PK(確認後扣除1點次數)當日剩餘次數: %s + 邀請\n主播 + 結束\nPK + 時間 %s + + 接受 + 拒绝 + 坚持拒绝 + 随机PK提示 + + 自動發言機器人設置 + 機器人開關 + 機器人名字設置 + 字數限制2-8個字 + 自動打招呼設置 + 已配置條數 + 自動發消息設置 + 前往設置 + 感謝送禮、PK開始、PK結束的自動機器人消息,\n暫不支持自定義。 + 添加內容 + 每隔一段時間,機器人自動隨機以下一句話發出。 + 填寫內容推薦,如:求送心願單、加粉絲團等 + 自動發言間隔時間(分鐘) + 最少間隔5分鐘1次 + 當有用戶進入直播間時,機器人會@該用戶並自動 + 隨機以下一句話。最少設置1條,最多20條。 + 機器人設置 + 高清 + 流暢 + 超高清 + 確定清晰度開播後,需要重新開播才能更改 + 開播設置確認 + 清晰度 + 直播頻道 + 開播 + 機器人 + 已設置 + 未設置 + + + 超高清提示 + 在網速不穩定的情況下,選擇超高清將會有可能導致直播間畫面卡頓,是否確認選擇? + 堅持選擇 + 網絡提示 + 系統監測到您的網絡不穩定,設備內存不足將會影響到您的直播流暢度,因此建議您選擇流暢清晰度。 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index baa28ab81..01237fa89 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -723,7 +723,7 @@ 心願單 娛樂整蠱 多人PK - 随机PK + 随机PK 語音連麥 周星榜 暫時離開 @@ -958,13 +958,13 @@ 換一批 聊聊天 想在其他APP上方也顯示小窗,\n可前往設置進行授權。 - 恭喜 %s 在幸運天使中抽中 %s!下一個幸運天使就是你哦! - 守護團%s人 - 領取 - 去完成 - 已領取 - 畫質選擇 - 更多設置 + 恭喜 %s 在幸運天使中抽中 %s!下一個幸運天使就是你哦! + 守護團%s人 + 領取 + 去完成 + 已領取 + 畫質選擇 + 更多設置 查看更多 礼物正在获取中... 開始PK @@ -974,39 +974,44 @@ 結束\nPK 時間 %s - 接受 - 拒绝 - 坚持拒绝 - 随机PK提示 + 接受 + 拒绝 + 坚持拒绝 + 随机PK提示 - 自動發言機器人設置 - 機器人開關 - 機器人名字設置 - 字數限制2-8個字 - 自動打招呼設置 - 已配置條數 - 自動發消息設置 - 前往設置 - 感謝送禮、PK開始、PK結束的自動機器人消息,\n暫不支持自定義。 - 添加內容 - 每隔一段時間,機器人自動隨機以下一句話發出。 - 填寫內容推薦,如:求送心願單、加粉絲團等 - 自動發言間隔時間(分鐘) - 最少間隔5分鐘1次 - 當有用戶進入直播間時,機器人會@該用戶並自動 - 隨機以下一句話。最少設置1條,最多20條。 - 機器人設置 - 高清 - 流暢 - 超高清 - 確定清晰度開播後,需要重新開播才能更改 - 開播設置確認 - 清晰度 - 直播頻道 - 開播 - 機器人 - 已設置 - 未設置 - - + 自動發言機器人設置 + 機器人開關 + 機器人名字設置 + 字數限制2-8個字 + 自動打招呼設置 + 已配置條數 + 自動發消息設置 + 前往設置 + 感謝送禮、PK開始、PK結束的自動機器人消息,\n暫不支持自定義。 + 添加內容 + 每隔一段時間,機器人自動隨機以下一句話發出。 + 填寫內容推薦,如:求送心願單、加粉絲團等 + 自動發言間隔時間(分鐘) + 最少間隔5分鐘1次 + 當有用戶進入直播間時,機器人會@該用戶並自動 + 隨機以下一句話。最少設置1條,最多20條。 + 機器人設置 + 高清 + 流暢 + 超高清 + 確定清晰度開播後,需要重新開播才能更改 + 開播設置確認 + 清晰度 + 直播頻道 + 開播 + 機器人 + 已設置 + 未設置 + + + 超高清提示 + 在網速不穩定的情況下,選擇超高清將會有可能導致直播間畫面卡頓,是否確認選擇? + 堅持選擇 + 網絡提示 + 系統監測到您的網絡不穩定,設備內存不足將會影響到您的直播流暢度,因此建議您選擇流暢清晰度。 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 f4f8b8178..782aa7d2e 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -112,10 +112,14 @@ import org.greenrobot.eventbus.ThreadMode; import java.io.File; import java.util.List; +import java.util.Map; import java.util.Random; import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; +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.base.RCRTCRect; import cn.rongcloud.rtc.base.RTCErrorCode; import io.rong.imlib.IRongCallback; @@ -208,6 +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); +// } +// } +// }); 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 202f538fe..f1b802e43 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java @@ -9,6 +9,8 @@ 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; import android.view.inputmethod.InputMethodManager; @@ -32,6 +34,7 @@ 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.DialogUitl; import com.yunbao.common.utils.L; import com.yunbao.common.utils.ProcessImageUtil; @@ -60,9 +63,15 @@ 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; public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnClickListener { @@ -202,12 +211,16 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl } //设置清晰度 +// DeviceUtils.getMemory(mContext); //获取可用内存 +// DeviceUtils.getNetSpeed(mContext);//获取当前上传网速 +// Log.e("网速和内存", "内存:" + + " 网速:" + DeviceUtils.getNetSpeed(mContext)); + selectClarity = IMLoginManager.get(mContext).getSelectClarity(); setSelectClarity(selectClarity); ViewClicksAntiShake .clicksAntiShake( findViewById(R.id.btn_live_clarity), () -> { - LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, selectClarity); + LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, IMLoginManager.get(mContext).getSelectClarity()); new XPopup.Builder(mContext) .setPopupCallback(new XPopupCallback() { @Override @@ -261,6 +274,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl } private void setSelectClarity(int selectClarity) { + this.selectClarity = selectClarity; IMLoginManager.get(mContext).setSelectClarity(selectClarity); switch (selectClarity) { @@ -280,12 +294,43 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl if (liveOpenCustomPopup != null) { liveOpenCustomPopup.setSelectClarity(selectClarity); } + //設置開播分辨率 + RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; + int minRate = 200; + int maxRate = 900; + switch (selectClarity) { + case 0: + rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; + minRate = 200; + maxRate = 900; + break; + case 1: + rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280; + minRate = 250; + maxRate = 2200; + break; + case 2: + rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920; + minRate = 400; + maxRate = 4000; + break; + } + RCRTCVideoStreamConfig config = + RCRTCVideoStreamConfig.Builder.create() + .setMinRate(minRate) + .setMaxRate(maxRate) + .setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_15) + .setVideoResolution(rcrtcVideoResolution) + .build(); + RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config); } public void setManager(FaceManager manager) { this.manager = manager; } + + @Override public void onClick(View v) { if (!canClick()) { 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 6d0da307f..b7fc7d1cb 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java @@ -25,7 +25,6 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.alibaba.fastjson.JSONObject; -import com.makeramen.roundedimageview.RoundedImageView; import com.tencent.liteav.device.TXDeviceManager; import com.tencent.rtmp.ITXLivePushListener; import com.tencent.rtmp.TXLiveConstants; @@ -35,11 +34,11 @@ 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.FollowEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; 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.DialogUitl; @@ -72,12 +71,14 @@ 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; @@ -114,11 +115,11 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX @Subscribe(threadMode = ThreadMode.MAIN) public void onUPAnchorInfo(AnchorInfoEvent e) { if (e != null) { - if(e.isClear()==false) { + if (e.isClear() == false) { tv_avatarOther_name.setText(e.getUserNiceName()); ImgLoader.displayAvatar(mContext, e.getAvatar(), avatarOther); goto_room_view.setVisibility(View.VISIBLE); - }else{ + } else { goto_room_view.setVisibility(View.GONE); } @@ -417,7 +418,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX @Override public void onConfirmClick(Dialog dialog, String content) { //断开连麦 - LiveRyAnchorActivity.isDRPK=0; + LiveRyAnchorActivity.isDRPK = 0; HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout") .execute(new HttpCallback() { @Override @@ -560,16 +561,37 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX RCRTCEngine.getInstance().init(contexts, config); RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC_HIGH, RCRTCParamsType.AudioScenario.MUSIC_CHATROOM); + //設置開播分辨率 + RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; + int minRate = 200; + int maxRate = 900; + switch (IMLoginManager.get(mContext).getSelectClarity()) { + case 0: + rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; + minRate = 200; + maxRate = 900; + break; + case 1: + rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280; + minRate = 250; + maxRate = 2200; + break; + case 2: + rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920; + minRate = 400; + maxRate = 4000; + break; + } RCRTCVideoStreamConfig videoConfigBuilder = RCRTCVideoStreamConfig.Builder.create() //设置分辨率 - .setVideoResolution(RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_640) + .setVideoResolution(rcrtcVideoResolution) //设置帧率 .setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_24) //设置最小码率,480P下推荐200 - .setMinRate(250) + .setMinRate(minRate) //设置最大码率,480P下推荐900 - .setMaxRate(5000) + .setMaxRate(maxRate) .build(); // 创建本地视频显示视图 @@ -595,7 +617,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX mPreView.addView(rongRTCVideoView); tencentTRTCBeautyManager = new TencentTRTCBeautyManager(mContext); - //加入房间成功后可以通过 RCRTCLocalUser 对象发布本地默认音视频流,包括:麦克风采集的音频和摄像头采集的视频。 RCRTCEngine.getInstance().getDefaultVideoStream().setEncoderMirror(true); if (rtcRoom == null || rtcRoom.getLocalUser() == null) { @@ -615,20 +636,13 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX room.registerRoomListener(roomEventsListener); //美颜 - new Handler(Looper.getMainLooper()).post(new Runnable() { - public void run() { - //旧美颜不需要了 - /*RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(new IRCRTCVideoOutputFrameListener() { - @Override - public RCRTCVideoFrame processVideoFrame(RCRTCVideoFrame rtcVideoFrame) { - // 使用数据进行美颜/录像等处理后,需要把数据再返回给 SDK 做发送。 - rtcVideoFrame.setTextureId(tencentTRTCBeautyManager.renderWithTexture(rtcVideoFrame.getTextureId(), rtcVideoFrame.getWidth(), rtcVideoFrame.getHeight(), false)); - return rtcVideoFrame; - } - });*/ - - } - }); +// new Handler(Looper.getMainLooper()).post(new Runnable() { +// public void run() { +// //旧美颜不需要了 +// +// +// } +// }); } @Override @@ -716,24 +730,38 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX 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 = 720; - int height = 1280; + + //推荐宽、高、帧率参数值可以通过默认视频流的配置获取,也可以根据实际需求来自定义设置 + //如不设置宽高值则服务端将使用默认宽高 360 * 640 + //例:发布的视频分辨率为720 * 1280,如果不设置则观众端看到的视频分辨率为 360 * 640, + //所以如果想让观众端看到的视频分辨率和发布视频分辨率一致,则应从发布的视频流中获取分辨率配置并设置到 mediaConfig 中 + //設置開播分辨率 + //設置開播分辨率 + RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; + int minRate = 200; + int maxRate = 900; + switch (IMLoginManager.get(mContext).getSelectClarity()) { + case 0: + rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848; + break; + case 1: + rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280; + break; + case 2: + rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920; + break; + } + int width = rcrtcVideoResolution.getWidth(); + int height = rcrtcVideoResolution.getHeight(); normal.setWidth(width); //视频宽 normal.setHeight(height); //视频高 - normal.setFps(25); //视频帧率 - + normal.setFps(15); //视频帧率 + videoConfig.setVideoLayout(normal); //2. 合流画布设置 //(请参照画布和声音配置示例代码) //3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准),设置每个视频流小窗口的坐标及宽高 @@ -747,6 +775,16 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX videoLayout1.setY(0); //Y 坐标 videoLayout1.setWidth(720); // 视频窗口的宽 videoLayout1.setHeight(1280); // 视频窗口的高 + 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 @@ -762,6 +800,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX }); } + } @Override