[Change]
开始直播功能开发 Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -29,7 +29,7 @@ project.android.productFlavors {
|
||||
// 构建的应用身份类型,司机|乘客
|
||||
buildConfigField 'int', 'APP_IDENTITY_MODE', "0x02"
|
||||
// 连接的工控机IP地址
|
||||
buildConfigField 'String', 'ADAS_CONNECT_IP', "\"192.168.1.102\""
|
||||
buildConfigField 'String', 'ADAS_CONNECT_IP', "\"192.168.1.103\""
|
||||
// 构建的是否是演示(美化)模式
|
||||
buildConfigField 'boolean', 'IS_DEMO_MODE', 'true'
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ public class MoGoAdasListenerImpl implements OnAdasListener {
|
||||
@Override
|
||||
public void onAutopilotTrajectory(List<TrajectoryInfo> trajectoryList) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
Logger.d(TAG, "onAutopilotTrajectory : " + trajectoryList);
|
||||
//Logger.d(TAG, "onAutopilotTrajectory : " + trajectoryList);
|
||||
ArrayList<ADASTrajectoryInfo> trajectoryInfoArrayList = new ArrayList<>();
|
||||
if (trajectoryList != null && trajectoryList.size() > 0) {
|
||||
for (TrajectoryInfo trajectory : trajectoryList) {
|
||||
@@ -271,7 +271,7 @@ public class MoGoAdasListenerImpl implements OnAdasListener {
|
||||
adasTrajectoryInfo.setTheta(trajectory.getTheta());
|
||||
trajectoryInfoArrayList.add(adasTrajectoryInfo);
|
||||
}
|
||||
Log.e(TAG, "time:" + System.currentTimeMillis() + "trajectoryInfoArrayList:" + trajectoryInfoArrayList);
|
||||
//Log.e(TAG, "time:" + System.currentTimeMillis() + "trajectoryInfoArrayList:" + trajectoryInfoArrayList);
|
||||
}
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.invokeAutopilotTrajectory(trajectoryInfoArrayList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mogo.eagle.core.function.carcorder.service
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.serenegiant.usb.common.BaseService
|
||||
|
||||
/**
|
||||
* 行车记录仪服务
|
||||
* @author donghongyu
|
||||
*/
|
||||
class LivePushService : BaseService() {
|
||||
private val DEBUG = true
|
||||
val TAG = LivePushService::class.java.name
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
if (DEBUG) {
|
||||
Logger.d(TAG, "onCreate……")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (DEBUG) Log.d(TAG, "onDestroy:")
|
||||
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
|
||||
|
||||
override fun onBind(intent: Intent): IBinder? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onRebind(intent: Intent) {
|
||||
if (DEBUG) Log.d(TAG, "onRebind:$intent")
|
||||
}
|
||||
|
||||
|
||||
override fun onUnbind(intent: Intent): Boolean {
|
||||
if (DEBUG) Log.d(TAG, "onUnbind:$intent")
|
||||
|
||||
if (DEBUG) Log.d(TAG, "onUnbind:finished")
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -8,7 +8,9 @@ import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.view.*
|
||||
import android.view.animation.OvershootInterpolator
|
||||
import android.widget.Toast
|
||||
import com.mogo.cloud.live.manager.ILiveStreamManager
|
||||
import com.mogo.cloud.live.manager.LiveStreamManagerImpl
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.notification.WarningFloat
|
||||
import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
|
||||
@@ -39,6 +41,8 @@ class CarcorderPreviewView private constructor(
|
||||
private var isRequest = false
|
||||
private var isPreview = false
|
||||
|
||||
private var liveStreamManager: ILiveStreamManager? = null
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_carcorder_preview, this, true)
|
||||
}
|
||||
@@ -178,7 +182,14 @@ class CarcorderPreviewView private constructor(
|
||||
mCameraHelper?.setDefaultFrameFormat(UVCCameraHelper.FRAME_FORMAT_MJPEG)
|
||||
mCameraHelper?.initUSBMonitor(context as Activity, carcorderPreview, listener)
|
||||
|
||||
mCameraHelper?.setOnPreviewFrameListener { nv21Yuv -> Log.d(TAG, "onPreviewResult: " + nv21Yuv.size) }
|
||||
mCameraHelper?.setOnPreviewFrameListener { nv21Yuv ->
|
||||
Log.d(TAG, "onPreviewResult: " + nv21Yuv.size)
|
||||
//Log.i(TAG, "onVideoFrame byte length: " + bytesLength);
|
||||
if (liveStreamManager != null) {
|
||||
// 将摄像头采集的YUV数据推送到ZEGO
|
||||
liveStreamManager!!.notifyYUVData(nv21Yuv, 1280, 720, 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +200,19 @@ class CarcorderPreviewView private constructor(
|
||||
if (mCameraHelper != null) {
|
||||
mCameraHelper!!.registerUSB()
|
||||
}
|
||||
// 初始化直播流管理
|
||||
// 初始化直播流管理
|
||||
liveStreamManager = LiveStreamManagerImpl.getInstance((context as Activity).application,
|
||||
MoGoAiCloudClientConfig.getInstance().sn, true)
|
||||
|
||||
// 设置状态回调
|
||||
liveStreamManager!!.setLiveStatusChangeCallback { status ->
|
||||
if (status == 0) {
|
||||
Logger.d(TAG, "直播中……")
|
||||
} else {
|
||||
Logger.d(TAG, "直播结束……")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
@@ -197,6 +221,13 @@ class CarcorderPreviewView private constructor(
|
||||
if (mCameraHelper != null) {
|
||||
mCameraHelper!!.unregisterUSB()
|
||||
}
|
||||
|
||||
if (liveStreamManager != null) {
|
||||
// 停止
|
||||
liveStreamManager!!.stopLiveStream()
|
||||
// 释放资源
|
||||
liveStreamManager!!.release()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSurfaceCreated(view: CameraViewInterface?, surface: Surface?) {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/dp_768"
|
||||
android:layout_height="@dimen/dp_432"
|
||||
android:background="#FFFFFF">
|
||||
android:layout_width="1px"
|
||||
android:layout_height="1px">
|
||||
|
||||
|
||||
<com.serenegiant.usb.widget.UVCCameraTextureView
|
||||
android:id="@+id/carcorderPreview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
|
||||
@@ -260,8 +260,8 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
startService(intentMainServicee);
|
||||
|
||||
// USB 摄像头行车记录仪进程
|
||||
Intent intentCarcorderService = new Intent(this, CarcorderService.class);
|
||||
startService(intentCarcorderService);
|
||||
// Intent intentCarcorderService = new Intent(this, CarcorderService.class);
|
||||
// startService(intentCarcorderService);
|
||||
}
|
||||
|
||||
protected void loadContainerModules() {
|
||||
|
||||
Reference in New Issue
Block a user