「dev_robobus-d_230322_3.0.0」

1、合并直播功能
2、修复乘客端打包不能运行bug
This commit is contained in:
donghongyu
2023-03-31 13:06:34 +08:00
parent 68ffe1e904
commit 378a161acb
9 changed files with 312 additions and 2 deletions

View File

@@ -0,0 +1,204 @@
package com.mogo.eagle.core.function.hmi.ui.widget
import android.app.Application
import android.content.Context
import android.os.Handler
import android.util.AttributeSet
import android.view.LayoutInflater
import com.mogo.cloud.live.manager.LiveStreamManagerImpl
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.cloud.trafficlive.api.ITrafficCarLiveCallBack
import com.mogo.cloud.trafficlive.api.MoGoAiCloudTrafficLive
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.widget.RoundConstraintLayout
import kotlinx.android.synthetic.main.view_camera_list.view.*
import kotlinx.android.synthetic.main.view_driver_monitor.view.*
/**
* 乘客端查看当前车辆驾驶舱的司机监控View
*/
class DriverMonitorView :
RoundConstraintLayout {
companion object {
private val TAG = "DriverMonitorView"
private var isLived = false
// TODO SOP演示功能代码乘客端查看当前车辆上的司机位置监控请求的是分体机提供的直播信息这里采用的是硬编码因为云平台的操作就是这样没有接口供查询对应关系
private var sopShowDriverMap = HashMap<String, String>()
}
private val mHandler = Handler()
private val mRunnable = object : Runnable {
override fun run() {
// Do something here
Logger.d(
"${SceneConstant.M_HMI}$TAG",
"检查司机直播……isLived=$isLived 当前车上的司机端SN=${sopShowDriverMap[CallerTelematicManager.getServerToken()]}"
)
CallerLogger.d(
"${SceneConstant.M_HMI}$TAG",
"检查司机直播……isLived=$isLived 当前车上的司机端SN=${sopShowDriverMap[CallerTelematicManager.getServerToken()]}"
)
showLive()
mHandler.postDelayed(this, 10000) // 1 second delay
}
}
private val liveStreamManager by lazy {
LiveStreamManagerImpl.getInstance(
context.applicationContext as Application?,
MoGoAiCloudClientConfig.getInstance().sn,
false
)
}
constructor(context: Context?) : super(context) {
initView(context)
}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
initView(context)
}
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
initView(context)
}
private fun initView(context: Context?) {
LayoutInflater.from(context)
.inflate(R.layout.view_driver_monitor, this, true)
textureViewDriverMonitor.isOpaque = false
liveStreamManager.setLiveStatusChangeCallback {
textureView
.post {
handleSnLiveStatus(it)
}
}
// TODO SOP演示需求只有乘客屏幕才会触发这个逻辑 begin
// 测试数据
sopShowDriverMap["X202022060289M7N8P"] = "F803EB2046PZD00188"//湘A01733D
// key=pad司机屏幕SNvalue=分体机SNvalue用来调用ZeGo直播服务查看直播@see MoGoAiCloudTrafficLive.viewDesignativeVehicleLive
sopShowDriverMap["20220524733SWT1"] = "F803EB2046PZD00190"//湘D01777D
sopShowDriverMap["20211110K7EJKPG"] = "F803EB2046PZD00188"//湘A01733D
sopShowDriverMap["20211120H342O9Z"] = "F803EB2046PZD00167"//未知
sopShowDriverMap["20211112X2RI32A"] = "F803EB2046PZD00274"//京A40776D
sopShowDriverMap["202204085X310A1"] = "F803EB2046PZD00263"//湘D09005D
// TODO SOP演示需求只有乘客屏幕才会触发这个逻辑 END
// 点击重新连接直播
ivNormal.setOnClickListener {
showLive()
}
mHandler.postDelayed(mRunnable, 1000) // 1 second delay
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
mHandler.removeCallbacks(mRunnable)
sopShowDriverMap[CallerTelematicManager.getServerToken()]?.let {
MoGoAiCloudTrafficLive.stopCarLive(it)
}
}
fun showLive() {
if (!isLived) {
sopShowDriverMap[CallerTelematicManager.getServerToken()]?.let {
Logger.d(
"${SceneConstant.M_HMI}$TAG",
"检查司机直播……isLived=$isLived 当前车上的司机端SN=${sopShowDriverMap[CallerTelematicManager.getServerToken()]}"
)
CallerLogger.d(
"${SceneConstant.M_HMI}$TAG",
"检查司机直播……isLived=$isLived 当前车上的司机端SN=${sopShowDriverMap[CallerTelematicManager.getServerToken()]}"
)
MoGoAiCloudTrafficLive.viewDesignativeVehicleLive(
it,
textureViewDriverMonitor,
carLiveCallBack
)
}
// MoGoAiCloudTrafficLive.viewDesignativeVehicleLive(
// "F803EB2046PZD00190",
// textureViewDriverMonitor,
// carLiveCallBack
// )
}
}
private fun refreshView(lived: Boolean) {
if (lived) {
textureViewDriverMonitor.visibility = VISIBLE
liveProgressBar.visibility = GONE
tvLoadingHit.visibility = GONE
} else {
textureViewDriverMonitor.visibility = GONE
liveProgressBar.visibility = VISIBLE
tvLoadingHit.visibility = VISIBLE
}
}
private fun handleSnLiveStatus(status: Int) {
when (status) {
0 -> {// 正在直播
isLived = true
}
1 -> {// 直播已停止
isLived = false
}
2 -> {// 直播强制结束
isLived = false
}
}
refreshView(isLived)
Logger.d("${SceneConstant.M_HMI}$TAG", "isLived:$isLived")
CallerLogger.d("${SceneConstant.M_HMI}$TAG", "isLived:$isLived")
}
private val carLiveCallBack = object : ITrafficCarLiveCallBack {
override fun onLive(liveSn: String?) {
Logger.d("${SceneConstant.M_HMI}$TAG", "onLive:$liveSn")
CallerLogger.d("${SceneConstant.M_HMI}$TAG", "onLive:$liveSn")
isLived = true
refreshView(isLived)
}
override fun onFirstFrame() {
Logger.d("${SceneConstant.M_HMI}$TAG", "onFirstFrame:isFirstPage")
CallerLogger.d("${SceneConstant.M_HMI}$TAG", "onFirstFrame:isFirstPage")
isLived = true
refreshView(isLived)
}
override fun onDisConnect() {
Logger.e("${SceneConstant.M_HMI}$TAG", "onDisConnect")
CallerLogger.e("${SceneConstant.M_HMI}$TAG", "onDisConnect")
isLived = false
refreshView(isLived)
}
override fun onError(errorMsg: String?) {
Logger.e("${SceneConstant.M_HMI}$TAG", "onError msg is:${errorMsg}")
CallerLogger.e("${SceneConstant.M_HMI}$TAG", "onError msg is:${errorMsg}")
isLived = false
refreshView(isLived)
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mogo.eagle.core.widget.RoundConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rclContainer"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_height="match_parent"
app:roundLayoutRadius="24dp">
<ImageView
android:id="@+id/ivNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bus_picture_nor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!--摄像头数据需要两种播放方式-->
<TextureView
android:id="@+id/textureViewDriverMonitor"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="@+id/liveProgressBar"
android:layout_width="90dp"
android:layout_height="90dp"
android:indeterminateDrawable="@drawable/icon_loading_live"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvLoadingHit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:text="加载中……"
android:textColor="#2D3E5F"
android:textSize="28dp"
app:layout_constraintEnd_toEndOf="@+id/liveProgressBar"
app:layout_constraintStart_toStartOf="@+id/liveProgressBar"
app:layout_constraintTop_toBottomOf="@+id/liveProgressBar" />
</com.mogo.eagle.core.widget.RoundConstraintLayout>