支持录像回放使用固定流地址以及自动点播录像回放
This commit is contained in:
parent
aad7228578
commit
2b5738cc3e
2
sql/2.6.9更新.sql
Normal file
2
sql/2.6.9更新.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
alter table wvp_device_channel
|
||||||
|
change stream_id stream_id varying(255)
|
@ -79,7 +79,7 @@ create table wvp_device_channel (
|
|||||||
custom_longitude double precision,
|
custom_longitude double precision,
|
||||||
latitude double precision,
|
latitude double precision,
|
||||||
custom_latitude double precision,
|
custom_latitude double precision,
|
||||||
stream_id character varying(50),
|
stream_id character varying(255),
|
||||||
device_id character varying(50) not null,
|
device_id character varying(50) not null,
|
||||||
parental character varying(50),
|
parental character varying(50),
|
||||||
has_audio bool default false,
|
has_audio bool default false,
|
||||||
|
@ -59,6 +59,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
|||||||
// 未注册的设备不做处理
|
// 未注册的设备不做处理
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
logger.info("[收到心跳], device: {}", device.getDeviceId());
|
||||||
SIPRequest request = (SIPRequest) evt.getRequest();
|
SIPRequest request = (SIPRequest) evt.getRequest();
|
||||||
// 回复200 OK
|
// 回复200 OK
|
||||||
try {
|
try {
|
||||||
|
@ -24,8 +24,10 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
|||||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
|
import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
|
||||||
import com.genersoft.iot.vmp.service.*;
|
import com.genersoft.iot.vmp.service.*;
|
||||||
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
||||||
|
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||||
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo;
|
import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
|
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
|
||||||
@ -559,7 +561,7 @@ public class ZLMHttpHookListener {
|
|||||||
|
|
||||||
if ("rtp".equals(param.getApp())) {
|
if ("rtp".equals(param.getApp())) {
|
||||||
String[] s = param.getStream().split("_");
|
String[] s = param.getStream().split("_");
|
||||||
if (!mediaInfo.isRtpEnable() || s.length != 2) {
|
if (!mediaInfo.isRtpEnable() || (s.length != 2 && s.length != 4)) {
|
||||||
defaultResult.setResult(HookResult.SUCCESS());
|
defaultResult.setResult(HookResult.SUCCESS());
|
||||||
return defaultResult;
|
return defaultResult;
|
||||||
}
|
}
|
||||||
@ -575,33 +577,79 @@ public class ZLMHttpHookListener {
|
|||||||
defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg()));
|
defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg()));
|
||||||
return defaultResult;
|
return defaultResult;
|
||||||
}
|
}
|
||||||
logger.info("[ZLM HOOK] 流未找到, 发起自动点播:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
if (s.length == 2) {
|
||||||
|
logger.info("[ZLM HOOK] 预览流未找到, 发起自动点播:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
||||||
|
|
||||||
RequestMessage msg = new RequestMessage();
|
RequestMessage msg = new RequestMessage();
|
||||||
String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
|
String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
|
||||||
boolean exist = resultHolder.exist(key, null);
|
boolean exist = resultHolder.exist(key, null);
|
||||||
msg.setKey(key);
|
msg.setKey(key);
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
msg.setId(uuid);
|
msg.setId(uuid);
|
||||||
DeferredResult<HookResult> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
DeferredResult<HookResult> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
||||||
|
|
||||||
result.onTimeout(() -> {
|
result.onTimeout(() -> {
|
||||||
logger.info("[ZLM HOOK] 自动点播, 等待超时");
|
logger.info("[ZLM HOOK] 预览流自动点播, 等待超时");
|
||||||
// 释放rtpserver
|
// 释放rtpserver
|
||||||
msg.setData(new HookResult(ErrorCode.ERROR100.getCode(), "点播超时"));
|
msg.setData(new HookResult(ErrorCode.ERROR100.getCode(), "点播超时"));
|
||||||
resultHolder.invokeResult(msg);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 录像查询以channelId作为deviceId查询
|
|
||||||
resultHolder.put(key, uuid, result);
|
|
||||||
|
|
||||||
if (!exist) {
|
|
||||||
playService.play(mediaInfo, deviceId, channelId, null, (code, message, data) -> {
|
|
||||||
msg.setData(new HookResult(code, message));
|
|
||||||
resultHolder.invokeResult(msg);
|
resultHolder.invokeResult(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
resultHolder.put(key, uuid, result);
|
||||||
|
|
||||||
|
if (!exist) {
|
||||||
|
playService.play(mediaInfo, deviceId, channelId, null, (code, message, data) -> {
|
||||||
|
msg.setData(new HookResult(code, message));
|
||||||
|
resultHolder.invokeResult(msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}else if(s.length == 4){
|
||||||
|
// 此时为录像回放, 录像回放格式为> 设备ID_通道ID_开始时间_结束时间
|
||||||
|
String startTimeStr = s[2];
|
||||||
|
String endTimeStr = s[3];
|
||||||
|
if (startTimeStr == null || endTimeStr == null || startTimeStr.length() != 14 || endTimeStr.length() != 14) {
|
||||||
|
defaultResult.setResult(HookResult.SUCCESS());
|
||||||
|
return defaultResult;
|
||||||
|
}
|
||||||
|
String startTime = DateUtil.urlToyyyy_MM_dd_HH_mm_ss(startTimeStr);
|
||||||
|
String endTime = DateUtil.urlToyyyy_MM_dd_HH_mm_ss(endTimeStr);
|
||||||
|
logger.info("[ZLM HOOK] 回放流未找到, 发起自动点播:{}->{}->{}/{}-{}-{}",
|
||||||
|
param.getMediaServerId(), param.getSchema(),
|
||||||
|
param.getApp(), param.getStream(),
|
||||||
|
startTime, endTime
|
||||||
|
);
|
||||||
|
RequestMessage msg = new RequestMessage();
|
||||||
|
String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId;
|
||||||
|
boolean exist = resultHolder.exist(key, null);
|
||||||
|
msg.setKey(key);
|
||||||
|
String uuid = UUID.randomUUID().toString();
|
||||||
|
msg.setId(uuid);
|
||||||
|
DeferredResult<HookResult> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
||||||
|
|
||||||
|
result.onTimeout(() -> {
|
||||||
|
logger.info("[ZLM HOOK] 回放流自动点播, 等待超时");
|
||||||
|
// 释放rtpserver
|
||||||
|
msg.setData(new HookResult(ErrorCode.ERROR100.getCode(), "点播超时"));
|
||||||
|
resultHolder.invokeResult(msg);
|
||||||
|
});
|
||||||
|
|
||||||
|
resultHolder.put(key, uuid, result);
|
||||||
|
|
||||||
|
if (!exist) {
|
||||||
|
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaInfo, param.getStream(), null,
|
||||||
|
device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam());
|
||||||
|
playService.playBack(mediaInfo, ssrcInfo, deviceId, channelId, startTime, endTime, (code, message, data) -> {
|
||||||
|
msg.setData(new HookResult(code, message));
|
||||||
|
resultHolder.invokeResult(msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}else {
|
||||||
|
defaultResult.setResult(HookResult.SUCCESS());
|
||||||
|
return defaultResult;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
} else {
|
} else {
|
||||||
// 拉流代理
|
// 拉流代理
|
||||||
StreamProxyItem streamProxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream());
|
StreamProxyItem streamProxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream());
|
||||||
|
@ -29,7 +29,6 @@ public interface IPlayService {
|
|||||||
|
|
||||||
void playBack(String deviceId, String channelId, String startTime, String endTime, ErrorCallback<Object> callback);
|
void playBack(String deviceId, String channelId, String startTime, String endTime, ErrorCallback<Object> callback);
|
||||||
void playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, ErrorCallback<Object> callback);
|
void playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, ErrorCallback<Object> callback);
|
||||||
|
|
||||||
void zlmServerOffline(String mediaServerId);
|
void zlmServerOffline(String mediaServerId);
|
||||||
|
|
||||||
void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback<Object> callback);
|
void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback<Object> callback);
|
||||||
@ -44,4 +43,6 @@ public interface IPlayService {
|
|||||||
void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException;
|
void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException;
|
||||||
|
|
||||||
void getSnap(String deviceId, String channelId, String fileName, ErrorCallback errorCallback);
|
void getSnap(String deviceId, String channelId, String fileName, ErrorCallback errorCallback);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,19 @@ public class PlayServiceImpl implements IPlayService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MediaServerItem newMediaServerItem = getNewMediaServerItem(device);
|
MediaServerItem newMediaServerItem = getNewMediaServerItem(device);
|
||||||
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam());
|
String stream = null;
|
||||||
|
if (newMediaServerItem.isRtpEnable()) {
|
||||||
|
String startTimeStr = startTime.replace("-", "")
|
||||||
|
.replace(":", "")
|
||||||
|
.replace(" ", "");
|
||||||
|
System.out.println(startTimeStr);
|
||||||
|
String endTimeTimeStr = endTime.replace("-", "")
|
||||||
|
.replace(":", "")
|
||||||
|
.replace(" ", "");
|
||||||
|
System.out.println(endTimeTimeStr);
|
||||||
|
stream = deviceId + "_" + channelId + "_" + startTimeStr + "_" + endTimeTimeStr;
|
||||||
|
}
|
||||||
|
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, stream, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam());
|
||||||
playBack(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, callback);
|
playBack(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,10 @@ public class DateUtil {
|
|||||||
return formatter.format(formatterCompatibleISO8601.parse(formatTime));
|
return formatter.format(formatterCompatibleISO8601.parse(formatTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String urlToyyyy_MM_dd_HH_mm_ss(String formatTime) {
|
||||||
|
return formatter.format(urlFormatter.parse(formatTime));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* yyyy_MM_dd_HH_mm_ss 转时间戳
|
* yyyy_MM_dd_HH_mm_ss 转时间戳
|
||||||
* @param formatTime
|
* @param formatTime
|
||||||
@ -82,6 +86,7 @@ public class DateUtil {
|
|||||||
return urlFormatter.format(nowDateTime);
|
return urlFormatter.format(nowDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式校验
|
* 格式校验
|
||||||
* @param timeStr 时间字符串
|
* @param timeStr 时间字符串
|
||||||
|
Loading…
Reference in New Issue
Block a user