From 69d9692f6194d1e03ec81cf87ea8f0e7a62f7173 Mon Sep 17 00:00:00 2001
From: wangyimeng <421132955@qq.com>
Date: 星期三, 16 三月 2022 15:27:12 +0800
Subject: [PATCH] 删除重复字段
---
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java | 74 +++++++++---------------------------
1 files changed, 19 insertions(+), 55 deletions(-)
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 8f83e7c..2fccaa8 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
@@ -18,6 +18,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -75,53 +76,9 @@
if (logger.isDebugEnabled()) {
logger.debug(String.format("璁惧鍥炴斁 API璋冪敤锛宒eviceId锛�%s 锛宑hannelId锛�%s", deviceId, channelId));
}
- String uuid = UUID.randomUUID().toString();
- String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId;
- DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(30000L);
- Device device = storager.queryVideoDevice(deviceId);
- if (device == null) {
- result.setResult(new ResponseEntity<>(HttpStatus.BAD_REQUEST));
- return result;
- }
- MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
- SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true);
- // 瓒呮椂澶勭悊
- result.onTimeout(()->{
- logger.warn(String.format("璁惧鍥炴斁瓒呮椂锛宒eviceId锛�%s 锛宑hannelId锛�%s", deviceId, channelId));
- RequestMessage msg = new RequestMessage();
- msg.setId(uuid);
- msg.setKey(key);
- msg.setData("Timeout");
- resultHolder.invokeResult(msg);
- });
-
- StreamInfo streamInfo = redisCatchStorage.queryPlaybackByDevice(deviceId, channelId);
- if (streamInfo != null) {
- // 鍋滄涔嬪墠鐨勫洖鏀�
- cmder.streamByeCmd(deviceId, channelId);
- }
- resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId, uuid, result);
-
- if (newMediaServerItem == null) {
- logger.warn(String.format("璁惧鍥炴斁瓒呮椂锛宒eviceId锛�%s 锛宑hannelId锛�%s", deviceId, channelId));
- RequestMessage msg = new RequestMessage();
- msg.setId(uuid);
- msg.setKey(key);
- msg.setData("Timeout");
- resultHolder.invokeResult(msg);
- return result;
- }
-
- cmder.playbackStreamCmd(newMediaServerItem, ssrcInfo, device, channelId, startTime, endTime, (MediaServerItem mediaServerItem, JSONObject response) -> {
- logger.info("鏀跺埌璁㈤槄娑堟伅锛� " + response.toJSONString());
- playService.onPublishHandlerForPlayBack(mediaServerItem, response, deviceId, channelId, uuid.toString());
- }, event -> {
- RequestMessage msg = new RequestMessage();
- msg.setId(uuid);
- msg.setKey(key);
- msg.setData(String.format("鍥炴斁澶辫触锛� 閿欒鐮侊細 %s, %s", event.statusCode, event.msg));
- resultHolder.invokeResult(msg);
+ DeferredResult<ResponseEntity<String>> result = playService.playBack(deviceId, channelId, startTime, endTime, null, wvpResult->{
+ resultHolder.invokeResult(wvpResult.getData());
});
return result;
@@ -131,24 +88,31 @@
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "璁惧ID", dataTypeClass = String.class),
@ApiImplicitParam(name = "channelId", value = "閫氶亾ID", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "stream", value = "娴両D", dataTypeClass = String.class),
})
- @GetMapping("/stop/{deviceId}/{channelId}")
- public ResponseEntity<String> playStop(@PathVariable String deviceId, @PathVariable String channelId) {
+ @GetMapping("/stop/{deviceId}/{channelId}/{stream}")
+ public ResponseEntity<String> playStop(
+ @PathVariable String deviceId,
+ @PathVariable String channelId,
+ @PathVariable String stream) {
- cmder.streamByeCmd(deviceId, channelId);
+ cmder.streamByeCmd(deviceId, channelId, stream, null);
if (logger.isDebugEnabled()) {
logger.debug(String.format("璁惧褰曞儚鍥炴斁鍋滄 API璋冪敤锛宒eviceId/channelId锛�%s/%s", deviceId, channelId));
+ }
+ if (StringUtils.isEmpty(deviceId) || StringUtils.isEmpty(channelId) || StringUtils.isEmpty(stream)) {
+ return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
if (deviceId != null && channelId != null) {
JSONObject json = new JSONObject();
json.put("deviceId", deviceId);
json.put("channelId", channelId);
- return new ResponseEntity<String>(json.toString(), HttpStatus.OK);
+ return new ResponseEntity<>(json.toString(), HttpStatus.OK);
} else {
logger.warn("璁惧褰曞儚鍥炴斁鍋滄API璋冪敤澶辫触锛�");
- return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@@ -160,7 +124,7 @@
public ResponseEntity<String> playPause(@PathVariable String streamId) {
logger.info("playPause: "+streamId);
JSONObject json = new JSONObject();
- StreamInfo streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
+ StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (null == streamInfo) {
json.put("msg", "streamId涓嶅瓨鍦�");
logger.warn("streamId涓嶅瓨鍦�!");
@@ -180,7 +144,7 @@
public ResponseEntity<String> playResume(@PathVariable String streamId) {
logger.info("playResume: "+streamId);
JSONObject json = new JSONObject();
- StreamInfo streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
+ StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (null == streamInfo) {
json.put("msg", "streamId涓嶅瓨鍦�");
logger.warn("streamId涓嶅瓨鍦�!");
@@ -201,7 +165,7 @@
public ResponseEntity<String> playSeek(@PathVariable String streamId, @PathVariable long seekTime) {
logger.info("playSeek: "+streamId+", "+seekTime);
JSONObject json = new JSONObject();
- StreamInfo streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
+ StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (null == streamInfo) {
json.put("msg", "streamId涓嶅瓨鍦�");
logger.warn("streamId涓嶅瓨鍦�!");
@@ -222,7 +186,7 @@
public ResponseEntity<String> playSpeed(@PathVariable String streamId, @PathVariable Double speed) {
logger.info("playSpeed: "+streamId+", "+speed);
JSONObject json = new JSONObject();
- StreamInfo streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
+ StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (null == streamInfo) {
json.put("msg", "streamId涓嶅瓨鍦�");
logger.warn("streamId涓嶅瓨鍦�!");
--
Gitblit v1.8.0