Commit c581974027cb6ff2123d5a7dd0b39fd3b3217bd4

Authored by 648540858
1 parent bb948311

使用GetMapping替换RequestMapping

src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
... ... @@ -141,6 +141,9 @@ public class PlayController {
141 141 streamInfo.channgeStreamIp(host);
142 142 }
143 143 wvpResult.setData(new StreamContent(streamInfo));
  144 + }else {
  145 + wvpResult.setCode(code);
  146 + wvpResult.setMsg(msg);
144 147 }
145 148 }else {
146 149 wvpResult.setCode(code);
... ...
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
... ... @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
8 8 import org.slf4j.Logger;
9 9 import org.slf4j.LoggerFactory;
10 10 import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.web.bind.annotation.GetMapping;
11 12 import org.springframework.web.bind.annotation.RequestMapping;
12 13 import org.springframework.web.bind.annotation.RequestParam;
13 14 import org.springframework.web.bind.annotation.RestController;
... ... @@ -41,7 +42,7 @@ public class ApiControlController {
41 42 * @param speed 速度(0~255) 默认值: 129
42 43 * @return
43 44 */
44   - @RequestMapping(value = "/ptz")
  45 + @GetMapping(value = "/ptz")
45 46 private void list(String serial,String command,
46 47 @RequestParam(required = false)Integer channel,
47 48 @RequestParam(required = false)String code,
... ... @@ -114,7 +115,7 @@ public class ApiControlController {
114 115 * @param name 预置位名称, command=set 时有效
115 116 * @return
116 117 */
117   - @RequestMapping(value = "/preset")
  118 + @GetMapping(value = "/preset")
118 119 private void list(String serial,String command,
119 120 @RequestParam(required = false)Integer channel,
120 121 @RequestParam(required = false)String code,
... ...
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiController.java
... ... @@ -6,6 +6,7 @@ import org.slf4j.Logger;
6 6 import org.slf4j.LoggerFactory;
7 7 import org.springframework.beans.factory.annotation.Autowired;
8 8 import org.springframework.stereotype.Controller;
  9 +import org.springframework.web.bind.annotation.GetMapping;
9 10 import org.springframework.web.bind.annotation.RequestMapping;
10 11 import org.springframework.web.bind.annotation.ResponseBody;
11 12  
... ... @@ -23,7 +24,7 @@ public class ApiController {
23 24 private SipConfig sipConfig;
24 25  
25 26  
26   - @RequestMapping("/getserverinfo")
  27 + @GetMapping("/getserverinfo")
27 28 private JSONObject getserverinfo(){
28 29 JSONObject result = new JSONObject();
29 30 result.put("Authorization","ceshi");
... ... @@ -50,7 +51,7 @@ public class ApiController {
50 51 return result;
51 52 }
52 53  
53   - @RequestMapping(value = "/userinfo")
  54 + @GetMapping(value = "/userinfo")
54 55 private JSONObject userinfo(){
55 56 // JSONObject result = new JSONObject();
56 57 // result.put("ID","ceshi");
... ... @@ -83,7 +84,7 @@ public class ApiController {
83 84 * @param password 密码(经过md5加密,32位长度,不带中划线,不区分大小写)
84 85 * @return
85 86 */
86   - @RequestMapping(value = "/login")
  87 + @GetMapping(value = "/login")
87 88 @ResponseBody
88 89 private JSONObject login(String username,String password ){
89 90 if (logger.isDebugEnabled()) {
... ...
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java
... ... @@ -18,6 +18,7 @@ import org.slf4j.Logger;
18 18 import org.slf4j.LoggerFactory;
19 19 import org.springframework.beans.factory.annotation.Autowired;
20 20 import org.springframework.util.ObjectUtils;
  21 +import org.springframework.web.bind.annotation.GetMapping;
21 22 import org.springframework.web.bind.annotation.RequestMapping;
22 23 import org.springframework.web.bind.annotation.RequestParam;
23 24 import org.springframework.web.bind.annotation.RestController;
... ... @@ -59,7 +60,7 @@ public class ApiDeviceController {
59 60 * @param online
60 61 * @return
61 62 */
62   - @RequestMapping(value = "/list")
  63 + @GetMapping(value = "/list")
63 64 public JSONObject list( @RequestParam(required = false)Integer start,
64 65 @RequestParam(required = false)Integer limit,
65 66 @RequestParam(required = false)String q,
... ... @@ -105,7 +106,7 @@ public class ApiDeviceController {
105 106 return result;
106 107 }
107 108  
108   - @RequestMapping(value = "/channellist")
  109 + @GetMapping(value = "/channellist")
109 110 public JSONObject channellist( String serial,
110 111 @RequestParam(required = false)String channel_type,
111 112 @RequestParam(required = false)String code ,
... ... @@ -186,7 +187,7 @@ public class ApiDeviceController {
186 187 * @param timeout 超时时间(秒) 默认值: 15
187 188 * @return
188 189 */
189   - @RequestMapping(value = "/fetchpreset")
  190 + @GetMapping(value = "/fetchpreset")
190 191 private DeferredResult<Object> list(String serial,
191 192 @RequestParam(required = false)Integer channel,
192 193 @RequestParam(required = false)String code,
... ...
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
... ... @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.web.gb28181;
3 3 import com.alibaba.fastjson2.JSONObject;
4 4 import com.genersoft.iot.vmp.common.InviteInfo;
5 5 import com.genersoft.iot.vmp.common.InviteSessionType;
  6 +import com.genersoft.iot.vmp.common.StreamInfo;
6 7 import com.genersoft.iot.vmp.conf.UserSetting;
7 8 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
8 9 import com.genersoft.iot.vmp.gb28181.bean.Device;
... ... @@ -13,15 +14,11 @@ import com.genersoft.iot.vmp.service.IDeviceService;
13 14 import com.genersoft.iot.vmp.service.IInviteStreamService;
14 15 import com.genersoft.iot.vmp.service.IPlayService;
15 16 import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
16   -import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
17 17 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
18 18 import org.slf4j.Logger;
19 19 import org.slf4j.LoggerFactory;
20 20 import org.springframework.beans.factory.annotation.Autowired;
21   -import org.springframework.web.bind.annotation.RequestMapping;
22   -import org.springframework.web.bind.annotation.RequestParam;
23   -import org.springframework.web.bind.annotation.ResponseBody;
24   -import org.springframework.web.bind.annotation.RestController;
  21 +import org.springframework.web.bind.annotation.*;
25 22 import org.springframework.web.context.request.async.DeferredResult;
26 23  
27 24 import javax.sip.InvalidArgumentException;
... ... @@ -49,9 +46,6 @@ public class ApiStreamController {
49 46 private UserSetting userSetting;
50 47  
51 48 @Autowired
52   - private IRedisCatchStorage redisCatchStorage;
53   -
54   - @Autowired
55 49 private IDeviceService deviceService;
56 50  
57 51 @Autowired
... ... @@ -73,7 +67,7 @@ public class ApiStreamController {
73 67 * @param timeout 拉流超时(秒),
74 68 * @return
75 69 */
76   - @RequestMapping(value = "/start")
  70 + @GetMapping("/start")
77 71 private DeferredResult<JSONObject> start(String serial ,
78 72 @RequestParam(required = false)Integer channel ,
79 73 @RequestParam(required = false)String code,
... ... @@ -85,107 +79,111 @@ public class ApiStreamController {
85 79 @RequestParam(required = false)String timeout
86 80  
87 81 ){
88   - DeferredResult<JSONObject> resultDeferredResult = new DeferredResult<>(userSetting.getPlayTimeout().longValue() + 10);
  82 + DeferredResult<JSONObject> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue() + 10);
89 83 Device device = storager.queryVideoDevice(serial);
90 84 if (device == null ) {
91   - JSONObject result = new JSONObject();
92   - result.put("error","device[ " + serial + " ]未找到");
93   - resultDeferredResult.setResult(result);
94   - return resultDeferredResult;
  85 + JSONObject resultJSON = new JSONObject();
  86 + resultJSON.put("error","device[ " + serial + " ]未找到");
  87 + result.setResult(resultJSON);
  88 + return result;
95 89 }else if (!device.isOnLine()) {
96   - JSONObject result = new JSONObject();
97   - result.put("error","device[ " + code + " ]offline");
98   - resultDeferredResult.setResult(result);
99   - return resultDeferredResult;
  90 + JSONObject resultJSON = new JSONObject();
  91 + resultJSON.put("error","device[ " + code + " ]offline");
  92 + result.setResult(resultJSON);
  93 + return result;
100 94 }
101   - resultDeferredResult.onTimeout(()->{
  95 + result.onTimeout(()->{
102 96 logger.info("播放等待超时");
103   - JSONObject result = new JSONObject();
104   - result.put("error","timeout");
105   - resultDeferredResult.setResult(result);
106   -
  97 + JSONObject resultJSON = new JSONObject();
  98 + resultJSON.put("error","timeout");
  99 + result.setResult(resultJSON);
  100 + inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, serial, code);
  101 + storager.stopPlay(serial, code);
107 102 // 清理RTP server
108 103 });
109 104  
110 105 DeviceChannel deviceChannel = storager.queryChannel(serial, code);
111 106 if (deviceChannel == null) {
112   - JSONObject result = new JSONObject();
113   - result.put("error","channel[ " + code + " ]未找到");
114   - resultDeferredResult.setResult(result);
115   - return resultDeferredResult;
  107 + JSONObject resultJSON = new JSONObject();
  108 + resultJSON.put("error","channel[ " + code + " ]未找到");
  109 + result.setResult(resultJSON);
  110 + return result;
116 111 }else if (!deviceChannel.isStatus()) {
117   - JSONObject result = new JSONObject();
118   - result.put("error","channel[ " + code + " ]offline");
119   - resultDeferredResult.setResult(result);
120   - return resultDeferredResult;
  112 + JSONObject resultJSON = new JSONObject();
  113 + resultJSON.put("error","channel[ " + code + " ]offline");
  114 + result.setResult(resultJSON);
  115 + return result;
121 116 }
122 117 MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
123 118  
124   -
125 119 playService.play(newMediaServerItem, serial, code, null, (errorCode, msg, data) -> {
126 120 if (errorCode == InviteErrorCode.SUCCESS.getCode()) {
127   - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, serial, code);
128   - if (inviteInfo != null && inviteInfo.getStreamInfo() != null) {
129   - JSONObject result = new JSONObject();
130   - result.put("StreamID", inviteInfo.getStreamInfo().getStream());
131   - result.put("DeviceID", device.getDeviceId());
132   - result.put("ChannelID", code);
133   - result.put("ChannelName", deviceChannel.getName());
134   - result.put("ChannelCustomName", "");
135   - result.put("FLV", inviteInfo.getStreamInfo().getFlv().getUrl());
136   - if(inviteInfo.getStreamInfo().getHttps_flv() != null) {
137   - result.put("HTTPS_FLV", inviteInfo.getStreamInfo().getHttps_flv().getUrl());
  121 + if (data != null) {
  122 + StreamInfo streamInfo = (StreamInfo)data;
  123 + JSONObject resultJjson = new JSONObject();
  124 + resultJjson.put("StreamID", streamInfo.getStream());
  125 + resultJjson.put("DeviceID", serial);
  126 + resultJjson.put("ChannelID", code);
  127 + resultJjson.put("ChannelName", deviceChannel.getName());
  128 + resultJjson.put("ChannelCustomName", "");
  129 + resultJjson.put("FLV", streamInfo.getFlv().getUrl());
  130 + if(streamInfo.getHttps_flv() != null) {
  131 + resultJjson.put("HTTPS_FLV", streamInfo.getHttps_flv().getUrl());
138 132 }
139   - result.put("WS_FLV", inviteInfo.getStreamInfo().getWs_flv().getUrl());
140   - if(inviteInfo.getStreamInfo().getWss_flv() != null) {
141   - result.put("WSS_FLV", inviteInfo.getStreamInfo().getWss_flv().getUrl());
  133 + resultJjson.put("WS_FLV", streamInfo.getWs_flv().getUrl());
  134 + if(streamInfo.getWss_flv() != null) {
  135 + resultJjson.put("WSS_FLV", streamInfo.getWss_flv().getUrl());
142 136 }
143   - result.put("RTMP", inviteInfo.getStreamInfo().getRtmp().getUrl());
144   - if (inviteInfo.getStreamInfo().getRtmps() != null) {
145   - result.put("RTMPS", inviteInfo.getStreamInfo().getRtmps().getUrl());
  137 + resultJjson.put("RTMP", streamInfo.getRtmp().getUrl());
  138 + if (streamInfo.getRtmps() != null) {
  139 + resultJjson.put("RTMPS", streamInfo.getRtmps().getUrl());
146 140 }
147   - result.put("HLS", inviteInfo.getStreamInfo().getHls().getUrl());
148   - if (inviteInfo.getStreamInfo().getHttps_hls() != null) {
149   - result.put("HTTPS_HLS", inviteInfo.getStreamInfo().getHttps_hls().getUrl());
  141 + resultJjson.put("HLS", streamInfo.getHls().getUrl());
  142 + if (streamInfo.getHttps_hls() != null) {
  143 + resultJjson.put("HTTPS_HLS", streamInfo.getHttps_hls().getUrl());
150 144 }
151   - result.put("RTSP", inviteInfo.getStreamInfo().getRtsp().getUrl());
152   - if (inviteInfo.getStreamInfo().getRtsps() != null) {
153   - result.put("RTSPS", inviteInfo.getStreamInfo().getRtsps().getUrl());
  145 + resultJjson.put("RTSP", streamInfo.getRtsp().getUrl());
  146 + if (streamInfo.getRtsps() != null) {
  147 + resultJjson.put("RTSPS", streamInfo.getRtsps().getUrl());
154 148 }
155   - result.put("WEBRTC", inviteInfo.getStreamInfo().getRtc().getUrl());
156   - if (inviteInfo.getStreamInfo().getRtcs() != null) {
157   - result.put("HTTPS_WEBRTC", inviteInfo.getStreamInfo().getRtcs().getUrl());
  149 + resultJjson.put("WEBRTC", streamInfo.getRtc().getUrl());
  150 + if (streamInfo.getRtcs() != null) {
  151 + resultJjson.put("HTTPS_WEBRTC", streamInfo.getRtcs().getUrl());
158 152 }
159   - result.put("CDN", "");
160   - result.put("SnapURL", "");
161   - result.put("Transport", device.getTransport());
162   - result.put("StartAt", "");
163   - result.put("Duration", "");
164   - result.put("SourceVideoCodecName", "");
165   - result.put("SourceVideoWidth", "");
166   - result.put("SourceVideoHeight", "");
167   - result.put("SourceVideoFrameRate", "");
168   - result.put("SourceAudioCodecName", "");
169   - result.put("SourceAudioSampleRate", "");
170   - result.put("AudioEnable", "");
171   - result.put("Ondemand", "");
172   - result.put("InBytes", "");
173   - result.put("InBitRate", "");
174   - result.put("OutBytes", "");
175   - result.put("NumOutputs", "");
176   - result.put("CascadeSize", "");
177   - result.put("RelaySize", "");
178   - result.put("ChannelPTZType", "0");
179   - resultDeferredResult.setResult(result);
  153 + resultJjson.put("CDN", "");
  154 + resultJjson.put("SnapURL", "");
  155 + resultJjson.put("Transport", device.getTransport());
  156 + resultJjson.put("StartAt", "");
  157 + resultJjson.put("Duration", "");
  158 + resultJjson.put("SourceVideoCodecName", "");
  159 + resultJjson.put("SourceVideoWidth", "");
  160 + resultJjson.put("SourceVideoHeight", "");
  161 + resultJjson.put("SourceVideoFrameRate", "");
  162 + resultJjson.put("SourceAudioCodecName", "");
  163 + resultJjson.put("SourceAudioSampleRate", "");
  164 + resultJjson.put("AudioEnable", "");
  165 + resultJjson.put("Ondemand", "");
  166 + resultJjson.put("InBytes", "");
  167 + resultJjson.put("InBitRate", "");
  168 + resultJjson.put("OutBytes", "");
  169 + resultJjson.put("NumOutputs", "");
  170 + resultJjson.put("CascadeSize", "");
  171 + resultJjson.put("RelaySize", "");
  172 + resultJjson.put("ChannelPTZType", "0");
  173 + result.setResult(resultJjson);
  174 + }else {
  175 + JSONObject resultJjson = new JSONObject();
  176 + resultJjson.put("error", "channel[ " + code + " ] " + msg);
  177 + result.setResult(resultJjson);
180 178 }
181 179 }else {
182   - JSONObject result = new JSONObject();
183   - result.put("error", "channel[ " + code + " ] " + msg);
184   - resultDeferredResult.setResult(result);
  180 + JSONObject resultJjson = new JSONObject();
  181 + resultJjson.put("error", "channel[ " + code + " ] " + msg);
  182 + result.setResult(resultJjson);
185 183 }
186 184 });
187 185  
188   - return resultDeferredResult;
  186 + return result;
189 187 }
190 188  
191 189 /**
... ... @@ -196,7 +194,7 @@ public class ApiStreamController {
196 194 * @param check_outputs
197 195 * @return
198 196 */
199   - @RequestMapping(value = "/stop")
  197 + @GetMapping("/stop")
200 198 @ResponseBody
201 199 private JSONObject stop(String serial ,
202 200 @RequestParam(required = false)Integer channel ,
... ... @@ -236,7 +234,7 @@ public class ApiStreamController {
236 234 * @param code 通道国标编号
237 235 * @return
238 236 */
239   - @RequestMapping(value = "/touch")
  237 + @GetMapping("/touch")
240 238 @ResponseBody
241 239 private JSONObject touch(String serial ,String t,
242 240 @RequestParam(required = false)Integer channel ,
... ...
src/main/java/com/genersoft/iot/vmp/web/gb28181/AuthController.java
... ... @@ -13,7 +13,7 @@ public class AuthController {
13 13 @Autowired
14 14 private IUserService userService;
15 15  
16   - @RequestMapping("/login")
  16 + @GetMapping("/login")
17 17 public String devices(String name, String passwd){
18 18 User user = userService.getUser(name, passwd);
19 19 if (user != null) {
... ...