From 4d9a62339d43e163c3615a52b72a3c3f01cc30ab Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 16 Oct 2020 16:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4lombok=E6=A1=86=E6=9E=B6=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=81=E4=BC=A0=E8=BE=93=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?udp/tcp=E8=A2=AB=E5=8A=A8=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/common/PageResult.java | 29 +- .../genersoft/iot/vmp/common/StreamInfo.java | 73 ++- .../iot/vmp/conf/MediaServerConfig.java | 523 +++++++++++++++++- .../com/genersoft/iot/vmp/conf/SipConfig.java | 50 +- .../iot/vmp/conf/VManagerConfig.java | 9 +- .../iot/vmp/gb28181/bean/RecordInfo.java | 2 - .../transmit/cmd/impl/SIPCommander.java | 51 +- .../request/impl/MessageRequestProcessor.java | 3 + .../impl/RegisterRequestProcessor.java | 1 + .../vmp/vmanager/device/DeviceController.java | 8 +- .../iot/vmp/vmanager/play/PlayController.java | 15 - .../src/components/gb28181/devicePlayer.vue | 29 +- web_src/src/components/videoList.vue | 16 +- 13 files changed, 739 insertions(+), 70 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/common/PageResult.java b/src/main/java/com/genersoft/iot/vmp/common/PageResult.java index d5b4c772..6d7c89e6 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/PageResult.java +++ b/src/main/java/com/genersoft/iot/vmp/common/PageResult.java @@ -1,10 +1,8 @@ package com.genersoft.iot.vmp.common; -import lombok.Data; import java.util.List; -@Data public class PageResult { private int page; @@ -17,4 +15,31 @@ public class PageResult { return data; } + public int getPage() { + return page; + } + + public void setPage(int page) { + this.page = page; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public void setData(List data) { + this.data = data; + } } 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 fcf5cd20..1dd3a854 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java @@ -1,9 +1,7 @@ package com.genersoft.iot.vmp.common; import com.alibaba.fastjson.JSONArray; -import lombok.Data; -@Data public class StreamInfo { private String ssrc; @@ -16,4 +14,75 @@ public class StreamInfo { private String rtsp; private JSONArray tracks; + public String getSsrc() { + return ssrc; + } + + public void setSsrc(String ssrc) { + this.ssrc = ssrc; + } + + public String getDeviceID() { + return deviceID; + } + + public void setDeviceID(String deviceID) { + this.deviceID = deviceID; + } + + public String getCahnnelId() { + return cahnnelId; + } + + public void setCahnnelId(String cahnnelId) { + this.cahnnelId = cahnnelId; + } + + 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 JSONArray getTracks() { + return tracks; + } + + public void setTracks(JSONArray tracks) { + this.tracks = tracks; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java index 807cd846..8c101b42 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java @@ -1,9 +1,7 @@ package com.genersoft.iot.vmp.conf; import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; -@Data public class MediaServerConfig { @JSONField(name = "api.apiDebug") @@ -200,4 +198,525 @@ public class MediaServerConfig { @JSONField(name = "shell.shell") private String shellPhell; + + + public String getApiDebug() { + return apiDebug; + } + + public void setApiDebug(String apiDebug) { + this.apiDebug = apiDebug; + } + + public String getApiSecret() { + return apiSecret; + } + + public void setApiSecret(String apiSecret) { + this.apiSecret = apiSecret; + } + + public String getFfmpegBin() { + return ffmpegBin; + } + + public void setFfmpegBin(String ffmpegBin) { + this.ffmpegBin = ffmpegBin; + } + + public String getFfmpegCmd() { + return ffmpegCmd; + } + + public void setFfmpegCmd(String ffmpegCmd) { + this.ffmpegCmd = ffmpegCmd; + } + + public String getFfmpegLog() { + return ffmpegLog; + } + + public void setFfmpegLog(String ffmpegLog) { + this.ffmpegLog = ffmpegLog; + } + + public String getGeneralEnableVhost() { + return generalEnableVhost; + } + + public void setGeneralEnableVhost(String generalEnableVhost) { + this.generalEnableVhost = generalEnableVhost; + } + + public String getGeneralFlowThreshold() { + return generalFlowThreshold; + } + + public void setGeneralFlowThreshold(String generalFlowThreshold) { + this.generalFlowThreshold = generalFlowThreshold; + } + + public String getGeneralMaxStreamWaitMS() { + return generalMaxStreamWaitMS; + } + + public void setGeneralMaxStreamWaitMS(String generalMaxStreamWaitMS) { + this.generalMaxStreamWaitMS = generalMaxStreamWaitMS; + } + + public String getGeneralStreamNoneReaderDelayMS() { + return generalStreamNoneReaderDelayMS; + } + + public void setGeneralStreamNoneReaderDelayMS(String generalStreamNoneReaderDelayMS) { + this.generalStreamNoneReaderDelayMS = generalStreamNoneReaderDelayMS; + } + + public String getLocalIP() { + return localIP; + } + + public void setLocalIP(String localIP) { + this.localIP = localIP; + } + + public String getHlsFileBufSize() { + return hlsFileBufSize; + } + + public void setHlsFileBufSize(String hlsFileBufSize) { + this.hlsFileBufSize = hlsFileBufSize; + } + + public String getHlsFilePath() { + return hlsFilePath; + } + + public void setHlsFilePath(String hlsFilePath) { + this.hlsFilePath = hlsFilePath; + } + + public String getHlsSegDur() { + return hlsSegDur; + } + + public void setHlsSegDur(String hlsSegDur) { + this.hlsSegDur = hlsSegDur; + } + + public String getHlsSegNum() { + return hlsSegNum; + } + + public void setHlsSegNum(String hlsSegNum) { + this.hlsSegNum = hlsSegNum; + } + + public String getHookAccessFileExceptHLS() { + return hookAccessFileExceptHLS; + } + + public void setHookAccessFileExceptHLS(String hookAccessFileExceptHLS) { + this.hookAccessFileExceptHLS = hookAccessFileExceptHLS; + } + + public String getHookAdminParams() { + return hookAdminParams; + } + + public void setHookAdminParams(String hookAdminParams) { + this.hookAdminParams = hookAdminParams; + } + + public String getHookEnable() { + return hookEnable; + } + + public void setHookEnable(String hookEnable) { + this.hookEnable = hookEnable; + } + + public String getHookOnFlowReport() { + return hookOnFlowReport; + } + + public void setHookOnFlowReport(String hookOnFlowReport) { + this.hookOnFlowReport = hookOnFlowReport; + } + + public String getHookOnHttpAccess() { + return hookOnHttpAccess; + } + + public void setHookOnHttpAccess(String hookOnHttpAccess) { + this.hookOnHttpAccess = hookOnHttpAccess; + } + + public String getHookOnPlay() { + return hookOnPlay; + } + + public void setHookOnPlay(String hookOnPlay) { + this.hookOnPlay = hookOnPlay; + } + + public String getHookOnPublish() { + return hookOnPublish; + } + + public void setHookOnPublish(String hookOnPublish) { + this.hookOnPublish = hookOnPublish; + } + + public String getHookOnRecordMp4() { + return hookOnRecordMp4; + } + + public void setHookOnRecordMp4(String hookOnRecordMp4) { + this.hookOnRecordMp4 = hookOnRecordMp4; + } + + public String getHookOnRtspAuth() { + return hookOnRtspAuth; + } + + public void setHookOnRtspAuth(String hookOnRtspAuth) { + this.hookOnRtspAuth = hookOnRtspAuth; + } + + public String getHookOnRtspRealm() { + return hookOnRtspRealm; + } + + public void setHookOnRtspRealm(String hookOnRtspRealm) { + this.hookOnRtspRealm = hookOnRtspRealm; + } + + public String getHookOnShellLogin() { + return hookOnShellLogin; + } + + public void setHookOnShellLogin(String hookOnShellLogin) { + this.hookOnShellLogin = hookOnShellLogin; + } + + public String getHookOnStreamChanged() { + return hookOnStreamChanged; + } + + public void setHookOnStreamChanged(String hookOnStreamChanged) { + this.hookOnStreamChanged = hookOnStreamChanged; + } + + public String getHookOnStreamNoneReader() { + return hookOnStreamNoneReader; + } + + public void setHookOnStreamNoneReader(String hookOnStreamNoneReader) { + this.hookOnStreamNoneReader = hookOnStreamNoneReader; + } + + public String getHookOnStreamNotFound() { + return hookOnStreamNotFound; + } + + public void setHookOnStreamNotFound(String hookOnStreamNotFound) { + this.hookOnStreamNotFound = hookOnStreamNotFound; + } + + public String getHookTimeoutSec() { + return hookTimeoutSec; + } + + public void setHookTimeoutSec(String hookTimeoutSec) { + this.hookTimeoutSec = hookTimeoutSec; + } + + public String getHttpCharSet() { + return httpCharSet; + } + + public void setHttpCharSet(String httpCharSet) { + this.httpCharSet = httpCharSet; + } + + public String getHttpKeepAliveSecond() { + return httpKeepAliveSecond; + } + + public void setHttpKeepAliveSecond(String httpKeepAliveSecond) { + this.httpKeepAliveSecond = httpKeepAliveSecond; + } + + public String getHttpMaxReqCount() { + return httpMaxReqCount; + } + + public void setHttpMaxReqCount(String httpMaxReqCount) { + this.httpMaxReqCount = httpMaxReqCount; + } + + public String getHttpMaxReqSize() { + return httpMaxReqSize; + } + + public void setHttpMaxReqSize(String httpMaxReqSize) { + this.httpMaxReqSize = httpMaxReqSize; + } + + public String getHttpNotFound() { + return httpNotFound; + } + + public void setHttpNotFound(String httpNotFound) { + this.httpNotFound = httpNotFound; + } + + public String getHttpPort() { + return httpPort; + } + + public void setHttpPort(String httpPort) { + this.httpPort = httpPort; + } + + public String getHttpRootPath() { + return httpRootPath; + } + + public void setHttpRootPath(String httpRootPath) { + this.httpRootPath = httpRootPath; + } + + public String getHttpSendBufSize() { + return httpSendBufSize; + } + + public void setHttpSendBufSize(String httpSendBufSize) { + this.httpSendBufSize = httpSendBufSize; + } + + public String getHttpSSLport() { + return httpSSLport; + } + + public void setHttpSSLport(String httpSSLport) { + this.httpSSLport = httpSSLport; + } + + public String getMulticastAddrMax() { + return multicastAddrMax; + } + + public void setMulticastAddrMax(String multicastAddrMax) { + this.multicastAddrMax = multicastAddrMax; + } + + public String getMulticastAddrMin() { + return multicastAddrMin; + } + + public void setMulticastAddrMin(String multicastAddrMin) { + this.multicastAddrMin = multicastAddrMin; + } + + public String getMulticastUdpTTL() { + return multicastUdpTTL; + } + + public void setMulticastUdpTTL(String multicastUdpTTL) { + this.multicastUdpTTL = multicastUdpTTL; + } + + public String getRecordAppName() { + return recordAppName; + } + + public void setRecordAppName(String recordAppName) { + this.recordAppName = recordAppName; + } + + public String getRecordFilePath() { + return recordFilePath; + } + + public void setRecordFilePath(String recordFilePath) { + this.recordFilePath = recordFilePath; + } + + public String getRecordFileSecond() { + return recordFileSecond; + } + + public void setRecordFileSecond(String recordFileSecond) { + this.recordFileSecond = recordFileSecond; + } + + public String getRecordFileSampleMS() { + return recordFileSampleMS; + } + + public void setRecordFileSampleMS(String recordFileSampleMS) { + this.recordFileSampleMS = recordFileSampleMS; + } + + public String getRtmpHandshakeSecond() { + return rtmpHandshakeSecond; + } + + public void setRtmpHandshakeSecond(String rtmpHandshakeSecond) { + this.rtmpHandshakeSecond = rtmpHandshakeSecond; + } + + public String getRtmpKeepAliveSecond() { + return rtmpKeepAliveSecond; + } + + public void setRtmpKeepAliveSecond(String rtmpKeepAliveSecond) { + this.rtmpKeepAliveSecond = rtmpKeepAliveSecond; + } + + public String getRtmpModifyStamp() { + return rtmpModifyStamp; + } + + public void setRtmpModifyStamp(String rtmpModifyStamp) { + this.rtmpModifyStamp = rtmpModifyStamp; + } + + public String getRtmpPort() { + return rtmpPort; + } + + public void setRtmpPort(String rtmpPort) { + this.rtmpPort = rtmpPort; + } + + public String getRtpAudioMtuSize() { + return rtpAudioMtuSize; + } + + public void setRtpAudioMtuSize(String rtpAudioMtuSize) { + this.rtpAudioMtuSize = rtpAudioMtuSize; + } + + public String getRtpClearCount() { + return rtpClearCount; + } + + public void setRtpClearCount(String rtpClearCount) { + this.rtpClearCount = rtpClearCount; + } + + public String getRtpCycleMS() { + return rtpCycleMS; + } + + public void setRtpCycleMS(String rtpCycleMS) { + this.rtpCycleMS = rtpCycleMS; + } + + public String getRtpMaxRtpCount() { + return rtpMaxRtpCount; + } + + public void setRtpMaxRtpCount(String rtpMaxRtpCount) { + this.rtpMaxRtpCount = rtpMaxRtpCount; + } + + public String getRtpVideoMtuSize() { + return rtpVideoMtuSize; + } + + public void setRtpVideoMtuSize(String rtpVideoMtuSize) { + this.rtpVideoMtuSize = rtpVideoMtuSize; + } + + public String getRtpProxyCheckSource() { + return rtpProxyCheckSource; + } + + public void setRtpProxyCheckSource(String rtpProxyCheckSource) { + this.rtpProxyCheckSource = rtpProxyCheckSource; + } + + public String getRtpProxyDumpDir() { + return rtpProxyDumpDir; + } + + public void setRtpProxyDumpDir(String rtpProxyDumpDir) { + this.rtpProxyDumpDir = rtpProxyDumpDir; + } + + public String getRtpProxyPort() { + return rtpProxyPort; + } + + public void setRtpProxyPort(String rtpProxyPort) { + this.rtpProxyPort = rtpProxyPort; + } + + public String getRtpProxyTimeoutSec() { + return rtpProxyTimeoutSec; + } + + public void setRtpProxyTimeoutSec(String rtpProxyTimeoutSec) { + this.rtpProxyTimeoutSec = rtpProxyTimeoutSec; + } + + public String getRtspAuthBasic() { + return rtspAuthBasic; + } + + public void setRtspAuthBasic(String rtspAuthBasic) { + this.rtspAuthBasic = rtspAuthBasic; + } + + public String getRtspHandshakeSecond() { + return rtspHandshakeSecond; + } + + public void setRtspHandshakeSecond(String rtspHandshakeSecond) { + this.rtspHandshakeSecond = rtspHandshakeSecond; + } + + public String getRtspKeepAliveSecond() { + return rtspKeepAliveSecond; + } + + public void setRtspKeepAliveSecond(String rtspKeepAliveSecond) { + this.rtspKeepAliveSecond = rtspKeepAliveSecond; + } + + public String getRtspPort() { + return rtspPort; + } + + public void setRtspPort(String rtspPort) { + this.rtspPort = rtspPort; + } + + public String getRtspSSlport() { + return rtspSSlport; + } + + public void setRtspSSlport(String rtspSSlport) { + this.rtspSSlport = rtspSSlport; + } + + public String getShellMaxReqSize() { + return shellMaxReqSize; + } + + public void setShellMaxReqSize(String shellMaxReqSize) { + this.shellMaxReqSize = shellMaxReqSize; + } + + public String getShellPhell() { + return shellPhell; + } + + public void setShellPhell(String shellPhell) { + this.shellPhell = shellPhell; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java index ba229750..52d80890 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java @@ -1,10 +1,9 @@ package com.genersoft.iot.vmp.conf; -import lombok.Data; + import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; -@Data @Configuration("sipConfig") public class SipConfig { @@ -22,4 +21,51 @@ public class SipConfig { @Value("${sip.ptz.speed:50}") Integer speed; + public String getSipIp() { + return sipIp; + } + + public void setSipIp(String sipIp) { + this.sipIp = sipIp; + } + + public Integer getSipPort() { + return sipPort; + } + + public void setSipPort(Integer sipPort) { + this.sipPort = sipPort; + } + + public String getSipDomain() { + return sipDomain; + } + + public void setSipDomain(String sipDomain) { + this.sipDomain = sipDomain; + } + + public String getSipId() { + return sipId; + } + + public void setSipId(String sipId) { + this.sipId = sipId; + } + + public String getSipPassword() { + return sipPassword; + } + + public void setSipPassword(String sipPassword) { + this.sipPassword = sipPassword; + } + + public Integer getSpeed() { + return speed; + } + + public void setSpeed(Integer speed) { + this.speed = speed; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java index b27ea2f0..4c71b5c9 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.conf; -import lombok.Data; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @@ -9,7 +8,6 @@ import org.springframework.context.annotation.Configuration; * @author: swwheihei * @date: 2020年5月6日 下午2:46:00 */ -@Data @Configuration("vmConfig") public class VManagerConfig { @@ -17,4 +15,11 @@ public class VManagerConfig { private String database; + public String getDatabase() { + return database; + } + + public void setDatabase(String database) { + this.database = database; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java index 7c3ebf67..cc39aa44 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.gb28181.bean; -import lombok.Data; import java.util.List; @@ -19,7 +18,6 @@ public class RecordInfo { private List recordList; - public String getDeviceId() { return deviceId; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 44467ae0..9af409f0 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -212,7 +212,7 @@ public class SIPCommander implements ISIPCommander { try { String ssrc = streamSession.createPlaySsrc(); - String transport = device.getTransport(); + String streamMode = device.getStreamMode().toUpperCase(); MediaServerConfig mediaInfo = storager.getMediaInfo(); String mediaPort = null; // 使用动态udp端口 @@ -228,20 +228,24 @@ public class SIPCommander implements ISIPCommander { content.append("s=Play\r\n"); content.append("c=IN IP4 "+mediaInfo.getLocalIP()+"\r\n"); content.append("t=0 0\r\n"); - if("TCP".equals(transport)) { + if("TCP-PASSIVE".equals(streamMode)) { content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n"); - } - if("UDP".equals(transport)) { + }else if ("TCP-ACTIVE".equals(streamMode)) { + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n"); + }else if("UDP".equals(streamMode)) { content.append("m=video "+ mediaPort +" RTP/AVP 96 98 97\r\n"); } content.append("a=recvonly\r\n"); content.append("a=rtpmap:96 PS/90000\r\n"); content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:97 MPEG4/90000\r\n"); - if("TCP".equals(transport)){ - content.append("a=setup:passive\r\n"); - content.append("a=connection:new\r\n"); - } + if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 + content.append("a=setup:passive\r\n"); + content.append("a=connection:new\r\n"); + }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 + content.append("a=setup:active\r\n"); + content.append("a=connection:new\r\n"); + } content.append("y="+ssrc+"\r\n");//ssrc Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "live", null); @@ -286,21 +290,34 @@ public class SIPCommander implements ISIPCommander { content.append("s=Playback\r\n"); content.append("u="+channelId+":0\r\n"); content.append("c=IN IP4 "+mediaInfo.getLocalIP()+"\r\n"); - content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" "+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n"); - if(device.getTransport().equals("TCP")) { - content.append("m=video "+mediaInfo.getRtpProxyPort()+" TCP/RTP/AVP 96 98 97\r\n"); + content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" " + +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n"); + String mediaPort = null; + // 使用动态udp端口 + if (rtpEnable) { + mediaPort = zlmUtils.getNewRTPPort(ssrc) + ""; + }else { + mediaPort = mediaInfo.getRtpProxyPort(); } - if(device.getTransport().equals("UDP")) { - content.append("m=video "+mediaInfo.getRtpProxyPort()+" RTP/AVP 96 98 97\r\n"); + String streamMode = device.getStreamMode().toUpperCase(); + if("TCP-PASSIVE".equals(streamMode)) { + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n"); + }else if ("TCP-ACTIVE".equals(streamMode)) { + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n"); + }else if("UDP".equals(streamMode)) { + content.append("m=video "+ mediaPort +" RTP/AVP 96 98 97\r\n"); } content.append("a=recvonly\r\n"); content.append("a=rtpmap:96 PS/90000\r\n"); content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:97 MPEG4/90000\r\n"); - if(device.getTransport().equals("TCP")){ - content.append("a=setup:passive\r\n"); - content.append("a=connection:new\r\n"); - } + if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 + content.append("a=setup:passive\r\n"); + content.append("a=connection:new\r\n"); + }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 + content.append("a=setup:active\r\n"); + content.append("a=connection:new\r\n"); + } content.append("y="+ssrc+"\r\n");//ssrc Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "playback", null); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java index 97682431..02f7e935 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java @@ -245,6 +245,9 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { device.setManufacturer(XmlUtil.getText(rootElement,"Manufacturer")); device.setModel(XmlUtil.getText(rootElement,"Model")); device.setFirmware(XmlUtil.getText(rootElement,"Firmware")); + if (StringUtils.isEmpty(device.getStreamMode())){ + device.setStreamMode("UDP"); + } storager.updateDevice(device); cmder.catalogQuery(device); } catch (DocumentException e) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java index 62170245..276127f2 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java @@ -113,6 +113,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { SipUri uri = (SipUri) address.getURI(); String deviceId = uri.getUser(); device = new Device(); + device.setStreamMode("UDP"); device.setDeviceId(deviceId); device.setHost(host); // 注销成功 diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java index bd5564e6..8c0ecfba 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java @@ -151,11 +151,11 @@ public class DeviceController { return new ResponseEntity<>(null,HttpStatus.OK); } - @GetMapping("/devices/{deviceId}/transport/{transport}") - @PostMapping("/devices/{deviceId}/transport/{transport}") - public ResponseEntity updateTransport(@PathVariable String deviceId, @PathVariable String transport){ + @GetMapping("/devices/{deviceId}/transport/{streamMode}") + @PostMapping("/devices/{deviceId}/transport/{streamMode}") + public ResponseEntity updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ Device device = storager.queryVideoDevice(deviceId); - device.setTransport(transport); + device.setStreamMode(streamMode); storager.updateDevice(device); return new ResponseEntity<>(null,HttpStatus.OK); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java index 19429a23..ad0ff0c0 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java @@ -76,23 +76,8 @@ public class PlayController { }else { lockFlag = false; streamInfo = storager.queryPlay(streamInfo); - // 获取媒体信息 - JSONObject mediaList = zlmresTfulUtils.getMediaList("rtp", "rtmp"); - if (mediaList.getInteger("code") == 0) { - JSONArray data = mediaList.getJSONArray("data"); - if (data!= null) { - for (Object datum : data) { - JSONObject media = (JSONObject)datum; - if (streamId.equals(media.getString("stream"))) { - streamInfo.setTracks(media.getJSONArray("tracks")); - storager.startPlay(streamInfo); - } - } - } - } }; } - streamInfo = storager.queryPlayByDevice(deviceId, channelId); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/web_src/src/components/gb28181/devicePlayer.vue b/web_src/src/components/gb28181/devicePlayer.vue index ce36483a..2f2cfc00 100644 --- a/web_src/src/components/gb28181/devicePlayer.vue +++ b/web_src/src/components/gb28181/devicePlayer.vue @@ -1,7 +1,8 @@