Merge branch 'master' into dev/springBoot3
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/controller/MediaController.java # src/main/java/com/genersoft/iot/vmp/jt1078/config/JT1078Controller.java
This commit is contained in:
@@ -59,11 +59,13 @@ public interface ICloudRecordService {
|
||||
/**
|
||||
* 加载录像文件,形成录像流
|
||||
*/
|
||||
void loadRecord(String app, String stream, String date, ErrorCallback<StreamInfo> callback);
|
||||
void loadMP4FileForDate(String app, String stream, String date, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
void seekRecord(String mediaServerId,String app, String stream, Double seek, String schema);
|
||||
|
||||
void setRecordSpeed(String mediaServerId, String app, String stream, Integer speed, String schema);
|
||||
|
||||
void deleteFileByIds(Set<Integer> ids);
|
||||
|
||||
void loadMP4File(String app, String stream, int cloudRecordId, ErrorCallback<StreamInfo> callback);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.genersoft.iot.vmp.service.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.media.event.media.MediaRecordMp4Event;
|
||||
import com.genersoft.iot.vmp.media.event.media.MediaRecordProcessEvent;
|
||||
import com.genersoft.iot.vmp.utils.MediaServerUtils;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -90,14 +91,14 @@ public class CloudRecordItem {
|
||||
CloudRecordItem cloudRecordItem = new CloudRecordItem();
|
||||
cloudRecordItem.setApp(param.getApp());
|
||||
cloudRecordItem.setStream(param.getStream());
|
||||
cloudRecordItem.setStartTime(param.getRecordInfo().getStartTime()*1000);
|
||||
cloudRecordItem.setStartTime(param.getRecordInfo().getStartTime());
|
||||
cloudRecordItem.setFileName(param.getRecordInfo().getFileName());
|
||||
cloudRecordItem.setFolder(param.getRecordInfo().getFolder());
|
||||
cloudRecordItem.setFileSize(param.getRecordInfo().getFileSize());
|
||||
cloudRecordItem.setFilePath(param.getRecordInfo().getFilePath());
|
||||
cloudRecordItem.setMediaServerId(param.getMediaServer().getId());
|
||||
cloudRecordItem.setTimeLen(param.getRecordInfo().getTimeLen() * 1000);
|
||||
cloudRecordItem.setEndTime((param.getRecordInfo().getStartTime() + (long)param.getRecordInfo().getTimeLen()) * 1000);
|
||||
cloudRecordItem.setTimeLen(param.getRecordInfo().getTimeLen());
|
||||
cloudRecordItem.setEndTime((param.getRecordInfo().getStartTime() + (long)param.getRecordInfo().getTimeLen()));
|
||||
Map<String, String> paramsMap = MediaServerUtils.urlParamToMap(param.getRecordInfo().getParams());
|
||||
if (paramsMap.get("callId") != null) {
|
||||
cloudRecordItem.setCallId(paramsMap.get("callId"));
|
||||
@@ -105,4 +106,14 @@ public class CloudRecordItem {
|
||||
return cloudRecordItem;
|
||||
}
|
||||
|
||||
public static CloudRecordItem getInstance(MediaRecordProcessEvent event) {
|
||||
CloudRecordItem cloudRecordItem = new CloudRecordItem();
|
||||
cloudRecordItem.setApp(event.getApp());
|
||||
cloudRecordItem.setStream(event.getStream());
|
||||
cloudRecordItem.setFileName(event.getFileName());
|
||||
cloudRecordItem.setMediaServerId(event.getMediaServer().getId());
|
||||
cloudRecordItem.setTimeLen(event.getCurrentFileDuration() * 1000);
|
||||
return cloudRecordItem;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.genersoft.iot.vmp.service.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DownloadFileInfo {
|
||||
|
||||
private String httpPath;
|
||||
@@ -7,35 +10,4 @@ public class DownloadFileInfo {
|
||||
private String httpDomainPath;
|
||||
private String httpsDomainPath;
|
||||
|
||||
public String getHttpPath() {
|
||||
return httpPath;
|
||||
}
|
||||
|
||||
public void setHttpPath(String httpPath) {
|
||||
this.httpPath = httpPath;
|
||||
}
|
||||
|
||||
public String getHttpsPath() {
|
||||
return httpsPath;
|
||||
}
|
||||
|
||||
public void setHttpsPath(String httpsPath) {
|
||||
this.httpsPath = httpsPath;
|
||||
}
|
||||
|
||||
public String getHttpDomainPath() {
|
||||
return httpDomainPath;
|
||||
}
|
||||
|
||||
public void setHttpDomainPath(String httpDomainPath) {
|
||||
this.httpDomainPath = httpDomainPath;
|
||||
}
|
||||
|
||||
public String getHttpsDomainPath() {
|
||||
return httpsDomainPath;
|
||||
}
|
||||
|
||||
public void setHttpsDomainPath(String httpsDomainPath) {
|
||||
this.httpsDomainPath = httpsDomainPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ public enum InviteErrorCode {
|
||||
ERROR_FOR_SIP_SENDING_FAILED(-10, "命令发送失败"),
|
||||
ERROR_FOR_ASSIST_NOT_READY(-11, "没有可用的assist服务"),
|
||||
ERROR_FOR_PARAMETER_ERROR(-13, "参数异常"),
|
||||
ERROR_FOR_TCP_ACTIVE_CONNECTION_REFUSED_ERROR(-14, "TCP主动连接失败");
|
||||
ERROR_FOR_TCP_ACTIVE_CONNECTION_REFUSED_ERROR(-14, "TCP主动连接失败"),
|
||||
ERROR_FOR_FINISH(-20, "已结束"),
|
||||
;
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
@@ -5,11 +5,8 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.event.hook.Hook;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookType;
|
||||
import com.genersoft.iot.vmp.media.bean.RecordInfo;
|
||||
import com.genersoft.iot.vmp.media.event.media.MediaRecordMp4Event;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils;
|
||||
@@ -21,7 +18,6 @@ import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper;
|
||||
import com.genersoft.iot.vmp.utils.CloudRecordUtils;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -37,7 +33,10 @@ import org.springframework.util.Assert;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -61,9 +60,6 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||
@Autowired
|
||||
private IRedisRpcPlayService redisRpcPlayService;
|
||||
|
||||
@Autowired
|
||||
private HookSubscribe subscribe;
|
||||
|
||||
@Override
|
||||
public PageInfo<CloudRecordItem> getList(int page, int count, String query, String app, String stream, String startTime,
|
||||
String endTime, List<MediaServer> mediaServerItems, String callId, Boolean ascOrder) {
|
||||
@@ -255,9 +251,10 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||
if (!userSetting.getServerId().equals(recordItem.getServerId())) {
|
||||
return redisRpcPlayService.getRecordPlayUrl(recordItem.getServerId(), recordId);
|
||||
}
|
||||
String filePath = recordItem.getFilePath();
|
||||
MediaServer mediaServerItem = mediaServerService.getOne(recordItem.getMediaServerId());
|
||||
return CloudRecordUtils.getDownloadFilePath(mediaServerItem, filePath);
|
||||
|
||||
MediaServer mediaServer = mediaServerService.getOne(recordItem.getMediaServerId());
|
||||
|
||||
return mediaServerService.getDownloadFilePath(mediaServer, RecordInfo.getInstance(recordItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,7 +281,36 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadRecord(String app, String stream, String date, ErrorCallback<StreamInfo> callback) {
|
||||
public void loadMP4File(String app, String stream, int cloudRecordId, ErrorCallback<StreamInfo> callback) {
|
||||
|
||||
CloudRecordItem recordItem = cloudRecordServiceMapper.queryOne(cloudRecordId);
|
||||
if (recordItem == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "无录像");
|
||||
}
|
||||
String mediaServerId = recordItem.getMediaServerId();
|
||||
MediaServer mediaServer = mediaServerService.getOne(mediaServerId);
|
||||
if (mediaServer == null) {
|
||||
log.warn("[云端录像] 播放 未找到录制的流媒体,将自动选择低负载流媒体使用");
|
||||
mediaServer = mediaServerService.getMediaServerForMinimumLoad(null);
|
||||
}
|
||||
if (mediaServer == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "无可用流媒体");
|
||||
}
|
||||
String fileName = recordItem.getFileName().substring(0 , recordItem.getFileName().indexOf("."));
|
||||
String filePath = recordItem.getFilePath();
|
||||
// if (filePath != null) {
|
||||
// fileName = filePath.substring(0, filePath.lastIndexOf("/"));
|
||||
// }
|
||||
mediaServerService.loadMP4File(mediaServer, app, stream, filePath, fileName, ((code, msg, streamInfo) -> {
|
||||
if (code == ErrorCode.SUCCESS.getCode()) {
|
||||
streamInfo.setDuration(recordItem.getTimeLen());
|
||||
}
|
||||
callback.run(code, msg, streamInfo);
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadMP4FileForDate(String app, String stream, String date, ErrorCallback<StreamInfo> callback) {
|
||||
long startTimestamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestampMs(date + " 00:00:00");
|
||||
long endTimestamp = startTimestamp + 24 * 60 * 60 * 1000;
|
||||
|
||||
@@ -297,26 +323,13 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||
if (mediaServer == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "媒体节点不存在: " + mediaServerId);
|
||||
}
|
||||
String buildApp = "mp4_record";
|
||||
String buildStream = app + "_" + stream + "_" + date;
|
||||
MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, buildApp, buildStream);
|
||||
if (mediaInfo != null) {
|
||||
if (callback != null) {
|
||||
StreamInfo streamInfo = mediaServerService.getStreamInfoByAppAndStream(mediaServer, buildApp, buildStream, mediaInfo, null);
|
||||
callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
|
||||
}
|
||||
return;
|
||||
}
|
||||
String dateDir = null;
|
||||
String filePath = recordItemList.get(0).getFilePath();
|
||||
if (filePath != null) {
|
||||
dateDir = filePath.substring(0, filePath.lastIndexOf("/"));
|
||||
}
|
||||
mediaServerService.loadMP4FileForDate(mediaServer, app, stream, date, dateDir, callback);
|
||||
|
||||
Hook hook = Hook.getInstance(HookType.on_media_arrival, buildApp, buildStream, mediaServerId);
|
||||
subscribe.addSubscribe(hook, (hookData) -> {
|
||||
StreamInfo streamInfo = mediaServerService.getStreamInfoByAppAndStream(mediaServer, buildApp, buildStream, hookData.getMediaInfo(), null);
|
||||
if (callback != null) {
|
||||
callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
|
||||
}
|
||||
});
|
||||
String dateDir = recordItemList.get(0).getFilePath().substring(0, recordItemList.get(0).getFilePath().lastIndexOf("/"));
|
||||
mediaServerService.loadMP4File(mediaServer, buildApp, buildStream, dateDir);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,11 +11,15 @@ import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.gb28181.session.SipInviteSessionManager;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTMediaStreamType;
|
||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078PlayService;
|
||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.bean.ResultForOnPublish;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
||||
import com.genersoft.iot.vmp.service.IMediaService;
|
||||
import com.genersoft.iot.vmp.service.IRecordPlanService;
|
||||
import com.genersoft.iot.vmp.service.ISendRtpServerService;
|
||||
import com.genersoft.iot.vmp.service.IUserService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
|
||||
@@ -60,6 +64,16 @@ public class MediaServiceImpl implements IMediaService {
|
||||
@Autowired
|
||||
private SipInviteSessionManager sessionManager;
|
||||
|
||||
@Autowired
|
||||
private Ijt1078Service ijt1078Service;
|
||||
|
||||
@Autowired
|
||||
private Ijt1078PlayService jt1078PlayService;
|
||||
|
||||
@Autowired
|
||||
private ISendRtpServerService sendRtpServerService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IRecordPlanService recordPlanService;
|
||||
|
||||
@@ -81,13 +95,25 @@ public class MediaServiceImpl implements IMediaService {
|
||||
@Override
|
||||
public ResultForOnPublish authenticatePublish(MediaServer mediaServer, String app, String stream, String params) {
|
||||
// 推流鉴权的处理
|
||||
if (!"rtp".equals(app)) {
|
||||
if (!"rtp".equals(app) && !"1078".equals(app) ) {
|
||||
if ("talk".equals(app) && stream.endsWith("_talk")) {
|
||||
ResultForOnPublish result = new ResultForOnPublish();
|
||||
result.setEnable_mp4(false);
|
||||
result.setEnable_audio(true);
|
||||
return result;
|
||||
}
|
||||
if ("jt_talk".equals(app) && stream.endsWith("_talk")) {
|
||||
ResultForOnPublish result = new ResultForOnPublish();
|
||||
result.setEnable_mp4(false);
|
||||
result.setEnable_audio(true);
|
||||
return result;
|
||||
}
|
||||
if ("mp4_record".equals(app) ) {
|
||||
ResultForOnPublish result = new ResultForOnPublish();
|
||||
result.setEnable_mp4(false);
|
||||
result.setEnable_audio(true);
|
||||
return result;
|
||||
}
|
||||
StreamProxy streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(app, stream);
|
||||
if (streamProxyItem != null) {
|
||||
ResultForOnPublish result = new ResultForOnPublish();
|
||||
@@ -146,7 +172,7 @@ public class MediaServiceImpl implements IMediaService {
|
||||
inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc);
|
||||
if (inviteInfo != null) {
|
||||
result.setStream_replace(inviteInfo.getStream());
|
||||
log.info("[ZLM HOOK]推流鉴权 stream: {} 替换为 {}", stream, inviteInfo.getStream());
|
||||
log.info("[HOOK]推流鉴权 stream: {} 替换为 {}", stream, inviteInfo.getStream());
|
||||
stream = inviteInfo.getStream();
|
||||
}
|
||||
}
|
||||
@@ -221,22 +247,36 @@ public class MediaServiceImpl implements IMediaService {
|
||||
result = userSetting.getStreamOnDemand();
|
||||
// 国标流, 点播/录像回放/录像下载
|
||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, stream);
|
||||
// 点播
|
||||
if (inviteInfo != null && inviteInfo.getStatus() == InviteSessionStatus.ok) {
|
||||
// 录像下载
|
||||
if (inviteInfo.getType() == InviteSessionType.DOWNLOAD) {
|
||||
return false;
|
||||
}
|
||||
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(inviteInfo.getChannelId());
|
||||
if (deviceChannel == null) {
|
||||
return false;
|
||||
if (inviteInfo != null) {
|
||||
if (inviteInfo.getStatus() == InviteSessionStatus.ok){
|
||||
// 录像下载
|
||||
if (inviteInfo.getType() == InviteSessionType.DOWNLOAD) {
|
||||
return false;
|
||||
}
|
||||
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(inviteInfo.getChannelId());
|
||||
if (deviceChannel == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}else if ("1078".equals(app)) {
|
||||
// 判断是否是1078播放类型
|
||||
JTMediaStreamType jtMediaStreamType = ijt1078Service.checkStreamFromJt(stream);
|
||||
if (jtMediaStreamType != null) {
|
||||
String[] streamParamArray = stream.split("_");
|
||||
if (jtMediaStreamType.equals(JTMediaStreamType.PLAY)) {
|
||||
jt1078PlayService.stopPlay(streamParamArray[0], Integer.parseInt(streamParamArray[1]));
|
||||
}else if (jtMediaStreamType.equals(JTMediaStreamType.PLAYBACK)) {
|
||||
jt1078PlayService.stopPlayback(streamParamArray[0], Integer.parseInt(streamParamArray[1]));
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
} else if ("talk".equals(app) || "broadcast".equals(app)) {
|
||||
}else if ("talk".equals(app) || "broadcast".equals(app)) {
|
||||
return false;
|
||||
} else if ("mp4_record".equals(app)) {
|
||||
return true;
|
||||
} else {
|
||||
// 非国标流 推流/拉流代理
|
||||
// 拉流代理
|
||||
@@ -260,5 +300,6 @@ public class MediaServiceImpl implements IMediaService {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,24 +16,23 @@ public interface IRedisRpcPlayService {
|
||||
|
||||
void playback(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
void playbackPause(String serverId, String streamId);
|
||||
|
||||
void playbackResume(String serverId, String streamId);
|
||||
|
||||
void download(String serverId, Integer channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
void queryRecordInfo(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback<RecordInfo> callback);
|
||||
|
||||
void pauseRtp(String serverId, String streamId);
|
||||
|
||||
void resumeRtp(String serverId, String streamId);
|
||||
|
||||
String frontEndCommand(String serverId, Integer channelId, int cmdCode, int parameter1, int parameter2, int combindCode2);
|
||||
|
||||
void playPush(String serverId, Integer id, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
StreamInfo playProxy(String serverId, int id);
|
||||
void playProxy(String serverId, int id, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
void stopProxy(String serverId, int id);
|
||||
|
||||
DownloadFileInfo getRecordPlayUrl(String serverId, Integer recordId);
|
||||
|
||||
|
||||
AudioBroadcastResult audioBroadcast(String serverId, String deviceId, String channelDeviceId, Boolean broadcastMode);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IRedisRpcService {
|
||||
|
||||
SendRtpInfo getSendRtpItem(String callId);
|
||||
@@ -63,5 +65,5 @@ public interface IRedisRpcService {
|
||||
|
||||
WVPResult<Object> deviceInfo(String serverId, Device device);
|
||||
|
||||
WVPResult<Object> queryPreset(String serverId, Device device, String channelId);
|
||||
WVPResult<List<Preset>> queryPreset(String serverId, Device device, String channelId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.genersoft.iot.vmp.service.redisMsg.control;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
@@ -10,9 +9,7 @@ import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.InviteMessageInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPTZService;
|
||||
@@ -81,7 +78,7 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
|
||||
InviteMessageInfo inviteInfo = new InviteMessageInfo();
|
||||
inviteInfo.setSessionName("Play");
|
||||
channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{
|
||||
channelPlayService.startInvite(channel, inviteInfo, null, (code, msg, data) ->{
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
response.setBody(data);
|
||||
@@ -118,9 +115,9 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
response.setBody("param error");
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
channelService.queryRecordInfo(channel, startTime, endTime, (code, msg, data) ->{
|
||||
channelPlayService.queryRecord(channel, startTime, endTime, (code, msg, data) ->{
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
||||
response.setStatusCode(code);
|
||||
response.setBody(data);
|
||||
@@ -134,15 +131,15 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
response.setStatusCode(ErrorCode.ERROR100.getCode());
|
||||
response.setBody(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停录像回放
|
||||
*/
|
||||
@RedisRpcMapping("pauseRtp")
|
||||
public RedisRpcResponse pauseRtp(RedisRpcRequest request) {
|
||||
@RedisRpcMapping("playbackPause")
|
||||
public RedisRpcResponse playbackPause(RedisRpcRequest request) {
|
||||
String streamId = request.getParam().toString();
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
|
||||
@@ -153,7 +150,7 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
}
|
||||
|
||||
try {
|
||||
channelPlayService.pauseRtp(streamId);
|
||||
// channelPlayService.playbackPause(streamId);
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
}catch (ControllerException e) {
|
||||
response.setStatusCode(ErrorCode.ERROR100.getCode());
|
||||
@@ -166,8 +163,8 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
/**
|
||||
* 恢复录像回放
|
||||
*/
|
||||
@RedisRpcMapping("resumeRtp")
|
||||
public RedisRpcResponse resumeRtp(RedisRpcRequest request) {
|
||||
@RedisRpcMapping("playbackResume")
|
||||
public RedisRpcResponse playbackResume(RedisRpcRequest request) {
|
||||
String streamId = request.getParam().toString();
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
|
||||
@@ -178,7 +175,7 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
}
|
||||
|
||||
try {
|
||||
channelPlayService.resumeRtp(streamId);
|
||||
// channelPlayService.playbackResume(streamId);
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
}catch (ControllerException e) {
|
||||
response.setStatusCode(ErrorCode.ERROR100.getCode());
|
||||
@@ -216,7 +213,7 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
return response;
|
||||
}
|
||||
try {
|
||||
channelPlayService.stopPlay(type, channel, stream);
|
||||
channelPlayService.stopInvite(type, channel, stream);
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
}catch (Exception e){
|
||||
response.setStatusCode(Response.SERVER_INTERNAL_ERROR);
|
||||
@@ -253,7 +250,7 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
inviteInfo.setSessionName("Playback");
|
||||
inviteInfo.setStartTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime));
|
||||
inviteInfo.setStopTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime));
|
||||
channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{
|
||||
channelPlayService.startInvite(channel, inviteInfo, null, (code, msg, data) ->{
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
response.setBody(data);
|
||||
@@ -296,7 +293,7 @@ public class RedisRpcChannelPlayController extends RpcController {
|
||||
inviteInfo.setStartTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime));
|
||||
inviteInfo.setStopTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime));
|
||||
inviteInfo.setDownloadSpeed(downloadSpeed + "");
|
||||
channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{
|
||||
channelPlayService.startInvite(channel, inviteInfo, null, (code, msg, data) ->{
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
response.setBody(data);
|
||||
|
||||
@@ -19,8 +19,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sip.message.Response;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@RedisRpcController("sendRtp")
|
||||
@@ -61,7 +59,7 @@ public class RedisRpcSendRtpController extends RpcController {
|
||||
}
|
||||
// 自平台内容
|
||||
int localPort = sendRtpServerService.getNextPort(mediaServerItem);
|
||||
if (localPort == 0) {
|
||||
if (localPort <= 0) {
|
||||
log.info("[redis-rpc] getSendRtpItem->服务器端口资源不足" );
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.genersoft.iot.vmp.service.redisMsg.control;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage;
|
||||
@@ -63,10 +62,13 @@ public class RedisRpcStreamProxyController extends RpcController {
|
||||
response.setBody("param error");
|
||||
return response;
|
||||
}
|
||||
StreamInfo streamInfo = streamProxyPlayService.startProxy(streamProxy);
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
response.setBody(JSONObject.toJSONString(streamInfo));
|
||||
return response;
|
||||
streamProxyPlayService.startProxy(streamProxy, (code, msg, streamInfo) -> {
|
||||
response.setStatusCode(code);
|
||||
response.setBody(JSONObject.toJSONString(streamInfo));
|
||||
sendResponse(response);
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,8 +121,8 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pauseRtp(String serverId, String streamId) {
|
||||
RedisRpcRequest request = buildRequest("channel/pauseRtp", streamId);
|
||||
public void playbackPause(String serverId, String streamId) {
|
||||
RedisRpcRequest request = buildRequest("channel/playbackPause", streamId);
|
||||
request.setToId(serverId);
|
||||
RedisRpcResponse response = redisRpcConfig.request(request, 5, TimeUnit.SECONDS);
|
||||
if (response == null) {
|
||||
@@ -135,8 +135,8 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumeRtp(String serverId, String streamId) {
|
||||
RedisRpcRequest request = buildRequest("channel/resumeRtp", streamId);
|
||||
public void playbackResume(String serverId, String streamId) {
|
||||
RedisRpcRequest request = buildRequest("channel/playbackResume", streamId);
|
||||
request.setToId(serverId);
|
||||
RedisRpcResponse response = redisRpcConfig.request(request, 5, TimeUnit.SECONDS);
|
||||
if (response == null) {
|
||||
@@ -212,13 +212,20 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamInfo playProxy(String serverId, int id) {
|
||||
public void playProxy(String serverId, int id, ErrorCallback<StreamInfo> callback) {
|
||||
RedisRpcRequest request = buildRequest("streamProxy/play", id);
|
||||
request.setToId(serverId);
|
||||
RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout(), TimeUnit.SECONDS);
|
||||
if (response != null && response.getStatusCode() == ErrorCode.SUCCESS.getCode()) {
|
||||
return JSON.parseObject(response.getBody().toString(), StreamInfo.class);
|
||||
if (response == null) {
|
||||
callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null);
|
||||
}else {
|
||||
if (response.getStatusCode() == ErrorCode.SUCCESS.getCode()) {
|
||||
StreamInfo streamInfo = JSON.parseObject(response.getBody().toString(), StreamInfo.class);
|
||||
callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
|
||||
}else {
|
||||
callback.run(response.getStatusCode(), response.getBody().toString(), null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@@ -406,7 +407,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WVPResult<Object> queryPreset(String serverId, Device device, String channelId) {
|
||||
public WVPResult<List<Preset>> queryPreset(String serverId, Device device, String channelId) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("device", device.getDeviceId());
|
||||
jsonObject.put("channelId", channelId);
|
||||
|
||||
Reference in New Issue
Block a user