Commit 13811b0c78a2676eada42dfd1835f5f2790b21af
Merge branch '2.6.8' into wvp-28181-2.0
# Conflicts: # sql/初始化.sql # src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java # src/main/resources/all-application.yml
Showing
2 changed files
with
57 additions
and
67 deletions
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
| 1 | package com.genersoft.iot.vmp.web.gb28181; | 1 | package com.genersoft.iot.vmp.web.gb28181; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson2.JSONObject; | 3 | import com.alibaba.fastjson2.JSONObject; |
| 4 | -import com.genersoft.iot.vmp.common.InviteInfo; | ||
| 5 | -import com.genersoft.iot.vmp.common.InviteSessionType; | 4 | +import com.genersoft.iot.vmp.common.StreamInfo; |
| 6 | import com.genersoft.iot.vmp.conf.UserSetting; | 5 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; | 6 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 8 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 7 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| @@ -10,18 +9,13 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | @@ -10,18 +9,13 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | ||
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 11 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 10 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 12 | import com.genersoft.iot.vmp.service.IDeviceService; | 11 | import com.genersoft.iot.vmp.service.IDeviceService; |
| 13 | -import com.genersoft.iot.vmp.service.IInviteStreamService; | ||
| 14 | import com.genersoft.iot.vmp.service.IPlayService; | 12 | import com.genersoft.iot.vmp.service.IPlayService; |
| 15 | -import com.genersoft.iot.vmp.service.bean.InviteErrorCode; | ||
| 16 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 13 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 17 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 14 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 18 | import org.slf4j.Logger; | 15 | import org.slf4j.Logger; |
| 19 | import org.slf4j.LoggerFactory; | 16 | import org.slf4j.LoggerFactory; |
| 20 | import org.springframework.beans.factory.annotation.Autowired; | 17 | 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; | 18 | +import org.springframework.web.bind.annotation.*; |
| 25 | import org.springframework.web.context.request.async.DeferredResult; | 19 | import org.springframework.web.context.request.async.DeferredResult; |
| 26 | 20 | ||
| 27 | import javax.sip.InvalidArgumentException; | 21 | import javax.sip.InvalidArgumentException; |
| @@ -52,9 +46,6 @@ public class ApiStreamController { | @@ -52,9 +46,6 @@ public class ApiStreamController { | ||
| 52 | private IRedisCatchStorage redisCatchStorage; | 46 | private IRedisCatchStorage redisCatchStorage; |
| 53 | 47 | ||
| 54 | @Autowired | 48 | @Autowired |
| 55 | - private IInviteStreamService inviteStreamService; | ||
| 56 | - | ||
| 57 | - @Autowired | ||
| 58 | private IDeviceService deviceService; | 49 | private IDeviceService deviceService; |
| 59 | 50 | ||
| 60 | @Autowired | 51 | @Autowired |
| @@ -92,7 +83,7 @@ public class ApiStreamController { | @@ -92,7 +83,7 @@ public class ApiStreamController { | ||
| 92 | result.put("error","device[ " + serial + " ]未找到"); | 83 | result.put("error","device[ " + serial + " ]未找到"); |
| 93 | resultDeferredResult.setResult(result); | 84 | resultDeferredResult.setResult(result); |
| 94 | return resultDeferredResult; | 85 | return resultDeferredResult; |
| 95 | - }else if (!device.isOnLine()) { | 86 | + }else if (device.getOnline() == 0) { |
| 96 | JSONObject result = new JSONObject(); | 87 | JSONObject result = new JSONObject(); |
| 97 | result.put("error","device[ " + code + " ]offline"); | 88 | result.put("error","device[ " + code + " ]offline"); |
| 98 | resultDeferredResult.setResult(result); | 89 | resultDeferredResult.setResult(result); |
| @@ -113,60 +104,59 @@ public class ApiStreamController { | @@ -113,60 +104,59 @@ public class ApiStreamController { | ||
| 113 | result.put("error","channel[ " + code + " ]未找到"); | 104 | result.put("error","channel[ " + code + " ]未找到"); |
| 114 | resultDeferredResult.setResult(result); | 105 | resultDeferredResult.setResult(result); |
| 115 | return resultDeferredResult; | 106 | return resultDeferredResult; |
| 116 | - }else if (!deviceChannel.isStatus()) { | 107 | + }else if (deviceChannel.getStatus() == 0) { |
| 117 | JSONObject result = new JSONObject(); | 108 | JSONObject result = new JSONObject(); |
| 118 | result.put("error","channel[ " + code + " ]offline"); | 109 | result.put("error","channel[ " + code + " ]offline"); |
| 119 | resultDeferredResult.setResult(result); | 110 | resultDeferredResult.setResult(result); |
| 120 | return resultDeferredResult; | 111 | return resultDeferredResult; |
| 121 | } | 112 | } |
| 122 | MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); | 113 | MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); |
| 123 | - | ||
| 124 | - | ||
| 125 | - playService.play(newMediaServerItem, serial, code, null, (errorCode, msg, data) -> { | ||
| 126 | - 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 | - result.put("WS_FLV", inviteInfo.getStreamInfo().getWs_flv().getUrl()); | ||
| 137 | - result.put("RTMP", inviteInfo.getStreamInfo().getRtmp().getUrl()); | ||
| 138 | - result.put("HLS", inviteInfo.getStreamInfo().getHls().getUrl()); | ||
| 139 | - result.put("RTSP", inviteInfo.getStreamInfo().getRtsp().getUrl()); | ||
| 140 | - result.put("WEBRTC", inviteInfo.getStreamInfo().getRtc().getUrl()); | ||
| 141 | - result.put("CDN", ""); | ||
| 142 | - result.put("SnapURL", ""); | ||
| 143 | - result.put("Transport", device.getTransport()); | ||
| 144 | - result.put("StartAt", ""); | ||
| 145 | - result.put("Duration", ""); | ||
| 146 | - result.put("SourceVideoCodecName", ""); | ||
| 147 | - result.put("SourceVideoWidth", ""); | ||
| 148 | - result.put("SourceVideoHeight", ""); | ||
| 149 | - result.put("SourceVideoFrameRate", ""); | ||
| 150 | - result.put("SourceAudioCodecName", ""); | ||
| 151 | - result.put("SourceAudioSampleRate", ""); | ||
| 152 | - result.put("AudioEnable", ""); | ||
| 153 | - result.put("Ondemand", ""); | ||
| 154 | - result.put("InBytes", ""); | ||
| 155 | - result.put("InBitRate", ""); | ||
| 156 | - result.put("OutBytes", ""); | ||
| 157 | - result.put("NumOutputs", ""); | ||
| 158 | - result.put("CascadeSize", ""); | ||
| 159 | - result.put("RelaySize", ""); | ||
| 160 | - result.put("ChannelPTZType", "0"); | ||
| 161 | - resultDeferredResult.setResult(result); | ||
| 162 | - } | ||
| 163 | - }else { | ||
| 164 | - JSONObject result = new JSONObject(); | ||
| 165 | - result.put("error", "channel[ " + code + " ] " + msg); | ||
| 166 | - resultDeferredResult.setResult(result); | ||
| 167 | - } | ||
| 168 | - }); | ||
| 169 | - | 114 | + playService.play(newMediaServerItem, serial, code, (mediaServerItem, response)->{ |
| 115 | + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(serial, code); | ||
| 116 | + JSONObject result = new JSONObject(); | ||
| 117 | + result.put("StreamID", streamInfo.getStream()); | ||
| 118 | + result.put("DeviceID", device.getDeviceId()); | ||
| 119 | + result.put("ChannelID", code); | ||
| 120 | + result.put("ChannelName", deviceChannel.getName()); | ||
| 121 | + result.put("ChannelCustomName", ""); | ||
| 122 | + result.put("FLV", streamInfo.getFlv().getUrl()); | ||
| 123 | + result.put("HTTPS_FLV", streamInfo.getHttps_flv().getUrl()); | ||
| 124 | + result.put("WS_FLV", streamInfo.getWs_flv().getUrl()); | ||
| 125 | + result.put("WSS_FLV", streamInfo.getWss_flv().getUrl()); | ||
| 126 | + result.put("RTMP", streamInfo.getRtmp().getUrl()); | ||
| 127 | + result.put("RTMPS", streamInfo.getRtmps().getUrl()); | ||
| 128 | + result.put("HLS", streamInfo.getHls().getUrl()); | ||
| 129 | + result.put("HTTPS_HLS", streamInfo.getHttps_hls().getUrl()); | ||
| 130 | + result.put("RTSP", streamInfo.getRtsp().getUrl()); | ||
| 131 | + result.put("RTSPS", streamInfo.getRtsps().getUrl()); | ||
| 132 | + result.put("WEBRTC", streamInfo.getRtc().getUrl()); | ||
| 133 | + result.put("HTTPS_WEBRTC", streamInfo.getRtcs().getUrl()); | ||
| 134 | + result.put("CDN", ""); | ||
| 135 | + result.put("SnapURL", ""); | ||
| 136 | + result.put("Transport", device.getTransport()); | ||
| 137 | + result.put("StartAt", ""); | ||
| 138 | + result.put("Duration", ""); | ||
| 139 | + result.put("SourceVideoCodecName", ""); | ||
| 140 | + result.put("SourceVideoWidth", ""); | ||
| 141 | + result.put("SourceVideoHeight", ""); | ||
| 142 | + result.put("SourceVideoFrameRate", ""); | ||
| 143 | + result.put("SourceAudioCodecName", ""); | ||
| 144 | + result.put("SourceAudioSampleRate", ""); | ||
| 145 | + result.put("AudioEnable", ""); | ||
| 146 | + result.put("Ondemand", ""); | ||
| 147 | + result.put("InBytes", ""); | ||
| 148 | + result.put("InBitRate", ""); | ||
| 149 | + result.put("OutBytes", ""); | ||
| 150 | + result.put("NumOutputs", ""); | ||
| 151 | + result.put("CascadeSize", ""); | ||
| 152 | + result.put("RelaySize", ""); | ||
| 153 | + result.put("ChannelPTZType", "0"); | ||
| 154 | + resultDeferredResult.setResult(result); | ||
| 155 | + }, (eventResult) -> { | ||
| 156 | + JSONObject result = new JSONObject(); | ||
| 157 | + result.put("error", "channel[ " + code + " ] " + eventResult.msg); | ||
| 158 | + resultDeferredResult.setResult(result); | ||
| 159 | + }, null); | ||
| 170 | return resultDeferredResult; | 160 | return resultDeferredResult; |
| 171 | } | 161 | } |
| 172 | 162 | ||
| @@ -187,8 +177,8 @@ public class ApiStreamController { | @@ -187,8 +177,8 @@ public class ApiStreamController { | ||
| 187 | 177 | ||
| 188 | ){ | 178 | ){ |
| 189 | 179 | ||
| 190 | - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, serial, code); | ||
| 191 | - if (inviteInfo == null) { | 180 | + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(serial, code); |
| 181 | + if (streamInfo == null) { | ||
| 192 | JSONObject result = new JSONObject(); | 182 | JSONObject result = new JSONObject(); |
| 193 | result.put("error","未找到流信息"); | 183 | result.put("error","未找到流信息"); |
| 194 | return result; | 184 | return result; |
| @@ -200,14 +190,14 @@ public class ApiStreamController { | @@ -200,14 +190,14 @@ public class ApiStreamController { | ||
| 200 | return result; | 190 | return result; |
| 201 | } | 191 | } |
| 202 | try { | 192 | try { |
| 203 | - cmder.streamByeCmd(device, code, inviteInfo.getStream(), null); | 193 | + cmder.streamByeCmd(device, code, streamInfo.getStream(), null); |
| 204 | } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { | 194 | } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { |
| 205 | JSONObject result = new JSONObject(); | 195 | JSONObject result = new JSONObject(); |
| 206 | result.put("error","发送BYE失败:" + e.getMessage()); | 196 | result.put("error","发送BYE失败:" + e.getMessage()); |
| 207 | return result; | 197 | return result; |
| 208 | } | 198 | } |
| 209 | - inviteStreamService.removeInviteInfo(inviteInfo); | ||
| 210 | - storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); | 199 | + redisCatchStorage.stopPlay(streamInfo); |
| 200 | + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | ||
| 211 | return null; | 201 | return null; |
| 212 | } | 202 | } |
| 213 | 203 |
src/main/resources/all-application.yml
| @@ -145,8 +145,8 @@ media: | @@ -145,8 +145,8 @@ media: | ||
| 145 | enable: true | 145 | enable: true |
| 146 | # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性,不然自动配置此属性可能不成功 | 146 | # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性,不然自动配置此属性可能不成功 |
| 147 | port-range: 30000,30500 # 端口范围 | 147 | port-range: 30000,30500 # 端口范围 |
| 148 | - # [可选] 国标级联在此范围内选择端口发送媒体流 | ||
| 149 | - send-port-range: 30000,30500 # 端口范围 | 148 | + # [可选] 国标级联在此范围内选择端口发送媒体流,请不要与收流端口范围重合 |
| 149 | + send-port-range: 50502,50506 # 端口范围 | ||
| 150 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 | 150 | # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 |
| 151 | record-assist-port: 0 | 151 | record-assist-port: 0 |
| 152 | 152 |