Commit 08c45876df5121b5b750798bae3e658f0ec575c6
1 parent
20082441
优化倍速播放参数
Showing
3 changed files
with
10 additions
and
5 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
| @@ -140,7 +140,7 @@ public interface ISIPCommander { | @@ -140,7 +140,7 @@ public interface ISIPCommander { | ||
| 140 | /** | 140 | /** |
| 141 | * 回放倍速播放 | 141 | * 回放倍速播放 |
| 142 | */ | 142 | */ |
| 143 | - void playSpeedCmd(Device device, StreamInfo streamInfo, String speed); | 143 | + void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed); |
| 144 | 144 | ||
| 145 | /** | 145 | /** |
| 146 | * 语音广播 | 146 | * 语音广播 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -1630,12 +1630,12 @@ public class SIPCommander implements ISIPCommander { | @@ -1630,12 +1630,12 @@ public class SIPCommander implements ISIPCommander { | ||
| 1630 | * 回放倍速播放 | 1630 | * 回放倍速播放 |
| 1631 | */ | 1631 | */ |
| 1632 | @Override | 1632 | @Override |
| 1633 | - public void playSpeedCmd(Device device, StreamInfo streamInfo, String speed) { | 1633 | + public void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) { |
| 1634 | try { | 1634 | try { |
| 1635 | StringBuffer content = new StringBuffer(200); | 1635 | StringBuffer content = new StringBuffer(200); |
| 1636 | content.append("PLAY RTSP/1.0\r\n"); | 1636 | content.append("PLAY RTSP/1.0\r\n"); |
| 1637 | content.append("CSeq: " + InfoCseqCache.CSEQCACHE.get(streamInfo.getStreamId()) + "\r\n"); | 1637 | content.append("CSeq: " + InfoCseqCache.CSEQCACHE.get(streamInfo.getStreamId()) + "\r\n"); |
| 1638 | - content.append("Scale: " + speed + ".000000\r\n"); | 1638 | + content.append("Scale: " + String.format("%.1f",speed) + "\r\n"); |
| 1639 | Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString()); | 1639 | Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString()); |
| 1640 | logger.info(request.toString()); | 1640 | logger.info(request.toString()); |
| 1641 | ClientTransaction clientTransaction = null; | 1641 | ClientTransaction clientTransaction = null; |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java
| @@ -221,10 +221,10 @@ public class PlaybackController { | @@ -221,10 +221,10 @@ public class PlaybackController { | ||
| 221 | @ApiOperation("回放倍速播放") | 221 | @ApiOperation("回放倍速播放") |
| 222 | @ApiImplicitParams({ | 222 | @ApiImplicitParams({ |
| 223 | @ApiImplicitParam(name = "streamId", value = "回放流ID", dataTypeClass = String.class), | 223 | @ApiImplicitParam(name = "streamId", value = "回放流ID", dataTypeClass = String.class), |
| 224 | - @ApiImplicitParam(name = "speed", value = "倍速 1、2、4", dataTypeClass = String.class), | 224 | + @ApiImplicitParam(name = "speed", value = "倍速0.25 0.5 1、2、4", dataTypeClass = Double.class), |
| 225 | }) | 225 | }) |
| 226 | @GetMapping("/speed/{streamId}/{speed}") | 226 | @GetMapping("/speed/{streamId}/{speed}") |
| 227 | - public ResponseEntity<String> playSpeed(@PathVariable String streamId, @PathVariable String speed) { | 227 | + public ResponseEntity<String> playSpeed(@PathVariable String streamId, @PathVariable Double speed) { |
| 228 | logger.info("playSpeed: "+streamId+", "+speed); | 228 | logger.info("playSpeed: "+streamId+", "+speed); |
| 229 | JSONObject json = new JSONObject(); | 229 | JSONObject json = new JSONObject(); |
| 230 | StreamInfo streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId); | 230 | StreamInfo streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId); |
| @@ -233,6 +233,11 @@ public class PlaybackController { | @@ -233,6 +233,11 @@ public class PlaybackController { | ||
| 233 | logger.warn("streamId不存在!"); | 233 | logger.warn("streamId不存在!"); |
| 234 | return new ResponseEntity<String>(json.toString(), HttpStatus.BAD_REQUEST); | 234 | return new ResponseEntity<String>(json.toString(), HttpStatus.BAD_REQUEST); |
| 235 | } | 235 | } |
| 236 | + if(speed != 0.25 && speed != 0.5 && speed != 1 && speed != 2.0 && speed != 4.0) { | ||
| 237 | + json.put("msg", "不支持的speed(0.25 0.5 1、2、4)"); | ||
| 238 | + logger.warn("不支持的speed: " + speed); | ||
| 239 | + return new ResponseEntity<String>(json.toString(), HttpStatus.BAD_REQUEST); | ||
| 240 | + } | ||
| 236 | setCseq(streamId); | 241 | setCseq(streamId); |
| 237 | Device device = storager.queryVideoDevice(streamInfo.getDeviceID()); | 242 | Device device = storager.queryVideoDevice(streamInfo.getDeviceID()); |
| 238 | cmder.playSpeedCmd(device, streamInfo, speed); | 243 | cmder.playSpeedCmd(device, streamInfo, speed); |