rebuild live func

This commit is contained in:
zhongchao
2021-04-01 17:34:15 +08:00
parent 48e9ad0f49
commit 45ff90fcfb
7 changed files with 78 additions and 81 deletions

1
.idea/gradle.xml generated
View File

@@ -91,6 +91,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@@ -155,19 +155,19 @@ LOGLIB_VERSION = 1.0.4
######## MogoAiCloudSDK Version
# 网络请求
MOGO_NETWORK_VERSION=1.0.58
MOGO_NETWORK_VERSION=1.0.60
# 鉴权
MOGO_PASSPORT_VERSION=1.0.58
MOGO_PASSPORT_VERSION=1.0.60
# 常链接
MOGO_SOCKET_VERSION=1.0.58
MOGO_SOCKET_VERSION=1.0.60
# 数据采集
MOGO_REALTIME_VERSION=1.0.58
MOGO_REALTIME_VERSION=1.0.60
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.0.58
MOGO_TANLU_VERSION=1.0.60
# 直播推流
MOGO_LIVE_VERSION=1.0.58
MOGO_LIVE_VERSION=1.0.60
# 直播拉流
MOGO_TRAFFICLIVE_VERSION=1.0.58
MOGO_TRAFFICLIVE_VERSION=1.0.60
######## Foundation MogoAiCloud Module
# mogoAiCloud apk services

View File

