Merge remote-tracking branch 'origin/master'

This commit is contained in:
zlzw 2023-01-03 10:16:36 +08:00
commit a1d95d6a94
16 changed files with 517 additions and 115 deletions

View File

@ -55,7 +55,9 @@ public class IMLoginManager extends BaseCacheManager {
* @return * @return
*/ */
public int getSelectClarity() { public int getSelectClarity() {
return getInt(SELECT_CLARITY, 1);
return getInt(SELECT_CLARITY, 0);
} }
public boolean isHint() { public boolean isHint() {

View File

@ -136,4 +136,6 @@ public class DeviceUtils {
lastTotalRxBytes = nowTotalRxBytes; lastTotalRxBytes = nowTotalRxBytes;
return speed; 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; package com.yunbao.common.views;
import android.content.Context; import android.content.Context;
import android.os.Handler;
import android.text.format.Formatter;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView; import com.lxj.xpopup.core.BottomPopupView;
import com.yunbao.common.R; 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 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 class LiveClarityCustomPopup extends BottomPopupView implements View.OnClickListener {
public static final int BAN_720 = 1; public static final int BAN_720 = 1;
public static final int BAN_1080 = 2; public static final int BAN_1080 = 2;
@ -91,16 +98,51 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl
}); });
//高清 //高清
ViewClicksAntiShake.clicksAntiShake(lineHd, () -> { ViewClicksAntiShake.clicksAntiShake(lineHd, () -> {
String memorg = formateFileSize(Long.parseLong(DeviceUtils.getMemory(getContext())));
if (Double.parseDouble(memorg) > 7 && netAverage > 100) {
selectClarity = 1; selectClarity = 1;
selectClarity(selectClarity); selectClarity(selectClarity);
dismiss(); 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, () -> { ViewClicksAntiShake.clicksAntiShake(lineFhd, () -> {
new XPopup.Builder(getContext())
.asCustom(new HintCustomPopup(getContext()).setCallBack(new HintCustomPopup.HintCustomCallBack() {
@Override
public void onSure() {
selectClarity = 2; selectClarity = 2;
selectClarity(selectClarity); selectClarity(selectClarity);
dismiss(); dismiss();
}
@Override
public void onCancel() {
}
}))
.show();
}); });
if (banSelect == BAN_720) { if (banSelect == BAN_720) {
lineFhd.setEnabled(false); 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() { private void initDate() {
netHandler.postDelayed(netRunnable, 100);
} }
} }

View File

@ -111,9 +111,12 @@ public class LiveRobotMessageCustomPopup extends BottomPopupView {
@Override @Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) { if (actionId == EditorInfo.IME_ACTION_DONE) {
String time = robotNameSetting.getText().toString();
int timeInt = Integer.parseInt(time);
if (timeInt > 5) {
// 修改助手名字 // 修改助手名字
LiveNetManager.get(getContext()) LiveNetManager.get(getContext())
.setAiRobotDate("ai_time", robotNameSetting.getText().toString(), new HttpCallback<HttpCallbackModel>() { .setAiRobotDate("ai_time", time, new HttpCallback<HttpCallbackModel>() {
@Override @Override
public void onSuccess(HttpCallbackModel data) { public void onSuccess(HttpCallbackModel data) {
robotNameSetting.setVisibility(GONE); robotNameSetting.setVisibility(GONE);
@ -126,6 +129,10 @@ public class LiveRobotMessageCustomPopup extends BottomPopupView {
ToastUtil.show(error); ToastUtil.show(error);
} }
}); });
} else {
ToastUtil.show(R.string.robot_minimum_interval);
}
} }
return false; return false;

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_width="87dp"
android:layout_height="33dp" android:layout_height="33dp"
android:layout_marginRight="7dp" android:layout_marginRight="7dp"
android:background="@mipmap/tipbox_btn_gray" android:background="@drawable/backgroud_live_open_lfet"
android:gravity="center" android:gravity="center"
android:text="@string/cancel" android:text="@string/cancel"
android:textColor="#B1B1B1" android:textColor="#FFC621"
android:textSize="14sp" /> 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_gift_effects">Blocking gift effects</string>
<string name="studio_ride_effects">Blocking seat 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="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" >To complete</string>
<string name="already_collected" >Already collected</string>
<string name="image_quality_selection" >Image quality selection</string>
<string name="more_settings" >More Settings</string>
<string name="moer">view more</string>
<string name="gift_way">The gift is on the way...</string>
<string name="start_pk">The gift is on the way</string>
<string name="number_of_remaining_times">Remaining count :%s</string>
<string name="confirmed_to_proceed">Whether to confirm multiple PK (deduct 1 point after confirmation) remaining times on the day: %s</string>
<string name="invite_anchor">Invite \n anchor</string>
<string name="end_pk">End \nPK</string>
<string name="pk_time">Time %s</string>
<string name="random_pk_dialog_apply" >accept</string>
<string name="random_pk_dialog_refuse" >refuse</string>
<string name="random_pk_dialog_refuse_again" >Persist in refusing</string>
<string name="random_pk_dialog_title" >Random PK hint</string>
<string name="speech_robot_setup" >Automatic speech robot setup</string>
<string name="robot_switch" >Robot switch</string>
<string name="robot_name_setting" >Robot name setting</string>
<string name="word_limit" >The word limit is 2 to 8 word</string>
<string name="automatic_greeting_setting" >Automatic greeting setting</string>
<string name="configured_items" >Number of configured items</string>
<string name="automatic_message_sending" >Set automatic message sending</string>
<string name="robot_go_setting" >Go to set</string>
<string name="robot_hint" >Thank you for sending gifts, PK start, PK end automatic robot message, \n does not support customization.</string>
<string name="robot_add_content" >Add content</string>
<string name="robot_add_content_hint1" >At regular intervals, the robot automatically says the following sentence at random。</string>
<string name="robot_add_content_hint2" >Fill in the content recommendation, such as: send wish list, add fan group, etc</string>
<string name="robot_automatic_speech_interval" >Automatic speech interval (minutes)</string>
<string name="robot_minimum_interval" >At least once every 5 minutes</string>
<string name="robot_add_content_hint3" >When a user enters the studio, the robot will @the user and automatically</string>
<string name="robot_add_content_hint4" >The following sentence is random. Set a minimum of 1 to a maximum of 20.</string>
<string name="robot_setup" >Robot setup</string>
<string name="high_definition" >High definition</string>
<string name="standard_clear" >fluency</string>
<string name="ultra_hd" >Ultra hd</string>
<string name="clarity_hint" >After determining the definition of the broadcast, you need to restart the broadcast to change</string>
<string name="confirmation_of_broadcast" >Confirmation of broadcast Settings</string>
<string name="clarity" >clarity</string>
<string name="live_class1" >Live channel</string>
<string name="broadcast" >broadcast</string>
<string name="robot" >robot</string>
<string name="do_set" >set</string>
<string name="not_set" >Not set</string>
<string name="robot_no" >no</string>
<string name="robot_yes" >yes</string>
<string name="ultra_hd_hint" >Ultra HD hint</string>
<string name="ultra_hd_hint2" >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?</string>
<string name="stick_to_choice" >Stick to choice</string>
<string name="net_hint" >Network prompt</string>
<string name="net_hint2" >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.</string>
</resources> </resources>

View File

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

View File

@ -112,10 +112,14 @@ import org.greenrobot.eventbus.ThreadMode;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Random; import java.util.Random;
import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; 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.RCRTCRect;
import cn.rongcloud.rtc.base.RTCErrorCode; import cn.rongcloud.rtc.base.RTCErrorCode;
import io.rong.imlib.IRongCallback; import io.rong.imlib.IRongCallback;
@ -208,6 +212,27 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
Bus.getOn(this); Bus.getOn(this);
Intent intent = getIntent(); Intent intent = getIntent();
initFaceManager(); 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); leave_img = findViewById(R.id.leave_img);
mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY); mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY);
mLiveKsyConfigBean = intent.getParcelableExtra(Constants.LIVE_KSY_CONFIG); mLiveKsyConfigBean = intent.getParcelableExtra(Constants.LIVE_KSY_CONFIG);

View File

@ -312,10 +312,10 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
if (mLiveLinkMicPkViewHolder != null) { if (mLiveLinkMicPkViewHolder != null) {
String s = mIsPkEnd ? mPkTimeString2 : mPkTimeString1; String s = mIsPkEnd ? mPkTimeString2 : mPkTimeString1;
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000); String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
if (i == 1 && s1.equals("00:01")) { // if (i == 1 && s1.equals("00:01")) {
s1 = "00:00"; // s1 = "00:00";
i = 0; // i = 0;
} // }
if (rtcRoom != null) { if (rtcRoom != null) {
ScreenDimenUtil util = ScreenDimenUtil.getInstance(); ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith(); int mScreenWdith = util.getScreenWdith();
@ -385,7 +385,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
*/ */
private void changePkTime() { private void changePkTime() {
mPkTimeCount--; mPkTimeCount--;
if (mPkTimeCount > 0) {// if (mPkTimeCount >= 0) {//
nextPkTimeCountDown(); nextPkTimeCountDown();
} else { } else {
if (mIsPkEnd) { if (mIsPkEnd) {
@ -398,7 +398,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
// mLiveLinkMicPkViewHolder.removeFromParent(); // mLiveLinkMicPkViewHolder.removeFromParent();
// mLiveLinkMicPkViewHolder.release(); // mLiveLinkMicPkViewHolder.release();
// } // }
mLiveLinkMicPkViewHolder = null; // mLiveLinkMicPkViewHolder = null;
} }
} }
} }

View File

@ -191,8 +191,8 @@ public class LiveLinkMicPkViewHolder extends AbsViewHolder {
public void setTime(String content) { public void setTime(String content) {
if (mTime != null) { if (mTime != null) {
Log.i("vvvs",content); Log.i("vvvs",content);
if(content.trim().equals("00:01")||content.trim().equals("00:00")){ if(content.trim().equals("00:00")){
mTime.setText("算中"); mTime.setText("算中");
}else { }else {
mTime.setText(content); mTime.setText(content);
} }

View File

@ -9,6 +9,8 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.format.Formatter;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager; 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.CommonCallback;
import com.yunbao.common.interfaces.ImageResultCallback; import com.yunbao.common.interfaces.ImageResultCallback;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ProcessImageUtil; import com.yunbao.common.utils.ProcessImageUtil;
@ -60,9 +63,15 @@ import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
import java.io.File; import java.io.File;
import java.util.Map;
import cn.rongcloud.rtc.api.RCRTCEngine; 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.RCRTCCameraOutputStream;
import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig;
import cn.rongcloud.rtc.base.RCRTCParamsType;
public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnClickListener { 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(); selectClarity = IMLoginManager.get(mContext).getSelectClarity();
setSelectClarity(selectClarity); setSelectClarity(selectClarity);
ViewClicksAntiShake ViewClicksAntiShake
.clicksAntiShake( .clicksAntiShake(
findViewById(R.id.btn_live_clarity), () -> { 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) new XPopup.Builder(mContext)
.setPopupCallback(new XPopupCallback() { .setPopupCallback(new XPopupCallback() {
@Override @Override
@ -261,6 +274,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
} }
private void setSelectClarity(int selectClarity) { private void setSelectClarity(int selectClarity) {
this.selectClarity = selectClarity; this.selectClarity = selectClarity;
IMLoginManager.get(mContext).setSelectClarity(selectClarity); IMLoginManager.get(mContext).setSelectClarity(selectClarity);
switch (selectClarity) { switch (selectClarity) {
@ -280,12 +294,43 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
if (liveOpenCustomPopup != null) { if (liveOpenCustomPopup != null) {
liveOpenCustomPopup.setSelectClarity(selectClarity); 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) { public void setManager(FaceManager manager) {
this.manager = manager; this.manager = manager;
} }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (!canClick()) { if (!canClick()) {
@ -310,10 +355,15 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
} else if (i == R.id.btn_room_type) { } else if (i == R.id.btn_room_type) {
chooseLiveType(); chooseLiveType();
} else if (i == R.id.btn_start_live) { } else if (i == R.id.btn_start_live) {
if (mLiveClassID == 0) {
ToastUtil.show(R.string.live_choose_live_class);
return;
}
// startLive(); // startLive();
liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, selectClarity, classBean, liveRoomTypeBean) liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, selectClarity, classBean, liveRoomTypeBean)
.setCallBack(new LiveOpenCustomPopup.LiveOpenCallBack() { .setCallBack(new LiveOpenCustomPopup.LiveOpenCallBack() {
@Override @Override
public void startLive(LiveRoomTypeBean liveRoomTypeModel, LiveClassBean classModel) { public void startLive(LiveRoomTypeBean liveRoomTypeModel, LiveClassBean classModel) {
if (classModel != null) { if (classModel != null) {
classBean = classModel; classBean = classModel;

View File

@ -25,7 +25,6 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.makeramen.roundedimageview.RoundedImageView;
import com.tencent.liteav.device.TXDeviceManager; import com.tencent.liteav.device.TXDeviceManager;
import com.tencent.rtmp.ITXLivePushListener; import com.tencent.rtmp.ITXLivePushListener;
import com.tencent.rtmp.TXLiveConstants; 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.HttpCallbackModel;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.AnchorInfoEvent; import com.yunbao.common.event.AnchorInfoEvent;
import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.RandomPkManager; import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.DialogUitl; 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.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback; import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener; 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.RCRTCInputStream;
import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo; import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo;
import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig; import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig;
import cn.rongcloud.rtc.api.stream.RCRTCVideoView; import cn.rongcloud.rtc.api.stream.RCRTCVideoView;
import cn.rongcloud.rtc.base.RCRTCParamsType; import cn.rongcloud.rtc.base.RCRTCParamsType;
import cn.rongcloud.rtc.base.RCRTCRoomType; import cn.rongcloud.rtc.base.RCRTCRoomType;
import cn.rongcloud.rtc.base.RCRTCVideoFrame;
import cn.rongcloud.rtc.base.RTCErrorCode; import cn.rongcloud.rtc.base.RTCErrorCode;
import cn.rongcloud.rtc.core.CameraVideoCapturer; import cn.rongcloud.rtc.core.CameraVideoCapturer;
import cn.rongcloud.rtc.core.RendererCommon; import cn.rongcloud.rtc.core.RendererCommon;
@ -560,16 +561,37 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
RCRTCEngine.getInstance().init(contexts, config); RCRTCEngine.getInstance().init(contexts, config);
RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC_HIGH, RCRTCParamsType.AudioScenario.MUSIC_CHATROOM); 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() RCRTCVideoStreamConfig videoConfigBuilder = RCRTCVideoStreamConfig.Builder.create()
//设置分辨率 //设置分辨率
.setVideoResolution(RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_640) .setVideoResolution(rcrtcVideoResolution)
//设置帧率 //设置帧率
.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_24) .setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_24)
//设置最小码率480P下推荐200 //设置最小码率480P下推荐200
.setMinRate(250) .setMinRate(minRate)
//设置最大码率480P下推荐900 //设置最大码率480P下推荐900
.setMaxRate(5000) .setMaxRate(maxRate)
.build(); .build();
// 创建本地视频显示视图 // 创建本地视频显示视图
@ -595,7 +617,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
mPreView.addView(rongRTCVideoView); mPreView.addView(rongRTCVideoView);
tencentTRTCBeautyManager = new TencentTRTCBeautyManager(mContext); tencentTRTCBeautyManager = new TencentTRTCBeautyManager(mContext);
//加入房间成功后可以通过 RCRTCLocalUser 对象发布本地默认音视频流包括麦克风采集的音频和摄像头采集的视频 //加入房间成功后可以通过 RCRTCLocalUser 对象发布本地默认音视频流包括麦克风采集的音频和摄像头采集的视频
RCRTCEngine.getInstance().getDefaultVideoStream().setEncoderMirror(true); RCRTCEngine.getInstance().getDefaultVideoStream().setEncoderMirror(true);
if (rtcRoom == null || rtcRoom.getLocalUser() == null) { if (rtcRoom == null || rtcRoom.getLocalUser() == null) {
@ -615,20 +636,13 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
room.registerRoomListener(roomEventsListener); room.registerRoomListener(roomEventsListener);
//美颜 //美颜
new Handler(Looper.getMainLooper()).post(new Runnable() { // new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() { // 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;
}
});*/
}
});
} }
@Override @Override
@ -721,19 +735,33 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
mediaConfig.setVideoConfig(videoConfig); mediaConfig.setVideoConfig(videoConfig);
//大流视频的输出参数 //大流视频的输出参数
RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout normal = new RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout(); RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout normal = new RCRTCMixConfig.MediaConfig.VideoConfig.VideoLayout();
videoConfig.setVideoLayout(normal);
//推荐宽帧率参数值可以通过默认视频流的配置获取也可以根据实际需求来自定义设置 //推荐宽帧率参数值可以通过默认视频流的配置获取也可以根据实际需求来自定义设置
//如不设置宽高值则服务端将使用默认宽高 360 * 640 //如不设置宽高值则服务端将使用默认宽高 360 * 640
//:发布的视频分辨率为720 * 1280如果不设置则观众端看到的视频分辨率为 360 * 640, //:发布的视频分辨率为720 * 1280如果不设置则观众端看到的视频分辨率为 360 * 640,
//所以如果想让观众端看到的视频分辨率和发布视频分辨率一致则应从发布的视频流中获取分辨率配置并设置到 mediaConfig //所以如果想让观众端看到的视频分辨率和发布视频分辨率一致则应从发布的视频流中获取分辨率配置并设置到 mediaConfig
RCRTCVideoStreamConfig defaultVideoConfig = RCRTCEngine.getInstance().getDefaultVideoStream().getVideoConfig(); //設置開播分辨率
int fps = defaultVideoConfig.getVideoFps().getFps(); //設置開播分辨率
int width = 720; RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
int height = 1280; 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.setWidth(width); //视频宽
normal.setHeight(height); //视频高 normal.setHeight(height); //视频高
normal.setFps(25); //视频帧率 normal.setFps(15); //视频帧率
videoConfig.setVideoLayout(normal);
//2. 合流画布设置 //2. 合流画布设置
//(请参照画布和声音配置示例代码) //(请参照画布和声音配置示例代码)
//3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准)设置每个视频流小窗口的坐标及宽高 //3. 假设以画布设置的宽高为 300 * 300为例(应以真实设置的宽高为准)设置每个视频流小窗口的坐标及宽高
@ -747,6 +775,16 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
videoLayout1.setY(0); //Y 坐标 videoLayout1.setY(0); //Y 坐标
videoLayout1.setWidth(720); // 视频窗口的宽 videoLayout1.setWidth(720); // 视频窗口的宽
videoLayout1.setHeight(1280); // 视频窗口的高 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. 合流画布设置 //2. 合流画布设置
rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() { rcrtcLiveInfo.setMixConfig(config, new IRCRTCResultCallback() {
@Override @Override
@ -762,6 +800,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
}); });
} }
} }
@Override @Override

View File

@ -1094,8 +1094,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public void onKick(String touid) { public void onKick(String touid) {
if (!TextUtils.isEmpty(touid) && touid.equals(CommonAppConfig.getInstance().getUid())) {//被踢的是自己 if (!TextUtils.isEmpty(touid) && touid.equals(CommonAppConfig.getInstance().getUid())) {//被踢的是自己
kick = true; kick = true;
exitLiveRoom(true);
ToastUtil.show(WordUtil.getString(R.string.live_kicked_2)); ToastUtil.show(WordUtil.getString(R.string.live_kicked_2));
onRemove(true);
} }
} }

View File

@ -112,6 +112,7 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginTop="122dp" android:layout_marginTop="122dp"
android:layout_marginRight="9dp" android:layout_marginRight="9dp"
android:visibility="gone"
android:background="@drawable/bg_live_other_ico" android:background="@drawable/bg_live_other_ico"
android:gravity="center"> android:gravity="center">