From 08c45876df5121b5b750798bae3e658f0ec575c6 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 24 Nov 2021 15:10:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=80=8D=E9=80=9F=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/transmit/cmd/ISIPCommander.java | 2 +- .../iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 4 ++-- .../vmanager/gb28181/playback/PlaybackController.java | 9 +++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 6238b70c..2da00105 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -140,7 +140,7 @@ public interface ISIPCommander { /** * 回放倍速播放 */ - void playSpeedCmd(Device device, StreamInfo streamInfo, String speed); + void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed); /** * 语音广播 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index d90705c3..c229decc 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -1630,12 +1630,12 @@ public class SIPCommander implements ISIPCommander { * 回放倍速播放 */ @Override - public void playSpeedCmd(Device device, StreamInfo streamInfo, String speed) { + public void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) { try { StringBuffer content = new StringBuffer(200); content.append("PLAY RTSP/1.0\r\n"); content.append("CSeq: " + InfoCseqCache.CSEQCACHE.get(streamInfo.getStreamId()) + "\r\n"); - content.append("Scale: " + speed + ".000000\r\n"); + content.append("Scale: " + String.format("%.1f",speed) + "\r\n"); Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString()); logger.info(request.toString()); ClientTransaction clientTransaction = null; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java index 90ecfd42..a0290732 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java @@ -221,10 +221,10 @@ public class PlaybackController { @ApiOperation("回放倍速播放") @ApiImplicitParams({ @ApiImplicitParam(name = "streamId", value = "回放流ID", dataTypeClass = String.class), - @ApiImplicitParam(name = "speed", value = "倍速 1、2、4", dataTypeClass = String.class), + @ApiImplicitParam(name = "speed", value = "倍速0.25 0.5 1、2、4", dataTypeClass = Double.class), }) @GetMapping("/speed/{streamId}/{speed}") - public ResponseEntity playSpeed(@PathVariable String streamId, @PathVariable String speed) { + public ResponseEntity playSpeed(@PathVariable String streamId, @PathVariable Double speed) { logger.info("playSpeed: "+streamId+", "+speed); JSONObject json = new JSONObject(); StreamInfo streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId); @@ -233,6 +233,11 @@ public class PlaybackController { logger.warn("streamId不存在!"); return new ResponseEntity(json.toString(), HttpStatus.BAD_REQUEST); } + if(speed != 0.25 && speed != 0.5 && speed != 1 && speed != 2.0 && speed != 4.0) { + json.put("msg", "不支持的speed(0.25 0.5 1、2、4)"); + logger.warn("不支持的speed: " + speed); + return new ResponseEntity(json.toString(), HttpStatus.BAD_REQUEST); + } setCseq(streamId); Device device = storager.queryVideoDevice(streamInfo.getDeviceID()); cmder.playSpeedCmd(device, streamInfo, speed);