add new func of live module and realTime add new field
This commit is contained in:
@@ -2,7 +2,14 @@ package com.mogo.cloud.live.listener;
|
||||
|
||||
public interface IRequestLiveListener {
|
||||
|
||||
void onSuccess();
|
||||
default void onSuccess() {
|
||||
}
|
||||
|
||||
default void onSuccess(String liveUrl) {
|
||||
}
|
||||
|
||||
default void onSuccess(String liveSn, String liveUrl, double lat, double lon) {
|
||||
}
|
||||
|
||||
void onError(Throwable e);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.mogo.cloud.live.constant.LiveConstant;
|
||||
import com.mogo.cloud.live.listener.IRequestLiveListener;
|
||||
import com.mogo.cloud.live.model.BaseData;
|
||||
import com.mogo.cloud.live.model.LivePush;
|
||||
import com.mogo.cloud.live.model.LiveReceive;
|
||||
import com.mogo.cloud.live.network.LiveApiServer;
|
||||
import com.mogo.cloud.network.NetConstants;
|
||||
import com.mogo.cloud.network.RetrofitFactory;
|
||||
@@ -32,7 +33,7 @@ public class RequestLiveManager {
|
||||
private final LiveApiServer liveApiServer;
|
||||
|
||||
private RequestLiveManager() {
|
||||
liveApiServer = RetrofitFactory.INSTANCE.getInstance(NetConstants.DEVA_HOST)
|
||||
liveApiServer = RetrofitFactory.INSTANCE.getInstance(NetConstants.DEVA_HOST) //todo 涉及直播接口 没有对HttpDNS进行配置
|
||||
.create(LiveApiServer.class);
|
||||
}
|
||||
|
||||
@@ -50,18 +51,18 @@ public class RequestLiveManager {
|
||||
/**
|
||||
* 请求服务器查看指定车机开启或关闭直播
|
||||
*
|
||||
* @param type
|
||||
* @param liveSn
|
||||
* @param requestLiveListener
|
||||
* @param type 0:open 1:close
|
||||
* @param liveSn 直播SN
|
||||
* @param requestLiveListener {@link IRequestLiveListener}
|
||||
*/
|
||||
public void requestVehicleHeadLive(String type, String liveSn, IRequestLiveListener requestLiveListener) {
|
||||
public void requestDesignativeVehicleLive(String type, String liveSn, IRequestLiveListener requestLiveListener) {
|
||||
Gson gson = new Gson();
|
||||
LivePush livePush = new LivePush(liveSn, type, FRONT_CAMERA);
|
||||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("data", gson.toJson(livePush));
|
||||
liveApiServer.getVehicleHeadLive(map)
|
||||
liveApiServer.getDesignativeVehicleLive(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseData>() {
|
||||
@@ -82,7 +83,153 @@ public class RequestLiveManager {
|
||||
if (requestLiveListener != null) {
|
||||
requestLiveListener.onError(e);
|
||||
}
|
||||
Logger.e(LiveConstant.TAG, "requestVehicleHeadLive exception : " + e);
|
||||
Logger.e(LiveConstant.TAG, "requestDesignativeVehicleLive exception : " + e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求服务器查看前方车机开启直播
|
||||
*
|
||||
* @param lat 纬度
|
||||
* @param lon 经度
|
||||
* @param bearing 方向角
|
||||
* @param requestLiveListener {@link IRequestLiveListener}
|
||||
*/
|
||||
public void requestFrontVehicleLive(double lat, double lon, int bearing, IRequestLiveListener requestLiveListener) {
|
||||
Gson gson = new Gson();
|
||||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
LivePush livePush = new LivePush(sn, FRONT_CAMERA, lat, lon, bearing);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("data", gson.toJson(livePush));
|
||||
liveApiServer.getFrontVehicleLive(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseData<LiveReceive>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseData<LiveReceive> baseData) {
|
||||
if (requestLiveListener != null) {
|
||||
LiveReceive liveReceive = baseData.result;
|
||||
if (liveReceive != null && liveReceive.getLive() != null && liveReceive.getSn() != null) {
|
||||
requestLiveListener.onSuccess(liveReceive.getSn(), liveReceive.getLive(),
|
||||
liveReceive.getLat(), liveReceive.getLon());
|
||||
} else {
|
||||
Logger.e(LiveConstant.TAG, "requestFrontVehicleLive exception : live receive msg is wrong, please check param");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
if (requestLiveListener != null) {
|
||||
requestLiveListener.onError(e);
|
||||
}
|
||||
Logger.e(LiveConstant.TAG, "requestFrontVehicleLive exception : " + e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求服务器查看前方路口直播
|
||||
*
|
||||
* @param lat 纬度
|
||||
* @param lon 经度
|
||||
* @param bearing 方向角
|
||||
* @param requestLiveListener {@link IRequestLiveListener}
|
||||
*/
|
||||
public void requestFrontIntersectionLive(double lat, double lon, int bearing, IRequestLiveListener requestLiveListener) {
|
||||
Gson gson = new Gson();
|
||||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
LivePush livePush = new LivePush(sn, lat, lon, bearing);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("data", gson.toJson(livePush));
|
||||
liveApiServer.getFrontIntersectionLive(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseData<LiveReceive>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseData<LiveReceive> baseData) {
|
||||
if (requestLiveListener != null) {
|
||||
LiveReceive liveReceive = baseData.result;
|
||||
if (liveReceive != null && liveReceive.getLive() != null) {
|
||||
requestLiveListener.onSuccess(liveReceive.getLive());
|
||||
} else {
|
||||
Logger.e(LiveConstant.TAG, "requestFrontIntersectionLive exception : live receive msg is wrong, please connect tech");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
if (requestLiveListener != null) {
|
||||
requestLiveListener.onError(e);
|
||||
}
|
||||
Logger.e(LiveConstant.TAG, "requestFrontIntersectionLive exception : " + e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void requestDesignativeIntersectionLive(int cameraId, double lat, double lon, IRequestLiveListener requestLiveListener) {
|
||||
Gson gson = new Gson();
|
||||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
LivePush livePush = new LivePush(cameraId, lat, lon);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("data", gson.toJson(livePush));
|
||||
liveApiServer.getDesignativeIntersectionLive(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseData<LiveReceive>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseData<LiveReceive> baseData) {
|
||||
if (requestLiveListener != null) {
|
||||
LiveReceive liveReceive = baseData.result;
|
||||
if (liveReceive != null && liveReceive.getLive() != null) {
|
||||
requestLiveListener.onSuccess(liveReceive.getLive());
|
||||
} else {
|
||||
Logger.e(LiveConstant.TAG, "requestDesignativeIntersectionLive exception : live receive msg is wrong, please connect tech");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
if (requestLiveListener != null) {
|
||||
requestLiveListener.onError(e);
|
||||
}
|
||||
Logger.e(LiveConstant.TAG, "requestDesignativeIntersectionLive exception : " + e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,10 +4,11 @@ import com.elegant.network.NetConstants;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class BaseData implements Serializable, Cloneable {
|
||||
public class BaseData<T> implements Serializable, Cloneable {
|
||||
|
||||
public int code = NetConstants.NO_DATA;
|
||||
public String msg;
|
||||
public T result;
|
||||
|
||||
public BaseData clone() {
|
||||
BaseData obj = null;
|
||||
@@ -18,4 +19,8 @@ public class BaseData implements Serializable, Cloneable {
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
public T getT() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,19 @@ package com.mogo.cloud.live.model;
|
||||
*/
|
||||
public class LivePush {
|
||||
|
||||
private String sn;
|
||||
private String type;
|
||||
private int id; //路口摄像头id
|
||||
private String sn; //直播车机sn
|
||||
private String type; //直播类型 0:开启直播 1:关闭直播
|
||||
private String videoChannel; //C_1 前摄
|
||||
private double lat; //本机纬度
|
||||
private double lon; //本机经度
|
||||
private int bearing; //本机方向角
|
||||
|
||||
public LivePush(int id, double lat, double lon) {
|
||||
this.id = id;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public LivePush(String sn, String type, String videoChannel) {
|
||||
this.sn = sn;
|
||||
@@ -15,6 +25,29 @@ public class LivePush {
|
||||
this.videoChannel = videoChannel;
|
||||
}
|
||||
|
||||
public LivePush(String sn, double lat, double lon, int bearing) {
|
||||
this.sn = sn;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
public LivePush(String sn, String videoChannel, double lat, double lon, int bearing) {
|
||||
this.sn = sn;
|
||||
this.videoChannel = videoChannel;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
@@ -39,12 +72,40 @@ public class LivePush {
|
||||
this.videoChannel = videoChannel;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public int getBearing() {
|
||||
return bearing;
|
||||
}
|
||||
|
||||
public void setBearing(int bearing) {
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LivePush{" +
|
||||
"sn='" + sn + '\'' +
|
||||
"id=" + id +
|
||||
", sn='" + sn + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", videoChannel='" + videoChannel + '\'' +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", bearing=" + bearing +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.mogo.cloud.live.model;
|
||||
|
||||
/**
|
||||
* 调用服务端接口直播返回数据
|
||||
*/
|
||||
public class LiveReceive {
|
||||
|
||||
//直播摄像头id
|
||||
private int id;
|
||||
//直播车机sn
|
||||
private String sn;
|
||||
//直播车机纬度
|
||||
private double lat;
|
||||
//直播车机经度
|
||||
private double lon;
|
||||
//直播流url
|
||||
private String live;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public String getLive() {
|
||||
return live;
|
||||
}
|
||||
|
||||
public void setLive(String live) {
|
||||
this.live = live;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LiveReceive{" +
|
||||
"id=" + id +
|
||||
", sn='" + sn + '\'' +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", live='" + live + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.cloud.live.network;
|
||||
|
||||
import com.mogo.cloud.live.model.BaseData;
|
||||
import com.mogo.cloud.live.model.LiveReceive;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,22 +15,42 @@ import retrofit2.http.POST;
|
||||
*/
|
||||
public interface LiveApiServer {
|
||||
/**
|
||||
* 获取车辆前方直播Url
|
||||
* 获取特定车辆直播Url
|
||||
*
|
||||
* @param vehicleHeadLiveMap 请求数据
|
||||
* @param designativeVehicleHeadLiveMap 请求数据
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/dataSave/integratedServices/app/push/no/livePushAndSwitch/v1")
|
||||
Observable<BaseData> getVehicleHeadLive(@FieldMap Map<String, String> vehicleHeadLiveMap);
|
||||
Observable<BaseData> getDesignativeVehicleLive(@FieldMap Map<String, String> designativeVehicleHeadLiveMap);
|
||||
|
||||
/**
|
||||
* 获取前方车辆直播Url
|
||||
*
|
||||
* @param frontVehicleHeadLiveMap 请求数据
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("yycp-geo-fence-carService/front/car")
|
||||
Observable<BaseData<LiveReceive>> getFrontVehicleLive(@FieldMap Map<String, String> frontVehicleHeadLiveMap);
|
||||
|
||||
/**
|
||||
* 获取前方路口直播Url
|
||||
*
|
||||
* @param intersectionLiveMap 请求数据
|
||||
* @param frontIntersectionLiveMap 请求数据
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("yycp-geo-fence-carService/front/crossing")
|
||||
Observable<BaseData<LiveReceive>> getFrontIntersectionLive(@FieldMap Map<String, String> frontIntersectionLiveMap);
|
||||
|
||||
/**
|
||||
* 获取固定路口摄像头直播Url
|
||||
*
|
||||
* @param designativeIntersectionLiveMap 请求数据
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("")
|
||||
Observable<BaseData> getIntersectionLive(@FieldMap Map<String, String> intersectionLiveMap);
|
||||
Observable<BaseData<LiveReceive>> getDesignativeIntersectionLive(@FieldMap Map<String, String> designativeIntersectionLiveMap);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user