Commit 468e2b2ffbbb4e15dea11d1f9c7451a8097a3ab8
1 parent
ff1e9f79
fix(play): 修复作为上级平台点播截取快照问题
Showing
1 changed file
with
24 additions
and
12 deletions
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -271,18 +271,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -271,18 +271,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 271 | streamInfo); | 271 | streamInfo); |
| 272 | logger.info("[点播成功] deviceId: {}, channelId:{}, 码流类型:{}", device.getDeviceId(), | 272 | logger.info("[点播成功] deviceId: {}, channelId:{}, 码流类型:{}", device.getDeviceId(), |
| 273 | device.isSwitchPrimarySubStream() ? "辅码流" : "主码流"); | 273 | device.isSwitchPrimarySubStream() ? "辅码流" : "主码流"); |
| 274 | - String streamUrl; | ||
| 275 | - if (mediaServerItemInuse.getRtspPort() != 0) { | ||
| 276 | - streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServerItemInuse.getRtspPort(), "rtp", ssrcInfo.getStream()); | ||
| 277 | - }else { | ||
| 278 | - streamUrl = String.format("http://127.0.0.1:%s/%s/%s.live.mp4", mediaServerItemInuse.getHttpPort(), "rtp", ssrcInfo.getStream()); | ||
| 279 | - } | ||
| 280 | - String path = "snap"; | ||
| 281 | - String fileName = device.getDeviceId() + "_" + channelId + ".jpg"; | ||
| 282 | - // 请求截图 | ||
| 283 | - logger.info("[请求截图]: " + fileName); | ||
| 284 | - zlmresTfulUtils.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); | ||
| 285 | - | 274 | + snapOnPlay(mediaServerItemInuse, device.getDeviceId(), channelId, ssrcInfo.getStream()); |
| 286 | }, (event) -> { | 275 | }, (event) -> { |
| 287 | inviteInfo.setStatus(InviteSessionStatus.ok); | 276 | inviteInfo.setStatus(InviteSessionStatus.ok); |
| 288 | 277 | ||
| @@ -365,6 +354,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -365,6 +354,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 365 | InviteErrorCode.SUCCESS.getCode(), | 354 | InviteErrorCode.SUCCESS.getCode(), |
| 366 | InviteErrorCode.SUCCESS.getMsg(), | 355 | InviteErrorCode.SUCCESS.getMsg(), |
| 367 | streamInfo); | 356 | streamInfo); |
| 357 | + snapOnPlay(mediaServerItemInUse, device.getDeviceId(), channelId, stream); | ||
| 368 | }); | 358 | }); |
| 369 | return; | 359 | return; |
| 370 | } | 360 | } |
| @@ -440,6 +430,28 @@ public class PlayServiceImpl implements IPlayService { | @@ -440,6 +430,28 @@ public class PlayServiceImpl implements IPlayService { | ||
| 440 | } | 430 | } |
| 441 | } | 431 | } |
| 442 | 432 | ||
| 433 | + /** | ||
| 434 | + * 点播成功时调用截图. | ||
| 435 | + * | ||
| 436 | + * @param mediaServerItemInuse media | ||
| 437 | + * @param deviceId 设备 ID | ||
| 438 | + * @param channelId 通道 ID | ||
| 439 | + * @param stream ssrc | ||
| 440 | + */ | ||
| 441 | + private void snapOnPlay(MediaServerItem mediaServerItemInuse, String deviceId, String channelId, String stream) { | ||
| 442 | + String streamUrl; | ||
| 443 | + if (mediaServerItemInuse.getRtspPort() != 0) { | ||
| 444 | + streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServerItemInuse.getRtspPort(), "rtp", stream); | ||
| 445 | + } else { | ||
| 446 | + streamUrl = String.format("http://127.0.0.1:%s/%s/%s.live.mp4", mediaServerItemInuse.getHttpPort(), "rtp", stream); | ||
| 447 | + } | ||
| 448 | + String path = "snap"; | ||
| 449 | + String fileName = deviceId + "_" + channelId + ".jpg"; | ||
| 450 | + // 请求截图 | ||
| 451 | + logger.info("[请求截图]: " + fileName); | ||
| 452 | + zlmresTfulUtils.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); | ||
| 453 | + } | ||
| 454 | + | ||
| 443 | private StreamInfo onPublishHandlerForPlay(MediaServerItem mediaServerItem, HookParam hookParam, String deviceId, String channelId) { | 455 | private StreamInfo onPublishHandlerForPlay(MediaServerItem mediaServerItem, HookParam hookParam, String deviceId, String channelId) { |
| 444 | StreamInfo streamInfo = null; | 456 | StreamInfo streamInfo = null; |
| 445 | Device device = redisCatchStorage.getDevice(deviceId); | 457 | Device device = redisCatchStorage.getDevice(deviceId); |