Browse Source

去除lombok框架

添加流传输模式udp/tcp被动支持
pull/1/head
648540858 4 years ago
parent
commit
4d9a62339d
  1. 29
      src/main/java/com/genersoft/iot/vmp/common/PageResult.java
  2. 73
      src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
  3. 523
      src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java
  4. 50
      src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
  5. 9
      src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java
  6. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java
  7. 51
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
  8. 3
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
  9. 1
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
  10. 8
      src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java
  11. 15
      src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
  12. 29
      web_src/src/components/gb28181/devicePlayer.vue
  13. 16
      web_src/src/components/videoList.vue

29
src/main/java/com/genersoft/iot/vmp/common/PageResult.java

@ -1,10 +1,8 @@
package com.genersoft.iot.vmp.common; package com.genersoft.iot.vmp.common;
import lombok.Data;
import java.util.List; import java.util.List;
@Data
public class PageResult<T> { public class PageResult<T> {
private int page; private int page;
@ -17,4 +15,31 @@ public class PageResult<T> {
return data; 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<T> data) {
this.data = data;
}
} }

73
src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java

@ -1,9 +1,7 @@
package com.genersoft.iot.vmp.common; package com.genersoft.iot.vmp.common;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import lombok.Data;
@Data
public class StreamInfo { public class StreamInfo {
private String ssrc; private String ssrc;
@ -16,4 +14,75 @@ public class StreamInfo {
private String rtsp; private String rtsp;
private JSONArray tracks; 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;
}
} }

523
src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java

@ -1,9 +1,7 @@
package com.genersoft.iot.vmp.conf; package com.genersoft.iot.vmp.conf;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class MediaServerConfig { public class MediaServerConfig {
@JSONField(name = "api.apiDebug") @JSONField(name = "api.apiDebug")
@ -200,4 +198,525 @@ public class MediaServerConfig {
@JSONField(name = "shell.shell") @JSONField(name = "shell.shell")
private String shellPhell; 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;
}
} }

50
src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java

@ -1,10 +1,9 @@
package com.genersoft.iot.vmp.conf; package com.genersoft.iot.vmp.conf;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Data
@Configuration("sipConfig") @Configuration("sipConfig")
public class SipConfig { public class SipConfig {
@ -22,4 +21,51 @@ public class SipConfig {
@Value("${sip.ptz.speed:50}") @Value("${sip.ptz.speed:50}")
Integer speed; 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;
}
} }

9
src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java

