diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java index 682e52f760..ddac88ec6b 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/test/V2XTestConsoleWindow.java @@ -22,8 +22,10 @@ import com.mogo.module.v2x.V2XConst; import com.mogo.module.v2x.V2XServiceManager; import com.mogo.module.v2x.alarm.V2XAlarmServer; import com.mogo.module.v2x.entity.net.V2XSpecialCarRes; +import com.mogo.module.v2x.scenario.scene.livecar.V2XVoiceCallLiveBiz; import com.mogo.module.v2x.utils.TestOnLineCarUtils; import com.mogo.module.v2x.utils.V2XSQLiteUtils; +import com.mogo.module.v2x.voice.V2XVoiceConstants; import com.mogo.utils.TipToast; import com.zhidao.carchattingprovider.MogoDriverInfo; @@ -51,6 +53,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout { private Button mBtnTriggerPushEvent; private Button mBtnTriggerPushLiveCarEvent; private Button mBtnTriggerAnimationEvent; + private Button mBtnbtnFrontCarLiveEvent; private Button mBtnTriggerFatigueDrivingEvent; private Button mBtnTriggerSeekHelpEvent; private Button mBtnTriggerParkEvent; @@ -112,6 +115,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout { mBtnTriggerPushEvent = findViewById(R.id.btnTriggerPushEvent); mBtnTriggerPushLiveCarEvent = findViewById(R.id.btnTriggerPushLiveCarEvent); mBtnTriggerAnimationEvent = findViewById(R.id.btnTriggerAnimationEvent); + mBtnbtnFrontCarLiveEvent = findViewById(R.id.btnFrontCarLiveEvent); mBtnTriggerFatigueDrivingEvent = findViewById(R.id.btnTriggerFatigueDrivingEvent); mBtnTriggerSeekHelpEvent = findViewById(R.id.btnTriggerSeekHelpEvent); mBtnTriggerParkEvent = findViewById(R.id.btnTriggerParkEvent); @@ -236,6 +240,10 @@ public class V2XTestConsoleWindow extends ConstraintLayout { LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); }); + mBtnbtnFrontCarLiveEvent.setOnClickListener(v -> { + V2XVoiceCallLiveBiz.getInstance().getFrontCarLive(); + }); + mBtnTriggerFatigueDrivingEvent.setOnClickListener(v -> { V2XMessageEntity v2XMessageEntity = TestOnLineCarUtils.getV2XScenarioFatigueDrivingData(); @@ -280,7 +288,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout { mBtnTriggerTrafficSearch.setOnClickListener(v -> V2XServiceManager.getIMogoTrafficUploadProvider().verifyCurrentTrafficStatus()); mBtnTriggerRecommendRouteEvent.setOnClickListener(view -> { - // V2XServiceManager.getV2XRefreshModel().queryRoadData("ZD802C1938L10797"); + // V2XServiceManager.getV2XRefreshModel().queryRoadData("ZD802C1938L10797"); V2XServiceManager.getV2XRefreshModel().queryRoadData("ZD802B1932L00622"); }); diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/CarZegoLiveVideoView.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/CarZegoLiveVideoView.java index 5e1eb94ee1..143a3fa344 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/CarZegoLiveVideoView.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/CarZegoLiveVideoView.java @@ -10,6 +10,7 @@ import android.view.SurfaceView; import android.view.View; import android.widget.ProgressBar; import android.widget.TextView; + import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.ContextCompat; @@ -37,6 +38,7 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME; * @since: 2021/2/23 */ public class CarZegoLiveVideoView extends RoundLayout { + private static final String TAG = "CarZegoLiveVideoView"; private SurfaceView mSurfaceView; private ProgressBar mLoading; private ConstraintLayout mClLoadError; @@ -99,61 +101,31 @@ public class CarZegoLiveVideoView extends RoundLayout { /** * 开始直播 - * - * @param carLiveInfo 要直播的车机,如果没有直播的地址需要重新获取最新的直播地址 */ public void startLive(MarkerCarInfo.CarLiveInfo carLiveInfo) { - // 进行直播播放 - if (mSurfaceView != null - && carLiveInfo != null) { - if (!TextUtils.isEmpty(carLiveInfo.getVideoUrl())) { - AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoice(AbsMogoApplication.getApp().getString(R.string.v2x_voice_see_front_car_live)); - setCarLiveInfo(carLiveInfo); - playLiveVideo(carLiveInfo); - } - // 根据SN重新获取直播流地址 - else { - V2XServiceManager - .getV2XRefreshModel() - .livePush(new V2XRefreshCallback() { - @Override - public void onSuccess(V2XLivePushVoRes result) { - AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoice(AbsMogoApplication.getApp().getString(R.string.v2x_voice_see_front_car_live)); - mClLoadError.setVisibility(GONE); - mClLoadError.setVisibility(GONE); - try { - MarkerCarInfo.CarLiveInfo carRealLiveInfo = new MarkerCarInfo.CarLiveInfo(); - carRealLiveInfo.setVideoUrl(result.getResult().getPlayUrl().getRtmp()); - carRealLiveInfo.setVideoSn(carLiveInfo.getVideoSn()); - carRealLiveInfo.setVideoChannel(result.getResult().getVideoChannel()); - setCarLiveInfo(carLiveInfo); - playLiveVideo(carRealLiveInfo); - } catch (Exception e) { - e.printStackTrace(); - } - } + if (mSurfaceView != null && carLiveInfo != null) { + AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoice(AbsMogoApplication.getApp().getString(R.string.v2x_voice_see_front_car_live)); + playLiveVideo(carLiveInfo); + mClLoadError.setVisibility(GONE); + Logger.d(TAG, "startLive"); - @Override - public void onFail(String msg) { - Logger.e(MODULE_NAME, "播放器:" + msg); - AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoice(AbsMogoApplication.getApp().getString(R.string.v2x_voice_see_front_car_live_error)); - mLoading.setVisibility(GONE); - mClLoadError.setVisibility(VISIBLE); - } - }, carLiveInfo.getVideoSn(), 0); - } + } else { + AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoice(AbsMogoApplication.getApp().getString(R.string.v2x_voice_see_front_car_live_error)); + mLoading.setVisibility(GONE); + mClLoadError.setVisibility(VISIBLE); + Logger.d(TAG, "没有找到可直播车机"); } } /** - * 播放直播流,且开始心跳 + * 播放直播流 */ private void playLiveVideo(MarkerCarInfo.CarLiveInfo carLiveInfo) { - startHeartLive(carLiveInfo); if (mSurfaceView != null) { MoGoAiCloudTrafficLive.viewVehicleHeadLive(AbsMogoApplication.getApp(), carLiveInfo.getVideoSn(), mSurfaceView, new ITrafficLiveCallBack() { @Override public void onLive() { + Logger.d(TAG, "onLive"); mLoading.setVisibility(VISIBLE); mClLoadError.setVisibility(GONE); refreshStatusToListener(true); @@ -163,7 +135,7 @@ public class CarZegoLiveVideoView extends RoundLayout { @Override public void onDisConnect() { - + Logger.d(TAG, "失去连接onDisConnect"); } @Override @@ -184,41 +156,12 @@ public class CarZegoLiveVideoView extends RoundLayout { } } - // 刷新直播心跳 - private void startHeartLive(MarkerCarInfo.CarLiveInfo carLiveInfo) { - try { - if (!TextUtils.isEmpty(carLiveInfo.getVideoSn()) - && !TextUtils.isEmpty(carLiveInfo.getVideoChannel())) { - V2XServiceManager - .getV2XRefreshModel() - .refreshHeartBeat(carLiveInfo.getVideoSn(), - carLiveInfo.getVideoChannel(), - null); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - public void stopLive(MarkerCarInfo.CarLiveInfo carLiveInfo) { try { - Logger.w(MODULE_NAME, "心跳:关闭直播..."); + Logger.w(TAG, "心跳:关闭直播..."); // 暂停 MoGoAiCloudTrafficLive.stopLive(carLiveInfo.getVideoSn()); - // 停止推流 - V2XServiceManager - .getV2XRefreshModel() - .livePush(new V2XRefreshCallback() { - @Override - public void onSuccess(V2XLivePushVoRes result) { - Logger.d(MODULE_NAME, "播放器:" + result); - } - - @Override - public void onFail(String msg) { - Logger.e(MODULE_NAME, "播放器:" + msg); - } - }, carLiveInfo.getVideoSn(), 1); + MoGoAiCloudTrafficLive.destroyLive(); } catch (Exception e) { e.printStackTrace(); } diff --git a/modules/mogo-module-v2x/src/main/res/layout/view_video_layout_see_live.xml b/modules/mogo-module-v2x/src/main/res/layout/view_video_layout_see_live.xml index e75175d07a..6a5a50343c 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/view_video_layout_see_live.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/view_video_layout_see_live.xml @@ -10,7 +10,7 @@ diff --git a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml index 65c2618955..b9253925c9 100644 --- a/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml +++ b/modules/mogo-module-v2x/src/main/res/layout/window_test_console.xml @@ -280,6 +280,20 @@ android:textSize="@dimen/dp_22" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" /> + +