Commit cd360f893df40ced698a4ab741251d096d42bc04

Authored by 王鑫
1 parent 158ae83b

fix():修改直播用主码流

src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/config/Jt1078ConfigBean.java
1 -package com.genersoft.iot.vmp.vmanager.jt1078.platform.config; import com.genersoft.iot.vmp.vmanager.jt1078.platform.Jt1078OfCarController; import lombok.Data; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.*; @Data @Component public class Jt1078ConfigBean { @Value("${tuohua.bsth.jt1078.url}") private String jt1078Url; @Value("${tuohua.bsth.jt1078.sendPort}") private String jt1078SendPort; @Value("${tuohua.bsth.jt1078.stopSendPort}") private String stopSendPort; @Value("${tuohua.bsth.jt1078.historyListPort}") private String historyListPort; @Value("${tuohua.bsth.jt1078.history_upload}") private String historyUpload = "9206"; @Value("${tuohua.bsth.jt1078.playHistoryPort}") private String playHistoryPort; @Value("${tuohua.bsth.jt1078.ports}") private String portsOf1078; @Value("${tuohua.bsth.jt1078.pushURL}") private String pushURL; @Value("${tuohua.bsth.jt1078.stopPushURL}") private String stopPUshURL; private Integer start1078Port; private Integer end1078Port; @Value("${tuohua.bsth.jt1078.get.url}") private String getURL; @Value("${tuohua.bsth.jt1078.addPortVal}") private Integer addPort; @Value("${tuohua.bsth.jt1078.ws}") private String ws; @Value("${tuohua.bsth.jt1078.ws-prefix}") private String wsPrefix; @Value("${tuohua.bsth.jt1078.wss}") private String wss; @Value("${tuohua.bsth.jt1078.downloadFLV}") private String downloadFlv; @Value("${tuohua.bsth.jt1078.port}") private Integer port; @Value("${tuohua.bsth.jt1078.httpPort}") private Integer httpPort; @Value("${spring.profiles.active}") private String profilesActive; @Value("${media.pushKey}") private String pushKey; @Resource private RedisTemplate<String, Integer> redisTemplate; @Resource private FtpConfigBean ftpConfigBean; public Integer getPort() { if (port == null) { return 40000; } return port; } public Integer getHttpPort() { if (httpPort == null) { return 40000; } return httpPort; } private Integer getIntPort() { //return profilesActive.equals("wx-local") ? 10000 : 0; return 0; } @PostConstruct public void initMap() { Set<String> historyPortKeys = redisTemplate.keys("history:port:*"); Set<String> keys = redisTemplate.keys("tag:*"); Set<String> patrolKeys = redisTemplate.keys("patrol:stream:*"); Set<String> historyListKeys = redisTemplate.keys("history-list:*"); if (!historyPortKeys.isEmpty()) { keys.addAll(historyPortKeys); } if (!patrolKeys.isEmpty()) { keys.addAll(patrolKeys); } if (!historyListKeys.isEmpty()) { keys.addAll(historyListKeys); } if (keys != null) { redisTemplate.delete(keys); } Map<Integer, Set<String>> hashMap = new HashMap<>(); for (int number = getStart1078Port(); number <= getEnd1078Port(); number++) { hashMap.put(number, new HashSet<>()); } Jt1078OfCarController.map.putAll(hashMap); } private static final String SEND_IO_MESSAGE_RTSP = "{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}"; private static final String SEND_IO_MESSAGE_RTSP_STOP = "{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}"; private static final String SEND_IO_HISTORY_RTSP = "{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"channelId\":{channelNo}}"; private static final String SEND_IO_PLAY_RTSP = "{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}"; public String formatMessageId(String sim, String channel, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"0\", \"streamType\": \"1\"}", "{clientId}", sim); msg = StringUtils.replace(msg, "{tcpPort}", (port + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{channelNo}", channel); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageStop(String sim, String channel) { String msg = StringUtils.replace("{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}", "{clientId}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryListRTSP(String sim, String channel, String startTime, String endTime) { String msg = StringUtils.replace("{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":1,\"storageType\":0,\"channelNo\":{channelNo}}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryPlayRTSP(String sim, String channel, String startTime, String endTime, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); msg = StringUtils.replace(msg, "{channelNo}", channel); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() + getIntPort() +getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{sim}", sim); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageHistoryUpload(String stream) { if (StringUtils.isBlank(stream)) { throw new RuntimeException("上传参数不能为空"); } String[] split = stream.split("_"); if (split.length < 4){ throw new RuntimeException("上传参数异常, 请联系管理员"); } String sim = split[0]; String channel = split[1]; String startTime = split[2]; String endTime = split[3]; String msg = StringUtils.replace("{\n" + " \"clientId\": \"{clientId}\",\n" + " \"ip\": \"{ip}\",\n" + " \"port\": {port},\n" + " \"username\": \"{username}\",\n" + " \"password\": \"{password}\",\n" + " \"path\": \"{path}\",\n" + " \"channelNo\": {channel},\n" + " \"startTime\": \"{startTime}\",\n" + " \"endTime\": \"{endTime}\",\n" + " \"mediaType\": 0,\n" + " \"streamType\": 1,\n" + " \"storageType\": 1,\n" + " \"condition\": 6\n" + "}","{clientId}",sim); msg = StringUtils.replace(msg, "{ip}", ftpConfigBean.getHost()); msg = StringUtils.replace(msg, "{port}", ftpConfigBean.getPort().toString()); msg = StringUtils.replace(msg, "{username}", ftpConfigBean.getUsername()); msg = StringUtils.replace(msg, "{password}", ftpConfigBean.getPassword()); msg = StringUtils.replace(msg, "{path}", StringUtils.join(ftpConfigBean.getBasePath(),"/",sim,"/channel_",channel,"/",stream)); msg = StringUtils.replace(msg, "{channel}", channel); msg = StringUtils.replace(msg, "{startTime}", Jt1078OfCarController.timeCover(startTime)); return StringUtils.replace(msg, "{endTime}", Jt1078OfCarController.timeCover(endTime)); } public String formatMessageHistoryStopRTSP(String sim, String channel, RtspConfigBean configBean) { String msg = StringUtils.replace("{\"playbackMode\":2,\"channelNo\":{channelNo},\"playbackSpeed\":0,\"clientId\":\"{sim}\"}", "{sim}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.pushURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatStopPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.stopPUshURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatVideoURL(String stream) { String url = StringUtils.replace(getGetURL(), "{stream}", stream); if (!StringUtils.endsWith(url, ".flv")) { url = url + ".flv"; } return url; } public String getJt1078Url() { return this.jt1078Url; } public String getJt1078SendPort() { return this.jt1078SendPort; } public String getStopSendPort() { return this.stopSendPort; } public String getHistoryListPort() { return this.historyListPort; } public String getPlayHistoryPort() { return this.playHistoryPort; } public String getPushURL() { return this.pushURL; } public Integer getStart1078Port() { if (Objects.isNull(this.start1078Port)) this.start1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringBefore(this.portsOf1078, ","))); return this.start1078Port; } public Integer getEnd1078Port() { if (Objects.isNull(this.end1078Port)) this.end1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringAfter(this.portsOf1078, ","))); return this.end1078Port; } public String getPushKey(){ if (Objects.isNull(this.pushKey)){ this.pushKey = "?callId=41db35390ddad33f83944f44b8b75ded"; } return "?callId="+this.pushKey; } public String getStopPUshURL() { return this.stopPUshURL; } public String getGetURL() { return this.getURL; } public Integer getAddPort() { return this.addPort; } public String getWs() { return this.ws; } public String getWss() { return this.wss; } public String getDownloadFlv() { return downloadFlv; } public String getPortsOf1078() { return portsOf1078; } }  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +package com.genersoft.iot.vmp.vmanager.jt1078.platform.config; import com.genersoft.iot.vmp.vmanager.jt1078.platform.Jt1078OfCarController; import lombok.Data; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.*; @Data @Component public class Jt1078ConfigBean { @Value("${tuohua.bsth.jt1078.url}") private String jt1078Url; @Value("${tuohua.bsth.jt1078.sendPort}") private String jt1078SendPort; @Value("${tuohua.bsth.jt1078.stopSendPort}") private String stopSendPort; @Value("${tuohua.bsth.jt1078.historyListPort}") private String historyListPort; @Value("${tuohua.bsth.jt1078.history_upload}") private String historyUpload = "9206"; @Value("${tuohua.bsth.jt1078.playHistoryPort}") private String playHistoryPort; @Value("${tuohua.bsth.jt1078.ports}") private String portsOf1078; @Value("${tuohua.bsth.jt1078.pushURL}") private String pushURL; @Value("${tuohua.bsth.jt1078.stopPushURL}") private String stopPUshURL; private Integer start1078Port; private Integer end1078Port; @Value("${tuohua.bsth.jt1078.get.url}") private String getURL; @Value("${tuohua.bsth.jt1078.addPortVal}") private Integer addPort; @Value("${tuohua.bsth.jt1078.ws}") private String ws; @Value("${tuohua.bsth.jt1078.ws-prefix}") private String wsPrefix; @Value("${tuohua.bsth.jt1078.wss}") private String wss; @Value("${tuohua.bsth.jt1078.downloadFLV}") private String downloadFlv; @Value("${tuohua.bsth.jt1078.port}") private Integer port; @Value("${tuohua.bsth.jt1078.httpPort}") private Integer httpPort; @Value("${spring.profiles.active}") private String profilesActive; @Value("${media.pushKey}") private String pushKey; @Resource private RedisTemplate<String, Integer> redisTemplate; @Resource private FtpConfigBean ftpConfigBean; public Integer getPort() { if (port == null) { return 40000; } return port; } public Integer getHttpPort() { if (httpPort == null) { return 40000; } return httpPort; } private Integer getIntPort() { //return profilesActive.equals("wx-local") ? 10000 : 0; return 0; } @PostConstruct public void initMap() { Set<String> historyPortKeys = redisTemplate.keys("history:port:*"); Set<String> keys = redisTemplate.keys("tag:*"); Set<String> patrolKeys = redisTemplate.keys("patrol:stream:*"); Set<String> historyListKeys = redisTemplate.keys("history-list:*"); if (!historyPortKeys.isEmpty()) { keys.addAll(historyPortKeys); } if (!patrolKeys.isEmpty()) { keys.addAll(patrolKeys); } if (!historyListKeys.isEmpty()) { keys.addAll(historyListKeys); } if (keys != null) { redisTemplate.delete(keys); } Map<Integer, Set<String>> hashMap = new HashMap<>(); for (int number = getStart1078Port(); number <= getEnd1078Port(); number++) { hashMap.put(number, new HashSet<>()); } Jt1078OfCarController.map.putAll(hashMap); } private static final String SEND_IO_MESSAGE_RTSP = "{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}"; private static final String SEND_IO_MESSAGE_RTSP_STOP = "{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}"; private static final String SEND_IO_HISTORY_RTSP = "{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"channelId\":{channelNo}}"; private static final String SEND_IO_PLAY_RTSP = "{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}"; public String formatMessageId(String sim, String channel, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"0\", \"streamType\": \"0\"}", "{clientId}", sim); msg = StringUtils.replace(msg, "{tcpPort}", (port + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{channelNo}", channel); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageStop(String sim, String channel) { String msg = StringUtils.replace("{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}", "{clientId}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryListRTSP(String sim, String channel, String startTime, String endTime) { String msg = StringUtils.replace("{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":1,\"storageType\":0,\"channelNo\":{channelNo}}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryPlayRTSP(String sim, String channel, String startTime, String endTime, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); msg = StringUtils.replace(msg, "{channelNo}", channel); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() + getIntPort() +getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{sim}", sim); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageHistoryUpload(String stream) { if (StringUtils.isBlank(stream)) { throw new RuntimeException("上传参数不能为空"); } String[] split = stream.split("_"); if (split.length < 4){ throw new RuntimeException("上传参数异常, 请联系管理员"); } String sim = split[0]; String channel = split[1]; String startTime = split[2]; String endTime = split[3]; String msg = StringUtils.replace("{\n" + " \"clientId\": \"{clientId}\",\n" + " \"ip\": \"{ip}\",\n" + " \"port\": {port},\n" + " \"username\": \"{username}\",\n" + " \"password\": \"{password}\",\n" + " \"path\": \"{path}\",\n" + " \"channelNo\": {channel},\n" + " \"startTime\": \"{startTime}\",\n" + " \"endTime\": \"{endTime}\",\n" + " \"mediaType\": 0,\n" + " \"streamType\": 1,\n" + " \"storageType\": 1,\n" + " \"condition\": 6\n" + "}","{clientId}",sim); msg = StringUtils.replace(msg, "{ip}", ftpConfigBean.getHost()); msg = StringUtils.replace(msg, "{port}", ftpConfigBean.getPort().toString()); msg = StringUtils.replace(msg, "{username}", ftpConfigBean.getUsername()); msg = StringUtils.replace(msg, "{password}", ftpConfigBean.getPassword()); msg = StringUtils.replace(msg, "{path}", StringUtils.join(ftpConfigBean.getBasePath(),"/",sim,"/channel_",channel,"/",stream)); msg = StringUtils.replace(msg, "{channel}", channel); msg = StringUtils.replace(msg, "{startTime}", Jt1078OfCarController.timeCover(startTime)); return StringUtils.replace(msg, "{endTime}", Jt1078OfCarController.timeCover(endTime)); } public String formatMessageHistoryStopRTSP(String sim, String channel, RtspConfigBean configBean) { String msg = StringUtils.replace("{\"playbackMode\":2,\"channelNo\":{channelNo},\"playbackSpeed\":0,\"clientId\":\"{sim}\"}", "{sim}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.pushURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatStopPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.stopPUshURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatVideoURL(String stream) { String url = StringUtils.replace(getGetURL(), "{stream}", stream); if (!StringUtils.endsWith(url, ".flv")) { url = url + ".flv"; } return url; } public String getJt1078Url() { return this.jt1078Url; } public String getJt1078SendPort() { return this.jt1078SendPort; } public String getStopSendPort() { return this.stopSendPort; } public String getHistoryListPort() { return this.historyListPort; } public String getPlayHistoryPort() { return this.playHistoryPort; } public String getPushURL() { return this.pushURL; } public Integer getStart1078Port() { if (Objects.isNull(this.start1078Port)) this.start1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringBefore(this.portsOf1078, ","))); return this.start1078Port; } public Integer getEnd1078Port() { if (Objects.isNull(this.end1078Port)) this.end1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringAfter(this.portsOf1078, ","))); return this.end1078Port; } public String getPushKey(){ if (Objects.isNull(this.pushKey)){ this.pushKey = "?callId=41db35390ddad33f83944f44b8b75ded"; } return "?callId="+this.pushKey; } public String getStopPUshURL() { return this.stopPUshURL; } public String getGetURL() { return this.getURL; } public Integer getAddPort() { return this.addPort; } public String getWs() { return this.ws; } public String getWss() { return this.wss; } public String getDownloadFlv() { return downloadFlv; } public String getPortsOf1078() { return portsOf1078; } }
3 \ No newline at end of file 3 \ No newline at end of file
src/main/resources/application-wx-local.yml
@@ -67,8 +67,6 @@ server: @@ -67,8 +67,6 @@ server:
67 key-store-type: JKS 67 key-store-type: JKS
68 68
69 # 作为28181服务器的配置 69 # 作为28181服务器的配置
70 -# 作为28181服务器的配置  
71 -# 作为28181服务器的配置  
72 sip: 70 sip:
73 # [必须修改] 本机的IP,对应你的网卡,监听什么ip就是使用什么网卡, 71 # [必须修改] 本机的IP,对应你的网卡,监听什么ip就是使用什么网卡,
74 # 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4 72 # 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4
@@ -119,34 +117,6 @@ media: @@ -119,34 +117,6 @@ media:
119 send-port-range: 30000,35000 # 端口范围 117 send-port-range: 30000,35000 # 端口范围
120 # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 118 # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用
121 record-assist-port: 18081 119 record-assist-port: 18081
122 -#zlm 默认服务器配置  
123 -#media:  
124 -# id: guzijian  
125 -# # [必须修改] zlm服务器的内网IP  
126 -# ip: 10.10.2.22  
127 -# # [必须修改] zlm服务器的http.port  
128 -# http-port: 1090  
129 -# # [可选] 返回流地址时的ip,置空使用 media.ip 1  
130 -# stream-ip: 118.113.164.50  
131 -# # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip 1  
132 -# sdp-ip: 118.113.164.50  
133 -# # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip  
134 -# hook-ip: 10.10.2.22  
135 -# # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置  
136 -# http-ssl-port: 8443  
137 -# # [可选] zlm服务器的hook.admin_params=secret  
138 -# secret: RPorcBlIw26uHGnEHYGesIYyFDXpgjkP  
139 -# pushKey: 41db35390ddad33f83944f44b8b75ded  
140 -# # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试  
141 -# rtp:  
142 -# # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输  
143 -# enable: true  
144 -# # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性,不然自动配置此属性可能不成功  
145 -# port-range: 7000,7500 # 端口范围  
146 -# # [可选] 国标级联在此范围内选择端口发送媒体流,  
147 -# send-port-range: 7000,7500 # 端口范围  
148 -# # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用  
149 -# record-assist-port: 18081  
150 # [根据业务需求配置] 120 # [根据业务需求配置]
151 user-settings: 121 user-settings:
152 # 点播/录像回放 等待超时时间,单位:毫秒 122 # 点播/录像回放 等待超时时间,单位:毫秒
@@ -203,7 +173,7 @@ tuohua: @@ -203,7 +173,7 @@ tuohua:
203 historyUdpPort: 9999 173 historyUdpPort: 9999
204 ip : 61.169.120.202 174 ip : 61.169.120.202
205 jt1078: 175 jt1078:
206 - ws-prefix: ws://192.169.1.87:18090 176 + ws-prefix: ws://192.168.1.117:18090
207 ports: 40001,40001 177 ports: 40001,40001
208 port: 40000 178 port: 40000
209 httpPort: 3333 179 httpPort: 3333
web_src/config/index.js
@@ -29,7 +29,7 @@ module.exports = { @@ -29,7 +29,7 @@ module.exports = {
29 // Various Dev Server settings 29 // Various Dev Server settings
30 host: "127.0.0.1", 30 host: "127.0.0.1",
31 useLocalIp: false, // can be overwritten by process.env.HOST 31 useLocalIp: false, // can be overwritten by process.env.HOST
32 - port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 32 + port: 8085, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
33 autoOpenBrowser: false, 33 autoOpenBrowser: false,
34 errorOverlay: true, 34 errorOverlay: true,
35 notifyOnErrors: true, 35 notifyOnErrors: true,
web_src/src/components/common/EasyPlayer.vue
@@ -28,7 +28,10 @@ export default { @@ -28,7 +28,10 @@ export default {
28 initialPlayUrl: { type: String, default: '' }, 28 initialPlayUrl: { type: String, default: '' },
29 isResize: { type: Boolean, default: true }, 29 isResize: { type: Boolean, default: true },
30 videoTitle: { type: String, default: '' }, 30 videoTitle: { type: String, default: '' },
31 - hasAudio: { type: Boolean, default: false } 31 + hasAudio: { type: Boolean, default: false },
  32 + // 码流切换所需参数
  33 + sim: { type: String, default: '' },
  34 + channel: { type: [String, Number], default: '' }
32 }, 35 },
33 data() { 36 data() {
34 return { 37 return {
@@ -38,6 +41,7 @@ export default { @@ -38,6 +41,7 @@ export default {
38 hasStarted: false, 41 hasStarted: false,
39 showControls: false, 42 showControls: false,
40 controlTimer: null, 43 controlTimer: null,
  44 + isFullscreen: false, // 全屏状态
41 45
42 // 【配置控制表】 46 // 【配置控制表】
43 controlsConfig: { 47 controlsConfig: {
@@ -158,6 +162,19 @@ export default { @@ -158,6 +162,19 @@ export default {
158 console.warn('Player Error:', err); 162 console.warn('Player Error:', err);
159 }); 163 });
160 164
  165 + // 监听播放器自身的全屏事件(只响应当前播放器的全屏操作)
  166 + // this.playerInstance.on('fullscreen', () => {
  167 + // console.log('进入全屏: 切换为主码流');
  168 + // this.isFullscreen = true;
  169 + // this.switchStream(0); // 进入全屏切换为主码流
  170 + // });
  171 +
  172 + // this.playerInstance.on('fullscreenExit', () => {
  173 + // console.log('退出全屏: 切换为子码流');
  174 + // this.isFullscreen = false;
  175 + // this.switchStream(1); // 退出全屏切换为子码流
  176 + // });
  177 +
161 } catch (e) { 178 } catch (e) {
162 console.error("Create Error:", e); 179 console.error("Create Error:", e);
163 } 180 }
@@ -199,6 +216,84 @@ export default { @@ -199,6 +216,84 @@ export default {
199 216
200 setControls(config) { 217 setControls(config) {
201 this.controlsConfig = { ...this.controlsConfig, ...config }; 218 this.controlsConfig = { ...this.controlsConfig, ...config };
  219 + },
  220 +
  221 + // 切换码流
  222 + switchStream(type) {
  223 + // 如果没有sim和channel参数,则不发送请求
  224 + if (!this.sim || !this.channel) {
  225 + console.log('码流切换跳过: 缺少sim或channel参数');
  226 + return;
  227 + }
  228 +
  229 + const params = {
  230 + sim: this.sim,
  231 + channel: parseInt(this.channel),
  232 + type: type
  233 + };
  234 +
  235 + console.log(`码流切换: sim=${params.sim}, channel=${params.channel}, type=${type} (0=主码流, 1=子码流)`);
  236 +
  237 + // 使用箭头函数保存this引用
  238 + const doSwitch = (axiosInstance) => {
  239 + axiosInstance.post('/api/jt1078/query/switch/stream', params)
  240 + .then(res => {
  241 + if (res.data.code === 200 || res.data.code === 0) {
  242 + console.log('码流切换成功,等待设备切换...');
  243 +
  244 + // 等待设备切换码流,然后重新获取播放地址并刷新播放器
  245 + // 增加等待时间,让设备有足够时间切换码流
  246 + setTimeout(() => {
  247 + this.refreshPlayUrl();
  248 + }, 1000); // 等待1000ms让设备完成码流切换
  249 +
  250 + } else {
  251 + console.warn('码流切换失败:', res.data.msg || res.data);
  252 + }
  253 + })
  254 + .catch(err => {
  255 + console.error('码流切换请求失败:', err);
  256 + });
  257 + };
  258 +
  259 + if (this.$axios) {
  260 + doSwitch(this.$axios);
  261 + } else if (window.axios) {
  262 + doSwitch(window.axios);
  263 + }
  264 + },
  265 +
  266 + // 刷新播放地址并重新播放
  267 + refreshPlayUrl() {
  268 + if (!this.sim || !this.channel) return;
  269 +
  270 + const axiosInstance = this.$axios || window.axios;
  271 + if (!axiosInstance) return;
  272 +
  273 + axiosInstance.get(`/api/jt1078/query/send/request/io/${this.sim}/${this.channel}`)
  274 + .then(res => {
  275 + if (res.data.code === 200 || res.data.code === 0) {
  276 + const newUrl = res.data.data.ws_flv || res.data.data.wss_flv;
  277 + console.log('获取新播放地址:', newUrl);
  278 +
  279 + if (newUrl) {
  280 + // 重新创建播放器并播放新地址
  281 + // 分步执行:先销毁,等待,再重建,确保播放器完全重置
  282 + this.destroy();
  283 +
  284 + // 等待一段时间后重新创建播放器
  285 + setTimeout(() => {
  286 + this.create();
  287 + this.play(newUrl);
  288 + }, 500); // 等待500ms确保完全销毁后再重建
  289 + }
  290 + } else {
  291 + console.warn('获取播放地址失败:', res.data.msg || res.data);
  292 + }
  293 + })
  294 + .catch(err => {
  295 + console.error('获取播放地址失败:', err);
  296 + });
202 } 297 }
203 }, 298 },
204 }; 299 };
@@ -272,7 +367,7 @@ export default { @@ -272,7 +367,7 @@ export default {
272 } 367 }
273 368
274 /* 音量按钮 */ 369 /* 音量按钮 */
275 -.player-wrapper.hide-btn-audio .easyplayer-audio-box { 370 +.player-wrapper.hide-btn-audio .easyplayer-volume {
276 display: none !important; 371 display: none !important;
277 } 372 }
278 373
web_src/src/components/common/PlayerListComponent.vue
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 :initial-buffer-time="0.1" 15 :initial-buffer-time="0.1"
16 :show-custom-mask="false" 16 :show-custom-mask="false"
17 :has-audio="true" 17 :has-audio="true"
  18 + :sim="playerDataList[i] ? playerDataList[i].sim : ''"
  19 + :channel="playerDataList[i] ? playerDataList[i].channel : ''"
18 style="width: 100%;height: 100%;" 20 style="width: 100%;height: 100%;"
19 @click="playerClick(item, i, items.length)" 21 @click="playerClick(item, i, items.length)"
20 ></easyPlayer> 22 ></easyPlayer>
@@ -57,6 +59,16 @@ export default { @@ -57,6 +59,16 @@ export default {
57 }, 59 },
58 //计算属性 类似于data概念", 60 //计算属性 类似于data概念",
59 computed: { 61 computed: {
  62 + // 生成播放器数据列表,包含 sim 和 channel
  63 + playerDataList() {
  64 + return this.items.map((item, i) => {
  65 + const data = this.videoDataList[i] || {};
  66 + return {
  67 + sim: this.getSim(data),
  68 + channel: this.getChannel(data)
  69 + };
  70 + });
  71 + },
60 }, 72 },
61 //监控data中的数据变化", 73 //监控data中的数据变化",
62 watch: { 74 watch: {
@@ -272,6 +284,22 @@ export default { @@ -272,6 +284,22 @@ export default {
272 } 284 }
273 }); 285 });
274 }, 286 },
  287 +
  288 + // 获取SIM卡号 (从parent对象中获取)
  289 + getSim(data) {
  290 + if (!data) return '';
  291 + // 优先从自身获取,否则从parent对象获取
  292 + return data.sim || (data.parent && data.parent.sim) || '';
  293 + },
  294 +
  295 + // 获取通道号 (从code中提取,格式: id_sim_channelNumber)
  296 + getChannel(data) {
  297 + console.log(data)
  298 + if (!data || !data.code) return '';
  299 + const parts = data.code.split('_');
  300 + // code格式: id_sim_channelNumber, channel是最后一部分
  301 + return parts.length >= 3 ? parts[parts.length - 1] : '';
  302 + }
275 }, 303 },
276 //生命周期 - 创建完成(可以访问当前this实例)", 304 //生命周期 - 创建完成(可以访问当前this实例)",
277 created() { 305 created() {
web_src/src/components/dialog/importChannel.vue
@@ -53,7 +53,7 @@ export default { @@ -53,7 +53,7 @@ export default {
53 headers: { 53 headers: {
54 "access-token": userService.getToken() 54 "access-token": userService.getToken()
55 }, 55 },
56 - uploadUrl: process.env.NODE_ENV === 'development'? `http://127.0.0.1:8080/debug/api/push/upload`: (window.baseUrl ? window.baseUrl : "") + `/api/push/upload`, 56 + uploadUrl: process.env.NODE_ENV === 'development'? `http://127.0.0.1:8085/debug/api/push/upload`: (window.baseUrl ? window.baseUrl : "") + `/api/push/upload`,
57 }; 57 };
58 }, 58 },
59 methods: { 59 methods: {