From 2b1645729ba25cbaa39dd2f2de19b461fb270e16 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 29 May 2024 18:36:19 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E5=88=87=E6=8D=A2=E7=A0=81=E6=B5=81?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jt1078/controller/JT1078Controller.java | 43 +++++++++---------- .../vmp/jt1078/service/Ijt1078Service.java | 2 + .../service/impl/jt1078ServiceImpl.java | 20 ++++++++- 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java index 7556d713a..9df604958 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java @@ -64,24 +64,20 @@ public class JT1078Controller { @GetMapping("/live/start") public DeferredResult> startLive(HttpServletRequest request, @Parameter(required = true) String deviceId, - @Parameter(required = false) String channelId, + @Parameter(required = true) String channelId, @Parameter(required = false) Integer type) { if (type == null || (type != 0 && type != 1 && type != 3)) { type = 0; } DeferredResult> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); - if (ObjectUtils.isEmpty(channelId)) { - channelId = "1"; - } - String finalChannelId = channelId; result.onTimeout(()->{ - logger.info("[1078-点播等待超时] deviceId:{}, channelId:{}, ", deviceId, finalChannelId); + logger.info("[1078-点播等待超时] deviceId:{}, channelId:{}, ", deviceId, channelId); // 释放rtpserver WVPResult wvpResult = new WVPResult<>(); wvpResult.setCode(ErrorCode.ERROR100.getCode()); wvpResult.setMsg("超时"); result.setResult(wvpResult); - service.stopPlay(deviceId, finalChannelId); + service.stopPlay(deviceId, channelId); }); service.play(deviceId, channelId, type, (code, msg, streamInfo) -> { @@ -123,10 +119,7 @@ public class JT1078Controller { @GetMapping("/live/stop") public void stopLive(HttpServletRequest request, @Parameter(required = true) String deviceId, - @Parameter(required = false) String channelId) { - if (ObjectUtils.isEmpty(channelId)) { - channelId = "1"; - } + @Parameter(required = true) String channelId) { service.stopPlay(deviceId, channelId); } @@ -199,10 +192,7 @@ public class JT1078Controller { @GetMapping("/talk/stop") public void stopTalk(HttpServletRequest request, @Parameter(required = true) String deviceId, - @Parameter(required = false) String channelId) { - if (ObjectUtils.isEmpty(channelId)) { - channelId = "1"; - } + @Parameter(required = true) String channelId) { service.stopTalk(deviceId, channelId); } @@ -213,10 +203,7 @@ public class JT1078Controller { @GetMapping("/live/pause") public void pauseLive(HttpServletRequest request, @Parameter(required = true) String deviceId, - @Parameter(required = false) String channelId) { - if (ObjectUtils.isEmpty(channelId)) { - channelId = "1"; - } + @Parameter(required = true) String channelId) { service.pausePlay(deviceId, channelId); } @@ -226,13 +213,23 @@ public class JT1078Controller { @GetMapping("/live/continue") public void continueLive(HttpServletRequest request, @Parameter(required = true) String deviceId, - @Parameter(required = false) String channelId) { - if (ObjectUtils.isEmpty(channelId)) { - channelId = "1"; - } + @Parameter(required = true) String channelId) { + service.continueLivePlay(deviceId, channelId); } + @Operation(summary = "1078-切换码流类型", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true) + @Parameter(name = "streamType", description = "0:主码流; 1:子码流", required = true) + @GetMapping("/live/continue") + public void changeStreamType(HttpServletRequest request, + @Parameter(required = true) String deviceId, + @Parameter(required = true) String channelId, + @Parameter(required = true) Integer streamType) { + service.changeStreamType(deviceId, channelId, streamType); + } + @Operation(summary = "1078-录像-查询资源列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true) diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java b/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java index f39b7f730..0233bc597 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java @@ -110,4 +110,6 @@ public interface Ijt1078Service { void startTalk(String deviceId, String channelId, String app, String stream, String mediaServerId, Boolean onlySend, GeneralCallback callback); void stopTalk(String deviceId, String channelId); + + void changeStreamType(String deviceId, String channelId, Integer streamType); } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java index 8b83efdad..ef1414b17 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java @@ -895,7 +895,7 @@ public class jt1078ServiceImpl implements Ijt1078Service { // 发送停止命令 J9102 j9102 = new J9102(); j9102.setChannel(Integer.valueOf(channelId)); - j9102.setCommand(0); + j9102.setCommand(4); j9102.setCloseType(0); j9102.setStreamType(1); jt1078Template.stopLive(deviceId, j9102, 6); @@ -914,4 +914,22 @@ public class jt1078ServiceImpl implements Ijt1078Service { } } } + + @Override + public void changeStreamType(String deviceId, String channelId, Integer streamType) { + String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAY + deviceId + ":" + channelId; + dynamicTask.stop(playKey); + StreamInfo streamInfo = (StreamInfo) redisTemplate.opsForValue().get(playKey); + if (streamInfo == null) { + logger.info("[1078-切换码流类型] 未找到点播信息 deviceId: {}, channelId: {}, streamType: {}", deviceId, channelId, streamType); + } + logger.info("[1078-切换码流类型] deviceId: {}, channelId: {}, streamType: {}", deviceId, channelId, streamType); + // 发送暂停命令 + J9102 j9102 = new J9102(); + j9102.setChannel(Integer.valueOf(channelId)); + j9102.setCommand(1); + j9102.setCloseType(0); + j9102.setStreamType(streamType); + jt1078Template.stopLive(deviceId, j9102, 6); + } }