diff --git a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index cb0e8a0c6..17ca385cc 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -55,7 +55,9 @@ public class IMLoginManager extends BaseCacheManager { * @return */ public int getSelectClarity() { - return getInt(SELECT_CLARITY, 1); + + return getInt(SELECT_CLARITY, 0); + } public boolean isHint() { 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/java/com/yunbao/common/views/LiveRobotMessageCustomPopup.java b/common/src/main/java/com/yunbao/common/views/LiveRobotMessageCustomPopup.java index f4652a3d6..7a84549d7 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveRobotMessageCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveRobotMessageCustomPopup.java @@ -111,21 +111,28 @@ public class LiveRobotMessageCustomPopup extends BottomPopupView { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { - // 修改助手名字 - LiveNetManager.get(getContext()) - .setAiRobotDate("ai_time", robotNameSetting.getText().toString(), new HttpCallback() { - @Override - public void onSuccess(HttpCallbackModel data) { - robotNameSetting.setVisibility(GONE); - robotTime.setVisibility(VISIBLE); - robotTime.setText(robotNameSetting.getText().toString()); - } + String time = robotNameSetting.getText().toString(); + int timeInt = Integer.parseInt(time); + if (timeInt > 5) { + // 修改助手名字 + LiveNetManager.get(getContext()) + .setAiRobotDate("ai_time", time, new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + robotNameSetting.setVisibility(GONE); + robotTime.setVisibility(VISIBLE); + robotTime.setText(robotNameSetting.getText().toString()); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } else { + ToastUtil.show(R.string.robot_minimum_interval); + } - @Override - public void onError(String error) { - ToastUtil.show(error); - } - }); } return false; @@ -136,7 +143,7 @@ public class LiveRobotMessageCustomPopup extends BottomPopupView { @Override public void onClick(View v) { new XPopup.Builder(getContext()) - .asCustom(new InputCustomPopup(getContext(),R.string.automatic_message_sending).setListener(new InputCustomPopup.InputCustomListener() { + .asCustom(new InputCustomPopup(getContext(), R.string.automatic_message_sending).setListener(new InputCustomPopup.InputCustomListener() { @Override public void onConfirm(String text) { //添加消息语 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..07b3a9a90 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 + To complete + Already collected + Image quality selection + More Settings + view more + The gift is on the way... + The gift is on the way + Remaining count :%s + Whether to confirm multiple PK (deduct 1 point after confirmation) remaining times on the day: %s + Invite \n anchor + End \nPK + Time %s + + accept + refuse + Persist in refusing + Random PK hint + + Automatic speech robot setup + Robot switch + Robot name setting + The word limit is 2 to 8 word + Automatic greeting setting + Number of configured items + Set automatic message sending + Go to set + Thank you for sending gifts, PK start, PK end automatic robot message, \n does not support customization. + Add content + At regular intervals, the robot automatically says the following sentence at random。 + Fill in the content recommendation, such as: send wish list, add fan group, etc + Automatic speech interval (minutes) + At least once every 5 minutes + When a user enters the studio, the robot will @the user and automatically + The following sentence is random. Set a minimum of 1 to a maximum of 20. + Robot setup + High definition + fluency + Ultra hd + After determining the definition of the broadcast, you need to restart the broadcast to change + Confirmation of broadcast Settings + clarity + Live channel + broadcast + robot + set + Not set + no + yes + Ultra HD hint + In the case of unstable network speed, the selection of ultra HD may lead to the delay of the picture in the broadcast room. Do you confirm the selection? + Stick to choice + Network prompt + The system detects that your network is unstable and insufficient device memory will affect the fluency of your live broadcast. Therefore, it is recommended that you choose fluency and clarity. 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/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java index 0c457eab4..ff2473388 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -312,10 +312,10 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { if (mLiveLinkMicPkViewHolder != null) { String s = mIsPkEnd ? mPkTimeString2 : mPkTimeString1; String s1 = StringUtil.getDurationText(mPkTimeCount * 1000); - if (i == 1 && s1.equals("00:01")) { - s1 = "00:00"; - i = 0; - } +// if (i == 1 && s1.equals("00:01")) { +// s1 = "00:00"; +// i = 0; +// } if (rtcRoom != null) { ScreenDimenUtil util = ScreenDimenUtil.getInstance(); int mScreenWdith = util.getScreenWdith(); @@ -385,7 +385,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { */ private void changePkTime() { mPkTimeCount--; - if (mPkTimeCount > 0) {// + if (mPkTimeCount >= 0) {// nextPkTimeCountDown(); } else { if (mIsPkEnd) { @@ -398,7 +398,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { // mLiveLinkMicPkViewHolder.removeFromParent(); // mLiveLinkMicPkViewHolder.release(); // } - mLiveLinkMicPkViewHolder = null; +// mLiveLinkMicPkViewHolder = null; } } } diff --git a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java index c83022461..0a83e1c49 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java @@ -191,8 +191,8 @@ public class LiveLinkMicPkViewHolder extends AbsViewHolder { public void setTime(String content) { if (mTime != null) { Log.i("vvvs",content); - if(content.trim().equals("00:01")||content.trim().equals("00:00")){ - mTime.setText("計算中"); + if(content.trim().equals("00:00")){ + mTime.setText("結算中"); }else { mTime.setText(content); } 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..418673747 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()) { @@ -310,10 +355,15 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl } else if (i == R.id.btn_room_type) { chooseLiveType(); } else if (i == R.id.btn_start_live) { + if (mLiveClassID == 0) { + ToastUtil.show(R.string.live_choose_live_class); + return; + } // startLive(); liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, selectClarity, classBean, liveRoomTypeBean) .setCallBack(new LiveOpenCustomPopup.LiveOpenCallBack() { @Override + public void startLive(LiveRoomTypeBean liveRoomTypeModel, LiveClassBean classModel) { if (classModel != null) { classBean = classModel; 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 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 6f9d9d03a..63aa213a2 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -1094,8 +1094,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe public void onKick(String touid) { if (!TextUtils.isEmpty(touid) && touid.equals(CommonAppConfig.getInstance().getUid())) {//被踢的是自己 kick = true; - exitLiveRoom(true); ToastUtil.show(WordUtil.getString(R.string.live_kicked_2)); + onRemove(true); } } diff --git a/live/src/main/res/layout/view_live_push_ry.xml b/live/src/main/res/layout/view_live_push_ry.xml index 733b3d72f..550226de5 100644 --- a/live/src/main/res/layout/view_live_push_ry.xml +++ b/live/src/main/res/layout/view_live_push_ry.xml @@ -112,6 +112,7 @@ android:layout_alignParentRight="true" android:layout_marginTop="122dp" android:layout_marginRight="9dp" + android:visibility="gone" android:background="@drawable/bg_live_other_ico" android:gravity="center">