临时提交

dev/abl支持
648540858 2024-05-28 15:55:26 +08:00
parent 5011a6b74a
commit 2c0c576d93
4 changed files with 33 additions and 25 deletions

View File

@ -12,10 +12,7 @@ import com.genersoft.iot.vmp.media.abl.event.HookAblServerKeepaliveEvent;
import com.genersoft.iot.vmp.media.abl.event.HookAblServerStartEvent; import com.genersoft.iot.vmp.media.abl.event.HookAblServerStartEvent;
import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.bean.ResultForOnPublish; import com.genersoft.iot.vmp.media.bean.ResultForOnPublish;
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent; import com.genersoft.iot.vmp.media.event.media.*;
import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
import com.genersoft.iot.vmp.media.event.media.MediaNotFoundEvent;
import com.genersoft.iot.vmp.media.event.media.MediaRtpServerTimeoutEvent;
import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.media.zlm.dto.hook.HookResult; import com.genersoft.iot.vmp.media.zlm.dto.hook.HookResult;
import com.genersoft.iot.vmp.media.zlm.dto.hook.HookResultForOnPublish; import com.genersoft.iot.vmp.media.zlm.dto.hook.HookResultForOnPublish;
@ -177,17 +174,16 @@ public class ABLHttpHookListener {
logger.info("[ABL HOOK] 录像进度通知:{}->{}/{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream(), param.getCurrentFileDuration(), param.getTotalVideoDuration()); logger.info("[ABL HOOK] 录像进度通知:{}->{}/{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream(), param.getCurrentFileDuration(), param.getTotalVideoDuration());
// TODO 这里用来做录像进度 try {
// MediaServer mediaServer = mediaServerService.getOne(param.getMediaServerId()); MediaServer mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
// if (mediaServer == null) { if (mediaServerItem != null) {
// return new HookResultForOnPublish(0, "success"); MediaRecordMp4Event event = MediaRecordMp4Event.getInstance(this, param, mediaServerItem);
// } event.setMediaServer(mediaServerItem);
// applicationEventPublisher.publishEvent(event);
// ResultForOnPublish resultForOnPublish = mediaService.authenticatePublish(mediaServer, param.getApp(), param.getStream(), param.getParams()); }
// if (resultForOnPublish == null) { }catch (Exception e) {
// logger.info("[ABL HOOK]推流鉴权 拒绝 响应:{}->{}", param.getMediaServerId(), param); logger.info("[ZLM-HOOK-rtpServer收流超时] 发送通知失败 ", e);
// ablresTfulUtils.closeStreams(mediaServer, param.getApp(), param.getStream()); }
// }
return HookResult.SUCCESS(); return HookResult.SUCCESS();
} }
@ -273,9 +269,8 @@ public class ABLHttpHookListener {
@ResponseBody @ResponseBody
@PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8") @PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8")
public HookResult onStreamNotFound(@RequestBody ABLHookParam param) { public HookResult onStreamNotFound(@RequestBody ABLHookParam param) {
logger.info("[ABL HOOK] 流未找到:{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream()); logger.info("[ABL HOOK] 流未找到:{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream());
MediaServer mediaServer = mediaServerService.getOne(param.getMediaServerId()); MediaServer mediaServer = mediaServerService.getOne(param.getMediaServerId());
if (!userSetting.isAutoApplyPlay() || mediaServer == null) { if (!userSetting.isAutoApplyPlay() || mediaServer == null) {
return HookResult.SUCCESS(); return HookResult.SUCCESS();
@ -341,7 +336,6 @@ public class ABLHttpHookListener {
@PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8") @PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8")
public HookResult onRecordMp4(HttpServletRequest request, @RequestBody OnRecordMp4ABLHookParam param) { public HookResult onRecordMp4(HttpServletRequest request, @RequestBody OnRecordMp4ABLHookParam param) {
logger.info("[ABL HOOK] 录像完成事件:{}->{}", param.getMediaServerId(), param.getFileName()); logger.info("[ABL HOOK] 录像完成事件:{}->{}", param.getMediaServerId(), param.getFileName());
// try { // try {
// MediaServer mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); // MediaServer mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
// if (mediaServerItem != null) { // if (mediaServerItem != null) {

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.CommonCallback; import com.genersoft.iot.vmp.common.CommonCallback;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.media.abl.bean.AblServerConfig; import com.genersoft.iot.vmp.media.abl.bean.AblServerConfig;
import com.genersoft.iot.vmp.media.abl.bean.hook.OnStreamArriveABLHookParam; import com.genersoft.iot.vmp.media.abl.bean.hook.OnStreamArriveABLHookParam;
@ -34,9 +35,18 @@ public class ABLMediaNodeServerService implements IMediaNodeServerService {
@Autowired @Autowired
private SipConfig sipConfig; private SipConfig sipConfig;
@Autowired
private UserSetting userSetting;
@Override
public boolean initStopSendRtp(MediaServer mediaInfo, String app, String stream, String ssrc) {
return false;
}
@Override @Override
public int createRTPServer(MediaServer mediaServer, String stream, long ssrc, Integer port, Boolean onlyAuto, Boolean disableAudio, Boolean reUsePort, Integer tcpMode) { public int createRTPServer(MediaServer mediaServer, String stream, long ssrc, Integer port, Boolean onlyAuto, Boolean disableAudio, Boolean reUsePort, Integer tcpMode) {
return ablresTfulUtils.openRtpServer(mediaServer, "rtp", stream, 96, port, tcpMode, disableAudio?1:0); Boolean recordSip = userSetting.getRecordSip();
return ablresTfulUtils.openRtpServer(mediaServer, "rtp", stream, 96, port, tcpMode, disableAudio?1:0, recordSip);
} }
@Override @Override

View File

@ -316,7 +316,7 @@ public class ABLRESTfulUtils {
} }
public Integer openRtpServer(MediaServer mediaServer, String app, String stream, int payload, Integer port, Integer tcpMode, Integer disableAudio) { public Integer openRtpServer(MediaServer mediaServer, String app, String stream, int payload, Integer port, Integer tcpMode, Integer disableAudio, Boolean record) {
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("vhost", "_defaultVhost_"); param.put("vhost", "_defaultVhost_");
param.put("app", app); param.put("app", app);
@ -331,6 +331,9 @@ public class ABLRESTfulUtils {
if (disableAudio != null) { if (disableAudio != null) {
param.put("disableAudio", disableAudio); param.put("disableAudio", disableAudio);
} }
if (record != null && record) {
param.put("enable_mp4", 1);
}
JSONObject jsonObject = sendPost(mediaServer, "openRtpServer", param, null); JSONObject jsonObject = sendPost(mediaServer, "openRtpServer", param, null);
if (jsonObject.getInteger("code") == 0) { if (jsonObject.getInteger("code") == 0) {

View File

@ -30,10 +30,10 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.service.IInviteStreamService;
import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
import com.genersoft.iot.vmp.service.bean.*; 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.CloudRecordUtils; import com.genersoft.iot.vmp.utils.CloudRecordUtils;
@ -1084,12 +1084,13 @@ public class PlayServiceImpl implements IPlayService {
return null; return null;
} }
String app = "rtp"; String app = "rtp";
MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServerItem, app, stream); MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServerItem, app, stream);
if (mediaInfo == null) { if (mediaInfo == null) {
logger.warn("[获取下载进度] 查询进度失败, 节点Id {} {}/{}", mediaServerId, app, stream); logger.warn("[获取下载进度] 查询进度失败, 节点Id {} {}/{}", mediaServerId, app, stream);
return null; return null;
} }
if (mediaInfo.getDuration() == 0) { if (mediaInfo.getDuration() == null || mediaInfo.getDuration() == 0) {
inviteInfo.getStreamInfo().setProgress(0); inviteInfo.getStreamInfo().setProgress(0);
} else { } else {
String startTime = inviteInfo.getStreamInfo().getStartTime(); String startTime = inviteInfo.getStreamInfo().getStartTime();