[6.9.0] fix bug of driver seat
This commit is contained in:
@@ -16,6 +16,8 @@ import com.mogo.eagle.core.function.api.driver.video.IDriveSeatVideoProvider.Eve
|
||||
import com.mogo.eagle.core.function.api.driver.video.IDriveSeatVideoProvider.Event.Playing
|
||||
import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizListener
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.apiCall
|
||||
import com.mogo.eagle.core.network.request
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.AppStateManager
|
||||
import com.tencent.liteav.basic.log.TXCLog
|
||||
@@ -48,9 +50,11 @@ class DriveSeatVideoProviderImpl : IDriveSeatVideoProvider {
|
||||
private const val TAG = "DriveSeatVideoProvider"
|
||||
}
|
||||
|
||||
@Volatile private var target: WeakReference<TXCloudVideoView>? = null
|
||||
@Volatile
|
||||
private var target: WeakReference<TXCloudVideoView>? = null
|
||||
|
||||
@Volatile private var timer: Job? = null
|
||||
@Volatile
|
||||
private var timer: Job? = null
|
||||
|
||||
private val scope by lazy { CoroutineScope(Dispatchers.IO + SupervisorJob()) }
|
||||
|
||||
@@ -63,22 +67,40 @@ class DriveSeatVideoProviderImpl : IDriveSeatVideoProvider {
|
||||
internal interface IVideoLiveUrlApi {
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@GET("/eagleEye-mis/camera/monitor/watch/status")
|
||||
suspend fun requestVideoLiveUrl(@Query(value = "numberPlate") numberPlate: String, @Query("cameraType") cameraType: Int, @Query("protocolType") protocolType: Int): BaseResponse<VideoUrlData>
|
||||
suspend fun requestVideoLiveUrl(
|
||||
@Query(value = "numberPlate") numberPlate: String,
|
||||
@Query("cameraType") cameraType: Int,
|
||||
@Query("protocolType") protocolType: Int
|
||||
): BaseResponse<VideoUrlData>
|
||||
}
|
||||
|
||||
|
||||
override suspend fun requestVideoInfo(): VideoUrlData? {
|
||||
override fun requestVideoInfo(onSuccess: (VideoUrlData) -> Unit, onError: (String) -> Unit) {
|
||||
val plateNumber = CallerDataCenterBizListener.getPlateNumber()
|
||||
// val plateNumber = "京A40188D"
|
||||
Log.d(TAG, "requestVideoInfo -> $plateNumber")
|
||||
if (plateNumber == null || TextUtils.isEmpty(plateNumber)) {
|
||||
Log.e(TAG, "-- isVideoLiveUsable -- plate number is empty.")
|
||||
return null
|
||||
onError.invoke("plate number is empty.")
|
||||
}
|
||||
request<BaseResponse<VideoUrlData>> {
|
||||
loader {
|
||||
apiCall {
|
||||
getApi().requestVideoLiveUrl(plateNumber!!, 2, 2)
|
||||
}
|
||||
}
|
||||
onSuccess {
|
||||
data = it.result
|
||||
Log.e(
|
||||
TAG,
|
||||
"-- isVideoLiveUsable -- receive 请求成功: { msg: ${it.msg}, result: ${it.result}}"
|
||||
)
|
||||
onSuccess.invoke(it.result)
|
||||
}
|
||||
onError {
|
||||
Log.e(TAG, "-- isVideoLiveUsable -- receive 请求失败: { msg: ${it.message}")
|
||||
onError.invoke("请求失败 , ${it.message}")
|
||||
}
|
||||
}
|
||||
val resp = getApi()?.requestVideoLiveUrl(plateNumber, 2, 2) ?: return null
|
||||
Log.e(TAG, "-- isVideoLiveUsable -- receive response: {code: ${resp.code}, msg: ${resp.msg}, result: ${resp.result}}")
|
||||
data = resp.result
|
||||
return resp.result
|
||||
}
|
||||
|
||||
override fun getDriveVideoView(playUrl: String, playCallback: ((Event) -> Unit)?): View? {
|
||||
@@ -148,7 +170,8 @@ class DriveSeatVideoProviderImpl : IDriveSeatVideoProvider {
|
||||
}
|
||||
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class) override fun poller(): Flow<Boolean> = channelFlow {
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override fun poller(): Flow<Boolean> = channelFlow {
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
throw AssertionError("此方法不支持司机屏使用")
|
||||
}
|
||||
@@ -174,13 +197,12 @@ class DriveSeatVideoProviderImpl : IDriveSeatVideoProvider {
|
||||
Log.d(TAG, "开启定时轮询请求...")
|
||||
while (true) {
|
||||
Log.d(TAG, "当次请求开始...")
|
||||
val result = requestVideoInfo()
|
||||
if (result != null) {
|
||||
data = result
|
||||
requestVideoInfo({
|
||||
data = it
|
||||
chl.get()?.trySend(true)
|
||||
} else {
|
||||
},{
|
||||
chl.get()?.trySend(false)
|
||||
}
|
||||
})
|
||||
Log.d(TAG, "当次请求结束...")
|
||||
delay(5000)
|
||||
}
|
||||
@@ -200,7 +222,8 @@ class DriveSeatVideoProviderImpl : IDriveSeatVideoProvider {
|
||||
return isPlaying.get()
|
||||
}
|
||||
|
||||
private fun getApi(): IVideoLiveUrlApi? {
|
||||
return MoGoRetrofitFactory.getInstanceNoCallAdapter(HostConst.HOST_RELEASE).create(IVideoLiveUrlApi::class.java)
|
||||
private fun getApi(): IVideoLiveUrlApi {
|
||||
return MoGoRetrofitFactory.getInstanceNoCallAdapter(HostConst.HOST_RELEASE)
|
||||
.create(IVideoLiveUrlApi::class.java)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user