Merge remote-tracking branch 'origin/wvp-28181-2.0' into liujie-20220712

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
#	src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
This commit is contained in:
648540858
2022-07-12 16:28:51 +08:00
66 changed files with 1614 additions and 665 deletions

View File

@@ -9,6 +9,9 @@ public class StreamInfo {
private String deviceID;
private String channelId;
private String flv;
private String ip;
private String https_flv;
private String ws_flv;
private String wss_flv;
@@ -292,4 +295,12 @@ public class StreamInfo {
public void setProgress(double progress) {
this.progress = progress;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
}

View File

@@ -58,6 +58,8 @@ public class VideoManagerConstants {
public static final String MEDIA_TRANSACTION_USED_PREFIX = "VMP_MEDIA_TRANSACTION_";
public static final String MEDIA_STREAM_AUTHORITY = "MEDIA_STREAM_AUTHORITY_";
public static final String SIP_CSEQ_PREFIX = "VMP_SIP_CSEQ_";
public static final String SIP_SN_PREFIX = "VMP_SIP_SN_";
@@ -71,6 +73,8 @@ public class VideoManagerConstants {
public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_";
//************************** redis 消息*********************************
// 流变化的通知
@@ -79,9 +83,15 @@ public class VideoManagerConstants {
// 接收推流设备的GPS变化通知
public static final String VM_MSG_GPS = "VM_MSG_GPS";
// 接收推流设备的GPS变化通知
public static final String VM_MSG_PUSH_STREAM_STATUS_CHANGE = "VM_MSG_PUSH_STREAM_STATUS_CHANGE";
// redis 消息通知设备推流到平台
public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED";
// redis 消息请求所有的在线通道
public static final String VM_MSG_GET_ALL_ONLINE_REQUESTED = "VM_MSG_GET_ALL_ONLINE_REQUESTED";
// 移动位置订阅通知
public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition";

View File

@@ -5,6 +5,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;
@@ -103,12 +104,9 @@ public class DynamicTask {
public void stop(String key) {
if (futureMap.get(key) != null && !futureMap.get(key).isCancelled()) {
// Runnable runnable = runnableMap.get(key);
// if (runnable instanceof ISubscribeTask) {
// ISubscribeTask subscribeTask = (ISubscribeTask) runnable;
// subscribeTask.stop();
// }
futureMap.get(key).cancel(false);
futureMap.remove(key);
runnableMap.remove(key);
}
}
@@ -123,4 +121,19 @@ public class DynamicTask {
public Runnable get(String key) {
return runnableMap.get(key);
}
/**
* 每五分钟检查失效的任务,并移除
*/
@Scheduled(cron="0 0/5 * * * ?")
public void execute(){
if (futureMap.size() > 0) {
for (String key : futureMap.keySet()) {
if (futureMap.get(key).isDone()) {
futureMap.remove(key);
runnableMap.remove(key);
}
}
}
}
}

View File

@@ -77,6 +77,8 @@ public class DeviceAlarm {
*/
private String alarmType;
private String createTime;
public String getId() {
return id;
@@ -157,4 +159,12 @@ public class DeviceAlarm {
public void setChannelId(String channelId) {
this.channelId = channelId;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
}

View File

@@ -199,6 +199,11 @@ public class DeviceChannel {
*/
private String businessGroupId;
/**
* GPS的更新时间
*/
private String gpsTime;
public int getId() {
return id;
}
@@ -519,4 +524,12 @@ public class DeviceChannel {
public void setBusinessGroupId(String businessGroupId) {
this.businessGroupId = businessGroupId;
}
public String getGpsTime() {
return gpsTime;
}
public void setGpsTime(String gpsTime) {
this.gpsTime = gpsTime;
}
}

View File

@@ -15,10 +15,8 @@ public class GbStream extends PlatformGbStream{
private double latitude;
private String streamType;
private boolean status;
/**
* GMT unix系统时间戳单位秒
*/
public Long createStamp;
public String createTime;
@Override
public Integer getGbStreamId() {
@@ -102,12 +100,11 @@ public class GbStream extends PlatformGbStream{
this.mediaServerId = mediaServerId;
}
public Long getCreateStamp() {
return createStamp;
public String getCreateTime() {
return createTime;
}
public void setCreateStamp(Long createStamp) {
this.createStamp = createStamp;
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
}

View File

@@ -57,20 +57,30 @@ public class MobilePosition {
*/
private String reportSource;
/**
* 国内地理坐标系GCJ-02 / BD-09
*/
private String GeodeticSystem;
/**
* 国内坐标系:经度坐标
*/
private String cnLng;
private double longitudeGcj02;
/**
* 国内坐标系:纬度坐标
*/
private String cnLat;
private double latitudeGcj02;
/**
* 国内坐标系:经度坐标
*/
private double longitudeWgs84;
/**
* 国内坐标系:纬度坐标
*/
private double latitudeWgs84;
/**
* 创建时间
*/
private String createTime;
public String getDeviceId() {
@@ -145,30 +155,6 @@ public class MobilePosition {
this.reportSource = reportSource;
}
public String getGeodeticSystem() {
return GeodeticSystem;
}
public void setGeodeticSystem(String geodeticSystem) {
GeodeticSystem = geodeticSystem;
}
public String getCnLng() {
return cnLng;
}
public void setCnLng(String cnLng) {
this.cnLng = cnLng;
}
public String getCnLat() {
return cnLat;
}
public void setCnLat(String cnLat) {
this.cnLat = cnLat;
}
public String getChannelId() {
return channelId;
}
@@ -176,4 +162,44 @@ public class MobilePosition {
public void setChannelId(String channelId) {
this.channelId = channelId;
}
public double getLongitudeGcj02() {
return longitudeGcj02;
}
public void setLongitudeGcj02(double longitudeGcj02) {
this.longitudeGcj02 = longitudeGcj02;
}
public double getLatitudeGcj02() {
return latitudeGcj02;
}
public void setLatitudeGcj02(double latitudeGcj02) {
this.latitudeGcj02 = latitudeGcj02;
}
public double getLongitudeWgs84() {
return longitudeWgs84;
}
public void setLongitudeWgs84(double longitudeWgs84) {
this.longitudeWgs84 = longitudeWgs84;
}
public double getLatitudeWgs84() {
return latitudeWgs84;
}
public void setLatitudeWgs84(double latitudeWgs84) {
this.latitudeWgs84 = latitudeWgs84;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
}

View File

@@ -144,6 +144,16 @@ public class ParentPlatform {
*/
private String administrativeDivision;
/**
* 更新时间
*/
private String updateTime;
/**
* 创建时间
*/
private String createTime;
public Integer getId() {
return id;
}
@@ -368,4 +378,20 @@ public class ParentPlatform {
public void setAdministrativeDivision(String administrativeDivision) {
this.administrativeDivision = administrativeDivision;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
}

View File

@@ -1,4 +1,4 @@
package com.genersoft.iot.vmp.domain.req;
package com.genersoft.iot.vmp.gb28181.bean;
/**

View File

@@ -140,6 +140,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
Element rootElement = getRootElement(evt);
MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setCreateTime(DateUtil.getNow());
Element deviceIdElement = rootElement.element("DeviceID");
String channelId = deviceIdElement.getTextTrim().toString();
Device device = redisCatchStorage.getDevice(deviceId);
@@ -173,16 +174,40 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setReportSource("Mobile Position");
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(deviceId);
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
storager.insertMobilePosition(mobilePosition);
storager.updateChannelPotion(deviceId, channelId, mobilePosition.getLongitude(), mobilePosition.getLatitude() );
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setChannelId(channelId);
deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime());
storager.updateChannelPosition(deviceChannel);
// 发送redis消息。 通知位置信息的变化
JSONObject jsonObject = new JSONObject();
jsonObject.put("time", time);
@@ -209,9 +234,12 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
return;
}
try {
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader);
Element rootElement = getRootElement(evt);
Element deviceIdElement = rootElement.element("DeviceID");
String deviceId = deviceIdElement.getText().toString();
String channelId = deviceIdElement.getText().toString();
Device device = redisCatchStorage.getDevice(deviceId);
if (device == null) {
@@ -247,21 +275,45 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
logger.info("[收到Notify-Alarm]{}/{}", device.getDeviceId(), deviceAlarm.getChannelId());
if ("4".equals(deviceAlarm.getAlarmMethod())) {
MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setCreateTime(DateUtil.getNow());
mobilePosition.setDeviceId(deviceAlarm.getDeviceId());
mobilePosition.setTime(deviceAlarm.getAlarmTime());
mobilePosition.setLongitude(deviceAlarm.getLongitude());
mobilePosition.setLatitude(deviceAlarm.getLatitude());
mobilePosition.setReportSource("GPS Alarm");
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(deviceId);
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
storager.insertMobilePosition(mobilePosition);
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setChannelId(channelId);
deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime());
storager.updateChannelPosition(deviceChannel);
}
// TODO: 需要实现存储报警信息、报警分类

View File

@@ -80,8 +80,8 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
Element deviceIdElement = rootElement.element("DeviceID");
String channelId = deviceIdElement.getText().toString();
DeviceAlarm deviceAlarm = new DeviceAlarm();
deviceAlarm.setCreateTime(DateUtil.getNow());
deviceAlarm.setDeviceId(device.getDeviceId());
deviceAlarm.setChannelId(channelId);
deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority"));
@@ -113,21 +113,45 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) {
if ( deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.GPS.getVal() + "")) {
MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setCreateTime(DateUtil.getNow());
mobilePosition.setDeviceId(deviceAlarm.getDeviceId());
mobilePosition.setTime(deviceAlarm.getAlarmTime());
mobilePosition.setLongitude(deviceAlarm.getLongitude());
mobilePosition.setLatitude(deviceAlarm.getLatitude());
mobilePosition.setReportSource("GPS Alarm");
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(device.getDeviceId());
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
storager.insertMobilePosition(mobilePosition);
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setChannelId(channelId);
deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime());
storager.updateChannelPosition(deviceChannel);
}
}
if (!StringUtils.isEmpty(deviceAlarm.getDeviceId())) {
@@ -177,6 +201,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
DeviceAlarm deviceAlarm = new DeviceAlarm();
deviceAlarm.setCreateTime(DateUtil.getNow());
deviceAlarm.setDeviceId(parentPlatform.getServerGBId());
deviceAlarm.setChannelId(channelId);
deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority"));

View File

@@ -1,16 +1,14 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.GpsUtil;
import org.dom4j.DocumentException;
import org.dom4j.Element;
@@ -56,6 +54,7 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
rootElement = getRootElement(evt, device.getCharset());
MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setCreateTime(DateUtil.getNow());
if (!StringUtils.isEmpty(device.getName())) {
mobilePosition.setDeviceName(device.getName());
}
@@ -80,16 +79,39 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
mobilePosition.setAltitude(0.0);
}
mobilePosition.setReportSource("Mobile Position");
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(device.getDeviceId());
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
storager.insertMobilePosition(mobilePosition);
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setChannelId(mobilePosition.getChannelId());
deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime());
storager.updateChannelPosition(deviceChannel);
//回复 200 OK
responseAck(evt, Response.OK);
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {

View File

@@ -171,71 +171,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
}
/**
* 处理设备位置的更新
*
* @param evt, itemDevice
*/
private void processNotifyMobilePosition(RequestEvent evt, Element itemDevice) {
try {
// 回复 200 OK
Element rootElement = getRootElement(evt);
MobilePosition mobilePosition = new MobilePosition();
Element deviceIdElement = rootElement.element("DeviceID");
String deviceId = deviceIdElement.getTextTrim().toString();
Device device = redisCatchStorage.getDevice(deviceId);
if (device != null) {
if (!StringUtils.isEmpty(device.getName())) {
mobilePosition.setDeviceName(device.getName());
}
}
mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID"));
String time = XmlUtil.getText(itemDevice, "Time");
if(time==null){
time = XmlUtil.getText(itemDevice, "EndTime");
}
mobilePosition.setTime(time);
String longitude = XmlUtil.getText(itemDevice, "Longitude");
if(longitude!=null) {
mobilePosition.setLongitude(Double.parseDouble(longitude));
}
String latitude = XmlUtil.getText(itemDevice, "Latitude");
if(latitude!=null) {
mobilePosition.setLatitude(Double.parseDouble(latitude));
}
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Speed"))) {
mobilePosition.setSpeed(Double.parseDouble(XmlUtil.getText(itemDevice, "Speed")));
} else {
mobilePosition.setSpeed(0.0);
}
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Direction"))) {
mobilePosition.setDirection(Double.parseDouble(XmlUtil.getText(itemDevice, "Direction")));
} else {
mobilePosition.setDirection(0.0);
}
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Altitude"))) {
mobilePosition.setAltitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Altitude")));
} else {
mobilePosition.setAltitude(0.0);
}
mobilePosition.setReportSource("Mobile Position");
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(deviceId);
}
storager.insertMobilePosition(mobilePosition);
responseAck(evt, Response.OK);
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
e.printStackTrace();
}
}
public SyncStatus getChannelSyncProgress(String deviceId) {
if (catalogDataCatch.get(deviceId) == null) {
return null;

View File

@@ -1,16 +1,14 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.GpsUtil;
import org.dom4j.DocumentException;
import org.dom4j.Element;
@@ -56,6 +54,7 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
rootElement = getRootElement(evt, device.getCharset());
MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setCreateTime(DateUtil.getNow());
if (!StringUtils.isEmpty(device.getName())) {
mobilePosition.setDeviceName(device.getName());
}
@@ -80,16 +79,39 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
mobilePosition.setAltitude(0.0);
}
mobilePosition.setReportSource("Mobile Position");
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(device.getDeviceId());
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
storager.insertMobilePosition(mobilePosition);
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setChannelId(mobilePosition.getChannelId());
deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime());
storager.updateChannelPosition(deviceChannel);
//回复 200 OK
responseAck(evt, Response.OK);
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {

View File

@@ -1,6 +1,6 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
import com.genersoft.iot.vmp.domain.req.PresetQuerySipReq;
import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.utils.DateUtil;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
@@ -314,6 +315,7 @@ public class XmlUtil {
} else {
deviceChannel.setLatitude(0.00);
}
deviceChannel.setGpsTime(DateUtil.getNow());
if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
if ("WGS84".equals(device.getGeoCoordSys())) {
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());

View File

@@ -1,7 +1,8 @@
package com.genersoft.iot.vmp.media.zlm;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.genersoft.iot.vmp.common.StreamInfo;
@@ -21,6 +22,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -79,6 +81,9 @@ public class ZLMHttpHookListener {
@Autowired
private UserSetting userSetting;
@Autowired
private IUserService userService;
@Autowired
private VideoStreamSessionManager sessionManager;
@@ -151,12 +156,14 @@ public class ZLMHttpHookListener {
*/
@ResponseBody
@PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onPlay(@RequestBody JSONObject json){
public ResponseEntity<String> onPlay(@RequestBody OnPlayHookParam param){
JSONObject json = (JSONObject)JSON.toJSON(param);
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ]on_play API调用参数" + json.toString());
logger.debug("[ ZLM HOOK ]on_play API调用参数" + JSON.toJSONString(param));
}
String mediaServerId = json.getString("mediaServerId");
String mediaServerId = param.getMediaServerId();
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_play, json);
if (subscribe != null ) {
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
@@ -165,9 +172,20 @@ public class ZLMHttpHookListener {
}
}
JSONObject ret = new JSONObject();
if (!"rtp".equals(param.getApp())) {
Map<String, String> paramMap = urlParamToMap(param.getParams());
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream());
if (streamAuthorityInfo == null
|| (streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(paramMap.get("callId")))) {
ret.put("code", 401);
ret.put("msg", "Unauthorized");
return new ResponseEntity<>(ret.toString(),HttpStatus.OK);
}
}
ret.put("code", 0);
ret.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
return new ResponseEntity<>(ret.toString(),HttpStatus.OK);
}
/**
@@ -176,16 +194,49 @@ public class ZLMHttpHookListener {
*/
@ResponseBody
@PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onPublish(@RequestBody JSONObject json) {
public ResponseEntity<String> onPublish(@RequestBody OnPublishHookParam param) {
JSONObject json = (JSONObject) JSON.toJSON(param);
logger.info("[ ZLM HOOK ]on_publish API调用参数" + json.toString());
JSONObject ret = new JSONObject();
if (!"rtp".equals(param.getApp())) {
// 推流鉴权
if (param.getParams() == null) {
logger.info("推流鉴权失败: 缺少不要参数sign=md5(user表的pushKey)");
ret.put("code", 401);
ret.put("msg", "Unauthorized");
return new ResponseEntity<>(ret.toString(), HttpStatus.OK);
}
Map<String, String> paramMap = urlParamToMap(param.getParams());
String sign = paramMap.get("sign");
if (sign == null) {
logger.info("推流鉴权失败: 缺少不要参数sign=md5(user表的pushKey)");
ret.put("code", 401);
ret.put("msg", "Unauthorized");
return new ResponseEntity<>(ret.toString(), HttpStatus.OK);
}
// 推流自定义播放鉴权码
String callId = paramMap.get("callId");
// 鉴权配置
boolean hasAuthority = userService.checkPushAuthority(callId, sign);
if (!hasAuthority) {
logger.info("推流鉴权失败: sign 无权限: callId={}. sign={}", callId, sign);
ret.put("code", 401);
ret.put("msg", "Unauthorized");
return new ResponseEntity<>(ret.toString(), HttpStatus.OK);
}
StreamAuthorityInfo streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param);
streamAuthorityInfo.setCallId(callId);
streamAuthorityInfo.setSign(sign);
// 鉴权通过
redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
}
ret.put("code", 0);
ret.put("msg", "success");
ret.put("enable_hls", true);
if (json.getInteger("originType") == 1
|| json.getInteger("originType") == 2
|| json.getInteger("originType") == 3) {
if (!"rtp".equals(param.getApp())) {
ret.put("enable_audio", true);
}
@@ -200,14 +251,13 @@ public class ZLMHttpHookListener {
ret.put("msg", "zlm not register");
}
}
String app = json.getString("app");
String stream = json.getString("stream");
if ("rtp".equals(app)) {
if ("rtp".equals(param.getApp())) {
ret.put("enable_mp4", userSetting.getRecordSip());
}else {
ret.put("enable_mp4", userSetting.isRecordPushLive());
}
List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, stream);
List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, param.getStream());
if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) {
String deviceId = ssrcTransactionForAll.get(0).getDeviceId();
String channelId = ssrcTransactionForAll.get(0).getChannelId();
@@ -221,13 +271,14 @@ public class ZLMHttpHookListener {
ret.put("enable_mp4", true);
ret.put("enable_audio", true);
}
}
return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
}
/**
* 录制mp4完成后通知事件此事件对回复不敏感。
*
@@ -312,9 +363,6 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ]on_shell_login API调用参数" + json.toString());
}
// TODO 如果是带有rtpstream则开启按需拉流
// String app = json.getString("app");
// String stream = json.getString("stream");
String mediaServerId = json.getString("mediaServerId");
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_shell_login, json);
if (subscribe != null ) {
@@ -351,12 +399,24 @@ public class ZLMHttpHookListener {
}
// 流消失移除redis play
String app = item.getApp();
String streamId = item.getStream();
String stream = item.getStream();
String schema = item.getSchema();
List<MediaItem.MediaTrack> tracks = item.getTracks();
boolean regist = item.isRegist();
if (regist) {
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
if (streamAuthorityInfo == null) {
streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(item);
}else {
streamAuthorityInfo.setOriginType(item.getOriginType());
streamAuthorityInfo.setOriginTypeStr(item.getOriginTypeStr());
}
redisCatchStorage.updateStreamAuthorityInfo(app, stream, streamAuthorityInfo);
}else {
redisCatchStorage.removeStreamAuthorityInfo(app, stream);
}
if ("rtmp".equals(schema)){
logger.info("on_stream_changed注册->{}, app->{}, stream->{}", regist, app, streamId);
logger.info("on_stream_changed注册->{}, app->{}, stream->{}", regist, app, stream);
if (regist) {
mediaServerService.addCount(mediaServerId);
}else {
@@ -365,15 +425,15 @@ public class ZLMHttpHookListener {
if (item.getOriginType() == OriginType.PULL.ordinal()
|| item.getOriginType() == OriginType.FFMPEG_PULL.ordinal()) {
// 设置拉流代理上线/离线
streamProxyService.updateStatus(regist, app, streamId);
streamProxyService.updateStatus(regist, app, stream);
}
if ("rtp".equals(app) && !regist ) {
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(stream);
if (streamInfo!=null){
redisCatchStorage.stopPlay(streamInfo);
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
}else{
streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
streamInfo = redisCatchStorage.queryPlayback(null, null, stream, null);
if (streamInfo != null) {
redisCatchStorage.stopPlayback(streamInfo.getDeviceID(), streamInfo.getChannelId(),
streamInfo.getStream(), null);
@@ -387,11 +447,12 @@ public class ZLMHttpHookListener {
if (mediaServerItem != null){
if (regist) {
StreamPushItem streamPushItem = null;
StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, streamId, tracks);
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem,
app, stream, tracks, streamAuthorityInfo.getCallId());
item.setStreamInfo(streamInfoByAppAndStream);
redisCatchStorage.addStream(mediaServerItem, type, app, streamId, item);
redisCatchStorage.addStream(mediaServerItem, type, app, stream, item);
if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|| item.getOriginType() == OriginType.RTMP_PUSH.ordinal()
|| item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) {
@@ -414,23 +475,23 @@ public class ZLMHttpHookListener {
}else {
// 兼容流注销时类型从redis记录获取
MediaItem mediaItem = redisCatchStorage.getStreamInfo(app, streamId, mediaServerId);
MediaItem mediaItem = redisCatchStorage.getStreamInfo(app, stream, mediaServerId);
if (mediaItem != null) {
type = OriginType.values()[mediaItem.getOriginType()].getType();
redisCatchStorage.removeStream(mediaServerItem.getId(), type, app, streamId);
redisCatchStorage.removeStream(mediaServerItem.getId(), type, app, stream);
}
GbStream gbStream = storager.getGbStream(app, streamId);
GbStream gbStream = storager.getGbStream(app, stream);
if (gbStream != null) {
// eventPublisher.catalogEventPublishForStream(null, gbStream, CatalogEvent.OFF);
}
zlmMediaListManager.removeMedia(app, streamId);
zlmMediaListManager.removeMedia(app, stream);
}
if (type != null) {
// 发送流变化redis消息
JSONObject jsonObject = new JSONObject();
jsonObject.put("serverId", userSetting.getServerId());
jsonObject.put("app", app);
jsonObject.put("stream", streamId);
jsonObject.put("stream", stream);
jsonObject.put("register", regist);
jsonObject.put("mediaServerId", mediaServerId);
redisCatchStorage.sendStreamChangeMsg(type, jsonObject);
@@ -453,10 +514,8 @@ public class ZLMHttpHookListener {
@ResponseBody
@PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8")
public ResponseEntity<String> onStreamNoneReader(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ]on_stream_none_reader API调用参数" + json.toString());
}
logger.info("[ ZLM HOOK ]on_stream_none_reader API调用参数" + json.toString());
String mediaServerId = json.getString("mediaServerId");
String streamId = json.getString("stream");
String app = json.getString("app");
@@ -568,4 +627,22 @@ public class ZLMHttpHookListener {
ret.put("msg", "success");
return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
}
private Map<String, String> urlParamToMap(String params) {
HashMap<String, String> map = new HashMap<>();
if (StringUtils.isEmpty(params)) {
return map;
}
String[] paramsArray = params.split("&");
if (paramsArray.length == 0) {
return map;
}
for (String param : paramsArray) {
String[] paramArray = param.split("=");
if (paramArray.length == 2){
map.put(paramArray[0], paramArray[1]);
}
}
return map;
}
}

View File

@@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.StreamPushMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import org.checkerframework.checker.units.qual.C;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -114,63 +115,42 @@ public class ZLMMediaListManager {
public StreamPushItem addPush(MediaItem mediaItem) {
// 查找此直播流是否存在redis预设gbId
StreamPushItem transform = streamPushService.transform(mediaItem);
// 从streamId取出查询关键值
Pattern pattern = Pattern.compile(userSetting.getThirdPartyGBIdReg());
Matcher matcher = pattern.matcher(mediaItem.getStream());// 指定要匹配的字符串
String queryKey = null;
if (matcher.find()) { //此处find每次被调用后会偏移到下一个匹配
queryKey = matcher.group();
}
if (queryKey != null) {
ThirdPartyGB thirdPartyGB = redisCatchStorage.queryMemberNoGBId(queryKey);
if (thirdPartyGB != null && !StringUtils.isEmpty(thirdPartyGB.getNationalStandardNo())) {
transform.setGbId(thirdPartyGB.getNationalStandardNo());
transform.setName(thirdPartyGB.getName());
}
}
if (!StringUtils.isEmpty(transform.getGbId())) {
// 如果这个国标ID已经给了其他推流且流已离线则移除其他推流
List<GbStream> gbStreams = gbStreamMapper.selectByGBId(transform.getGbId());
if (gbStreams.size() > 0) {
for (GbStream gbStream : gbStreams) {
// 出现使用相同国标Id的视频流时使用新流替换旧流
if (queryKey != null && gbStream.getApp().equals(mediaItem.getApp())) {
Matcher matcherForStream = pattern.matcher(gbStream.getStream());
String queryKeyForStream = null;
if (matcherForStream.find()) { //此处find每次被调用后会偏移到下一个匹配
queryKeyForStream = matcherForStream.group();
}
if (queryKeyForStream == null || !queryKeyForStream.equals(queryKey)) {
// 此时不是同一个流
gbStreamMapper.del(gbStream.getApp(), gbStream.getStream());
if (!gbStream.isStatus()) {
streamPushMapper.del(gbStream.getApp(), gbStream.getStream());
}
}
}
}
}
List<GbStream> gbStreamList = gbStreamMapper.selectByGBId(transform.getGbId());
if (gbStreamList != null && gbStreamList.size() == 1) {
transform.setGbStreamId(gbStreamList.get(0).getGbStreamId());
transform.setPlatformId(gbStreamList.get(0).getPlatformId());
transform.setCatalogId(gbStreamList.get(0).getCatalogId());
transform.setGbId(gbStreamList.get(0).getGbId());
gbStreamMapper.update(transform);
streamPushMapper.del(gbStreamList.get(0).getApp(), gbStreamList.get(0).getStream());
}else {
transform.setCreateStamp(System.currentTimeMillis());
gbStreamMapper.add(transform);
}
if (transform != null) {
if (channelOnlineEvents.get(transform.getGbId()) != null) {
channelOnlineEvents.get(transform.getGbId()).run(transform.getApp(), transform.getStream(), transform.getServerId());
channelOnlineEvents.remove(transform.getGbId());
}
}
StreamPushItem pushInDb = streamPushService.getPush(mediaItem.getApp(), mediaItem.getStream());
transform.setUpdateTime(DateUtil.getNow());
transform.setPushTime(DateUtil.getNow());
if (pushInDb == null) {
transform.setCreateTime(DateUtil.getNow());
streamPushMapper.add(transform);
}else {
streamPushMapper.update(transform);
// if (!StringUtils.isEmpty(pushInDb.getGbId())) {
// List<GbStream> gbStreamList = gbStreamMapper.selectByGBId(transform.getGbId());
// if (gbStreamList != null && gbStreamList.size() == 1) {
// transform.setGbStreamId(gbStreamList.get(0).getGbStreamId());
// transform.setPlatformId(gbStreamList.get(0).getPlatformId());
// transform.setCatalogId(gbStreamList.get(0).getCatalogId());
// transform.setGbId(gbStreamList.get(0).getGbId());
// gbStreamMapper.update(transform);
// streamPushMapper.del(gbStreamList.get(0).getApp(), gbStreamList.get(0).getStream());
// }else {
// transform.setCreateTime(DateUtil.getNow());
// transform.setUpdateTime(DateUtil.getNow());
// gbStreamMapper.add(transform);
// }
// 通知通道上线
// if (transform != null) {
// if (channelOnlineEvents.get(transform.getGbId()) != null) {
// channelOnlineEvents.get(transform.getGbId()).run(transform.getApp(), transform.getStream(), transform.getServerId());
// channelOnlineEvents.remove(transform.getGbId());
// }
// }
// }
}
storager.updateMedia(transform);
return transform;
}
@@ -204,13 +184,13 @@ public class ZLMMediaListManager {
public int removeMedia(String app, String streamId) {
// 查找是否关联了国标, 关联了不删除, 置为离线
StreamProxyItem streamProxyItem = gbStreamMapper.selectOne(app, streamId);
int result = 0;
if (streamProxyItem == null) {
GbStream gbStream = gbStreamMapper.selectOne(app, streamId);
int result;
if (gbStream == null) {
result = storager.removeMedia(app, streamId);
}else {
// TODO 暂不设置为离线
result =storager.mediaOutline(app, streamId);
result =storager.mediaOffline(app, streamId);
}
return result;
}

View File

@@ -66,7 +66,7 @@ public class ZLMRTPServerFactory {
String stream = UUID.randomUUID().toString();
param.put("enable_tcp", 1);
param.put("stream_id", stream);
param.put("port", 0);
// param.put("port", 0);
JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param);
if (openRtpServerResultJson != null) {
@@ -101,9 +101,10 @@ public class ZLMRTPServerFactory {
}
Map<String, Object> param = new HashMap<>();
// 推流端口设置0则使用随机端口
param.put("enable_tcp", 1);
param.put("stream_id", streamId);
// 推流端口设置0则使用随机端口
param.put("port", 0);
param.put("ssrc", ssrc);
JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param);

View File

@@ -0,0 +1,17 @@
package com.genersoft.iot.vmp.media.zlm.dto;
/**
* zlm hook事件的参数
* @author lin
*/
public class HookParam {
private String mediaServerId;
public String getMediaServerId() {
return mediaServerId;
}
public void setMediaServerId(String mediaServerId) {
this.mediaServerId = mediaServerId;
}
}

View File

@@ -0,0 +1,82 @@
package com.genersoft.iot.vmp.media.zlm.dto;
/**
* zlm hook事件中的on_play事件的参数
* @author lin
*/
public class OnPlayHookParam extends HookParam{
private String id;
private String app;
private String stream;
private String ip;
private String params;
private int port;
private String schema;
private String vhost;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getSchema() {
return schema;
}
public void setSchema(String schema) {
this.schema = schema;
}
public String getVhost() {
return vhost;
}
public void setVhost(String vhost) {
this.vhost = vhost;
}
}

View File

@@ -0,0 +1,82 @@
package com.genersoft.iot.vmp.media.zlm.dto;
/**
* zlm hook事件中的on_publish事件的参数
* @author lin
*/
public class OnPublishHookParam extends HookParam{
private String id;
private String app;
private String stream;
private String ip;
private String params;
private int port;
private String schema;
private String vhost;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getSchema() {
return schema;
}
public void setSchema(String schema) {
this.schema = schema;
}
public String getVhost() {
return vhost;
}
public void setVhost(String vhost) {
this.vhost = vhost;
}
}

View File

@@ -0,0 +1,114 @@
package com.genersoft.iot.vmp.media.zlm.dto;
/**
* 流的鉴权信息
* @author lin
*/
public class StreamAuthorityInfo {
private String id;
private String app;
private String stream;
/**
* 产生源类型,
* unknown = 0,
* rtmp_push=1,
* rtsp_push=2,
* rtp_push=3,
* pull=4,
* ffmpeg_pull=5,
* mp4_vod=6,
* device_chn=7
*/
private int originType;
/**
* 产生源类型的字符串描述
*/
private String originTypeStr;
/**
* 推流时自定义的播放鉴权ID
*/
private String callId;
/**
* 推流的鉴权签名
*/
private String sign;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
public int getOriginType() {
return originType;
}
public void setOriginType(int originType) {
this.originType = originType;
}
public String getOriginTypeStr() {
return originTypeStr;
}
public void setOriginTypeStr(String originTypeStr) {
this.originTypeStr = originTypeStr;
}
public String getCallId() {
return callId;
}
public void setCallId(String callId) {
this.callId = callId;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public static StreamAuthorityInfo getInstanceByHook(OnPublishHookParam hookParam) {
StreamAuthorityInfo streamAuthorityInfo = new StreamAuthorityInfo();
streamAuthorityInfo.setApp(hookParam.getApp());
streamAuthorityInfo.setStream(hookParam.getStream());
streamAuthorityInfo.setId(hookParam.getId());
return streamAuthorityInfo;
}
public static StreamAuthorityInfo getInstanceByHook(MediaItem mediaItem) {
StreamAuthorityInfo streamAuthorityInfo = new StreamAuthorityInfo();
streamAuthorityInfo.setApp(mediaItem.getApp());
streamAuthorityInfo.setStream(mediaItem.getStream());
streamAuthorityInfo.setId(mediaItem.getMediaServerId());
streamAuthorityInfo.setOriginType(mediaItem.getOriginType());
streamAuthorityInfo.setOriginTypeStr(mediaItem.getOriginTypeStr());
return streamAuthorityInfo;
}
}

View File

@@ -1,7 +1,9 @@
package com.genersoft.iot.vmp.media.zlm.dto;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.utils.DateUtil;
import org.jetbrains.annotations.NotNull;
import org.springframework.util.unit.DataUnit;
import java.util.List;
@@ -86,6 +88,21 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte
*/
private String serverId;
/**
* 推流时间
*/
private String pushTime;
/**
* 更新时间
*/
private String updateTime;
/**
* 创建时间
*/
private String createTime;
public String getVhost() {
return vhost;
}
@@ -97,7 +114,8 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte
@Override
public int compareTo(@NotNull StreamPushItem streamPushItem) {
return Long.valueOf(super.createStamp - streamPushItem.getCreateStamp().intValue()).intValue();
return Long.valueOf(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(super.createTime)
- DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(streamPushItem.getCreateTime())).intValue();
}
public static class MediaSchema {
@@ -232,5 +250,32 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte
public void setServerId(String serverId) {
this.serverId = serverId;
}
public String getPushTime() {
return pushTime;
}
public void setPushTime(String pushTime) {
this.pushTime = pushTime;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
@Override
public String getCreateTime() {
return createTime;
}
@Override
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
}

View File

@@ -15,7 +15,7 @@ public interface IMediaService {
* @param stream
* @return
*/
StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId,String addr);
StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId,String addr, boolean authority);
/**
@@ -24,7 +24,7 @@ public interface IMediaService {
* @param stream
* @return
*/
StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId);
StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId, boolean authority);
/**
* 根据应用名和流ID获取播放地址, 只是地址拼接
@@ -32,7 +32,7 @@ public interface IMediaService {
* @param stream
* @return
*/
StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaServerItem, String app, String stream, Object tracks);
StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaServerItem, String app, String stream, Object tracks, String callId);
/**
* 根据应用名和流ID获取播放地址, 只是地址拼接返回的ip使用远程访问ip适用与zlm与wvp在一台主机的情况
@@ -40,6 +40,6 @@ public interface IMediaService {
* @param stream
* @return
*/
StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr);
StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, String callId);
StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, boolean isPlay);
}

View File

@@ -19,4 +19,6 @@ public interface IUserService {
List<User> getAllUsers();
int updateUsers(User user);
boolean checkPushAuthority(String callId, String sign);
}

View File

@@ -0,0 +1,41 @@
package com.genersoft.iot.vmp.service.bean;
import java.util.List;
/**
* 收到redis通知修改推流通道状态
* @author lin
*/
public class PushStreamStatusChangeFromRedisDto {
private boolean setAllOffline;
private List<StreamPushItemFromRedis> onlineStreams;
private List<StreamPushItemFromRedis> offlineStreams;
public boolean isSetAllOffline() {
return setAllOffline;
}
public void setSetAllOffline(boolean setAllOffline) {
this.setAllOffline = setAllOffline;
}
public List<StreamPushItemFromRedis> getOnlineStreams() {
return onlineStreams;
}
public void setOnlineStreams(List<StreamPushItemFromRedis> onlineStreams) {
this.onlineStreams = onlineStreams;
}
public List<StreamPushItemFromRedis> getOfflineStreams() {
return offlineStreams;
}
public void setOfflineStreams(List<StreamPushItemFromRedis> offlineStreams) {
this.offlineStreams = offlineStreams;
}
}

View File

@@ -0,0 +1,34 @@
package com.genersoft.iot.vmp.service.bean;
public class StreamPushItemFromRedis {
private String app;
private String stream;
private long timeStamp;
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
public long getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(long timeStamp) {
this.timeStamp = timeStamp;
}
}

View File

@@ -149,9 +149,9 @@ public class GbStreamServiceImpl implements IGbStreamService {
if (gbStream.getGbId() != null) {
gbStreams.add(gbStream);
}else {
StreamProxyItem streamProxyItem = gbStreamMapper.selectOne(gbStream.getApp(), gbStream.getStream());
if (streamProxyItem != null && streamProxyItem.getGbId() != null){
gbStreams.add(streamProxyItem);
GbStream gbStreamIndb = gbStreamMapper.selectOne(gbStream.getApp(), gbStream.getStream());
if (gbStreamIndb != null && gbStreamIndb.getGbId() != null){
gbStreams.add(gbStreamIndb);
}
}
sendCatalogMsgs(gbStreams, type);

View File

@@ -7,12 +7,15 @@ import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaConfig;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.service.IMediaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@Service
public class MediaServiceImpl implements IMediaService {
@@ -36,20 +39,24 @@ public class MediaServiceImpl implements IMediaService {
@Override
public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks) {
return getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, null);
public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String callId) {
return getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, null, callId);
}
@Override
public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId, String addr) {
public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId, String addr, boolean authority) {
StreamInfo streamInfo = null;
if (mediaServerId == null) {
mediaServerId = mediaConfig.getId();
}
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);;
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
if (mediaInfo == null) {
return null;
}
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
if (streamAuthorityInfo == null) {
return null;
}
JSONObject mediaList = zlmresTfulUtils.getMediaList(mediaInfo, app, stream);
if (mediaList != null) {
if (mediaList.getInteger("code") == 0) {
@@ -59,7 +66,12 @@ public class MediaServiceImpl implements IMediaService {
}
JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class);
JSONArray tracks = mediaJSON.getJSONArray("tracks");
streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks);
if (authority) {
streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, streamAuthorityInfo.getCallId());
}else {
streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, null);
}
}
}
return streamInfo;
@@ -68,8 +80,8 @@ public class MediaServiceImpl implements IMediaService {
@Override
public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId) {
return getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, null);
public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId, boolean authority) {
return getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, null, authority);
}
@Override
@@ -78,41 +90,43 @@ public class MediaServiceImpl implements IMediaService {
}
@Override
public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, boolean isPlay) {
public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, String callId, boolean isPlay) {
StreamInfo streamInfoResult = new StreamInfo();
streamInfoResult.setStream(stream);
streamInfoResult.setApp(app);
if (addr == null) {
addr = mediaInfo.getStreamIp();
}
streamInfoResult.setIp(addr);
streamInfoResult.setMediaServerId(mediaInfo.getId());
streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", addr, mediaInfo.getRtmpPort(), app, stream));
String callIdParam = StringUtils.isEmpty(callId)?"":"?callId=" + callId;
streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpPort(), app, stream, callIdParam));
if (mediaInfo.getRtmpSSlPort() != 0) {
streamInfoResult.setRtmps(String.format("rtmps://%s:%s/%s/%s", addr, mediaInfo.getRtmpSSlPort(), app, stream));
streamInfoResult.setRtmps(String.format("rtmps://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpSSlPort(), app, stream, callIdParam));
}
streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s", addr, mediaInfo.getRtspPort(), app, stream));
streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s%s", addr, mediaInfo.getRtspPort(), app, stream, callIdParam));
if (mediaInfo.getRtspSSLPort() != 0) {
streamInfoResult.setRtsps(String.format("rtsps://%s:%s/%s/%s", addr, mediaInfo.getRtspSSLPort(), app, stream));
streamInfoResult.setRtsps(String.format("rtsps://%s:%s/%s/%s%s", addr, mediaInfo.getRtspSSLPort(), app, stream, callIdParam));
}
streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.live.flv", addr, mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.live.flv", addr, mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8", addr, mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8", addr, mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4", addr, mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", addr, mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
if (mediaInfo.getHttpSSlPort() != 0) {
streamInfoResult.setHttps_flv(String.format("https://%s:%s/%s/%s.live.flv", addr, mediaInfo.getHttpSSlPort(), app, stream));
streamInfoResult.setWss_flv(String.format("wss://%s:%s/%s/%s.live.flv", addr, mediaInfo.getHttpSSlPort(), app, stream));
streamInfoResult.setHttps_hls(String.format("https://%s:%s/%s/%s/hls.m3u8", addr, mediaInfo.getHttpSSlPort(), app, stream));
streamInfoResult.setWss_hls(String.format("wss://%s:%s/%s/%s/hls.m3u8", addr, mediaInfo.getHttpSSlPort(), app, stream));
streamInfoResult.setHttps_fmp4(String.format("https://%s:%s/%s/%s.live.mp4", addr, mediaInfo.getHttpSSlPort(), app, stream));
streamInfoResult.setWss_fmp4(String.format("wss://%s:%s/%s/%s.live.mp4", addr, mediaInfo.getHttpSSlPort(), app, stream));
streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, isPlay?"play":"push"));
streamInfoResult.setHttps_flv(String.format("https://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_flv(String.format("wss://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setHttps_hls(String.format("https://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_hls(String.format("wss://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setHttps_fmp4(String.format("https://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_fmp4(String.format("wss://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=%s%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, isPlay?"play":"push", StringUtils.isEmpty(callId)?"":"&callId=" + callId));
}
streamInfoResult.setTracks(tracks);

View File

@@ -637,7 +637,7 @@ public class PlayServiceImpl implements IPlayService {
public StreamInfo onPublishHandler(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId) {
String streamId = resonse.getString("stream");
JSONArray tracks = resonse.getJSONArray("tracks");
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(mediaServerItem,"rtp", streamId, tracks);
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(mediaServerItem,"rtp", streamId, tracks, null);
streamInfo.setDeviceID(deviceId);
streamInfo.setChannelId(channelId);
return streamInfo;

View File

@@ -41,6 +41,7 @@ public class RedisAlarmMsgListener implements MessageListener {
ParentPlatform platform = storage.queryParentPlatByServerGBId(gbId);
DeviceAlarm deviceAlarm = new DeviceAlarm();
deviceAlarm.setCreateTime(DateUtil.getNow());
deviceAlarm.setChannelId(gbId);
deviceAlarm.setAlarmDescription(alarmChannelMessage.getAlarmDescription());
deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn());

View File

@@ -25,9 +25,6 @@ public class RedisGpsMsgListener implements MessageListener {
@Override
public void onMessage(@NotNull Message message, byte[] bytes) {
if (logger.isDebugEnabled()) {
logger.debug("收到来自REDIS的GPS通知 {}", new String(message.getBody()));
}
GPSMsgInfo gpsMsgInfo = JSON.parseObject(message.getBody(), GPSMsgInfo.class);
redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo);
}

View File

@@ -230,11 +230,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
public boolean start(String app, String stream) {
boolean result = false;
StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream);
if (!streamProxy.isEnable() && streamProxy != null) {
if (!streamProxy.isEnable() ) {
JSONObject jsonObject = addStreamProxyToZlm(streamProxy);
if (jsonObject == null) {
return false;
}
System.out.println(jsonObject);
if (jsonObject.getInteger("code") == 0) {
result = true;
streamProxy.setEnable(true);
@@ -250,7 +251,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
StreamProxyItem streamProxyDto = videoManagerStorager.queryStreamProxy(app, stream);
if (streamProxyDto != null && streamProxyDto.isEnable()) {
JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyDto);
if (jsonObject.getInteger("code") == 0) {
if (jsonObject != null && jsonObject.getInteger("code") == 0) {
streamProxyDto.setEnable(false);
result = videoManagerStorager.updateStreamProxy(streamProxyDto);
}
@@ -318,7 +319,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
}
streamProxyMapper.deleteAutoRemoveItemByMediaServerId(mediaServerId);
// 其他的流设置离线
streamProxyMapper.updateStatusByMediaServerId(false, mediaServerId);
streamProxyMapper.updateStatusByMediaServerId(mediaServerId, false);
String type = "PULL";
// 发送redis消息
@@ -345,7 +346,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
@Override
public int updateStatus(boolean status, String app, String stream) {
return streamProxyMapper.updateStatus(status, app, stream);
return streamProxyMapper.updateStatus(app, stream, status);
}
private void syncPullStream(String mediaServerId){

View File

@@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.*;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
@@ -37,6 +38,9 @@ public class StreamPushServiceImpl implements IStreamPushService {
@Autowired
private StreamPushMapper streamPushMapper;
@Autowired
private StreamProxyMapper streamProxyMapper;
@Autowired
private ParentPlatformMapper parentPlatformMapper;
@@ -102,7 +106,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
streamPushItem.setOriginType(item.getOriginType());
streamPushItem.setOriginTypeStr(item.getOriginTypeStr());
streamPushItem.setOriginUrl(item.getOriginUrl());
streamPushItem.setCreateStamp(item.getCreateStamp() * 1000);
streamPushItem.setCreateTime(DateUtil.getNow());
streamPushItem.setAliveSecond(item.getAliveSecond());
streamPushItem.setStatus(true);
streamPushItem.setStreamType("push");
@@ -127,7 +131,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
public boolean saveToGB(GbStream stream) {
stream.setStreamType("push");
stream.setStatus(true);
stream.setCreateStamp(System.currentTimeMillis());
stream.setCreateTime(DateUtil.getNow());
int add = gbStreamMapper.add(stream);
// 查找开启了全部直播流共享的上级平台
@@ -284,7 +288,8 @@ public class StreamPushServiceImpl implements IStreamPushService {
streamPushMapper.deleteWithoutGBId(mediaServerId);
gbStreamMapper.deleteWithoutGBId("push", mediaServerId);
// 其他的流设置未启用
gbStreamMapper.updateStatusByMediaServerId(mediaServerId, false);
streamPushMapper.updateStatusByMediaServerId(mediaServerId, false);
streamProxyMapper.updateStatusByMediaServerId(mediaServerId, false);
// 发送流停止消息
String type = "PUSH";
// 发送redis消息
@@ -317,7 +322,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
streamPushItem.setStreamType("push");
streamPushItem.setStatus(true);
streamPushItem.setGbId("34020000004111" + gbId);
streamPushItem.setCreateStamp(System.currentTimeMillis());
streamPushItem.setCreateTime(DateUtil.getNow());
gbId ++;
}
int limitCount = 30;

View File

@@ -4,6 +4,7 @@ import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
@@ -94,7 +95,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
streamPushItem.setGbId(streamPushExcelDto.getGbId());
streamPushItem.setStatus(false);
streamPushItem.setStreamType("push");
streamPushItem.setCreateStamp(System.currentTimeMillis());
streamPushItem.setCreateTime(DateUtil.getNow());
streamPushItem.setMediaServerId(defaultMediaServerId);
streamPushItem.setName(streamPushExcelDto.getName());
streamPushItem.setOriginType(2);

View File

@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.storager.dao.UserMapper;
import com.genersoft.iot.vmp.storager.dao.dto.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@@ -55,4 +56,12 @@ public class UserServiceImpl implements IUserService {
}
@Override
public boolean checkPushAuthority(String callId, String sign) {
if (StringUtils.isEmpty(callId)) {
return userMapper.checkPushAuthorityByCallId(sign).size() > 0;
}else {
return userMapper.checkPushAuthorityByCallIdAndSign(callId, sign).size() > 0;
}
}
}

View File

@@ -3,9 +3,7 @@ package com.genersoft.iot.vmp.storager;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.media.zlm.dto.*;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
@@ -213,4 +211,26 @@ public interface IRedisCatchStorage {
*/
public boolean deviceIsOnline(String deviceId);
/**
* 存储推流的鉴权信息
* @param app 应用名
* @param stream 流
* @param streamAuthorityInfo 鉴权信息
*/
void updateStreamAuthorityInfo(String app, String stream, StreamAuthorityInfo streamAuthorityInfo);
/**
* 移除推流的鉴权信息
* @param app 应用名
* @param streamId 流
*/
void removeStreamAuthorityInfo(String app, String streamId);
/**
* 获取推流的鉴权信息
* @param app 应用名
* @param stream 流
* @return
*/
StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream);
}

View File

@@ -372,14 +372,16 @@ public interface IVideoManagerStorage {
/**
* 设置流离线
* @param app
* @param streamId
*/
int mediaOutline(String app, String streamId);
int mediaOffline(String app, String streamId);
/**
* 设置流上线
*/
int mediaOnline(String app, String streamId);
/**
* 设置平台在线/离线
* @param online
*/
void updateParentPlatformStatus(String platformGbID, boolean online);
@@ -463,5 +465,5 @@ public interface IVideoManagerStorage {
List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude);
void updateChannelPosition(DeviceChannel deviceChannel);
}

View File

@@ -15,8 +15,8 @@ import java.util.List;
@Repository
public interface DeviceAlarmMapper {
@Insert("INSERT INTO device_alarm (deviceId, channelId, alarmPriority, alarmMethod, alarmTime, alarmDescription, longitude, latitude, alarmType ) " +
"VALUES ('${deviceId}', '${channelId}', '${alarmPriority}', '${alarmMethod}', '${alarmTime}', '${alarmDescription}', ${longitude}, ${latitude}, '${alarmType}')")
@Insert("INSERT INTO device_alarm (deviceId, channelId, alarmPriority, alarmMethod, alarmTime, alarmDescription, longitude, latitude, alarmType , createTime ) " +
"VALUES ('${deviceId}', '${channelId}', '${alarmPriority}', '${alarmMethod}', '${alarmTime}', '${alarmDescription}', ${longitude}, ${latitude}, '${alarmType}', '${createTime}')")
int add(DeviceAlarm alarm);

View File

@@ -19,11 +19,11 @@ public interface DeviceChannelMapper {
@Insert("INSERT INTO device_channel (channelId, deviceId, name, manufacture, model, owner, civilCode, block, " +
"address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
"ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " +
"longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId) " +
"longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId, gpsTime) " +
"VALUES ('${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," +
"'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " +
"'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude}, ${longitudeGcj02}, " +
"${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84},'${createTime}', '${updateTime}', '${businessGroupId}')")
"${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84},'${createTime}', '${updateTime}', '${businessGroupId}', '${gpsTime}')")
int add(DeviceChannel channel);
@Update(value = {" <script>" +
@@ -58,6 +58,7 @@ public interface DeviceChannelMapper {
"<if test='longitudeWgs84 != null'>, longitudeWgs84=${longitudeWgs84}</if>" +
"<if test='latitudeWgs84 != null'>, latitudeWgs84=${latitudeWgs84}</if>" +
"<if test='businessGroupId != null'>, businessGroupId=#{businessGroupId}</if>" +
"<if test='gpsTime != null'>, gpsTime=#{gpsTime}</if>" +
"WHERE deviceId='${deviceId}' AND channelId='${channelId}'"+
" </script>"})
int update(DeviceChannel channel);
@@ -147,7 +148,7 @@ public interface DeviceChannelMapper {
"(channelId, deviceId, name, manufacture, model, owner, civilCode, block, subCount, " +
" address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
" ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " +
" longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId) " +
" longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId, gpsTime) " +
"values " +
"<foreach collection='addChannels' index='index' item='item' separator=','> " +
"('${item.channelId}', '${item.deviceId}', '${item.name}', '${item.manufacture}', '${item.model}', " +
@@ -157,7 +158,7 @@ public interface DeviceChannelMapper {
"'${item.ipAddress}', ${item.port}, '${item.password}', ${item.PTZType}, ${item.status}, " +
"'${item.streamId}', ${item.longitude}, ${item.latitude},${item.longitudeGcj02}, " +
"${item.latitudeGcj02},${item.longitudeWgs84}, ${item.latitudeWgs84},'${item.createTime}', '${item.updateTime}', " +
"'${item.businessGroupId}') " +
"'${item.businessGroupId}', '${item.gpsTime}') " +
"</foreach> " +
"ON DUPLICATE KEY UPDATE " +
"updateTime=VALUES(updateTime), " +
@@ -189,7 +190,8 @@ public interface DeviceChannelMapper {
"latitudeGcj02=VALUES(latitudeGcj02), " +
"longitudeWgs84=VALUES(longitudeWgs84), " +
"latitudeWgs84=VALUES(latitudeWgs84), " +
"businessGroupId=VALUES(businessGroupId) " +
"businessGroupId=VALUES(businessGroupId), " +
"gpsTime=VALUES(gpsTime)" +
"</script>")
int batchAdd(List<DeviceChannel> addChannels);
@@ -228,6 +230,7 @@ public interface DeviceChannelMapper {
"<if test='item.longitudeWgs84 != null'>, longitudeWgs84=${item.longitudeWgs84}</if>" +
"<if test='item.latitudeWgs84 != null'>, latitudeWgs84=${item.latitudeWgs84}</if>" +
"<if test='item.businessGroupId != null'>, businessGroupId=#{item.businessGroupId}</if>" +
"<if test='item.gpsTime != null'>, gpsTime=#{item.gpsTime}</if>" +
"WHERE deviceId='${item.deviceId}' AND channelId='${item.channelId}'"+
"</foreach>" +
"</script>"})
@@ -276,8 +279,20 @@ public interface DeviceChannelMapper {
" and channelId = #{channelId}")
int updateChannelSubCount(String deviceId, String channelId);
@Update(value = {"UPDATE device_channel SET latitude=${latitude}, longitude=${longitude} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
void updatePotion(String deviceId, String channelId, double longitude, double latitude);
@Update(value = {" <script>" +
"UPDATE device_channel " +
"SET " +
"latitude=${latitude}, " +
"longitude=${longitude}, " +
"longitudeGcj02=${longitudeGcj02}, " +
"latitudeGcj02=${latitudeGcj02}, " +
"longitudeWgs84=${longitudeWgs84}, " +
"latitudeWgs84=${latitudeWgs84}, " +
"gpsTime='${gpsTime}' " +
"WHERE deviceId=#{deviceId} " +
" <if test='channelId != null' > AND channelId=#{channelId}</if>" +
" </script>"})
void updatePosition(DeviceChannel deviceChannel);
@Select("SELECT * FROM device_channel WHERE length(trim(streamId)) > 0")
List<DeviceChannel> getAllChannelInPlay();
@@ -313,4 +328,6 @@ public interface DeviceChannelMapper {
@Select("select * from device_channel where deviceId=#{deviceId} and SUBSTRING(channelId, 11, 3)=#{typeCode}")
List<DeviceChannel> getBusinessGroups(String deviceId, String typeCode);
}

View File

@@ -4,19 +4,18 @@ import java.util.List;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import org.apache.ibatis.annotations.*;
//import org.springframework.stereotype.Repository;
@Mapper
//@Repository
public interface DeviceMobilePositionMapper {
@Insert("INSERT INTO device_mobile_position (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource, geodeticSystem, cnLng, cnLat) " +
"VALUES ('${deviceId}','${channelId}', '${deviceName}', '${time}', ${longitude}, ${latitude}, ${altitude}, ${speed}, ${direction}, '${reportSource}', '${geodeticSystem}', '${cnLng}', '${cnLat}')")
@Insert("INSERT INTO device_mobile_position (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource, longitudeGcj02, latitudeGcj02, longitudeWgs84, latitudeWgs84, createTime) " +
"VALUES ('${deviceId}','${channelId}', '${deviceName}', '${time}', ${longitude}, ${latitude}, ${altitude}, ${speed}, ${direction}, '${reportSource}', ${longitudeGcj02}, ${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84}, '${createTime}')")
int insertNewPosition(MobilePosition mobilePosition);
@Select(value = {" <script>" +
"SELECT * FROM device_mobile_position" +
" WHERE deviceId = #{deviceId} and channelId = #{channelId} " +
" WHERE deviceId = #{deviceId}" +
"<if test=\"channelId != null\"> and channelId = #{channelId}</if>" +
"<if test=\"startTime != null\"> AND time&gt;=#{startTime}</if>" +
"<if test=\"endTime != null\"> AND time&lt;=#{endTime}</if>" +
" ORDER BY time ASC" +

View File

@@ -15,10 +15,10 @@ import java.util.List;
public interface GbStreamMapper {
@Insert("REPLACE INTO gb_stream (app, stream, gbId, name, " +
"longitude, latitude, streamType, mediaServerId, status, createStamp) VALUES" +
"longitude, latitude, streamType, mediaServerId, status, createTime) VALUES" +
"('${app}', '${stream}', '${gbId}', '${name}', " +
"'${longitude}', '${latitude}', '${streamType}', " +
"'${mediaServerId}', ${status}, ${createStamp})")
"'${mediaServerId}', ${status}, '${createTime}')")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
int add(GbStream gbStream);
@@ -68,7 +68,7 @@ public interface GbStreamMapper {
List<GbStream> selectAll(String platformId, String catalogId, String query, Boolean pushing, String mediaServerId);
@Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
StreamProxyItem selectOne(String app, String stream);
GbStream selectOne(String app, String stream);
@Select("SELECT * FROM gb_stream WHERE gbId=#{gbId}")
List<GbStream> selectByGBId(String gbId);
@@ -88,16 +88,6 @@ public interface GbStreamMapper {
"ON gs.gbStreamId = pgs.gbStreamId WHERE pgs.gbStreamId is NULL")
List<GbStream> queryStreamNotInPlatform();
@Update("UPDATE gb_stream " +
"SET status=${status} " +
"WHERE app=#{app} AND stream=#{stream}")
int setStatus(String app, String stream, boolean status);
@Update("UPDATE gb_stream " +
"SET status=${status} " +
"WHERE mediaServerId=#{mediaServerId} ")
void updateStatusByMediaServerId(String mediaServerId, boolean status);
@Delete("DELETE FROM gb_stream WHERE streamType=#{type} AND gbId=NULL AND mediaServerId=#{mediaServerId}")
void deleteWithoutGBId(String type, String mediaServerId);
@@ -120,12 +110,12 @@ public interface GbStreamMapper {
@Insert("<script> " +
"INSERT IGNORE into gb_stream " +
"(app, stream, gbId, name, " +
"longitude, latitude, streamType, mediaServerId, status, createStamp)" +
"longitude, latitude, streamType, mediaServerId, status, createTime)" +
"values " +
"<foreach collection='subList' index='index' item='item' separator=','> " +
"('${item.app}', '${item.stream}', '${item.gbId}', '${item.name}', " +
"'${item.longitude}', '${item.latitude}', '${item.streamType}', " +
"'${item.mediaServerId}', ${item.status}, ${item.createStamp}) "+
"'${item.mediaServerId}', ${item.status}, '${item.createTime}') "+
"</foreach> " +
"</script>")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")

View File

@@ -16,10 +16,10 @@ public interface ParentPlatformMapper {
@Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
" devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " +
" status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup) " +
" status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime) " +
" VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
" '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " +
" ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup})")
" ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime})")
int addParentPlatform(ParentPlatform parentPlatform);
@Update("UPDATE parent_platform " +
@@ -45,6 +45,8 @@ public interface ParentPlatformMapper {
"startOfflinePush=${startOfflinePush}, " +
"catalogGroup=#{catalogGroup}, " +
"administrativeDivision=#{administrativeDivision}, " +
"createTime=#{createTime}, " +
"updateTime=#{updateTime}, " +
"catalogId=#{catalogId} " +
"WHERE id=#{id}")
int updateParentPlatform(ParentPlatform parentPlatform);
@@ -86,10 +88,10 @@ public interface ParentPlatformMapper {
@Update(value = {" <script>" +
"UPDATE parent_platform " +
"SET catalogId=#{catalogId}" +
"SET catalogId=#{catalogId}, updateTime=#{updateTime}" +
"WHERE serverGBId=#{platformId}"+
"</script>"})
int setDefaultCatalog(String platformId, String catalogId);
int setDefaultCatalog(String platformId, String catalogId, String updateTime);
@Select("select 'channel' as name, count(pgc.platformId) count from platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId where pgc.platformId=#{platformId} and dc.channelId =#{gbId} " +
"union " +

View File

@@ -62,12 +62,12 @@ public interface StreamProxyMapper {
@Update("UPDATE stream_proxy " +
"SET status=#{status} " +
"WHERE mediaServerId=#{mediaServerId}")
void updateStatusByMediaServerId(boolean status, String mediaServerId);
void updateStatusByMediaServerId(String mediaServerId, boolean status);
@Update("UPDATE stream_proxy " +
"SET status=${status} " +
"WHERE app=#{app} AND stream=#{stream}")
int updateStatus(boolean status, String app, String stream);
int updateStatus(String app, String stream, boolean status);
@Delete("DELETE FROM stream_proxy WHERE enable_remove_none_reader=true AND mediaServerId=#{mediaServerId}")
void deleteAutoRemoveItemByMediaServerId(String mediaServerId);

View File

@@ -14,21 +14,23 @@ import java.util.List;
public interface StreamPushMapper {
@Insert("INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
"createStamp, aliveSecond, mediaServerId, serverId) VALUES" +
"pushTime, aliveSecond, mediaServerId, serverId, updateTime, createTime) VALUES" +
"('${app}', '${stream}', '${totalReaderCount}', '${originType}', '${originTypeStr}', " +
"'${createStamp}', '${aliveSecond}', '${mediaServerId}' , '${serverId}' )")
"'${pushTime}', '${aliveSecond}', '${mediaServerId}' , '${serverId}' , '${updateTime}' , '${createTime}' )")
int add(StreamPushItem streamPushItem);
@Update("UPDATE stream_push " +
"SET app=#{app}," +
"stream=#{stream}," +
"mediaServerId=#{mediaServerId}," +
"totalReaderCount=#{totalReaderCount}, " +
"originType=#{originType}," +
"originTypeStr=#{originTypeStr}, " +
"createStamp=#{createStamp}, " +
"aliveSecond=#{aliveSecond} " +
"WHERE app=#{app} AND stream=#{stream}")
@Update(value = {" <script>" +
"UPDATE stream_push " +
"SET updateTime='${updateTime}'" +
"<if test=\"mediaServerId != null\">, mediaServerId='${mediaServerId}'</if>" +
"<if test=\"totalReaderCount != null\">, totalReaderCount='${totalReaderCount}'</if>" +
"<if test=\"originType != null\">, originType=${originType}</if>" +
"<if test=\"originTypeStr != null\">, originTypeStr='${originTypeStr}'</if>" +
"<if test=\"pushTime != null\">, pushTime='${pushTime}'</if>" +
"<if test=\"aliveSecond != null\">, aliveSecond='${aliveSecond}'</if>" +
"WHERE app=#{app} AND stream=#{stream}"+
" </script>"})
int update(StreamPushItem streamPushItem);
@Delete("DELETE FROM stream_push WHERE app=#{app} AND stream=#{stream}")
@@ -62,7 +64,7 @@ public interface StreamPushMapper {
@Select(value = {" <script>" +
"SELECT " +
"st.*, " +
"gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude, gs.gbStreamId " +
"gs.gbId, gs.name, gs.longitude, gs.latitude, gs.gbStreamId " +
"from " +
"stream_push st " +
"LEFT JOIN gb_stream gs " +
@@ -70,25 +72,25 @@ public interface StreamPushMapper {
"WHERE " +
"1=1 " +
" <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " +
" <if test='pushing == true' > AND (gs.gbId is null OR gs.status=1)</if>" +
" <if test='pushing == false' > AND gs.status=0</if>" +
" <if test='pushing == true' > AND (gs.gbId is null OR st.status=1)</if>" +
" <if test='pushing == false' > AND st.status=0</if>" +
" <if test='mediaServerId != null' > AND st.mediaServerId=#{mediaServerId} </if>" +
"order by st.createStamp desc" +
"order by st.createTime desc" +
" </script>"})
List<StreamPushItem> selectAllForList(String query, Boolean pushing, String mediaServerId);
@Select("SELECT st.*, gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream order by st.createStamp desc")
@Select("SELECT st.*, gs.gbId, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream order by st.createTime desc")
List<StreamPushItem> selectAll();
@Select("SELECT st.*, gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream WHERE st.app=#{app} AND st.stream=#{stream}")
@Select("SELECT st.*, gs.gbId, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream WHERE st.app=#{app} AND st.stream=#{stream}")
StreamPushItem selectOne(String app, String stream);
@Insert("<script>" +
"Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
"createStamp, aliveSecond, mediaServerId) " +
"createTime, aliveSecond, mediaServerId) " +
"VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
"( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " +
"'${item.originTypeStr}',#{item.createStamp}, #{item.aliveSecond}, '${item.mediaServerId}' )" +
"'${item.originTypeStr}',#{item.createTime}, #{item.aliveSecond}, '${item.mediaServerId}' )" +
" </foreach>" +
"</script>")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@@ -106,4 +108,13 @@ public interface StreamPushMapper {
@Select("SELECT sp.* FROM stream_push sp left join gb_stream gs on gs.app = sp.app and gs.stream= sp.stream WHERE sp.mediaServerId=#{mediaServerId} and gs.gbId is null")
List<StreamPushItem> selectAllByMediaServerIdWithOutGbID(String mediaServerId);
@Update("UPDATE stream_push " +
"SET status=${status} " +
"WHERE app=#{app} AND stream=#{stream}")
int updateStatus(String app, String stream, boolean status);
@Update("UPDATE stream_push " +
"SET status=#{status} " +
"WHERE mediaServerId=#{mediaServerId}")
void updateStatusByMediaServerId(String mediaServerId, boolean status);
}

View File

@@ -10,13 +10,14 @@ import java.util.List;
@Repository
public interface UserMapper {
@Insert("INSERT INTO user (username, password, roleId, createTime, updateTime) VALUES" +
"('${username}', '${password}', '${role.id}', '${createTime}', '${updateTime}')")
@Insert("INSERT INTO user (username, password, roleId, pushKey, createTime, updateTime) VALUES" +
"('${username}', '${password}', '${role.id}', '${pushKey}', '${createTime}', '${updateTime}')")
int add(User user);
@Update(value = {" <script>" +
"UPDATE user " +
"SET updateTime='${updateTime}' " +
"<if test=\"pushKey != null\">, pushKey='${pushKey}'</if>" +
"<if test=\"role != null\">, roleId='${role.id}'</if>" +
"<if test=\"password != null\">, password='${password}'</if>" +
"<if test=\"username != null\">, username='${username}'</if>" +
@@ -48,4 +49,10 @@ public interface UserMapper {
@Select("select u.*, r.id as roleID, r.name as roleName, r.authority as roleAuthority , r.createTime as roleCreateTime , r.updateTime as roleUpdateTime FROM user u, user_role r WHERE u.roleId=r.id")
@ResultMap(value="roleMap")
List<User> selectAll();
@Select("select * from (select user.*, concat('${callId}_', pushKey) as str1 from user) as u where md5(u.str1) = '${sign}'")
List<User> checkPushAuthorityByCallIdAndSign(String callId, String sign);
@Select("select * from user where md5(pushKey) = '${sign}'")
List<User> checkPushAuthorityByCallId(String sign);
}

View File

@@ -7,6 +7,7 @@ public class User {
private String password;
private String createTime;
private String updateTime;
private String pushKey;
private Role role;
public int getId() {
@@ -56,4 +57,12 @@ public class User {
public void setRole(Role role) {
this.role = role;
}
public String getPushKey() {
return pushKey;
}
public void setPushKey(String pushKey) {
this.pushKey = pushKey;
}
}

View File

@@ -9,6 +9,8 @@ import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
@@ -20,6 +22,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.*;
@@ -598,6 +601,26 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
return result;
}
@Override
public void updateStreamAuthorityInfo(String app, String stream, StreamAuthorityInfo streamAuthorityInfo) {
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream;
redis.set(key, streamAuthorityInfo);
}
@Override
public void removeStreamAuthorityInfo(String app, String stream) {
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ;
redis.del(key);
}
@Override
public StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream) {
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ;
return (StreamAuthorityInfo) redis.get(key);
}
@Override
public MediaItem getStreamInfo(String app, String streamId, String mediaServerId) {
String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId;
@@ -682,4 +705,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
public boolean deviceIsOnline(String deviceId) {
return getDevice(deviceId).getOnline() == 1;
}
}

View File

@@ -472,6 +472,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
*/
@Override
public synchronized boolean insertMobilePosition(MobilePosition mobilePosition) {
if (mobilePosition.getDeviceId().equals(mobilePosition.getChannelId())) {
mobilePosition.setChannelId(null);
}
return deviceMobilePositionMapper.insertNewPosition(mobilePosition) > 0;
}
@@ -711,7 +714,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
streamProxyItem.setStatus(true);
String now = DateUtil.getNow();
streamProxyItem.setCreateTime(now);
streamProxyItem.setCreateStamp(System.currentTimeMillis());
try {
if (streamProxyMapper.add(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
@@ -846,7 +848,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
streamPushMapper.addAll(streamPushItems);
// TODO 待优化
for (int i = 0; i < streamPushItems.size(); i++) {
int onlineResult = gbStreamMapper.setStatus(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream(), true);
int onlineResult = mediaOnline(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream());
if (onlineResult > 0) {
// 发送上线通知
eventPublisher.catalogEventPublishForStream(null, streamPushItems.get(i), CatalogEvent.ON);
@@ -854,11 +856,13 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
}
}
@Override
public void updateMedia(StreamPushItem streamPushItem) {
streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream());
streamPushMapper.add(streamPushItem);
gbStreamMapper.setStatus(streamPushItem.getApp(), streamPushItem.getStream(), true);
mediaOffline(streamPushItem.getApp(), streamPushItem.getStream());
if(!StringUtils.isEmpty(streamPushItem.getGbId() )){
// 查找开启了全部直播流共享的上级平台
@@ -895,8 +899,26 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
}
@Override
public int mediaOutline(String app, String streamId) {
return gbStreamMapper.setStatus(app, streamId, false);
public int mediaOffline(String app, String stream) {
GbStream gbStream = gbStreamMapper.selectOne(app, stream);
int result;
if ("proxy".equals(gbStream.getStreamType())) {
result = streamProxyMapper.updateStatus(app, stream, false);
}else {
result = streamPushMapper.updateStatus(app, stream, false);
}
return result;
}
public int mediaOnline(String app, String stream) {
GbStream gbStream = gbStreamMapper.selectOne(app, stream);
int result;
if ("proxy".equals(gbStream.getStreamType())) {
result = streamProxyMapper.updateStatus(app, stream, true);
}else {
result = streamPushMapper.updateStatus(app, stream, true);
}
return result;
}
@Override
@@ -1006,7 +1028,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
@Override
public int setDefaultCatalog(String platformId, String catalogId) {
return platformMapper.setDefaultCatalog(platformId, catalogId);
return platformMapper.setDefaultCatalog(platformId, catalogId, DateUtil.getNow());
}
@Override
@@ -1119,7 +1141,14 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
}
@Override
public void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude) {
deviceChannelMapper.updatePotion(deviceId, channelId, longitude, latitude);
public void updateChannelPosition(DeviceChannel deviceChannel) {
if (deviceChannel.getChannelId().equals(deviceChannel.getDeviceId())) {
deviceChannel.setChannelId(null);
}
if (deviceChannel.getGpsTime() == null) {
deviceChannel.setGpsTime(DateUtil.getNow());
}
deviceChannelMapper.updatePosition(deviceChannel);
}
}

View File

@@ -8,7 +8,6 @@ import oshi.hardware.NetworkIF;
import oshi.software.os.OperatingSystem;
import oshi.util.FormatUtil;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View File

@@ -63,12 +63,13 @@ public class MobilePositionController {
@ApiOperation("查询历史轨迹")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "start", value = "开始时间", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "end", value = "结束时间", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "channelId", value = "通道ID", required = false, dataTypeClass = String.class),
@ApiImplicitParam(name = "start", value = "开始时间", required = false, dataTypeClass = String.class),
@ApiImplicitParam(name = "end", value = "结束时间", required = false, dataTypeClass = String.class),
})
@GetMapping("/history/{deviceId}/{channelId}")
@GetMapping("/history/{deviceId}")
public ResponseEntity<WVPResult<List<MobilePosition>>> positions(@PathVariable String deviceId,
@PathVariable String channelId,
@RequestParam(required = false) String channelId,
@RequestParam(required = false) String start,
@RequestParam(required = false) String end) {
// if (logger.isDebugEnabled()) {

View File

@@ -1,9 +1,14 @@
package com.genersoft.iot.vmp.vmanager.gb28181.media;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.annotations.Api;
@@ -16,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@Api(tags = "媒体流相关")
@Controller
@@ -26,17 +33,11 @@ public class MediaController {
private final static Logger logger = LoggerFactory.getLogger(MediaController.class);
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IStreamPushService streamPushService;
private IRedisCatchStorage redisCatchStorage;
@Autowired
private IMediaService mediaService;
@Autowired
private IMediaServerService mediaServerService;
/**
* 根据应用名和流id获取播放地址
@@ -52,13 +53,47 @@ public class MediaController {
})
@GetMapping(value = "/stream_info_by_app_and_stream")
@ResponseBody
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(@RequestParam String app, @RequestParam String stream, @RequestParam(required = false) String mediaServerId){
StreamInfo streamInfoByAppAndStreamWithCheck = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId);
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
@RequestParam String stream,
@RequestParam(required = false) String mediaServerId,
@RequestParam(required = false) String callId,
@RequestParam(required = false) Boolean useSourceIpAsStreamIp){
boolean authority = false;
if (callId != null) {
// 权限校验
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
if (streamAuthorityInfo.getCallId().equals(callId)) {
authority = true;
}else {
WVPResult<StreamInfo> result = new WVPResult<>();
result.setCode(401);
result.setMsg("fail");
return result;
}
}else {
// 是否登陆用户, 登陆用户返回完整信息
LoginUser userInfo = SecurityUtils.getUserInfo();
if (userInfo!= null) {
authority = true;
}
}
StreamInfo streamInfo;
if (useSourceIpAsStreamIp != null && useSourceIpAsStreamIp) {
String host = request.getHeader("Host");
String localAddr = host.split(":")[0];
logger.info("使用{}作为返回流的ip", localAddr);
streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority);
}else {
streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
}
WVPResult<StreamInfo> result = new WVPResult<>();
if (streamInfoByAppAndStreamWithCheck != null){
if (streamInfo != null){
result.setCode(0);
result.setMsg("scccess");
result.setData(streamInfoByAppAndStreamWithCheck);
result.setData(streamInfo);
}else {
result.setCode(-1);
result.setMsg("fail");

View File

@@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam;
@@ -169,6 +170,8 @@ public class PlatformController {
wvpResult.setMsg("平台 " + parentPlatform.getServerGBId() + " 已存在");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
}
parentPlatform.setCreateTime(DateUtil.getNow());
parentPlatform.setUpdateTime(DateUtil.getNow());
boolean updateResult = storager.updateParentPlatform(parentPlatform);
if (updateResult) {
@@ -232,7 +235,7 @@ public class PlatformController {
}
parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase());
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
parentPlatform.setUpdateTime(DateUtil.getNow());
boolean updateResult = storager.updateParentPlatform(parentPlatform);
if (updateResult) {

View File

@@ -197,7 +197,7 @@ public class PlayController {
JSONObject data = jsonObject.getJSONObject("data");
if (data != null) {
result.put("key", data.getString("key"));
StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId());
StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId(), false);
result.put("data", streamInfoResult);
}
}else {

View File

@@ -131,6 +131,9 @@ public class StreamProxyController {
public Object start(String app, String stream){
logger.info("启用代理: " + app + "/" + stream);
boolean result = streamProxyService.start(app, stream);
if (!result) {
logger.info("启用代理失败: " + app + "/" + stream);
}
return result?"success":"fail";
}

View File

@@ -3,11 +3,16 @@ package com.genersoft.iot.vmp.vmanager.streamPush;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.service.impl.StreamPushUploadFileHandler;
import com.genersoft.iot.vmp.vmanager.bean.BatchGBStreamParam;
@@ -30,6 +35,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -54,6 +60,9 @@ public class StreamPushController {
@Autowired
private DeferredResultHolder resultHolder;
@Autowired
private IMediaService mediaService;
@ApiOperation("推流列表查询")
@ApiImplicitParams({
@ApiImplicitParam(name="page", value = "当前页", required = true, dataTypeClass = Integer.class),
@@ -237,5 +246,43 @@ public class StreamPushController {
return result;
}
/**
* 获取推流播放地址
* @param app 应用名
* @param stream 流id
* @return
*/
@ApiOperation("获取推流播放地址")
@ApiImplicitParams({
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
@ApiImplicitParam(name = "stream", value = "流id", dataTypeClass = String.class),
@ApiImplicitParam(name = "mediaServerId", value = "媒体服务器id", dataTypeClass = String.class, required = false),
})
@GetMapping(value = "/getPlayUrl")
@ResponseBody
public WVPResult<StreamInfo> getPlayUrl(HttpServletRequest request, @RequestParam String app,
@RequestParam String stream,
@RequestParam(required = false) String mediaServerId){
boolean authority = false;
// 是否登陆用户, 登陆用户返回完整信息
LoginUser userInfo = SecurityUtils.getUserInfo();
if (userInfo!= null) {
authority = true;
}
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
WVPResult<StreamInfo> result = new WVPResult<>();
if (streamInfo != null){
result.setCode(0);
result.setMsg("scccess");
result.setData(streamInfo);
}else {
result.setCode(-1);
result.setMsg("fail");
}
return result;
}
}