Merge branch 'wvp-28181-2.0'
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java # src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java # src/main/java/com/genersoft/iot/vmp/service/IPlayService.java # src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java结构优化
commit
6bfd48776d
|
@ -27,3 +27,4 @@ hs_err_pid*
|
||||||
/target/
|
/target/
|
||||||
|
|
||||||
/src/main/resources/static/
|
/src/main/resources/static/
|
||||||
|
certificates
|
||||||
|
|
|
@ -48,6 +48,7 @@ CREATE TABLE `device` (
|
||||||
`ssrcCheck` int DEFAULT '0',
|
`ssrcCheck` int DEFAULT '0',
|
||||||
`geoCoordSys` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
`geoCoordSys` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||||
`treeType` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
`treeType` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||||
|
`mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'auto',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `device_deviceId_uindex` (`deviceId`)
|
UNIQUE KEY `device_deviceId_uindex` (`deviceId`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class StreamInfo {
|
||||||
private String endTime;
|
private String endTime;
|
||||||
private double progress;
|
private double progress;
|
||||||
|
|
||||||
|
private boolean pause;
|
||||||
|
|
||||||
public static class TransactionInfo{
|
public static class TransactionInfo{
|
||||||
public String callId;
|
public String callId;
|
||||||
public String localTag;
|
public String localTag;
|
||||||
|
@ -312,4 +314,12 @@ public class StreamInfo {
|
||||||
public void setRtcs(String rtcs) {
|
public void setRtcs(String rtcs) {
|
||||||
this.rtcs = rtcs;
|
this.rtcs = rtcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPause() {
|
||||||
|
return pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPause(boolean pause) {
|
||||||
|
this.pause = pause;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.genersoft.iot.vmp.conf.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lin
|
||||||
|
*/
|
||||||
|
public class ServiceException extends Exception{
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ServiceException(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
package com.genersoft.iot.vmp.conf.exception;
|
package com.genersoft.iot.vmp.conf.exception;
|
||||||
|
|
||||||
import com.sun.javafx.binding.StringFormatter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lin
|
* @author lin
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -132,6 +132,7 @@ public interface ISIPCommander {
|
||||||
|
|
||||||
void talkStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, String callId, ZlmHttpHookSubscribe.Event event, ZlmHttpHookSubscribe.Event eventForPush, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
void talkStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, String callId, ZlmHttpHookSubscribe.Event event, ZlmHttpHookSubscribe.Event eventForPush, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
|
|
||||||
void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;
|
void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;
|
||||||
|
|
||||||
void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
|
void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
|
||||||
|
|
|
@ -729,8 +729,11 @@ public class ZLMHttpHookListener {
|
||||||
storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
|
storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
|
||||||
}else{
|
}else{
|
||||||
StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
||||||
if (streamInfoForPlayBackCatch != null) {
|
if (streamInfoForPlayBackCatch != null ) {
|
||||||
Device device = deviceService.queryDevice(streamInfoForPlayCatch.getDeviceID());
|
if (streamInfoForPlayBackCatch.isPause()) {
|
||||||
|
ret.put("close", false);
|
||||||
|
}else {
|
||||||
|
Device device = deviceService.queryDevice(streamInfoForPlayBackCatch.getDeviceID());
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
try {
|
try {
|
||||||
cmder.streamByeCmd(device,streamInfoForPlayBackCatch.getChannelId(),
|
cmder.streamByeCmd(device,streamInfoForPlayBackCatch.getChannelId(),
|
||||||
|
@ -742,6 +745,8 @@ public class ZLMHttpHookListener {
|
||||||
}
|
}
|
||||||
redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch.getDeviceID(),
|
redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch.getDeviceID(),
|
||||||
streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
|
streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
|
||||||
|
}
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, streamId, null);
|
StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, streamId, null);
|
||||||
// 进行录像下载时无人观看不断流
|
// 进行录像下载时无人观看不断流
|
||||||
|
|
|
@ -23,6 +23,9 @@ public class ZLMRESTfulUtils {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ZLMRESTfulUtils.class);
|
private final static Logger logger = LoggerFactory.getLogger(ZLMRESTfulUtils.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface RequestCallback{
|
public interface RequestCallback{
|
||||||
void run(JSONObject response);
|
void run(JSONObject response);
|
||||||
}
|
}
|
||||||
|
@ -326,10 +329,22 @@ public class ZLMRESTfulUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSnap(MediaServerItem mediaServerItem, String flvUrl, int timeout_sec, int expire_sec, String targetPath, String fileName) {
|
public void getSnap(MediaServerItem mediaServerItem, String flvUrl, int timeout_sec, int expire_sec, String targetPath, String fileName) {
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>(3);
|
||||||
param.put("url", flvUrl);
|
param.put("url", flvUrl);
|
||||||
param.put("timeout_sec", timeout_sec);
|
param.put("timeout_sec", timeout_sec);
|
||||||
param.put("expire_sec", expire_sec);
|
param.put("expire_sec", expire_sec);
|
||||||
sendGetForImg(mediaServerItem, "getSnap", param, targetPath, fileName);
|
sendGetForImg(mediaServerItem, "getSnap", param, targetPath, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JSONObject pauseRtpCheck(MediaServerItem mediaServerItem, String streamId) {
|
||||||
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
|
param.put("stream_id", streamId);
|
||||||
|
return sendPost(mediaServerItem, "pauseRtpCheck",param, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject resumeRtpCheck(MediaServerItem mediaServerItem, String streamId) {
|
||||||
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
|
param.put("stream_id", streamId);
|
||||||
|
return sendPost(mediaServerItem, "resumeRtpCheck",param, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,6 @@ public class ZLMRTPServerFactory {
|
||||||
param.put("stream_id", streamId);
|
param.put("stream_id", streamId);
|
||||||
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param);
|
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param);
|
||||||
if (jsonObject != null ) {
|
if (jsonObject != null ) {
|
||||||
System.out.println(jsonObject);
|
|
||||||
if (jsonObject.getInteger("code") == 0) {
|
if (jsonObject.getInteger("code") == 0) {
|
||||||
return createRTPServer(mediaServerItem, streamId, ssrc, port);
|
return createRTPServer(mediaServerItem, streamId, ssrc, port);
|
||||||
}else {
|
}else {
|
||||||
|
@ -151,7 +150,6 @@ public class ZLMRTPServerFactory {
|
||||||
param.put("stream_id", streamId);
|
param.put("stream_id", streamId);
|
||||||
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(serverItem, param);
|
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(serverItem, param);
|
||||||
if (jsonObject != null ) {
|
if (jsonObject != null ) {
|
||||||
System.out.println(jsonObject);
|
|
||||||
if (jsonObject.getInteger("code") == 0) {
|
if (jsonObject.getInteger("code") == 0) {
|
||||||
result = jsonObject.getInteger("hit") == 1;
|
result = jsonObject.getInteger("hit") == 1;
|
||||||
}else {
|
}else {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
|
import com.genersoft.iot.vmp.conf.exception.ServiceException;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback;
|
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
|
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
|
||||||
|
@ -57,4 +58,8 @@ public interface IPlayService {
|
||||||
void stopAudioBroadcast(String deviceId, String channelId);
|
void stopAudioBroadcast(String deviceId, String channelId);
|
||||||
|
|
||||||
void audioBroadcastCmd(Device device, String channelId, int timeout, AudioBroadcastEvent event) throws InvalidArgumentException, ParseException, SipException;
|
void audioBroadcastCmd(Device device, String channelId, int timeout, AudioBroadcastEvent event) throws InvalidArgumentException, ParseException, SipException;
|
||||||
|
|
||||||
|
void pauseRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException;
|
||||||
|
|
||||||
|
void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,7 +526,6 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||||
|
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("api.secret",mediaServerItem.getSecret()); // -profile:v Baseline
|
param.put("api.secret",mediaServerItem.getSecret()); // -profile:v Baseline
|
||||||
param.put("ffmpeg.cmd","%s -fflags nobuffer -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s");
|
|
||||||
param.put("hook.enable","1");
|
param.put("hook.enable","1");
|
||||||
param.put("hook.on_flow_report",String.format("%s/on_flow_report", hookPrex));
|
param.put("hook.on_flow_report",String.format("%s/on_flow_report", hookPrex));
|
||||||
param.put("hook.on_play",String.format("%s/on_play", hookPrex));
|
param.put("hook.on_play",String.format("%s/on_play", hookPrex));
|
||||||
|
|
|
@ -10,20 +10,26 @@ import javax.sip.ResponseEvent;
|
||||||
import javax.sip.SipException;
|
import javax.sip.SipException;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
|
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
|
import com.genersoft.iot.vmp.conf.exception.ServiceException;
|
||||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
|
||||||
import com.genersoft.iot.vmp.service.IDeviceService;
|
import com.genersoft.iot.vmp.service.IDeviceService;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
|
import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
|
||||||
|
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.context.request.async.DeferredResult;
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
@ -157,6 +163,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
StreamInfo streamInfoForSuccess = (StreamInfo) wvpResult.getData();
|
StreamInfo streamInfoForSuccess = (StreamInfo) wvpResult.getData();
|
||||||
MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
|
MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
|
||||||
String streamUrl = streamInfoForSuccess.getFmp4();
|
String streamUrl = streamInfoForSuccess.getFmp4();
|
||||||
|
|
||||||
// 请求截图
|
// 请求截图
|
||||||
logger.info("[请求截图]: " + fileName);
|
logger.info("[请求截图]: " + fileName);
|
||||||
zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName);
|
zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName);
|
||||||
|
@ -441,7 +448,6 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
|
public void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
|
||||||
ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
|
ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
|
||||||
|
@ -600,12 +606,13 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String mediaServerId = device.getMediaServerId();
|
|
||||||
MediaServerItem mediaServerItem;
|
MediaServerItem mediaServerItem;
|
||||||
if (mediaServerId == null) {
|
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
|
||||||
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
|
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
|
||||||
} else {
|
} else {
|
||||||
mediaServerItem = mediaServerService.getOne(mediaServerId);
|
mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||||
|
} else {
|
||||||
|
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
|
||||||
}
|
}
|
||||||
if (mediaServerItem == null) {
|
if (mediaServerItem == null) {
|
||||||
logger.warn("点播时未找到可使用的ZLM...");
|
logger.warn("点播时未找到可使用的ZLM...");
|
||||||
|
@ -1116,4 +1123,52 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
// }
|
// }
|
||||||
// }));
|
// }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pauseRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException {
|
||||||
|
String key = redisCatchStorage.queryPlaybackForKey(null, null, streamId, null);
|
||||||
|
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
||||||
|
if (null == streamInfo) {
|
||||||
|
logger.warn("streamId不存在!");
|
||||||
|
throw new ServiceException("streamId不存在");
|
||||||
|
}
|
||||||
|
streamInfo.setPause(true);
|
||||||
|
RedisUtil.set(key, streamInfo);
|
||||||
|
MediaServerItem mediaServerItem = mediaServerService.getOne(streamInfo.getMediaServerId());
|
||||||
|
if (null == mediaServerItem) {
|
||||||
|
logger.warn("mediaServer 不存在!");
|
||||||
|
throw new ServiceException("mediaServer不存在");
|
||||||
|
}
|
||||||
|
// zlm 暂停RTP超时检查
|
||||||
|
JSONObject jsonObject = zlmresTfulUtils.pauseRtpCheck(mediaServerItem, streamId);
|
||||||
|
if (jsonObject == null || jsonObject.getInteger("code") != 0) {
|
||||||
|
throw new ServiceException("暂停RTP接收失败");
|
||||||
|
}
|
||||||
|
Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
|
||||||
|
cmder.playPauseCmd(device, streamInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException {
|
||||||
|
String key = redisCatchStorage.queryPlaybackForKey(null, null, streamId, null);
|
||||||
|
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
||||||
|
if (null == streamInfo) {
|
||||||
|
logger.warn("streamId不存在!");
|
||||||
|
throw new ServiceException("streamId不存在");
|
||||||
|
}
|
||||||
|
streamInfo.setPause(false);
|
||||||
|
RedisUtil.set(key, streamInfo);
|
||||||
|
MediaServerItem mediaServerItem = mediaServerService.getOne(streamInfo.getMediaServerId());
|
||||||
|
if (null == mediaServerItem) {
|
||||||
|
logger.warn("mediaServer 不存在!");
|
||||||
|
throw new ServiceException("mediaServer不存在");
|
||||||
|
}
|
||||||
|
// zlm 暂停RTP超时检查
|
||||||
|
JSONObject jsonObject = zlmresTfulUtils.resumeRtpCheck(mediaServerItem, streamId);
|
||||||
|
if (jsonObject == null || jsonObject.getInteger("code") != 0) {
|
||||||
|
throw new ServiceException("继续RTP接收失败");
|
||||||
|
}
|
||||||
|
Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
|
||||||
|
cmder.playResumeCmd(device, streamInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||||
@Override
|
@Override
|
||||||
public StreamInfo save(StreamProxyItem param) {
|
public StreamInfo save(StreamProxyItem param) {
|
||||||
MediaServerItem mediaInfo;
|
MediaServerItem mediaInfo;
|
||||||
if (param.getMediaServerId() == null || "auto".equals(param.getMediaServerId())){
|
if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
|
||||||
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
|
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
|
||||||
}else {
|
}else {
|
||||||
mediaInfo = mediaServerService.getOne(param.getMediaServerId());
|
mediaInfo = mediaServerService.getOne(param.getMediaServerId());
|
||||||
|
|
|
@ -56,6 +56,8 @@ public interface IRedisCatchStorage {
|
||||||
|
|
||||||
StreamInfo queryPlayback(String deviceId, String channelID, String stream, String callId);
|
StreamInfo queryPlayback(String deviceId, String channelID, String stream, String callId);
|
||||||
|
|
||||||
|
String queryPlaybackForKey(String deviceId, String channelId, String stream, String callId);
|
||||||
|
|
||||||
void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch);
|
void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch);
|
||||||
|
|
||||||
ParentPlatformCatch queryPlatformCatchInfo(String platformGbId);
|
ParentPlatformCatch queryPlatformCatchInfo(String platformGbId);
|
||||||
|
|
|
@ -93,6 +93,7 @@ public interface DeviceMapper {
|
||||||
"<if test=\"ssrcCheck != null\">, ssrcCheck=${ssrcCheck}</if>" +
|
"<if test=\"ssrcCheck != null\">, ssrcCheck=${ssrcCheck}</if>" +
|
||||||
"<if test=\"geoCoordSys != null\">, geoCoordSys=#{geoCoordSys}</if>" +
|
"<if test=\"geoCoordSys != null\">, geoCoordSys=#{geoCoordSys}</if>" +
|
||||||
"<if test=\"treeType != null\">, treeType=#{treeType}</if>" +
|
"<if test=\"treeType != null\">, treeType=#{treeType}</if>" +
|
||||||
|
"<if test=\"mediaServerId != null\">, mediaServerId=#{mediaServerId}</if>" +
|
||||||
"WHERE deviceId='${deviceId}'"+
|
"WHERE deviceId='${deviceId}'"+
|
||||||
" </script>"})
|
" </script>"})
|
||||||
int update(Device device);
|
int update(Device device);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
|
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.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam;
|
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
||||||
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
||||||
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
||||||
|
@ -22,7 +21,6 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -127,6 +125,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public StreamInfo queryPlayByStreamId(String streamId) {
|
public StreamInfo queryPlayByStreamId(String streamId) {
|
||||||
|
System.out.println(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
|
||||||
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
|
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
|
||||||
if (playLeys == null || playLeys.size() == 0) {
|
if (playLeys == null || playLeys.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -165,6 +164,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startPlayback(StreamInfo stream, String callId) {
|
public boolean startPlayback(StreamInfo stream, String callId) {
|
||||||
|
System.out.println(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
||||||
|
userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId));
|
||||||
return RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
return RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
||||||
userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream);
|
userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream);
|
||||||
}
|
}
|
||||||
|
@ -285,6 +286,34 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String queryPlaybackForKey(String deviceId, String channelId, String stream, String callId) {
|
||||||
|
if (stream == null && callId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (deviceId == null) {
|
||||||
|
deviceId = "*";
|
||||||
|
}
|
||||||
|
if (channelId == null) {
|
||||||
|
channelId = "*";
|
||||||
|
}
|
||||||
|
if (stream == null) {
|
||||||
|
stream = "*";
|
||||||
|
}
|
||||||
|
if (callId == null) {
|
||||||
|
callId = "*";
|
||||||
|
}
|
||||||
|
String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
||||||
|
userSetting.getServerId(),
|
||||||
|
deviceId,
|
||||||
|
channelId,
|
||||||
|
stream,
|
||||||
|
callId
|
||||||
|
);
|
||||||
|
List<Object> streamInfoScan = RedisUtil.scan(key);
|
||||||
|
return (String) streamInfoScan.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch) {
|
public void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch) {
|
||||||
String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + parentPlatformCatch.getId();
|
String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + parentPlatformCatch.getId();
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.genersoft.iot.vmp.utils;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class CollectionUtil {
|
|
||||||
|
|
||||||
public static <T> boolean contains(T[] array, final T element) {
|
|
||||||
return array != null && Arrays.stream(array).anyMatch((x) -> {
|
|
||||||
return ObjectUtils.nullSafeEquals(x, element);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package com.genersoft.iot.vmp.utils;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class ObjectUtils {
|
|
||||||
public static boolean nullSafeEquals(Object o1, Object o2) {
|
|
||||||
if (o1 == o2) {
|
|
||||||
return true;
|
|
||||||
} else if (o1 != null && o2 != null) {
|
|
||||||
if (o1.equals(o2)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return o1.getClass().isArray() && o2.getClass().isArray() && arrayEquals(o1, o2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean arrayEquals(Object o1, Object o2) {
|
|
||||||
if (o1 instanceof Object[] && o2 instanceof Object[]) {
|
|
||||||
return Arrays.equals((Object[])((Object[])o1), (Object[])((Object[])o2));
|
|
||||||
} else if (o1 instanceof boolean[] && o2 instanceof boolean[]) {
|
|
||||||
return Arrays.equals((boolean[])((boolean[])o1), (boolean[])((boolean[])o2));
|
|
||||||
} else if (o1 instanceof byte[] && o2 instanceof byte[]) {
|
|
||||||
return Arrays.equals((byte[])((byte[])o1), (byte[])((byte[])o2));
|
|
||||||
} else if (o1 instanceof char[] && o2 instanceof char[]) {
|
|
||||||
return Arrays.equals((char[])((char[])o1), (char[])((char[])o2));
|
|
||||||
} else if (o1 instanceof double[] && o2 instanceof double[]) {
|
|
||||||
return Arrays.equals((double[])((double[])o1), (double[])((double[])o2));
|
|
||||||
} else if (o1 instanceof float[] && o2 instanceof float[]) {
|
|
||||||
return Arrays.equals((float[])((float[])o1), (float[])((float[])o2));
|
|
||||||
} else if (o1 instanceof int[] && o2 instanceof int[]) {
|
|
||||||
return Arrays.equals((int[])((int[])o1), (int[])((int[])o2));
|
|
||||||
} else if (o1 instanceof long[] && o2 instanceof long[]) {
|
|
||||||
return Arrays.equals((long[])((long[])o1), (long[])((long[])o2));
|
|
||||||
} else {
|
|
||||||
return o1 instanceof short[] && o2 instanceof short[] && Arrays.equals((short[]) ((short[]) o1), (short[]) ((short[]) o2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,9 +2,11 @@ package com.genersoft.iot.vmp.vmanager.gb28181.playback;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
|
import com.genersoft.iot.vmp.conf.exception.ServiceException;
|
||||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.service.IPlayService;
|
import com.genersoft.iot.vmp.service.IPlayService;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
|
@ -45,6 +47,9 @@ public class PlaybackController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SIPCommander cmder;
|
private SIPCommander cmder;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ZLMRTPServerFactory zlmrtpServerFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IVideoManagerStorage storager;
|
private IVideoManagerStorage storager;
|
||||||
|
|
||||||
|
@ -113,14 +118,11 @@ public class PlaybackController {
|
||||||
@GetMapping("/pause/{streamId}")
|
@GetMapping("/pause/{streamId}")
|
||||||
public void playPause(@PathVariable String streamId) {
|
public void playPause(@PathVariable String streamId) {
|
||||||
logger.info("playPause: "+streamId);
|
logger.info("playPause: "+streamId);
|
||||||
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
|
||||||
if (null == streamInfo) {
|
|
||||||
logger.warn("streamId不存在!");
|
|
||||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
|
|
||||||
}
|
|
||||||
Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
|
|
||||||
try {
|
try {
|
||||||
cmder.playPauseCmd(device, streamInfo);
|
playService.pauseRtp(streamId);
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR400.getCode(), e.getMessage());
|
||||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
} catch (InvalidArgumentException | ParseException | SipException e) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -132,14 +134,10 @@ public class PlaybackController {
|
||||||
@GetMapping("/resume/{streamId}")
|
@GetMapping("/resume/{streamId}")
|
||||||
public void playResume(@PathVariable String streamId) {
|
public void playResume(@PathVariable String streamId) {
|
||||||
logger.info("playResume: "+streamId);
|
logger.info("playResume: "+streamId);
|
||||||
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
|
||||||
if (null == streamInfo) {
|
|
||||||
logger.warn("streamId不存在!");
|
|
||||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
|
|
||||||
}
|
|
||||||
Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
|
|
||||||
try {
|
try {
|
||||||
cmder.playResumeCmd(device, streamInfo);
|
playService.resumeRtp(streamId);
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR400.getCode(), e.getMessage());
|
||||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
} catch (InvalidArgumentException | ParseException | SipException e) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,17 +18,17 @@
|
||||||
<el-form-item label="设备名称" prop="name">
|
<el-form-item label="设备名称" prop="name">
|
||||||
<el-input v-model="form.name" clearable></el-input>
|
<el-input v-model="form.name" clearable></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item label="流媒体ID" prop="mediaServerId">-->
|
<el-form-item label="流媒体ID" prop="mediaServerId">
|
||||||
<!-- <el-select v-model="form.mediaServerId" style="float: left; width: 100%" >-->
|
<el-select v-model="form.mediaServerId" style="float: left; width: 100%" >
|
||||||
<!-- <el-option key="auto" label="自动负载最小" value="null"></el-option>-->
|
<el-option key="auto" label="自动负载最小" value="auto"></el-option>
|
||||||
<!-- <el-option-->
|
<el-option
|
||||||
<!-- v-for="item in mediaServerList"-->
|
v-for="item in mediaServerList"
|
||||||
<!-- :key="item.id"-->
|
:key="item.id"
|
||||||
<!-- :label="item.id"-->
|
:label="item.id"
|
||||||
<!-- :value="item.id">-->
|
:value="item.id">
|
||||||
<!-- </el-option>-->
|
</el-option>
|
||||||
<!-- </el-select>-->
|
</el-select>
|
||||||
<!-- </el-form-item>-->
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="字符集" prop="charset" >
|
<el-form-item label="字符集" prop="charset" >
|
||||||
<el-select v-model="form.charset" style="float: left; width: 100%" >
|
<el-select v-model="form.charset" style="float: left; width: 100%" >
|
||||||
|
|
Loading…
Reference in New Issue