add MoGoAiCloud sdk --> socket passport replace origin logic
This commit is contained in:
@@ -8,9 +8,9 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.CloudRoadData;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.live.impl.AbsCameraScenario;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
|
||||
@@ -10,10 +10,9 @@ import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.CloudRoadData;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.live.listener.CameraLiveWindowStatusListener;
|
||||
import com.mogo.module.extensions.live.impl.ICameraWindow;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.service.imageloader.MogoImageView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -24,13 +23,12 @@ import com.mogo.utils.logger.Logger;
|
||||
*/
|
||||
public class PushCameraLiveWindow extends RelativeLayout implements ICameraWindow<CloudRoadData> {
|
||||
private static final String TAG = "PushCameraLiveWindow";
|
||||
private Context mContext;
|
||||
private CameraLiveGSYVideoView mLiveGSYVideoView;
|
||||
private MogoImageView mIvReportHead;
|
||||
private ImageView pushVideoClose;
|
||||
|
||||
// 直播30秒自动关闭
|
||||
private static Handler handlerV2XEvent = new Handler();
|
||||
private static final Handler handlerV2XEvent = new Handler();
|
||||
private static Runnable runnableV2XEvent;
|
||||
|
||||
public PushCameraLiveWindow() {
|
||||
@@ -47,7 +45,6 @@ public class PushCameraLiveWindow extends RelativeLayout implements ICameraWindo
|
||||
|
||||
public PushCameraLiveWindow(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mContext = context;
|
||||
initView(context);
|
||||
}
|
||||
|
||||
@@ -91,11 +88,10 @@ public class PushCameraLiveWindow extends RelativeLayout implements ICameraWindo
|
||||
@Override
|
||||
public void close() {
|
||||
// 停止倒计时
|
||||
if (handlerV2XEvent != null && runnableV2XEvent != null) {
|
||||
if (runnableV2XEvent != null) {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
runnableV2XEvent = null;
|
||||
}
|
||||
|
||||
//移除窗体
|
||||
MogoApisHandler.getInstance().getApis().getTopViewManager().removeViewNoLinkage(this);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.mogo.module.extensions.live.impl;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
|
||||
|
||||
public abstract class AbsCameraScenario<T> implements ICameraScenario {
|
||||
|
||||
@@ -6,19 +6,17 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.CloudRoadData;
|
||||
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
import com.mogo.module.extensions.navi.VrModeNavInfoView;
|
||||
import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
import com.mogo.service.adas.IMogoAdasWarnMessageCallback;
|
||||
import com.mogo.service.adas.MogoADASWarnType;
|
||||
import com.mogo.service.adas.entity.ADASWarnMessage;
|
||||
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.WebSocketMsgType;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@@ -30,7 +28,7 @@ import org.json.JSONObject;
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLocationListener,
|
||||
Handler.Callback, IMogoOnWebSocketMessageListener<MogoSnapshotSetData> {
|
||||
Handler.Callback, IMogoCloudOnMsgListener {
|
||||
private static final String TAG = "AdasNoticeHelper";
|
||||
|
||||
private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_OBU = 1001;
|
||||
@@ -77,8 +75,7 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasWarnMessageCallback(this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG, this);
|
||||
// 先不监听服务端下发消息
|
||||
// MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this);
|
||||
|
||||
// MoGoAiCloudRealTime.registerOnMsgListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +86,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().showADAS();
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().removeAdasWarnMessageCallback(this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
|
||||
// MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).unregisterOnWebSocketMessageListener(this);
|
||||
// 先不监听服务端下发消息
|
||||
// MoGoAiCloudRealTime.unRegisterOnMsgListener(this);
|
||||
context.unregisterReceiver(adasReceiver);
|
||||
}
|
||||
}
|
||||
@@ -200,13 +198,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketMsgType getDownLinkType() {
|
||||
return WebSocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
|
||||
}
|
||||
public void onMsgSend(long id) {
|
||||
|
||||
@Override
|
||||
public Class<MogoSnapshotSetData> target() {
|
||||
return MogoSnapshotSetData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,17 +8,16 @@ import android.util.Log;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.CloudRoadData;
|
||||
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.live.CameraLiveManager;
|
||||
import com.mogo.module.extensions.live.CameraWindow3DAdapter;
|
||||
import com.mogo.module.extensions.live.PushDataType;
|
||||
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.WebSocketMsgType;
|
||||
import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -26,7 +25,7 @@ import com.mogo.utils.logger.Logger;
|
||||
/**
|
||||
* vr模式下,摄像头消息 AdasNoticeHelper
|
||||
*/
|
||||
public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<MogoSnapshotSetData> {
|
||||
public class CameraLiveNoticeHelper implements IMogoCloudOnMsgListener {
|
||||
private static final String TAG = "CameraLiveNoticeHelper";
|
||||
private Context mContext;
|
||||
private static IMogoMarker mMogoMarker;
|
||||
@@ -40,28 +39,25 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
|
||||
Logger.d(TAG, "init ======= ");
|
||||
mContext = context;
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(mContext).registerOnWebSocketMessageListener(this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoMarkerClickListener(PushDataType.TYPE_PUSH_CAMERA_DATA, new IMogoMarkerClickListener() {
|
||||
@Override
|
||||
public boolean onMarkerClicked(IMogoMarker marker) {
|
||||
//点击的marker的具体数据
|
||||
if (mCloudRoadData != null && !TextUtils.isEmpty(mCloudRoadData.getRtmpUrl())) {
|
||||
CameraLiveManager.getInstance().init(mCloudRoadData);
|
||||
} else {
|
||||
Logger.e(TAG, " onMarkerClicked mCloudRoadData == null ");
|
||||
TipToast.shortTip("直播流地址为空");
|
||||
}
|
||||
|
||||
return false;
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoMarkerClickListener(PushDataType.TYPE_PUSH_CAMERA_DATA, marker -> {
|
||||
//点击的marker的具体数据
|
||||
if (mCloudRoadData != null && !TextUtils.isEmpty(mCloudRoadData.getRtmpUrl())) {
|
||||
CameraLiveManager.getInstance().init(mCloudRoadData);
|
||||
} else {
|
||||
Logger.e(TAG, " onMarkerClicked mCloudRoadData == null ");
|
||||
TipToast.shortTip("直播流地址为空");
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// loadMarker(false);
|
||||
}
|
||||
|
||||
public void release() {
|
||||
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(mContext).unregisterOnWebSocketMessageListener(this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoMarkerClickListener( PushDataType.TYPE_PUSH_CAMERA_DATA );
|
||||
MoGoAiCloudRealTime.unRegisterOnMsgListener(this);
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoMarkerClickListener(PushDataType.TYPE_PUSH_CAMERA_DATA);
|
||||
mCloudRoadData = null;
|
||||
mContext = null;
|
||||
}
|
||||
@@ -69,37 +65,18 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
|
||||
public void enterVrMode() {
|
||||
Logger.d(TAG, "进入vr模式=========");
|
||||
isVrMode = true;
|
||||
|
||||
// loadMarker(true);
|
||||
}
|
||||
|
||||
public void exitVrMode() {
|
||||
Logger.d(TAG, "退出vr模式=========");
|
||||
isVrMode = false;
|
||||
|
||||
// loadMarker(false);
|
||||
}
|
||||
|
||||
//test
|
||||
private void loadMarker(boolean isVrMode) {
|
||||
mCloudRoadData = new CloudRoadData();
|
||||
mCloudRoadData.setRtmpUrl("rtmp://58.200.131.2:1935/livetv/hunantv");
|
||||
|
||||
mCloudRoadData.setLat(40.200583);
|
||||
mCloudRoadData.setLon(116.738538);
|
||||
mCloudRoadData.setUuid("10011");
|
||||
if (isVrMode) {
|
||||
addVrCameraMarker(mCloudRoadData);
|
||||
} else {
|
||||
addNormalCameraMarker(mCloudRoadData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PushRoadConditionDrawer
|
||||
* vr模式
|
||||
*
|
||||
* @param roadData
|
||||
* @param roadData 道路数据
|
||||
*/
|
||||
private void addVrCameraMarker(CloudRoadData roadData) {
|
||||
Log.e(TAG, "addVrCameraMarker --lat = " + roadData.getLat() + "--lon =" + roadData.getLon() + "--uuid = " + roadData.getUuid() + "---rtmpUrl =" + roadData.getRtmpUrl());
|
||||
@@ -126,7 +103,7 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
|
||||
/**
|
||||
* 普通模式
|
||||
*
|
||||
* @param roadData
|
||||
* @param roadData 道路数据
|
||||
*/
|
||||
private void addNormalCameraMarker(CloudRoadData roadData) {
|
||||
Log.e(TAG, "addNormalCameraMarker --lat = " + roadData.getLat() + " --lon =" + roadData.getLon() + "--uuid = " + roadData.getUuid() + "---rtmpUrl =" + roadData.getRtmpUrl());
|
||||
@@ -157,22 +134,7 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketMsgType getDownLinkType() {
|
||||
return WebSocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<MogoSnapshotSetData> target() {
|
||||
return MogoSnapshotSetData.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param obj
|
||||
*/
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData obj) {
|
||||
Logger.d(TAG, "onMsgReceived cameralive : " + obj);
|
||||
private void renderMarker(MogoSnapshotSetData obj) {
|
||||
if (obj != null) {
|
||||
if (obj.getCamera() != null && !TextUtils.isEmpty(obj.getCamera().getRtmpUrl())) {
|
||||
mCloudRoadData = obj.getCamera();
|
||||
@@ -209,7 +171,7 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
|
||||
if (obj.getCamera() != null) {
|
||||
Log.e(TAG, "onMsgReceived RtmpUrl() = " + obj.getCamera().getRtmpUrl());
|
||||
} else {
|
||||
Log.e(TAG,"obj.getCamera() == null ----------- ");
|
||||
Log.e(TAG, "obj.getCamera() == null ----------- ");
|
||||
}
|
||||
removeCameraMarker();
|
||||
}
|
||||
@@ -218,4 +180,14 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgSend(long id) {
|
||||
Logger.d(TAG, "onMsgSend id : " + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
|
||||
Logger.d(TAG, "onMsgReceived mogoSnapshotSetData : " + mogoSnapshotSetData);
|
||||
renderMarker(mogoSnapshotSetData);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user