Commit a53dce38c2f58c0bfd37203e46dc57aa56025f45
Committed by
GitHub
Merge pull request #673 from 648540858/wvp-28181-2.0-multi-network
Wvp 28181 2.0 multi network
Showing
49 changed files
with
1258 additions
and
844 deletions
sql/update.sql
src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
| ... | ... | @@ -2,8 +2,10 @@ package com.genersoft.iot.vmp.common; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | |
| 5 | +import java.io.Serializable; | |
| 6 | + | |
| 5 | 7 | @Schema(description = "流信息") |
| 6 | -public class StreamInfo { | |
| 8 | +public class StreamInfo implements Serializable, Cloneable{ | |
| 7 | 9 | |
| 8 | 10 | @Schema(description = "应用名") |
| 9 | 11 | private String app; |
| ... | ... | @@ -13,54 +15,56 @@ public class StreamInfo { |
| 13 | 15 | private String deviceID; |
| 14 | 16 | @Schema(description = "通道编号") |
| 15 | 17 | private String channelId; |
| 16 | - @Schema(description = "HTTP-FLV流地址") | |
| 17 | - private String flv; | |
| 18 | 18 | |
| 19 | 19 | @Schema(description = "IP") |
| 20 | 20 | private String ip; |
| 21 | + | |
| 22 | + @Schema(description = "HTTP-FLV流地址") | |
| 23 | + private StreamURL flv; | |
| 24 | + | |
| 21 | 25 | @Schema(description = "HTTPS-FLV流地址") |
| 22 | - private String https_flv; | |
| 26 | + private StreamURL https_flv; | |
| 23 | 27 | @Schema(description = "Websocket-FLV流地址") |
| 24 | - private String ws_flv; | |
| 28 | + private StreamURL ws_flv; | |
| 25 | 29 | @Schema(description = "Websockets-FLV流地址") |
| 26 | - private String wss_flv; | |
| 30 | + private StreamURL wss_flv; | |
| 27 | 31 | @Schema(description = "HTTP-FMP4流地址") |
| 28 | - private String fmp4; | |
| 32 | + private StreamURL fmp4; | |
| 29 | 33 | @Schema(description = "HTTPS-FMP4流地址") |
| 30 | - private String https_fmp4; | |
| 34 | + private StreamURL https_fmp4; | |
| 31 | 35 | @Schema(description = "Websocket-FMP4流地址") |
| 32 | - private String ws_fmp4; | |
| 36 | + private StreamURL ws_fmp4; | |
| 33 | 37 | @Schema(description = "Websockets-FMP4流地址") |
| 34 | - private String wss_fmp4; | |
| 38 | + private StreamURL wss_fmp4; | |
| 35 | 39 | @Schema(description = "HLS流地址") |
| 36 | - private String hls; | |
| 40 | + private StreamURL hls; | |
| 37 | 41 | @Schema(description = "HTTPS-HLS流地址") |
| 38 | - private String https_hls; | |
| 42 | + private StreamURL https_hls; | |
| 39 | 43 | @Schema(description = "Websocket-HLS流地址") |
| 40 | - private String ws_hls; | |
| 44 | + private StreamURL ws_hls; | |
| 41 | 45 | @Schema(description = "Websockets-HLS流地址") |
| 42 | - private String wss_hls; | |
| 46 | + private StreamURL wss_hls; | |
| 43 | 47 | @Schema(description = "HTTP-TS流地址") |
| 44 | - private String ts; | |
| 48 | + private StreamURL ts; | |
| 45 | 49 | @Schema(description = "HTTPS-TS流地址") |
| 46 | - private String https_ts; | |
| 50 | + private StreamURL https_ts; | |
| 47 | 51 | @Schema(description = "Websocket-TS流地址") |
| 48 | - private String ws_ts; | |
| 52 | + private StreamURL ws_ts; | |
| 49 | 53 | @Schema(description = "Websockets-TS流地址") |
| 50 | - private String wss_ts; | |
| 54 | + private StreamURL wss_ts; | |
| 51 | 55 | @Schema(description = "RTMP流地址") |
| 52 | - private String rtmp; | |
| 56 | + private StreamURL rtmp; | |
| 53 | 57 | @Schema(description = "RTMPS流地址") |
| 54 | - private String rtmps; | |
| 58 | + private StreamURL rtmps; | |
| 55 | 59 | @Schema(description = "RTSP流地址") |
| 56 | - private String rtsp; | |
| 60 | + private StreamURL rtsp; | |
| 57 | 61 | @Schema(description = "RTSPS流地址") |
| 58 | - private String rtsps; | |
| 62 | + private StreamURL rtsps; | |
| 59 | 63 | @Schema(description = "RTC流地址") |
| 60 | - private String rtc; | |
| 64 | + private StreamURL rtc; | |
| 61 | 65 | |
| 62 | 66 | @Schema(description = "RTCS流地址") |
| 63 | - private String rtcs; | |
| 67 | + private StreamURL rtcs; | |
| 64 | 68 | @Schema(description = "流媒体ID") |
| 65 | 69 | private String mediaServerId; |
| 66 | 70 | @Schema(description = "流编码信息") |
| ... | ... | @@ -75,125 +79,221 @@ public class StreamInfo { |
| 75 | 79 | @Schema(description = "是否暂停(录像回放使用)") |
| 76 | 80 | private boolean pause; |
| 77 | 81 | |
| 78 | - public static class TransactionInfo{ | |
| 79 | - public String callId; | |
| 80 | - public String localTag; | |
| 81 | - public String remoteTag; | |
| 82 | - public String branch; | |
| 82 | + public void setFlv(StreamURL flv) { | |
| 83 | + this.flv = flv; | |
| 83 | 84 | } |
| 84 | 85 | |
| 85 | - private TransactionInfo transactionInfo; | |
| 86 | + public void setHttps_flv(StreamURL https_flv) { | |
| 87 | + this.https_flv = https_flv; | |
| 88 | + } | |
| 86 | 89 | |
| 87 | - public String getApp() { | |
| 88 | - return app; | |
| 90 | + public void setWs_flv(StreamURL ws_flv) { | |
| 91 | + this.ws_flv = ws_flv; | |
| 89 | 92 | } |
| 90 | 93 | |
| 91 | - public void setApp(String app) { | |
| 92 | - this.app = app; | |
| 94 | + public void setWss_flv(StreamURL wss_flv) { | |
| 95 | + this.wss_flv = wss_flv; | |
| 93 | 96 | } |
| 94 | 97 | |
| 95 | - public String getDeviceID() { | |
| 96 | - return deviceID; | |
| 98 | + public void setFmp4(StreamURL fmp4) { | |
| 99 | + this.fmp4 = fmp4; | |
| 97 | 100 | } |
| 98 | 101 | |
| 99 | - public void setDeviceID(String deviceID) { | |
| 100 | - this.deviceID = deviceID; | |
| 102 | + public void setHttps_fmp4(StreamURL https_fmp4) { | |
| 103 | + this.https_fmp4 = https_fmp4; | |
| 101 | 104 | } |
| 102 | 105 | |
| 103 | - public String getChannelId() { | |
| 104 | - return channelId; | |
| 106 | + public void setWs_fmp4(StreamURL ws_fmp4) { | |
| 107 | + this.ws_fmp4 = ws_fmp4; | |
| 105 | 108 | } |
| 106 | 109 | |
| 107 | - public void setChannelId(String channelId) { | |
| 108 | - this.channelId = channelId; | |
| 110 | + public void setWss_fmp4(StreamURL wss_fmp4) { | |
| 111 | + this.wss_fmp4 = wss_fmp4; | |
| 109 | 112 | } |
| 110 | 113 | |
| 111 | - public String getFlv() { | |
| 112 | - return flv; | |
| 114 | + public void setHls(StreamURL hls) { | |
| 115 | + this.hls = hls; | |
| 113 | 116 | } |
| 114 | 117 | |
| 115 | - public void setFlv(String flv) { | |
| 116 | - this.flv = flv; | |
| 118 | + public void setHttps_hls(StreamURL https_hls) { | |
| 119 | + this.https_hls = https_hls; | |
| 117 | 120 | } |
| 118 | 121 | |
| 119 | - public String getWs_flv() { | |
| 120 | - return ws_flv; | |
| 122 | + public void setWs_hls(StreamURL ws_hls) { | |
| 123 | + this.ws_hls = ws_hls; | |
| 121 | 124 | } |
| 122 | 125 | |
| 123 | - public void setWs_flv(String ws_flv) { | |
| 124 | - this.ws_flv = ws_flv; | |
| 126 | + public void setWss_hls(StreamURL wss_hls) { | |
| 127 | + this.wss_hls = wss_hls; | |
| 125 | 128 | } |
| 126 | 129 | |
| 127 | - public String getRtmp() { | |
| 128 | - return rtmp; | |
| 130 | + public void setTs(StreamURL ts) { | |
| 131 | + this.ts = ts; | |
| 129 | 132 | } |
| 130 | 133 | |
| 131 | - public void setRtmp(String rtmp) { | |
| 132 | - this.rtmp = rtmp; | |
| 134 | + public void setHttps_ts(StreamURL https_ts) { | |
| 135 | + this.https_ts = https_ts; | |
| 133 | 136 | } |
| 134 | 137 | |
| 135 | - public String getHls() { | |
| 136 | - return hls; | |
| 138 | + public void setWs_ts(StreamURL ws_ts) { | |
| 139 | + this.ws_ts = ws_ts; | |
| 137 | 140 | } |
| 138 | 141 | |
| 139 | - public void setHls(String hls) { | |
| 140 | - this.hls = hls; | |
| 142 | + public void setWss_ts(StreamURL wss_ts) { | |
| 143 | + this.wss_ts = wss_ts; | |
| 141 | 144 | } |
| 142 | 145 | |
| 143 | - public String getRtsp() { | |
| 144 | - return rtsp; | |
| 146 | + public void setRtmp(StreamURL rtmp) { | |
| 147 | + this.rtmp = rtmp; | |
| 145 | 148 | } |
| 146 | 149 | |
| 147 | - public void setRtsp(String rtsp) { | |
| 148 | - this.rtsp = rtsp; | |
| 150 | + public void setRtmps(StreamURL rtmps) { | |
| 151 | + this.rtmps = rtmps; | |
| 149 | 152 | } |
| 150 | 153 | |
| 151 | - public Object getTracks() { | |
| 152 | - return tracks; | |
| 154 | + public void setRtsp(StreamURL rtsp) { | |
| 155 | + this.rtsp = rtsp; | |
| 153 | 156 | } |
| 154 | 157 | |
| 155 | - public void setTracks(Object tracks) { | |
| 156 | - this.tracks = tracks; | |
| 158 | + public void setRtsps(StreamURL rtsps) { | |
| 159 | + this.rtsps = rtsps; | |
| 157 | 160 | } |
| 158 | 161 | |
| 159 | - public String getFmp4() { | |
| 160 | - return fmp4; | |
| 162 | + public void setRtc(StreamURL rtc) { | |
| 163 | + this.rtc = rtc; | |
| 161 | 164 | } |
| 162 | 165 | |
| 163 | - public void setFmp4(String fmp4) { | |
| 164 | - this.fmp4 = fmp4; | |
| 166 | + public void setRtcs(StreamURL rtcs) { | |
| 167 | + this.rtcs = rtcs; | |
| 165 | 168 | } |
| 166 | 169 | |
| 167 | - public String getWs_fmp4() { | |
| 168 | - return ws_fmp4; | |
| 170 | + public void setRtmp(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 171 | + String file = String.format("%s/%s/%s", app, stream, callIdParam); | |
| 172 | + this.rtmp = new StreamURL("rtmp", host, port, file); | |
| 173 | + if (sslPort != 0) { | |
| 174 | + this.rtmps = new StreamURL("rtmps", host, sslPort, file); | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + public void setRtsp(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 179 | + String file = String.format("%s/%s/%s", app, stream, callIdParam); | |
| 180 | + this.rtsp = new StreamURL("rtsp", host, port, file); | |
| 181 | + if (sslPort != 0) { | |
| 182 | + this.rtsps = new StreamURL("rtsps", host, sslPort, file); | |
| 183 | + } | |
| 184 | + } | |
| 185 | + | |
| 186 | + public void setFlv(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 187 | + String file = String.format("%s/%s.live.flv%s", app, stream, callIdParam); | |
| 188 | + this.flv = new StreamURL("http", host, port, file); | |
| 189 | + this.ws_flv = new StreamURL("ws", host, port, file); | |
| 190 | + if (sslPort != 0) { | |
| 191 | + this.https_flv = new StreamURL("https", host, sslPort, file); | |
| 192 | + this.wss_flv = new StreamURL("wss", host, sslPort, file); | |
| 193 | + } | |
| 194 | + } | |
| 195 | + | |
| 196 | + public void setFmp4(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 197 | + String file = String.format("%s/%s.live.mp4%s", app, stream, callIdParam); | |
| 198 | + this.fmp4 = new StreamURL("http", host, port, file); | |
| 199 | + this.ws_fmp4 = new StreamURL("ws", host, port, file); | |
| 200 | + if (sslPort != 0) { | |
| 201 | + this.https_fmp4 = new StreamURL("https", host, sslPort, file); | |
| 202 | + this.wss_fmp4 = new StreamURL("wss", host, sslPort, file); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + | |
| 206 | + public void setHls(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 207 | + String file = String.format("%s/%s/hls.m3u8%s", app, stream, callIdParam); | |
| 208 | + this.hls = new StreamURL("http", host, port, file); | |
| 209 | + this.ws_hls = new StreamURL("ws", host, port, file); | |
| 210 | + if (sslPort != 0) { | |
| 211 | + this.https_hls = new StreamURL("https", host, sslPort, file); | |
| 212 | + this.wss_hls = new StreamURL("wss", host, sslPort, file); | |
| 213 | + } | |
| 214 | + } | |
| 215 | + | |
| 216 | + public void setTs(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 217 | + String file = String.format("%s/%s.live.ts%s", app, stream, callIdParam); | |
| 218 | + this.ts = new StreamURL("http", host, port, file); | |
| 219 | + this.ws_ts = new StreamURL("ws", host, port, file); | |
| 220 | + if (sslPort != 0) { | |
| 221 | + this.https_ts = new StreamURL("https", host, sslPort, file); | |
| 222 | + this.wss_ts = new StreamURL("wss", host, sslPort, file); | |
| 223 | + } | |
| 224 | + } | |
| 225 | + | |
| 226 | + public void setRtc(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 227 | + String file = String.format("index/api/webrtc?app=%s&stream=%s&type=play%s", app, stream, callIdParam); | |
| 228 | + this.rtc = new StreamURL("http", host, port, file); | |
| 229 | + if (sslPort != 0) { | |
| 230 | + this.rtcs = new StreamURL("https", host, sslPort, file); | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 234 | + public void channgeStreamIp(String localAddr) { | |
| 235 | + this.flv.setHost(localAddr); | |
| 236 | + this.ws_flv.setHost(localAddr); | |
| 237 | + this.hls.setHost(localAddr); | |
| 238 | + this.ws_hls.setHost(localAddr); | |
| 239 | + this.ts.setHost(localAddr); | |
| 240 | + this.ws_ts.setHost(localAddr); | |
| 241 | + this.fmp4.setHost(localAddr); | |
| 242 | + this.ws_fmp4.setHost(localAddr); | |
| 243 | + this.rtc.setHost(localAddr); | |
| 244 | + if (this.https_flv != null) { | |
| 245 | + this.https_flv.setHost(localAddr); | |
| 246 | + this.wss_flv.setHost(localAddr); | |
| 247 | + this.https_hls.setHost(localAddr); | |
| 248 | + this.wss_hls.setHost(localAddr); | |
| 249 | + this.wss_ts.setHost(localAddr); | |
| 250 | + this.https_fmp4.setHost(localAddr); | |
| 251 | + this.wss_fmp4.setHost(localAddr); | |
| 252 | + this.rtcs.setHost(localAddr); | |
| 253 | + } | |
| 254 | + this.rtsp.setHost(localAddr); | |
| 255 | + if (this.rtsps != null) { | |
| 256 | + this.rtsps.setHost(localAddr); | |
| 257 | + } | |
| 258 | + this.rtmp.setHost(localAddr); | |
| 259 | + if (this.rtmps != null) { | |
| 260 | + this.rtmps.setHost(localAddr); | |
| 261 | + } | |
| 262 | + | |
| 169 | 263 | } |
| 170 | 264 | |
| 171 | - public void setWs_fmp4(String ws_fmp4) { | |
| 172 | - this.ws_fmp4 = ws_fmp4; | |
| 265 | + | |
| 266 | + public static class TransactionInfo{ | |
| 267 | + public String callId; | |
| 268 | + public String localTag; | |
| 269 | + public String remoteTag; | |
| 270 | + public String branch; | |
| 173 | 271 | } |
| 174 | 272 | |
| 175 | - public String getWs_hls() { | |
| 176 | - return ws_hls; | |
| 273 | + private TransactionInfo transactionInfo; | |
| 274 | + | |
| 275 | + public String getApp() { | |
| 276 | + return app; | |
| 177 | 277 | } |
| 178 | 278 | |
| 179 | - public void setWs_hls(String ws_hls) { | |
| 180 | - this.ws_hls = ws_hls; | |
| 279 | + public void setApp(String app) { | |
| 280 | + this.app = app; | |
| 181 | 281 | } |
| 182 | 282 | |
| 183 | - public String getTs() { | |
| 184 | - return ts; | |
| 283 | + public String getDeviceID() { | |
| 284 | + return deviceID; | |
| 185 | 285 | } |
| 186 | 286 | |
| 187 | - public void setTs(String ts) { | |
| 188 | - this.ts = ts; | |
| 287 | + public void setDeviceID(String deviceID) { | |
| 288 | + this.deviceID = deviceID; | |
| 189 | 289 | } |
| 190 | 290 | |
| 191 | - public String getWs_ts() { | |
| 192 | - return ws_ts; | |
| 291 | + public String getChannelId() { | |
| 292 | + return channelId; | |
| 193 | 293 | } |
| 194 | 294 | |
| 195 | - public void setWs_ts(String ws_ts) { | |
| 196 | - this.ws_ts = ws_ts; | |
| 295 | + public void setChannelId(String channelId) { | |
| 296 | + this.channelId = channelId; | |
| 197 | 297 | } |
| 198 | 298 | |
| 199 | 299 | public String getStream() { |
| ... | ... | @@ -204,110 +304,125 @@ public class StreamInfo { |
| 204 | 304 | this.stream = stream; |
| 205 | 305 | } |
| 206 | 306 | |
| 207 | - public String getRtc() { | |
| 208 | - return rtc; | |
| 307 | + public String getIp() { | |
| 308 | + return ip; | |
| 209 | 309 | } |
| 210 | 310 | |
| 211 | - public void setRtc(String rtc) { | |
| 212 | - this.rtc = rtc; | |
| 311 | + public void setIp(String ip) { | |
| 312 | + this.ip = ip; | |
| 213 | 313 | } |
| 214 | 314 | |
| 215 | - public TransactionInfo getTransactionInfo() { | |
| 216 | - return transactionInfo; | |
| 315 | + public StreamURL getFlv() { | |
| 316 | + return flv; | |
| 217 | 317 | } |
| 218 | 318 | |
| 219 | - public void setTransactionInfo(TransactionInfo transactionInfo) { | |
| 220 | - this.transactionInfo = transactionInfo; | |
| 319 | + public StreamURL getHttps_flv() { | |
| 320 | + return https_flv; | |
| 221 | 321 | } |
| 222 | 322 | |
| 223 | - public String getMediaServerId() { | |
| 224 | - return mediaServerId; | |
| 323 | + public StreamURL getWs_flv() { | |
| 324 | + return ws_flv; | |
| 225 | 325 | } |
| 226 | 326 | |
| 227 | - public void setMediaServerId(String mediaServerId) { | |
| 228 | - this.mediaServerId = mediaServerId; | |
| 229 | - } | |
| 230 | 327 | |
| 231 | - public String getHttps_flv() { | |
| 232 | - return https_flv; | |
| 328 | + public StreamURL getWss_flv() { | |
| 329 | + return wss_flv; | |
| 233 | 330 | } |
| 234 | 331 | |
| 235 | - public void setHttps_flv(String https_flv) { | |
| 236 | - this.https_flv = https_flv; | |
| 332 | + public StreamURL getFmp4() { | |
| 333 | + return fmp4; | |
| 237 | 334 | } |
| 238 | 335 | |
| 239 | - public String getWss_flv() { | |
| 240 | - return wss_flv; | |
| 336 | + | |
| 337 | + | |
| 338 | + public StreamURL getHttps_fmp4() { | |
| 339 | + return https_fmp4; | |
| 241 | 340 | } |
| 242 | 341 | |
| 243 | - public void setWss_flv(String wss_flv) { | |
| 244 | - this.wss_flv = wss_flv; | |
| 342 | + public StreamURL getWs_fmp4() { | |
| 343 | + return ws_fmp4; | |
| 245 | 344 | } |
| 246 | 345 | |
| 247 | - public String getWss_fmp4() { | |
| 346 | + public StreamURL getWss_fmp4() { | |
| 248 | 347 | return wss_fmp4; |
| 249 | 348 | } |
| 250 | 349 | |
| 251 | - public void setWss_fmp4(String wss_fmp4) { | |
| 252 | - this.wss_fmp4 = wss_fmp4; | |
| 350 | + public StreamURL getHls() { | |
| 351 | + return hls; | |
| 253 | 352 | } |
| 254 | 353 | |
| 255 | - public String getWss_hls() { | |
| 354 | + | |
| 355 | + public StreamURL getHttps_hls() { | |
| 356 | + return https_hls; | |
| 357 | + } | |
| 358 | + | |
| 359 | + public StreamURL getWs_hls() { | |
| 360 | + return ws_hls; | |
| 361 | + } | |
| 362 | + | |
| 363 | + public StreamURL getWss_hls() { | |
| 256 | 364 | return wss_hls; |
| 257 | 365 | } |
| 258 | 366 | |
| 259 | - public void setWss_hls(String wss_hls) { | |
| 260 | - this.wss_hls = wss_hls; | |
| 367 | + public StreamURL getTs() { | |
| 368 | + return ts; | |
| 261 | 369 | } |
| 262 | 370 | |
| 263 | - public String getWss_ts() { | |
| 264 | - return wss_ts; | |
| 371 | + | |
| 372 | + public StreamURL getHttps_ts() { | |
| 373 | + return https_ts; | |
| 265 | 374 | } |
| 266 | 375 | |
| 267 | - public void setWss_ts(String wss_ts) { | |
| 268 | - this.wss_ts = wss_ts; | |
| 376 | + | |
| 377 | + public StreamURL getWs_ts() { | |
| 378 | + return ws_ts; | |
| 269 | 379 | } |
| 270 | 380 | |
| 271 | - public String getRtmps() { | |
| 272 | - return rtmps; | |
| 381 | + | |
| 382 | + public StreamURL getWss_ts() { | |
| 383 | + return wss_ts; | |
| 273 | 384 | } |
| 274 | 385 | |
| 275 | - public void setRtmps(String rtmps) { | |
| 276 | - this.rtmps = rtmps; | |
| 386 | + | |
| 387 | + public StreamURL getRtmp() { | |
| 388 | + return rtmp; | |
| 277 | 389 | } |
| 278 | 390 | |
| 279 | - public String getRtsps() { | |
| 280 | - return rtsps; | |
| 391 | + public StreamURL getRtmps() { | |
| 392 | + return rtmps; | |
| 281 | 393 | } |
| 282 | 394 | |
| 283 | - public void setRtsps(String rtsps) { | |
| 284 | - this.rtsps = rtsps; | |
| 395 | + public StreamURL getRtsp() { | |
| 396 | + return rtsp; | |
| 285 | 397 | } |
| 286 | 398 | |
| 287 | - public String getHttps_hls() { | |
| 288 | - return https_hls; | |
| 399 | + public StreamURL getRtsps() { | |
| 400 | + return rtsps; | |
| 289 | 401 | } |
| 290 | 402 | |
| 291 | - public void setHttps_hls(String https_hls) { | |
| 292 | - this.https_hls = https_hls; | |
| 403 | + public StreamURL getRtc() { | |
| 404 | + return rtc; | |
| 293 | 405 | } |
| 294 | 406 | |
| 295 | - public String getHttps_fmp4() { | |
| 296 | - return https_fmp4; | |
| 407 | + public StreamURL getRtcs() { | |
| 408 | + return rtcs; | |
| 297 | 409 | } |
| 298 | 410 | |
| 299 | - public void setHttps_fmp4(String https_fmp4) { | |
| 300 | - this.https_fmp4 = https_fmp4; | |
| 411 | + public String getMediaServerId() { | |
| 412 | + return mediaServerId; | |
| 301 | 413 | } |
| 302 | 414 | |
| 303 | - public String getHttps_ts() { | |
| 304 | - return https_ts; | |
| 415 | + public void setMediaServerId(String mediaServerId) { | |
| 416 | + this.mediaServerId = mediaServerId; | |
| 305 | 417 | } |
| 306 | 418 | |
| 307 | - public void setHttps_ts(String https_ts) { | |
| 308 | - this.https_ts = https_ts; | |
| 419 | + public Object getTracks() { | |
| 420 | + return tracks; | |
| 309 | 421 | } |
| 310 | 422 | |
| 423 | + public void setTracks(Object tracks) { | |
| 424 | + this.tracks = tracks; | |
| 425 | + } | |
| 311 | 426 | |
| 312 | 427 | public String getStartTime() { |
| 313 | 428 | return startTime; |
| ... | ... | @@ -333,27 +448,30 @@ public class StreamInfo { |
| 333 | 448 | this.progress = progress; |
| 334 | 449 | } |
| 335 | 450 | |
| 336 | - public String getIp() { | |
| 337 | - return ip; | |
| 338 | - } | |
| 339 | - | |
| 340 | - public void setIp(String ip) { | |
| 341 | - this.ip = ip; | |
| 451 | + public boolean isPause() { | |
| 452 | + return pause; | |
| 342 | 453 | } |
| 343 | 454 | |
| 344 | - public String getRtcs() { | |
| 345 | - return rtcs; | |
| 455 | + public void setPause(boolean pause) { | |
| 456 | + this.pause = pause; | |
| 346 | 457 | } |
| 347 | 458 | |
| 348 | - public void setRtcs(String rtcs) { | |
| 349 | - this.rtcs = rtcs; | |
| 459 | + public TransactionInfo getTransactionInfo() { | |
| 460 | + return transactionInfo; | |
| 350 | 461 | } |
| 351 | 462 | |
| 352 | - public boolean isPause() { | |
| 353 | - return pause; | |
| 463 | + public void setTransactionInfo(TransactionInfo transactionInfo) { | |
| 464 | + this.transactionInfo = transactionInfo; | |
| 354 | 465 | } |
| 355 | 466 | |
| 356 | - public void setPause(boolean pause) { | |
| 357 | - this.pause = pause; | |
| 467 | + @Override | |
| 468 | + public StreamInfo clone() { | |
| 469 | + StreamInfo instance = null; | |
| 470 | + try{ | |
| 471 | + instance = (StreamInfo)super.clone(); | |
| 472 | + }catch(CloneNotSupportedException e) { | |
| 473 | + e.printStackTrace(); | |
| 474 | + } | |
| 475 | + return instance; | |
| 358 | 476 | } |
| 359 | 477 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/common/StreamURL.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.common; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | + | |
| 5 | +import java.io.Serializable; | |
| 6 | + | |
| 7 | + | |
| 8 | +@Schema(description = "流地址信息") | |
| 9 | +public class StreamURL implements Serializable { | |
| 10 | + | |
| 11 | + @Schema(description = "协议") | |
| 12 | + private String protocol; | |
| 13 | + | |
| 14 | + @Schema(description = "主机地址") | |
| 15 | + private String host; | |
| 16 | + | |
| 17 | + @Schema(description = "端口") | |
| 18 | + private int port = -1; | |
| 19 | + | |
| 20 | + @Schema(description = "定位位置") | |
| 21 | + private String file; | |
| 22 | + | |
| 23 | + @Schema(description = "拼接后的地址") | |
| 24 | + private String url; | |
| 25 | + | |
| 26 | + public StreamURL() { | |
| 27 | + } | |
| 28 | + | |
| 29 | + public StreamURL(String protocol, String host, int port, String file) { | |
| 30 | + this.protocol = protocol; | |
| 31 | + this.host = host; | |
| 32 | + this.port = port; | |
| 33 | + this.file = file; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public String getProtocol() { | |
| 37 | + return protocol; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void setProtocol(String protocol) { | |
| 41 | + this.protocol = protocol; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public String getHost() { | |
| 45 | + return host; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public void setHost(String host) { | |
| 49 | + this.host = host; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public int getPort() { | |
| 53 | + return port; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public void setPort(int port) { | |
| 57 | + this.port = port; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public String getFile() { | |
| 61 | + return file; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public void setFile(String file) { | |
| 65 | + this.file = file; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public String getUrl() { | |
| 69 | + return this.toString(); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + public String toString() { | |
| 74 | + if (protocol != null && host != null && port != -1 ) { | |
| 75 | + return String.format("%s://%s:%s/%s", protocol, host, port, file); | |
| 76 | + }else { | |
| 77 | + return null; | |
| 78 | + } | |
| 79 | + } | |
| 80 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
| ... | ... | @@ -127,11 +127,15 @@ public class DynamicTask { |
| 127 | 127 | public void execute(){ |
| 128 | 128 | if (futureMap.size() > 0) { |
| 129 | 129 | for (String key : futureMap.keySet()) { |
| 130 | - if (futureMap.get(key).isDone()) { | |
| 130 | + if (futureMap.get(key).isDone() || futureMap.get(key).isCancelled()) { | |
| 131 | 131 | futureMap.remove(key); |
| 132 | 132 | runnableMap.remove(key); |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | + | |
| 138 | + public boolean isAlive(String key) { | |
| 139 | + return futureMap.get(key) != null && !futureMap.get(key).isDone() && !futureMap.get(key).isCancelled(); | |
| 140 | + } | |
| 137 | 141 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
| ... | ... | @@ -25,7 +25,7 @@ public class MediaConfig{ |
| 25 | 25 | @Value("${media.ip}") |
| 26 | 26 | private String ip; |
| 27 | 27 | |
| 28 | - @Value("${media.hook-ip:${sip.ip}}") | |
| 28 | + @Value("${media.hook-ip:}") | |
| 29 | 29 | private String hookIp; |
| 30 | 30 | |
| 31 | 31 | @Value("${sip.ip}") |
| ... | ... | @@ -86,7 +86,7 @@ public class MediaConfig{ |
| 86 | 86 | |
| 87 | 87 | public String getHookIp() { |
| 88 | 88 | if (ObjectUtils.isEmpty(hookIp)){ |
| 89 | - return sipIp; | |
| 89 | + return sipIp.split(",")[0]; | |
| 90 | 90 | }else { |
| 91 | 91 | return hookIp; |
| 92 | 92 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
| ... | ... | @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.conf; |
| 3 | 3 | |
| 4 | 4 | import org.springframework.boot.context.properties.ConfigurationProperties; |
| 5 | 5 | import org.springframework.stereotype.Component; |
| 6 | +import org.springframework.util.ObjectUtils; | |
| 6 | 7 | |
| 7 | 8 | @Component |
| 8 | 9 | @ConfigurationProperties(prefix = "sip", ignoreInvalidFields = true) |
| ... | ... | @@ -10,11 +11,6 @@ public class SipConfig { |
| 10 | 11 | |
| 11 | 12 | private String ip; |
| 12 | 13 | |
| 13 | - /** | |
| 14 | - * 默认使用 0.0.0.0 | |
| 15 | - */ | |
| 16 | - private String monitorIp = "0.0.0.0"; | |
| 17 | - | |
| 18 | 14 | private Integer port; |
| 19 | 15 | |
| 20 | 16 | private String domain; |
| ... | ... | @@ -25,8 +21,6 @@ public class SipConfig { |
| 25 | 21 | |
| 26 | 22 | Integer ptzSpeed = 50; |
| 27 | 23 | |
| 28 | - Integer keepaliveTimeOut = 255; | |
| 29 | - | |
| 30 | 24 | Integer registerTimeInterval = 120; |
| 31 | 25 | |
| 32 | 26 | private boolean alarm; |
| ... | ... | @@ -35,10 +29,6 @@ public class SipConfig { |
| 35 | 29 | this.ip = ip; |
| 36 | 30 | } |
| 37 | 31 | |
| 38 | - public void setMonitorIp(String monitorIp) { | |
| 39 | - this.monitorIp = monitorIp; | |
| 40 | - } | |
| 41 | - | |
| 42 | 32 | public void setPort(Integer port) { |
| 43 | 33 | this.port = port; |
| 44 | 34 | } |
| ... | ... | @@ -59,18 +49,11 @@ public class SipConfig { |
| 59 | 49 | this.ptzSpeed = ptzSpeed; |
| 60 | 50 | } |
| 61 | 51 | |
| 62 | - public void setKeepaliveTimeOut(Integer keepaliveTimeOut) { | |
| 63 | - this.keepaliveTimeOut = keepaliveTimeOut; | |
| 64 | - } | |
| 65 | 52 | |
| 66 | 53 | public void setRegisterTimeInterval(Integer registerTimeInterval) { |
| 67 | 54 | this.registerTimeInterval = registerTimeInterval; |
| 68 | 55 | } |
| 69 | 56 | |
| 70 | - public String getMonitorIp() { | |
| 71 | - return monitorIp; | |
| 72 | - } | |
| 73 | - | |
| 74 | 57 | public String getIp() { |
| 75 | 58 | return ip; |
| 76 | 59 | } |
| ... | ... | @@ -99,10 +82,6 @@ public class SipConfig { |
| 99 | 82 | return ptzSpeed; |
| 100 | 83 | } |
| 101 | 84 | |
| 102 | - public Integer getKeepaliveTimeOut() { | |
| 103 | - return keepaliveTimeOut; | |
| 104 | - } | |
| 105 | - | |
| 106 | 85 | public Integer getRegisterTimeInterval() { |
| 107 | 86 | return registerTimeInterval; |
| 108 | 87 | } |
| ... | ... | @@ -114,4 +93,10 @@ public class SipConfig { |
| 114 | 93 | public void setAlarm(boolean alarm) { |
| 115 | 94 | this.alarm = alarm; |
| 116 | 95 | } |
| 96 | + | |
| 97 | + public void getLocalIp(String deviceLocalIp) { | |
| 98 | + if (ObjectUtils.isEmpty(deviceLocalIp)) { | |
| 99 | + | |
| 100 | + } | |
| 101 | + } | |
| 117 | 102 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
| ... | ... | @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.conf; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| 5 | -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | |
| 6 | 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 7 | 6 | import com.genersoft.iot.vmp.service.IPlatformService; |
| 8 | 7 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| ... | ... | @@ -47,7 +46,7 @@ public class SipPlatformRunner implements CommandLineRunner { |
| 47 | 46 | parentPlatformCatch.setId(parentPlatform.getServerGBId()); |
| 48 | 47 | redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); |
| 49 | 48 | // 设置所有平台离线 |
| 50 | - platformService.offline(parentPlatform); | |
| 49 | + platformService.offline(parentPlatform, true); | |
| 51 | 50 | // 取消订阅 |
| 52 | 51 | sipCommanderForPlatform.unregister(parentPlatform, null, (eventResult)->{ |
| 53 | 52 | platformService.login(parentPlatform); | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
| ... | ... | @@ -33,6 +33,8 @@ public class UserSetting { |
| 33 | 33 | |
| 34 | 34 | private Boolean usePushingAsStatus = Boolean.TRUE; |
| 35 | 35 | |
| 36 | + private Boolean useSourceIpAsStreamIp = Boolean.FALSE; | |
| 37 | + | |
| 36 | 38 | private Boolean streamOnDemand = Boolean.TRUE; |
| 37 | 39 | |
| 38 | 40 | private Boolean pushAuthority = Boolean.TRUE; |
| ... | ... | @@ -161,6 +163,14 @@ public class UserSetting { |
| 161 | 163 | this.streamOnDemand = streamOnDemand; |
| 162 | 164 | } |
| 163 | 165 | |
| 166 | + public Boolean getUseSourceIpAsStreamIp() { | |
| 167 | + return useSourceIpAsStreamIp; | |
| 168 | + } | |
| 169 | + | |
| 170 | + public void setUseSourceIpAsStreamIp(Boolean useSourceIpAsStreamIp) { | |
| 171 | + this.useSourceIpAsStreamIp = useSourceIpAsStreamIp; | |
| 172 | + } | |
| 173 | + | |
| 164 | 174 | public Boolean getPushAuthority() { |
| 165 | 175 | return pushAuthority; |
| 166 | 176 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
| ... | ... | @@ -8,16 +8,18 @@ import gov.nist.javax.sip.SipStackImpl; |
| 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.context.annotation.Bean; | |
| 12 | -import org.springframework.context.annotation.Configuration; | |
| 13 | -import org.springframework.context.annotation.DependsOn; | |
| 11 | +import org.springframework.boot.CommandLineRunner; | |
| 12 | +import org.springframework.core.annotation.Order; | |
| 13 | +import org.springframework.stereotype.Component; | |
| 14 | +import org.springframework.util.ObjectUtils; | |
| 14 | 15 | |
| 15 | 16 | import javax.sip.*; |
| 16 | -import java.util.Properties; | |
| 17 | -import java.util.TooManyListenersException; | |
| 17 | +import java.util.*; | |
| 18 | +import java.util.concurrent.ConcurrentHashMap; | |
| 18 | 19 | |
| 19 | -@Configuration | |
| 20 | -public class SipLayer{ | |
| 20 | +@Component | |
| 21 | +@Order(value=1) | |
| 22 | +public class SipLayer implements CommandLineRunner { | |
| 21 | 23 | |
| 22 | 24 | private final static Logger logger = LoggerFactory.getLogger(SipLayer.class); |
| 23 | 25 | |
| ... | ... | @@ -27,70 +29,117 @@ public class SipLayer{ |
| 27 | 29 | @Autowired |
| 28 | 30 | private ISIPProcessorObserver sipProcessorObserver; |
| 29 | 31 | |
| 30 | - private SipStackImpl sipStack; | |
| 32 | + | |
| 33 | + | |
| 34 | + private final Map<String, SipProviderImpl> tcpSipProviderMap = new ConcurrentHashMap<>(); | |
| 35 | + private final Map<String, SipProviderImpl> udpSipProviderMap = new ConcurrentHashMap<>(); | |
| 31 | 36 | |
| 32 | 37 | private SipFactory sipFactory; |
| 33 | 38 | |
| 39 | + @Override | |
| 40 | + public void run(String... args) { | |
| 41 | + List<String> monitorIps = new ArrayList<>(); | |
| 42 | + // 使用逗号分割多个ip | |
| 43 | + String separator = ","; | |
| 44 | + if (sipConfig.getIp().indexOf(separator) > 0) { | |
| 45 | + String[] split = sipConfig.getIp().split(separator); | |
| 46 | + monitorIps.addAll(Arrays.asList(split)); | |
| 47 | + }else { | |
| 48 | + monitorIps.add(sipConfig.getIp()); | |
| 49 | + } | |
| 34 | 50 | |
| 35 | - @Bean("sipFactory") | |
| 36 | - SipFactory createSipFactory() { | |
| 37 | 51 | sipFactory = SipFactory.getInstance(); |
| 38 | 52 | sipFactory.setPathName("gov.nist"); |
| 39 | - return sipFactory; | |
| 40 | - } | |
| 41 | - | |
| 42 | - @Bean("sipStack") | |
| 43 | - @DependsOn({"sipFactory"}) | |
| 44 | - SipStackImpl createSipStack() throws PeerUnavailableException { | |
| 45 | - sipStack = ( SipStackImpl )sipFactory.createSipStack(DefaultProperties.getProperties(sipConfig.getMonitorIp(), false)); | |
| 46 | - return sipStack; | |
| 53 | + if (monitorIps.size() > 0) { | |
| 54 | + for (String monitorIp : monitorIps) { | |
| 55 | + addListeningPoint(monitorIp, sipConfig.getPort()); | |
| 56 | + } | |
| 57 | + if (udpSipProviderMap.size() + tcpSipProviderMap.size() == 0) { | |
| 58 | + System.exit(1); | |
| 59 | + } | |
| 60 | + } | |
| 47 | 61 | } |
| 48 | 62 | |
| 49 | - @Bean(name = "tcpSipProvider") | |
| 50 | - @DependsOn("sipStack") | |
| 51 | - SipProviderImpl startTcpListener() { | |
| 52 | - ListeningPoint tcpListeningPoint = null; | |
| 53 | - SipProviderImpl tcpSipProvider = null; | |
| 63 | + private void addListeningPoint(String monitorIp, int port){ | |
| 64 | + SipStackImpl sipStack; | |
| 65 | + try { | |
| 66 | + sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties(monitorIp, false)); | |
| 67 | + } catch (PeerUnavailableException e) { | |
| 68 | + logger.error("[Sip Server] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp); | |
| 69 | + return; | |
| 70 | + } | |
| 71 | + | |
| 54 | 72 | try { |
| 55 | - tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "TCP"); | |
| 56 | - tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint); | |
| 73 | + ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "TCP"); | |
| 74 | + SipProviderImpl tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint); | |
| 75 | + | |
| 57 | 76 | tcpSipProvider.setDialogErrorsAutomaticallyHandled(); |
| 58 | 77 | tcpSipProvider.addSipListener(sipProcessorObserver); |
| 59 | - logger.info("[Sip Server] TCP 启动成功 {}:{}", sipConfig.getMonitorIp(), sipConfig.getPort()); | |
| 60 | - } catch (TransportNotSupportedException e) { | |
| 61 | - e.printStackTrace(); | |
| 62 | - } catch (InvalidArgumentException e) { | |
| 63 | - logger.error("[Sip Server] 无法使用 [ {}:{} ]作为SIP[ TCP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用" | |
| 64 | - , sipConfig.getMonitorIp(), sipConfig.getPort()); | |
| 65 | - } catch (TooManyListenersException e) { | |
| 66 | - e.printStackTrace(); | |
| 67 | - } catch (ObjectInUseException e) { | |
| 68 | - e.printStackTrace(); | |
| 78 | + tcpSipProviderMap.put(monitorIp, tcpSipProvider); | |
| 79 | + | |
| 80 | + logger.info("[Sip Server] tcp://{}:{} 启动成功", monitorIp, port); | |
| 81 | + } catch (TransportNotSupportedException | |
| 82 | + | TooManyListenersException | |
| 83 | + | ObjectInUseException | |
| 84 | + | InvalidArgumentException e) { | |
| 85 | + logger.error("[Sip Server] tcp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确" | |
| 86 | + , monitorIp, port); | |
| 69 | 87 | } |
| 70 | - return tcpSipProvider; | |
| 71 | - } | |
| 72 | - | |
| 73 | - @Bean(name = "udpSipProvider") | |
| 74 | - @DependsOn("sipStack") | |
| 75 | - SipProviderImpl startUdpListener() { | |
| 76 | - ListeningPoint udpListeningPoint = null; | |
| 77 | - SipProviderImpl udpSipProvider = null; | |
| 88 | + | |
| 78 | 89 | try { |
| 79 | - udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "UDP"); | |
| 80 | - udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint); | |
| 90 | + ListeningPoint udpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "UDP"); | |
| 91 | + | |
| 92 | + SipProviderImpl udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint); | |
| 81 | 93 | udpSipProvider.addSipListener(sipProcessorObserver); |
| 82 | - } catch (TransportNotSupportedException e) { | |
| 83 | - e.printStackTrace(); | |
| 84 | - } catch (InvalidArgumentException e) { | |
| 85 | - logger.error("[Sip Server] 无法使用 [ {}:{} ]作为SIP[ UDP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用" | |
| 86 | - , sipConfig.getMonitorIp(), sipConfig.getPort()); | |
| 87 | - } catch (TooManyListenersException e) { | |
| 88 | - e.printStackTrace(); | |
| 89 | - } catch (ObjectInUseException e) { | |
| 90 | - e.printStackTrace(); | |
| 94 | + | |
| 95 | + udpSipProviderMap.put(monitorIp, udpSipProvider); | |
| 96 | + | |
| 97 | + logger.info("[Sip Server] udp://{}:{} 启动成功", monitorIp, port); | |
| 98 | + } catch (TransportNotSupportedException | |
| 99 | + | TooManyListenersException | |
| 100 | + | ObjectInUseException | |
| 101 | + | InvalidArgumentException e) { | |
| 102 | + logger.error("[Sip Server] udp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确" | |
| 103 | + , monitorIp, port); | |
| 91 | 104 | } |
| 92 | - logger.info("[Sip Server] UDP 启动成功 {}:{}", sipConfig.getMonitorIp(), sipConfig.getPort()); | |
| 93 | - return udpSipProvider; | |
| 94 | 105 | } |
| 95 | 106 | |
| 107 | + public SipFactory getSipFactory() { | |
| 108 | + return sipFactory; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public SipProviderImpl getUdpSipProvider(String ip) { | |
| 112 | + if (ObjectUtils.isEmpty(ip)) { | |
| 113 | + return null; | |
| 114 | + } | |
| 115 | + return udpSipProviderMap.get(ip); | |
| 116 | + } | |
| 117 | + | |
| 118 | + public SipProviderImpl getUdpSipProvider() { | |
| 119 | + if (udpSipProviderMap.size() != 1) { | |
| 120 | + return null; | |
| 121 | + } | |
| 122 | + return udpSipProviderMap.values().stream().findFirst().get(); | |
| 123 | + } | |
| 124 | + | |
| 125 | + public SipProviderImpl getTcpSipProvider() { | |
| 126 | + if (tcpSipProviderMap.size() != 1) { | |
| 127 | + return null; | |
| 128 | + } | |
| 129 | + return tcpSipProviderMap.values().stream().findFirst().get(); | |
| 130 | + } | |
| 131 | + | |
| 132 | + public SipProviderImpl getTcpSipProvider(String ip) { | |
| 133 | + if (ObjectUtils.isEmpty(ip)) { | |
| 134 | + return null; | |
| 135 | + } | |
| 136 | + return tcpSipProviderMap.get(ip); | |
| 137 | + } | |
| 138 | + | |
| 139 | + public String getLocalIp(String deviceLocalIp) { | |
| 140 | + if (!ObjectUtils.isEmpty(deviceLocalIp)) { | |
| 141 | + return deviceLocalIp; | |
| 142 | + } | |
| 143 | + return getUdpSipProvider().getListeningPoint().getIPAddress(); | |
| 144 | + } | |
| 96 | 145 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
| ... | ... | @@ -178,6 +178,9 @@ public class Device { |
| 178 | 178 | @Schema(description = "收流IP") |
| 179 | 179 | private String sdpIp; |
| 180 | 180 | |
| 181 | + @Schema(description = "SIP交互IP(设备访问平台的IP)") | |
| 182 | + private String localIp; | |
| 183 | + | |
| 181 | 184 | |
| 182 | 185 | public String getDeviceId() { |
| 183 | 186 | return deviceId; |
| ... | ... | @@ -402,4 +405,12 @@ public class Device { |
| 402 | 405 | public void setSdpIp(String sdpIp) { |
| 403 | 406 | this.sdpIp = sdpIp; |
| 404 | 407 | } |
| 408 | + | |
| 409 | + public String getLocalIp() { | |
| 410 | + return localIp; | |
| 411 | + } | |
| 412 | + | |
| 413 | + public void setLocalIp(String localIp) { | |
| 414 | + this.localIp = localIp; | |
| 415 | + } | |
| 405 | 416 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java
| ... | ... | @@ -5,11 +5,9 @@ import org.slf4j.Logger; |
| 5 | 5 | import org.slf4j.LoggerFactory; |
| 6 | 6 | import org.springframework.context.ApplicationListener; |
| 7 | 7 | import org.springframework.stereotype.Component; |
| 8 | -import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; | |
| 9 | 8 | |
| 10 | -import java.util.HashMap; | |
| 11 | -import java.util.Hashtable; | |
| 12 | 9 | import java.util.Map; |
| 10 | +import java.util.concurrent.ConcurrentHashMap; | |
| 13 | 11 | |
| 14 | 12 | /** |
| 15 | 13 | * @description: 录像查询结束事件 |
| ... | ... | @@ -22,13 +20,12 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven |
| 22 | 20 | |
| 23 | 21 | private final static Logger logger = LoggerFactory.getLogger(RecordEndEventListener.class); |
| 24 | 22 | |
| 25 | - private static Map<String, SseEmitter> sseEmitters = new Hashtable<>(); | |
| 26 | - | |
| 27 | 23 | public interface RecordEndEventHandler{ |
| 28 | 24 | void handler(RecordInfo recordInfo); |
| 29 | 25 | } |
| 30 | 26 | |
| 31 | - private Map<String, RecordEndEventHandler> handlerMap = new HashMap<>(); | |
| 27 | + private Map<String, RecordEndEventHandler> handlerMap = new ConcurrentHashMap<>(); | |
| 28 | + | |
| 32 | 29 | @Override |
| 33 | 30 | public void onApplicationEvent(RecordEndEvent event) { |
| 34 | 31 | logger.info("录像查询完成事件触发,deviceId:{}, channelId: {}, 录像数量{}条", event.getRecordInfo().getDeviceId(), |
| ... | ... | @@ -38,7 +35,6 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven |
| 38 | 35 | recordEndEventHandler.handler(event.getRecordInfo()); |
| 39 | 36 | } |
| 40 | 37 | } |
| 41 | - | |
| 42 | 38 | } |
| 43 | 39 | |
| 44 | 40 | public void addEndEventHandler(String device, String channelId, RecordEndEventHandler recordEndEventHandler) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java
| ... | ... | @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor; |
| 8 | +import gov.nist.javax.sip.message.SIPRequest; | |
| 8 | 9 | import org.slf4j.Logger; |
| 9 | 10 | import org.slf4j.LoggerFactory; |
| 10 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -15,6 +16,7 @@ import javax.sip.*; |
| 15 | 16 | import javax.sip.header.*; |
| 16 | 17 | import javax.sip.message.Request; |
| 17 | 18 | import javax.sip.message.Response; |
| 19 | +import java.net.InetAddress; | |
| 18 | 20 | import java.util.Map; |
| 19 | 21 | import java.util.concurrent.ConcurrentHashMap; |
| 20 | 22 | |
| ... | ... | @@ -75,6 +77,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { |
| 75 | 77 | ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); |
| 76 | 78 | if (sipRequestProcessor == null) { |
| 77 | 79 | logger.warn("不支持方法{}的request", method); |
| 80 | + // TODO 回复错误玛 | |
| 78 | 81 | return; |
| 79 | 82 | } |
| 80 | 83 | requestProcessorMap.get(method).process(requestEvent); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit; |
| 2 | 2 | |
| 3 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 3 | 4 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 4 | 5 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 5 | 6 | import com.genersoft.iot.vmp.utils.GitUtil; |
| ... | ... | @@ -7,11 +8,10 @@ import gov.nist.javax.sip.SipProviderImpl; |
| 7 | 8 | import org.slf4j.Logger; |
| 8 | 9 | import org.slf4j.LoggerFactory; |
| 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | -import org.springframework.beans.factory.annotation.Qualifier; | |
| 11 | 11 | import org.springframework.stereotype.Component; |
| 12 | +import org.springframework.util.ObjectUtils; | |
| 12 | 13 | |
| 13 | 14 | import javax.sip.SipException; |
| 14 | -import javax.sip.SipFactory; | |
| 15 | 15 | import javax.sip.header.CallIdHeader; |
| 16 | 16 | import javax.sip.header.UserAgentHeader; |
| 17 | 17 | import javax.sip.header.ViaHeader; |
| ... | ... | @@ -30,15 +30,7 @@ public class SIPSender { |
| 30 | 30 | private final Logger logger = LoggerFactory.getLogger(SIPSender.class); |
| 31 | 31 | |
| 32 | 32 | @Autowired |
| 33 | - @Qualifier(value = "tcpSipProvider") | |
| 34 | - private SipProviderImpl tcpSipProvider; | |
| 35 | - | |
| 36 | - @Autowired | |
| 37 | - @Qualifier(value = "udpSipProvider") | |
| 38 | - private SipProviderImpl udpSipProvider; | |
| 39 | - | |
| 40 | - @Autowired | |
| 41 | - private SipFactory sipFactory; | |
| 33 | + private SipLayer sipLayer; | |
| 42 | 34 | |
| 43 | 35 | @Autowired |
| 44 | 36 | private GitUtil gitUtil; |
| ... | ... | @@ -46,25 +38,25 @@ public class SIPSender { |
| 46 | 38 | @Autowired |
| 47 | 39 | private SipSubscribe sipSubscribe; |
| 48 | 40 | |
| 49 | - public void transmitRequest(Message message) throws SipException, ParseException { | |
| 50 | - transmitRequest(message, null, null); | |
| 41 | + public void transmitRequest(String ip, Message message) throws SipException, ParseException { | |
| 42 | + transmitRequest(ip, message, null, null); | |
| 51 | 43 | } |
| 52 | 44 | |
| 53 | - public void transmitRequest(Message message, SipSubscribe.Event errorEvent) throws SipException, ParseException { | |
| 54 | - transmitRequest(message, errorEvent, null); | |
| 45 | + public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent) throws SipException, ParseException { | |
| 46 | + transmitRequest(ip, message, errorEvent, null); | |
| 55 | 47 | } |
| 56 | 48 | |
| 57 | - public void transmitRequest(Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException { | |
| 49 | + public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException { | |
| 58 | 50 | ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME); |
| 59 | 51 | String transport = "UDP"; |
| 60 | 52 | if (viaHeader == null) { |
| 61 | - logger.warn("[消息头缺失]: ViaHeader"); | |
| 53 | + logger.warn("[消息头缺失]: ViaHeader, 使用默认的UDP方式处理数据"); | |
| 62 | 54 | }else { |
| 63 | 55 | transport = viaHeader.getTransport(); |
| 64 | 56 | } |
| 65 | 57 | if (message.getHeader(UserAgentHeader.NAME) == null) { |
| 66 | 58 | try { |
| 67 | - message.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 59 | + message.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 68 | 60 | } catch (ParseException e) { |
| 69 | 61 | logger.error("添加UserAgentHeader失败", e); |
| 70 | 62 | } |
| ... | ... | @@ -88,6 +80,11 @@ public class SIPSender { |
| 88 | 80 | }); |
| 89 | 81 | } |
| 90 | 82 | if ("TCP".equals(transport)) { |
| 83 | + SipProviderImpl tcpSipProvider = sipLayer.getTcpSipProvider(ip); | |
| 84 | + if (tcpSipProvider == null) { | |
| 85 | + logger.error("[发送信息失败] 未找到tcp://{}的监听信息", ip); | |
| 86 | + return; | |
| 87 | + } | |
| 91 | 88 | if (message instanceof Request) { |
| 92 | 89 | tcpSipProvider.sendRequest((Request)message); |
| 93 | 90 | }else if (message instanceof Response) { |
| ... | ... | @@ -95,16 +92,41 @@ public class SIPSender { |
| 95 | 92 | } |
| 96 | 93 | |
| 97 | 94 | } else if ("UDP".equals(transport)) { |
| 95 | + SipProviderImpl sipProvider = sipLayer.getUdpSipProvider(ip); | |
| 96 | + if (sipProvider == null) { | |
| 97 | + logger.error("[发送信息失败] 未找到udp://{}的监听信息", ip); | |
| 98 | + return; | |
| 99 | + } | |
| 98 | 100 | if (message instanceof Request) { |
| 99 | - udpSipProvider.sendRequest((Request)message); | |
| 101 | + sipProvider.sendRequest((Request)message); | |
| 100 | 102 | }else if (message instanceof Response) { |
| 101 | - udpSipProvider.sendResponse((Response)message); | |
| 103 | + sipProvider.sendResponse((Response)message); | |
| 102 | 104 | } |
| 103 | 105 | } |
| 104 | 106 | } |
| 105 | 107 | |
| 106 | - public CallIdHeader getNewCallIdHeader(String transport){ | |
| 107 | - return transport.equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 108 | - : udpSipProvider.getNewCallId(); | |
| 108 | + public CallIdHeader getNewCallIdHeader(String ip, String transport){ | |
| 109 | + if (ObjectUtils.isEmpty(transport)) { | |
| 110 | + return sipLayer.getUdpSipProvider().getNewCallId(); | |
| 111 | + } | |
| 112 | + SipProviderImpl sipProvider; | |
| 113 | + if (ObjectUtils.isEmpty(ip)) { | |
| 114 | + sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider() | |
| 115 | + : sipLayer.getUdpSipProvider(); | |
| 116 | + }else { | |
| 117 | + sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider(ip) | |
| 118 | + : sipLayer.getUdpSipProvider(ip); | |
| 119 | + } | |
| 120 | + | |
| 121 | + if (sipProvider == null) { | |
| 122 | + sipProvider = sipLayer.getUdpSipProvider(); | |
| 123 | + } | |
| 124 | + | |
| 125 | + if (sipProvider != null) { | |
| 126 | + return sipProvider.getNewCallId(); | |
| 127 | + }else { | |
| 128 | + logger.warn("[新建CallIdHeader失败], ip={}, transport={}", ip, transport); | |
| 129 | + return null; | |
| 130 | + } | |
| 109 | 131 | } |
| 110 | 132 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.callback; |
| 2 | 2 | |
| 3 | -import java.util.HashMap; | |
| 3 | +import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx; | |
| 4 | +import org.springframework.stereotype.Component; | |
| 5 | +import org.springframework.util.ObjectUtils; | |
| 6 | +import org.springframework.web.context.request.async.DeferredResult; | |
| 7 | + | |
| 8 | +import java.util.Collection; | |
| 4 | 9 | import java.util.Map; |
| 5 | 10 | import java.util.Set; |
| 6 | 11 | import java.util.concurrent.ConcurrentHashMap; |
| 7 | 12 | |
| 8 | -import org.springframework.http.HttpStatus; | |
| 9 | -import org.springframework.http.ResponseEntity; | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | -import org.springframework.web.context.request.async.DeferredResult; | |
| 12 | - | |
| 13 | 13 | /** |
| 14 | 14 | * @description: 异步请求处理 |
| 15 | 15 | * @author: swwheihei |
| ... | ... | @@ -51,31 +51,48 @@ public class DeferredResultHolder { |
| 51 | 51 | |
| 52 | 52 | public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST"; |
| 53 | 53 | |
| 54 | - private Map<String, Map<String, DeferredResult>> map = new ConcurrentHashMap<>(); | |
| 54 | + private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>(); | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - public void put(String key, String id, DeferredResult result) { | |
| 58 | - Map<String, DeferredResult> deferredResultMap = map.get(key); | |
| 57 | + public void put(String key, String id, DeferredResultEx result) { | |
| 58 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 59 | 59 | if (deferredResultMap == null) { |
| 60 | 60 | deferredResultMap = new ConcurrentHashMap<>(); |
| 61 | 61 | map.put(key, deferredResultMap); |
| 62 | 62 | } |
| 63 | 63 | deferredResultMap.put(id, result); |
| 64 | 64 | } |
| 65 | - | |
| 66 | - public DeferredResult get(String key, String id) { | |
| 67 | - Map<String, DeferredResult> deferredResultMap = map.get(key); | |
| 65 | + | |
| 66 | + public void put(String key, String id, DeferredResult result) { | |
| 67 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 68 | 68 | if (deferredResultMap == null) { |
| 69 | + deferredResultMap = new ConcurrentHashMap<>(); | |
| 70 | + map.put(key, deferredResultMap); | |
| 71 | + } | |
| 72 | + deferredResultMap.put(id, new DeferredResultEx(result)); | |
| 73 | + } | |
| 74 | + | |
| 75 | + public DeferredResultEx get(String key, String id) { | |
| 76 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 77 | + if (deferredResultMap == null || ObjectUtils.isEmpty(id)) { | |
| 69 | 78 | return null; |
| 70 | 79 | } |
| 71 | 80 | return deferredResultMap.get(id); |
| 72 | 81 | } |
| 73 | 82 | |
| 83 | + public Collection<DeferredResultEx> getAllByKey(String key) { | |
| 84 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 85 | + if (deferredResultMap == null) { | |
| 86 | + return null; | |
| 87 | + } | |
| 88 | + return deferredResultMap.values(); | |
| 89 | + } | |
| 90 | + | |
| 74 | 91 | public boolean exist(String key, String id){ |
| 75 | 92 | if (key == null) { |
| 76 | 93 | return false; |
| 77 | 94 | } |
| 78 | - Map<String, DeferredResult> deferredResultMap = map.get(key); | |
| 95 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 79 | 96 | if (id == null) { |
| 80 | 97 | return deferredResultMap != null; |
| 81 | 98 | }else { |
| ... | ... | @@ -88,15 +105,15 @@ public class DeferredResultHolder { |
| 88 | 105 | * @param msg |
| 89 | 106 | */ |
| 90 | 107 | public void invokeResult(RequestMessage msg) { |
| 91 | - Map<String, DeferredResult> deferredResultMap = map.get(msg.getKey()); | |
| 108 | + Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey()); | |
| 92 | 109 | if (deferredResultMap == null) { |
| 93 | 110 | return; |
| 94 | 111 | } |
| 95 | - DeferredResult result = deferredResultMap.get(msg.getId()); | |
| 112 | + DeferredResultEx result = deferredResultMap.get(msg.getId()); | |
| 96 | 113 | if (result == null) { |
| 97 | 114 | return; |
| 98 | 115 | } |
| 99 | - result.setResult(msg.getData()); | |
| 116 | + result.getDeferredResult().setResult(msg.getData()); | |
| 100 | 117 | deferredResultMap.remove(msg.getId()); |
| 101 | 118 | if (deferredResultMap.size() == 0) { |
| 102 | 119 | map.remove(msg.getKey()); |
| ... | ... | @@ -108,18 +125,30 @@ public class DeferredResultHolder { |
| 108 | 125 | * @param msg |
| 109 | 126 | */ |
| 110 | 127 | public void invokeAllResult(RequestMessage msg) { |
| 111 | - Map<String, DeferredResult> deferredResultMap = map.get(msg.getKey()); | |
| 128 | + Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey()); | |
| 112 | 129 | if (deferredResultMap == null) { |
| 113 | 130 | return; |
| 114 | 131 | } |
| 115 | - Set<String> ids = deferredResultMap.keySet(); | |
| 116 | - for (String id : ids) { | |
| 117 | - DeferredResult result = deferredResultMap.get(id); | |
| 118 | - if (result == null) { | |
| 132 | + synchronized (this) { | |
| 133 | + deferredResultMap = map.get(msg.getKey()); | |
| 134 | + if (deferredResultMap == null) { | |
| 119 | 135 | return; |
| 120 | 136 | } |
| 121 | - result.setResult(msg.getData()); | |
| 137 | + Set<String> ids = deferredResultMap.keySet(); | |
| 138 | + for (String id : ids) { | |
| 139 | + DeferredResultEx result = deferredResultMap.get(id); | |
| 140 | + if (result == null) { | |
| 141 | + return; | |
| 142 | + } | |
| 143 | + if (result.getFilter() != null) { | |
| 144 | + Object handler = result.getFilter().handler(msg.getData()); | |
| 145 | + result.getDeferredResult().setResult(handler); | |
| 146 | + }else { | |
| 147 | + result.getDeferredResult().setResult(msg.getData()); | |
| 148 | + } | |
| 149 | + | |
| 150 | + } | |
| 151 | + map.remove(msg.getKey()); | |
| 122 | 152 | } |
| 123 | - map.remove(msg.getKey()); | |
| 124 | 153 | } |
| 125 | 154 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 4 | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | 6 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 6 | 7 | import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; |
| ... | ... | @@ -36,7 +37,7 @@ public class SIPRequestHeaderPlarformProvider { |
| 36 | 37 | private SipConfig sipConfig; |
| 37 | 38 | |
| 38 | 39 | @Autowired |
| 39 | - private SipFactory sipFactory; | |
| 40 | + private SipLayer sipLayer; | |
| 40 | 41 | |
| 41 | 42 | @Autowired |
| 42 | 43 | private GitUtil gitUtil; |
| ... | ... | @@ -44,42 +45,42 @@ public class SIPRequestHeaderPlarformProvider { |
| 44 | 45 | @Autowired |
| 45 | 46 | private IRedisCatchStorage redisCatchStorage; |
| 46 | 47 | |
| 47 | - public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader, boolean isRegister) throws ParseException, InvalidArgumentException, PeerUnavailableException { | |
| 48 | + public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader, boolean isRegister) throws ParseException, InvalidArgumentException, PeerUnavailableException { | |
| 48 | 49 | Request request = null; |
| 49 | - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); | |
| 50 | + String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); | |
| 50 | 51 | //请求行 |
| 51 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), | |
| 52 | - platform.getServerIP() + ":" + platform.getServerPort()); | |
| 52 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), | |
| 53 | + parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); | |
| 53 | 54 | //via |
| 54 | 55 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 55 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(platform.getServerIP(), platform.getServerPort(), platform.getTransport(), viaTag); | |
| 56 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getServerIP(), parentPlatform.getServerPort(), parentPlatform.getTransport(), viaTag); | |
| 56 | 57 | viaHeader.setRPort(); |
| 57 | 58 | viaHeaders.add(viaHeader); |
| 58 | 59 | //from |
| 59 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); | |
| 60 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 61 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 60 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); | |
| 61 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 62 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 62 | 63 | //to |
| 63 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); | |
| 64 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 65 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | |
| 64 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); | |
| 65 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 66 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); | |
| 66 | 67 | |
| 67 | 68 | //Forwards |
| 68 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 69 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 69 | 70 | |
| 70 | 71 | //ceq |
| 71 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER); | |
| 72 | - request = sipFactory.createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader, | |
| 72 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER); | |
| 73 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader, | |
| 73 | 74 | cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); |
| 74 | 75 | |
| 75 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory() | |
| 76 | - .createSipURI(platform.getDeviceGBId(), sipAddress)); | |
| 77 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 76 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() | |
| 77 | + .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); | |
| 78 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 78 | 79 | |
| 79 | - ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(isRegister ? platform.getExpires() : 0); | |
| 80 | + ExpiresHeader expires = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(isRegister ? parentPlatform.getExpires() : 0); | |
| 80 | 81 | request.addHeader(expires); |
| 81 | 82 | |
| 82 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 83 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 83 | 84 | |
| 84 | 85 | return request; |
| 85 | 86 | } |
| ... | ... | @@ -89,9 +90,9 @@ public class SIPRequestHeaderPlarformProvider { |
| 89 | 90 | |
| 90 | 91 | |
| 91 | 92 | Request registerRequest = createRegisterRequest(parentPlatform, redisCatchStorage.getCSEQ(), fromTag, viaTag, callIdHeader, isRegister); |
| 92 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); | |
| 93 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); | |
| 93 | 94 | if (www == null) { |
| 94 | - AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader("Digest"); | |
| 95 | + AuthorizationHeader authorizationHeader = sipLayer.getSipFactory().createHeaderFactory().createAuthorizationHeader("Digest"); | |
| 95 | 96 | authorizationHeader.setUsername(parentPlatform.getDeviceGBId()); |
| 96 | 97 | authorizationHeader.setURI(requestURI); |
| 97 | 98 | authorizationHeader.setAlgorithm("MD5"); |
| ... | ... | @@ -140,7 +141,7 @@ public class SIPRequestHeaderPlarformProvider { |
| 140 | 141 | |
| 141 | 142 | String RESPONSE = DigestUtils.md5DigestAsHex(reStr.toString().getBytes()); |
| 142 | 143 | |
| 143 | - AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader(scheme); | |
| 144 | + AuthorizationHeader authorizationHeader = sipLayer.getSipFactory().createHeaderFactory().createAuthorizationHeader(scheme); | |
| 144 | 145 | authorizationHeader.setUsername(parentPlatform.getDeviceGBId()); |
| 145 | 146 | authorizationHeader.setRealm(realm); |
| 146 | 147 | authorizationHeader.setNonce(nonce); |
| ... | ... | @@ -158,7 +159,7 @@ public class SIPRequestHeaderPlarformProvider { |
| 158 | 159 | } |
| 159 | 160 | |
| 160 | 161 | public Request createMessageRequest(ParentPlatform parentPlatform, String content, SendRtpItem sendRtpItem) throws PeerUnavailableException, ParseException, InvalidArgumentException { |
| 161 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); | |
| 162 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); | |
| 162 | 163 | return createMessageRequest(parentPlatform, content, sendRtpItem.getToTag(), SipUtils.getNewViaTag(), sendRtpItem.getFromTag(), callIdHeader); |
| 163 | 164 | } |
| 164 | 165 | |
| ... | ... | @@ -171,36 +172,36 @@ public class SIPRequestHeaderPlarformProvider { |
| 171 | 172 | Request request = null; |
| 172 | 173 | String serverAddress = parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort(); |
| 173 | 174 | // sipuri |
| 174 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); | |
| 175 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); | |
| 175 | 176 | // via |
| 176 | 177 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 177 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), | |
| 178 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), | |
| 178 | 179 | parentPlatform.getTransport(), viaTag); |
| 179 | 180 | viaHeader.setRPort(); |
| 180 | 181 | viaHeaders.add(viaHeader); |
| 181 | 182 | // from |
| 182 | - // SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDeviceIp()); | |
| 183 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); | |
| 184 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 185 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 183 | + // SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDeviceIp()); | |
| 184 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); | |
| 185 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 186 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 186 | 187 | // to |
| 187 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); | |
| 188 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 189 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); | |
| 188 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); | |
| 189 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 190 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, toTag); | |
| 190 | 191 | |
| 191 | 192 | // Forwards |
| 192 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 193 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 193 | 194 | // ceq |
| 194 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); | |
| 195 | - MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); | |
| 195 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); | |
| 196 | + MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); | |
| 196 | 197 | // 设置编码, 防止中文乱码 |
| 197 | 198 | messageFactory.setDefaultContentEncodingCharset(parentPlatform.getCharacterSet()); |
| 198 | 199 | request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, |
| 199 | 200 | toHeader, viaHeaders, maxForwards); |
| 200 | 201 | |
| 201 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 202 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 202 | 203 | |
| 203 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 204 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 204 | 205 | request.setContent(content, contentTypeHeader); |
| 205 | 206 | return request; |
| 206 | 207 | } |
| ... | ... | @@ -208,54 +209,54 @@ public class SIPRequestHeaderPlarformProvider { |
| 208 | 209 | public SIPRequest createNotifyRequest(ParentPlatform parentPlatform, String content, SubscribeInfo subscribeInfo) throws PeerUnavailableException, ParseException, InvalidArgumentException { |
| 209 | 210 | SIPRequest request = null; |
| 210 | 211 | // sipuri |
| 211 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort()); | |
| 212 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort()); | |
| 212 | 213 | // via |
| 213 | 214 | ArrayList<ViaHeader> viaHeaders = new ArrayList<>(); |
| 214 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), | |
| 215 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), | |
| 215 | 216 | parentPlatform.getTransport(), SipUtils.getNewViaTag()); |
| 216 | 217 | viaHeader.setRPort(); |
| 217 | 218 | viaHeaders.add(viaHeader); |
| 218 | 219 | // from |
| 219 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), | |
| 220 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), | |
| 220 | 221 | parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort()); |
| 221 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 222 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse().getToTag()); | |
| 222 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 223 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse().getToTag()); | |
| 223 | 224 | // to |
| 224 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); | |
| 225 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 226 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest().getFromTag()); | |
| 225 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); | |
| 226 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 227 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest().getFromTag()); | |
| 227 | 228 | |
| 228 | 229 | // Forwards |
| 229 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 230 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 230 | 231 | // ceq |
| 231 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.NOTIFY); | |
| 232 | - MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); | |
| 232 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.NOTIFY); | |
| 233 | + MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); | |
| 233 | 234 | // 设置编码, 防止中文乱码 |
| 234 | 235 | messageFactory.setDefaultContentEncodingCharset("gb2312"); |
| 235 | 236 | |
| 236 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest().getCallIdHeader().getCallId()); | |
| 237 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest().getCallIdHeader().getCallId()); | |
| 237 | 238 | |
| 238 | 239 | request = (SIPRequest) messageFactory.createRequest(requestURI, Request.NOTIFY, callIdHeader, cSeqHeader, fromHeader, |
| 239 | 240 | toHeader, viaHeaders, maxForwards); |
| 240 | 241 | |
| 241 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 242 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 242 | 243 | |
| 243 | - EventHeader event = sipFactory.createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); | |
| 244 | + EventHeader event = sipLayer.getSipFactory().createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); | |
| 244 | 245 | if (subscribeInfo.getEventId() != null) { |
| 245 | 246 | event.setEventId(subscribeInfo.getEventId()); |
| 246 | 247 | } |
| 247 | 248 | |
| 248 | 249 | request.addHeader(event); |
| 249 | 250 | |
| 250 | - SubscriptionStateHeader active = sipFactory.createHeaderFactory().createSubscriptionStateHeader("active"); | |
| 251 | + SubscriptionStateHeader active = sipLayer.getSipFactory().createHeaderFactory().createSubscriptionStateHeader("active"); | |
| 251 | 252 | request.setHeader(active); |
| 252 | 253 | |
| 253 | - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); | |
| 254 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory() | |
| 254 | + String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); | |
| 255 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() | |
| 255 | 256 | .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); |
| 256 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 257 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 257 | 258 | |
| 258 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 259 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 259 | 260 | request.setContent(content, contentTypeHeader); |
| 260 | 261 | return request; |
| 261 | 262 | } |
| ... | ... | @@ -268,42 +269,42 @@ public class SIPRequestHeaderPlarformProvider { |
| 268 | 269 | |
| 269 | 270 | SIPRequest request = null; |
| 270 | 271 | // sipuri |
| 271 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+ ":" + platform.getServerPort()); | |
| 272 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+ ":" + platform.getServerPort()); | |
| 272 | 273 | // via |
| 273 | 274 | ArrayList<ViaHeader> viaHeaders = new ArrayList<>(); |
| 274 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(platform.getDeviceIp(), Integer.parseInt(platform.getDevicePort()), | |
| 275 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(platform.getDeviceIp(), Integer.parseInt(platform.getDevicePort()), | |
| 275 | 276 | platform.getTransport(), SipUtils.getNewViaTag()); |
| 276 | 277 | viaHeader.setRPort(); |
| 277 | 278 | viaHeaders.add(viaHeader); |
| 278 | 279 | // from |
| 279 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), | |
| 280 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(), | |
| 280 | 281 | platform.getDeviceIp() + ":" + platform.getDevicePort()); |
| 281 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 282 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, sendRtpItem.getToTag()); | |
| 282 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 283 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, sendRtpItem.getToTag()); | |
| 283 | 284 | // to |
| 284 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerGBDomain()); | |
| 285 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 286 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, sendRtpItem.getFromTag()); | |
| 285 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerGBDomain()); | |
| 286 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 287 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, sendRtpItem.getFromTag()); | |
| 287 | 288 | |
| 288 | 289 | // Forwards |
| 289 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 290 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 290 | 291 | // ceq |
| 291 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); | |
| 292 | - MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); | |
| 292 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); | |
| 293 | + MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); | |
| 293 | 294 | // 设置编码, 防止中文乱码 |
| 294 | 295 | messageFactory.setDefaultContentEncodingCharset("gb2312"); |
| 295 | 296 | |
| 296 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); | |
| 297 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); | |
| 297 | 298 | |
| 298 | 299 | request = (SIPRequest) messageFactory.createRequest(requestURI, Request.BYE, callIdHeader, cSeqHeader, fromHeader, |
| 299 | 300 | toHeader, viaHeaders, maxForwards); |
| 300 | 301 | |
| 301 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 302 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 302 | 303 | |
| 303 | - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); | |
| 304 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory() | |
| 304 | + String sipAddress = platform.getDeviceIp() + ":" + platform.getDevicePort(); | |
| 305 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() | |
| 305 | 306 | .createSipURI(platform.getDeviceGBId(), sipAddress)); |
| 306 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 307 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 307 | 308 | |
| 308 | 309 | return request; |
| 309 | 310 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd; |
| 2 | 2 | |
| 3 | -import java.text.ParseException; | |
| 4 | -import java.util.ArrayList; | |
| 5 | - | |
| 6 | -import javax.sip.*; | |
| 7 | -import javax.sip.address.Address; | |
| 8 | -import javax.sip.address.SipURI; | |
| 9 | -import javax.sip.header.*; | |
| 10 | -import javax.sip.message.Request; | |
| 11 | - | |
| 12 | -import com.genersoft.iot.vmp.common.StreamInfo; | |
| 13 | -import com.genersoft.iot.vmp.gb28181.bean.SipMsgInfo; | |
| 3 | +import com.genersoft.iot.vmp.conf.SipConfig; | |
| 4 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 14 | 6 | import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; |
| 15 | -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; | |
| 16 | 7 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 17 | 8 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 18 | 9 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 19 | 10 | import com.genersoft.iot.vmp.utils.GitUtil; |
| 20 | -import gov.nist.javax.sip.SipProviderImpl; | |
| 21 | -import gov.nist.javax.sip.SipStackImpl; | |
| 22 | 11 | import gov.nist.javax.sip.message.SIPRequest; |
| 23 | 12 | import gov.nist.javax.sip.message.SIPResponse; |
| 24 | -import gov.nist.javax.sip.stack.SIPDialog; | |
| 25 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | -import org.springframework.beans.factory.annotation.Qualifier; | |
| 27 | 14 | import org.springframework.stereotype.Component; |
| 28 | 15 | |
| 29 | -import com.genersoft.iot.vmp.conf.SipConfig; | |
| 30 | -import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 16 | +import javax.sip.InvalidArgumentException; | |
| 17 | +import javax.sip.PeerUnavailableException; | |
| 18 | +import javax.sip.SipException; | |
| 19 | +import javax.sip.address.Address; | |
| 20 | +import javax.sip.address.SipURI; | |
| 21 | +import javax.sip.header.*; | |
| 22 | +import javax.sip.message.Request; | |
| 23 | +import java.text.ParseException; | |
| 24 | +import java.util.ArrayList; | |
| 31 | 25 | |
| 32 | 26 | /** |
| 33 | 27 | * @description:摄像头命令request创造器 TODO 冗余代码太多待优化 |
| ... | ... | @@ -41,7 +35,7 @@ public class SIPRequestHeaderProvider { |
| 41 | 35 | private SipConfig sipConfig; |
| 42 | 36 | |
| 43 | 37 | @Autowired |
| 44 | - private SipFactory sipFactory; | |
| 38 | + private SipLayer sipLayer; | |
| 45 | 39 | |
| 46 | 40 | @Autowired |
| 47 | 41 | private GitUtil gitUtil; |
| ... | ... | @@ -55,32 +49,32 @@ public class SIPRequestHeaderProvider { |
| 55 | 49 | public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 56 | 50 | Request request = null; |
| 57 | 51 | // sipuri |
| 58 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 52 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 59 | 53 | // via |
| 60 | 54 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 61 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 55 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 62 | 56 | viaHeader.setRPort(); |
| 63 | 57 | viaHeaders.add(viaHeader); |
| 64 | 58 | // from |
| 65 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 66 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 67 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 59 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 60 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 61 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 68 | 62 | // to |
| 69 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 70 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 71 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); | |
| 63 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 64 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 65 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, toTag); | |
| 72 | 66 | |
| 73 | 67 | // Forwards |
| 74 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 68 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 75 | 69 | // ceq |
| 76 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); | |
| 70 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); | |
| 77 | 71 | |
| 78 | - request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, | |
| 72 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, | |
| 79 | 73 | toHeader, viaHeaders, maxForwards); |
| 80 | 74 | |
| 81 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 75 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 82 | 76 | |
| 83 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 77 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 84 | 78 | request.setContent(content, contentTypeHeader); |
| 85 | 79 | return request; |
| 86 | 80 | } |
| ... | ... | @@ -88,38 +82,39 @@ public class SIPRequestHeaderProvider { |
| 88 | 82 | public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 89 | 83 | Request request = null; |
| 90 | 84 | //请求行 |
| 91 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 85 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 92 | 86 | //via |
| 93 | 87 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 94 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 88 | + HeaderFactory headerFactory = sipLayer.getSipFactory().createHeaderFactory(); | |
| 89 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 95 | 90 | viaHeader.setRPort(); |
| 96 | 91 | viaHeaders.add(viaHeader); |
| 97 | 92 | |
| 98 | 93 | //from |
| 99 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 100 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 101 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | |
| 94 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 95 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 96 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | |
| 102 | 97 | //to |
| 103 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 104 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 105 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | |
| 98 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 99 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 100 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); | |
| 106 | 101 | |
| 107 | 102 | //Forwards |
| 108 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 103 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 109 | 104 | |
| 110 | 105 | //ceq |
| 111 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); | |
| 112 | - request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 106 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); | |
| 107 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 113 | 108 | |
| 114 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 109 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 115 | 110 | |
| 116 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 117 | - // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | |
| 118 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 111 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 112 | + // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | |
| 113 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 119 | 114 | // Subject |
| 120 | - SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); | |
| 115 | + SubjectHeader subjectHeader = sipLayer.getSipFactory().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); | |
| 121 | 116 | request.addHeader(subjectHeader); |
| 122 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | |
| 117 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | |
| 123 | 118 | request.setContent(content, contentTypeHeader); |
| 124 | 119 | return request; |
| 125 | 120 | } |
| ... | ... | @@ -127,39 +122,39 @@ public class SIPRequestHeaderProvider { |
| 127 | 122 | public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 128 | 123 | Request request = null; |
| 129 | 124 | //请求行 |
| 130 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 125 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 131 | 126 | // via |
| 132 | 127 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 133 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 128 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 134 | 129 | viaHeader.setRPort(); |
| 135 | 130 | viaHeaders.add(viaHeader); |
| 136 | 131 | //from |
| 137 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 138 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 139 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | |
| 132 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 133 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 134 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | |
| 140 | 135 | //to |
| 141 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 142 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 143 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | |
| 136 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 137 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 138 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); | |
| 144 | 139 | |
| 145 | 140 | //Forwards |
| 146 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 141 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 147 | 142 | |
| 148 | 143 | //ceq |
| 149 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); | |
| 150 | - request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 144 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); | |
| 145 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 151 | 146 | |
| 152 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 153 | - // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | |
| 154 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 147 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 148 | + // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | |
| 149 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 155 | 150 | |
| 156 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 151 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 157 | 152 | |
| 158 | 153 | // Subject |
| 159 | - SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); | |
| 154 | + SubjectHeader subjectHeader = sipLayer.getSipFactory().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); | |
| 160 | 155 | request.addHeader(subjectHeader); |
| 161 | 156 | |
| 162 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | |
| 157 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | |
| 163 | 158 | request.setContent(content, contentTypeHeader); |
| 164 | 159 | return request; |
| 165 | 160 | } |
| ... | ... | @@ -167,34 +162,34 @@ public class SIPRequestHeaderProvider { |
| 167 | 162 | public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 168 | 163 | Request request = null; |
| 169 | 164 | //请求行 |
| 170 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 165 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 171 | 166 | // via |
| 172 | 167 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 173 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | |
| 168 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | |
| 174 | 169 | viaHeaders.add(viaHeader); |
| 175 | 170 | //from |
| 176 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | |
| 177 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 178 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); | |
| 171 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | |
| 172 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 173 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); | |
| 179 | 174 | //to |
| 180 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,device.getHostAddress()); | |
| 181 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 182 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); | |
| 175 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress()); | |
| 176 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 177 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); | |
| 183 | 178 | |
| 184 | 179 | //Forwards |
| 185 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 180 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 186 | 181 | |
| 187 | 182 | //ceq |
| 188 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); | |
| 189 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); | |
| 190 | - request = sipFactory.createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 183 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); | |
| 184 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); | |
| 185 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 191 | 186 | |
| 192 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 187 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 193 | 188 | |
| 194 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 195 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 189 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 190 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 196 | 191 | |
| 197 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 192 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 198 | 193 | |
| 199 | 194 | return request; |
| 200 | 195 | } |
| ... | ... | @@ -202,50 +197,50 @@ public class SIPRequestHeaderProvider { |
| 202 | 197 | public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 203 | 198 | Request request = null; |
| 204 | 199 | // sipuri |
| 205 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 200 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 206 | 201 | // via |
| 207 | 202 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 208 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), | |
| 203 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), | |
| 209 | 204 | device.getTransport(), SipUtils.getNewViaTag()); |
| 210 | 205 | viaHeader.setRPort(); |
| 211 | 206 | viaHeaders.add(viaHeader); |
| 212 | 207 | // from |
| 213 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 214 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 215 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag()); | |
| 208 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 209 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 210 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag()); | |
| 216 | 211 | // to |
| 217 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 218 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 219 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag()); | |
| 212 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 213 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 214 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag()); | |
| 220 | 215 | |
| 221 | 216 | // Forwards |
| 222 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 217 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 223 | 218 | |
| 224 | 219 | // ceq |
| 225 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE); | |
| 220 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE); | |
| 226 | 221 | |
| 227 | - request = sipFactory.createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader, | |
| 222 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader, | |
| 228 | 223 | toHeader, viaHeaders, maxForwards); |
| 229 | 224 | |
| 230 | 225 | |
| 231 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 232 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 226 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 227 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 233 | 228 | |
| 234 | 229 | // Expires |
| 235 | - ExpiresHeader expireHeader = sipFactory.createHeaderFactory().createExpiresHeader(expires); | |
| 230 | + ExpiresHeader expireHeader = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(expires); | |
| 236 | 231 | request.addHeader(expireHeader); |
| 237 | 232 | |
| 238 | 233 | // Event |
| 239 | - EventHeader eventHeader = sipFactory.createHeaderFactory().createEventHeader(event); | |
| 234 | + EventHeader eventHeader = sipLayer.getSipFactory().createHeaderFactory().createEventHeader(event); | |
| 240 | 235 | |
| 241 | 236 | int random = (int) Math.floor(Math.random() * 10000); |
| 242 | 237 | eventHeader.setEventId(random + ""); |
| 243 | 238 | request.addHeader(eventHeader); |
| 244 | 239 | |
| 245 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 240 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 246 | 241 | request.setContent(content, contentTypeHeader); |
| 247 | 242 | |
| 248 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 243 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 249 | 244 | |
| 250 | 245 | return request; |
| 251 | 246 | } |
| ... | ... | @@ -257,64 +252,65 @@ public class SIPRequestHeaderProvider { |
| 257 | 252 | } |
| 258 | 253 | SIPRequest request = null; |
| 259 | 254 | //请求行 |
| 260 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 255 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 261 | 256 | // via |
| 262 | 257 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 263 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | |
| 258 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | |
| 264 | 259 | viaHeaders.add(viaHeader); |
| 265 | 260 | //from |
| 266 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | |
| 267 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 268 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); | |
| 261 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | |
| 262 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 263 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); | |
| 269 | 264 | //to |
| 270 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,device.getHostAddress()); | |
| 271 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 272 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); | |
| 265 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress()); | |
| 266 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 267 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); | |
| 273 | 268 | |
| 274 | 269 | //Forwards |
| 275 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 270 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 276 | 271 | |
| 277 | 272 | //ceq |
| 278 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO); | |
| 279 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); | |
| 280 | - request = (SIPRequest)sipFactory.createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 273 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO); | |
| 274 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); | |
| 275 | + request = (SIPRequest)sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 281 | 276 | |
| 282 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 277 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 283 | 278 | |
| 284 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 285 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 279 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 280 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 286 | 281 | |
| 287 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 282 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 288 | 283 | |
| 289 | 284 | if (content != null) { |
| 290 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", | |
| 285 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", | |
| 291 | 286 | "MANSRTSP"); |
| 292 | 287 | request.setContent(content, contentTypeHeader); |
| 293 | 288 | } |
| 294 | 289 | return request; |
| 295 | 290 | } |
| 296 | 291 | |
| 297 | - public Request createAckRequest(SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException { | |
| 292 | + public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException { | |
| 293 | + | |
| 298 | 294 | |
| 299 | 295 | // via |
| 300 | 296 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 301 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag()); | |
| 297 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag()); | |
| 302 | 298 | viaHeaders.add(viaHeader); |
| 303 | 299 | |
| 304 | 300 | //Forwards |
| 305 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 301 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 306 | 302 | |
| 307 | 303 | //ceq |
| 308 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK); | |
| 304 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK); | |
| 309 | 305 | |
| 310 | - Request request = sipFactory.createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards); | |
| 306 | + Request request = sipLayer.getSipFactory().createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards); | |
| 311 | 307 | |
| 312 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 308 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 313 | 309 | |
| 314 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 315 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 310 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort())); | |
| 311 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 316 | 312 | |
| 317 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 313 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 318 | 314 | |
| 319 | 315 | return request; |
| 320 | 316 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| ... | ... | @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | 7 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 8 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 8 | 9 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 9 | 10 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 10 | 11 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| ... | ... | @@ -32,7 +33,6 @@ import org.springframework.util.ObjectUtils; |
| 32 | 33 | import javax.sip.InvalidArgumentException; |
| 33 | 34 | import javax.sip.ResponseEvent; |
| 34 | 35 | import javax.sip.SipException; |
| 35 | -import javax.sip.SipFactory; | |
| 36 | 36 | import javax.sip.header.CallIdHeader; |
| 37 | 37 | import javax.sip.message.Request; |
| 38 | 38 | import java.text.ParseException; |
| ... | ... | @@ -52,7 +52,7 @@ public class SIPCommander implements ISIPCommander { |
| 52 | 52 | private SipConfig sipConfig; |
| 53 | 53 | |
| 54 | 54 | @Autowired |
| 55 | - private SipFactory sipFactory; | |
| 55 | + private SipLayer sipLayer; | |
| 56 | 56 | |
| 57 | 57 | @Autowired |
| 58 | 58 | private SIPSender sipSender; |
| ... | ... | @@ -181,9 +181,9 @@ public class SIPCommander implements ISIPCommander { |
| 181 | 181 | ptzXml.append("</Info>\r\n"); |
| 182 | 182 | ptzXml.append("</Control>\r\n"); |
| 183 | 183 | |
| 184 | - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(device.getTransport())); | |
| 184 | + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 185 | 185 | |
| 186 | - sipSender.transmitRequest( request); | |
| 186 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); | |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
| ... | ... | @@ -216,8 +216,8 @@ public class SIPCommander implements ISIPCommander { |
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | |
| 219 | - SIPRequest request = (SIPRequest) headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 220 | - sipSender.transmitRequest(request); | |
| 219 | + SIPRequest request = (SIPRequest) headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 220 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); | |
| 221 | 221 | |
| 222 | 222 | } |
| 223 | 223 | |
| ... | ... | @@ -245,8 +245,8 @@ public class SIPCommander implements ISIPCommander { |
| 245 | 245 | ptzXml.append("</Control>\r\n"); |
| 246 | 246 | |
| 247 | 247 | |
| 248 | - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 249 | - sipSender.transmitRequest(request, errorEvent, okEvent); | |
| 248 | + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 249 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request, errorEvent, okEvent); | |
| 250 | 250 | |
| 251 | 251 | } |
| 252 | 252 | |
| ... | ... | @@ -340,8 +340,8 @@ public class SIPCommander implements ISIPCommander { |
| 340 | 340 | |
| 341 | 341 | |
| 342 | 342 | |
| 343 | - Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(device.getTransport())); | |
| 344 | - sipSender.transmitRequest( request, (e -> { | |
| 343 | + Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 344 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, (e -> { | |
| 345 | 345 | streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); |
| 346 | 346 | mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); |
| 347 | 347 | errorEvent.response(e); |
| ... | ... | @@ -423,36 +423,39 @@ public class SIPCommander implements ISIPCommander { |
| 423 | 423 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); |
| 424 | 424 | content.append("a=rtpmap:98 H264/90000\r\n"); |
| 425 | 425 | content.append("a=rtpmap:99 H265/90000\r\n"); |
| 426 | - if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { // tcp被动模式 | |
| 426 | + if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { | |
| 427 | + // tcp被动模式 | |
| 427 | 428 | content.append("a=setup:passive\r\n"); |
| 428 | 429 | content.append("a=connection:new\r\n"); |
| 429 | - } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { // tcp主动模式 | |
| 430 | + } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { | |
| 431 | + // tcp主动模式 | |
| 430 | 432 | content.append("a=setup:active\r\n"); |
| 431 | 433 | content.append("a=connection:new\r\n"); |
| 432 | 434 | } |
| 433 | 435 | } |
| 434 | 436 | |
| 435 | - content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc | |
| 437 | + //ssrc | |
| 438 | + content.append("y=" + ssrcInfo.getSsrc() + "\r\n"); | |
| 436 | 439 | |
| 437 | 440 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); |
| 438 | 441 | // 添加订阅 |
| 439 | 442 | subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { |
| 440 | 443 | if (hookEvent != null) { |
| 441 | - InviteStreamInfo inviteStreamInfo = new InviteStreamInfo(mediaServerItemInUse, json,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()); | |
| 444 | + InviteStreamInfo inviteStreamInfo = new InviteStreamInfo(mediaServerItemInUse, json,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()); | |
| 442 | 445 | hookEvent.call(inviteStreamInfo); |
| 443 | 446 | } |
| 444 | 447 | subscribe.removeSubscribe(hookSubscribe); |
| 445 | 448 | }); |
| 446 | - Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()), ssrcInfo.getSsrc()); | |
| 449 | + Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()), ssrcInfo.getSsrc()); | |
| 447 | 450 | |
| 448 | - sipSender.transmitRequest( request, errorEvent, event -> { | |
| 451 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, event -> { | |
| 449 | 452 | ResponseEvent responseEvent = (ResponseEvent) event.event; |
| 450 | 453 | SIPResponse response = (SIPResponse) responseEvent.getResponse(); |
| 451 | - streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.playback); | |
| 454 | + streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.playback); | |
| 452 | 455 | okEvent.response(event); |
| 453 | 456 | }); |
| 454 | 457 | if (inviteStreamCallback != null) { |
| 455 | - inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); | |
| 458 | + inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); | |
| 456 | 459 | } |
| 457 | 460 | } |
| 458 | 461 | |
| ... | ... | @@ -541,7 +544,7 @@ public class SIPCommander implements ISIPCommander { |
| 541 | 544 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, null, mediaServerItem.getId()); |
| 542 | 545 | // 添加订阅 |
| 543 | 546 | subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { |
| 544 | - hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); | |
| 547 | + hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); | |
| 545 | 548 | subscribe.removeSubscribe(hookSubscribe); |
| 546 | 549 | hookSubscribe.getContent().put("regist", false); |
| 547 | 550 | hookSubscribe.getContent().put("schema", "rtsp"); |
| ... | ... | @@ -550,7 +553,7 @@ public class SIPCommander implements ISIPCommander { |
| 550 | 553 | (MediaServerItem mediaServerItemForEnd, JSONObject jsonForEnd) -> { |
| 551 | 554 | logger.info("[录像]下载结束, 发送BYE"); |
| 552 | 555 | try { |
| 553 | - streamByeCmd(device, channelId, ssrcInfo.getStream(),sipSender.getNewCallIdHeader(device.getTransport()).getCallId()); | |
| 556 | + streamByeCmd(device, channelId, ssrcInfo.getStream(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId()); | |
| 554 | 557 | } catch (InvalidArgumentException | ParseException | SipException | |
| 555 | 558 | SsrcTransactionNotFoundException e) { |
| 556 | 559 | logger.error("[录像]下载结束, 发送BYE失败 {}", e.getMessage()); |
| ... | ... | @@ -558,14 +561,14 @@ public class SIPCommander implements ISIPCommander { |
| 558 | 561 | }); |
| 559 | 562 | }); |
| 560 | 563 | |
| 561 | - Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()), ssrcInfo.getSsrc()); | |
| 564 | + Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()), ssrcInfo.getSsrc()); | |
| 562 | 565 | if (inviteStreamCallback != null) { |
| 563 | - inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); | |
| 566 | + inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); | |
| 564 | 567 | } |
| 565 | - sipSender.transmitRequest( request, errorEvent, okEvent -> { | |
| 568 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent -> { | |
| 566 | 569 | ResponseEvent responseEvent = (ResponseEvent) okEvent.event; |
| 567 | 570 | SIPResponse response = (SIPResponse) responseEvent.getResponse(); |
| 568 | - streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download); | |
| 571 | + streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download); | |
| 569 | 572 | }); |
| 570 | 573 | } |
| 571 | 574 | |
| ... | ... | @@ -592,7 +595,7 @@ public class SIPCommander implements ISIPCommander { |
| 592 | 595 | streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); |
| 593 | 596 | |
| 594 | 597 | Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo()); |
| 595 | - sipSender.transmitRequest( byteRequest, null, okEvent); | |
| 598 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); | |
| 596 | 599 | } |
| 597 | 600 | |
| 598 | 601 | /** |
| ... | ... | @@ -625,8 +628,8 @@ public class SIPCommander implements ISIPCommander { |
| 625 | 628 | |
| 626 | 629 | |
| 627 | 630 | |
| 628 | - Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 629 | - sipSender.transmitRequest( request); | |
| 631 | + Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 632 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 630 | 633 | |
| 631 | 634 | } |
| 632 | 635 | |
| ... | ... | @@ -645,8 +648,8 @@ public class SIPCommander implements ISIPCommander { |
| 645 | 648 | |
| 646 | 649 | |
| 647 | 650 | |
| 648 | - Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 649 | - sipSender.transmitRequest( request, errorEvent); | |
| 651 | + Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 652 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 650 | 653 | |
| 651 | 654 | } |
| 652 | 655 | |
| ... | ... | @@ -676,8 +679,8 @@ public class SIPCommander implements ISIPCommander { |
| 676 | 679 | |
| 677 | 680 | |
| 678 | 681 | |
| 679 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 680 | - sipSender.transmitRequest( request, errorEvent); | |
| 682 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 683 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 681 | 684 | } |
| 682 | 685 | |
| 683 | 686 | /** |
| ... | ... | @@ -700,8 +703,8 @@ public class SIPCommander implements ISIPCommander { |
| 700 | 703 | |
| 701 | 704 | |
| 702 | 705 | |
| 703 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 704 | - sipSender.transmitRequest( request); | |
| 706 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 707 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 705 | 708 | } |
| 706 | 709 | |
| 707 | 710 | /** |
| ... | ... | @@ -725,8 +728,8 @@ public class SIPCommander implements ISIPCommander { |
| 725 | 728 | |
| 726 | 729 | |
| 727 | 730 | |
| 728 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 729 | - sipSender.transmitRequest( request, errorEvent); | |
| 731 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 732 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 730 | 733 | } |
| 731 | 734 | |
| 732 | 735 | /** |
| ... | ... | @@ -761,8 +764,8 @@ public class SIPCommander implements ISIPCommander { |
| 761 | 764 | |
| 762 | 765 | |
| 763 | 766 | |
| 764 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 765 | - sipSender.transmitRequest( request, errorEvent); | |
| 767 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 768 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 766 | 769 | } |
| 767 | 770 | |
| 768 | 771 | /** |
| ... | ... | @@ -790,8 +793,8 @@ public class SIPCommander implements ISIPCommander { |
| 790 | 793 | |
| 791 | 794 | |
| 792 | 795 | |
| 793 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 794 | - sipSender.transmitRequest( request); | |
| 796 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 797 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 795 | 798 | } |
| 796 | 799 | |
| 797 | 800 | /** |
| ... | ... | @@ -837,8 +840,8 @@ public class SIPCommander implements ISIPCommander { |
| 837 | 840 | |
| 838 | 841 | |
| 839 | 842 | |
| 840 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 841 | - sipSender.transmitRequest( request, errorEvent); | |
| 843 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 844 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 842 | 845 | } |
| 843 | 846 | |
| 844 | 847 | /** |
| ... | ... | @@ -900,8 +903,8 @@ public class SIPCommander implements ISIPCommander { |
| 900 | 903 | |
| 901 | 904 | |
| 902 | 905 | |
| 903 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 904 | - sipSender.transmitRequest( request, errorEvent); | |
| 906 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 907 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 905 | 908 | } |
| 906 | 909 | |
| 907 | 910 | /** |
| ... | ... | @@ -923,9 +926,9 @@ public class SIPCommander implements ISIPCommander { |
| 923 | 926 | |
| 924 | 927 | |
| 925 | 928 | |
| 926 | - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 929 | + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 927 | 930 | |
| 928 | - sipSender.transmitRequest( request, errorEvent); | |
| 931 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 929 | 932 | } |
| 930 | 933 | |
| 931 | 934 | /** |
| ... | ... | @@ -947,9 +950,9 @@ public class SIPCommander implements ISIPCommander { |
| 947 | 950 | |
| 948 | 951 | |
| 949 | 952 | |
| 950 | - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 953 | + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 951 | 954 | |
| 952 | - sipSender.transmitRequest( request); | |
| 955 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 953 | 956 | |
| 954 | 957 | } |
| 955 | 958 | |
| ... | ... | @@ -972,9 +975,9 @@ public class SIPCommander implements ISIPCommander { |
| 972 | 975 | |
| 973 | 976 | |
| 974 | 977 | |
| 975 | - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 978 | + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 976 | 979 | |
| 977 | - sipSender.transmitRequest( request, errorEvent); | |
| 980 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 978 | 981 | } |
| 979 | 982 | |
| 980 | 983 | /** |
| ... | ... | @@ -1018,9 +1021,9 @@ public class SIPCommander implements ISIPCommander { |
| 1018 | 1021 | |
| 1019 | 1022 | |
| 1020 | 1023 | Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), |
| 1021 | - SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 1024 | + SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1022 | 1025 | |
| 1023 | - sipSender.transmitRequest( request, errorEvent, okEvent); | |
| 1026 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); | |
| 1024 | 1027 | } |
| 1025 | 1028 | |
| 1026 | 1029 | /** |
| ... | ... | @@ -1068,8 +1071,8 @@ public class SIPCommander implements ISIPCommander { |
| 1068 | 1071 | |
| 1069 | 1072 | |
| 1070 | 1073 | |
| 1071 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 1072 | - sipSender.transmitRequest( request, errorEvent); | |
| 1074 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1075 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 1073 | 1076 | } |
| 1074 | 1077 | |
| 1075 | 1078 | /** |
| ... | ... | @@ -1098,8 +1101,8 @@ public class SIPCommander implements ISIPCommander { |
| 1098 | 1101 | |
| 1099 | 1102 | |
| 1100 | 1103 | |
| 1101 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 1102 | - sipSender.transmitRequest( request, errorEvent); | |
| 1104 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1105 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 1103 | 1106 | } |
| 1104 | 1107 | |
| 1105 | 1108 | /** |
| ... | ... | @@ -1125,8 +1128,8 @@ public class SIPCommander implements ISIPCommander { |
| 1125 | 1128 | |
| 1126 | 1129 | |
| 1127 | 1130 | |
| 1128 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 1129 | - sipSender.transmitRequest( request, errorEvent); | |
| 1131 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1132 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 1130 | 1133 | } |
| 1131 | 1134 | |
| 1132 | 1135 | /** |
| ... | ... | @@ -1149,9 +1152,9 @@ public class SIPCommander implements ISIPCommander { |
| 1149 | 1152 | |
| 1150 | 1153 | |
| 1151 | 1154 | |
| 1152 | - Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 1155 | + Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1153 | 1156 | |
| 1154 | - sipSender.transmitRequest( request, errorEvent); | |
| 1157 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 1155 | 1158 | |
| 1156 | 1159 | } |
| 1157 | 1160 | |
| ... | ... | @@ -1179,13 +1182,13 @@ public class SIPCommander implements ISIPCommander { |
| 1179 | 1182 | CallIdHeader callIdHeader; |
| 1180 | 1183 | |
| 1181 | 1184 | if (requestOld != null) { |
| 1182 | - callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); | |
| 1185 | + callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); | |
| 1183 | 1186 | } else { |
| 1184 | - callIdHeader = sipSender.getNewCallIdHeader(device.getTransport()); | |
| 1187 | + callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()); | |
| 1185 | 1188 | } |
| 1186 | 1189 | SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), requestOld, device.getSubscribeCycleForMobilePosition(), "presence",callIdHeader); //Position;id=" + tm.substring(tm.length() - 4)); |
| 1187 | 1190 | |
| 1188 | - sipSender.transmitRequest( request, errorEvent, okEvent); | |
| 1191 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); | |
| 1189 | 1192 | return request; |
| 1190 | 1193 | } |
| 1191 | 1194 | |
| ... | ... | @@ -1234,8 +1237,8 @@ public class SIPCommander implements ISIPCommander { |
| 1234 | 1237 | |
| 1235 | 1238 | |
| 1236 | 1239 | |
| 1237 | - Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(device.getTransport())); | |
| 1238 | - sipSender.transmitRequest( request); | |
| 1240 | + Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1241 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 1239 | 1242 | |
| 1240 | 1243 | } |
| 1241 | 1244 | |
| ... | ... | @@ -1254,15 +1257,15 @@ public class SIPCommander implements ISIPCommander { |
| 1254 | 1257 | CallIdHeader callIdHeader; |
| 1255 | 1258 | |
| 1256 | 1259 | if (requestOld != null) { |
| 1257 | - callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); | |
| 1260 | + callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); | |
| 1258 | 1261 | } else { |
| 1259 | - callIdHeader = sipSender.getNewCallIdHeader(device.getTransport()); | |
| 1262 | + callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()); | |
| 1260 | 1263 | } |
| 1261 | 1264 | |
| 1262 | 1265 | // 有效时间默认为60秒以上 |
| 1263 | 1266 | SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, cmdXml.toString(), requestOld, device.getSubscribeCycleForCatalog(), "Catalog", |
| 1264 | 1267 | callIdHeader); |
| 1265 | - sipSender.transmitRequest( request, errorEvent, okEvent); | |
| 1268 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); | |
| 1266 | 1269 | return request; |
| 1267 | 1270 | } |
| 1268 | 1271 | |
| ... | ... | @@ -1283,9 +1286,9 @@ public class SIPCommander implements ISIPCommander { |
| 1283 | 1286 | dragXml.append(cmdString); |
| 1284 | 1287 | dragXml.append("</Control>\r\n"); |
| 1285 | 1288 | |
| 1286 | - Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 1289 | + Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1287 | 1290 | logger.debug("拉框信令: " + request.toString()); |
| 1288 | - sipSender.transmitRequest(request); | |
| 1291 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); | |
| 1289 | 1292 | } |
| 1290 | 1293 | |
| 1291 | 1294 | |
| ... | ... | @@ -1364,7 +1367,7 @@ public class SIPCommander implements ISIPCommander { |
| 1364 | 1367 | return; |
| 1365 | 1368 | } |
| 1366 | 1369 | |
| 1367 | - sipSender.transmitRequest( request, errorEvent, okEvent); | |
| 1370 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); | |
| 1368 | 1371 | } |
| 1369 | 1372 | |
| 1370 | 1373 | @Override |
| ... | ... | @@ -1394,8 +1397,8 @@ public class SIPCommander implements ISIPCommander { |
| 1394 | 1397 | deviceStatusXml.append("</Notify>\r\n"); |
| 1395 | 1398 | |
| 1396 | 1399 | |
| 1397 | - Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport())); | |
| 1398 | - sipSender.transmitRequest(request); | |
| 1400 | + Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1401 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); | |
| 1399 | 1402 | |
| 1400 | 1403 | |
| 1401 | 1404 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.fastjson2.JSON; |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 4 | 6 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 5 | 7 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 6 | 8 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| ... | ... | @@ -53,7 +55,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 53 | 55 | private ZLMRTPServerFactory zlmrtpServerFactory; |
| 54 | 56 | |
| 55 | 57 | @Autowired |
| 56 | - private SipFactory sipFactory; | |
| 58 | + private SipLayer sipLayer; | |
| 57 | 59 | |
| 58 | 60 | @Autowired |
| 59 | 61 | private SIPSender sipSender; |
| ... | ... | @@ -73,7 +75,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 73 | 75 | SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain, boolean isRegister) throws SipException, InvalidArgumentException, ParseException { |
| 74 | 76 | Request request; |
| 75 | 77 | if (!registerAgain ) { |
| 76 | - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); | |
| 78 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 77 | 79 | |
| 78 | 80 | request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, |
| 79 | 81 | redisCatchStorage.getCSEQ(), SipUtils.getNewFromTag(), |
| ... | ... | @@ -95,11 +97,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 95 | 97 | }); |
| 96 | 98 | |
| 97 | 99 | }else { |
| 98 | - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); | |
| 100 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 99 | 101 | request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, SipUtils.getNewFromTag(), null, callId, www, callIdHeader, isRegister); |
| 100 | 102 | } |
| 101 | 103 | |
| 102 | - sipSender.transmitRequest( request, null, okEvent); | |
| 104 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, okEvent); | |
| 103 | 105 | } |
| 104 | 106 | |
| 105 | 107 | @Override |
| ... | ... | @@ -114,7 +116,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 114 | 116 | keepaliveXml.append("<Status>OK</Status>\r\n"); |
| 115 | 117 | keepaliveXml.append("</Notify>\r\n"); |
| 116 | 118 | |
| 117 | - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); | |
| 119 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 118 | 120 | |
| 119 | 121 | Request request = headerProviderPlatformProvider.createMessageRequest( |
| 120 | 122 | parentPlatform, |
| ... | ... | @@ -122,7 +124,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 122 | 124 | SipUtils.getNewFromTag(), |
| 123 | 125 | SipUtils.getNewViaTag(), |
| 124 | 126 | callIdHeader); |
| 125 | - sipSender.transmitRequest( request, errorEvent, okEvent); | |
| 127 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, errorEvent, okEvent); | |
| 126 | 128 | return callIdHeader.getCallId(); |
| 127 | 129 | } |
| 128 | 130 | |
| ... | ... | @@ -145,10 +147,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 145 | 147 | String catalogXml = getCatalogXml(channels, sn, parentPlatform, size); |
| 146 | 148 | |
| 147 | 149 | // callid |
| 148 | - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); | |
| 150 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 149 | 151 | |
| 150 | 152 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 151 | - sipSender.transmitRequest( request); | |
| 153 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 152 | 154 | |
| 153 | 155 | } |
| 154 | 156 | |
| ... | ... | @@ -231,10 +233,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 231 | 233 | } |
| 232 | 234 | String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size()); |
| 233 | 235 | // callid |
| 234 | - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); | |
| 236 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 235 | 237 | |
| 236 | 238 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 237 | - sipSender.transmitRequest( request, null, eventResult -> { | |
| 239 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, eventResult -> { | |
| 238 | 240 | int indexNext = index + parentPlatform.getCatalogGroup(); |
| 239 | 241 | try { |
| 240 | 242 | sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext); |
| ... | ... | @@ -270,10 +272,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 270 | 272 | deviceInfoXml.append("<Result>OK</Result>\r\n"); |
| 271 | 273 | deviceInfoXml.append("</Response>\r\n"); |
| 272 | 274 | |
| 273 | - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); | |
| 275 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 274 | 276 | |
| 275 | 277 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 276 | - sipSender.transmitRequest( request); | |
| 278 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 277 | 279 | } |
| 278 | 280 | |
| 279 | 281 | /** |
| ... | ... | @@ -300,10 +302,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 300 | 302 | deviceStatusXml.append("<Status>OK</Status>\r\n"); |
| 301 | 303 | deviceStatusXml.append("</Response>\r\n"); |
| 302 | 304 | |
| 303 | - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); | |
| 305 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 304 | 306 | |
| 305 | 307 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 306 | - sipSender.transmitRequest( request); | |
| 308 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 307 | 309 | |
| 308 | 310 | } |
| 309 | 311 | |
| ... | ... | @@ -362,10 +364,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 362 | 364 | deviceStatusXml.append("</info>\r\n"); |
| 363 | 365 | deviceStatusXml.append("</Notify>\r\n"); |
| 364 | 366 | |
| 365 | - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); | |
| 367 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 366 | 368 | |
| 367 | 369 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader); |
| 368 | - sipSender.transmitRequest( request); | |
| 370 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 369 | 371 | |
| 370 | 372 | } |
| 371 | 373 | |
| ... | ... | @@ -405,14 +407,14 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 405 | 407 | private void sendNotify(ParentPlatform parentPlatform, String catalogXmlContent, |
| 406 | 408 | SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent ) |
| 407 | 409 | throws SipException, ParseException, InvalidArgumentException { |
| 408 | - MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); | |
| 410 | + MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); | |
| 409 | 411 | String characterSet = parentPlatform.getCharacterSet(); |
| 410 | 412 | // 设置编码, 防止中文乱码 |
| 411 | 413 | messageFactory.setDefaultContentEncodingCharset(characterSet); |
| 412 | 414 | |
| 413 | 415 | SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo); |
| 414 | 416 | |
| 415 | - sipSender.transmitRequest( notifyRequest); | |
| 417 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), notifyRequest); | |
| 416 | 418 | } |
| 417 | 419 | |
| 418 | 420 | private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List<DeviceChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) { |
| ... | ... | @@ -577,21 +579,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 577 | 579 | recordXml.append("</Response>\r\n"); |
| 578 | 580 | |
| 579 | 581 | // callid |
| 580 | - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); | |
| 582 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 581 | 583 | |
| 582 | 584 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 583 | - sipSender.transmitRequest( request); | |
| 585 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 584 | 586 | |
| 585 | 587 | } |
| 586 | 588 | |
| 587 | 589 | @Override |
| 588 | - public void sendMediaStatusNotify(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { | |
| 589 | - if (sendRtpItem == null || platform == null) { | |
| 590 | + public void sendMediaStatusNotify(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { | |
| 591 | + if (sendRtpItem == null || parentPlatform == null) { | |
| 590 | 592 | return; |
| 591 | 593 | } |
| 592 | 594 | |
| 593 | 595 | |
| 594 | - String characterSet = platform.getCharacterSet(); | |
| 596 | + String characterSet = parentPlatform.getCharacterSet(); | |
| 595 | 597 | StringBuffer mediaStatusXml = new StringBuffer(200); |
| 596 | 598 | mediaStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| 597 | 599 | mediaStatusXml.append("<Notify>\r\n"); |
| ... | ... | @@ -601,10 +603,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 601 | 603 | mediaStatusXml.append("<NotifyType>121</NotifyType>\r\n"); |
| 602 | 604 | mediaStatusXml.append("</Notify>\r\n"); |
| 603 | 605 | |
| 604 | - SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(platform, mediaStatusXml.toString(), | |
| 606 | + SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(parentPlatform, mediaStatusXml.toString(), | |
| 605 | 607 | sendRtpItem); |
| 606 | 608 | |
| 607 | - sipSender.transmitRequest(messageRequest); | |
| 609 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(),messageRequest); | |
| 608 | 610 | |
| 609 | 611 | } |
| 610 | 612 | |
| ... | ... | @@ -620,26 +622,26 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 620 | 622 | } |
| 621 | 623 | |
| 622 | 624 | @Override |
| 623 | - public void streamByeCmd(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { | |
| 625 | + public void streamByeCmd(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { | |
| 624 | 626 | if (sendRtpItem == null ) { |
| 625 | 627 | logger.info("[向上级发送BYE], sendRtpItem 为NULL"); |
| 626 | 628 | return; |
| 627 | 629 | } |
| 628 | - if (platform == null) { | |
| 630 | + if (parentPlatform == null) { | |
| 629 | 631 | logger.info("[向上级发送BYE], platform 为NULL"); |
| 630 | 632 | return; |
| 631 | 633 | } |
| 632 | - logger.info("[向上级发送BYE], {}/{}", platform.getServerGBId(), sendRtpItem.getChannelId()); | |
| 634 | + logger.info("[向上级发送BYE], {}/{}", parentPlatform.getServerGBId(), sendRtpItem.getChannelId()); | |
| 633 | 635 | String mediaServerId = sendRtpItem.getMediaServerId(); |
| 634 | 636 | MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); |
| 635 | 637 | if (mediaServerItem != null) { |
| 636 | 638 | mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc()); |
| 637 | 639 | zlmrtpServerFactory.closeRtpServer(mediaServerItem, sendRtpItem.getStreamId()); |
| 638 | 640 | } |
| 639 | - SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(platform, sendRtpItem); | |
| 641 | + SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(parentPlatform, sendRtpItem); | |
| 640 | 642 | if (byeRequest == null) { |
| 641 | 643 | logger.warn("[向上级发送bye]:无法创建 byeRequest"); |
| 642 | 644 | } |
| 643 | - sipSender.transmitRequest(byeRequest); | |
| 645 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(),byeRequest); | |
| 644 | 646 | } |
| 645 | 647 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
| ... | ... | @@ -177,7 +177,7 @@ public abstract class SIPRequestProcessorParent { |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // 发送response |
| 180 | - sipSender.transmitRequest(response); | |
| 180 | + sipSender.transmitRequest(sipRequest.getLocalAddress().getHostAddress(), response); | |
| 181 | 181 | |
| 182 | 182 | return response; |
| 183 | 183 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| ... | ... | @@ -418,7 +418,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 418 | 418 | // 未知错误。直接转发设备点播的错误 |
| 419 | 419 | try { |
| 420 | 420 | Response response = getMessageFactory().createResponse(event.statusCode, evt.getRequest()); |
| 421 | - sipSender.transmitRequest(response); | |
| 421 | + sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); | |
| 422 | 422 | } catch (ParseException | SipException e) { |
| 423 | 423 | e.printStackTrace(); |
| 424 | 424 | } |
| ... | ... | @@ -481,8 +481,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 481 | 481 | playService.play(mediaServerItem, ssrcInfo, device, channelId, hookEvent, errorEvent, (code, msg) -> { |
| 482 | 482 | logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId); |
| 483 | 483 | redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); |
| 484 | - zlmrtpServerFactory.releasePort(finalMediaServerItem, sendRtpItem.getSsrc()); | |
| 485 | - }, null); | |
| 484 | + }); | |
| 486 | 485 | } else { |
| 487 | 486 | sendRtpItem.setStreamId(playTransaction.getStream()); |
| 488 | 487 | // 写入redis, 超时时回复 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | +import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; | |
| 4 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 5 | 6 | import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate; |
| 6 | 7 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| 7 | 8 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| 8 | 9 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 9 | 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 10 | -import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; | |
| 11 | 11 | import com.genersoft.iot.vmp.service.IDeviceService; |
| 12 | 12 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 13 | 13 | import gov.nist.javax.sip.RequestEventExt; |
| 14 | 14 | import gov.nist.javax.sip.address.AddressImpl; |
| 15 | 15 | import gov.nist.javax.sip.address.SipUri; |
| 16 | -import gov.nist.javax.sip.header.Expires; | |
| 17 | 16 | import gov.nist.javax.sip.header.SIPDateHeader; |
| 17 | +import gov.nist.javax.sip.message.SIPRequest; | |
| 18 | 18 | import org.slf4j.Logger; |
| 19 | 19 | import org.slf4j.LoggerFactory; |
| 20 | 20 | import org.springframework.beans.factory.InitializingBean; |
| ... | ... | @@ -24,8 +24,10 @@ import org.springframework.util.ObjectUtils; |
| 24 | 24 | |
| 25 | 25 | import javax.sip.RequestEvent; |
| 26 | 26 | import javax.sip.SipException; |
| 27 | -import javax.sip.header.*; | |
| 28 | -import javax.sip.message.Request; | |
| 27 | +import javax.sip.header.AuthorizationHeader; | |
| 28 | +import javax.sip.header.ContactHeader; | |
| 29 | +import javax.sip.header.FromHeader; | |
| 30 | +import javax.sip.header.ViaHeader; | |
| 29 | 31 | import javax.sip.message.Response; |
| 30 | 32 | import java.security.NoSuchAlgorithmException; |
| 31 | 33 | import java.text.ParseException; |
| ... | ... | @@ -71,12 +73,11 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen |
| 71 | 73 | RequestEventExt evtExt = (RequestEventExt) evt; |
| 72 | 74 | String requestAddress = evtExt.getRemoteIpAddress() + ":" + evtExt.getRemotePort(); |
| 73 | 75 | logger.info("[注册请求] 开始处理: {}", requestAddress); |
| 74 | - Request request = evt.getRequest(); | |
| 75 | - ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(Expires.NAME); | |
| 76 | + SIPRequest request = (SIPRequest)evt.getRequest(); | |
| 76 | 77 | Response response = null; |
| 77 | 78 | boolean passwordCorrect = false; |
| 78 | 79 | // 注册标志 |
| 79 | - boolean registerFlag = false; | |
| 80 | + boolean registerFlag; | |
| 80 | 81 | FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME); |
| 81 | 82 | AddressImpl address = (AddressImpl) fromHeader.getAddress(); |
| 82 | 83 | SipUri uri = (SipUri) address.getURI(); |
| ... | ... | @@ -88,7 +89,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen |
| 88 | 89 | logger.info("[注册请求] 回复401: {}", requestAddress); |
| 89 | 90 | response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); |
| 90 | 91 | new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); |
| 91 | - sipSender.transmitRequest(response); | |
| 92 | + sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); | |
| 92 | 93 | return; |
| 93 | 94 | } |
| 94 | 95 | |
| ... | ... | @@ -101,7 +102,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen |
| 101 | 102 | response = getMessageFactory().createResponse(Response.FORBIDDEN, request); |
| 102 | 103 | response.setReasonPhrase("wrong password"); |
| 103 | 104 | logger.info("[注册请求] 密码/SIP服务器ID错误, 回复403: {}", requestAddress); |
| 104 | - sipSender.transmitRequest(response); | |
| 105 | + sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); | |
| 105 | 106 | return; |
| 106 | 107 | } |
| 107 | 108 | |
| ... | ... | @@ -114,9 +115,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen |
| 114 | 115 | dateHeader.setDate(wvpSipDate); |
| 115 | 116 | response.addHeader(dateHeader); |
| 116 | 117 | |
| 117 | - if (expiresHeader == null) { | |
| 118 | + if (request.getExpires() == null) { | |
| 118 | 119 | response = getMessageFactory().createResponse(Response.BAD_REQUEST, request); |
| 119 | - sipSender.transmitRequest(response); | |
| 120 | + sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); | |
| 120 | 121 | return; |
| 121 | 122 | } |
| 122 | 123 | // 添加Contact头 |
| ... | ... | @@ -145,12 +146,13 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen |
| 145 | 146 | device.setIp(received); |
| 146 | 147 | device.setPort(rPort); |
| 147 | 148 | device.setHostAddress(received.concat(":").concat(String.valueOf(rPort))); |
| 148 | - if (expiresHeader.getExpires() == 0) { | |
| 149 | + device.setLocalIp(request.getLocalAddress().getHostAddress()); | |
| 150 | + if (request.getExpires().getExpires() == 0) { | |
| 149 | 151 | // 注销成功 |
| 150 | 152 | registerFlag = false; |
| 151 | 153 | } else { |
| 152 | 154 | // 注册成功 |
| 153 | - device.setExpires(expiresHeader.getExpires()); | |
| 155 | + device.setExpires(request.getExpires().getExpires()); | |
| 154 | 156 | registerFlag = true; |
| 155 | 157 | // 判断TCP还是UDP |
| 156 | 158 | ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); |
| ... | ... | @@ -158,7 +160,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen |
| 158 | 160 | device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP"); |
| 159 | 161 | } |
| 160 | 162 | |
| 161 | - sipSender.transmitRequest(response); | |
| 163 | + sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); | |
| 162 | 164 | // 注册成功 |
| 163 | 165 | // 保存到redis |
| 164 | 166 | if (registerFlag) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
| ... | ... | @@ -93,7 +93,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme |
| 93 | 93 | response.setExpires(expireHeader); |
| 94 | 94 | } |
| 95 | 95 | logger.info("response : " + response); |
| 96 | - sipSender.transmitRequest(response); | |
| 96 | + sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); | |
| 97 | 97 | } |
| 98 | 98 | } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { |
| 99 | 99 | e.printStackTrace(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java
| ... | ... | @@ -9,8 +9,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP |
| 9 | 9 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 10 | 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler; |
| 11 | 11 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 12 | -import com.genersoft.iot.vmp.utils.SpringBeanFactory; | |
| 13 | -import gov.nist.javax.sip.SipStackImpl; | |
| 14 | 12 | import gov.nist.javax.sip.message.SIPRequest; |
| 15 | 13 | import org.dom4j.Element; |
| 16 | 14 | import org.slf4j.Logger; |
| ... | ... | @@ -84,23 +82,24 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent |
| 84 | 82 | logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage()); |
| 85 | 83 | } |
| 86 | 84 | taskExecutor.execute(()->{ |
| 87 | - try { | |
| 88 | - Thread.sleep(3000); | |
| 89 | - SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); | |
| 90 | - SipStackImpl stack = (SipStackImpl)up.getSipStack(); | |
| 91 | - stack.stop(); | |
| 92 | - Iterator listener = stack.getListeningPoints(); | |
| 93 | - while (listener.hasNext()) { | |
| 94 | - stack.deleteListeningPoint((ListeningPoint) listener.next()); | |
| 95 | - } | |
| 96 | - Iterator providers = stack.getSipProviders(); | |
| 97 | - while (providers.hasNext()) { | |
| 98 | - stack.deleteSipProvider((SipProvider) providers.next()); | |
| 99 | - } | |
| 100 | - VManageBootstrap.restart(); | |
| 101 | - } catch (InterruptedException | ObjectInUseException e) { | |
| 102 | - logger.error("[任务执行失败] 服务重启: {}", e.getMessage()); | |
| 103 | - } | |
| 85 | + // 远程启动 | |
| 86 | +// try { | |
| 87 | +// Thread.sleep(3000); | |
| 88 | +// SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); | |
| 89 | +// SipStackImpl stack = (SipStackImpl)up.getSipStack(); | |
| 90 | +// stack.stop(); | |
| 91 | +// Iterator listener = stack.getListeningPoints(); | |
| 92 | +// while (listener.hasNext()) { | |
| 93 | +// stack.deleteListeningPoint((ListeningPoint) listener.next()); | |
| 94 | +// } | |
| 95 | +// Iterator providers = stack.getSipProviders(); | |
| 96 | +// while (providers.hasNext()) { | |
| 97 | +// stack.deleteSipProvider((SipProvider) providers.next()); | |
| 98 | +// } | |
| 99 | +// VManageBootstrap.restart(); | |
| 100 | +// } catch (InterruptedException | ObjectInUseException e) { | |
| 101 | +// logger.error("[任务执行失败] 服务重启: {}", e.getMessage()); | |
| 102 | +// } | |
| 104 | 103 | }); |
| 105 | 104 | } else { |
| 106 | 105 | // 远程启动指定设备 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 4 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 5 | 6 | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; |
| 6 | 7 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| ... | ... | @@ -54,7 +55,7 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract { |
| 54 | 55 | |
| 55 | 56 | |
| 56 | 57 | @Autowired |
| 57 | - private SipFactory sipFactory; | |
| 58 | + private SipLayer sipLayer; | |
| 58 | 59 | |
| 59 | 60 | @Autowired |
| 60 | 61 | private SIPSender sipSender; |
| ... | ... | @@ -103,11 +104,12 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract { |
| 103 | 104 | } else { |
| 104 | 105 | sdp = SdpFactory.getInstance().createSessionDescription(contentString); |
| 105 | 106 | } |
| 106 | - SipURI requestUri = sipFactory.createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort()); | |
| 107 | - Request reqAck = headerProvider.createAckRequest(requestUri, response); | |
| 107 | + | |
| 108 | + SipURI requestUri = sipLayer.getSipFactory().createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort()); | |
| 109 | + Request reqAck = headerProvider.createAckRequest(response.getLocalAddress().getHostAddress(), requestUri, response); | |
| 108 | 110 | |
| 109 | 111 | logger.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort()); |
| 110 | - sipSender.transmitRequest(reqAck); | |
| 112 | + sipSender.transmitRequest( response.getLocalAddress().getHostAddress(), reqAck); | |
| 111 | 113 | } |
| 112 | 114 | } catch (InvalidArgumentException | ParseException | SipException | SdpParseException e) { |
| 113 | 115 | logger.info("[点播回复ACK],异常:", e ); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java
| ... | ... | @@ -100,7 +100,7 @@ public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { |
| 100 | 100 | if (platformRegisterInfo.isRegister()) { |
| 101 | 101 | platformService.online(parentPlatform); |
| 102 | 102 | }else { |
| 103 | - platformService.offline(parentPlatform); | |
| 103 | + platformService.offline(parentPlatform, false); | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // 注册/注销成功移除缓存的信息 | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| ... | ... | @@ -568,8 +568,6 @@ public class ZLMHttpHookListener { |
| 568 | 568 | public JSONObject onServerStarted(HttpServletRequest request, @RequestBody JSONObject jsonObject){ |
| 569 | 569 | |
| 570 | 570 | jsonObject.put("ip", request.getRemoteAddr()); |
| 571 | - System.out.println(jsonObject.toJSONString() | |
| 572 | - ); | |
| 573 | 571 | ZLMServerConfig zlmServerConfig = JSON.to(ZLMServerConfig.class, jsonObject); |
| 574 | 572 | zlmServerConfig.setIp(request.getRemoteAddr()); |
| 575 | 573 | logger.info("[ZLM HOOK] zlm 启动 " + zlmServerConfig.getGeneralMediaServerId()); |
| ... | ... | @@ -632,7 +630,6 @@ public class ZLMHttpHookListener { |
| 632 | 630 | @ResponseBody |
| 633 | 631 | @PostMapping(value = "/on_rtp_server_timeout", produces = "application/json;charset=UTF-8") |
| 634 | 632 | public JSONObject onRtpServerTimeout(HttpServletRequest request, @RequestBody OnRtpServerTimeoutHookParam param){ |
| 635 | - System.out.println(param); | |
| 636 | 633 | logger.info("[ZLM HOOK] rtpServer收流超时:{}->{}({})", param.getMediaServerId(), param.getStream_id(), param.getSsrc()); |
| 637 | 634 | |
| 638 | 635 | JSONObject ret = new JSONObject(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| ... | ... | @@ -169,7 +169,6 @@ public class ZLMRESTfulUtils { |
| 169 | 169 | .build(); |
| 170 | 170 | Response response = client.newCall(request).execute(); |
| 171 | 171 | if (response.isSuccessful()) { |
| 172 | - logger.info("response body contentType: " + Objects.requireNonNull(response.body()).contentType()); | |
| 173 | 172 | if (targetPath != null) { |
| 174 | 173 | File snapFolder = new File(targetPath); |
| 175 | 174 | if (!snapFolder.exists()) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| ... | ... | @@ -25,7 +25,7 @@ import java.util.Set; |
| 25 | 25 | import java.util.concurrent.ConcurrentHashMap; |
| 26 | 26 | |
| 27 | 27 | @Component |
| 28 | -@Order(value=1) | |
| 28 | +@Order(value=2) | |
| 29 | 29 | public class ZLMRunner implements CommandLineRunner { |
| 30 | 30 | |
| 31 | 31 | private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java
| 1 | 1 | package com.genersoft.iot.vmp.service; |
| 2 | 2 | |
| 3 | -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | |
| 4 | 3 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | -import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; | |
| 6 | -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | |
| 7 | 4 | import com.github.pagehelper.PageInfo; |
| 8 | 5 | |
| 9 | -import java.util.List; | |
| 10 | - | |
| 11 | 6 | /** |
| 12 | 7 | * 国标平台的业务类 |
| 13 | 8 | * @author lin |
| ... | ... | @@ -40,7 +35,7 @@ public interface IPlatformService { |
| 40 | 35 | * 平台离线 |
| 41 | 36 | * @param parentPlatform 平台信息 |
| 42 | 37 | */ |
| 43 | - void offline(ParentPlatform parentPlatform); | |
| 38 | + void offline(ParentPlatform parentPlatform, boolean stopRegisterTask); | |
| 44 | 39 | |
| 45 | 40 | /** |
| 46 | 41 | * 向上级平台发起注册 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
| ... | ... | @@ -13,7 +13,6 @@ import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback; |
| 13 | 13 | import com.genersoft.iot.vmp.service.bean.PlayBackCallback; |
| 14 | 14 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 15 | 15 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 16 | -import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; | |
| 17 | 16 | import org.springframework.web.context.request.async.DeferredResult; |
| 18 | 17 | |
| 19 | 18 | import javax.sip.InvalidArgumentException; |
| ... | ... | @@ -25,12 +24,12 @@ import java.text.ParseException; |
| 25 | 24 | */ |
| 26 | 25 | public interface IPlayService { |
| 27 | 26 | |
| 28 | - void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId, String uuid); | |
| 27 | + void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId); | |
| 29 | 28 | |
| 30 | 29 | void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, |
| 31 | 30 | ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, |
| 32 | - InviteTimeOutCallback timeoutCallback, String uuid); | |
| 33 | - PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent, Runnable timeoutCallback); | |
| 31 | + InviteTimeOutCallback timeoutCallback); | |
| 32 | + void play(MediaServerItem mediaServerItem, String deviceId, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent, Runnable timeoutCallback); | |
| 34 | 33 | |
| 35 | 34 | MediaServerItem getNewMediaServerItem(Device device); |
| 36 | 35 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| ... | ... | @@ -604,7 +604,7 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 604 | 604 | mediaServerItem.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); |
| 605 | 605 | mediaServerItem.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); |
| 606 | 606 | mediaServerItem.setStreamIp(ip); |
| 607 | - mediaServerItem.setHookIp(sipConfig.getIp()); | |
| 607 | + mediaServerItem.setHookIp(sipConfig.getIp().split(",")[0]); | |
| 608 | 608 | mediaServerItem.setSdpIp(ip); |
| 609 | 609 | return mediaServerItem; |
| 610 | 610 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
| ... | ... | @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; |
| 4 | 4 | import com.alibaba.fastjson2.JSONArray; |
| 5 | 5 | import com.alibaba.fastjson2.JSONObject; |
| 6 | 6 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 7 | +import com.genersoft.iot.vmp.common.StreamURL; | |
| 7 | 8 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 8 | 9 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 9 | 10 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| ... | ... | @@ -16,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 16 | 17 | import org.springframework.stereotype.Service; |
| 17 | 18 | import org.springframework.util.ObjectUtils; |
| 18 | 19 | |
| 20 | +import java.net.URL; | |
| 21 | + | |
| 19 | 22 | @Service |
| 20 | 23 | public class MediaServiceImpl implements IMediaService { |
| 21 | 24 | |
| ... | ... | @@ -91,38 +94,17 @@ public class MediaServiceImpl implements IMediaService { |
| 91 | 94 | if (addr == null) { |
| 92 | 95 | addr = mediaInfo.getStreamIp(); |
| 93 | 96 | } |
| 97 | + | |
| 94 | 98 | streamInfoResult.setIp(addr); |
| 95 | 99 | streamInfoResult.setMediaServerId(mediaInfo.getId()); |
| 96 | 100 | String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId; |
| 97 | - streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpPort(), app, stream, callIdParam)); | |
| 98 | - if (mediaInfo.getRtmpSSlPort() != 0) { | |
| 99 | - streamInfoResult.setRtmps(String.format("rtmps://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpSSlPort(), app, stream, callIdParam)); | |
| 100 | - } | |
| 101 | - streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s%s", addr, mediaInfo.getRtspPort(), app, stream, callIdParam)); | |
| 102 | - if (mediaInfo.getRtspSSLPort() != 0) { | |
| 103 | - streamInfoResult.setRtsps(String.format("rtsps://%s:%s/%s/%s%s", addr, mediaInfo.getRtspSSLPort(), app, stream, callIdParam)); | |
| 104 | - } | |
| 105 | - streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | |
| 106 | - streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | |
| 107 | - streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | |
| 108 | - streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | |
| 109 | - streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | |
| 110 | - streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | |
| 111 | - streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | |
| 112 | - streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | |
| 113 | - streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream, ObjectUtils.isEmpty(callId)?"":"&callId=" + callId)); | |
| 114 | - if (mediaInfo.getHttpSSlPort() != 0) { | |
| 115 | - streamInfoResult.setHttps_flv(String.format("https://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | |
| 116 | - streamInfoResult.setWss_flv(String.format("wss://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | |
| 117 | - streamInfoResult.setHttps_hls(String.format("https://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | |
| 118 | - streamInfoResult.setWss_hls(String.format("wss://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | |
| 119 | - streamInfoResult.setHttps_fmp4(String.format("https://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | |
| 120 | - streamInfoResult.setWss_fmp4(String.format("wss://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | |
| 121 | - streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | |
| 122 | - streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | |
| 123 | - streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | |
| 124 | - streamInfoResult.setRtcs(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, ObjectUtils.isEmpty(callId)?"":"&callId=" + callId)); | |
| 125 | - } | |
| 101 | + streamInfoResult.setRtmp(addr, mediaInfo.getRtmpPort(),mediaInfo.getRtmpSSlPort(), app, stream, callIdParam); | |
| 102 | + streamInfoResult.setRtsp(addr, mediaInfo.getRtspPort(),mediaInfo.getRtspSSLPort(), app, stream, callIdParam); | |
| 103 | + streamInfoResult.setFlv(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | |
| 104 | + streamInfoResult.setFmp4(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | |
| 105 | + streamInfoResult.setHls(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | |
| 106 | + streamInfoResult.setTs(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | |
| 107 | + streamInfoResult.setRtc(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | |
| 126 | 108 | |
| 127 | 109 | streamInfoResult.setTracks(tracks); |
| 128 | 110 | return streamInfoResult; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
| ... | ... | @@ -22,7 +22,6 @@ import org.springframework.stereotype.Service; |
| 22 | 22 | |
| 23 | 23 | import javax.sip.InvalidArgumentException; |
| 24 | 24 | import javax.sip.SipException; |
| 25 | -import javax.sip.TimeoutEvent; | |
| 26 | 25 | import java.text.ParseException; |
| 27 | 26 | import java.util.HashMap; |
| 28 | 27 | import java.util.List; |
| ... | ... | @@ -131,20 +130,23 @@ public class PlatformServiceImpl implements IPlatformService { |
| 131 | 130 | } |
| 132 | 131 | |
| 133 | 132 | final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); |
| 134 | - if (dynamicTask.contains(registerTaskKey)) { | |
| 135 | - dynamicTask.stop(registerTaskKey); | |
| 136 | - } | |
| 137 | - // 添加注册任务 | |
| 138 | - dynamicTask.startDelay(registerTaskKey, | |
| 133 | + if (!dynamicTask.isAlive(registerTaskKey)) { | |
| 134 | + // 添加注册任务 | |
| 135 | + dynamicTask.startCron(registerTaskKey, | |
| 139 | 136 | // 注册失败(注册成功时由程序直接调用了online方法) |
| 140 | 137 | ()-> { |
| 141 | 138 | try { |
| 142 | - commanderForPlatform.register(parentPlatform, eventResult -> offline(parentPlatform),null); | |
| 139 | + logger.info("[国标级联] 平台:{}注册即将到期,重新注册", parentPlatform.getServerGBId()); | |
| 140 | + commanderForPlatform.register(parentPlatform, eventResult -> { | |
| 141 | + offline(parentPlatform, false); | |
| 142 | + },null); | |
| 143 | 143 | } catch (InvalidArgumentException | ParseException | SipException e) { |
| 144 | 144 | logger.error("[命令发送失败] 国标级联定时注册: {}", e.getMessage()); |
| 145 | 145 | } |
| 146 | 146 | }, |
| 147 | 147 | (parentPlatform.getExpires() - 10) *1000); |
| 148 | + } | |
| 149 | + | |
| 148 | 150 | |
| 149 | 151 | final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId(); |
| 150 | 152 | if (!dynamicTask.contains(keepaliveTaskKey)) { |
| ... | ... | @@ -160,16 +162,11 @@ public class PlatformServiceImpl implements IPlatformService { |
| 160 | 162 | // 此时是第三次心跳超时, 平台离线 |
| 161 | 163 | if (platformCatch.getKeepAliveReply() == 2) { |
| 162 | 164 | // 设置平台离线,并重新注册 |
| 163 | - offline(parentPlatform); | |
| 164 | 165 | logger.info("[国标级联] {},三次心跳超时后再次发起注册", parentPlatform.getServerGBId()); |
| 165 | 166 | try { |
| 166 | 167 | commanderForPlatform.register(parentPlatform, eventResult1 -> { |
| 167 | 168 | logger.info("[国标级联] {},三次心跳超时后再次发起注册仍然失败,开始定时发起注册,间隔为1分钟", parentPlatform.getServerGBId()); |
| 168 | - // 添加注册任务 | |
| 169 | - dynamicTask.startCron(registerTaskKey, | |
| 170 | - // 注册失败(注册成功时由程序直接调用了online方法) | |
| 171 | - ()->logger.info("[国标级联] {},平台离线后持续发起注册,失败", parentPlatform.getServerGBId()), | |
| 172 | - 60*1000); | |
| 169 | + offline(parentPlatform, false); | |
| 173 | 170 | }, null); |
| 174 | 171 | } catch (InvalidArgumentException | ParseException | SipException e) { |
| 175 | 172 | logger.error("[命令发送失败] 国标级联 注册: {}", e.getMessage()); |
| ... | ... | @@ -198,7 +195,7 @@ public class PlatformServiceImpl implements IPlatformService { |
| 198 | 195 | } |
| 199 | 196 | |
| 200 | 197 | @Override |
| 201 | - public void offline(ParentPlatform parentPlatform) { | |
| 198 | + public void offline(ParentPlatform parentPlatform, boolean stopRegister) { | |
| 202 | 199 | logger.info("[平台离线]:{}", parentPlatform.getServerGBId()); |
| 203 | 200 | ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); |
| 204 | 201 | parentPlatformCatch.setKeepAliveReply(0); |
| ... | ... | @@ -212,11 +209,13 @@ public class PlatformServiceImpl implements IPlatformService { |
| 212 | 209 | // 停止所有推流 |
| 213 | 210 | logger.info("[平台离线] {}, 停止所有推流", parentPlatform.getServerGBId()); |
| 214 | 211 | stopAllPush(parentPlatform.getServerGBId()); |
| 215 | - // 清除注册定时 | |
| 216 | - logger.info("[平台离线] {}, 停止定时注册任务", parentPlatform.getServerGBId()); | |
| 217 | - final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); | |
| 218 | - if (dynamicTask.contains(registerTaskKey)) { | |
| 219 | - dynamicTask.stop(registerTaskKey); | |
| 212 | + if (stopRegister) { | |
| 213 | + // 清除注册定时 | |
| 214 | + logger.info("[平台离线] {}, 停止定时注册任务", parentPlatform.getServerGBId()); | |
| 215 | + final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); | |
| 216 | + if (dynamicTask.contains(registerTaskKey)) { | |
| 217 | + dynamicTask.stop(registerTaskKey); | |
| 218 | + } | |
| 220 | 219 | } |
| 221 | 220 | // 清除心跳定时 |
| 222 | 221 | logger.info("[平台离线] {}, 停止定时发送心跳任务", parentPlatform.getServerGBId()); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| ... | ... | @@ -36,7 +36,6 @@ import com.genersoft.iot.vmp.utils.DateUtil; |
| 36 | 36 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 37 | 37 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 38 | 38 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 39 | -import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; | |
| 40 | 39 | import org.slf4j.Logger; |
| 41 | 40 | import org.slf4j.LoggerFactory; |
| 42 | 41 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -53,7 +52,6 @@ import java.math.BigDecimal; |
| 53 | 52 | import java.math.RoundingMode; |
| 54 | 53 | import java.text.ParseException; |
| 55 | 54 | import java.util.List; |
| 56 | -import java.util.Objects; | |
| 57 | 55 | import java.util.UUID; |
| 58 | 56 | |
| 59 | 57 | @SuppressWarnings(value = {"rawtypes", "unchecked"}) |
| ... | ... | @@ -111,46 +109,19 @@ public class PlayServiceImpl implements IPlayService { |
| 111 | 109 | private ThreadPoolTaskExecutor taskExecutor; |
| 112 | 110 | |
| 113 | 111 | @Override |
| 114 | - public PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, | |
| 115 | - ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, | |
| 116 | - Runnable timeoutCallback) { | |
| 112 | + public void play(MediaServerItem mediaServerItem, String deviceId, String channelId, | |
| 113 | + ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, | |
| 114 | + Runnable timeoutCallback) { | |
| 117 | 115 | if (mediaServerItem == null) { |
| 118 | 116 | throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); |
| 119 | 117 | } |
| 120 | - PlayResult playResult = new PlayResult(); | |
| 121 | - RequestMessage msg = new RequestMessage(); | |
| 122 | 118 | String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId; |
| 119 | + | |
| 120 | + RequestMessage msg = new RequestMessage(); | |
| 123 | 121 | msg.setKey(key); |
| 124 | - String uuid = UUID.randomUUID().toString(); | |
| 125 | - msg.setId(uuid); | |
| 126 | - playResult.setUuid(uuid); | |
| 127 | - DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); | |
| 128 | - playResult.setResult(result); | |
| 129 | - // 录像查询以channelId作为deviceId查询 | |
| 130 | - resultHolder.put(key, uuid, result); | |
| 131 | 122 | |
| 132 | 123 | Device device = redisCatchStorage.getDevice(deviceId); |
| 133 | 124 | StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); |
| 134 | - playResult.setDevice(device); | |
| 135 | - | |
| 136 | - result.onCompletion(() -> { | |
| 137 | - // 点播结束时调用截图接口 | |
| 138 | - taskExecutor.execute(() -> { | |
| 139 | - // TODO 应该在上流时调用更好,结束也可能是错误结束 | |
| 140 | - String path = "snap"; | |
| 141 | - String fileName = deviceId + "_" + channelId + ".jpg"; | |
| 142 | - WVPResult wvpResult = (WVPResult) result.getResult(); | |
| 143 | - if (Objects.requireNonNull(wvpResult).getCode() == 0) { | |
| 144 | - StreamInfo streamInfoForSuccess = (StreamInfo) wvpResult.getData(); | |
| 145 | - MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId()); | |
| 146 | - String streamUrl = streamInfoForSuccess.getFmp4(); | |
| 147 | - | |
| 148 | - // 请求截图 | |
| 149 | - logger.info("[请求截图]: " + fileName); | |
| 150 | - zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName); | |
| 151 | - } | |
| 152 | - }); | |
| 153 | - }); | |
| 154 | 125 | |
| 155 | 126 | if (streamInfo != null) { |
| 156 | 127 | String streamId = streamInfo.getStream(); |
| ... | ... | @@ -160,7 +131,7 @@ public class PlayServiceImpl implements IPlayService { |
| 160 | 131 | wvpResult.setMsg("点播失败, redis缓存streamId等于null"); |
| 161 | 132 | msg.setData(wvpResult); |
| 162 | 133 | resultHolder.invokeAllResult(msg); |
| 163 | - return playResult; | |
| 134 | + return; | |
| 164 | 135 | } |
| 165 | 136 | String mediaServerId = streamInfo.getMediaServerId(); |
| 166 | 137 | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); |
| ... | ... | @@ -178,14 +149,13 @@ public class PlayServiceImpl implements IPlayService { |
| 178 | 149 | msg.setData(wvpResult); |
| 179 | 150 | |
| 180 | 151 | resultHolder.invokeAllResult(msg); |
| 181 | - return playResult; | |
| 152 | + return; | |
| 182 | 153 | } else { |
| 183 | 154 | WVPResult wvpResult = new WVPResult(); |
| 184 | 155 | wvpResult.setCode(ErrorCode.SUCCESS.getCode()); |
| 185 | 156 | wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); |
| 186 | 157 | wvpResult.setData(streamInfo); |
| 187 | 158 | msg.setData(wvpResult); |
| 188 | - | |
| 189 | 159 | resultHolder.invokeAllResult(msg); |
| 190 | 160 | if (hookEvent != null) { |
| 191 | 161 | hookEvent.response(mediaServerItem, JSON.parseObject(JSON.toJSONString(streamInfo))); |
| ... | ... | @@ -211,7 +181,6 @@ public class PlayServiceImpl implements IPlayService { |
| 211 | 181 | streamId = String.format("%s_%s", device.getDeviceId(), channelId); |
| 212 | 182 | } |
| 213 | 183 | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false); |
| 214 | - logger.info(JSONObject.toJSONString(ssrcInfo)); | |
| 215 | 184 | if (ssrcInfo == null) { |
| 216 | 185 | WVPResult wvpResult = new WVPResult(); |
| 217 | 186 | wvpResult.setCode(ErrorCode.ERROR100.getCode()); |
| ... | ... | @@ -219,7 +188,7 @@ public class PlayServiceImpl implements IPlayService { |
| 219 | 188 | msg.setData(wvpResult); |
| 220 | 189 | |
| 221 | 190 | resultHolder.invokeAllResult(msg); |
| 222 | - return playResult; | |
| 191 | + return; | |
| 223 | 192 | } |
| 224 | 193 | play(mediaServerItem, ssrcInfo, device, channelId, (mediaServerItemInUse, response) -> { |
| 225 | 194 | if (hookEvent != null) { |
| ... | ... | @@ -247,16 +216,15 @@ public class PlayServiceImpl implements IPlayService { |
| 247 | 216 | msg.setData(wvpResult); |
| 248 | 217 | // 回复之前所有的点播请求 |
| 249 | 218 | resultHolder.invokeAllResult(msg); |
| 250 | - }, uuid); | |
| 219 | + }); | |
| 251 | 220 | } |
| 252 | - return playResult; | |
| 253 | 221 | } |
| 254 | 222 | |
| 255 | 223 | |
| 256 | 224 | @Override |
| 257 | 225 | public void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, |
| 258 | 226 | ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, |
| 259 | - InviteTimeOutCallback timeoutCallback, String uuid) { | |
| 227 | + InviteTimeOutCallback timeoutCallback) { | |
| 260 | 228 | |
| 261 | 229 | logger.info("[点播开始] deviceId: {}, channelId: {},收流端口: {}, 收流模式:{}, SSRC: {}, SSRC校验:{}", device.getDeviceId(), channelId, ssrcInfo.getPort(), device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck()); |
| 262 | 230 | // 超时处理 |
| ... | ... | @@ -279,16 +247,36 @@ public class PlayServiceImpl implements IPlayService { |
| 279 | 247 | } |
| 280 | 248 | } |
| 281 | 249 | }, userSetting.getPlayTimeout()); |
| 250 | + //端口获取失败的ssrcInfo 没有必要发送点播指令 | |
| 251 | + if (ssrcInfo.getPort() <= 0) { | |
| 252 | + logger.info("[点播端口分配异常],deviceId={},channelId={},ssrcInfo={}", device.getDeviceId(), channelId, ssrcInfo); | |
| 253 | + dynamicTask.stop(timeOutTaskKey); | |
| 254 | + // 释放ssrc | |
| 255 | + mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); | |
| 282 | 256 | |
| 257 | + streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); | |
| 258 | + | |
| 259 | + RequestMessage msg = new RequestMessage(); | |
| 260 | + msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + device.getDeviceId() + channelId); | |
| 261 | + msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "点播端口分配异常")); | |
| 262 | + resultHolder.invokeAllResult(msg); | |
| 263 | + return; | |
| 264 | + } | |
| 283 | 265 | try { |
| 284 | 266 | cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> { |
| 285 | 267 | logger.info("收到订阅消息: " + response.toJSONString()); |
| 286 | 268 | dynamicTask.stop(timeOutTaskKey); |
| 287 | 269 | |
| 288 | 270 | // hook响应 |
| 289 | - onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId, uuid); | |
| 271 | + onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId); | |
| 290 | 272 | hookEvent.response(mediaServerItemInuse, response); |
| 291 | 273 | logger.info("[点播成功] deviceId: {}, channelId: {}", device.getDeviceId(), channelId); |
| 274 | + String streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServerItemInuse.getRtspPort(), "rtp", ssrcInfo.getStream()); | |
| 275 | + String path = "snap"; | |
| 276 | + String fileName = device.getDeviceId() + "_" + channelId + ".jpg"; | |
| 277 | + // 请求截图 | |
| 278 | + logger.info("[请求截图]: " + fileName); | |
| 279 | + zlmresTfulUtils.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); | |
| 292 | 280 | |
| 293 | 281 | }, (event) -> { |
| 294 | 282 | ResponseEvent responseEvent = (ResponseEvent) event.event; |
| ... | ... | @@ -328,7 +316,7 @@ public class PlayServiceImpl implements IPlayService { |
| 328 | 316 | logger.info("[ZLM HOOK] ssrc修正后收到订阅消息: " + response.toJSONString()); |
| 329 | 317 | dynamicTask.stop(timeOutTaskKey); |
| 330 | 318 | // hook响应 |
| 331 | - onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid); | |
| 319 | + onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId); | |
| 332 | 320 | hookEvent.response(mediaServerItemInUse, response); |
| 333 | 321 | }); |
| 334 | 322 | } |
| ... | ... | @@ -364,13 +352,41 @@ public class PlayServiceImpl implements IPlayService { |
| 364 | 352 | } |
| 365 | 353 | |
| 366 | 354 | @Override |
| 367 | - public void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId, String uuid) { | |
| 355 | + public void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId) { | |
| 356 | + StreamInfo streamInfo = onPublishHandler(mediaServerItem, response, deviceId, channelId); | |
| 368 | 357 | RequestMessage msg = new RequestMessage(); |
| 369 | - if (uuid != null) { | |
| 370 | - msg.setId(uuid); | |
| 358 | + msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId); | |
| 359 | + if (streamInfo != null) { | |
| 360 | + DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); | |
| 361 | + if (deviceChannel != null) { | |
| 362 | + deviceChannel.setStreamId(streamInfo.getStream()); | |
| 363 | + storager.startPlay(deviceId, channelId, streamInfo.getStream()); | |
| 364 | + } | |
| 365 | + redisCatchStorage.startPlay(streamInfo); | |
| 366 | + | |
| 367 | + WVPResult wvpResult = new WVPResult(); | |
| 368 | + wvpResult.setCode(ErrorCode.SUCCESS.getCode()); | |
| 369 | + wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); | |
| 370 | + wvpResult.setData(streamInfo); | |
| 371 | + | |
| 372 | + msg.setData(wvpResult); | |
| 373 | + resultHolder.invokeAllResult(msg); | |
| 374 | + | |
| 375 | + } else { | |
| 376 | + logger.warn("设备预览API调用失败!"); | |
| 377 | + msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "设备预览API调用失败!")); | |
| 378 | + resultHolder.invokeAllResult(msg); | |
| 371 | 379 | } |
| 380 | + } | |
| 381 | + | |
| 382 | + private void onPublishHandlerForPlayback(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId, String uuid) { | |
| 383 | + RequestMessage msg = new RequestMessage(); | |
| 372 | 384 | msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId); |
| 385 | + if (!ObjectUtils.isEmpty(uuid)) { | |
| 386 | + msg.setId(uuid); | |
| 387 | + } | |
| 373 | 388 | StreamInfo streamInfo = onPublishHandler(mediaServerItem, response, deviceId, channelId); |
| 389 | + | |
| 374 | 390 | if (streamInfo != null) { |
| 375 | 391 | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); |
| 376 | 392 | if (deviceChannel != null) { |
| ... | ... | @@ -387,8 +403,8 @@ public class PlayServiceImpl implements IPlayService { |
| 387 | 403 | |
| 388 | 404 | resultHolder.invokeAllResult(msg); |
| 389 | 405 | } else { |
| 390 | - logger.warn("设备预览API调用失败!"); | |
| 391 | - msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "设备预览API调用失败!")); | |
| 406 | + logger.warn("录像回放调用失败!"); | |
| 407 | + msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "录像回放调用失败!")); | |
| 392 | 408 | resultHolder.invokeAllResult(msg); |
| 393 | 409 | } |
| 394 | 410 | } |
| ... | ... | @@ -542,7 +558,7 @@ public class PlayServiceImpl implements IPlayService { |
| 542 | 558 | logger.info("[ZLM HOOK] ssrc修正后收到订阅消息: " + response.toJSONString()); |
| 543 | 559 | dynamicTask.stop(playBackTimeOutTaskKey); |
| 544 | 560 | // hook响应 |
| 545 | - onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid); | |
| 561 | + onPublishHandlerForPlayback(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid); | |
| 546 | 562 | hookEvent.call(new InviteStreamInfo(mediaServerItem, null, eventResult.callId, "rtp", ssrcInfo.getStream())); |
| 547 | 563 | }); |
| 548 | 564 | } |
| ... | ... | @@ -565,6 +581,8 @@ public class PlayServiceImpl implements IPlayService { |
| 565 | 581 | return result; |
| 566 | 582 | } |
| 567 | 583 | |
| 584 | + | |
| 585 | + | |
| 568 | 586 | @Override |
| 569 | 587 | public DeferredResult<WVPResult<StreamInfo>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { |
| 570 | 588 | Device device = storager.queryVideoDevice(deviceId); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
| ... | ... | @@ -221,6 +221,12 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 221 | 221 | streamInfoPushItemMap.put(onStreamChangedHookParam.getApp() + onStreamChangedHookParam.getStream(), onStreamChangedHookParam); |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | + // 获取所有推流鉴权信息,清理过期的 | |
| 225 | + List<StreamAuthorityInfo> allStreamAuthorityInfo = redisCatchStorage.getAllStreamAuthorityInfo(); | |
| 226 | + Map<String, StreamAuthorityInfo> streamAuthorityInfoInfoMap = new HashMap<>(); | |
| 227 | + for (StreamAuthorityInfo streamAuthorityInfo : allStreamAuthorityInfo) { | |
| 228 | + streamAuthorityInfoInfoMap.put(streamAuthorityInfo.getApp() + streamAuthorityInfo.getStream(), streamAuthorityInfo); | |
| 229 | + } | |
| 224 | 230 | zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ |
| 225 | 231 | if (mediaList == null) { |
| 226 | 232 | return; |
| ... | ... | @@ -239,6 +245,7 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 239 | 245 | for (StreamPushItem streamPushItem : streamPushItems) { |
| 240 | 246 | pushItemMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); |
| 241 | 247 | streamInfoPushItemMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); |
| 248 | + streamAuthorityInfoInfoMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); | |
| 242 | 249 | } |
| 243 | 250 | } |
| 244 | 251 | List<StreamPushItem> offlinePushItems = new ArrayList<>(pushItemMap.values()); |
| ... | ... | @@ -274,6 +281,14 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 274 | 281 | redisCatchStorage.removeStream(mediaServerItem.getId(), "PUSH", offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream()); |
| 275 | 282 | } |
| 276 | 283 | } |
| 284 | + | |
| 285 | + Collection<StreamAuthorityInfo> streamAuthorityInfos = streamAuthorityInfoInfoMap.values(); | |
| 286 | + if (streamAuthorityInfos.size() > 0) { | |
| 287 | + for (StreamAuthorityInfo streamAuthorityInfo : streamAuthorityInfos) { | |
| 288 | + // 移除redis内流的信息 | |
| 289 | + redisCatchStorage.removeStreamAuthorityInfo(streamAuthorityInfo.getApp(), streamAuthorityInfo.getStream()); | |
| 290 | + } | |
| 291 | + } | |
| 277 | 292 | })); |
| 278 | 293 | } |
| 279 | 294 | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
| ... | ... | @@ -25,6 +25,7 @@ public interface DeviceMapper { |
| 25 | 25 | "streamMode," + |
| 26 | 26 | "ip," + |
| 27 | 27 | "sdpIp," + |
| 28 | + "localIp," + | |
| 28 | 29 | "port," + |
| 29 | 30 | "hostAddress," + |
| 30 | 31 | "expires," + |
| ... | ... | @@ -54,6 +55,7 @@ public interface DeviceMapper { |
| 54 | 55 | "streamMode," + |
| 55 | 56 | "ip," + |
| 56 | 57 | "sdpIp," + |
| 58 | + "localIp," + | |
| 57 | 59 | "port," + |
| 58 | 60 | "hostAddress," + |
| 59 | 61 | "expires," + |
| ... | ... | @@ -80,6 +82,7 @@ public interface DeviceMapper { |
| 80 | 82 | "#{streamMode}," + |
| 81 | 83 | "#{ip}," + |
| 82 | 84 | "#{sdpIp}," + |
| 85 | + "#{localIp}," + | |
| 83 | 86 | "#{port}," + |
| 84 | 87 | "#{hostAddress}," + |
| 85 | 88 | "#{expires}," + |
| ... | ... | @@ -108,6 +111,7 @@ public interface DeviceMapper { |
| 108 | 111 | "<if test=\"firmware != null\">, firmware='${firmware}'</if>" + |
| 109 | 112 | "<if test=\"transport != null\">, transport='${transport}'</if>" + |
| 110 | 113 | "<if test=\"ip != null\">, ip='${ip}'</if>" + |
| 114 | + "<if test=\"localIp != null\">, localIp='${localIp}'</if>" + | |
| 111 | 115 | "<if test=\"port != null\">, port=${port}</if>" + |
| 112 | 116 | "<if test=\"hostAddress != null\">, hostAddress='${hostAddress}'</if>" + |
| 113 | 117 | "<if test=\"online != null\">, online=${online}</if>" + |
| ... | ... | @@ -129,6 +133,7 @@ public interface DeviceMapper { |
| 129 | 133 | "streamMode," + |
| 130 | 134 | "ip," + |
| 131 | 135 | "sdpIp," + |
| 136 | + "localIp," + | |
| 132 | 137 | "port," + |
| 133 | 138 | "hostAddress," + |
| 134 | 139 | "expires," + |
| ... | ... | @@ -165,6 +170,7 @@ public interface DeviceMapper { |
| 165 | 170 | "streamMode," + |
| 166 | 171 | "ip," + |
| 167 | 172 | "sdpIp," + |
| 173 | + "localIp," + | |
| 168 | 174 | "port," + |
| 169 | 175 | "hostAddress," + |
| 170 | 176 | "expires," + |
| ... | ... | @@ -194,6 +200,7 @@ public interface DeviceMapper { |
| 194 | 200 | "streamMode," + |
| 195 | 201 | "ip," + |
| 196 | 202 | "sdpIp," + |
| 203 | + "localIp," + | |
| 197 | 204 | "port," + |
| 198 | 205 | "hostAddress," + |
| 199 | 206 | "expires," + | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
| ... | ... | @@ -714,6 +714,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| 714 | 714 | |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | + @Override | |
| 718 | + public List<StreamAuthorityInfo> getAllStreamAuthorityInfo() { | |
| 719 | + String scanKey = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_*_*" ; | |
| 720 | + List<StreamAuthorityInfo> result = new ArrayList<>(); | |
| 721 | + List<Object> keys = RedisUtil.scan(scanKey); | |
| 722 | + for (Object o : keys) { | |
| 723 | + String key = (String) o; | |
| 724 | + result.add((StreamAuthorityInfo) RedisUtil.get(key)); | |
| 725 | + } | |
| 726 | + return result; | |
| 727 | + } | |
| 728 | + | |
| 717 | 729 | |
| 718 | 730 | @Override |
| 719 | 731 | public OnStreamChangedHookParam getStreamInfo(String app, String streamId, String mediaServerId) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/utils/redis/FastJsonRedisSerializer.java
| 1 | 1 | package com.genersoft.iot.vmp.utils.redis; |
| 2 | 2 | |
| 3 | -import java.nio.charset.Charset; | |
| 4 | - | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 5 | 4 | import com.alibaba.fastjson2.JSONReader; |
| 6 | 5 | import com.alibaba.fastjson2.JSONWriter; |
| 7 | 6 | import org.springframework.data.redis.serializer.RedisSerializer; |
| 8 | 7 | import org.springframework.data.redis.serializer.SerializationException; |
| 9 | 8 | |
| 10 | -import com.alibaba.fastjson2.JSON; | |
| 11 | -import com.alibaba.fastjson2.JSONWriter.Feature; | |
| 9 | +import java.nio.charset.Charset; | |
| 12 | 10 | |
| 13 | 11 | /** |
| 14 | 12 | * @description:使用fastjson实现redis的序列化 |
| ... | ... | @@ -31,7 +29,7 @@ public class FastJsonRedisSerializer<T> implements RedisSerializer<T> { |
| 31 | 29 | if (t == null) { |
| 32 | 30 | return new byte[0]; |
| 33 | 31 | } |
| 34 | - return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET); | |
| 32 | + return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName, JSONWriter.Feature.WritePairAsJavaBean).getBytes(DEFAULT_CHARSET); | |
| 35 | 33 | } |
| 36 | 34 | |
| 37 | 35 | @Override |
| ... | ... | @@ -42,4 +40,6 @@ public class FastJsonRedisSerializer<T> implements RedisSerializer<T> { |
| 42 | 40 | String str = new String(bytes, DEFAULT_CHARSET); |
| 43 | 41 | return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); |
| 44 | 42 | } |
| 43 | + | |
| 44 | + | |
| 45 | 45 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultEx.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.vmanager.bean; | |
| 2 | + | |
| 3 | +import org.springframework.web.context.request.async.DeferredResult; | |
| 4 | + | |
| 5 | +public class DeferredResultEx<T> { | |
| 6 | + | |
| 7 | + private DeferredResult<T> deferredResult; | |
| 8 | + | |
| 9 | + private DeferredResultFilter filter; | |
| 10 | + | |
| 11 | + public DeferredResultEx(DeferredResult<T> result) { | |
| 12 | + this.deferredResult = result; | |
| 13 | + } | |
| 14 | + | |
| 15 | + | |
| 16 | + public DeferredResult<T> getDeferredResult() { | |
| 17 | + return deferredResult; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setDeferredResult(DeferredResult<T> deferredResult) { | |
| 21 | + this.deferredResult = deferredResult; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public DeferredResultFilter getFilter() { | |
| 25 | + return filter; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setFilter(DeferredResultFilter filter) { | |
| 29 | + this.filter = filter; | |
| 30 | + } | |
| 31 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultFilter.java
0 → 100644
src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java
| ... | ... | @@ -4,7 +4,7 @@ package com.genersoft.iot.vmp.vmanager.bean; |
| 4 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 5 | |
| 6 | 6 | @Schema(description = "统一返回结果") |
| 7 | -public class WVPResult<T> { | |
| 7 | +public class WVPResult<T> implements Cloneable{ | |
| 8 | 8 | |
| 9 | 9 | public WVPResult() { |
| 10 | 10 | } |
| ... | ... | @@ -63,4 +63,9 @@ public class WVPResult<T> { |
| 63 | 63 | public void setData(T data) { |
| 64 | 64 | this.data = data; |
| 65 | 65 | } |
| 66 | + | |
| 67 | + @Override | |
| 68 | + public Object clone() throws CloneNotSupportedException { | |
| 69 | + return super.clone(); | |
| 70 | + } | |
| 66 | 71 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.gb28181.play; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.fastjson2.JSONArray; |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 5 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 6 | +import com.genersoft.iot.vmp.conf.UserSetting; | |
| 5 | 7 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 6 | 8 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 9 | +import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 7 | 10 | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; |
| 8 | 11 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 9 | -import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 10 | 12 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 11 | 13 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| 14 | +import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | |
| 12 | 15 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 13 | 16 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 14 | 17 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 18 | +import com.genersoft.iot.vmp.service.IMediaService; | |
| 19 | +import com.genersoft.iot.vmp.service.IPlayService; | |
| 15 | 20 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 21 | +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | |
| 22 | +import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx; | |
| 16 | 23 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 17 | 24 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 18 | -import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; | |
| 19 | -import com.genersoft.iot.vmp.service.IMediaService; | |
| 20 | -import com.genersoft.iot.vmp.service.IPlayService; | |
| 21 | - | |
| 22 | 25 | import io.swagger.v3.oas.annotations.Operation; |
| 23 | 26 | import io.swagger.v3.oas.annotations.Parameter; |
| 24 | 27 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 25 | 28 | import org.slf4j.Logger; |
| 26 | 29 | import org.slf4j.LoggerFactory; |
| 27 | 30 | import org.springframework.beans.factory.annotation.Autowired; |
| 28 | -import org.springframework.web.bind.annotation.CrossOrigin; | |
| 29 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 30 | -import org.springframework.web.bind.annotation.PathVariable; | |
| 31 | -import org.springframework.web.bind.annotation.PostMapping; | |
| 32 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 33 | -import org.springframework.web.bind.annotation.RestController; | |
| 34 | - | |
| 35 | -import com.alibaba.fastjson2.JSONObject; | |
| 36 | -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | |
| 37 | -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | |
| 31 | +import org.springframework.web.bind.annotation.*; | |
| 38 | 32 | import org.springframework.web.context.request.async.DeferredResult; |
| 39 | 33 | |
| 34 | +import javax.servlet.http.HttpServletRequest; | |
| 40 | 35 | import javax.sip.InvalidArgumentException; |
| 41 | 36 | import javax.sip.SipException; |
| 42 | 37 | import java.text.ParseException; |
| ... | ... | @@ -78,19 +73,63 @@ public class PlayController { |
| 78 | 73 | @Autowired |
| 79 | 74 | private IMediaServerService mediaServerService; |
| 80 | 75 | |
| 76 | + @Autowired | |
| 77 | + private UserSetting userSetting; | |
| 78 | + | |
| 81 | 79 | @Operation(summary = "开始点播") |
| 82 | 80 | @Parameter(name = "deviceId", description = "设备国标编号", required = true) |
| 83 | 81 | @Parameter(name = "channelId", description = "通道国标编号", required = true) |
| 84 | 82 | @GetMapping("/start/{deviceId}/{channelId}") |
| 85 | - public DeferredResult<WVPResult<StreamInfo>> play(@PathVariable String deviceId, | |
| 86 | - @PathVariable String channelId) { | |
| 83 | + public DeferredResult<WVPResult<StreamInfo>> play(HttpServletRequest request, @PathVariable String deviceId, | |
| 84 | + @PathVariable String channelId) { | |
| 87 | 85 | |
| 88 | 86 | // 获取可用的zlm |
| 89 | 87 | Device device = storager.queryVideoDevice(deviceId); |
| 90 | 88 | MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); |
| 91 | - PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null, null); | |
| 92 | 89 | |
| 93 | - return playResult.getResult(); | |
| 90 | + RequestMessage msg = new RequestMessage(); | |
| 91 | + String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId; | |
| 92 | + boolean exist = resultHolder.exist(key, null); | |
| 93 | + msg.setKey(key); | |
| 94 | + String uuid = UUID.randomUUID().toString(); | |
| 95 | + msg.setId(uuid); | |
| 96 | + DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); | |
| 97 | + DeferredResultEx<WVPResult<StreamInfo>> deferredResultEx = new DeferredResultEx<>(result); | |
| 98 | + | |
| 99 | + result.onTimeout(()->{ | |
| 100 | + logger.info("点播接口等待超时"); | |
| 101 | + // 释放rtpserver | |
| 102 | + WVPResult<StreamInfo> wvpResult = new WVPResult<>(); | |
| 103 | + wvpResult.setCode(ErrorCode.ERROR100.getCode()); | |
| 104 | + wvpResult.setMsg("点播超时"); | |
| 105 | + msg.setData(wvpResult); | |
| 106 | + resultHolder.invokeResult(msg); | |
| 107 | + }); | |
| 108 | + | |
| 109 | + // TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误 | |
| 110 | + deferredResultEx.setFilter(result1 -> { | |
| 111 | + WVPResult<StreamInfo> wvpResult1 = (WVPResult<StreamInfo>)result1; | |
| 112 | + WVPResult<StreamInfo> clone = null; | |
| 113 | + try { | |
| 114 | + clone = (WVPResult<StreamInfo>)wvpResult1.clone(); | |
| 115 | + } catch (CloneNotSupportedException e) { | |
| 116 | + throw new RuntimeException(e); | |
| 117 | + } | |
| 118 | + if (clone.getCode() == ErrorCode.SUCCESS.getCode()) { | |
| 119 | + StreamInfo data = clone.getData().clone(); | |
| 120 | + data.channgeStreamIp(request.getLocalName()); | |
| 121 | + clone.setData(data); | |
| 122 | + } | |
| 123 | + return clone; | |
| 124 | + }); | |
| 125 | + | |
| 126 | + // 录像查询以channelId作为deviceId查询 | |
| 127 | + resultHolder.put(key, uuid, deferredResultEx); | |
| 128 | + | |
| 129 | + if (!exist) { | |
| 130 | + playService.play(newMediaServerItem, deviceId, channelId, null, null, null); | |
| 131 | + } | |
| 132 | + return result; | |
| 94 | 133 | } |
| 95 | 134 | |
| 96 | 135 | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
| ... | ... | @@ -158,25 +158,25 @@ public class ServerController { |
| 158 | 158 | @GetMapping(value = "/restart") |
| 159 | 159 | @ResponseBody |
| 160 | 160 | public void restart() { |
| 161 | - taskExecutor.execute(()-> { | |
| 162 | - try { | |
| 163 | - Thread.sleep(3000); | |
| 164 | - SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); | |
| 165 | - SipStackImpl stack = (SipStackImpl) up.getSipStack(); | |
| 166 | - stack.stop(); | |
| 167 | - Iterator listener = stack.getListeningPoints(); | |
| 168 | - while (listener.hasNext()) { | |
| 169 | - stack.deleteListeningPoint((ListeningPoint) listener.next()); | |
| 170 | - } | |
| 171 | - Iterator providers = stack.getSipProviders(); | |
| 172 | - while (providers.hasNext()) { | |
| 173 | - stack.deleteSipProvider((SipProvider) providers.next()); | |
| 174 | - } | |
| 175 | - VManageBootstrap.restart(); | |
| 176 | - } catch (InterruptedException | ObjectInUseException e) { | |
| 177 | - throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); | |
| 178 | - } | |
| 179 | - }); | |
| 161 | +// taskExecutor.execute(()-> { | |
| 162 | +// try { | |
| 163 | +// Thread.sleep(3000); | |
| 164 | +// SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); | |
| 165 | +// SipStackImpl stack = (SipStackImpl) up.getSipStack(); | |
| 166 | +// stack.stop(); | |
| 167 | +// Iterator listener = stack.getListeningPoints(); | |
| 168 | +// while (listener.hasNext()) { | |
| 169 | +// stack.deleteListeningPoint((ListeningPoint) listener.next()); | |
| 170 | +// } | |
| 171 | +// Iterator providers = stack.getSipProviders(); | |
| 172 | +// while (providers.hasNext()) { | |
| 173 | +// stack.deleteSipProvider((SipProvider) providers.next()); | |
| 174 | +// } | |
| 175 | +// VManageBootstrap.restart(); | |
| 176 | +// } catch (InterruptedException | ObjectInUseException e) { | |
| 177 | +// throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); | |
| 178 | +// } | |
| 179 | +// }); | |
| 180 | 180 | }; |
| 181 | 181 | |
| 182 | 182 | @Operation(summary = "获取系统信息信息") | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
| ... | ... | @@ -6,22 +6,17 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 6 | 6 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 7 | 7 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 8 | 8 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 9 | -import com.genersoft.iot.vmp.service.IMediaService; | |
| 10 | -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | |
| 11 | 9 | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| 12 | 10 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 13 | -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | |
| 14 | 11 | import com.github.pagehelper.PageInfo; |
| 15 | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 16 | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 17 | -import io.swagger.v3.oas.annotations.Parameters; | |
| 18 | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 19 | 15 | import org.slf4j.Logger; |
| 20 | 16 | import org.slf4j.LoggerFactory; |
| 21 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 22 | 18 | import org.springframework.stereotype.Controller; |
| 23 | 19 | import org.springframework.util.ObjectUtils; |
| 24 | -import org.springframework.util.StringUtils; | |
| 25 | 20 | import org.springframework.web.bind.annotation.*; |
| 26 | 21 | |
| 27 | 22 | @SuppressWarnings("rawtypes") |
| ... | ... | @@ -63,7 +58,7 @@ public class StreamProxyController { |
| 63 | 58 | }) |
| 64 | 59 | @PostMapping(value = "/save") |
| 65 | 60 | @ResponseBody |
| 66 | - public StreamInfo save(@RequestBody StreamProxyItem param){ | |
| 61 | + public StreamInfo save(@RequestBody StreamProxyItem param){ | |
| 67 | 62 | logger.info("添加代理: " + JSONObject.toJSONString(param)); |
| 68 | 63 | if (ObjectUtils.isEmpty(param.getMediaServerId())) { |
| 69 | 64 | param.setMediaServerId("auto"); | ... | ... |
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
| ... | ... | @@ -112,7 +112,7 @@ public class ApiStreamController { |
| 112 | 112 | return resultDeferredResult; |
| 113 | 113 | } |
| 114 | 114 | MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); |
| 115 | - PlayResult play = playService.play(newMediaServerItem, serial, code, (mediaServerItem, response)->{ | |
| 115 | + playService.play(newMediaServerItem, serial, code, (mediaServerItem, response)->{ | |
| 116 | 116 | StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(serial, code); |
| 117 | 117 | JSONObject result = new JSONObject(); |
| 118 | 118 | result.put("StreamID", streamInfo.getStream()); | ... | ... |
src/main/resources/all-application.yml
| ... | ... | @@ -105,8 +105,6 @@ sip: |
| 105 | 105 | id: 44010200492000000001 |
| 106 | 106 | # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 |
| 107 | 107 | password: admin123 |
| 108 | - # [可选] 心跳超时时间, 建议设置为心跳周期的三倍 | |
| 109 | - keepalive-timeout: 255 | |
| 110 | 108 | # [可选] 国标级联注册失败,再次发起注册的时间间隔。 默认60秒 |
| 111 | 109 | register-time-interval: 60 |
| 112 | 110 | # [可选] 云台控制速度 |
| ... | ... | @@ -188,6 +186,8 @@ user-settings: |
| 188 | 186 | logInDatebase: true |
| 189 | 187 | # 使用推流状态作为推流通道状态 |
| 190 | 188 | use-pushing-as-status: true |
| 189 | + # 使用来源请求ip作为streamIp | |
| 190 | + use-source-ip-as-stream-ip: true | |
| 191 | 191 | # 按需拉流, true:有人观看拉流,无人观看释放, false:拉起后不自动释放 |
| 192 | 192 | stream-on-demand: true |
| 193 | 193 | # 推流鉴权, 默认开启 | ... | ... |
web_src/src/components/dialog/devicePlayer.vue
| ... | ... | @@ -53,93 +53,93 @@ |
| 53 | 53 | 更多地址<i class="el-icon-arrow-down el-icon--right"></i> |
| 54 | 54 | </el-button> |
| 55 | 55 | <el-dropdown-menu slot="dropdown" > |
| 56 | - <el-dropdown-item :command="streamInfo.flv"> | |
| 56 | + <el-dropdown-item :command="streamInfo.flv.url"> | |
| 57 | 57 | <el-tag >FLV:</el-tag> |
| 58 | - <span>{{ streamInfo.flv }}</span> | |
| 58 | + <span>{{ streamInfo.flv.url }}</span> | |
| 59 | 59 | </el-dropdown-item> |
| 60 | - <el-dropdown-item :command="streamInfo.https_flv"> | |
| 60 | + <el-dropdown-item :command="streamInfo.https_flv.url"> | |
| 61 | 61 | <el-tag >FLV(https):</el-tag> |
| 62 | - <span>{{ streamInfo.https_flv }}</span> | |
| 62 | + <span>{{ streamInfo.https_flv.url }}</span> | |
| 63 | 63 | </el-dropdown-item> |
| 64 | - <el-dropdown-item :command="streamInfo.ws_flv"> | |
| 64 | + <el-dropdown-item :command="streamInfo.ws_flv.url"> | |
| 65 | 65 | <el-tag >FLV(ws):</el-tag> |
| 66 | - <span >{{ streamInfo.ws_flv }}</span> | |
| 66 | + <span >{{ streamInfo.ws_flv.url }}</span> | |
| 67 | 67 | </el-dropdown-item> |
| 68 | - <el-dropdown-item :command="streamInfo.wss_flv"> | |
| 68 | + <el-dropdown-item :command="streamInfo.wss_flv.url"> | |
| 69 | 69 | <el-tag >FLV(wss):</el-tag> |
| 70 | - <span>{{ streamInfo.wss_flv }}</span> | |
| 70 | + <span>{{ streamInfo.wss_flv.url }}</span> | |
| 71 | 71 | </el-dropdown-item> |
| 72 | - <el-dropdown-item :command="streamInfo.fmp4"> | |
| 72 | + <el-dropdown-item :command="streamInfo.fmp4.url"> | |
| 73 | 73 | <el-tag >FMP4:</el-tag> |
| 74 | - <span>{{ streamInfo.fmp4 }}</span> | |
| 74 | + <span>{{ streamInfo.fmp4.url }}</span> | |
| 75 | 75 | </el-dropdown-item> |
| 76 | - <el-dropdown-item :command="streamInfo.https_fmp4"> | |
| 76 | + <el-dropdown-item :command="streamInfo.https_fmp4.url"> | |
| 77 | 77 | <el-tag >FMP4(https):</el-tag> |
| 78 | - <span>{{ streamInfo.https_fmp4 }}</span> | |
| 78 | + <span>{{ streamInfo.https_fmp4.url }}</span> | |
| 79 | 79 | </el-dropdown-item> |
| 80 | - <el-dropdown-item :command="streamInfo.ws_fmp4"> | |
| 80 | + <el-dropdown-item :command="streamInfo.ws_fmp4.url"> | |
| 81 | 81 | <el-tag >FMP4(ws):</el-tag> |
| 82 | - <span>{{ streamInfo.ws_fmp4 }}</span> | |
| 82 | + <span>{{ streamInfo.ws_fmp4.url }}</span> | |
| 83 | 83 | </el-dropdown-item> |
| 84 | - <el-dropdown-item :command="streamInfo.wss_fmp4"> | |
| 84 | + <el-dropdown-item :command="streamInfo.wss_fmp4.url"> | |
| 85 | 85 | <el-tag >FMP4(wss):</el-tag> |
| 86 | - <span>{{ streamInfo.wss_fmp4 }}</span> | |
| 86 | + <span>{{ streamInfo.wss_fmp4.url }}</span> | |
| 87 | 87 | </el-dropdown-item> |
| 88 | - <el-dropdown-item :command="streamInfo.hls"> | |
| 88 | + <el-dropdown-item :command="streamInfo.hls.url"> | |
| 89 | 89 | <el-tag>HLS:</el-tag> |
| 90 | - <span>{{ streamInfo.hls }}</span> | |
| 90 | + <span>{{ streamInfo.hls.url }}</span> | |
| 91 | 91 | </el-dropdown-item> |
| 92 | - <el-dropdown-item :command="streamInfo.https_hls"> | |
| 92 | + <el-dropdown-item :command="streamInfo.https_hls.url"> | |
| 93 | 93 | <el-tag >HLS(https):</el-tag> |
| 94 | - <span>{{ streamInfo.https_hls }}</span> | |
| 94 | + <span>{{ streamInfo.https_hls.url }}</span> | |
| 95 | 95 | </el-dropdown-item> |
| 96 | - <el-dropdown-item :command="streamInfo.ws_hls"> | |
| 96 | + <el-dropdown-item :command="streamInfo.ws_hls.url"> | |
| 97 | 97 | <el-tag >HLS(ws):</el-tag> |
| 98 | - <span>{{ streamInfo.ws_hls }}</span> | |
| 98 | + <span>{{ streamInfo.ws_hls.url }}</span> | |
| 99 | 99 | </el-dropdown-item> |
| 100 | - <el-dropdown-item :command="streamInfo.wss_hls"> | |
| 100 | + <el-dropdown-item :command="streamInfo.wss_hls.url"> | |
| 101 | 101 | <el-tag >HLS(wss):</el-tag> |
| 102 | - <span>{{ streamInfo.wss_hls }}</span> | |
| 102 | + <span>{{ streamInfo.wss_hls.url }}</span> | |
| 103 | 103 | </el-dropdown-item> |
| 104 | - <el-dropdown-item :command="streamInfo.ts"> | |
| 104 | + <el-dropdown-item :command="streamInfo.ts.url"> | |
| 105 | 105 | <el-tag>TS:</el-tag> |
| 106 | - <span>{{ streamInfo.ts }}</span> | |
| 106 | + <span>{{ streamInfo.ts.url }}</span> | |
| 107 | 107 | </el-dropdown-item> |
| 108 | - <el-dropdown-item :command="streamInfo.https_ts"> | |
| 108 | + <el-dropdown-item :command="streamInfo.https_ts.url"> | |
| 109 | 109 | <el-tag>TS(https):</el-tag> |
| 110 | - <span>{{ streamInfo.https_ts }}</span> | |
| 110 | + <span>{{ streamInfo.https_ts.url }}</span> | |
| 111 | 111 | </el-dropdown-item> |
| 112 | - <el-dropdown-item :command="streamInfo.ws_ts"> | |
| 112 | + <el-dropdown-item :command="streamInfo.ws_ts.url"> | |
| 113 | 113 | <el-tag>TS(ws):</el-tag> |
| 114 | - <span>{{ streamInfo.ws_ts }}</span> | |
| 114 | + <span>{{ streamInfo.ws_ts.url }}</span> | |
| 115 | 115 | </el-dropdown-item> |
| 116 | - <el-dropdown-item :command="streamInfo.wss_ts"> | |
| 116 | + <el-dropdown-item :command="streamInfo.wss_ts.url"> | |
| 117 | 117 | <el-tag>TS(wss):</el-tag> |
| 118 | - <span>{{ streamInfo.wss_ts }}</span> | |
| 118 | + <span>{{ streamInfo.wss_ts.url }}</span> | |
| 119 | 119 | </el-dropdown-item> |
| 120 | - <el-dropdown-item :command="streamInfo.rtc"> | |
| 120 | + <el-dropdown-item :command="streamInfo.rtc.url"> | |
| 121 | 121 | <el-tag >RTC:</el-tag> |
| 122 | - <span>{{ streamInfo.rtc }}</span> | |
| 122 | + <span>{{ streamInfo.rtc.url }}</span> | |
| 123 | 123 | </el-dropdown-item> |
| 124 | - <el-dropdown-item :command="streamInfo.rtcs"> | |
| 124 | + <el-dropdown-item :command="streamInfo.rtcs.url"> | |
| 125 | 125 | <el-tag >RTCS:</el-tag> |
| 126 | 126 | <span>{{ streamInfo.rtcs }}</span> |
| 127 | 127 | </el-dropdown-item> |
| 128 | - <el-dropdown-item :command="streamInfo.rtmp"> | |
| 128 | + <el-dropdown-item :command="streamInfo.rtmp.url"> | |
| 129 | 129 | <el-tag >RTMP:</el-tag> |
| 130 | - <span>{{ streamInfo.rtmp }}</span> | |
| 130 | + <span>{{ streamInfo.rtmp.url }}</span> | |
| 131 | 131 | </el-dropdown-item> |
| 132 | - <el-dropdown-item :command="streamInfo.rtmps"> | |
| 132 | + <el-dropdown-item :command="streamInfo.rtmps.url"> | |
| 133 | 133 | <el-tag >RTMPS:</el-tag> |
| 134 | - <span>{{ streamInfo.rtmps }}</span> | |
| 134 | + <span>{{ streamInfo.rtmps.url }}</span> | |
| 135 | 135 | </el-dropdown-item> |
| 136 | - <el-dropdown-item :command="streamInfo.rtsp"> | |
| 136 | + <el-dropdown-item :command="streamInfo.rtsp.url"> | |
| 137 | 137 | <el-tag >RTSP:</el-tag> |
| 138 | - <span>{{ streamInfo.rtsp }}</span> | |
| 138 | + <span>{{ streamInfo.rtsp.url }}</span> | |
| 139 | 139 | </el-dropdown-item> |
| 140 | - <el-dropdown-item :command="streamInfo.rtsps"> | |
| 140 | + <el-dropdown-item :command="streamInfo.rtsps.url"> | |
| 141 | 141 | <el-tag >RTSPS:</el-tag> |
| 142 | - <span>{{ streamInfo.rtsps }}</span> | |
| 142 | + <span>{{ streamInfo.rtsps.url }}</span> | |
| 143 | 143 | </el-dropdown-item> |
| 144 | 144 | </el-dropdown-menu> |
| 145 | 145 | </el-dropdown> |
| ... | ... | @@ -450,9 +450,9 @@ export default { |
| 450 | 450 | getUrlByStreamInfo(){ |
| 451 | 451 | console.log(this.streamInfo) |
| 452 | 452 | if (location.protocol === "https:") { |
| 453 | - this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]] | |
| 453 | + this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]].url | |
| 454 | 454 | }else { |
| 455 | - this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]] | |
| 455 | + this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]].url | |
| 456 | 456 | } |
| 457 | 457 | return this.videoUrl; |
| 458 | 458 | ... | ... |
web_src/src/components/live.vue
| ... | ... | @@ -140,9 +140,9 @@ export default { |
| 140 | 140 | if (res.data.code === 0 && res.data.data) { |
| 141 | 141 | let videoUrl; |
| 142 | 142 | if (location.protocol === "https:") { |
| 143 | - videoUrl = res.data.data.wss_flv; | |
| 143 | + videoUrl = res.data.data.wss_flv.url; | |
| 144 | 144 | } else { |
| 145 | - videoUrl = res.data.data.ws_flv; | |
| 145 | + videoUrl = res.data.data.ws_flv.url; | |
| 146 | 146 | } |
| 147 | 147 | itemData.playUrl = videoUrl; |
| 148 | 148 | that.setPlayUrl(videoUrl, idxTmp); | ... | ... |