開播設置,修改開播接口新增分辨率設置參數,網絡內存檢測和提示信息

This commit is contained in:
18401019693 2022-12-30 14:47:25 +08:00
parent 06b5f99930
commit 8b357233c2
10 changed files with 477 additions and 90 deletions

View File

@ -136,4 +136,6 @@ public class DeviceUtils {
lastTotalRxBytes = nowTotalRxBytes;
return speed;
}
}

View File

@ -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();
}
}

View File

@ -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, () -> {
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, () -> {
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<Long> netSpeeds = new ArrayList<>();
private double netAverage = 0;
private void initDate() {
netHandler.postDelayed(netRunnable, 100);
}
}

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="270dp"
android:layout_height="180dp"
android:orientation="vertical"
app:cardCornerRadius="18dp"
app:cardElevation="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/ultra_hd_hint"
android:textColor="#161616"
android:textSize="16sp" />
<TextView
android:id="@+id/contest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="10dp"
android:text="@string/ultra_hd_hint2"
android:textColor="#999999"
android:textSize="12sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/live_open_cancel"
android:layout_width="100dp"
android:layout_height="36dp"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:background="@drawable/backgroud_live_open_lfet"
android:gravity="center"
android:text="@string/back"
android:textColor="#FFC621"
android:textSize="14sp" />
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/live_open_ok"
android:layout_width="100dp"
android:layout_height="36dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:background="@drawable/backgroud_live_open_right"
android:gravity="center"
android:text="@string/stick_to_choice"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -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" />

View File

@ -934,4 +934,64 @@ Limited ride And limited avatar frame</string>
<string name="studio_gift_effects">Blocking gift effects</string>
<string name="studio_ride_effects">Blocking seat effects</string>
<string name="want_pre">If you want to Minimize Play,\nYou can go to set the license.</string>
<string name="in_batch">In a batch</string>
<string name="chat_chat">Chat</string>
<string name="lucky_angel" >Congratulations %s have won %s in the Lucky Angel! The next lucky angel will be you!</string>
<string name="user_card_guard" >Guardian group %s people</string>
<string name="to_receive" >receive</string>
<string name="to_complete" >去完成</string>
<string name="already_collected" >已領取</string>
<string name="image_quality_selection" >畫質選擇</string>
<string name="more_settings" >更多設置</string>
<string name="moer">查看更多</string>
<string name="gift_way">礼物正在获取中...</string>
<string name="start_pk">開始PK</string>
<string name="number_of_remaining_times">剩餘次數:%s</string>
<string name="confirmed_to_proceed">是否確認進行多人PK確認後扣除1點次數當日剩餘次數: %s</string>
<string name="invite_anchor">邀請\n主播</string>
<string name="end_pk">結束\nPK</string>
<string name="pk_time">時間 %s</string>
<string name="random_pk_dialog_apply" >接受</string>
<string name="random_pk_dialog_refuse" >拒绝</string>
<string name="random_pk_dialog_refuse_again" >坚持拒绝</string>
<string name="random_pk_dialog_title" >随机PK提示</string>
<string name="speech_robot_setup" >自動發言機器人設置</string>
<string name="robot_switch" >機器人開關</string>
<string name="robot_name_setting" >機器人名字設置</string>
<string name="word_limit" >字數限制2-8個字</string>
<string name="automatic_greeting_setting" >自動打招呼設置</string>
<string name="configured_items" >已配置條數</string>
<string name="automatic_message_sending" >自動發消息設置</string>
<string name="robot_go_setting" >前往設置</string>
<string name="robot_hint" >感謝送禮、PK開始、PK結束的自動機器人消息\n暫不支持自定義。</string>
<string name="robot_add_content" >添加內容</string>
<string name="robot_add_content_hint1" >每隔一段時間,機器人自動隨機以下一句話發出。</string>
<string name="robot_add_content_hint2" >填寫內容推薦,如:求送心願單、加粉絲團等</string>
<string name="robot_automatic_speech_interval" >自動發言間隔時間(分鐘)</string>
<string name="robot_minimum_interval" >最少間隔5分鐘1次</string>
<string name="robot_add_content_hint3" >當有用戶進入直播間時,機器人會@該用戶並自動</string>
<string name="robot_add_content_hint4" >隨機以下一句話。最少設置1條最多20條。</string>
<string name="robot_setup" >機器人設置</string>
<string name="high_definition" >高清</string>
<string name="standard_clear" >流暢</string>
<string name="ultra_hd" >超高清</string>
<string name="clarity_hint" >確定清晰度開播後,需要重新開播才能更改</string>
<string name="confirmation_of_broadcast" >開播設置確認</string>
<string name="clarity" >清晰度</string>
<string name="live_class1" >直播頻道</string>
<string name="broadcast" >開播</string>
<string name="robot" >機器人</string>
<string name="do_set" >已設置</string>
<string name="not_set" >未設置</string>
<string name="robot_no" ></string>
<string name="robot_yes" ></string>
<string name="ultra_hd_hint" >超高清提示</string>
<string name="ultra_hd_hint2" >在網速不穩定的情況下,選擇超高清將會有可能導致直播間畫面卡頓,是否確認選擇?</string>
<string name="stick_to_choice" >堅持選擇</string>
<string name="net_hint" >網絡提示</string>
<string name="net_hint2" >系統監測到您的網絡不穩定,設備內存不足將會影響到您的直播流暢度,因此建議您選擇流暢清晰度。</string>
</resources>

View File

@ -723,7 +723,7 @@
<string name="live_wishlist">心願單</string>
<string name="live_zg">娛樂整蠱</string>
<string name="live_dr">多人PK</string>
<string name="live_random" translatable="false">随机PK</string>
<string name="live_random" >随机PK</string>
<string name="live_mic">語音連麥</string>
<string name="live_wks">周星榜</string>
<string name="live_zslk">暫時離開</string>
@ -958,13 +958,13 @@
<string name="in_batch">換一批</string>
<string name="chat_chat">聊聊天</string>
<string name="want_pre">想在其他APP上方也顯示小窗\n可前往設置進行授權。</string>
<string name="lucky_angel" translatable="false">恭喜 %s 在幸運天使中抽中 %s下一個幸運天使就是你哦</string>
<string name="user_card_guard" translatable="false">守護團%s人</string>
<string name="to_receive" translatable="false">領取</string>
<string name="to_complete" translatable="false">去完成</string>
<string name="already_collected" translatable="false">已領取</string>
<string name="image_quality_selection" translatable="false">畫質選擇</string>
<string name="more_settings" translatable="false">更多設置</string>
<string name="lucky_angel" >恭喜 %s 在幸運天使中抽中 %s下一個幸運天使就是你哦</string>
<string name="user_card_guard" >守護團%s人</string>
<string name="to_receive" >領取</string>
<string name="to_complete" >去完成</string>
<string name="already_collected" >已領取</string>
<string name="image_quality_selection" >畫質選擇</string>
<string name="more_settings" >更多設置</string>
<string name="moer">查看更多</string>
<string name="gift_way">礼物正在获取中...</string>
<string name="start_pk">開始PK</string>
@ -974,39 +974,44 @@
<string name="end_pk">結束\nPK</string>
<string name="pk_time">時間 %s</string>
<string name="random_pk_dialog_apply" translatable="false">接受</string>
<string name="random_pk_dialog_refuse" translatable="false">拒绝</string>
<string name="random_pk_dialog_refuse_again" translatable="false">坚持拒绝</string>
<string name="random_pk_dialog_title" translatable="false">随机PK提示</string>
<string name="random_pk_dialog_apply" >接受</string>
<string name="random_pk_dialog_refuse" >拒绝</string>
<string name="random_pk_dialog_refuse_again" >坚持拒绝</string>
<string name="random_pk_dialog_title" >随机PK提示</string>
<string name="speech_robot_setup" translatable="false">自動發言機器人設置</string>
<string name="robot_switch" translatable="false">機器人開關</string>
<string name="robot_name_setting" translatable="false">機器人名字設置</string>
<string name="word_limit" translatable="false">字數限制2-8個字</string>
<string name="automatic_greeting_setting" translatable="false">自動打招呼設置</string>
<string name="configured_items" translatable="false">已配置條數</string>
<string name="automatic_message_sending" translatable="false">自動發消息設置</string>
<string name="robot_go_setting" translatable="false">前往設置</string>
<string name="robot_hint" translatable="false">感謝送禮、PK開始、PK結束的自動機器人消息\n暫不支持自定義。</string>
<string name="robot_add_content" translatable="false">添加內容</string>
<string name="robot_add_content_hint1" translatable="false">每隔一段時間,機器人自動隨機以下一句話發出。</string>
<string name="robot_add_content_hint2" translatable="false">填寫內容推薦,如:求送心願單、加粉絲團等</string>
<string name="robot_automatic_speech_interval" translatable="false">自動發言間隔時間(分鐘)</string>
<string name="robot_minimum_interval" translatable="false">最少間隔5分鐘1次</string>
<string name="robot_add_content_hint3" translatable="false">當有用戶進入直播間時,機器人會@該用戶並自動</string>
<string name="robot_add_content_hint4" translatable="false">隨機以下一句話。最少設置1條最多20條。</string>
<string name="robot_setup" translatable="false">機器人設置</string>
<string name="high_definition" translatable="false">高清</string>
<string name="standard_clear" translatable="false">流暢</string>
<string name="ultra_hd" translatable="false">超高清</string>
<string name="clarity_hint" translatable="false">確定清晰度開播後,需要重新開播才能更改</string>
<string name="confirmation_of_broadcast" translatable="false">開播設置確認</string>
<string name="clarity" translatable="false">清晰度</string>
<string name="live_class1" translatable="false">直播頻道</string>
<string name="broadcast" translatable="false">開播</string>
<string name="robot" translatable="false">機器人</string>
<string name="do_set" translatable="false">已設置</string>
<string name="not_set" translatable="false">未設置</string>
<string name="robot_no" translatable="false"></string>
<string name="robot_yes" translatable="false"></string>
<string name="speech_robot_setup" >自動發言機器人設置</string>
<string name="robot_switch" >機器人開關</string>
<string name="robot_name_setting" >機器人名字設置</string>
<string name="word_limit" >字數限制2-8個字</string>
<string name="automatic_greeting_setting" >自動打招呼設置</string>
<string name="configured_items" >已配置條數</string>
<string name="automatic_message_sending" >自動發消息設置</string>
<string name="robot_go_setting" >前往設置</string>
<string name="robot_hint" >感謝送禮、PK開始、PK結束的自動機器人消息\n暫不支持自定義。</string>
<string name="robot_add_content" >添加內容</string>
<string name="robot_add_content_hint1" >每隔一段時間,機器人自動隨機以下一句話發出。</string>
<string name="robot_add_content_hint2" >填寫內容推薦,如:求送心願單、加粉絲團等</string>
<string name="robot_automatic_speech_interval" >自動發言間隔時間(分鐘)</string>
<string name="robot_minimum_interval" >最少間隔5分鐘1次</string>
<string name="robot_add_content_hint3" >當有用戶進入直播間時,機器人會@該用戶並自動</string>
<string name="robot_add_content_hint4" >隨機以下一句話。最少設置1條最多20條。</string>
<string name="robot_setup" >機器人設置</string>
<string name="high_definition" >高清</string>
<string name="standard_clear" >流暢</string>
<string name="ultra_hd" >超高清</string>
<string name="clarity_hint" >確定清晰度開播後,需要重新開播才能更改</string>
<string name="confirmation_of_broadcast" >開播設置確認</string>
<string name="clarity" >清晰度</string>
<string name="live_class1" >直播頻道</string>
<string name="broadcast" >開播</string>
<string name="robot" >機器人</string>
<string name="do_set" >已設置</string>
<string name="not_set" >未設置</string>
<string name="robot_no" ></string>
<string name="robot_yes" ></string>
<string name="ultra_hd_hint" >超高清提示</string>
<string name="ultra_hd_hint2" >在網速不穩定的情況下,選擇超高清將會有可能導致直播間畫面卡頓,是否確認選擇?</string>
<string name="stick_to_choice" >堅持選擇</string>
<string name="net_hint" >網絡提示</string>
<string name="net_hint2" >系統監測到您的網絡不穩定,設備內存不足將會影響到您的直播流暢度,因此建議您選擇流暢清晰度。</string>
</resources>

View File

@ -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<String, StatusBean> 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);

View File

@ -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()) {

View File

@ -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