@@ -3,17 +3,14 @@ package com.mogo.module.v2x.scenario.scene.livecar;
import android.content.Context;
import android.text.TextUtils;
import com.mogo.cloud.trafficlive.api.ITrafficIntersectionLiveCallBack;
import com.mogo.cloud.trafficlive.api.MoGoAiCloudTrafficLive;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XDemoManager;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.net.V2XDemoUserInfoRes;
import com.mogo.module.v2x.entity.net.V2XLiveCrossRoad;
import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.network.V2XRefreshModel;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
import com.mogo.module.v2x.voice.V2XVoiceManager;
import com.mogo.service.statusmanager.StatusDescriptor;
@@ -99,26 +96,25 @@ public class V2XVoiceCallLiveBiz {
.unRegisterWakeCmd(COMMAND_ZHIDAO_V2X_AHEAD_LIVE).unRegisterWakeCmd(COMMAND_ZHIDAO_V2X_CROSSROADS_LIVE);
}
/**
* 查看前方车辆直播,同方向角 200米范围
*/
public void getFrontCarLive() {
// V2XDemoUserInfoRes.ResultBean.UserListBean.UserInfoBean userInfoBean = V2XDemoManager.getInstance().getV2XDemoUserInfoEntity1().getUserInfo();
String liveCarSn = "F803EB2046PZD00149";
if (TextUtils.isEmpty(liveCarSn)) {
ToastUtils.showShort("附近没有可直播车机");
Logger.d(MODULE_NAME, "getFrontCarLive : sn is null");
return;
}
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = buildCallLiveParams(liveCarSn, null);
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = buildCallLiveParams(null, null);
mV2XVoiceCallLiveScenario = new V2XVoiceCallLiveScenario();
mV2XVoiceCallLiveScenario.setV2XWindow(new V2XVoiceCallLiveCarWindow());
mV2XVoiceCallLiveScenario.init(v2XMessageEntity);
}
/**
* 查看前方路口摄像头直播,同方向角 1公里范围
*/
public void getOpenRoadCameraLive() {
V2XRefreshModel.getInstance(mContext).queryCrossRoadsLive(new V2XRefreshCallback<V2XLiveCrossRoad>() {
MogoLocation mogoLocation = V2XServiceManager.getMogoLocationClient().getLastKnowLocation();
MoGoAiCloudTrafficLive.viewFrontIntersectionLive(mogoLocation.getLatitude(), mogoLocation.getLongitude(), ((int) mogoLocation.getBearing()), new ITrafficIntersectionLiveCallBack() {
@Override
public void onSuccess(V2XLiveCrossRoad result) {
if (result != null && result.getResult().getUrl() != null) {
String liveUrl = result.getResult().getUrl();
public void liveUrlResult(String liveUrl) {
if (!TextUtils.isEmpty(liveUrl)) {
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity = buildCallLiveParams(null, liveUrl);
mV2XVoiceCallLiveScenario = new V2XVoiceCallLiveScenario();
mV2XVoiceCallLiveScenario.setV2XWindow(new V2XVoiceCrossRoadLiveWindow());
@@ -129,12 +125,19 @@ public class V2XVoiceCallLiveBiz {
}
@Override
public void onFail(String msg) {
Logger.d(MODULE_NAME, "getOpenRoadCameraLive : " + msg);
public void onError(String errorMsg) {
Logger.d(MODULE_NAME, "getOpenRoadCameraLive : " + errorMsg);
}
});
}
/**
* 构建直播参数
*
* @param sn 直播车机sn
* @param liveUrl 直播Url
* @return {@link V2XMessageEntity<V2XPushMessageEntity>}
*/
private V2XMessageEntity<V2XPushMessageEntity> buildCallLiveParams(String sn, String liveUrl) {
V2XPushMessageEntity v2XPushMessageEntity = new V2XPushMessageEntity();
v2XPushMessageEntity.setVideoSn(sn);

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.SurfaceView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -50,7 +51,7 @@ public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
}
private void initView(Context context) {
Logger.w(MODULE_NAME, "V2X===初始化语音呼叫直播视图"); //todo 更改样式
Logger.w(MODULE_NAME, "V2X===初始化语音呼叫直播视图");
LayoutInflater.from(context).inflate(R.layout.window_see_carlive_video, this);
mV2XCarLiveVideoView = findViewById(R.id.videoPlayer);
tvCountDown = findViewById(R.id.tvCountDown);
@@ -75,7 +76,6 @@ public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
carLiveInfo.setVideoSn(entity.getVideoSn());
carLiveInfo.setVideoUrl(entity.getVideoUrl());
Logger.w(MODULE_NAME, "更新直播信息 END");
mV2XCarLiveVideoView.setCarLiveInfo(carLiveInfo);
if (isVideoPlay) {
startCountDown();
}

View File

@@ -6,7 +6,6 @@ import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.mogo.module.common.entity.MarkerCarInfo;

View File

@@ -3,6 +3,7 @@ package com.mogo.module.v2x.view;
import android.content.Context;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.SurfaceView;
@@ -12,11 +13,11 @@ import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import com.mogo.cloud.trafficlive.api.ITrafficLiveCallBack;
import com.mogo.cloud.trafficlive.api.ITrafficCarLiveCallBack;
import com.mogo.cloud.trafficlive.api.MoGoAiCloudTrafficLive;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.voice.AIAssist;
import com.mogo.module.common.entity.MarkerCarInfo;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.utils.V2XUtils;
@@ -36,17 +37,15 @@ public class CarZegoLiveVideoView extends RoundLayout {
private ProgressBar mLoading;
private ConstraintLayout mClLoadError;
private TextView mTvRefreshButton;
private String liveSn;
private MarkerCarInfo.CarLiveInfo mCarLiveInfo;
// 重新刷新直播流
private final V2XVoiceCallbackListener v2XVoiceCallbackRefreshListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
mLoading.setVisibility(VISIBLE);
mClLoadError.setVisibility(GONE);
if (mCarLiveInfo != null) {
startLive(mCarLiveInfo);
}
startLive();
}
};
@@ -76,26 +75,17 @@ public class CarZegoLiveVideoView extends RoundLayout {
mTvRefreshButton.setOnClickListener(v -> {
mLoading.setVisibility(VISIBLE);
mClLoadError.setVisibility(GONE);
if (mCarLiveInfo != null) {
startLive(mCarLiveInfo);
}
startLive();
});
}
/**
* 设置直播信息
*/
public void setCarLiveInfo(MarkerCarInfo.CarLiveInfo carLiveInfo) {
mCarLiveInfo = carLiveInfo;
}
/**
* 开始直播
*/
public void startLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
if (mSurfaceView != null && carLiveInfo != null) {
public void startLive() {
if (mSurfaceView != null) {
AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoice(AbsMogoApplication.getApp().getString(R.string.v2x_voice_see_front_car_live));
playLiveVideo(carLiveInfo);
playLiveVideo();
mClLoadError.setVisibility(GONE);
Logger.d(TAG, "startLive");
@@ -110,12 +100,16 @@ public class CarZegoLiveVideoView extends RoundLayout {
/**
* 播放直播流
*/
private void playLiveVideo(MarkerCarInfo.CarLiveInfo carLiveInfo) {
private void playLiveVideo() {
if (mSurfaceView != null) {
MoGoAiCloudTrafficLive.viewVehicleHeadLive(AbsMogoApplication.getApp(), carLiveInfo.getVideoSn(), mSurfaceView, new ITrafficLiveCallBack() {
MogoLocation mogoLocation = V2XServiceManager.getMogoLocationClient().getLastKnowLocation();
MoGoAiCloudTrafficLive.viewFrontVehicleLive(mogoLocation.getLatitude(), mogoLocation.getLongitude(), ((int) mogoLocation.getBearing()), mSurfaceView, new ITrafficCarLiveCallBack() {
@Override
public void onLive() {
public void onLive(String liveSn) {
Logger.d(TAG, "onLive");
if (!TextUtils.isEmpty(liveSn)) {
CarZegoLiveVideoView.this.liveSn = liveSn;
}
mLoading.setVisibility(VISIBLE);
mClLoadError.setVisibility(GONE);
refreshStatusToListener(true);
@@ -132,7 +126,7 @@ public class CarZegoLiveVideoView extends RoundLayout {
public void onError(String errorMsg) {
refreshStatusToListener(false);
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("直播获取识败,可以对我说重试", null);
stopLive(mCarLiveInfo);
stopLive();
mLoading.setVisibility(GONE);
mClLoadError.setVisibility(VISIBLE);
// 注册语音交互
@@ -146,11 +140,14 @@ public class CarZegoLiveVideoView extends RoundLayout {
}
}
public void stopLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
public void stopLive() {
try {
Logger.w(TAG, "心跳:关闭直播...");
// 暂停
MoGoAiCloudTrafficLive.stopLive(carLiveInfo.getVideoSn());
if (!TextUtils.isEmpty(liveSn)) {
MoGoAiCloudTrafficLive.stopCarLive(liveSn);
} else {
Logger.e(TAG, "直播 liveSn is null");
}
} catch (Exception e) {
e.printStackTrace();
}
@@ -159,14 +156,12 @@ public class CarZegoLiveVideoView extends RoundLayout {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (mCarLiveInfo != null) {
startLive(mCarLiveInfo);
}
startLive();
}
@Override
protected void onDetachedFromWindow() {
stopLive(mCarLiveInfo);
stopLive();
mLoading.setVisibility(VISIBLE);
// 反注册语音交互
V2XVoiceManager.INSTANCE
@@ -181,9 +176,9 @@ public class CarZegoLiveVideoView extends RoundLayout {
}
}
private V2XCarLiveVideoView.OnVideoStatusChange onVideoStatusChange;
private OnVideoStatusChange onVideoStatusChange;
public void addOnVideoStatusChangeListener(V2XCarLiveVideoView.OnVideoStatusChange onVideoStatusChange) {
public void addOnVideoStatusChangeListener(OnVideoStatusChange onVideoStatusChange) {
this.onVideoStatusChange = onVideoStatusChange;
}

View File

@@ -12,13 +12,13 @@ import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.cloud.trafficlive.api.ITrafficIntersectionLiveCallBack;
import com.mogo.cloud.trafficlive.api.MoGoAiCloudTrafficLive;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.entity.MarkerCarInfo;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.entity.net.V2XLiveCrossRoad;
import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.network.V2XRefreshModel;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
import com.mogo.module.v2x.voice.V2XVoiceConstants;
@@ -43,10 +43,10 @@ import static com.mogo.module.v2x.view.SimpleLiveVideoPlayer.PLAY_EVT_PLAY_BEGIN
import static com.mogo.module.v2x.view.SimpleLiveVideoPlayer.PLAY_EVT_PLAY_LOADING;
/**
* author : donghongyu
* author : donghongyu EmArrow
* e-mail : 1358506549@qq.com
* date : 2020-02-0623:07
* desc :
* date : 2020-02-06 23:07
* update : 2021-04-01 17:30
* version: 1.0
*/
public class V2XCrossRoadVideoView extends RoundLayout {
@@ -54,7 +54,7 @@ public class V2XCrossRoadVideoView extends RoundLayout {
private static final String TAG = "CrossRoadVideo";
private SimpleLiveVideoPlayer mTxcVideoView;
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
private final GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
private ProgressBar mLoading;
private ConstraintLayout mClLoadError;
private TextView mTvRefreshButton;
@@ -62,7 +62,7 @@ public class V2XCrossRoadVideoView extends RoundLayout {
private MarkerCarInfo.CarLiveInfo mCarLiveInfo;
// 重新刷新直播流
private V2XVoiceCallbackListener v2XVoiceCallbackRefreshListener = new V2XVoiceCallbackListener() {
private final V2XVoiceCallbackListener v2XVoiceCallbackRefreshListener = new V2XVoiceCallbackListener() {
@Override
public void onCallback(String command, Intent intent) {
mLoading.setVisibility(VISIBLE);
@@ -87,7 +87,7 @@ public class V2XCrossRoadVideoView extends RoundLayout {
}
private void initView(Context context) {
if(init){
if (init) {
return;
}
Logger.d("V2XCrossRoadVideoView", "V2X===初始化语音呼叫路口直播视图");
@@ -129,9 +129,9 @@ public class V2XCrossRoadVideoView extends RoundLayout {
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1));
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_clear", 1));
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_timeout", -1));
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration",1));
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration", 1));
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "packet-buffering", 0));
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "reconnect",10));
list.add(new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "reconnect", 10));
GSYVideoManager.instance().setOptionModelList(list);
GSYVideoType.enableMediaCodec();
@@ -149,7 +149,7 @@ public class V2XCrossRoadVideoView extends RoundLayout {
/**
* 开始直播
*
* @param carLiveInfo 要直播的车机,如果没有直播的地址需要重新获取最新的直播地址
* @param carLiveInfo 要直播的设备信息,如果没有直播的地址需要重新获取最新的直播地址
*/
public void startLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
initView(this.getContext());
@@ -162,11 +162,11 @@ public class V2XCrossRoadVideoView extends RoundLayout {
}
//重新获取直播流地址
else {
V2XRefreshModel.getInstance(AbsMogoApplication.getApp()).queryCrossRoadsLive(new V2XRefreshCallback<V2XLiveCrossRoad>() {
MogoLocation mogoLocation = V2XServiceManager.getMogoLocationClient().getLastKnowLocation();
MoGoAiCloudTrafficLive.viewFrontIntersectionLive(mogoLocation.getLatitude(), mogoLocation.getLongitude(), ((int) mogoLocation.getBearing()), new ITrafficIntersectionLiveCallBack() {
@Override
public void onSuccess(V2XLiveCrossRoad result) {
if (result != null && result.getResult().getUrl() != null) {
String liveUrl = result.getResult().getUrl();
public void liveUrlResult(String liveUrl) {
if (!TextUtils.isEmpty(liveUrl)) {
MarkerCarInfo.CarLiveInfo carLiveInfo = new MarkerCarInfo.CarLiveInfo();
carLiveInfo.setVideoUrl(liveUrl);
setCarLiveInfo(carLiveInfo);
@@ -177,8 +177,7 @@ public class V2XCrossRoadVideoView extends RoundLayout {
}
@Override
public void onFail(String msg) {
//获取路口实况失败
public void onError(String errorMsg) {
Logger.d(MODULE_NAME, "获取路口实况失败");
}
});