@ -1,6 +1,5 @@
package com.genersoft.iot.vmp.conf; package com.genersoft.iot.vmp.conf;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -9,7 +8,6 @@ import org.springframework.context.annotation.Configuration;
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月6日 下午2:46:00 * @date: 2020年5月6日 下午2:46:00
*/ */
@Data
@Configuration("vmConfig") @Configuration("vmConfig")
public class VManagerConfig { public class VManagerConfig {
@ -17,4 +15,11 @@ public class VManagerConfig {
private String database; private String database;
public String getDatabase() {
return database;
}
public void setDatabase(String database) {
this.database = database;
}
} }

2
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java

@ -1,6 +1,5 @@
package com.genersoft.iot.vmp.gb28181.bean; package com.genersoft.iot.vmp.gb28181.bean;
import lombok.Data;
import java.util.List; import java.util.List;
@ -19,7 +18,6 @@ public class RecordInfo {
private List<RecordItem> recordList; private List<RecordItem> recordList;
public String getDeviceId() { public String getDeviceId() {
return deviceId; return deviceId;
} }

51
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@ -212,7 +212,7 @@ public class SIPCommander implements ISIPCommander {
try { try {
String ssrc = streamSession.createPlaySsrc(); String ssrc = streamSession.createPlaySsrc();
String transport = device.getTransport(); String streamMode = device.getStreamMode().toUpperCase();
MediaServerConfig mediaInfo = storager.getMediaInfo(); MediaServerConfig mediaInfo = storager.getMediaInfo();
String mediaPort = null; String mediaPort = null;
// 使用动态udp端口 // 使用动态udp端口
@ -228,20 +228,24 @@ public class SIPCommander implements ISIPCommander {
content.append("s=Play\r\n"); content.append("s=Play\r\n");
content.append("c=IN IP4 "+mediaInfo.getLocalIP()+"\r\n"); content.append("c=IN IP4 "+mediaInfo.getLocalIP()+"\r\n");
content.append("t=0 0\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"); content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n");
} }else if ("TCP-ACTIVE".equals(streamMode)) {
if("UDP".equals(transport)) { 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("m=video "+ mediaPort +" RTP/AVP 96 98 97\r\n");
} }
content.append("a=recvonly\r\n"); content.append("a=recvonly\r\n");
content.append("a=rtpmap:96 PS/90000\r\n"); content.append("a=rtpmap:96 PS/90000\r\n");
content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:98 H264/90000\r\n");
content.append("a=rtpmap:97 MPEG4/90000\r\n"); content.append("a=rtpmap:97 MPEG4/90000\r\n");
if("TCP".equals(transport)){ if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式
content.append("a=setup:passive\r\n"); content.append("a=setup:passive\r\n");
content.append("a=connection:new\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 content.append("y="+ssrc+"\r\n");//ssrc
Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "live", null); 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("s=Playback\r\n");
content.append("u="+channelId+":0\r\n"); content.append("u="+channelId+":0\r\n");
content.append("c=IN IP4 "+mediaInfo.getLocalIP()+"\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"); content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" "
if(device.getTransport().equals("TCP")) { +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n");
content.append("m=video "+mediaInfo.getRtpProxyPort()+" TCP/RTP/AVP 96 98 97\r\n"); String mediaPort = null;
// 使用动态udp端口
if (rtpEnable) {
mediaPort = zlmUtils.getNewRTPPort(ssrc) + "";
}else {
mediaPort = mediaInfo.getRtpProxyPort();
} }
if(device.getTransport().equals("UDP")) { String streamMode = device.getStreamMode().toUpperCase();
content.append("m=video "+mediaInfo.getRtpProxyPort()+" RTP/AVP 96 98 97\r\n"); 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=recvonly\r\n");
content.append("a=rtpmap:96 PS/90000\r\n"); content.append("a=rtpmap:96 PS/90000\r\n");
content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:98 H264/90000\r\n");
content.append("a=rtpmap:97 MPEG4/90000\r\n"); content.append("a=rtpmap:97 MPEG4/90000\r\n");
if(device.getTransport().equals("TCP")){ if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式
content.append("a=setup:passive\r\n"); content.append("a=setup:passive\r\n");
content.append("a=connection:new\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 content.append("y="+ssrc+"\r\n");//ssrc
Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "playback", null); Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "playback", null);

3
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.setManufacturer(XmlUtil.getText(rootElement,"Manufacturer"));
device.setModel(XmlUtil.getText(rootElement,"Model")); device.setModel(XmlUtil.getText(rootElement,"Model"));
device.setFirmware(XmlUtil.getText(rootElement,"Firmware")); device.setFirmware(XmlUtil.getText(rootElement,"Firmware"));
if (StringUtils.isEmpty(device.getStreamMode())){
device.setStreamMode("UDP");
}
storager.updateDevice(device); storager.updateDevice(device);
cmder.catalogQuery(device); cmder.catalogQuery(device);
} catch (DocumentException e) { } catch (DocumentException e) {

1
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(); SipUri uri = (SipUri) address.getURI();
String deviceId = uri.getUser(); String deviceId = uri.getUser();
device = new Device(); device = new Device();
device.setStreamMode("UDP");
device.setDeviceId(deviceId); device.setDeviceId(deviceId);
device.setHost(host); device.setHost(host);
// 注销成功 // 注销成功

8
src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java

@ -151,11 +151,11 @@ public class DeviceController {
return new ResponseEntity<>(null,HttpStatus.OK); return new ResponseEntity<>(null,HttpStatus.OK);
} }
@GetMapping("/devices/{deviceId}/transport/{transport}") @GetMapping("/devices/{deviceId}/transport/{streamMode}")
@PostMapping("/devices/{deviceId}/transport/{transport}") @PostMapping("/devices/{deviceId}/transport/{streamMode}")
public ResponseEntity<PageResult> updateTransport(@PathVariable String deviceId, @PathVariable String transport){ public ResponseEntity<PageResult> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
device.setTransport(transport); device.setStreamMode(streamMode);
storager.updateDevice(device); storager.updateDevice(device);
return new ResponseEntity<>(null,HttpStatus.OK); return new ResponseEntity<>(null,HttpStatus.OK);
} }

15
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java

@ -76,23 +76,8 @@ public class PlayController {
}else { }else {
lockFlag = false; lockFlag = false;
streamInfo = storager.queryPlay(streamInfo); 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) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }

29
web_src/src/components/gb28181/devicePlayer.vue

@ -1,7 +1,8 @@
<template> <template>
<div id="devicePlayer"> <div id="devicePlayer">
<el-dialog title="视频播放" top="0" :visible.sync="showVideoDialog" :destroy-on-close="true" @close="close()"> <el-dialog title="视频播放" top="0" :visible.sync="showVideoDialog" :destroy-on-close="true" @close="close()">
<LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :hasaudio="hasaudio" fluent autoplay live ></LivePlayer> <LivePlayer v-if="showVideoDialog && hasaudio" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" hasaudio fluent autoplay live ></LivePlayer>
<LivePlayer v-if="showVideoDialog && !hasaudio" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" fluent autoplay live ></LivePlayer>
<div id="shared" style="text-align: right; margin-top: 1rem;"> <div id="shared" style="text-align: right; margin-top: 1rem;">
<el-tabs v-model="tabActiveName"> <el-tabs v-model="tabActiveName">
<el-tab-pane label="媒体流信息" name="media"> <el-tab-pane label="媒体流信息" name="media">
@ -122,20 +123,20 @@
methods: { methods: {
play: function(streamInfo, deviceId, channelId, hasAudio) { play: function(streamInfo, deviceId, channelId, hasAudio) {
console.log(hasAudio); // this.hasaudio = hasAudio;
this.hasaudio = hasAudio; if (!hasAudio) { // hasaudio == falsehasaudio false,
// this.hasaudio = hasAudio;
if( this.hasaudio && !!streamInfo.tracks && streamInfo.tracks.length > 0) {
var realHasAudio = false;
for (let i = 0; i < streamInfo.tracks; i++) {
if (streamInfo.tracks[i].codec_type == 1) { //
realHasAudio = true;
}
}
this.hasaudio = realHasAudio && this.hasaudio;
} }
console.log("111") //
console.log(this.hasaudio) // if( this.hasaudio && !!streamInfo.tracks && streamInfo.tracks.length > 0) {
// var realHasAudio = false;
// for (let i = 0; i < streamInfo.tracks; i++) {
// if (streamInfo.tracks[i].codec_type == 1) { //
// realHasAudio = true;
// }
// }
// this.hasaudio = realHasAudio && this.hasaudio;
// }
this.ssrc = streamInfo.ssrc; this.ssrc = streamInfo.ssrc;
this.deviceId = deviceId; this.deviceId = deviceId;
this.channelId = channelId; this.channelId = channelId;

16
web_src/src/components/videoList.vue

@ -29,12 +29,12 @@
</el-table-column> </el-table-column>
<el-table-column prop="model" label="固件版本" align="center"> <el-table-column prop="model" label="固件版本" align="center">
</el-table-column> </el-table-column>
<el-table-column label="通讯方式" align="center"> <el-table-column label="流传输模式" align="center" width="160">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select @change="transportChange(scope.row)" v-model="scope.row.streamMode" placeholder="请选择"> <el-select size="mini" @change="transportChange(scope.row)" v-model="scope.row.streamMode" placeholder="请选择">
<el-option key="UDP" label="UDP" value="UDP"></el-option> <el-option key="UDP" label="UDP" value="UDP"></el-option>
<el-option key="TCP-ACTIVE" label="TCP主动模式" value="TCP-ACTIVE"></el-option> <el-option key="TCP-ACTIVE" label="TCP主动模式" :disabled="true" value="TCP-ACTIVE"></el-option>
<el-option key="TCP-PASSIVE" label="TCP被动模式" :disabled="true" value="TCP-PASSIVE"></el-option> <el-option key="TCP-PASSIVE" label="TCP被动模式" value="TCP-PASSIVE"></el-option>
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
@ -189,14 +189,14 @@
}); });
}, },
transportChange: function (row) { transportChange: function (row) {
console.log(`修改传输方式为 ${row.transport}${row.deviceId} `); console.log(row);
console.log(`修改传输方式为 ${row.streamMode}${row.deviceId} `);
let that = this; let that = this;
this.$axios({ this.$axios({
method: 'get', method: 'get',
url: '/api/devices/' + row.deviceId + '/transport/' + row.transport url: '/api/devices/' + row.deviceId + '/transport/' + row.streamMode
}).then(function(res) { }).then(function(res) {
let ssrc = res.data.ssrc;
that.$refs.devicePlayer.play(ssrc,deviceId,channelId);
}).catch(function(e) { }).catch(function(e) {
}); });
} }

Loading…
Cancel
Save