From aed45e0f0dfa02e633c126b2e6d437b4db8769d4 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 28 Oct 2022 16:40:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=9A=E7=BD=91=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/common/StreamInfo.java | 449 +++++++++--------- .../genersoft/iot/vmp/common/StreamURL.java | 78 +++ .../genersoft/iot/vmp/conf/MediaConfig.java | 4 +- .../genersoft/iot/vmp/conf/UserSetting.java | 10 + .../cmd/SIPRequestHeaderPlarformProvider.java | 22 +- .../cmd/SIPRequestHeaderProvider.java | 29 +- .../cmd/DeviceControlQueryMessageHandler.java | 2 - .../impl/InviteResponseProcessor.java | 5 +- .../service/impl/MediaServerServiceImpl.java | 2 +- .../vmp/service/impl/MediaServiceImpl.java | 40 +- .../iot/vmp/service/impl/PlayServiceImpl.java | 2 +- .../service/impl/StreamProxyServiceImpl.java | 41 -- .../iot/vmp/vmanager/bean/WVPResult.java | 1 + .../vmanager/gb28181/play/PlayController.java | 16 +- src/main/resources/all-application.yml | 2 + .../src/components/dialog/devicePlayer.vue | 90 ++-- web_src/src/components/live.vue | 4 +- 17 files changed, 429 insertions(+), 368 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/common/StreamURL.java diff --git a/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java b/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java index 93d837c8..20a286cd 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java @@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.common; import io.swagger.v3.oas.annotations.media.Schema; +import java.net.URL; + @Schema(description = "流信息") public class StreamInfo { @@ -13,54 +15,56 @@ public class StreamInfo { private String deviceID; @Schema(description = "通道编号") private String channelId; - @Schema(description = "HTTP-FLV流地址") - private String flv; @Schema(description = "IP") private String ip; + + @Schema(description = "HTTP-FLV流地址") + private StreamURL flv; + @Schema(description = "HTTPS-FLV流地址") - private String https_flv; + private StreamURL https_flv; @Schema(description = "Websocket-FLV流地址") - private String ws_flv; + private StreamURL ws_flv; @Schema(description = "Websockets-FLV流地址") - private String wss_flv; + private StreamURL wss_flv; @Schema(description = "HTTP-FMP4流地址") - private String fmp4; + private StreamURL fmp4; @Schema(description = "HTTPS-FMP4流地址") - private String https_fmp4; + private StreamURL https_fmp4; @Schema(description = "Websocket-FMP4流地址") - private String ws_fmp4; + private StreamURL ws_fmp4; @Schema(description = "Websockets-FMP4流地址") - private String wss_fmp4; + private StreamURL wss_fmp4; @Schema(description = "HLS流地址") - private String hls; + private StreamURL hls; @Schema(description = "HTTPS-HLS流地址") - private String https_hls; + private StreamURL https_hls; @Schema(description = "Websocket-HLS流地址") - private String ws_hls; + private StreamURL ws_hls; @Schema(description = "Websockets-HLS流地址") - private String wss_hls; + private StreamURL wss_hls; @Schema(description = "HTTP-TS流地址") - private String ts; + private StreamURL ts; @Schema(description = "HTTPS-TS流地址") - private String https_ts; + private StreamURL https_ts; @Schema(description = "Websocket-TS流地址") - private String ws_ts; + private StreamURL ws_ts; @Schema(description = "Websockets-TS流地址") - private String wss_ts; + private StreamURL wss_ts; @Schema(description = "RTMP流地址") - private String rtmp; + private StreamURL rtmp; @Schema(description = "RTMPS流地址") - private String rtmps; + private StreamURL rtmps; @Schema(description = "RTSP流地址") - private String rtsp; + private StreamURL rtsp; @Schema(description = "RTSPS流地址") - private String rtsps; + private StreamURL rtsps; @Schema(description = "RTC流地址") - private String rtc; + private StreamURL rtc; @Schema(description = "RTCS流地址") - private String rtcs; + private StreamURL rtcs; @Schema(description = "流媒体ID") private String mediaServerId; @Schema(description = "流编码信息") @@ -75,6 +79,102 @@ public class StreamInfo { @Schema(description = "是否暂停(录像回放使用)") private boolean pause; + public void setRtmp(String host, int port, int sslPort, String app, String stream, String callIdParam) { + String file = String.format("%s/%s/%s", app, stream, callIdParam); + this.rtmp = new StreamURL("rtmp", host, port, file); + if (sslPort != 0) { + this.rtmps = new StreamURL("rtmps", host, sslPort, file); + } + } + + public void setRtsp(String host, int port, int sslPort, String app, String stream, String callIdParam) { + String file = String.format("%s/%s/%s", app, stream, callIdParam); + this.rtsp = new StreamURL("rtsp", host, port, file); + if (sslPort != 0) { + this.rtsps = new StreamURL("rtsps", host, sslPort, file); + } + } + + public void setFlv(String host, int port, int sslPort, String app, String stream, String callIdParam) { + String file = String.format("%s/%s.live.flv%s", app, stream, callIdParam); + this.flv = new StreamURL("http", host, port, file); + this.ws_flv = new StreamURL("ws", host, port, file); + if (sslPort != 0) { + this.https_flv = new StreamURL("https", host, sslPort, file); + this.wss_flv = new StreamURL("wss", host, sslPort, file); + } + } + + public void setFmp4(String host, int port, int sslPort, String app, String stream, String callIdParam) { + String file = String.format("%s/%s.live.mp4%s", app, stream, callIdParam); + this.fmp4 = new StreamURL("http", host, port, file); + this.ws_fmp4 = new StreamURL("ws", host, port, file); + if (sslPort != 0) { + this.https_fmp4 = new StreamURL("https", host, sslPort, file); + this.wss_fmp4 = new StreamURL("wss", host, sslPort, file); + } + } + + public void setHls(String host, int port, int sslPort, String app, String stream, String callIdParam) { + String file = String.format("%s/%s/hls.m3u8%s", app, stream, callIdParam); + this.hls = new StreamURL("http", host, port, file); + this.ws_hls = new StreamURL("ws", host, port, file); + if (sslPort != 0) { + this.https_hls = new StreamURL("https", host, sslPort, file); + this.wss_hls = new StreamURL("wss", host, sslPort, file); + } + } + + public void setTs(String host, int port, int sslPort, String app, String stream, String callIdParam) { + String file = String.format("%s/%s.live.ts%s", app, stream, callIdParam); + this.ts = new StreamURL("http", host, port, file); + this.ws_ts = new StreamURL("ws", host, port, file); + if (sslPort != 0) { + this.https_ts = new StreamURL("https", host, sslPort, file); + this.wss_ts = new StreamURL("wss", host, sslPort, file); + } + } + + public void setRtc(String host, int port, int sslPort, String app, String stream, String callIdParam) { + String file = String.format("index/api/webrtc?app=%s&stream=%s&type=play%s", app, stream, callIdParam); + this.rtc = new StreamURL("http", host, port, file); + if (sslPort != 0) { + this.rtcs = new StreamURL("https", host, sslPort, file); + } + } + + public void channgeStreamIp(String localAddr) { + this.flv.setHost(localAddr); + this.ws_flv.setHost(localAddr); + this.hls.setHost(localAddr); + this.ws_hls.setHost(localAddr); + this.ts.setHost(localAddr); + this.ws_ts.setHost(localAddr); + this.fmp4.setHost(localAddr); + this.ws_fmp4.setHost(localAddr); + this.rtc.setHost(localAddr); + if (this.https_flv != null) { + this.https_flv.setHost(localAddr); + this.wss_flv.setHost(localAddr); + this.https_hls.setHost(localAddr); + this.wss_hls.setHost(localAddr); + this.wss_ts.setHost(localAddr); + this.https_fmp4.setHost(localAddr); + this.wss_fmp4.setHost(localAddr); + this.rtcs.setHost(localAddr); + } + this.rtsp.setHost(localAddr); + if (this.rtsps != null) { + this.rtsps.setHost(localAddr); + } + this.rtmp.setHost(localAddr); + if (this.rtmps != null) { + this.rtmps.setHost(localAddr); + } + + } + + public static class TransactionInfo{ public String callId; public String localTag; @@ -108,94 +208,6 @@ public class StreamInfo { this.channelId = channelId; } - public String getFlv() { - return flv; - } - - public void setFlv(String flv) { - this.flv = flv; - } - - public String getWs_flv() { - return ws_flv; - } - - public void setWs_flv(String ws_flv) { - this.ws_flv = ws_flv; - } - - public String getRtmp() { - return rtmp; - } - - public void setRtmp(String rtmp) { - this.rtmp = rtmp; - } - - public String getHls() { - return hls; - } - - public void setHls(String hls) { - this.hls = hls; - } - - public String getRtsp() { - return rtsp; - } - - public void setRtsp(String rtsp) { - this.rtsp = rtsp; - } - - public Object getTracks() { - return tracks; - } - - public void setTracks(Object tracks) { - this.tracks = tracks; - } - - public String getFmp4() { - return fmp4; - } - - public void setFmp4(String fmp4) { - this.fmp4 = fmp4; - } - - public String getWs_fmp4() { - return ws_fmp4; - } - - public void setWs_fmp4(String ws_fmp4) { - this.ws_fmp4 = ws_fmp4; - } - - public String getWs_hls() { - return ws_hls; - } - - public void setWs_hls(String ws_hls) { - this.ws_hls = ws_hls; - } - - public String getTs() { - return ts; - } - - public void setTs(String ts) { - this.ts = ts; - } - - public String getWs_ts() { - return ws_ts; - } - - public void setWs_ts(String ws_ts) { - this.ws_ts = ws_ts; - } - public String getStream() { return stream; } @@ -204,20 +216,108 @@ public class StreamInfo { this.stream = stream; } - public String getRtc() { + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public StreamURL getFlv() { + return flv; + } + + public StreamURL getHttps_flv() { + return https_flv; + } + + public StreamURL getWs_flv() { + return ws_flv; + } + + + public StreamURL getWss_flv() { + return wss_flv; + } + + public StreamURL getFmp4() { + return fmp4; + } + + + + public StreamURL getHttps_fmp4() { + return https_fmp4; + } + + public StreamURL getWs_fmp4() { + return ws_fmp4; + } + + public StreamURL getWss_fmp4() { + return wss_fmp4; + } + + public StreamURL getHls() { + return hls; + } + + + public StreamURL getHttps_hls() { + return https_hls; + } + + public StreamURL getWs_hls() { + return ws_hls; + } + + public StreamURL getWss_hls() { + return wss_hls; + } + + public StreamURL getTs() { + return ts; + } + + + public StreamURL getHttps_ts() { + return https_ts; + } + + + public StreamURL getWs_ts() { + return ws_ts; + } + + + public StreamURL getWss_ts() { + return wss_ts; + } + + + public StreamURL getRtmp() { + return rtmp; + } + + public StreamURL getRtmps() { + return rtmps; + } + + public StreamURL getRtsp() { + return rtsp; + } + + public StreamURL getRtsps() { + return rtsps; + } + + public StreamURL getRtc() { return rtc; } - public void setRtc(String rtc) { - this.rtc = rtc; - } - - public TransactionInfo getTransactionInfo() { - return transactionInfo; - } - - public void setTransactionInfo(TransactionInfo transactionInfo) { - this.transactionInfo = transactionInfo; + public StreamURL getRtcs() { + return rtcs; } public String getMediaServerId() { @@ -228,87 +328,14 @@ public class StreamInfo { this.mediaServerId = mediaServerId; } - public String getHttps_flv() { - return https_flv; + public Object getTracks() { + return tracks; } - public void setHttps_flv(String https_flv) { - this.https_flv = https_flv; + public void setTracks(Object tracks) { + this.tracks = tracks; } - public String getWss_flv() { - return wss_flv; - } - - public void setWss_flv(String wss_flv) { - this.wss_flv = wss_flv; - } - - public String getWss_fmp4() { - return wss_fmp4; - } - - public void setWss_fmp4(String wss_fmp4) { - this.wss_fmp4 = wss_fmp4; - } - - public String getWss_hls() { - return wss_hls; - } - - public void setWss_hls(String wss_hls) { - this.wss_hls = wss_hls; - } - - public String getWss_ts() { - return wss_ts; - } - - public void setWss_ts(String wss_ts) { - this.wss_ts = wss_ts; - } - - public String getRtmps() { - return rtmps; - } - - public void setRtmps(String rtmps) { - this.rtmps = rtmps; - } - - public String getRtsps() { - return rtsps; - } - - public void setRtsps(String rtsps) { - this.rtsps = rtsps; - } - - public String getHttps_hls() { - return https_hls; - } - - public void setHttps_hls(String https_hls) { - this.https_hls = https_hls; - } - - public String getHttps_fmp4() { - return https_fmp4; - } - - public void setHttps_fmp4(String https_fmp4) { - this.https_fmp4 = https_fmp4; - } - - public String getHttps_ts() { - return https_ts; - } - - public void setHttps_ts(String https_ts) { - this.https_ts = https_ts; - } - - public String getStartTime() { return startTime; } @@ -333,22 +360,6 @@ public class StreamInfo { this.progress = progress; } - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public String getRtcs() { - return rtcs; - } - - public void setRtcs(String rtcs) { - this.rtcs = rtcs; - } - public boolean isPause() { return pause; } @@ -356,4 +367,12 @@ public class StreamInfo { public void setPause(boolean pause) { this.pause = pause; } + + public TransactionInfo getTransactionInfo() { + return transactionInfo; + } + + public void setTransactionInfo(TransactionInfo transactionInfo) { + this.transactionInfo = transactionInfo; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/common/StreamURL.java b/src/main/java/com/genersoft/iot/vmp/common/StreamURL.java new file mode 100644 index 00000000..bb67dee1 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/common/StreamURL.java @@ -0,0 +1,78 @@ +package com.genersoft.iot.vmp.common; + +import io.swagger.v3.oas.annotations.media.Schema; + + +@Schema(description = "流地址信息") +public class StreamURL { + + @Schema(description = "协议") + private String protocol; + + @Schema(description = "主机地址") + private String host; + + @Schema(description = "端口") + private int port = -1; + + @Schema(description = "定位位置") + private String file; + + @Schema(description = "拼接后的地址") + private String url; + + public StreamURL() { + } + + public StreamURL(String protocol, String host, int port, String file) { + this.protocol = protocol; + this.host = host; + this.port = port; + this.file = file; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getFile() { + return file; + } + + public void setFile(String file) { + this.file = file; + } + + public String getUrl() { + return this.toString(); + } + + @Override + public String toString() { + if (protocol != null && host != null && port != -1 ) { + return String.format("%s://%s:%s/%s", protocol, host, port, file); + }else { + return null; + } + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java index 708f72be..e2294f92 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java @@ -27,7 +27,7 @@ public class MediaConfig{ @Value("${media.ip}") private String ip; - @Value("${media.hook-ip:${sip.ip}}") + @Value("${media.hook-ip:}") private String hookIp; @Value("${sip.ip}") @@ -92,7 +92,7 @@ public class MediaConfig{ public String getHookIp() { if (ObjectUtils.isEmpty(hookIp)){ - return sipIp; + return sipIp.split(",")[0]; }else { return hookIp; } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index ea2655e2..7d0e92f1 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -33,6 +33,8 @@ public class UserSetting { private Boolean usePushingAsStatus = Boolean.TRUE; + private Boolean useSourceIpAsStreamIp = Boolean.FALSE; + private Boolean streamOnDemand = Boolean.TRUE; private String serverId = "000000"; @@ -156,4 +158,12 @@ public class UserSetting { public void setStreamOnDemand(Boolean streamOnDemand) { this.streamOnDemand = streamOnDemand; } + + public Boolean getUseSourceIpAsStreamIp() { + return useSourceIpAsStreamIp; + } + + public void setUseSourceIpAsStreamIp(Boolean useSourceIpAsStreamIp) { + this.useSourceIpAsStreamIp = useSourceIpAsStreamIp; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java index 7e67edd4..0fe11c01 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java @@ -45,23 +45,23 @@ public class SIPRequestHeaderPlarformProvider { @Autowired private IRedisCatchStorage redisCatchStorage; - public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader, boolean isRegister) throws ParseException, InvalidArgumentException, PeerUnavailableException { + public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader, boolean isRegister) throws ParseException, InvalidArgumentException, PeerUnavailableException { Request request = null; - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); + String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); //请求行 - SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), - platform.getServerIP() + ":" + platform.getServerPort()); + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), + parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); //via ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(platform.getServerIP(), platform.getServerPort(), platform.getTransport(), viaTag); + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getServerIP(), parentPlatform.getServerPort(), parentPlatform.getTransport(), viaTag); viaHeader.setRPort(); viaHeaders.add(viaHeader); //from - SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); //to - SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); @@ -74,10 +74,10 @@ public class SIPRequestHeaderPlarformProvider { cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() - .createSipURI(platform.getDeviceGBId(), sipAddress)); + .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); - ExpiresHeader expires = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(isRegister ? platform.getExpires() : 0); + ExpiresHeader expires = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(isRegister ? parentPlatform.getExpires() : 0); request.addHeader(expires); request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); @@ -251,7 +251,7 @@ public class SIPRequestHeaderPlarformProvider { SubscriptionStateHeader active = sipLayer.getSipFactory().createHeaderFactory().createSubscriptionStateHeader("active"); request.setHeader(active); - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); + String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); @@ -301,7 +301,7 @@ public class SIPRequestHeaderPlarformProvider { request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); + String sipAddress = platform.getDeviceIp() + ":" + platform.getDevicePort(); Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() .createSipURI(platform.getDeviceGBId(), sipAddress)); request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java index 50dd1d9a..b9a595c6 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java @@ -52,7 +52,7 @@ public class SIPRequestHeaderProvider { SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); // via ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), viaTag); viaHeader.setRPort(); viaHeaders.add(viaHeader); // from @@ -85,7 +85,7 @@ public class SIPRequestHeaderProvider { SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); //via ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), viaTag); viaHeader.setRPort(); viaHeaders.add(viaHeader); @@ -107,7 +107,7 @@ public class SIPRequestHeaderProvider { request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); // Subject @@ -124,7 +124,7 @@ public class SIPRequestHeaderProvider { SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); // via ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), viaTag); viaHeader.setRPort(); viaHeaders.add(viaHeader); //from @@ -143,7 +143,7 @@ public class SIPRequestHeaderProvider { CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); @@ -164,7 +164,7 @@ public class SIPRequestHeaderProvider { SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); // via ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); viaHeaders.add(viaHeader); //from SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); @@ -185,7 +185,7 @@ public class SIPRequestHeaderProvider { request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); @@ -199,7 +199,7 @@ public class SIPRequestHeaderProvider { SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); // via ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); viaHeader.setRPort(); viaHeaders.add(viaHeader); @@ -222,7 +222,7 @@ public class SIPRequestHeaderProvider { toHeader, viaHeaders, maxForwards); - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); // Expires @@ -254,7 +254,7 @@ public class SIPRequestHeaderProvider { SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); // via ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(device.getLocalIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); viaHeaders.add(viaHeader); //from SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); @@ -275,7 +275,7 @@ public class SIPRequestHeaderProvider { request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getLocalIp()+":"+sipConfig.getPort())); request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); @@ -288,11 +288,12 @@ public class SIPRequestHeaderProvider { return request; } - public Request createAckRequest(SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException { + public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException { + // via ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag()); + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag()); viaHeaders.add(viaHeader); //Forwards @@ -305,7 +306,7 @@ public class SIPRequestHeaderProvider { request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); - Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort())); request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index f0722244..f97a6592 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/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 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.SpringBeanFactory; -import gov.nist.javax.sip.SipStackImpl; import gov.nist.javax.sip.message.SIPRequest; import org.dom4j.Element; import org.slf4j.Logger; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java index 2c8237f5..d0ba97eb 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java @@ -104,11 +104,12 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract { } else { sdp = SdpFactory.getInstance().createSessionDescription(contentString); } + SipURI requestUri = sipLayer.getSipFactory().createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort()); - Request reqAck = headerProvider.createAckRequest(requestUri, response); + Request reqAck = headerProvider.createAckRequest(response.getLocalAddress().getHostAddress(), requestUri, response); logger.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort()); - sipSender.transmitRequest(response.getLocalAddress().getHostAddress(), reqAck); + sipSender.transmitRequest( response.getLocalAddress().getHostAddress(), reqAck); } } catch (InvalidArgumentException | ParseException | SipException | SdpParseException e) { logger.info("[点播回复ACK],异常:", e ); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index 716f1dff..0f3eaeca 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -608,7 +608,7 @@ public class MediaServerServiceImpl implements IMediaServerService { mediaServerItem.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); mediaServerItem.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); mediaServerItem.setStreamIp(ip); - mediaServerItem.setHookIp(sipConfig.getIp()); + mediaServerItem.setHookIp(sipConfig.getIp().split(",")[0]); mediaServerItem.setSdpIp(ip); return mediaServerItem; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java index dd3800f2..db4100ab 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.common.StreamURL; import com.genersoft.iot.vmp.conf.MediaConfig; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; @@ -18,6 +19,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; +import java.net.URL; + @Service public class MediaServiceImpl implements IMediaService { @@ -93,38 +96,17 @@ public class MediaServiceImpl implements IMediaService { if (addr == null) { addr = mediaInfo.getStreamIp(); } + streamInfoResult.setIp(addr); streamInfoResult.setMediaServerId(mediaInfo.getId()); String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId; - streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpPort(), app, stream, callIdParam)); - if (mediaInfo.getRtmpSSlPort() != 0) { - streamInfoResult.setRtmps(String.format("rtmps://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpSSlPort(), app, stream, callIdParam)); - } - streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s%s", addr, mediaInfo.getRtspPort(), app, stream, callIdParam)); - if (mediaInfo.getRtspSSLPort() != 0) { - streamInfoResult.setRtsps(String.format("rtsps://%s:%s/%s/%s%s", addr, mediaInfo.getRtspSSLPort(), app, stream, callIdParam)); - } - streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); - streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); - streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); - streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); - streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); - streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); - streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); - streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); - 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)); - if (mediaInfo.getHttpSSlPort() != 0) { - streamInfoResult.setHttps_flv(String.format("https://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); - streamInfoResult.setWss_flv(String.format("wss://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); - streamInfoResult.setHttps_hls(String.format("https://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); - streamInfoResult.setWss_hls(String.format("wss://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); - streamInfoResult.setHttps_fmp4(String.format("https://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); - streamInfoResult.setWss_fmp4(String.format("wss://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); - streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); - streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); - streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); - 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)); - } + streamInfoResult.setRtmp(addr, mediaInfo.getRtmpPort(),mediaInfo.getRtmpSSlPort(), app, stream, callIdParam); + streamInfoResult.setRtsp(addr, mediaInfo.getRtspPort(),mediaInfo.getRtspSSLPort(), app, stream, callIdParam); + streamInfoResult.setFlv(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); + streamInfoResult.setFmp4(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); + streamInfoResult.setHls(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); + streamInfoResult.setTs(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); + streamInfoResult.setRtc(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); streamInfoResult.setTracks(tracks); return streamInfoResult; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 831c1360..4278e70b 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -143,7 +143,7 @@ public class PlayServiceImpl implements IPlayService { if (Objects.requireNonNull(wvpResult).getCode() == 0) { StreamInfo streamInfoForSuccess = (StreamInfo) wvpResult.getData(); MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId()); - String streamUrl = streamInfoForSuccess.getFmp4(); + String streamUrl = streamInfoForSuccess.getFmp4().getUrl(); // 请求截图 logger.info("[请求截图]: " + fileName); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index 6798b488..484b984e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -415,47 +415,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService { return streamProxyMapper.updateStatus(app, stream, status); } - private void syncPullStream(String mediaServerId){ - MediaServerItem mediaServer = mediaServerService.getOne(mediaServerId); - if (mediaServer != null) { - List allPullStream = redisCatchStorage.getStreams(mediaServerId, "PULL"); - if (allPullStream.size() > 0) { - zlmresTfulUtils.getMediaList(mediaServer, jsonObject->{ - Map stringStreamInfoMap = new HashMap<>(); - if (jsonObject.getInteger("code") == 0) { - JSONArray data = jsonObject.getJSONArray("data"); - if(data != null && data.size() > 0) { - for (int i = 0; i < data.size(); i++) { - JSONObject streamJSONObj = data.getJSONObject(i); - if ("rtsp".equals(streamJSONObj.getString("schema"))) { - StreamInfo streamInfo = new StreamInfo(); - String app = streamJSONObj.getString("app"); - String stream = streamJSONObj.getString("stream"); - streamInfo.setApp(app); - streamInfo.setStream(stream); - stringStreamInfoMap.put(app+stream, streamInfo); - } - } - } - } - if (stringStreamInfoMap.size() == 0) { - redisCatchStorage.removeStream(mediaServerId, "PULL"); - }else { - for (String key : stringStreamInfoMap.keySet()) { - StreamInfo streamInfo = stringStreamInfoMap.get(key); - if (stringStreamInfoMap.get(streamInfo.getApp() + streamInfo.getStream()) == null) { - redisCatchStorage.removeStream(mediaServerId, "PULL", streamInfo.getApp(), - streamInfo.getStream()); - } - } - } - }); - } - - } - - } - @Override public ResourceBaceInfo getOverview() { return streamProxyMapper.getOverview(); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java index c93f026e..e3182c64 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java @@ -63,4 +63,5 @@ public class WVPResult { public void setData(T data) { this.data = data; } + } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index d22e56b9..66e750cd 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.play; import com.alibaba.fastjson.JSONArray; import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; @@ -37,6 +38,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.springframework.web.context.request.async.DeferredResult; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; @@ -78,18 +81,25 @@ public class PlayController { @Autowired private IMediaServerService mediaServerService; + @Autowired + private UserSetting userSetting; + @Operation(summary = "开始点播") @Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true) @GetMapping("/start/{deviceId}/{channelId}") - public DeferredResult> play(@PathVariable String deviceId, - @PathVariable String channelId) { + public DeferredResult> play(HttpServletRequest request, @PathVariable String deviceId, + @PathVariable String channelId) { // 获取可用的zlm Device device = storager.queryVideoDevice(deviceId); MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null, null); - + playResult.getResult().onCompletion(()->{ + WVPResult result = (WVPResult)playResult.getResult().getResult(); + result.getData().channgeStreamIp(request.getLocalAddr()); + playResult.getResult().setResult(result); + }); return playResult.getResult(); } diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index 49d5aca1..d3193a2b 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -188,6 +188,8 @@ user-settings: logInDatebase: true # 使用推流状态作为推流通道状态 use-pushing-as-status: true + # 使用来源请求ip作为streamIp + use-source-ip-as-stream-ip: true # 按需拉流, true:有人观看拉流,无人观看释放, false:拉起后不自动释放 stream-on-demand: true diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue index 4d8f7199..a5e46aa9 100644 --- a/web_src/src/components/dialog/devicePlayer.vue +++ b/web_src/src/components/dialog/devicePlayer.vue @@ -53,89 +53,89 @@ 更多地址 - + FLV: - {{ streamInfo.flv }} + {{ streamInfo.flv.url }} - + FLV(https): - {{ streamInfo.https_flv }} + {{ streamInfo.https_flv.url }} - + FLV(ws): - {{ streamInfo.ws_flv }} + {{ streamInfo.ws_flv.url }} - + FLV(wss): - {{ streamInfo.wss_flv }} + {{ streamInfo.wss_flv.url }} - + FMP4: - {{ streamInfo.fmp4 }} + {{ streamInfo.fmp4.url }} - + FMP4(https): - {{ streamInfo.https_fmp4 }} + {{ streamInfo.https_fmp4.url }} - + FMP4(ws): - {{ streamInfo.ws_fmp4 }} + {{ streamInfo.ws_fmp4.url }} - + FMP4(wss): - {{ streamInfo.wss_fmp4 }} + {{ streamInfo.wss_fmp4.url }} - + HLS: - {{ streamInfo.hls }} + {{ streamInfo.hls.url }} - + HLS(https): - {{ streamInfo.https_hls }} + {{ streamInfo.https_hls.url }} - + HLS(ws): - {{ streamInfo.ws_hls }} + {{ streamInfo.ws_hls.url }} - + HLS(wss): - {{ streamInfo.wss_hls }} + {{ streamInfo.wss_hls.url }} - + TS: - {{ streamInfo.ts }} + {{ streamInfo.ts.url }} - + TS(https): - {{ streamInfo.https_ts }} + {{ streamInfo.https_ts.url }} - + TS(ws): - {{ streamInfo.ws_ts }} + {{ streamInfo.ws_ts.url }} - + TS(wss): - {{ streamInfo.wss_ts }} + {{ streamInfo.wss_ts.url }} - + RTC: - {{ streamInfo.rtc }} + {{ streamInfo.rtc.url }} - + RTMP: - {{ streamInfo.rtmp }} + {{ streamInfo.rtmp.url }} - + RTMPS: - {{ streamInfo.rtmps }} + {{ streamInfo.rtmps.url }} - + RTSP: - {{ streamInfo.rtsp }} + {{ streamInfo.rtsp.url }} - + RTSPS: - {{ streamInfo.rtsps }} + {{ streamInfo.rtsps.url }} @@ -393,7 +393,7 @@ export default { changePlayer: function (tab) { console.log(this.player[tab.name][0]) this.activePlayer = tab.name; - this.videoUrl = this.streamInfo[this.player[tab.name][0]] + this.videoUrl = this.streamInfo[this.player[tab.name][0]].url console.log(this.videoUrl) }, openDialog: function (tab, deviceId, channelId, param) { @@ -446,9 +446,9 @@ export default { getUrlByStreamInfo(){ console.log(this.streamInfo) if (location.protocol === "https:") { - this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]] + this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]].url }else { - this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]] + this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]].url } return this.videoUrl; diff --git a/web_src/src/components/live.vue b/web_src/src/components/live.vue index c2c09f4c..cfbe9359 100644 --- a/web_src/src/components/live.vue +++ b/web_src/src/components/live.vue @@ -138,8 +138,8 @@ export default { url: '/api/play/start/' + deviceId + '/' + channelId }).then(function (res) { if (res.data.code === 0 && res.data.data) { - itemData.playUrl = res.data.data.httpsFlv - that.setPlayUrl(res.data.data.ws_flv, idxTmp) + itemData.playUrl = res.data.data.https_flv.url + that.setPlayUrl(res.data.data.ws_flv.url, idxTmp) } else { that.$message.error(res.data.msg); }