Commit 9a05908a by 万齐军

网络情况显示

parent 32e8effe
......@@ -18,6 +18,7 @@ import android.text.TextUtils
import android.view.View
import android.view.WindowManager
import android.view.animation.AccelerateInterpolator
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.alibaba.android.arouter.facade.annotation.Route
......@@ -235,6 +236,14 @@ class AudioHomeActivity :
private var canChangeRoute: Boolean = false
private var hasHandleRefused = false
private val tvNetDelay: TextView by lazy { findViewById(R.id.tvDelay) }
private val tvNetDown: TextView by lazy { findViewById(R.id.tvDown) }
private val tvNetUp: TextView by lazy { findViewById(R.id.tvUp) }
private val ivNetQuality: ImageView by lazy { findViewById(R.id.ivQuality) }
private val tvNetQuality: TextView by lazy { findViewById(R.id.tvQuality) }
private val layoutQualityGroup: View by lazy { findViewById(R.id.layoutQualityGroup) }
private val notificationCallback = object : IMRegisterObserverCustomNotificationCallBack {
override fun onObserverCustomNotification(fromUid: String, toUid: String, content: String) {
if (fromUid == listenerUid) {
......@@ -1659,28 +1668,51 @@ class AudioHomeActivity :
inner class NetQuality : RtcNetInterface {
override fun onLocalAudioStats(bitrate: Int, packetLossRate: Int) {
XLog.i("NetQuality", "bitrate:$bitrate,packetLossRate:$packetLossRate")
runOnUiThread {
tvNetUp.text = "${bitrate}Kbps"
}
}
override fun onNetQuality(uid: Int, tx: Int, rx: Int) {
if (tx in 4..6 || rx in 4..6) {
XLog.i("NetQuality", "$uid,tx:$tx,rx:$rx")
}
runOnUiThread {
if (uid == 0) {
when (rx) {
1 -> {
ivNetQuality.setImageResource(R.drawable.audioim_bg_net_excellent)
tvNetQuality.text = "网络优秀"
}
2, 3 -> {
ivNetQuality.setImageResource(R.drawable.audioim_bg_net_good)
tvNetQuality.text = "网络良好"
}
4, 5, 6 -> {
ivNetQuality.setImageResource(R.drawable.audioim_bg_net_poor)
tvNetQuality.text = "网络极差"
}
}
}
}
}
override fun onRemoteAudioFeel(frozenRate: Int, qoeQuality: Int, reason: Int, mos: Int) {
XLog.i("NetQuality", "frozenRate:$frozenRate,qoeQuality:$qoeQuality,reason:$reason,mos:$mos")
}
override fun onRemoteAudioStateChanged(uid: Int, state: Int, reason: Int, elapsed: Int) {
XLog.i("NetQuality", "uid:$uid,state:$state,reason:$reason,elapsed:$elapsed")
}
override fun onRemoteAudioStats(quality: Int, delay: Int, bitrate: Int, audioLossRate: Int) {
runOnUiThread {
tvNetDown.text = "${bitrate}Kbps"
tvNetDelay.text = "${delay}ms"
layoutQualityGroup.visibility = View.VISIBLE
}
}
}
/**
......
......@@ -16,6 +16,8 @@ import android.provider.Settings
import android.text.TextUtils
import android.view.View
import android.view.animation.AccelerateInterpolator
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
......@@ -35,6 +37,7 @@ import com.ydl.consultantim.utils.ConsultantAudioUtils
import com.ydl.consultantim.utils.VibratorUtil
import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import com.ydl.ydl_av.voice.listener.RtcNetInterface
import com.ydl.ydl_av.voice.manager.YDLVoiceManager
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
......@@ -49,6 +52,7 @@ import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.log.XLog
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus
......@@ -118,6 +122,13 @@ class ConsultantAudioHomeActivity :
*/
private var isConnectSuccess: Boolean = false
private val tvNetDelay: TextView by lazy { findViewById(R.id.tvDelay) }
private val tvNetDown: TextView by lazy { findViewById(R.id.tvDown) }
private val tvNetUp: TextView by lazy { findViewById(R.id.tvUp) }
private val ivNetQuality: ImageView by lazy { findViewById(R.id.ivQuality) }
private val tvNetQuality: TextView by lazy { findViewById(R.id.tvQuality) }
private val layoutQualityGroup: View by lazy { findViewById(R.id.layoutQualityGroup) }
companion object {
const val PARAM: String = "param"
......@@ -678,6 +689,7 @@ class ConsultantAudioHomeActivity :
*/
voiceManage = YDLVoiceManager()
voiceManage?.attachVoiceEventHandler(mRtcEventHandler)
voiceManage?.attachNetQualityListener(NetQuality())
voiceManage?.getVoiceApi()?.setAudioProfile(Constants.AUDIO_PROFILE_DEFAULT, Constants.AUDIO_SCENARIO_CHATROOM_GAMING)
}
......@@ -1120,6 +1132,56 @@ class ConsultantAudioHomeActivity :
super.onDestroy()
}
inner class NetQuality : RtcNetInterface {
override fun onLocalAudioStats(bitrate: Int, packetLossRate: Int) {
XLog.i("NetQuality", "bitrate:$bitrate,packetLossRate:$packetLossRate")
runOnUiThread {
tvNetUp.text = "${bitrate}Kbps"
}
}
override fun onNetQuality(uid: Int, tx: Int, rx: Int) {
if (tx in 4..6 || rx in 4..6) {
XLog.i("NetQuality", "$uid,tx:$tx,rx:$rx")
}
runOnUiThread {
if (uid == 0) {
when (rx) {
1 -> {
ivNetQuality.setImageResource(R.drawable.audioim_bg_net_excellent)
tvNetQuality.text = "网络优秀"
}
2, 3 -> {
ivNetQuality.setImageResource(R.drawable.audioim_bg_net_good)
tvNetQuality.text = "网络良好"
}
4, 5, 6 -> {
ivNetQuality.setImageResource(R.drawable.audioim_bg_net_poor)
tvNetQuality.text = "网络极差"
}
}
}
}
}
override fun onRemoteAudioFeel(frozenRate: Int, qoeQuality: Int, reason: Int, mos: Int) {
XLog.i("NetQuality", "frozenRate:$frozenRate,qoeQuality:$qoeQuality,reason:$reason,mos:$mos")
}
override fun onRemoteAudioStateChanged(uid: Int, state: Int, reason: Int, elapsed: Int) {
XLog.i("NetQuality", "uid:$uid,state:$state,reason:$reason,elapsed:$elapsed")
}
override fun onRemoteAudioStats(quality: Int, delay: Int, bitrate: Int, audioLossRate: Int) {
runOnUiThread {
tvNetDown.text = "${bitrate}Kbps"
tvNetDelay.text = "${delay}ms"
layoutQualityGroup.visibility = View.VISIBLE
}
}
}
/**
* 倾诉日志
* @param session 通话业务id
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#48CC95" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#FF994B" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#E05252" />
</shape>
\ No newline at end of file
......@@ -38,6 +38,85 @@
android:textSize="13sp" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layoutQualityGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_marginTop="44dp"
android:layout_marginRight="18dp"
android:visibility="gone">
<TextView
android:id="@+id/tvDelay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_net_delay"
android:drawablePadding="4dp"
android:textColor="#99FFFFFF"
android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tvDown"
app:layout_constraintTop_toTopOf="parent"
tools:text="12ms" />
<TextView
android:id="@+id/tvDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_net_down"
android:textColor="#99FFFFFF"
android:drawablePadding="4dp"
android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/tvDelay"
app:layout_constraintRight_toLeftOf="@+id/tvUp"
app:layout_constraintTop_toTopOf="parent"
tools:text="12ms" />
<TextView
android:id="@+id/tvUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_net_up"
android:textColor="#99FFFFFF"
android:drawablePadding="4dp"
android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/tvDown"
app:layout_constraintRight_toLeftOf="@+id/layoutQuality"
app:layout_constraintTop_toTopOf="parent"
tools:text="12ms" />
<LinearLayout
android:id="@+id/layoutQuality"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:orientation="horizontal"
android:gravity="center"
app:layout_constraintLeft_toRightOf="@+id/tvUp"
app:layout_constraintRight_toRightOf="parent">
<ImageView
android:id="@+id/ivQuality"
tools:src="@drawable/audioim_bg_net_excellent"
android:layout_width="6dp"
android:layout_height="6dp"/>
<TextView
android:id="@+id/tvQuality"
android:layout_width="wrap_content"
android:layout_marginLeft="4dp"
android:layout_height="wrap_content"
android:textColor="#99FFFFFF"
android:textSize="13sp"
tools:text="12ms" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:id="@+id/rl_head"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/platform_color_80353535">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layoutQualityGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_marginTop="44dp"
android:layout_marginRight="18dp"
android:visibility="gone">
<TextView
android:id="@+id/tvDelay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_net_delay"
android:drawablePadding="4dp"
android:textColor="#99FFFFFF"
android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tvDown"
app:layout_constraintTop_toTopOf="parent"
tools:text="12ms" />
<TextView
android:id="@+id/tvDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_net_down"
android:textColor="#99FFFFFF"
android:drawablePadding="4dp"
android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/tvDelay"
app:layout_constraintRight_toLeftOf="@+id/tvUp"
app:layout_constraintTop_toTopOf="parent"
tools:text="12ms" />
<TextView
android:id="@+id/tvUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_net_up"
android:textColor="#99FFFFFF"
android:drawablePadding="4dp"
android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/tvDown"
app:layout_constraintRight_toLeftOf="@+id/layoutQuality"
app:layout_constraintTop_toTopOf="parent"
tools:text="12ms" />
<LinearLayout
android:id="@+id/layoutQuality"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:orientation="horizontal"
android:gravity="center"
app:layout_constraintLeft_toRightOf="@+id/tvUp"
app:layout_constraintRight_toRightOf="parent">
<ImageView
android:id="@+id/ivQuality"
tools:src="@drawable/audioim_bg_net_excellent"
android:layout_width="6dp"
android:layout_height="6dp"/>
<TextView
android:id="@+id/tvQuality"
android:layout_width="wrap_content"
android:layout_marginLeft="4dp"
android:layout_height="wrap_content"
android:textColor="#99FFFFFF"
android:textSize="13sp"
tools:text="12ms" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:id="@+id/rl_head"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment