Commit aed45e0f0dfa02e633c126b2e6d437b4db8769d4
1 parent
1ab73f69
优化多网卡
Showing
17 changed files
with
383 additions
and
322 deletions
src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
| @@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.common; | @@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.common; | ||
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | ||
| 5 | +import java.net.URL; | ||
| 6 | + | ||
| 5 | @Schema(description = "流信息") | 7 | @Schema(description = "流信息") |
| 6 | public class StreamInfo { | 8 | public class StreamInfo { |
| 7 | 9 | ||
| @@ -13,54 +15,56 @@ public class StreamInfo { | @@ -13,54 +15,56 @@ public class StreamInfo { | ||
| 13 | private String deviceID; | 15 | private String deviceID; |
| 14 | @Schema(description = "通道编号") | 16 | @Schema(description = "通道编号") |
| 15 | private String channelId; | 17 | private String channelId; |
| 16 | - @Schema(description = "HTTP-FLV流地址") | ||
| 17 | - private String flv; | ||
| 18 | 18 | ||
| 19 | @Schema(description = "IP") | 19 | @Schema(description = "IP") |
| 20 | private String ip; | 20 | private String ip; |
| 21 | + | ||
| 22 | + @Schema(description = "HTTP-FLV流地址") | ||
| 23 | + private StreamURL flv; | ||
| 24 | + | ||
| 21 | @Schema(description = "HTTPS-FLV流地址") | 25 | @Schema(description = "HTTPS-FLV流地址") |
| 22 | - private String https_flv; | 26 | + private StreamURL https_flv; |
| 23 | @Schema(description = "Websocket-FLV流地址") | 27 | @Schema(description = "Websocket-FLV流地址") |
| 24 | - private String ws_flv; | 28 | + private StreamURL ws_flv; |
| 25 | @Schema(description = "Websockets-FLV流地址") | 29 | @Schema(description = "Websockets-FLV流地址") |
| 26 | - private String wss_flv; | 30 | + private StreamURL wss_flv; |
| 27 | @Schema(description = "HTTP-FMP4流地址") | 31 | @Schema(description = "HTTP-FMP4流地址") |
| 28 | - private String fmp4; | 32 | + private StreamURL fmp4; |
| 29 | @Schema(description = "HTTPS-FMP4流地址") | 33 | @Schema(description = "HTTPS-FMP4流地址") |
| 30 | - private String https_fmp4; | 34 | + private StreamURL https_fmp4; |
| 31 | @Schema(description = "Websocket-FMP4流地址") | 35 | @Schema(description = "Websocket-FMP4流地址") |
| 32 | - private String ws_fmp4; | 36 | + private StreamURL ws_fmp4; |
| 33 | @Schema(description = "Websockets-FMP4流地址") | 37 | @Schema(description = "Websockets-FMP4流地址") |
| 34 | - private String wss_fmp4; | 38 | + private StreamURL wss_fmp4; |
| 35 | @Schema(description = "HLS流地址") | 39 | @Schema(description = "HLS流地址") |
| 36 | - private String hls; | 40 | + private StreamURL hls; |
| 37 | @Schema(description = "HTTPS-HLS流地址") | 41 | @Schema(description = "HTTPS-HLS流地址") |
| 38 | - private String https_hls; | 42 | + private StreamURL https_hls; |
| 39 | @Schema(description = "Websocket-HLS流地址") | 43 | @Schema(description = "Websocket-HLS流地址") |
| 40 | - private String ws_hls; | 44 | + private StreamURL ws_hls; |
| 41 | @Schema(description = "Websockets-HLS流地址") | 45 | @Schema(description = "Websockets-HLS流地址") |
| 42 | - private String wss_hls; | 46 | + private StreamURL wss_hls; |
| 43 | @Schema(description = "HTTP-TS流地址") | 47 | @Schema(description = "HTTP-TS流地址") |
| 44 | - private String ts; | 48 | + private StreamURL ts; |
| 45 | @Schema(description = "HTTPS-TS流地址") | 49 | @Schema(description = "HTTPS-TS流地址") |
| 46 | - private String https_ts; | 50 | + private StreamURL https_ts; |
| 47 | @Schema(description = "Websocket-TS流地址") | 51 | @Schema(description = "Websocket-TS流地址") |
| 48 | - private String ws_ts; | 52 | + private StreamURL ws_ts; |
| 49 | @Schema(description = "Websockets-TS流地址") | 53 | @Schema(description = "Websockets-TS流地址") |
| 50 | - private String wss_ts; | 54 | + private StreamURL wss_ts; |
| 51 | @Schema(description = "RTMP流地址") | 55 | @Schema(description = "RTMP流地址") |
| 52 | - private String rtmp; | 56 | + private StreamURL rtmp; |
| 53 | @Schema(description = "RTMPS流地址") | 57 | @Schema(description = "RTMPS流地址") |
| 54 | - private String rtmps; | 58 | + private StreamURL rtmps; |
| 55 | @Schema(description = "RTSP流地址") | 59 | @Schema(description = "RTSP流地址") |
| 56 | - private String rtsp; | 60 | + private StreamURL rtsp; |
| 57 | @Schema(description = "RTSPS流地址") | 61 | @Schema(description = "RTSPS流地址") |
| 58 | - private String rtsps; | 62 | + private StreamURL rtsps; |
| 59 | @Schema(description = "RTC流地址") | 63 | @Schema(description = "RTC流地址") |
| 60 | - private String rtc; | 64 | + private StreamURL rtc; |
| 61 | 65 | ||
| 62 | @Schema(description = "RTCS流地址") | 66 | @Schema(description = "RTCS流地址") |
| 63 | - private String rtcs; | 67 | + private StreamURL rtcs; |
| 64 | @Schema(description = "流媒体ID") | 68 | @Schema(description = "流媒体ID") |
| 65 | private String mediaServerId; | 69 | private String mediaServerId; |
| 66 | @Schema(description = "流编码信息") | 70 | @Schema(description = "流编码信息") |
| @@ -75,6 +79,102 @@ public class StreamInfo { | @@ -75,6 +79,102 @@ public class StreamInfo { | ||
| 75 | @Schema(description = "是否暂停(录像回放使用)") | 79 | @Schema(description = "是否暂停(录像回放使用)") |
| 76 | private boolean pause; | 80 | private boolean pause; |
| 77 | 81 | ||
| 82 | + public void setRtmp(String host, int port, int sslPort, String app, String stream, String callIdParam) { | ||
| 83 | + String file = String.format("%s/%s/%s", app, stream, callIdParam); | ||
| 84 | + this.rtmp = new StreamURL("rtmp", host, port, file); | ||
| 85 | + if (sslPort != 0) { | ||
| 86 | + this.rtmps = new StreamURL("rtmps", host, sslPort, file); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + public void setRtsp(String host, int port, int sslPort, String app, String stream, String callIdParam) { | ||
| 91 | + String file = String.format("%s/%s/%s", app, stream, callIdParam); | ||
| 92 | + this.rtsp = new StreamURL("rtsp", host, port, file); | ||
| 93 | + if (sslPort != 0) { | ||
| 94 | + this.rtsps = new StreamURL("rtsps", host, sslPort, file); | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public void setFlv(String host, int port, int sslPort, String app, String stream, String callIdParam) { | ||
| 99 | + String file = String.format("%s/%s.live.flv%s", app, stream, callIdParam); | ||
| 100 | + this.flv = new StreamURL("http", host, port, file); | ||
| 101 | + this.ws_flv = new StreamURL("ws", host, port, file); | ||
| 102 | + if (sslPort != 0) { | ||
| 103 | + this.https_flv = new StreamURL("https", host, sslPort, file); | ||
| 104 | + this.wss_flv = new StreamURL("wss", host, sslPort, file); | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public void setFmp4(String host, int port, int sslPort, String app, String stream, String callIdParam) { | ||
| 109 | + String file = String.format("%s/%s.live.mp4%s", app, stream, callIdParam); | ||
| 110 | + this.fmp4 = new StreamURL("http", host, port, file); | ||
| 111 | + this.ws_fmp4 = new StreamURL("ws", host, port, file); | ||
| 112 | + if (sslPort != 0) { | ||
| 113 | + this.https_fmp4 = new StreamURL("https", host, sslPort, file); | ||
| 114 | + this.wss_fmp4 = new StreamURL("wss", host, sslPort, file); | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + public void setHls(String host, int port, int sslPort, String app, String stream, String callIdParam) { | ||
| 119 | + String file = String.format("%s/%s/hls.m3u8%s", app, stream, callIdParam); | ||
| 120 | + this.hls = new StreamURL("http", host, port, file); | ||
| 121 | + this.ws_hls = new StreamURL("ws", host, port, file); | ||
| 122 | + if (sslPort != 0) { | ||
| 123 | + this.https_hls = new StreamURL("https", host, sslPort, file); | ||
| 124 | + this.wss_hls = new StreamURL("wss", host, sslPort, file); | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public void setTs(String host, int port, int sslPort, String app, String stream, String callIdParam) { | ||
| 129 | + String file = String.format("%s/%s.live.ts%s", app, stream, callIdParam); | ||
| 130 | + this.ts = new StreamURL("http", host, port, file); | ||
| 131 | + this.ws_ts = new StreamURL("ws", host, port, file); | ||
| 132 | + if (sslPort != 0) { | ||
| 133 | + this.https_ts = new StreamURL("https", host, sslPort, file); | ||
| 134 | + this.wss_ts = new StreamURL("wss", host, sslPort, file); | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + public void setRtc(String host, int port, int sslPort, String app, String stream, String callIdParam) { | ||
| 139 | + String file = String.format("index/api/webrtc?app=%s&stream=%s&type=play%s", app, stream, callIdParam); | ||
| 140 | + this.rtc = new StreamURL("http", host, port, file); | ||
| 141 | + if (sslPort != 0) { | ||
| 142 | + this.rtcs = new StreamURL("https", host, sslPort, file); | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + public void channgeStreamIp(String localAddr) { | ||
| 147 | + this.flv.setHost(localAddr); | ||
| 148 | + this.ws_flv.setHost(localAddr); | ||
| 149 | + this.hls.setHost(localAddr); | ||
| 150 | + this.ws_hls.setHost(localAddr); | ||
| 151 | + this.ts.setHost(localAddr); | ||
| 152 | + this.ws_ts.setHost(localAddr); | ||
| 153 | + this.fmp4.setHost(localAddr); | ||
| 154 | + this.ws_fmp4.setHost(localAddr); | ||
| 155 | + this.rtc.setHost(localAddr); | ||
| 156 | + if (this.https_flv != null) { | ||
| 157 | + this.https_flv.setHost(localAddr); | ||
| 158 | + this.wss_flv.setHost(localAddr); | ||
| 159 | + this.https_hls.setHost(localAddr); | ||
| 160 | + this.wss_hls.setHost(localAddr); | ||
| 161 | + this.wss_ts.setHost(localAddr); | ||
| 162 | + this.https_fmp4.setHost(localAddr); | ||
| 163 | + this.wss_fmp4.setHost(localAddr); | ||
| 164 | + this.rtcs.setHost(localAddr); | ||
| 165 | + } | ||
| 166 | + this.rtsp.setHost(localAddr); | ||
| 167 | + if (this.rtsps != null) { | ||
| 168 | + this.rtsps.setHost(localAddr); | ||
| 169 | + } | ||
| 170 | + this.rtmp.setHost(localAddr); | ||
| 171 | + if (this.rtmps != null) { | ||
| 172 | + this.rtmps.setHost(localAddr); | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + | ||
| 78 | public static class TransactionInfo{ | 178 | public static class TransactionInfo{ |
| 79 | public String callId; | 179 | public String callId; |
| 80 | public String localTag; | 180 | public String localTag; |
| @@ -108,207 +208,134 @@ public class StreamInfo { | @@ -108,207 +208,134 @@ public class StreamInfo { | ||
| 108 | this.channelId = channelId; | 208 | this.channelId = channelId; |
| 109 | } | 209 | } |
| 110 | 210 | ||
| 111 | - public String getFlv() { | ||
| 112 | - return flv; | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - public void setFlv(String flv) { | ||
| 116 | - this.flv = flv; | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - public String getWs_flv() { | ||
| 120 | - return ws_flv; | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - public void setWs_flv(String ws_flv) { | ||
| 124 | - this.ws_flv = ws_flv; | 211 | + public String getStream() { |
| 212 | + return stream; | ||
| 125 | } | 213 | } |
| 126 | 214 | ||
| 127 | - public String getRtmp() { | ||
| 128 | - return rtmp; | 215 | + public void setStream(String stream) { |
| 216 | + this.stream = stream; | ||
| 129 | } | 217 | } |
| 130 | 218 | ||
| 131 | - public void setRtmp(String rtmp) { | ||
| 132 | - this.rtmp = rtmp; | 219 | + public String getIp() { |
| 220 | + return ip; | ||
| 133 | } | 221 | } |
| 134 | 222 | ||
| 135 | - public String getHls() { | ||
| 136 | - return hls; | 223 | + public void setIp(String ip) { |
| 224 | + this.ip = ip; | ||
| 137 | } | 225 | } |
| 138 | 226 | ||
| 139 | - public void setHls(String hls) { | ||
| 140 | - this.hls = hls; | 227 | + public StreamURL getFlv() { |
| 228 | + return flv; | ||
| 141 | } | 229 | } |
| 142 | 230 | ||
| 143 | - public String getRtsp() { | ||
| 144 | - return rtsp; | 231 | + public StreamURL getHttps_flv() { |
| 232 | + return https_flv; | ||
| 145 | } | 233 | } |
| 146 | 234 | ||
| 147 | - public void setRtsp(String rtsp) { | ||
| 148 | - this.rtsp = rtsp; | 235 | + public StreamURL getWs_flv() { |
| 236 | + return ws_flv; | ||
| 149 | } | 237 | } |
| 150 | 238 | ||
| 151 | - public Object getTracks() { | ||
| 152 | - return tracks; | ||
| 153 | - } | ||
| 154 | 239 | ||
| 155 | - public void setTracks(Object tracks) { | ||
| 156 | - this.tracks = tracks; | 240 | + public StreamURL getWss_flv() { |
| 241 | + return wss_flv; | ||
| 157 | } | 242 | } |
| 158 | 243 | ||
| 159 | - public String getFmp4() { | 244 | + public StreamURL getFmp4() { |
| 160 | return fmp4; | 245 | return fmp4; |
| 161 | } | 246 | } |
| 162 | 247 | ||
| 163 | - public void setFmp4(String fmp4) { | ||
| 164 | - this.fmp4 = fmp4; | ||
| 165 | - } | ||
| 166 | 248 | ||
| 167 | - public String getWs_fmp4() { | ||
| 168 | - return ws_fmp4; | ||
| 169 | - } | ||
| 170 | - | ||
| 171 | - public void setWs_fmp4(String ws_fmp4) { | ||
| 172 | - this.ws_fmp4 = ws_fmp4; | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - public String getWs_hls() { | ||
| 176 | - return ws_hls; | ||
| 177 | - } | ||
| 178 | - | ||
| 179 | - public void setWs_hls(String ws_hls) { | ||
| 180 | - this.ws_hls = ws_hls; | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | - public String getTs() { | ||
| 184 | - return ts; | ||
| 185 | - } | ||
| 186 | 249 | ||
| 187 | - public void setTs(String ts) { | ||
| 188 | - this.ts = ts; | ||
| 189 | - } | ||
| 190 | - | ||
| 191 | - public String getWs_ts() { | ||
| 192 | - return ws_ts; | ||
| 193 | - } | ||
| 194 | - | ||
| 195 | - public void setWs_ts(String ws_ts) { | ||
| 196 | - this.ws_ts = ws_ts; | ||
| 197 | - } | ||
| 198 | - | ||
| 199 | - public String getStream() { | ||
| 200 | - return stream; | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - public void setStream(String stream) { | ||
| 204 | - this.stream = stream; | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - public String getRtc() { | ||
| 208 | - return rtc; | 250 | + public StreamURL getHttps_fmp4() { |
| 251 | + return https_fmp4; | ||
| 209 | } | 252 | } |
| 210 | 253 | ||
| 211 | - public void setRtc(String rtc) { | ||
| 212 | - this.rtc = rtc; | 254 | + public StreamURL getWs_fmp4() { |
| 255 | + return ws_fmp4; | ||
| 213 | } | 256 | } |
| 214 | 257 | ||
| 215 | - public TransactionInfo getTransactionInfo() { | ||
| 216 | - return transactionInfo; | 258 | + public StreamURL getWss_fmp4() { |
| 259 | + return wss_fmp4; | ||
| 217 | } | 260 | } |
| 218 | 261 | ||
| 219 | - public void setTransactionInfo(TransactionInfo transactionInfo) { | ||
| 220 | - this.transactionInfo = transactionInfo; | 262 | + public StreamURL getHls() { |
| 263 | + return hls; | ||
| 221 | } | 264 | } |
| 222 | 265 | ||
| 223 | - public String getMediaServerId() { | ||
| 224 | - return mediaServerId; | ||
| 225 | - } | ||
| 226 | 266 | ||
| 227 | - public void setMediaServerId(String mediaServerId) { | ||
| 228 | - this.mediaServerId = mediaServerId; | 267 | + public StreamURL getHttps_hls() { |
| 268 | + return https_hls; | ||
| 229 | } | 269 | } |
| 230 | 270 | ||
| 231 | - public String getHttps_flv() { | ||
| 232 | - return https_flv; | 271 | + public StreamURL getWs_hls() { |
| 272 | + return ws_hls; | ||
| 233 | } | 273 | } |
| 234 | 274 | ||
| 235 | - public void setHttps_flv(String https_flv) { | ||
| 236 | - this.https_flv = https_flv; | 275 | + public StreamURL getWss_hls() { |
| 276 | + return wss_hls; | ||
| 237 | } | 277 | } |
| 238 | 278 | ||
| 239 | - public String getWss_flv() { | ||
| 240 | - return wss_flv; | 279 | + public StreamURL getTs() { |
| 280 | + return ts; | ||
| 241 | } | 281 | } |
| 242 | 282 | ||
| 243 | - public void setWss_flv(String wss_flv) { | ||
| 244 | - this.wss_flv = wss_flv; | ||
| 245 | - } | ||
| 246 | 283 | ||
| 247 | - public String getWss_fmp4() { | ||
| 248 | - return wss_fmp4; | 284 | + public StreamURL getHttps_ts() { |
| 285 | + return https_ts; | ||
| 249 | } | 286 | } |
| 250 | 287 | ||
| 251 | - public void setWss_fmp4(String wss_fmp4) { | ||
| 252 | - this.wss_fmp4 = wss_fmp4; | ||
| 253 | - } | ||
| 254 | 288 | ||
| 255 | - public String getWss_hls() { | ||
| 256 | - return wss_hls; | 289 | + public StreamURL getWs_ts() { |
| 290 | + return ws_ts; | ||
| 257 | } | 291 | } |
| 258 | 292 | ||
| 259 | - public void setWss_hls(String wss_hls) { | ||
| 260 | - this.wss_hls = wss_hls; | ||
| 261 | - } | ||
| 262 | 293 | ||
| 263 | - public String getWss_ts() { | 294 | + public StreamURL getWss_ts() { |
| 264 | return wss_ts; | 295 | return wss_ts; |
| 265 | } | 296 | } |
| 266 | 297 | ||
| 267 | - public void setWss_ts(String wss_ts) { | ||
| 268 | - this.wss_ts = wss_ts; | 298 | + |
| 299 | + public StreamURL getRtmp() { | ||
| 300 | + return rtmp; | ||
| 269 | } | 301 | } |
| 270 | 302 | ||
| 271 | - public String getRtmps() { | 303 | + public StreamURL getRtmps() { |
| 272 | return rtmps; | 304 | return rtmps; |
| 273 | } | 305 | } |
| 274 | 306 | ||
| 275 | - public void setRtmps(String rtmps) { | ||
| 276 | - this.rtmps = rtmps; | 307 | + public StreamURL getRtsp() { |
| 308 | + return rtsp; | ||
| 277 | } | 309 | } |
| 278 | 310 | ||
| 279 | - public String getRtsps() { | 311 | + public StreamURL getRtsps() { |
| 280 | return rtsps; | 312 | return rtsps; |
| 281 | } | 313 | } |
| 282 | 314 | ||
| 283 | - public void setRtsps(String rtsps) { | ||
| 284 | - this.rtsps = rtsps; | ||
| 285 | - } | ||
| 286 | - | ||
| 287 | - public String getHttps_hls() { | ||
| 288 | - return https_hls; | 315 | + public StreamURL getRtc() { |
| 316 | + return rtc; | ||
| 289 | } | 317 | } |
| 290 | 318 | ||
| 291 | - public void setHttps_hls(String https_hls) { | ||
| 292 | - this.https_hls = https_hls; | 319 | + public StreamURL getRtcs() { |
| 320 | + return rtcs; | ||
| 293 | } | 321 | } |
| 294 | 322 | ||
| 295 | - public String getHttps_fmp4() { | ||
| 296 | - return https_fmp4; | 323 | + public String getMediaServerId() { |
| 324 | + return mediaServerId; | ||
| 297 | } | 325 | } |
| 298 | 326 | ||
| 299 | - public void setHttps_fmp4(String https_fmp4) { | ||
| 300 | - this.https_fmp4 = https_fmp4; | 327 | + public void setMediaServerId(String mediaServerId) { |
| 328 | + this.mediaServerId = mediaServerId; | ||
| 301 | } | 329 | } |
| 302 | 330 | ||
| 303 | - public String getHttps_ts() { | ||
| 304 | - return https_ts; | 331 | + public Object getTracks() { |
| 332 | + return tracks; | ||
| 305 | } | 333 | } |
| 306 | 334 | ||
| 307 | - public void setHttps_ts(String https_ts) { | ||
| 308 | - this.https_ts = https_ts; | 335 | + public void setTracks(Object tracks) { |
| 336 | + this.tracks = tracks; | ||
| 309 | } | 337 | } |
| 310 | 338 | ||
| 311 | - | ||
| 312 | public String getStartTime() { | 339 | public String getStartTime() { |
| 313 | return startTime; | 340 | return startTime; |
| 314 | } | 341 | } |
| @@ -333,22 +360,6 @@ public class StreamInfo { | @@ -333,22 +360,6 @@ public class StreamInfo { | ||
| 333 | this.progress = progress; | 360 | this.progress = progress; |
| 334 | } | 361 | } |
| 335 | 362 | ||
| 336 | - public String getIp() { | ||
| 337 | - return ip; | ||
| 338 | - } | ||
| 339 | - | ||
| 340 | - public void setIp(String ip) { | ||
| 341 | - this.ip = ip; | ||
| 342 | - } | ||
| 343 | - | ||
| 344 | - public String getRtcs() { | ||
| 345 | - return rtcs; | ||
| 346 | - } | ||
| 347 | - | ||
| 348 | - public void setRtcs(String rtcs) { | ||
| 349 | - this.rtcs = rtcs; | ||
| 350 | - } | ||
| 351 | - | ||
| 352 | public boolean isPause() { | 363 | public boolean isPause() { |
| 353 | return pause; | 364 | return pause; |
| 354 | } | 365 | } |
| @@ -356,4 +367,12 @@ public class StreamInfo { | @@ -356,4 +367,12 @@ public class StreamInfo { | ||
| 356 | public void setPause(boolean pause) { | 367 | public void setPause(boolean pause) { |
| 357 | this.pause = pause; | 368 | this.pause = pause; |
| 358 | } | 369 | } |
| 370 | + | ||
| 371 | + public TransactionInfo getTransactionInfo() { | ||
| 372 | + return transactionInfo; | ||
| 373 | + } | ||
| 374 | + | ||
| 375 | + public void setTransactionInfo(TransactionInfo transactionInfo) { | ||
| 376 | + this.transactionInfo = transactionInfo; | ||
| 377 | + } | ||
| 359 | } | 378 | } |
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 | + | ||
| 6 | +@Schema(description = "流地址信息") | ||
| 7 | +public class StreamURL { | ||
| 8 | + | ||
| 9 | + @Schema(description = "协议") | ||
| 10 | + private String protocol; | ||
| 11 | + | ||
| 12 | + @Schema(description = "主机地址") | ||
| 13 | + private String host; | ||
| 14 | + | ||
| 15 | + @Schema(description = "端口") | ||
| 16 | + private int port = -1; | ||
| 17 | + | ||
| 18 | + @Schema(description = "定位位置") | ||
| 19 | + private String file; | ||
| 20 | + | ||
| 21 | + @Schema(description = "拼接后的地址") | ||
| 22 | + private String url; | ||
| 23 | + | ||
| 24 | + public StreamURL() { | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public StreamURL(String protocol, String host, int port, String file) { | ||
| 28 | + this.protocol = protocol; | ||
| 29 | + this.host = host; | ||
| 30 | + this.port = port; | ||
| 31 | + this.file = file; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public String getProtocol() { | ||
| 35 | + return protocol; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public void setProtocol(String protocol) { | ||
| 39 | + this.protocol = protocol; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public String getHost() { | ||
| 43 | + return host; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public void setHost(String host) { | ||
| 47 | + this.host = host; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public int getPort() { | ||
| 51 | + return port; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setPort(int port) { | ||
| 55 | + this.port = port; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public String getFile() { | ||
| 59 | + return file; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public void setFile(String file) { | ||
| 63 | + this.file = file; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public String getUrl() { | ||
| 67 | + return this.toString(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public String toString() { | ||
| 72 | + if (protocol != null && host != null && port != -1 ) { | ||
| 73 | + return String.format("%s://%s:%s/%s", protocol, host, port, file); | ||
| 74 | + }else { | ||
| 75 | + return null; | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | +} |
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
| @@ -27,7 +27,7 @@ public class MediaConfig{ | @@ -27,7 +27,7 @@ public class MediaConfig{ | ||
| 27 | @Value("${media.ip}") | 27 | @Value("${media.ip}") |
| 28 | private String ip; | 28 | private String ip; |
| 29 | 29 | ||
| 30 | - @Value("${media.hook-ip:${sip.ip}}") | 30 | + @Value("${media.hook-ip:}") |
| 31 | private String hookIp; | 31 | private String hookIp; |
| 32 | 32 | ||
| 33 | @Value("${sip.ip}") | 33 | @Value("${sip.ip}") |
| @@ -92,7 +92,7 @@ public class MediaConfig{ | @@ -92,7 +92,7 @@ public class MediaConfig{ | ||
| 92 | 92 | ||
| 93 | public String getHookIp() { | 93 | public String getHookIp() { |
| 94 | if (ObjectUtils.isEmpty(hookIp)){ | 94 | if (ObjectUtils.isEmpty(hookIp)){ |
| 95 | - return sipIp; | 95 | + return sipIp.split(",")[0]; |
| 96 | }else { | 96 | }else { |
| 97 | return hookIp; | 97 | return hookIp; |
| 98 | } | 98 | } |
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
| @@ -33,6 +33,8 @@ public class UserSetting { | @@ -33,6 +33,8 @@ public class UserSetting { | ||
| 33 | 33 | ||
| 34 | private Boolean usePushingAsStatus = Boolean.TRUE; | 34 | private Boolean usePushingAsStatus = Boolean.TRUE; |
| 35 | 35 | ||
| 36 | + private Boolean useSourceIpAsStreamIp = Boolean.FALSE; | ||
| 37 | + | ||
| 36 | private Boolean streamOnDemand = Boolean.TRUE; | 38 | private Boolean streamOnDemand = Boolean.TRUE; |
| 37 | 39 | ||
| 38 | private String serverId = "000000"; | 40 | private String serverId = "000000"; |
| @@ -156,4 +158,12 @@ public class UserSetting { | @@ -156,4 +158,12 @@ public class UserSetting { | ||
| 156 | public void setStreamOnDemand(Boolean streamOnDemand) { | 158 | public void setStreamOnDemand(Boolean streamOnDemand) { |
| 157 | this.streamOnDemand = streamOnDemand; | 159 | this.streamOnDemand = streamOnDemand; |
| 158 | } | 160 | } |
| 161 | + | ||
| 162 | + public Boolean getUseSourceIpAsStreamIp() { | ||
| 163 | + return useSourceIpAsStreamIp; | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + public void setUseSourceIpAsStreamIp(Boolean useSourceIpAsStreamIp) { | ||
| 167 | + this.useSourceIpAsStreamIp = useSourceIpAsStreamIp; | ||
| 168 | + } | ||
| 159 | } | 169 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
| @@ -45,23 +45,23 @@ public class SIPRequestHeaderPlarformProvider { | @@ -45,23 +45,23 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 45 | @Autowired | 45 | @Autowired |
| 46 | private IRedisCatchStorage redisCatchStorage; | 46 | private IRedisCatchStorage redisCatchStorage; |
| 47 | 47 | ||
| 48 | - 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 { |
| 49 | Request request = null; | 49 | Request request = null; |
| 50 | - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); | 50 | + String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); |
| 51 | //请求行 | 51 | //请求行 |
| 52 | - SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), | ||
| 53 | - platform.getServerIP() + ":" + platform.getServerPort()); | 52 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), |
| 53 | + parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); | ||
| 54 | //via | 54 | //via |
| 55 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 55 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 56 | - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(platform.getServerIP(), platform.getServerPort(), platform.getTransport(), viaTag); | 56 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getServerIP(), parentPlatform.getServerPort(), parentPlatform.getTransport(), viaTag); |
| 57 | viaHeader.setRPort(); | 57 | viaHeader.setRPort(); |
| 58 | viaHeaders.add(viaHeader); | 58 | viaHeaders.add(viaHeader); |
| 59 | //from | 59 | //from |
| 60 | - SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); | 60 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); |
| 61 | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | 61 | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); |
| 62 | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); | 62 | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); |
| 63 | //to | 63 | //to |
| 64 | - SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); | 64 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); |
| 65 | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | 65 | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); |
| 66 | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); | 66 | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); |
| 67 | 67 | ||
| @@ -74,10 +74,10 @@ public class SIPRequestHeaderPlarformProvider { | @@ -74,10 +74,10 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 74 | cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | 74 | cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); |
| 75 | 75 | ||
| 76 | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() | 76 | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() |
| 77 | - .createSipURI(platform.getDeviceGBId(), sipAddress)); | 77 | + .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); |
| 78 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | 78 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| 79 | 79 | ||
| 80 | - ExpiresHeader expires = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(isRegister ? platform.getExpires() : 0); | 80 | + ExpiresHeader expires = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(isRegister ? parentPlatform.getExpires() : 0); |
| 81 | request.addHeader(expires); | 81 | request.addHeader(expires); |
| 82 | 82 | ||
| 83 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | 83 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| @@ -251,7 +251,7 @@ public class SIPRequestHeaderPlarformProvider { | @@ -251,7 +251,7 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 251 | SubscriptionStateHeader active = sipLayer.getSipFactory().createHeaderFactory().createSubscriptionStateHeader("active"); | 251 | SubscriptionStateHeader active = sipLayer.getSipFactory().createHeaderFactory().createSubscriptionStateHeader("active"); |
| 252 | request.setHeader(active); | 252 | request.setHeader(active); |
| 253 | 253 | ||
| 254 | - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); | 254 | + String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); |
| 255 | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() | 255 | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() |
| 256 | .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); | 256 | .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); |
| 257 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | 257 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| @@ -301,7 +301,7 @@ public class SIPRequestHeaderPlarformProvider { | @@ -301,7 +301,7 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 301 | 301 | ||
| 302 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | 302 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| 303 | 303 | ||
| 304 | - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); | 304 | + String sipAddress = platform.getDeviceIp() + ":" + platform.getDevicePort(); |
| 305 | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() | 305 | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() |
| 306 | .createSipURI(platform.getDeviceGBId(), sipAddress)); | 306 | .createSipURI(platform.getDeviceGBId(), sipAddress)); |
| 307 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | 307 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| @@ -52,7 +52,7 @@ public class SIPRequestHeaderProvider { | @@ -52,7 +52,7 @@ public class SIPRequestHeaderProvider { | ||
| 52 | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | 52 | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); |
| 53 | // via | 53 | // via |
| 54 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 54 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 55 | - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); | 55 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), viaTag); |
| 56 | viaHeader.setRPort(); | 56 | viaHeader.setRPort(); |
| 57 | viaHeaders.add(viaHeader); | 57 | viaHeaders.add(viaHeader); |
| 58 | // from | 58 | // from |
| @@ -85,7 +85,7 @@ public class SIPRequestHeaderProvider { | @@ -85,7 +85,7 @@ public class SIPRequestHeaderProvider { | ||
| 85 | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | 85 | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); |
| 86 | //via | 86 | //via |
| 87 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 87 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 88 | - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); | 88 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), viaTag); |
| 89 | viaHeader.setRPort(); | 89 | viaHeader.setRPort(); |
| 90 | viaHeaders.add(viaHeader); | 90 | viaHeaders.add(viaHeader); |
| 91 | 91 | ||
| @@ -107,7 +107,7 @@ public class SIPRequestHeaderProvider { | @@ -107,7 +107,7 @@ public class SIPRequestHeaderProvider { | ||
| 107 | 107 | ||
| 108 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | 108 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| 109 | 109 | ||
| 110 | - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | 110 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); |
| 111 | // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | 111 | // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); |
| 112 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | 112 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| 113 | // Subject | 113 | // Subject |
| @@ -124,7 +124,7 @@ public class SIPRequestHeaderProvider { | @@ -124,7 +124,7 @@ public class SIPRequestHeaderProvider { | ||
| 124 | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | 124 | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); |
| 125 | // via | 125 | // via |
| 126 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 126 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 127 | - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); | 127 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), viaTag); |
| 128 | viaHeader.setRPort(); | 128 | viaHeader.setRPort(); |
| 129 | viaHeaders.add(viaHeader); | 129 | viaHeaders.add(viaHeader); |
| 130 | //from | 130 | //from |
| @@ -143,7 +143,7 @@ public class SIPRequestHeaderProvider { | @@ -143,7 +143,7 @@ public class SIPRequestHeaderProvider { | ||
| 143 | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); | 143 | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); |
| 144 | request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | 144 | request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); |
| 145 | 145 | ||
| 146 | - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | 146 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); |
| 147 | // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | 147 | // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); |
| 148 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | 148 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| 149 | 149 | ||
| @@ -164,7 +164,7 @@ public class SIPRequestHeaderProvider { | @@ -164,7 +164,7 @@ public class SIPRequestHeaderProvider { | ||
| 164 | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | 164 | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); |
| 165 | // via | 165 | // via |
| 166 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 166 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 167 | - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | 167 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); |
| 168 | viaHeaders.add(viaHeader); | 168 | viaHeaders.add(viaHeader); |
| 169 | //from | 169 | //from |
| 170 | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | 170 | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); |
| @@ -185,7 +185,7 @@ public class SIPRequestHeaderProvider { | @@ -185,7 +185,7 @@ public class SIPRequestHeaderProvider { | ||
| 185 | 185 | ||
| 186 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | 186 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| 187 | 187 | ||
| 188 | - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | 188 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); |
| 189 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | 189 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| 190 | 190 | ||
| 191 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | 191 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| @@ -199,7 +199,7 @@ public class SIPRequestHeaderProvider { | @@ -199,7 +199,7 @@ public class SIPRequestHeaderProvider { | ||
| 199 | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | 199 | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); |
| 200 | // via | 200 | // via |
| 201 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 201 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 202 | - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), | 202 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), |
| 203 | device.getTransport(), SipUtils.getNewViaTag()); | 203 | device.getTransport(), SipUtils.getNewViaTag()); |
| 204 | viaHeader.setRPort(); | 204 | viaHeader.setRPort(); |
| 205 | viaHeaders.add(viaHeader); | 205 | viaHeaders.add(viaHeader); |
| @@ -222,7 +222,7 @@ public class SIPRequestHeaderProvider { | @@ -222,7 +222,7 @@ public class SIPRequestHeaderProvider { | ||
| 222 | toHeader, viaHeaders, maxForwards); | 222 | toHeader, viaHeaders, maxForwards); |
| 223 | 223 | ||
| 224 | 224 | ||
| 225 | - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | 225 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); |
| 226 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | 226 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| 227 | 227 | ||
| 228 | // Expires | 228 | // Expires |
| @@ -254,7 +254,7 @@ public class SIPRequestHeaderProvider { | @@ -254,7 +254,7 @@ public class SIPRequestHeaderProvider { | ||
| 254 | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | 254 | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); |
| 255 | // via | 255 | // via |
| 256 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 256 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 257 | - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | 257 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); |
| 258 | viaHeaders.add(viaHeader); | 258 | viaHeaders.add(viaHeader); |
| 259 | //from | 259 | //from |
| 260 | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | 260 | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); |
| @@ -275,7 +275,7 @@ public class SIPRequestHeaderProvider { | @@ -275,7 +275,7 @@ public class SIPRequestHeaderProvider { | ||
| 275 | 275 | ||
| 276 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | 276 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| 277 | 277 | ||
| 278 | - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | 278 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); |
| 279 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | 279 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| 280 | 280 | ||
| 281 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | 281 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| @@ -288,11 +288,12 @@ public class SIPRequestHeaderProvider { | @@ -288,11 +288,12 @@ public class SIPRequestHeaderProvider { | ||
| 288 | return request; | 288 | return request; |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | - public Request createAckRequest(SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException { | 291 | + public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 292 | + | ||
| 292 | 293 | ||
| 293 | // via | 294 | // via |
| 294 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 295 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 295 | - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag()); | 296 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag()); |
| 296 | viaHeaders.add(viaHeader); | 297 | viaHeaders.add(viaHeader); |
| 297 | 298 | ||
| 298 | //Forwards | 299 | //Forwards |
| @@ -305,7 +306,7 @@ public class SIPRequestHeaderProvider { | @@ -305,7 +306,7 @@ public class SIPRequestHeaderProvider { | ||
| 305 | 306 | ||
| 306 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | 307 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| 307 | 308 | ||
| 308 | - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | 309 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort())); |
| 309 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | 310 | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| 310 | 311 | ||
| 311 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | 312 | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
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,8 +9,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP | ||
| 9 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler; | 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler; |
| 11 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 11 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 12 | -import com.genersoft.iot.vmp.utils.SpringBeanFactory; | ||
| 13 | -import gov.nist.javax.sip.SipStackImpl; | ||
| 14 | import gov.nist.javax.sip.message.SIPRequest; | 12 | import gov.nist.javax.sip.message.SIPRequest; |
| 15 | import org.dom4j.Element; | 13 | import org.dom4j.Element; |
| 16 | import org.slf4j.Logger; | 14 | import org.slf4j.Logger; |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java
| @@ -104,11 +104,12 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract { | @@ -104,11 +104,12 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract { | ||
| 104 | } else { | 104 | } else { |
| 105 | sdp = SdpFactory.getInstance().createSessionDescription(contentString); | 105 | sdp = SdpFactory.getInstance().createSessionDescription(contentString); |
| 106 | } | 106 | } |
| 107 | + | ||
| 107 | SipURI requestUri = sipLayer.getSipFactory().createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort()); | 108 | SipURI requestUri = sipLayer.getSipFactory().createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort()); |
| 108 | - Request reqAck = headerProvider.createAckRequest(requestUri, response); | 109 | + Request reqAck = headerProvider.createAckRequest(response.getLocalAddress().getHostAddress(), requestUri, response); |
| 109 | 110 | ||
| 110 | logger.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort()); | 111 | logger.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort()); |
| 111 | - sipSender.transmitRequest(response.getLocalAddress().getHostAddress(), reqAck); | 112 | + sipSender.transmitRequest( response.getLocalAddress().getHostAddress(), reqAck); |
| 112 | } | 113 | } |
| 113 | } catch (InvalidArgumentException | ParseException | SipException | SdpParseException e) { | 114 | } catch (InvalidArgumentException | ParseException | SipException | SdpParseException e) { |
| 114 | logger.info("[点播回复ACK],异常:", e ); | 115 | logger.info("[点播回复ACK],异常:", e ); |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| @@ -608,7 +608,7 @@ public class MediaServerServiceImpl implements IMediaServerService { | @@ -608,7 +608,7 @@ public class MediaServerServiceImpl implements IMediaServerService { | ||
| 608 | mediaServerItem.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); | 608 | mediaServerItem.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); |
| 609 | mediaServerItem.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); | 609 | mediaServerItem.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); |
| 610 | mediaServerItem.setStreamIp(ip); | 610 | mediaServerItem.setStreamIp(ip); |
| 611 | - mediaServerItem.setHookIp(sipConfig.getIp()); | 611 | + mediaServerItem.setHookIp(sipConfig.getIp().split(",")[0]); |
| 612 | mediaServerItem.setSdpIp(ip); | 612 | mediaServerItem.setSdpIp(ip); |
| 613 | return mediaServerItem; | 613 | return mediaServerItem; |
| 614 | } | 614 | } |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
| @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; | @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; | ||
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | import com.genersoft.iot.vmp.common.StreamInfo; | 6 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 7 | +import com.genersoft.iot.vmp.common.StreamURL; | ||
| 7 | import com.genersoft.iot.vmp.conf.MediaConfig; | 8 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 8 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 9 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 9 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 10 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| @@ -18,6 +19,8 @@ import org.springframework.stereotype.Service; | @@ -18,6 +19,8 @@ import org.springframework.stereotype.Service; | ||
| 18 | import org.springframework.util.ObjectUtils; | 19 | import org.springframework.util.ObjectUtils; |
| 19 | import org.springframework.util.StringUtils; | 20 | import org.springframework.util.StringUtils; |
| 20 | 21 | ||
| 22 | +import java.net.URL; | ||
| 23 | + | ||
| 21 | @Service | 24 | @Service |
| 22 | public class MediaServiceImpl implements IMediaService { | 25 | public class MediaServiceImpl implements IMediaService { |
| 23 | 26 | ||
| @@ -93,38 +96,17 @@ public class MediaServiceImpl implements IMediaService { | @@ -93,38 +96,17 @@ public class MediaServiceImpl implements IMediaService { | ||
| 93 | if (addr == null) { | 96 | if (addr == null) { |
| 94 | addr = mediaInfo.getStreamIp(); | 97 | addr = mediaInfo.getStreamIp(); |
| 95 | } | 98 | } |
| 99 | + | ||
| 96 | streamInfoResult.setIp(addr); | 100 | streamInfoResult.setIp(addr); |
| 97 | streamInfoResult.setMediaServerId(mediaInfo.getId()); | 101 | streamInfoResult.setMediaServerId(mediaInfo.getId()); |
| 98 | String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId; | 102 | String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId; |
| 99 | - streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpPort(), app, stream, callIdParam)); | ||
| 100 | - if (mediaInfo.getRtmpSSlPort() != 0) { | ||
| 101 | - streamInfoResult.setRtmps(String.format("rtmps://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpSSlPort(), app, stream, callIdParam)); | ||
| 102 | - } | ||
| 103 | - streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s%s", addr, mediaInfo.getRtspPort(), app, stream, callIdParam)); | ||
| 104 | - if (mediaInfo.getRtspSSLPort() != 0) { | ||
| 105 | - streamInfoResult.setRtsps(String.format("rtsps://%s:%s/%s/%s%s", addr, mediaInfo.getRtspSSLPort(), app, stream, callIdParam)); | ||
| 106 | - } | ||
| 107 | - streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | ||
| 108 | - streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | ||
| 109 | - streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | ||
| 110 | - streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | ||
| 111 | - streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | ||
| 112 | - streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | ||
| 113 | - streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | ||
| 114 | - streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); | ||
| 115 | - 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)); | ||
| 116 | - if (mediaInfo.getHttpSSlPort() != 0) { | ||
| 117 | - streamInfoResult.setHttps_flv(String.format("https://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | ||
| 118 | - streamInfoResult.setWss_flv(String.format("wss://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | ||
| 119 | - streamInfoResult.setHttps_hls(String.format("https://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | ||
| 120 | - streamInfoResult.setWss_hls(String.format("wss://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | ||
| 121 | - streamInfoResult.setHttps_fmp4(String.format("https://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | ||
| 122 | - streamInfoResult.setWss_fmp4(String.format("wss://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | ||
| 123 | - streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | ||
| 124 | - streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | ||
| 125 | - streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); | ||
| 126 | - 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)); | ||
| 127 | - } | 103 | + streamInfoResult.setRtmp(addr, mediaInfo.getRtmpPort(),mediaInfo.getRtmpSSlPort(), app, stream, callIdParam); |
| 104 | + streamInfoResult.setRtsp(addr, mediaInfo.getRtspPort(),mediaInfo.getRtspSSLPort(), app, stream, callIdParam); | ||
| 105 | + streamInfoResult.setFlv(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | ||
| 106 | + streamInfoResult.setFmp4(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | ||
| 107 | + streamInfoResult.setHls(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | ||
| 108 | + streamInfoResult.setTs(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | ||
| 109 | + streamInfoResult.setRtc(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | ||
| 128 | 110 | ||
| 129 | streamInfoResult.setTracks(tracks); | 111 | streamInfoResult.setTracks(tracks); |
| 130 | return streamInfoResult; | 112 | return streamInfoResult; |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -143,7 +143,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -143,7 +143,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 143 | if (Objects.requireNonNull(wvpResult).getCode() == 0) { | 143 | if (Objects.requireNonNull(wvpResult).getCode() == 0) { |
| 144 | StreamInfo streamInfoForSuccess = (StreamInfo) wvpResult.getData(); | 144 | StreamInfo streamInfoForSuccess = (StreamInfo) wvpResult.getData(); |
| 145 | MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId()); | 145 | MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId()); |
| 146 | - String streamUrl = streamInfoForSuccess.getFmp4(); | 146 | + String streamUrl = streamInfoForSuccess.getFmp4().getUrl(); |
| 147 | 147 | ||
| 148 | // 请求截图 | 148 | // 请求截图 |
| 149 | logger.info("[请求截图]: " + fileName); | 149 | logger.info("[请求截图]: " + fileName); |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
| @@ -415,47 +415,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | @@ -415,47 +415,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 415 | return streamProxyMapper.updateStatus(app, stream, status); | 415 | return streamProxyMapper.updateStatus(app, stream, status); |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | - private void syncPullStream(String mediaServerId){ | ||
| 419 | - MediaServerItem mediaServer = mediaServerService.getOne(mediaServerId); | ||
| 420 | - if (mediaServer != null) { | ||
| 421 | - List<MediaItem> allPullStream = redisCatchStorage.getStreams(mediaServerId, "PULL"); | ||
| 422 | - if (allPullStream.size() > 0) { | ||
| 423 | - zlmresTfulUtils.getMediaList(mediaServer, jsonObject->{ | ||
| 424 | - Map<String, StreamInfo> stringStreamInfoMap = new HashMap<>(); | ||
| 425 | - if (jsonObject.getInteger("code") == 0) { | ||
| 426 | - JSONArray data = jsonObject.getJSONArray("data"); | ||
| 427 | - if(data != null && data.size() > 0) { | ||
| 428 | - for (int i = 0; i < data.size(); i++) { | ||
| 429 | - JSONObject streamJSONObj = data.getJSONObject(i); | ||
| 430 | - if ("rtsp".equals(streamJSONObj.getString("schema"))) { | ||
| 431 | - StreamInfo streamInfo = new StreamInfo(); | ||
| 432 | - String app = streamJSONObj.getString("app"); | ||
| 433 | - String stream = streamJSONObj.getString("stream"); | ||
| 434 | - streamInfo.setApp(app); | ||
| 435 | - streamInfo.setStream(stream); | ||
| 436 | - stringStreamInfoMap.put(app+stream, streamInfo); | ||
| 437 | - } | ||
| 438 | - } | ||
| 439 | - } | ||
| 440 | - } | ||
| 441 | - if (stringStreamInfoMap.size() == 0) { | ||
| 442 | - redisCatchStorage.removeStream(mediaServerId, "PULL"); | ||
| 443 | - }else { | ||
| 444 | - for (String key : stringStreamInfoMap.keySet()) { | ||
| 445 | - StreamInfo streamInfo = stringStreamInfoMap.get(key); | ||
| 446 | - if (stringStreamInfoMap.get(streamInfo.getApp() + streamInfo.getStream()) == null) { | ||
| 447 | - redisCatchStorage.removeStream(mediaServerId, "PULL", streamInfo.getApp(), | ||
| 448 | - streamInfo.getStream()); | ||
| 449 | - } | ||
| 450 | - } | ||
| 451 | - } | ||
| 452 | - }); | ||
| 453 | - } | ||
| 454 | - | ||
| 455 | - } | ||
| 456 | - | ||
| 457 | - } | ||
| 458 | - | ||
| 459 | @Override | 418 | @Override |
| 460 | public ResourceBaceInfo getOverview() { | 419 | public ResourceBaceInfo getOverview() { |
| 461 | return streamProxyMapper.getOverview(); | 420 | return streamProxyMapper.getOverview(); |
src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
| @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.play; | @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.play; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONArray; | 3 | import com.alibaba.fastjson.JSONArray; |
| 4 | import com.genersoft.iot.vmp.common.StreamInfo; | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | +import com.genersoft.iot.vmp.conf.UserSetting; | ||
| 5 | import com.genersoft.iot.vmp.conf.exception.ControllerException; | 6 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 6 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; | 7 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 7 | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; | 8 | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; |
| @@ -37,6 +38,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | @@ -37,6 +38,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | ||
| 37 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 38 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 38 | import org.springframework.web.context.request.async.DeferredResult; | 39 | import org.springframework.web.context.request.async.DeferredResult; |
| 39 | 40 | ||
| 41 | +import javax.servlet.http.HttpServlet; | ||
| 42 | +import javax.servlet.http.HttpServletRequest; | ||
| 40 | import javax.sip.InvalidArgumentException; | 43 | import javax.sip.InvalidArgumentException; |
| 41 | import javax.sip.SipException; | 44 | import javax.sip.SipException; |
| 42 | import java.text.ParseException; | 45 | import java.text.ParseException; |
| @@ -78,18 +81,25 @@ public class PlayController { | @@ -78,18 +81,25 @@ public class PlayController { | ||
| 78 | @Autowired | 81 | @Autowired |
| 79 | private IMediaServerService mediaServerService; | 82 | private IMediaServerService mediaServerService; |
| 80 | 83 | ||
| 84 | + @Autowired | ||
| 85 | + private UserSetting userSetting; | ||
| 86 | + | ||
| 81 | @Operation(summary = "开始点播") | 87 | @Operation(summary = "开始点播") |
| 82 | @Parameter(name = "deviceId", description = "设备国标编号", required = true) | 88 | @Parameter(name = "deviceId", description = "设备国标编号", required = true) |
| 83 | @Parameter(name = "channelId", description = "通道国标编号", required = true) | 89 | @Parameter(name = "channelId", description = "通道国标编号", required = true) |
| 84 | @GetMapping("/start/{deviceId}/{channelId}") | 90 | @GetMapping("/start/{deviceId}/{channelId}") |
| 85 | - public DeferredResult<WVPResult<StreamInfo>> play(@PathVariable String deviceId, | ||
| 86 | - @PathVariable String channelId) { | 91 | + public DeferredResult<WVPResult<StreamInfo>> play(HttpServletRequest request, @PathVariable String deviceId, |
| 92 | + @PathVariable String channelId) { | ||
| 87 | 93 | ||
| 88 | // 获取可用的zlm | 94 | // 获取可用的zlm |
| 89 | Device device = storager.queryVideoDevice(deviceId); | 95 | Device device = storager.queryVideoDevice(deviceId); |
| 90 | MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); | 96 | MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); |
| 91 | PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null, null); | 97 | PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null, null); |
| 92 | - | 98 | + playResult.getResult().onCompletion(()->{ |
| 99 | + WVPResult<StreamInfo> result = (WVPResult<StreamInfo>)playResult.getResult().getResult(); | ||
| 100 | + result.getData().channgeStreamIp(request.getLocalAddr()); | ||
| 101 | + playResult.getResult().setResult(result); | ||
| 102 | + }); | ||
| 93 | return playResult.getResult(); | 103 | return playResult.getResult(); |
| 94 | } | 104 | } |
| 95 | 105 |
src/main/resources/all-application.yml
| @@ -188,6 +188,8 @@ user-settings: | @@ -188,6 +188,8 @@ user-settings: | ||
| 188 | logInDatebase: true | 188 | logInDatebase: true |
| 189 | # 使用推流状态作为推流通道状态 | 189 | # 使用推流状态作为推流通道状态 |
| 190 | use-pushing-as-status: true | 190 | use-pushing-as-status: true |
| 191 | + # 使用来源请求ip作为streamIp | ||
| 192 | + use-source-ip-as-stream-ip: true | ||
| 191 | # 按需拉流, true:有人观看拉流,无人观看释放, false:拉起后不自动释放 | 193 | # 按需拉流, true:有人观看拉流,无人观看释放, false:拉起后不自动释放 |
| 192 | stream-on-demand: true | 194 | stream-on-demand: true |
| 193 | 195 |
web_src/src/components/dialog/devicePlayer.vue
| @@ -53,89 +53,89 @@ | @@ -53,89 +53,89 @@ | ||
| 53 | 更多地址<i class="el-icon-arrow-down el-icon--right"></i> | 53 | 更多地址<i class="el-icon-arrow-down el-icon--right"></i> |
| 54 | </el-button> | 54 | </el-button> |
| 55 | <el-dropdown-menu slot="dropdown" > | 55 | <el-dropdown-menu slot="dropdown" > |
| 56 | - <el-dropdown-item :command="streamInfo.flv"> | 56 | + <el-dropdown-item :command="streamInfo.flv.url"> |
| 57 | <el-tag >FLV:</el-tag> | 57 | <el-tag >FLV:</el-tag> |
| 58 | - <span>{{ streamInfo.flv }}</span> | 58 | + <span>{{ streamInfo.flv.url }}</span> |
| 59 | </el-dropdown-item> | 59 | </el-dropdown-item> |
| 60 | - <el-dropdown-item :command="streamInfo.https_flv"> | 60 | + <el-dropdown-item :command="streamInfo.https_flv.url"> |
| 61 | <el-tag >FLV(https):</el-tag> | 61 | <el-tag >FLV(https):</el-tag> |
| 62 | - <span>{{ streamInfo.https_flv }}</span> | 62 | + <span>{{ streamInfo.https_flv.url }}</span> |
| 63 | </el-dropdown-item> | 63 | </el-dropdown-item> |
| 64 | - <el-dropdown-item :command="streamInfo.ws_flv"> | 64 | + <el-dropdown-item :command="streamInfo.ws_flv.url"> |
| 65 | <el-tag >FLV(ws):</el-tag> | 65 | <el-tag >FLV(ws):</el-tag> |
| 66 | - <span >{{ streamInfo.ws_flv }}</span> | 66 | + <span >{{ streamInfo.ws_flv.url }}</span> |
| 67 | </el-dropdown-item> | 67 | </el-dropdown-item> |
| 68 | - <el-dropdown-item :command="streamInfo.wss_flv"> | 68 | + <el-dropdown-item :command="streamInfo.wss_flv.url"> |
| 69 | <el-tag >FLV(wss):</el-tag> | 69 | <el-tag >FLV(wss):</el-tag> |
| 70 | - <span>{{ streamInfo.wss_flv }}</span> | 70 | + <span>{{ streamInfo.wss_flv.url }}</span> |
| 71 | </el-dropdown-item> | 71 | </el-dropdown-item> |
| 72 | - <el-dropdown-item :command="streamInfo.fmp4"> | 72 | + <el-dropdown-item :command="streamInfo.fmp4.url"> |
| 73 | <el-tag >FMP4:</el-tag> | 73 | <el-tag >FMP4:</el-tag> |
| 74 | - <span>{{ streamInfo.fmp4 }}</span> | 74 | + <span>{{ streamInfo.fmp4.url }}</span> |
| 75 | </el-dropdown-item> | 75 | </el-dropdown-item> |
| 76 | - <el-dropdown-item :command="streamInfo.https_fmp4"> | 76 | + <el-dropdown-item :command="streamInfo.https_fmp4.url"> |
| 77 | <el-tag >FMP4(https):</el-tag> | 77 | <el-tag >FMP4(https):</el-tag> |
| 78 | - <span>{{ streamInfo.https_fmp4 }}</span> | 78 | + <span>{{ streamInfo.https_fmp4.url }}</span> |
| 79 | </el-dropdown-item> | 79 | </el-dropdown-item> |
| 80 | - <el-dropdown-item :command="streamInfo.ws_fmp4"> | 80 | + <el-dropdown-item :command="streamInfo.ws_fmp4.url"> |
| 81 | <el-tag >FMP4(ws):</el-tag> | 81 | <el-tag >FMP4(ws):</el-tag> |
| 82 | - <span>{{ streamInfo.ws_fmp4 }}</span> | 82 | + <span>{{ streamInfo.ws_fmp4.url }}</span> |
| 83 | </el-dropdown-item> | 83 | </el-dropdown-item> |
| 84 | - <el-dropdown-item :command="streamInfo.wss_fmp4"> | 84 | + <el-dropdown-item :command="streamInfo.wss_fmp4.url"> |
| 85 | <el-tag >FMP4(wss):</el-tag> | 85 | <el-tag >FMP4(wss):</el-tag> |
| 86 | - <span>{{ streamInfo.wss_fmp4 }}</span> | 86 | + <span>{{ streamInfo.wss_fmp4.url }}</span> |
| 87 | </el-dropdown-item> | 87 | </el-dropdown-item> |
| 88 | - <el-dropdown-item :command="streamInfo.hls"> | 88 | + <el-dropdown-item :command="streamInfo.hls.url"> |
| 89 | <el-tag>HLS:</el-tag> | 89 | <el-tag>HLS:</el-tag> |
| 90 | - <span>{{ streamInfo.hls }}</span> | 90 | + <span>{{ streamInfo.hls.url }}</span> |
| 91 | </el-dropdown-item> | 91 | </el-dropdown-item> |
| 92 | - <el-dropdown-item :command="streamInfo.https_hls"> | 92 | + <el-dropdown-item :command="streamInfo.https_hls.url"> |
| 93 | <el-tag >HLS(https):</el-tag> | 93 | <el-tag >HLS(https):</el-tag> |
| 94 | - <span>{{ streamInfo.https_hls }}</span> | 94 | + <span>{{ streamInfo.https_hls.url }}</span> |
| 95 | </el-dropdown-item> | 95 | </el-dropdown-item> |
| 96 | - <el-dropdown-item :command="streamInfo.ws_hls"> | 96 | + <el-dropdown-item :command="streamInfo.ws_hls.url"> |
| 97 | <el-tag >HLS(ws):</el-tag> | 97 | <el-tag >HLS(ws):</el-tag> |
| 98 | - <span>{{ streamInfo.ws_hls }}</span> | 98 | + <span>{{ streamInfo.ws_hls.url }}</span> |
| 99 | </el-dropdown-item> | 99 | </el-dropdown-item> |
| 100 | - <el-dropdown-item :command="streamInfo.wss_hls"> | 100 | + <el-dropdown-item :command="streamInfo.wss_hls.url"> |
| 101 | <el-tag >HLS(wss):</el-tag> | 101 | <el-tag >HLS(wss):</el-tag> |
| 102 | - <span>{{ streamInfo.wss_hls }}</span> | 102 | + <span>{{ streamInfo.wss_hls.url }}</span> |
| 103 | </el-dropdown-item> | 103 | </el-dropdown-item> |
| 104 | - <el-dropdown-item :command="streamInfo.ts"> | 104 | + <el-dropdown-item :command="streamInfo.ts.url"> |
| 105 | <el-tag>TS:</el-tag> | 105 | <el-tag>TS:</el-tag> |
| 106 | - <span>{{ streamInfo.ts }}</span> | 106 | + <span>{{ streamInfo.ts.url }}</span> |
| 107 | </el-dropdown-item> | 107 | </el-dropdown-item> |
| 108 | - <el-dropdown-item :command="streamInfo.https_ts"> | 108 | + <el-dropdown-item :command="streamInfo.https_ts.url"> |
| 109 | <el-tag>TS(https):</el-tag> | 109 | <el-tag>TS(https):</el-tag> |
| 110 | - <span>{{ streamInfo.https_ts }}</span> | 110 | + <span>{{ streamInfo.https_ts.url }}</span> |
| 111 | </el-dropdown-item> | 111 | </el-dropdown-item> |
| 112 | - <el-dropdown-item :command="streamInfo.ws_ts"> | 112 | + <el-dropdown-item :command="streamInfo.ws_ts.url"> |
| 113 | <el-tag>TS(ws):</el-tag> | 113 | <el-tag>TS(ws):</el-tag> |
| 114 | - <span>{{ streamInfo.ws_ts }}</span> | 114 | + <span>{{ streamInfo.ws_ts.url }}</span> |
| 115 | </el-dropdown-item> | 115 | </el-dropdown-item> |
| 116 | - <el-dropdown-item :command="streamInfo.wss_ts"> | 116 | + <el-dropdown-item :command="streamInfo.wss_ts.url"> |
| 117 | <el-tag>TS(wss):</el-tag> | 117 | <el-tag>TS(wss):</el-tag> |
| 118 | - <span>{{ streamInfo.wss_ts }}</span> | 118 | + <span>{{ streamInfo.wss_ts.url }}</span> |
| 119 | </el-dropdown-item> | 119 | </el-dropdown-item> |
| 120 | - <el-dropdown-item :command="streamInfo.rtc"> | 120 | + <el-dropdown-item :command="streamInfo.rtc.url"> |
| 121 | <el-tag >RTC:</el-tag> | 121 | <el-tag >RTC:</el-tag> |
| 122 | - <span>{{ streamInfo.rtc }}</span> | 122 | + <span>{{ streamInfo.rtc.url }}</span> |
| 123 | </el-dropdown-item> | 123 | </el-dropdown-item> |
| 124 | - <el-dropdown-item :command="streamInfo.rtmp"> | 124 | + <el-dropdown-item :command="streamInfo.rtmp.url"> |
| 125 | <el-tag >RTMP:</el-tag> | 125 | <el-tag >RTMP:</el-tag> |
| 126 | - <span>{{ streamInfo.rtmp }}</span> | 126 | + <span>{{ streamInfo.rtmp.url }}</span> |
| 127 | </el-dropdown-item> | 127 | </el-dropdown-item> |
| 128 | - <el-dropdown-item :command="streamInfo.rtmps"> | 128 | + <el-dropdown-item :command="streamInfo.rtmps.url"> |
| 129 | <el-tag >RTMPS:</el-tag> | 129 | <el-tag >RTMPS:</el-tag> |
| 130 | - <span>{{ streamInfo.rtmps }}</span> | 130 | + <span>{{ streamInfo.rtmps.url }}</span> |
| 131 | </el-dropdown-item> | 131 | </el-dropdown-item> |
| 132 | - <el-dropdown-item :command="streamInfo.rtsp"> | 132 | + <el-dropdown-item :command="streamInfo.rtsp.url"> |
| 133 | <el-tag >RTSP:</el-tag> | 133 | <el-tag >RTSP:</el-tag> |
| 134 | - <span>{{ streamInfo.rtsp }}</span> | 134 | + <span>{{ streamInfo.rtsp.url }}</span> |
| 135 | </el-dropdown-item> | 135 | </el-dropdown-item> |
| 136 | - <el-dropdown-item :command="streamInfo.rtsps"> | 136 | + <el-dropdown-item :command="streamInfo.rtsps.url"> |
| 137 | <el-tag >RTSPS:</el-tag> | 137 | <el-tag >RTSPS:</el-tag> |
| 138 | - <span>{{ streamInfo.rtsps }}</span> | 138 | + <span>{{ streamInfo.rtsps.url }}</span> |
| 139 | </el-dropdown-item> | 139 | </el-dropdown-item> |
| 140 | </el-dropdown-menu> | 140 | </el-dropdown-menu> |
| 141 | </el-dropdown> | 141 | </el-dropdown> |
| @@ -393,7 +393,7 @@ export default { | @@ -393,7 +393,7 @@ export default { | ||
| 393 | changePlayer: function (tab) { | 393 | changePlayer: function (tab) { |
| 394 | console.log(this.player[tab.name][0]) | 394 | console.log(this.player[tab.name][0]) |
| 395 | this.activePlayer = tab.name; | 395 | this.activePlayer = tab.name; |
| 396 | - this.videoUrl = this.streamInfo[this.player[tab.name][0]] | 396 | + this.videoUrl = this.streamInfo[this.player[tab.name][0]].url |
| 397 | console.log(this.videoUrl) | 397 | console.log(this.videoUrl) |
| 398 | }, | 398 | }, |
| 399 | openDialog: function (tab, deviceId, channelId, param) { | 399 | openDialog: function (tab, deviceId, channelId, param) { |
| @@ -446,9 +446,9 @@ export default { | @@ -446,9 +446,9 @@ export default { | ||
| 446 | getUrlByStreamInfo(){ | 446 | getUrlByStreamInfo(){ |
| 447 | console.log(this.streamInfo) | 447 | console.log(this.streamInfo) |
| 448 | if (location.protocol === "https:") { | 448 | if (location.protocol === "https:") { |
| 449 | - this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]] | 449 | + this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]].url |
| 450 | }else { | 450 | }else { |
| 451 | - this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]] | 451 | + this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]].url |
| 452 | } | 452 | } |
| 453 | return this.videoUrl; | 453 | return this.videoUrl; |
| 454 | 454 |
web_src/src/components/live.vue
| @@ -138,8 +138,8 @@ export default { | @@ -138,8 +138,8 @@ export default { | ||
| 138 | url: '/api/play/start/' + deviceId + '/' + channelId | 138 | url: '/api/play/start/' + deviceId + '/' + channelId |
| 139 | }).then(function (res) { | 139 | }).then(function (res) { |
| 140 | if (res.data.code === 0 && res.data.data) { | 140 | if (res.data.code === 0 && res.data.data) { |
| 141 | - itemData.playUrl = res.data.data.httpsFlv | ||
| 142 | - that.setPlayUrl(res.data.data.ws_flv, idxTmp) | 141 | + itemData.playUrl = res.data.data.https_flv.url |
| 142 | + that.setPlayUrl(res.data.data.ws_flv.url, idxTmp) | ||
| 143 | } else { | 143 | } else { |
| 144 | that.$message.error(res.data.msg); | 144 | that.$message.error(res.data.msg); |
| 145 | } | 145 | } |