diff --git a/src/main/java/com/genersoft/iot/vmp/media/abl/ABLMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/abl/ABLMediaNodeServerService.java index 06ebd2dc..3ba5e639 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/abl/ABLMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/abl/ABLMediaNodeServerService.java @@ -181,8 +181,8 @@ public class ABLMediaNodeServerService implements IMediaNodeServerService { } @Override - public void getSnap(MediaServer mediaServerItem, String streamUrl, int timeoutSec, int expireSec, String path, String fileName) { - logger.warn("[abl-getSnap] 未实现"); + public void getSnap(MediaServer mediaServerItem, String app, String stream, int timeoutSec, int expireSec, String path, String fileName) { + ablresTfulUtils.getSnap(mediaServerItem, app, stream, timeoutSec, path, fileName); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/media/abl/ABLRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/abl/ABLRESTfulUtils.java index d1301025..50ac3c3a 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/abl/ABLRESTfulUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/media/abl/ABLRESTfulUtils.java @@ -250,7 +250,6 @@ public class ABLRESTfulUtils { if (!snapFolder.mkdirs()) { logger.warn("{}路径创建失败", snapFolder.getAbsolutePath()); } - } File snapFile = new File(targetPath + File.separator + fileName); FileOutputStream outStream = new FileOutputStream(snapFile); @@ -330,4 +329,13 @@ public class ABLRESTfulUtils { param.put("stream", stream); return sendPost(mediaServer,"getMediaList", param, null); } + public void getSnap(MediaServer mediaServer, String app, String stream, int timeoutSec, String path, String fileName) { + Map param = new HashMap<>(); + param.put("app", app); + param.put("stream", stream); + param.put("timeout_sec", timeoutSec); + param.put("vhost", "_defaultVhost_"); + sendGetForImg(mediaServer,"getSnap", param, path, fileName); + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/media/service/IMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/service/IMediaNodeServerService.java index 87399382..50d80973 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/service/IMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/service/IMediaNodeServerService.java @@ -35,7 +35,7 @@ public interface IMediaNodeServerService { Boolean connectRtpServer(MediaServer mediaServer, String address, int port, String stream); - void getSnap(MediaServer mediaServer, String streamUrl, int timeoutSec, int expireSec, String path, String fileName); + void getSnap(MediaServer mediaServer, String app, String stream, int timeoutSec, int expireSec, String path, String fileName); MediaInfo getMediaInfo(MediaServer mediaServer, String app, String stream); diff --git a/src/main/java/com/genersoft/iot/vmp/media/service/IMediaServerService.java b/src/main/java/com/genersoft/iot/vmp/media/service/IMediaServerService.java index fb56ab6f..eea19f0e 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/service/IMediaServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/service/IMediaServerService.java @@ -82,7 +82,7 @@ public interface IMediaServerService { Boolean connectRtpServer(MediaServer mediaServerItem, String address, int port, String stream); - void getSnap(MediaServer mediaServerItemInuse, String streamUrl, int timeoutSec, int expireSec, String path, String fileName); + void getSnap(MediaServer mediaServerItemInuse, String app, String stream, int timeoutSec, int expireSec, String path, String fileName); MediaInfo getMediaInfo(MediaServer mediaServerItem, String app, String stream); diff --git a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java index fab8a3de..92925e43 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java @@ -610,13 +610,13 @@ public class MediaServerServiceImpl implements IMediaServerService { } @Override - public void getSnap(MediaServer mediaServer, String streamUrl, int timeoutSec, int expireSec, String path, String fileName) { + public void getSnap(MediaServer mediaServer, String app, String stream, int timeoutSec, int expireSec, String path, String fileName) { IMediaNodeServerService mediaNodeServerService = nodeServerServiceMap.get(mediaServer.getType()); if (mediaNodeServerService == null) { logger.info("[getSnap] 失败, mediaServer的类型: {},未找到对应的实现类", mediaServer.getType()); return; } - mediaNodeServerService.getSnap(mediaServer, streamUrl, timeoutSec, expireSec, path, fileName); + mediaNodeServerService.getSnap(mediaServer, app, stream, timeoutSec, expireSec, path, fileName); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java index 707ea01c..c1bf2753 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java @@ -200,7 +200,13 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService { } @Override - public void getSnap(MediaServer mediaServer, String streamUrl, int timeoutSec, int expireSec, String path, String fileName) { + public void getSnap(MediaServer mediaServer, String app, String stream, int timeoutSec, int expireSec, String path, String fileName) { + String streamUrl; + if (mediaServer.getRtspPort() != 0) { + streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServer.getRtspPort(), app, stream); + }else { + streamUrl = String.format("http://127.0.0.1:%s/%s/%s.live.mp4", mediaServer.getHttpPort(), app, stream); + } zlmresTfulUtils.getSnap(mediaServer, streamUrl, timeoutSec, expireSec, path, fileName); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 7406483d..a6a9b775 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.service.impl; -import com.alibaba.fastjson2.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.*; import com.genersoft.iot.vmp.conf.DynamicTask; @@ -17,18 +16,20 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.media.bean.MediaInfo; +import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.bean.RecordInfo; 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.event.media.MediaArrivalEvent; import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent; import com.genersoft.iot.vmp.media.event.media.MediaNotFoundEvent; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; -import com.genersoft.iot.vmp.media.bean.MediaServer; -import com.genersoft.iot.vmp.service.*; +import com.genersoft.iot.vmp.service.IDeviceChannelService; +import com.genersoft.iot.vmp.service.IDeviceService; +import com.genersoft.iot.vmp.service.IInviteStreamService; +import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.bean.*; import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; @@ -57,7 +58,10 @@ import java.io.File; import java.math.BigDecimal; import java.math.RoundingMode; import java.text.ParseException; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.Vector; @SuppressWarnings(value = {"rawtypes", "unchecked"}) @Service @@ -662,17 +666,11 @@ public class PlayServiceImpl implements IPlayService { * @param stream ssrc */ private void snapOnPlay(MediaServer mediaServerItemInuse, String deviceId, String channelId, String stream) { - String streamUrl; - if (mediaServerItemInuse.getRtspPort() != 0) { - streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServerItemInuse.getRtspPort(), "rtp", stream); - } else { - streamUrl = String.format("http://127.0.0.1:%s/%s/%s.live.mp4", mediaServerItemInuse.getHttpPort(), "rtp", stream); - } String path = "snap"; String fileName = deviceId + "_" + channelId + ".jpg"; // 请求截图 logger.info("[请求截图]: " + fileName); - mediaServerService.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); + mediaServerService.getSnap(mediaServerItemInuse, "rtp", stream,15, 1, path, fileName); } public StreamInfo onPublishHandlerForPlay(MediaServer mediaServerItem, MediaInfo mediaInfo, String deviceId, String channelId) { @@ -1581,16 +1579,10 @@ public class PlayServiceImpl implements IPlayService { if (inviteInfo.getStreamInfo() != null) { // 已存在线直接截图 MediaServer mediaServerItemInuse = mediaServerService.getOne(inviteInfo.getStreamInfo().getMediaServerId()); - String streamUrl; - if (mediaServerItemInuse.getRtspPort() != 0) { - streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServerItemInuse.getRtspPort(), "rtp", inviteInfo.getStreamInfo().getStream()); - }else { - streamUrl = String.format("http://127.0.0.1:%s/%s/%s.live.mp4", mediaServerItemInuse.getHttpPort(), "rtp", inviteInfo.getStreamInfo().getStream()); - } String path = "snap"; // 请求截图 logger.info("[请求截图]: " + fileName); - mediaServerService.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); + mediaServerService.getSnap(mediaServerItemInuse, "rtp", inviteInfo.getStreamInfo().getStream(), 15, 1, path, fileName); File snapFile = new File(path + File.separator + fileName); if (snapFile.exists()) { errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), snapFile.getAbsoluteFile());