Commit 96bb3814f65edb36327eb02f2ea1beed30f06dfc
Merge branch 'wvp-28181-2.0' into wvp-28181-2.0-multi-network
# Conflicts: # src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java # src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java # web_src/src/components/dialog/devicePlayer.vue # web_src/src/components/live.vue
Showing
91 changed files
with
737 additions
and
628 deletions
doc/_content/qa/play_error.md
pom.xml
| ... | ... | @@ -153,13 +153,17 @@ |
| 153 | 153 | <version>2.1.3</version> |
| 154 | 154 | </dependency> |
| 155 | 155 | |
| 156 | - <!-- json解析库fastjson --> | |
| 156 | + <!-- json解析库fastjson2 --> | |
| 157 | 157 | <dependency> |
| 158 | - <groupId>com.alibaba</groupId> | |
| 159 | - <artifactId>fastjson</artifactId> | |
| 160 | - <version>1.2.83</version> | |
| 158 | + <groupId>com.alibaba.fastjson2</groupId> | |
| 159 | + <artifactId>fastjson2</artifactId> | |
| 160 | + <version>2.0.17</version> | |
| 161 | + </dependency> | |
| 162 | + <dependency> | |
| 163 | + <groupId>com.alibaba.fastjson2</groupId> | |
| 164 | + <artifactId>fastjson2-extension</artifactId> | |
| 165 | + <version>2.0.17</version> | |
| 161 | 166 | </dependency> |
| 162 | - | |
| 163 | 167 | |
| 164 | 168 | <!-- okhttp --> |
| 165 | 169 | <dependency> | ... | ... |
src/main/java/com/genersoft/iot/vmp/common/VersionPo.java
src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java
| 1 | 1 | package com.genersoft.iot.vmp.conf; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.support.spring.http.converter.FastJsonHttpMessageConverter; | |
| 5 | 5 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 6 | 6 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 7 | 7 | import org.jetbrains.annotations.NotNull; | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/MediaStatusTimerTask.java
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
| ... | ... | @@ -37,6 +37,8 @@ public class UserSetting { |
| 37 | 37 | |
| 38 | 38 | private Boolean streamOnDemand = Boolean.TRUE; |
| 39 | 39 | |
| 40 | + private Boolean pushAuthority = Boolean.TRUE; | |
| 41 | + | |
| 40 | 42 | private String serverId = "000000"; |
| 41 | 43 | |
| 42 | 44 | private String thirdPartyGBIdReg = "[\\s\\S]*"; |
| ... | ... | @@ -166,4 +168,12 @@ public class UserSetting { |
| 166 | 168 | public void setUseSourceIpAsStreamIp(Boolean useSourceIpAsStreamIp) { |
| 167 | 169 | this.useSourceIpAsStreamIp = useSourceIpAsStreamIp; |
| 168 | 170 | } |
| 171 | + | |
| 172 | + public Boolean getPushAuthority() { | |
| 173 | + return pushAuthority; | |
| 174 | + } | |
| 175 | + | |
| 176 | + public void setPushAuthority(Boolean pushAuthority) { | |
| 177 | + this.pushAuthority = pushAuthority; | |
| 178 | + } | |
| 169 | 179 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java
| 1 | 1 | package com.genersoft.iot.vmp.conf; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 5 | 5 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 6 | 6 | import org.springframework.beans.factory.annotation.Autowired; | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java
| 1 | 1 | package com.genersoft.iot.vmp.conf.redis; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import com.alibaba.fastjson.parser.ParserConfig; | |
| 5 | 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 6 | 5 | import com.genersoft.iot.vmp.service.redisMsg.*; |
| 7 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -55,8 +54,7 @@ public class RedisConfig extends CachingConfigurerSupport { |
| 55 | 54 | // value值的序列化采用fastJsonRedisSerializer |
| 56 | 55 | redisTemplate.setValueSerializer(fastJsonRedisSerializer); |
| 57 | 56 | redisTemplate.setHashValueSerializer(fastJsonRedisSerializer); |
| 58 | - // 全局开启AutoType,不建议使用 | |
| 59 | - ParserConfig.getGlobalInstance().setAutoTypeSupport(true); | |
| 57 | + | |
| 60 | 58 | // key的序列化采用StringRedisSerializer |
| 61 | 59 | redisTemplate.setKeySerializer(new StringRedisSerializer()); |
| 62 | 60 | redisTemplate.setHashKeySerializer(new StringRedisSerializer()); | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamInfo.java
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
| ... | ... | @@ -42,7 +42,7 @@ public class CatalogDataCatch { |
| 42 | 42 | catalogData.setSn(sn); |
| 43 | 43 | catalogData.setTotal(total); |
| 44 | 44 | catalogData.setDevice(device); |
| 45 | - catalogData.setChannelList(Collections.synchronizedList(new ArrayList<>())); | |
| 45 | + catalogData.setChannelList(deviceChannelList); | |
| 46 | 46 | catalogData.setStatus(CatalogData.CatalogDataStatus.runIng); |
| 47 | 47 | catalogData.setLastTime(Instant.now()); |
| 48 | 48 | data.put(deviceId, catalogData); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.task; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.SipConfig; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 4 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| ... | ... | @@ -347,7 +347,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 347 | 347 | return; |
| 348 | 348 | } |
| 349 | 349 | logger.info("[发送报警通知] {}/{}->{},{}: {}", parentPlatform.getServerGBId(), deviceAlarm.getChannelId(), |
| 350 | - deviceAlarm.getLongitude(), deviceAlarm.getLatitude(), JSONObject.toJSON(deviceAlarm)); | |
| 350 | + deviceAlarm.getLongitude(), deviceAlarm.getLatitude(), JSON.toJSONString(deviceAlarm)); | |
| 351 | 351 | String characterSet = parentPlatform.getCharacterSet(); |
| 352 | 352 | StringBuffer deviceStatusXml = new StringBuffer(600); |
| 353 | 353 | deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 5 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 5 | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | 7 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| ... | ... | @@ -141,7 +142,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In |
| 141 | 142 | logger.info("调用ZLM推流接口, 结果: {}", jsonObject); |
| 142 | 143 | logger.info("RTP推流成功[ {}/{} ],{}->{}:{}, " ,param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port")); |
| 143 | 144 | } else { |
| 144 | - logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"),JSONObject.toJSON(param)); | |
| 145 | + logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"), JSON.toJSONString(param)); | |
| 145 | 146 | if (sendRtpItem.isOnlyAudio()) { |
| 146 | 147 | // TODO 可能是语音对讲 |
| 147 | 148 | }else { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.*; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.*; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 5 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 5 | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 7 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| ... | ... | @@ -184,7 +185,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme |
| 184 | 185 | deviceAlarm.setAlarmType(getText(sipMsgInfo.getRootElement().element("Info"), "AlarmType")); |
| 185 | 186 | } |
| 186 | 187 | } |
| 187 | - logger.info("[收到报警通知]内容:{}", JSONObject.toJSON(deviceAlarm)); | |
| 188 | + logger.info("[收到报警通知]内容:{}", JSON.toJSONString(deviceAlarm)); | |
| 188 | 189 | if ("7".equals(deviceAlarm.getAlarmMethod()) ) { |
| 189 | 190 | // 发送给平台的报警信息。 发送redis通知 |
| 190 | 191 | AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceConfigResponseMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceControlResponseMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.utils; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONArray; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONArray; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.bean.TreeType; | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
| 1 | 1 | package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 6 | 6 | import okhttp3.*; |
| 7 | 7 | import okhttp3.logging.HttpLoggingInterceptor; | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| ... | ... | @@ -5,7 +5,7 @@ import java.util.HashMap; |
| 5 | 5 | import java.util.List; |
| 6 | 6 | import java.util.Map; |
| 7 | 7 | |
| 8 | -import com.alibaba.fastjson.JSON; | |
| 8 | +import com.alibaba.fastjson2.JSON; | |
| 9 | 9 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 10 | 10 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 11 | 11 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| ... | ... | @@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 14 | 14 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 15 | 15 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; |
| 16 | 16 | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| 17 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.*; | |
| 17 | 18 | import com.genersoft.iot.vmp.service.*; |
| 18 | 19 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 19 | 20 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| ... | ... | @@ -29,7 +30,7 @@ import org.springframework.web.bind.annotation.RequestMapping; |
| 29 | 30 | import org.springframework.web.bind.annotation.ResponseBody; |
| 30 | 31 | import org.springframework.web.bind.annotation.RestController; |
| 31 | 32 | |
| 32 | -import com.alibaba.fastjson.JSONObject; | |
| 33 | +import com.alibaba.fastjson2.JSONObject; | |
| 33 | 34 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 34 | 35 | |
| 35 | 36 | import javax.servlet.http.HttpServletRequest; |
| ... | ... | @@ -108,17 +109,20 @@ public class ZLMHttpHookListener { |
| 108 | 109 | */ |
| 109 | 110 | @ResponseBody |
| 110 | 111 | @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8") |
| 111 | - public JSONObject onServerKeepalive(@RequestBody JSONObject json){ | |
| 112 | + public JSONObject onServerKeepalive(@RequestBody OnServerKeepaliveHookParam param){ | |
| 112 | 113 | |
| 113 | - logger.info("[ ZLM HOOK ]on_server_keepalive API调用,参数:" + json.toString()); | |
| 114 | - String mediaServerId = json.getString("mediaServerId"); | |
| 115 | - List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive); | |
| 116 | - if (subscribes != null && subscribes.size() > 0) { | |
| 117 | - for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { | |
| 118 | - subscribe.response(null, json); | |
| 114 | + logger.info("[ZLM HOOK] 收到zlm心跳:" + param.getMediaServerId()); | |
| 115 | + | |
| 116 | + taskExecutor.execute(()->{ | |
| 117 | + List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive); | |
| 118 | + JSONObject json = (JSONObject) JSON.toJSON(param); | |
| 119 | + if (subscribes != null && subscribes.size() > 0) { | |
| 120 | + for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { | |
| 121 | + subscribe.response(null, json); | |
| 122 | + } | |
| 119 | 123 | } |
| 120 | - } | |
| 121 | - mediaServerService.updateMediaServerKeepalive(mediaServerId, json.getJSONObject("data")); | |
| 124 | + }); | |
| 125 | + mediaServerService.updateMediaServerKeepalive(param.getMediaServerId(), param.getData()); | |
| 122 | 126 | |
| 123 | 127 | JSONObject ret = new JSONObject(); |
| 124 | 128 | ret.put("code", 0); |
| ... | ... | @@ -126,43 +130,6 @@ public class ZLMHttpHookListener { |
| 126 | 130 | |
| 127 | 131 | return ret; |
| 128 | 132 | } |
| 129 | - | |
| 130 | - /** | |
| 131 | - * 流量统计事件,播放器或推流器断开时并且耗用流量超过特定阈值时会触发此事件,阈值通过配置文件general.flowThreshold配置;此事件对回复不敏感。 | |
| 132 | - * | |
| 133 | - */ | |
| 134 | - @ResponseBody | |
| 135 | - @PostMapping(value = "/on_flow_report", produces = "application/json;charset=UTF-8") | |
| 136 | - public JSONObject onFlowReport(@RequestBody JSONObject json){ | |
| 137 | - | |
| 138 | - if (logger.isDebugEnabled()) { | |
| 139 | - logger.debug("[ ZLM HOOK ]on_flow_report API调用,参数:" + json.toString()); | |
| 140 | - } | |
| 141 | - JSONObject ret = new JSONObject(); | |
| 142 | - ret.put("code", 0); | |
| 143 | - ret.put("msg", "success"); | |
| 144 | - return ret; | |
| 145 | - } | |
| 146 | - | |
| 147 | - /** | |
| 148 | - * 访问http文件服务器上hls之外的文件时触发。 | |
| 149 | - * | |
| 150 | - */ | |
| 151 | - @ResponseBody | |
| 152 | - @PostMapping(value = "/on_http_access", produces = "application/json;charset=UTF-8") | |
| 153 | - public JSONObject onHttpAccess(@RequestBody JSONObject json){ | |
| 154 | - | |
| 155 | - if (logger.isDebugEnabled()) { | |
| 156 | - logger.debug("[ ZLM HOOK ]on_http_access API 调用,参数:" + json.toString()); | |
| 157 | - } | |
| 158 | - String mediaServerId = json.getString("mediaServerId"); | |
| 159 | - JSONObject ret = new JSONObject(); | |
| 160 | - ret.put("code", 0); | |
| 161 | - ret.put("err", ""); | |
| 162 | - ret.put("path", ""); | |
| 163 | - ret.put("second", 600); | |
| 164 | - return ret; | |
| 165 | - } | |
| 166 | 133 | |
| 167 | 134 | /** |
| 168 | 135 | * 播放器鉴权事件,rtsp/rtmp/http-flv/ws-flv/hls的播放都将触发此鉴权事件。 |
| ... | ... | @@ -171,20 +138,21 @@ public class ZLMHttpHookListener { |
| 171 | 138 | @ResponseBody |
| 172 | 139 | @PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8") |
| 173 | 140 | public JSONObject onPlay(@RequestBody OnPlayHookParam param){ |
| 174 | - | |
| 175 | - JSONObject json = (JSONObject)JSON.toJSON(param); | |
| 176 | - | |
| 177 | 141 | if (logger.isDebugEnabled()) { |
| 178 | - logger.debug("[ ZLM HOOK ]on_play API调用,参数:" + JSON.toJSONString(param)); | |
| 142 | + logger.debug("[ZLM HOOK] 播放鉴权:{}->{}" + param.getMediaServerId(), param); | |
| 179 | 143 | } |
| 180 | 144 | String mediaServerId = param.getMediaServerId(); |
| 181 | - ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json); | |
| 182 | - if (subscribe != null ) { | |
| 183 | - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); | |
| 184 | - if (mediaInfo != null) { | |
| 185 | - subscribe.response(mediaInfo, json); | |
| 145 | + | |
| 146 | + taskExecutor.execute(()->{ | |
| 147 | + JSONObject json = (JSONObject) JSON.toJSON(param); | |
| 148 | + ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json); | |
| 149 | + if (subscribe != null ) { | |
| 150 | + MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); | |
| 151 | + if (mediaInfo != null) { | |
| 152 | + subscribe.response(mediaInfo, json); | |
| 153 | + } | |
| 186 | 154 | } |
| 187 | - } | |
| 155 | + }); | |
| 188 | 156 | JSONObject ret = new JSONObject(); |
| 189 | 157 | if (!"rtp".equals(param.getApp())) { |
| 190 | 158 | Map<String, String> paramMap = urlParamToMap(param.getParams()); |
| ... | ... | @@ -211,46 +179,49 @@ public class ZLMHttpHookListener { |
| 211 | 179 | |
| 212 | 180 | JSONObject json = (JSONObject) JSON.toJSON(param); |
| 213 | 181 | |
| 214 | - logger.info("[ ZLM HOOK ]on_publish API调用,参数:" + json.toString()); | |
| 182 | + logger.info("[ZLM HOOK]推流鉴权:{}->{}", param.getMediaServerId(), param); | |
| 215 | 183 | JSONObject ret = new JSONObject(); |
| 216 | 184 | String mediaServerId = json.getString("mediaServerId"); |
| 217 | 185 | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); |
| 186 | + | |
| 218 | 187 | if (!"rtp".equals(param.getApp())) { |
| 219 | - // 推流鉴权 | |
| 220 | - if (param.getParams() == null) { | |
| 221 | - logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); | |
| 222 | - ret.put("code", 401); | |
| 223 | - ret.put("msg", "Unauthorized"); | |
| 224 | - return ret; | |
| 225 | - } | |
| 226 | - Map<String, String> paramMap = urlParamToMap(param.getParams()); | |
| 227 | - String sign = paramMap.get("sign"); | |
| 228 | - if (sign == null) { | |
| 229 | - logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); | |
| 230 | - ret.put("code", 401); | |
| 231 | - ret.put("msg", "Unauthorized"); | |
| 232 | - return ret; | |
| 233 | - } | |
| 234 | - // 推流自定义播放鉴权码 | |
| 235 | - String callId = paramMap.get("callId"); | |
| 236 | - // 鉴权配置 | |
| 237 | - boolean hasAuthority = userService.checkPushAuthority(callId, sign); | |
| 238 | - if (!hasAuthority) { | |
| 239 | - logger.info("推流鉴权失败: sign 无权限: callId={}. sign={}", callId, sign); | |
| 240 | - ret.put("code", 401); | |
| 241 | - ret.put("msg", "Unauthorized"); | |
| 242 | - return ret; | |
| 243 | - } | |
| 244 | - StreamAuthorityInfo streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); | |
| 245 | - streamAuthorityInfo.setCallId(callId); | |
| 246 | - streamAuthorityInfo.setSign(sign); | |
| 247 | - // 鉴权通过 | |
| 248 | - redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); | |
| 249 | - // 通知assist新的callId | |
| 250 | - if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) { | |
| 251 | - taskExecutor.execute(()->{ | |
| 252 | - assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null); | |
| 253 | - }); | |
| 188 | + if (userSetting.getPushAuthority()) { | |
| 189 | +// 推流鉴权 | |
| 190 | + if (param.getParams() == null) { | |
| 191 | + logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); | |
| 192 | + ret.put("code", 401); | |
| 193 | + ret.put("msg", "Unauthorized"); | |
| 194 | + return ret; | |
| 195 | + } | |
| 196 | + Map<String, String> paramMap = urlParamToMap(param.getParams()); | |
| 197 | + String sign = paramMap.get("sign"); | |
| 198 | + if (sign == null) { | |
| 199 | + logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); | |
| 200 | + ret.put("code", 401); | |
| 201 | + ret.put("msg", "Unauthorized"); | |
| 202 | + return ret; | |
| 203 | + } | |
| 204 | + // 推流自定义播放鉴权码 | |
| 205 | + String callId = paramMap.get("callId"); | |
| 206 | + // 鉴权配置 | |
| 207 | + boolean hasAuthority = userService.checkPushAuthority(callId, sign); | |
| 208 | + if (!hasAuthority) { | |
| 209 | + logger.info("推流鉴权失败: sign 无权限: callId={}. sign={}", callId, sign); | |
| 210 | + ret.put("code", 401); | |
| 211 | + ret.put("msg", "Unauthorized"); | |
| 212 | + return ret; | |
| 213 | + } | |
| 214 | + StreamAuthorityInfo streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); | |
| 215 | + streamAuthorityInfo.setCallId(callId); | |
| 216 | + streamAuthorityInfo.setSign(sign); | |
| 217 | + // 鉴权通过 | |
| 218 | + redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); | |
| 219 | + // 通知assist新的callId | |
| 220 | + if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) { | |
| 221 | + taskExecutor.execute(()->{ | |
| 222 | + assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null); | |
| 223 | + }); | |
| 224 | + } | |
| 254 | 225 | } |
| 255 | 226 | }else { |
| 256 | 227 | zlmMediaListManager.sendStreamEvent(param.getApp(),param.getStream(), param.getMediaServerId()); |
| ... | ... | @@ -258,21 +229,22 @@ public class ZLMHttpHookListener { |
| 258 | 229 | |
| 259 | 230 | ret.put("code", 0); |
| 260 | 231 | ret.put("msg", "success"); |
| 261 | - ret.put("enable_hls", true); | |
| 232 | + | |
| 262 | 233 | if (!"rtp".equals(param.getApp())) { |
| 263 | 234 | ret.put("enable_audio", true); |
| 264 | 235 | } |
| 265 | 236 | |
| 266 | - | |
| 267 | - ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); | |
| 268 | - if (subscribe != null) { | |
| 269 | - if (mediaInfo != null) { | |
| 270 | - subscribe.response(mediaInfo, json); | |
| 271 | - }else { | |
| 272 | - ret.put("code", 1); | |
| 273 | - ret.put("msg", "zlm not register"); | |
| 237 | + taskExecutor.execute(()->{ | |
| 238 | + ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); | |
| 239 | + if (subscribe != null) { | |
| 240 | + if (mediaInfo != null) { | |
| 241 | + subscribe.response(mediaInfo, json); | |
| 242 | + }else { | |
| 243 | + ret.put("code", 1); | |
| 244 | + ret.put("msg", "zlm not register"); | |
| 245 | + } | |
| 274 | 246 | } |
| 275 | - } | |
| 247 | + }); | |
| 276 | 248 | |
| 277 | 249 | if ("rtp".equals(param.getApp())) { |
| 278 | 250 | ret.put("enable_mp4", userSetting.getRecordSip()); |
| ... | ... | @@ -292,111 +264,8 @@ public class ZLMHttpHookListener { |
| 292 | 264 | ret.put("mp4_max_second", 10); |
| 293 | 265 | ret.put("enable_mp4", true); |
| 294 | 266 | ret.put("enable_audio", true); |
| 295 | - | |
| 296 | - } | |
| 297 | - } | |
| 298 | - return ret; | |
| 299 | - } | |
| 300 | - | |
| 301 | - | |
| 302 | - | |
| 303 | - /** | |
| 304 | - * 录制mp4完成后通知事件;此事件对回复不敏感。 | |
| 305 | - * | |
| 306 | - */ | |
| 307 | - @ResponseBody | |
| 308 | - @PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8") | |
| 309 | - public JSONObject onRecordMp4(@RequestBody JSONObject json){ | |
| 310 | - | |
| 311 | - if (logger.isDebugEnabled()) { | |
| 312 | - logger.debug("[ ZLM HOOK ]on_record_mp4 API调用,参数:" + json.toString()); | |
| 313 | - } | |
| 314 | - String mediaServerId = json.getString("mediaServerId"); | |
| 315 | - JSONObject ret = new JSONObject(); | |
| 316 | - ret.put("code", 0); | |
| 317 | - ret.put("msg", "success"); | |
| 318 | - return ret; | |
| 319 | - } | |
| 320 | - /** | |
| 321 | - * 录制hls完成后通知事件;此事件对回复不敏感。 | |
| 322 | - * | |
| 323 | - */ | |
| 324 | - @ResponseBody | |
| 325 | - @PostMapping(value = "/on_record_ts", produces = "application/json;charset=UTF-8") | |
| 326 | - public JSONObject onRecordTs(@RequestBody JSONObject json){ | |
| 327 | - | |
| 328 | - if (logger.isDebugEnabled()) { | |
| 329 | - logger.debug("[ ZLM HOOK ]on_record_ts API调用,参数:" + json.toString()); | |
| 330 | - } | |
| 331 | - String mediaServerId = json.getString("mediaServerId"); | |
| 332 | - JSONObject ret = new JSONObject(); | |
| 333 | - ret.put("code", 0); | |
| 334 | - ret.put("msg", "success"); | |
| 335 | - return ret; | |
| 336 | - } | |
| 337 | - | |
| 338 | - /** | |
| 339 | - * rtsp专用的鉴权事件,先触发on_rtsp_realm事件然后才会触发on_rtsp_auth事件。 | |
| 340 | - * | |
| 341 | - */ | |
| 342 | - @ResponseBody | |
| 343 | - @PostMapping(value = "/on_rtsp_realm", produces = "application/json;charset=UTF-8") | |
| 344 | - public JSONObject onRtspRealm(@RequestBody JSONObject json){ | |
| 345 | - | |
| 346 | - if (logger.isDebugEnabled()) { | |
| 347 | - logger.debug("[ ZLM HOOK ]on_rtsp_realm API调用,参数:" + json.toString()); | |
| 348 | - } | |
| 349 | - String mediaServerId = json.getString("mediaServerId"); | |
| 350 | - JSONObject ret = new JSONObject(); | |
| 351 | - ret.put("code", 0); | |
| 352 | - ret.put("realm", ""); | |
| 353 | - return ret; | |
| 354 | - } | |
| 355 | - | |
| 356 | - | |
| 357 | - /** | |
| 358 | - * 该rtsp流是否开启rtsp专用方式的鉴权事件,开启后才会触发on_rtsp_auth事件。需要指出的是rtsp也支持url参数鉴权,它支持两种方式鉴权。 | |
| 359 | - * | |
| 360 | - */ | |
| 361 | - @ResponseBody | |
| 362 | - @PostMapping(value = "/on_rtsp_auth", produces = "application/json;charset=UTF-8") | |
| 363 | - public JSONObject onRtspAuth(@RequestBody JSONObject json){ | |
| 364 | - | |
| 365 | - if (logger.isDebugEnabled()) { | |
| 366 | - logger.debug("[ ZLM HOOK ]on_rtsp_auth API调用,参数:" + json.toString()); | |
| 367 | - } | |
| 368 | - String mediaServerId = json.getString("mediaServerId"); | |
| 369 | - JSONObject ret = new JSONObject(); | |
| 370 | - ret.put("code", 0); | |
| 371 | - ret.put("encrypted", false); | |
| 372 | - ret.put("passwd", "test"); | |
| 373 | - return ret; | |
| 374 | - } | |
| 375 | - | |
| 376 | - /** | |
| 377 | - * shell登录鉴权,ZLMediaKit提供简单的telnet调试方式,使用telnet 127.0.0.1 9000能进入MediaServer进程的shell界面。 | |
| 378 | - * | |
| 379 | - */ | |
| 380 | - @ResponseBody | |
| 381 | - @PostMapping(value = "/on_shell_login", produces = "application/json;charset=UTF-8") | |
| 382 | - public JSONObject onShellLogin(@RequestBody JSONObject json){ | |
| 383 | - | |
| 384 | - if (logger.isDebugEnabled()) { | |
| 385 | - logger.debug("[ ZLM HOOK ]on_shell_login API调用,参数:" + json.toString()); | |
| 386 | - } | |
| 387 | - String mediaServerId = json.getString("mediaServerId"); | |
| 388 | - ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_shell_login, json); | |
| 389 | - if (subscribe != null ) { | |
| 390 | - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); | |
| 391 | - if (mediaInfo != null) { | |
| 392 | - subscribe.response(mediaInfo, json); | |
| 393 | 267 | } |
| 394 | - | |
| 395 | 268 | } |
| 396 | - | |
| 397 | - JSONObject ret = new JSONObject(); | |
| 398 | - ret.put("code", 0); | |
| 399 | - ret.put("msg", "success"); | |
| 400 | 269 | return ret; |
| 401 | 270 | } |
| 402 | 271 | |
| ... | ... | @@ -406,137 +275,139 @@ public class ZLMHttpHookListener { |
| 406 | 275 | */ |
| 407 | 276 | @ResponseBody |
| 408 | 277 | @PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8") |
| 409 | - public JSONObject onStreamChanged(@RequestBody MediaItem item){ | |
| 410 | - | |
| 411 | - logger.info("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item)); | |
| 412 | - String mediaServerId = item.getMediaServerId(); | |
| 413 | - JSONObject json = (JSONObject) JSON.toJSON(item); | |
| 414 | - ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); | |
| 415 | - if (subscribe != null ) { | |
| 416 | - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); | |
| 417 | - if (mediaInfo != null) { | |
| 418 | - subscribe.response(mediaInfo, json); | |
| 419 | - } | |
| 420 | - } | |
| 421 | - // 流消失移除redis play | |
| 422 | - String app = item.getApp(); | |
| 423 | - String stream = item.getStream(); | |
| 424 | - String schema = item.getSchema(); | |
| 425 | - List<MediaItem.MediaTrack> tracks = item.getTracks(); | |
| 426 | - boolean regist = item.isRegist(); | |
| 427 | - if (regist) { | |
| 428 | - if (item.getOriginType() == OriginType.RTMP_PUSH.ordinal() | |
| 429 | - || item.getOriginType() == OriginType.RTSP_PUSH.ordinal() | |
| 430 | - || item.getOriginType() == OriginType.RTC_PUSH.ordinal()) { | |
| 431 | - | |
| 432 | - StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); | |
| 433 | - if (streamAuthorityInfo == null) { | |
| 434 | - streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(item); | |
| 435 | - }else { | |
| 436 | - streamAuthorityInfo.setOriginType(item.getOriginType()); | |
| 437 | - streamAuthorityInfo.setOriginTypeStr(item.getOriginTypeStr()); | |
| 438 | - } | |
| 439 | - redisCatchStorage.updateStreamAuthorityInfo(app, stream, streamAuthorityInfo); | |
| 440 | - } | |
| 278 | + public JSONObject onStreamChanged(@RequestBody OnStreamChangedHookParam param){ | |
| 279 | + | |
| 280 | + if (param.isRegist()) { | |
| 281 | + logger.info("[ZLM HOOK] 流注册, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); | |
| 441 | 282 | }else { |
| 442 | - redisCatchStorage.removeStreamAuthorityInfo(app, stream); | |
| 283 | + logger.info("[ZLM HOOK] 流注销, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); | |
| 443 | 284 | } |
| 444 | 285 | |
| 445 | - if ("rtsp".equals(schema)){ | |
| 446 | - logger.info("on_stream_changed:注册->{}, app->{}, stream->{}", regist, app, stream); | |
| 447 | - if (regist) { | |
| 448 | - mediaServerService.addCount(mediaServerId); | |
| 449 | - }else { | |
| 450 | - mediaServerService.removeCount(mediaServerId); | |
| 451 | - } | |
| 452 | - if (item.getOriginType() == OriginType.PULL.ordinal() | |
| 453 | - || item.getOriginType() == OriginType.FFMPEG_PULL.ordinal()) { | |
| 454 | - // 设置拉流代理上线/离线 | |
| 455 | - streamProxyService.updateStatus(regist, app, stream); | |
| 286 | + | |
| 287 | + JSONObject json = (JSONObject) JSON.toJSON(param); | |
| 288 | + taskExecutor.execute(()->{ | |
| 289 | + ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); | |
| 290 | + if (subscribe != null ) { | |
| 291 | + MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); | |
| 292 | + if (mediaInfo != null) { | |
| 293 | + subscribe.response(mediaInfo, json); | |
| 294 | + } | |
| 456 | 295 | } |
| 457 | - if ("rtp".equals(app) && !regist ) { | |
| 458 | - StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(stream); | |
| 459 | - if (streamInfo!=null){ | |
| 460 | - redisCatchStorage.stopPlay(streamInfo); | |
| 461 | - storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | |
| 462 | - }else{ | |
| 463 | - streamInfo = redisCatchStorage.queryPlayback(null, null, stream, null); | |
| 464 | - if (streamInfo != null) { | |
| 465 | - redisCatchStorage.stopPlayback(streamInfo.getDeviceID(), streamInfo.getChannelId(), | |
| 466 | - streamInfo.getStream(), null); | |
| 296 | + // 流消失移除redis play | |
| 297 | + List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks(); | |
| 298 | + if (param.isRegist()) { | |
| 299 | + if (param.getOriginType() == OriginType.RTMP_PUSH.ordinal() | |
| 300 | + || param.getOriginType() == OriginType.RTSP_PUSH.ordinal() | |
| 301 | + || param.getOriginType() == OriginType.RTC_PUSH.ordinal()) { | |
| 302 | + | |
| 303 | + StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); | |
| 304 | + if (streamAuthorityInfo == null) { | |
| 305 | + streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); | |
| 306 | + }else { | |
| 307 | + streamAuthorityInfo.setOriginType(param.getOriginType()); | |
| 308 | + streamAuthorityInfo.setOriginTypeStr(param.getOriginTypeStr()); | |
| 467 | 309 | } |
| 310 | + redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); | |
| 468 | 311 | } |
| 469 | 312 | }else { |
| 470 | - if (!"rtp".equals(app)){ | |
| 471 | - String type = OriginType.values()[item.getOriginType()].getType(); | |
| 472 | - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); | |
| 473 | - | |
| 474 | - if (mediaServerItem != null){ | |
| 475 | - if (regist) { | |
| 476 | - StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); | |
| 477 | - String callId = null; | |
| 478 | - if (streamAuthorityInfo != null) { | |
| 479 | - callId = streamAuthorityInfo.getCallId(); | |
| 480 | - } | |
| 481 | - StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem, | |
| 482 | - app, stream, tracks, callId); | |
| 483 | - item.setStreamInfo(streamInfoByAppAndStream); | |
| 484 | - redisCatchStorage.addStream(mediaServerItem, type, app, stream, item); | |
| 485 | - if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() | |
| 486 | - || item.getOriginType() == OriginType.RTMP_PUSH.ordinal() | |
| 487 | - || item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) { | |
| 488 | - item.setSeverId(userSetting.getServerId()); | |
| 489 | - zlmMediaListManager.addPush(item); | |
| 490 | - } | |
| 491 | - }else { | |
| 492 | - // 兼容流注销时类型从redis记录获取 | |
| 493 | - MediaItem mediaItem = redisCatchStorage.getStreamInfo(app, stream, mediaServerId); | |
| 494 | - if (mediaItem != null) { | |
| 495 | - type = OriginType.values()[mediaItem.getOriginType()].getType(); | |
| 496 | - redisCatchStorage.removeStream(mediaServerItem.getId(), type, app, stream); | |
| 497 | - } | |
| 498 | - GbStream gbStream = storager.getGbStream(app, stream); | |
| 499 | - if (gbStream != null) { | |
| 313 | + redisCatchStorage.removeStreamAuthorityInfo(param.getApp(), param.getStream()); | |
| 314 | + } | |
| 315 | + | |
| 316 | + if ("rtsp".equals(param.getSchema())){ | |
| 317 | + if (param.isRegist()) { | |
| 318 | + mediaServerService.addCount(param.getMediaServerId()); | |
| 319 | + }else { | |
| 320 | + mediaServerService.removeCount(param.getMediaServerId()); | |
| 321 | + } | |
| 322 | + if (param.getOriginType() == OriginType.PULL.ordinal() | |
| 323 | + || param.getOriginType() == OriginType.FFMPEG_PULL.ordinal()) { | |
| 324 | + // 设置拉流代理上线/离线 | |
| 325 | + streamProxyService.updateStatus(param.isRegist(), param.getApp(), param.getStream()); | |
| 326 | + } | |
| 327 | + if ("rtp".equals(param.getApp()) && !param.isRegist() ) { | |
| 328 | + StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(param.getStream()); | |
| 329 | + if (streamInfo!=null){ | |
| 330 | + redisCatchStorage.stopPlay(streamInfo); | |
| 331 | + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | |
| 332 | + }else{ | |
| 333 | + streamInfo = redisCatchStorage.queryPlayback(null, null, param.getStream(), null); | |
| 334 | + if (streamInfo != null) { | |
| 335 | + redisCatchStorage.stopPlayback(streamInfo.getDeviceID(), streamInfo.getChannelId(), | |
| 336 | + streamInfo.getStream(), null); | |
| 337 | + } | |
| 338 | + } | |
| 339 | + }else { | |
| 340 | + if (!"rtp".equals(param.getApp())){ | |
| 341 | + String type = OriginType.values()[param.getOriginType()].getType(); | |
| 342 | + MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); | |
| 343 | + | |
| 344 | + if (mediaServerItem != null){ | |
| 345 | + if (param.isRegist()) { | |
| 346 | + StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); | |
| 347 | + String callId = null; | |
| 348 | + if (streamAuthorityInfo != null) { | |
| 349 | + callId = streamAuthorityInfo.getCallId(); | |
| 350 | + } | |
| 351 | + StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem, | |
| 352 | + param.getApp(), param.getStream(), tracks, callId); | |
| 353 | + param.setStreamInfo(streamInfoByAppAndStream); | |
| 354 | + redisCatchStorage.addStream(mediaServerItem, type, param.getApp(), param.getStream(), param); | |
| 355 | + if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal() | |
| 356 | + || param.getOriginType() == OriginType.RTMP_PUSH.ordinal() | |
| 357 | + || param.getOriginType() == OriginType.RTC_PUSH.ordinal() ) { | |
| 358 | + param.setSeverId(userSetting.getServerId()); | |
| 359 | + zlmMediaListManager.addPush(param); | |
| 360 | + } | |
| 361 | + }else { | |
| 362 | + // 兼容流注销时类型从redis记录获取 | |
| 363 | + OnStreamChangedHookParam onStreamChangedHookParam = redisCatchStorage.getStreamInfo(param.getApp(), param.getStream(), param.getMediaServerId()); | |
| 364 | + if (onStreamChangedHookParam != null) { | |
| 365 | + type = OriginType.values()[onStreamChangedHookParam.getOriginType()].getType(); | |
| 366 | + redisCatchStorage.removeStream(mediaServerItem.getId(), type, param.getApp(), param.getStream()); | |
| 367 | + } | |
| 368 | + GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream()); | |
| 369 | + if (gbStream != null) { | |
| 500 | 370 | // eventPublisher.catalogEventPublishForStream(null, gbStream, CatalogEvent.OFF); |
| 371 | + } | |
| 372 | + zlmMediaListManager.removeMedia(param.getApp(), param.getStream()); | |
| 373 | + } | |
| 374 | + if (type != null) { | |
| 375 | + // 发送流变化redis消息 | |
| 376 | + JSONObject jsonObject = new JSONObject(); | |
| 377 | + jsonObject.put("serverId", userSetting.getServerId()); | |
| 378 | + jsonObject.put("app", param.getApp()); | |
| 379 | + jsonObject.put("stream", param.getStream()); | |
| 380 | + jsonObject.put("register", param.isRegist()); | |
| 381 | + jsonObject.put("mediaServerId", param.getMediaServerId()); | |
| 382 | + redisCatchStorage.sendStreamChangeMsg(type, jsonObject); | |
| 501 | 383 | } |
| 502 | - zlmMediaListManager.removeMedia(app, stream); | |
| 503 | - } | |
| 504 | - if (type != null) { | |
| 505 | - // 发送流变化redis消息 | |
| 506 | - JSONObject jsonObject = new JSONObject(); | |
| 507 | - jsonObject.put("serverId", userSetting.getServerId()); | |
| 508 | - jsonObject.put("app", app); | |
| 509 | - jsonObject.put("stream", stream); | |
| 510 | - jsonObject.put("register", regist); | |
| 511 | - jsonObject.put("mediaServerId", mediaServerId); | |
| 512 | - redisCatchStorage.sendStreamChangeMsg(type, jsonObject); | |
| 513 | 384 | } |
| 514 | 385 | } |
| 515 | 386 | } |
| 516 | - } | |
| 517 | - if (!regist) { | |
| 518 | - List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(stream); | |
| 519 | - if (sendRtpItems.size() > 0) { | |
| 520 | - for (SendRtpItem sendRtpItem : sendRtpItems) { | |
| 521 | - if (sendRtpItem.getApp().equals(app)) { | |
| 522 | - String platformId = sendRtpItem.getPlatformId(); | |
| 523 | - ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); | |
| 524 | - Device device = deviceService.getDevice(platformId); | |
| 525 | - | |
| 526 | - try { | |
| 527 | - if (platform != null) { | |
| 528 | - commanderFroPlatform.streamByeCmd(platform, sendRtpItem); | |
| 529 | - }else { | |
| 530 | - cmder.streamByeCmd(device, sendRtpItem.getChannelId(), stream, sendRtpItem.getCallId()); | |
| 387 | + if (!param.isRegist()) { | |
| 388 | + List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(param.getStream()); | |
| 389 | + if (sendRtpItems.size() > 0) { | |
| 390 | + for (SendRtpItem sendRtpItem : sendRtpItems) { | |
| 391 | + if (sendRtpItem.getApp().equals(param.getApp())) { | |
| 392 | + String platformId = sendRtpItem.getPlatformId(); | |
| 393 | + ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); | |
| 394 | + Device device = deviceService.getDevice(platformId); | |
| 395 | + | |
| 396 | + try { | |
| 397 | + if (platform != null) { | |
| 398 | + commanderFroPlatform.streamByeCmd(platform, sendRtpItem); | |
| 399 | + }else { | |
| 400 | + cmder.streamByeCmd(device, sendRtpItem.getChannelId(), param.getStream(), sendRtpItem.getCallId()); | |
| 401 | + } | |
| 402 | + } catch (SipException | InvalidArgumentException | ParseException | SsrcTransactionNotFoundException e) { | |
| 403 | + logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); | |
| 531 | 404 | } |
| 532 | - } catch (SipException | InvalidArgumentException | ParseException | SsrcTransactionNotFoundException e) { | |
| 533 | - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); | |
| 534 | 405 | } |
| 535 | 406 | } |
| 536 | 407 | } |
| 537 | 408 | } |
| 538 | 409 | } |
| 539 | - } | |
| 410 | + }); | |
| 540 | 411 | |
| 541 | 412 | JSONObject ret = new JSONObject(); |
| 542 | 413 | ret.put("code", 0); |
| ... | ... | @@ -550,19 +421,16 @@ public class ZLMHttpHookListener { |
| 550 | 421 | */ |
| 551 | 422 | @ResponseBody |
| 552 | 423 | @PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8") |
| 553 | - public JSONObject onStreamNoneReader(@RequestBody JSONObject json){ | |
| 424 | + public JSONObject onStreamNoneReader(@RequestBody OnStreamNoneReaderHookParam param){ | |
| 554 | 425 | |
| 555 | - logger.info("[ ZLM HOOK ]on_stream_none_reader API调用,参数:" + json.toString()); | |
| 556 | - String mediaServerId = json.getString("mediaServerId"); | |
| 557 | - String streamId = json.getString("stream"); | |
| 558 | - String app = json.getString("app"); | |
| 426 | + logger.info("[ZLM HOOK]流无人观看:{]->{}->{}/{}" + param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); | |
| 559 | 427 | JSONObject ret = new JSONObject(); |
| 560 | 428 | ret.put("code", 0); |
| 561 | 429 | // 录像下载 |
| 562 | - ret.put("close", userSetting.getStreamOnDemand()); | |
| 563 | - if ("rtp".equals(app)){ | |
| 430 | + if ("rtp".equals(param.getApp())){ | |
| 431 | + ret.put("close", userSetting.getStreamOnDemand()); | |
| 564 | 432 | // 国标流, 点播/录像回放/录像下载 |
| 565 | - StreamInfo streamInfoForPlayCatch = redisCatchStorage.queryPlayByStreamId(streamId); | |
| 433 | + StreamInfo streamInfoForPlayCatch = redisCatchStorage.queryPlayByStreamId(param.getStream()); | |
| 566 | 434 | // 点播 |
| 567 | 435 | if (streamInfoForPlayCatch != null) { |
| 568 | 436 | // 收到无人观看说明流也没有在往上级推送 |
| ... | ... | @@ -596,7 +464,7 @@ public class ZLMHttpHookListener { |
| 596 | 464 | return ret; |
| 597 | 465 | } |
| 598 | 466 | // 录像回放 |
| 599 | - StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null); | |
| 467 | + StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, param.getStream(), null); | |
| 600 | 468 | if (streamInfoForPlayBackCatch != null ) { |
| 601 | 469 | if (streamInfoForPlayBackCatch.isPause()) { |
| 602 | 470 | ret.put("close", false); |
| ... | ... | @@ -617,7 +485,7 @@ public class ZLMHttpHookListener { |
| 617 | 485 | return ret; |
| 618 | 486 | } |
| 619 | 487 | // 录像下载 |
| 620 | - StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, streamId, null); | |
| 488 | + StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, param.getStream(), null); | |
| 621 | 489 | // 进行录像下载时无人观看不断流 |
| 622 | 490 | if (streamInfoForDownload != null) { |
| 623 | 491 | ret.put("close", false); |
| ... | ... | @@ -626,19 +494,19 @@ public class ZLMHttpHookListener { |
| 626 | 494 | }else { |
| 627 | 495 | // 非国标流 推流/拉流代理 |
| 628 | 496 | // 拉流代理 |
| 629 | - StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(app, streamId); | |
| 497 | + StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); | |
| 630 | 498 | if (streamProxyItem != null ) { |
| 631 | 499 | if (streamProxyItem.isEnable_remove_none_reader()) { |
| 632 | 500 | // 无人观看自动移除 |
| 633 | 501 | ret.put("close", true); |
| 634 | - streamProxyService.del(app, streamId); | |
| 502 | + streamProxyService.del(param.getApp(), param.getStream()); | |
| 635 | 503 | String url = streamProxyItem.getUrl() != null?streamProxyItem.getUrl():streamProxyItem.getSrc_url(); |
| 636 | - logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", app, streamId, url); | |
| 504 | + logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", param.getApp(), param.getStream(), url); | |
| 637 | 505 | }else if (streamProxyItem.isEnable_disable_none_reader()) { |
| 638 | 506 | // 无人观看停用 |
| 639 | 507 | ret.put("close", true); |
| 640 | 508 | // 修改数据 |
| 641 | - streamProxyService.stop(app, streamId); | |
| 509 | + streamProxyService.stop(param.getApp(), param.getStream()); | |
| 642 | 510 | }else { |
| 643 | 511 | ret.put("close", false); |
| 644 | 512 | } |
| ... | ... | @@ -660,35 +528,33 @@ public class ZLMHttpHookListener { |
| 660 | 528 | */ |
| 661 | 529 | @ResponseBody |
| 662 | 530 | @PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8") |
| 663 | - public JSONObject onStreamNotFound(@RequestBody JSONObject json){ | |
| 664 | - if (logger.isDebugEnabled()) { | |
| 665 | - logger.debug("[ ZLM HOOK ]on_stream_not_found API调用,参数:" + json.toString()); | |
| 666 | - } | |
| 667 | - String mediaServerId = json.getString("mediaServerId"); | |
| 668 | - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); | |
| 669 | - if (userSetting.isAutoApplyPlay() && mediaInfo != null) { | |
| 670 | - String app = json.getString("app"); | |
| 671 | - String streamId = json.getString("stream"); | |
| 672 | - if ("rtp".equals(app)) { | |
| 673 | - if (mediaInfo.isRtpEnable()) { | |
| 674 | - String[] s = streamId.split("_"); | |
| 675 | - if (s.length == 2) { | |
| 676 | - String deviceId = s[0]; | |
| 677 | - String channelId = s[1]; | |
| 678 | - Device device = redisCatchStorage.getDevice(deviceId); | |
| 679 | - if (device != null) { | |
| 680 | - playService.play(mediaInfo,deviceId, channelId, null, null, null); | |
| 531 | + public JSONObject onStreamNotFound(@RequestBody OnStreamNotFoundHookParam param){ | |
| 532 | + logger.info("[ZLM HOOK] 流未找到:{}->{}->{}/{}" + param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); | |
| 533 | + taskExecutor.execute(()->{ | |
| 534 | + MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); | |
| 535 | + if (userSetting.isAutoApplyPlay() && mediaInfo != null) { | |
| 536 | + if ("rtp".equals(param.getApp())) { | |
| 537 | + if (mediaInfo.isRtpEnable()) { | |
| 538 | + String[] s = param.getStream().split("_"); | |
| 539 | + if (s.length == 2) { | |
| 540 | + String deviceId = s[0]; | |
| 541 | + String channelId = s[1]; | |
| 542 | + Device device = redisCatchStorage.getDevice(deviceId); | |
| 543 | + if (device != null) { | |
| 544 | + playService.play(mediaInfo,deviceId, channelId, null, null, null); | |
| 545 | + } | |
| 681 | 546 | } |
| 682 | 547 | } |
| 683 | - } | |
| 684 | - }else { | |
| 685 | - // 拉流代理 | |
| 686 | - StreamProxyItem streamProxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(app, streamId); | |
| 687 | - if (streamProxyByAppAndStream != null && streamProxyByAppAndStream.isEnable_disable_none_reader()) { | |
| 688 | - streamProxyService.start(app, streamId); | |
| 548 | + }else { | |
| 549 | + // 拉流代理 | |
| 550 | + StreamProxyItem streamProxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); | |
| 551 | + if (streamProxyByAppAndStream != null && streamProxyByAppAndStream.isEnable_disable_none_reader()) { | |
| 552 | + streamProxyService.start(param.getApp(), param.getStream()); | |
| 553 | + } | |
| 689 | 554 | } |
| 690 | 555 | } |
| 691 | - } | |
| 556 | + }); | |
| 557 | + | |
| 692 | 558 | |
| 693 | 559 | JSONObject ret = new JSONObject(); |
| 694 | 560 | ret.put("code", 0); |
| ... | ... | @@ -704,22 +570,20 @@ public class ZLMHttpHookListener { |
| 704 | 570 | @PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8") |
| 705 | 571 | public JSONObject onServerStarted(HttpServletRequest request, @RequestBody JSONObject jsonObject){ |
| 706 | 572 | |
| 707 | - if (logger.isDebugEnabled()) { | |
| 708 | - logger.debug("[ ZLM HOOK ]on_server_started API调用,参数:" + jsonObject.toString()); | |
| 709 | - } | |
| 710 | - String remoteAddr = request.getRemoteAddr(); | |
| 711 | - jsonObject.put("ip", remoteAddr); | |
| 712 | - List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started); | |
| 713 | - if (subscribes != null && subscribes.size() > 0) { | |
| 714 | - for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { | |
| 715 | - subscribe.response(null, jsonObject); | |
| 573 | + jsonObject.put("ip", request.getRemoteAddr()); | |
| 574 | + ZLMServerConfig zlmServerConfig = JSON.to(ZLMServerConfig.class, jsonObject); | |
| 575 | + zlmServerConfig.setIp(request.getRemoteAddr()); | |
| 576 | + logger.info("[ZLM HOOK] zlm 启动 " + zlmServerConfig.getGeneralMediaServerId()); | |
| 577 | + taskExecutor.execute(()->{ | |
| 578 | + List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started); | |
| 579 | + if (subscribes != null && subscribes.size() > 0) { | |
| 580 | + for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { | |
| 581 | + subscribe.response(null, jsonObject); | |
| 582 | + } | |
| 716 | 583 | } |
| 717 | - } | |
| 718 | - | |
| 719 | - ZLMServerConfig zlmServerConfig = JSONObject.toJavaObject(jsonObject, ZLMServerConfig.class); | |
| 720 | - if (zlmServerConfig !=null ) { | |
| 721 | 584 | mediaServerService.zlmServerOnline(zlmServerConfig); |
| 722 | - } | |
| 585 | + }); | |
| 586 | + | |
| 723 | 587 | JSONObject ret = new JSONObject(); |
| 724 | 588 | ret.put("code", 0); |
| 725 | 589 | ret.put("msg", "success"); |
| ... | ... | @@ -731,33 +595,33 @@ public class ZLMHttpHookListener { |
| 731 | 595 | */ |
| 732 | 596 | @ResponseBody |
| 733 | 597 | @PostMapping(value = "/on_send_rtp_stopped", produces = "application/json;charset=UTF-8") |
| 734 | - public JSONObject onSendRtpStopped(HttpServletRequest request, @RequestBody JSONObject jsonObject){ | |
| 598 | + public JSONObject onSendRtpStopped(HttpServletRequest request, @RequestBody OnSendRtpStoppedHookParam param){ | |
| 735 | 599 | |
| 736 | - logger.info("[ ZLM HOOK ]on_send_rtp_stopped API调用,参数:" + jsonObject); | |
| 600 | + logger.info("[ZLM HOOK] 发送rtp被动关闭:{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream()); | |
| 737 | 601 | |
| 738 | 602 | JSONObject ret = new JSONObject(); |
| 739 | 603 | ret.put("code", 0); |
| 740 | 604 | ret.put("msg", "success"); |
| 741 | 605 | |
| 742 | 606 | // 查找对应的上级推流,发送停止 |
| 743 | - String app = jsonObject.getString("app"); | |
| 744 | - if (!"rtp".equals(app)) { | |
| 607 | + if (!"rtp".equals(param.getApp())) { | |
| 745 | 608 | return ret; |
| 746 | 609 | } |
| 747 | - String stream = jsonObject.getString("stream"); | |
| 748 | - List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(stream); | |
| 749 | - if (sendRtpItems.size() > 0) { | |
| 750 | - for (SendRtpItem sendRtpItem : sendRtpItems) { | |
| 751 | - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); | |
| 752 | - try { | |
| 753 | - commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId()); | |
| 754 | - } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 755 | - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); | |
| 610 | + taskExecutor.execute(()->{ | |
| 611 | + List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(param.getStream()); | |
| 612 | + if (sendRtpItems.size() > 0) { | |
| 613 | + for (SendRtpItem sendRtpItem : sendRtpItems) { | |
| 614 | + ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); | |
| 615 | + try { | |
| 616 | + commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId()); | |
| 617 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 618 | + logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); | |
| 619 | + } | |
| 620 | + redisCatchStorage.deleteSendRTPServer(parentPlatform.getServerGBId(), sendRtpItem.getChannelId(), | |
| 621 | + sendRtpItem.getCallId(), sendRtpItem.getStreamId()); | |
| 756 | 622 | } |
| 757 | - redisCatchStorage.deleteSendRTPServer(parentPlatform.getServerGBId(), sendRtpItem.getChannelId(), | |
| 758 | - sendRtpItem.getCallId(), sendRtpItem.getStreamId()); | |
| 759 | 623 | } |
| 760 | - } | |
| 624 | + }); | |
| 761 | 625 | |
| 762 | 626 | |
| 763 | 627 | return ret; | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
| ... | ... | @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.media.zlm; |
| 3 | 3 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| 6 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | |
| 6 | 7 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 7 | 8 | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| 8 | 9 | import com.genersoft.iot.vmp.service.IStreamPushService; |
| ... | ... | @@ -67,19 +68,19 @@ public class ZLMMediaListManager { |
| 67 | 68 | |
| 68 | 69 | private Map<String, ChannelOnlineEvent> channelOnPublishEvents = new ConcurrentHashMap<>(); |
| 69 | 70 | |
| 70 | - public StreamPushItem addPush(MediaItem mediaItem) { | |
| 71 | - StreamPushItem transform = streamPushService.transform(mediaItem); | |
| 72 | - StreamPushItem pushInDb = streamPushService.getPush(mediaItem.getApp(), mediaItem.getStream()); | |
| 73 | - transform.setPushIng(mediaItem.isRegist()); | |
| 71 | + public StreamPushItem addPush(OnStreamChangedHookParam onStreamChangedHookParam) { | |
| 72 | + StreamPushItem transform = streamPushService.transform(onStreamChangedHookParam); | |
| 73 | + StreamPushItem pushInDb = streamPushService.getPush(onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream()); | |
| 74 | + transform.setPushIng(onStreamChangedHookParam.isRegist()); | |
| 74 | 75 | transform.setUpdateTime(DateUtil.getNow()); |
| 75 | 76 | transform.setPushTime(DateUtil.getNow()); |
| 76 | - transform.setSelf(userSetting.getServerId().equals(mediaItem.getSeverId())); | |
| 77 | + transform.setSelf(userSetting.getServerId().equals(onStreamChangedHookParam.getSeverId())); | |
| 77 | 78 | if (pushInDb == null) { |
| 78 | 79 | transform.setCreateTime(DateUtil.getNow()); |
| 79 | 80 | streamPushMapper.add(transform); |
| 80 | 81 | }else { |
| 81 | 82 | streamPushMapper.update(transform); |
| 82 | - gbStreamMapper.updateMediaServer(mediaItem.getApp(), mediaItem.getStream(), mediaItem.getMediaServerId()); | |
| 83 | + gbStreamMapper.updateMediaServer(onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream(), onStreamChangedHookParam.getMediaServerId()); | |
| 83 | 84 | } |
| 84 | 85 | ChannelOnlineEvent channelOnlineEventLister = getChannelOnlineEventLister(transform.getApp(), transform.getStream()); |
| 85 | 86 | if ( channelOnlineEventLister != null) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| 1 | 1 | package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 6 | 6 | import okhttp3.*; |
| 7 | 7 | import okhttp3.logging.HttpLoggingInterceptor; | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
| 1 | 1 | package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONArray; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONArray; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 7 | 7 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| ... | ... | @@ -333,7 +333,7 @@ public class ZLMRTPServerFactory { |
| 333 | 333 | result= true; |
| 334 | 334 | logger.info("[停止RTP推流] 成功"); |
| 335 | 335 | } else { |
| 336 | - logger.error("[停止RTP推流] 失败: {}, 参数:{}->\r\n{}",jsonObject.getString("msg"),JSONObject.toJSON(param), jsonObject); | |
| 336 | + logger.error("[停止RTP推流] 失败: {}, 参数:{}->\r\n{}",jsonObject.getString("msg"),jsonObject.toJSONString(param)); | |
| 337 | 337 | } |
| 338 | 338 | return result; |
| 339 | 339 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| 1 | 1 | package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONArray; | |
| 5 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONArray; | |
| 5 | +import com.alibaba.fastjson2.JSONObject; | |
| 6 | 6 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 7 | 7 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 8 | 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| ... | ... | @@ -62,7 +62,7 @@ public class ZLMRunner implements CommandLineRunner { |
| 62 | 62 | // 订阅 zlm启动事件, 新的zlm也会从这里进入系统 |
| 63 | 63 | hookSubscribe.addSubscribe(hookSubscribeForServerStarted, |
| 64 | 64 | (MediaServerItem mediaServerItem, JSONObject response)->{ |
| 65 | - ZLMServerConfig zlmServerConfig = JSONObject.toJavaObject(response, ZLMServerConfig.class); | |
| 65 | + ZLMServerConfig zlmServerConfig = response.to(ZLMServerConfig.class); | |
| 66 | 66 | if (zlmServerConfig !=null ) { |
| 67 | 67 | if (startGetMedia != null) { |
| 68 | 68 | startGetMedia.remove(zlmServerConfig.getGeneralMediaServerId()); | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java
src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java
| 1 | 1 | package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.media.zlm.dto.HookType; |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; |
| 6 | 6 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java
| 1 | 1 | package com.genersoft.iot.vmp.media.zlm.dto; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * hook 订阅工厂 |
| ... | ... | @@ -11,7 +11,7 @@ public class HookSubscribeFactory { |
| 11 | 11 | |
| 12 | 12 | public static HookSubscribeForStreamChange on_stream_changed(String app, String stream, boolean regist, String scheam, String mediaServerId) { |
| 13 | 13 | HookSubscribeForStreamChange hookSubscribe = new HookSubscribeForStreamChange(); |
| 14 | - JSONObject subscribeKey = new com.alibaba.fastjson.JSONObject(); | |
| 14 | + JSONObject subscribeKey = new com.alibaba.fastjson2.JSONObject(); | |
| 15 | 15 | subscribeKey.put("app", app); |
| 16 | 16 | subscribeKey.put("stream", stream); |
| 17 | 17 | subscribeKey.put("regist", regist); | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForServerStarted.java
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamChange.java
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/IHookSubscribe.java
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ServerKeepaliveData.java
0 → 100644
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamAuthorityInfo.java
| 1 | 1 | package com.genersoft.iot.vmp.media.zlm.dto; |
| 2 | 2 | |
| 3 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnPublishHookParam; | |
| 4 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | |
| 5 | + | |
| 3 | 6 | /** |
| 4 | 7 | * 流的鉴权信息 |
| 5 | 8 | * @author lin |
| ... | ... | @@ -102,13 +105,13 @@ public class StreamAuthorityInfo { |
| 102 | 105 | return streamAuthorityInfo; |
| 103 | 106 | } |
| 104 | 107 | |
| 105 | - public static StreamAuthorityInfo getInstanceByHook(MediaItem mediaItem) { | |
| 108 | + public static StreamAuthorityInfo getInstanceByHook(OnStreamChangedHookParam onStreamChangedHookParam) { | |
| 106 | 109 | StreamAuthorityInfo streamAuthorityInfo = new StreamAuthorityInfo(); |
| 107 | - streamAuthorityInfo.setApp(mediaItem.getApp()); | |
| 108 | - streamAuthorityInfo.setStream(mediaItem.getStream()); | |
| 109 | - streamAuthorityInfo.setId(mediaItem.getMediaServerId()); | |
| 110 | - streamAuthorityInfo.setOriginType(mediaItem.getOriginType()); | |
| 111 | - streamAuthorityInfo.setOriginTypeStr(mediaItem.getOriginTypeStr()); | |
| 110 | + streamAuthorityInfo.setApp(onStreamChangedHookParam.getApp()); | |
| 111 | + streamAuthorityInfo.setStream(onStreamChangedHookParam.getStream()); | |
| 112 | + streamAuthorityInfo.setId(onStreamChangedHookParam.getMediaServerId()); | |
| 113 | + streamAuthorityInfo.setOriginType(onStreamChangedHookParam.getOriginType()); | |
| 114 | + streamAuthorityInfo.setOriginTypeStr(onStreamChangedHookParam.getOriginTypeStr()); | |
| 112 | 115 | return streamAuthorityInfo; |
| 113 | 116 | } |
| 114 | 117 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java
| 1 | 1 | package com.genersoft.iot.vmp.media.zlm.dto; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 4 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | |
| 4 | 5 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 5 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 7 | import org.jetbrains.annotations.NotNull; |
| 7 | -import org.springframework.util.unit.DataUnit; | |
| 8 | 8 | |
| 9 | 9 | import java.util.List; |
| 10 | 10 | |
| ... | ... | @@ -59,7 +59,7 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte |
| 59 | 59 | * 客户端和服务器网络信息,可能为null类型 |
| 60 | 60 | */ |
| 61 | 61 | @Schema(description = "客户端和服务器网络信息,可能为null类型") |
| 62 | - private MediaItem.OriginSock originSock; | |
| 62 | + private OnStreamChangedHookParam.OriginSock originSock; | |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * 产生源类型的字符串描述 |
| ... | ... | @@ -83,7 +83,7 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte |
| 83 | 83 | * 音视频轨道 |
| 84 | 84 | */ |
| 85 | 85 | @Schema(description = "音视频轨道") |
| 86 | - private List<MediaItem.MediaTrack> tracks; | |
| 86 | + private List<OnStreamChangedHookParam.MediaTrack> tracks; | |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * 音视频轨道 |
| ... | ... | @@ -223,11 +223,11 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte |
| 223 | 223 | this.originType = originType; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public MediaItem.OriginSock getOriginSock() { | |
| 226 | + public OnStreamChangedHookParam.OriginSock getOriginSock() { | |
| 227 | 227 | return originSock; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - public void setOriginSock(MediaItem.OriginSock originSock) { | |
| 230 | + public void setOriginSock(OnStreamChangedHookParam.OriginSock originSock) { | |
| 231 | 231 | this.originSock = originSock; |
| 232 | 232 | } |
| 233 | 233 | |
| ... | ... | @@ -256,11 +256,11 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte |
| 256 | 256 | this.aliveSecond = aliveSecond; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - public List<MediaItem.MediaTrack> getTracks() { | |
| 259 | + public List<OnStreamChangedHookParam.MediaTrack> getTracks() { | |
| 260 | 260 | return tracks; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - public void setTracks(List<MediaItem.MediaTrack> tracks) { | |
| 263 | + public void setTracks(List<OnStreamChangedHookParam.MediaTrack> tracks) { | |
| 264 | 264 | this.tracks = tracks; |
| 265 | 265 | } |
| 266 | 266 | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookParam.java renamed to src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookParam.java
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/OnPlayHookParam.java renamed to src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPlayHookParam.java
| 1 | -package com.genersoft.iot.vmp.media.zlm.dto; | |
| 1 | +package com.genersoft.iot.vmp.media.zlm.dto.hook; | |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * zlm hook事件中的on_play事件的参数 |
| ... | ... | @@ -79,4 +79,8 @@ public class OnPlayHookParam extends HookParam{ |
| 79 | 79 | this.vhost = vhost; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | + @Override | |
| 83 | + public String toString() { | |
| 84 | + return String.format("%s://%s:%s/%s/%s?%s", schema, ip, port, app, stream, params); | |
| 85 | + } | |
| 82 | 86 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/OnPublishHookParam.java renamed to src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPublishHookParam.java
| 1 | -package com.genersoft.iot.vmp.media.zlm.dto; | |
| 1 | +package com.genersoft.iot.vmp.media.zlm.dto.hook; | |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * zlm hook事件中的on_publish事件的参数 |
| ... | ... | @@ -79,4 +79,8 @@ public class OnPublishHookParam extends HookParam{ |
| 79 | 79 | this.vhost = vhost; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | + @Override | |
| 83 | + public String toString() { | |
| 84 | + return String.format("%s://%s:%s/%s/%s?%s", schema, ip, port, app, stream, params); | |
| 85 | + } | |
| 82 | 86 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnSendRtpStoppedHookParam.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.media.zlm.dto.hook; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * zlm hook事件中的on_send_rtp_stopped事件的参数 | |
| 5 | + * @author lin | |
| 6 | + */ | |
| 7 | +public class OnSendRtpStoppedHookParam extends HookParam{ | |
| 8 | + private String app; | |
| 9 | + private String stream; | |
| 10 | + | |
| 11 | + | |
| 12 | + public String getApp() { | |
| 13 | + return app; | |
| 14 | + } | |
| 15 | + | |
| 16 | + public void setApp(String app) { | |
| 17 | + this.app = app; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public String getStream() { | |
| 21 | + return stream; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public void setStream(String stream) { | |
| 25 | + this.stream = stream; | |
| 26 | + } | |
| 27 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnServerKeepaliveHookParam.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.media.zlm.dto.hook; | |
| 2 | + | |
| 3 | +import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * zlm hook事件中的on_play事件的参数 | |
| 7 | + * @author lin | |
| 8 | + */ | |
| 9 | +public class OnServerKeepaliveHookParam extends HookParam{ | |
| 10 | + | |
| 11 | + private ServerKeepaliveData data; | |
| 12 | + | |
| 13 | + public ServerKeepaliveData getData() { | |
| 14 | + return data; | |
| 15 | + } | |
| 16 | + | |
| 17 | + public void setData(ServerKeepaliveData data) { | |
| 18 | + this.data = data; | |
| 19 | + } | |
| 20 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaItem.java renamed to src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamChangedHookParam.java
| 1 | -package com.genersoft.iot.vmp.media.zlm.dto; | |
| 1 | +package com.genersoft.iot.vmp.media.zlm.dto.hook; | |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 4 | 4 | |
| ... | ... | @@ -7,7 +7,7 @@ import java.util.List; |
| 7 | 7 | /** |
| 8 | 8 | * @author lin |
| 9 | 9 | */ |
| 10 | -public class MediaItem { | |
| 10 | +public class OnStreamChangedHookParam extends HookParam{ | |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * 注册/注销 |
| ... | ... | @@ -69,11 +69,6 @@ public class MediaItem { |
| 69 | 69 | private String originUrl; |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * 流媒体服务器id | |
| 73 | - */ | |
| 74 | - private String mediaServerId; | |
| 75 | - | |
| 76 | - /** | |
| 77 | 72 | * 服务器id |
| 78 | 73 | */ |
| 79 | 74 | private String severId; |
| ... | ... | @@ -412,14 +407,6 @@ public class MediaItem { |
| 412 | 407 | this.docker = docker; |
| 413 | 408 | } |
| 414 | 409 | |
| 415 | - public String getMediaServerId() { | |
| 416 | - return mediaServerId; | |
| 417 | - } | |
| 418 | - | |
| 419 | - public void setMediaServerId(String mediaServerId) { | |
| 420 | - this.mediaServerId = mediaServerId; | |
| 421 | - } | |
| 422 | - | |
| 423 | 410 | public StreamInfo getStreamInfo() { |
| 424 | 411 | return streamInfo; |
| 425 | 412 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNoneReaderHookParam.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.media.zlm.dto.hook; | |
| 2 | + | |
| 3 | +public class OnStreamNoneReaderHookParam extends HookParam{ | |
| 4 | + | |
| 5 | + private String schema; | |
| 6 | + private String app; | |
| 7 | + private String stream; | |
| 8 | + private String vhost; | |
| 9 | + | |
| 10 | + public String getSchema() { | |
| 11 | + return schema; | |
| 12 | + } | |
| 13 | + | |
| 14 | + public void setSchema(String schema) { | |
| 15 | + this.schema = schema; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public String getApp() { | |
| 19 | + return app; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void setApp(String app) { | |
| 23 | + this.app = app; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public String getStream() { | |
| 27 | + return stream; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public void setStream(String stream) { | |
| 31 | + this.stream = stream; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public String getVhost() { | |
| 35 | + return vhost; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public void setVhost(String vhost) { | |
| 39 | + this.vhost = vhost; | |
| 40 | + } | |
| 41 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNotFoundHookParam.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.media.zlm.dto.hook; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * zlm hook事件中的on_stream_not_found事件的参数 | |
| 5 | + * @author lin | |
| 6 | + */ | |
| 7 | +public class OnStreamNotFoundHookParam extends HookParam{ | |
| 8 | + private String id; | |
| 9 | + private String app; | |
| 10 | + private String stream; | |
| 11 | + private String ip; | |
| 12 | + private String params; | |
| 13 | + private int port; | |
| 14 | + private String schema; | |
| 15 | + private String vhost; | |
| 16 | + | |
| 17 | + | |
| 18 | + public String getId() { | |
| 19 | + return id; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void setId(String id) { | |
| 23 | + this.id = id; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public String getApp() { | |
| 27 | + return app; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public void setApp(String app) { | |
| 31 | + this.app = app; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public String getStream() { | |
| 35 | + return stream; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public void setStream(String stream) { | |
| 39 | + this.stream = stream; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public String getIp() { | |
| 43 | + return ip; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public void setIp(String ip) { | |
| 47 | + this.ip = ip; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public String getParams() { | |
| 51 | + return params; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public void setParams(String params) { | |
| 55 | + this.params = params; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public int getPort() { | |
| 59 | + return port; | |
| 60 | + } | |
| 61 | + | |
| 62 | + public void setPort(int port) { | |
| 63 | + this.port = port; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public String getSchema() { | |
| 67 | + return schema; | |
| 68 | + } | |
| 69 | + | |
| 70 | + public void setSchema(String schema) { | |
| 71 | + this.schema = schema; | |
| 72 | + } | |
| 73 | + | |
| 74 | + public String getVhost() { | |
| 75 | + return vhost; | |
| 76 | + } | |
| 77 | + | |
| 78 | + public void setVhost(String vhost) { | |
| 79 | + this.vhost = vhost; | |
| 80 | + } | |
| 81 | + | |
| 82 | + @Override | |
| 83 | + public String toString() { | |
| 84 | + return String.format("%s://%s:%s/%s/%s?%s", schema, ip, port, app, stream, params); | |
| 85 | + } | |
| 86 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/OriginType.java renamed to src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OriginType.java
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
| 1 | 1 | package com.genersoft.iot.vmp.service; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| 6 | 6 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 7 | +import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; | |
| 7 | 8 | import com.genersoft.iot.vmp.service.bean.MediaServerLoad; |
| 8 | 9 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 9 | 10 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| ... | ... | @@ -86,7 +87,7 @@ public interface IMediaServerService { |
| 86 | 87 | |
| 87 | 88 | MediaServerItem getDefaultMediaServer(); |
| 88 | 89 | |
| 89 | - void updateMediaServerKeepalive(String mediaServerId, JSONObject data); | |
| 90 | + void updateMediaServerKeepalive(String mediaServerId, ServerKeepaliveData data); | |
| 90 | 91 | |
| 91 | 92 | boolean checkRtpServer(MediaServerItem mediaServerItem, String rtp, String stream); |
| 92 | 93 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
| 1 | 1 | package com.genersoft.iot.vmp.service; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.exception.ServiceException; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.Device; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
| 1 | 1 | package com.genersoft.iot.vmp.service; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 6 | 6 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
| 1 | 1 | package com.genersoft.iot.vmp.service; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 4 | -import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; | |
| 5 | -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | |
| 4 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | |
| 6 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 7 | 6 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 8 | 7 | import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; |
| 9 | 8 | import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; |
| 10 | -import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; | |
| 11 | 9 | import com.github.pagehelper.PageInfo; |
| 12 | 10 | |
| 13 | 11 | import java.util.List; |
| ... | ... | @@ -38,7 +36,7 @@ public interface IStreamPushService { |
| 38 | 36 | |
| 39 | 37 | List<StreamPushItem> getPushList(String mediaSererId); |
| 40 | 38 | |
| 41 | - StreamPushItem transform(MediaItem item); | |
| 39 | + StreamPushItem transform(OnStreamChangedHookParam item); | |
| 42 | 40 | |
| 43 | 41 | StreamPushItem getPush(String app, String streamId); |
| 44 | 42 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackResult.java
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| ... | ... | @@ -10,6 +10,7 @@ import java.util.Set; |
| 10 | 10 | |
| 11 | 11 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 12 | 12 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 13 | +import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; | |
| 13 | 14 | import com.genersoft.iot.vmp.service.bean.MediaServerLoad; |
| 14 | 15 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 15 | 16 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| ... | ... | @@ -23,9 +24,9 @@ import org.springframework.transaction.TransactionDefinition; |
| 23 | 24 | import org.springframework.transaction.TransactionStatus; |
| 24 | 25 | import org.springframework.util.ObjectUtils; |
| 25 | 26 | |
| 26 | -import com.alibaba.fastjson.JSON; | |
| 27 | -import com.alibaba.fastjson.JSONArray; | |
| 28 | -import com.alibaba.fastjson.JSONObject; | |
| 27 | +import com.alibaba.fastjson2.JSON; | |
| 28 | +import com.alibaba.fastjson2.JSONArray; | |
| 29 | +import com.alibaba.fastjson2.JSONObject; | |
| 29 | 30 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 30 | 31 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 31 | 32 | import com.genersoft.iot.vmp.conf.UserSetting; |
| ... | ... | @@ -434,7 +435,7 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 434 | 435 | if (mediaServerConfig != null && mediaServerConfig.getInteger("code") == 0) { |
| 435 | 436 | logger.info("[zlm心跳到期]:{}验证后zlm仍在线,恢复心跳信息,请检查zlm是否可以正常向wvp发送心跳", serverItem.getId()); |
| 436 | 437 | // 添加zlm信息 |
| 437 | - updateMediaServerKeepalive(serverItem.getId(), mediaServerConfig); | |
| 438 | + updateMediaServerKeepalive(serverItem.getId(), null); | |
| 438 | 439 | }else { |
| 439 | 440 | publisher.zlmOfflineEventPublish(serverItem.getId()); |
| 440 | 441 | } |
| ... | ... | @@ -526,15 +527,15 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 526 | 527 | Map<String, Object> param = new HashMap<>(); |
| 527 | 528 | param.put("api.secret",mediaServerItem.getSecret()); // -profile:v Baseline |
| 528 | 529 | param.put("hook.enable","1"); |
| 529 | - param.put("hook.on_flow_report",String.format("%s/on_flow_report", hookPrex)); | |
| 530 | + param.put("hook.on_flow_report",""); | |
| 530 | 531 | param.put("hook.on_play",String.format("%s/on_play", hookPrex)); |
| 531 | - param.put("hook.on_http_access",String.format("%s/on_http_access", hookPrex)); | |
| 532 | + param.put("hook.on_http_access",""); | |
| 532 | 533 | param.put("hook.on_publish", String.format("%s/on_publish", hookPrex)); |
| 533 | - param.put("hook.on_record_ts",String.format("%s/on_record_ts", hookPrex)); | |
| 534 | - param.put("hook.on_rtsp_auth",String.format("%s/on_rtsp_auth", hookPrex)); | |
| 535 | - param.put("hook.on_rtsp_realm",String.format("%s/on_rtsp_realm", hookPrex)); | |
| 534 | + param.put("hook.on_record_ts",""); | |
| 535 | + param.put("hook.on_rtsp_auth",""); | |
| 536 | + param.put("hook.on_rtsp_realm",""); | |
| 536 | 537 | param.put("hook.on_server_started",String.format("%s/on_server_started", hookPrex)); |
| 537 | - param.put("hook.on_shell_login",String.format("%s/on_shell_login", hookPrex)); | |
| 538 | + param.put("hook.on_shell_login",""); | |
| 538 | 539 | param.put("hook.on_stream_changed",String.format("%s/on_stream_changed", hookPrex)); |
| 539 | 540 | param.put("hook.on_stream_none_reader",String.format("%s/on_stream_none_reader", hookPrex)); |
| 540 | 541 | param.put("hook.on_stream_not_found",String.format("%s/on_stream_not_found", hookPrex)); |
| ... | ... | @@ -551,6 +552,7 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 551 | 552 | // 此参数不应大于播放器超时时间 |
| 552 | 553 | // 优化此消息以更快的收到流注销事件 |
| 553 | 554 | param.put("general.continue_push_ms", "3000" ); |
| 555 | + param.put("general.publishToHls", "0" ); | |
| 554 | 556 | // 最多等待未初始化的Track时间,单位毫秒,超时之后会忽略未初始化的Track, 设置此选项优化那些音频错误的不规范流, |
| 555 | 557 | // 等zlm支持给每个rtpServer设置关闭音频的时候可以不设置此选项 |
| 556 | 558 | // param.put("general.wait_track_ready_ms", "3000" ); |
| ... | ... | @@ -645,7 +647,7 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 645 | 647 | } |
| 646 | 648 | |
| 647 | 649 | @Override |
| 648 | - public void updateMediaServerKeepalive(String mediaServerId, JSONObject data) { | |
| 650 | + public void updateMediaServerKeepalive(String mediaServerId, ServerKeepaliveData data) { | |
| 649 | 651 | MediaServerItem mediaServerItem = getOne(mediaServerId); |
| 650 | 652 | if (mediaServerItem == null) { |
| 651 | 653 | // 缓存不存在,从数据库查询,如果数据库不存在则是错误的 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
| 1 | 1 | package com.genersoft.iot.vmp.service.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONArray; | |
| 5 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONArray; | |
| 5 | +import com.alibaba.fastjson2.JSONObject; | |
| 6 | 6 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 7 | 7 | import com.genersoft.iot.vmp.common.StreamURL; |
| 8 | 8 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 9 | 9 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 10 | 10 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 11 | -import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam; | |
| 12 | 11 | import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; |
| 13 | 12 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 14 | 13 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| ... | ... | @@ -17,7 +16,6 @@ import com.genersoft.iot.vmp.service.IMediaService; |
| 17 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | 17 | import org.springframework.stereotype.Service; |
| 19 | 18 | import org.springframework.util.ObjectUtils; |
| 20 | -import org.springframework.util.StringUtils; | |
| 21 | 19 | |
| 22 | 20 | import java.net.URL; |
| 23 | 21 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| ... | ... | @@ -25,9 +25,9 @@ import org.springframework.stereotype.Service; |
| 25 | 25 | import org.springframework.util.ObjectUtils; |
| 26 | 26 | import org.springframework.web.context.request.async.DeferredResult; |
| 27 | 27 | |
| 28 | -import com.alibaba.fastjson.JSON; | |
| 29 | -import com.alibaba.fastjson.JSONArray; | |
| 30 | -import com.alibaba.fastjson.JSONObject; | |
| 28 | +import com.alibaba.fastjson2.JSON; | |
| 29 | +import com.alibaba.fastjson2.JSONArray; | |
| 30 | +import com.alibaba.fastjson2.JSONObject; | |
| 31 | 31 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 32 | 32 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 33 | 33 | import com.genersoft.iot.vmp.conf.UserSetting; |
| ... | ... | @@ -188,7 +188,7 @@ public class PlayServiceImpl implements IPlayService { |
| 188 | 188 | |
| 189 | 189 | resultHolder.invokeAllResult(msg); |
| 190 | 190 | if (hookEvent != null) { |
| 191 | - hookEvent.response(mediaServerItem, JSONObject.parseObject(JSON.toJSONString(streamInfo))); | |
| 191 | + hookEvent.response(mediaServerItem, JSON.parseObject(JSON.toJSONString(streamInfo))); | |
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
| 1 | 1 | package com.genersoft.iot.vmp.service.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONArray; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONArray; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | 7 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 8 | 8 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 9 | -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | |
| 10 | -import com.genersoft.iot.vmp.gb28181.bean.TreeType; | |
| 11 | 9 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 12 | 10 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; |
| 13 | 11 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 14 | -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | |
| 12 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | |
| 15 | 13 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 16 | 14 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 17 | 15 | import com.genersoft.iot.vmp.service.IGbStreamService; |
| ... | ... | @@ -27,7 +25,6 @@ import com.genersoft.iot.vmp.service.IStreamProxyService; |
| 27 | 25 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 28 | 26 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 29 | 27 | import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; |
| 30 | -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | |
| 31 | 28 | import com.github.pagehelper.PageInfo; |
| 32 | 29 | import org.slf4j.Logger; |
| 33 | 30 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -37,9 +34,7 @@ import org.springframework.stereotype.Service; |
| 37 | 34 | import org.springframework.transaction.TransactionDefinition; |
| 38 | 35 | import org.springframework.transaction.TransactionStatus; |
| 39 | 36 | import org.springframework.util.ObjectUtils; |
| 40 | -import org.springframework.util.StringUtils; | |
| 41 | 37 | |
| 42 | -import java.net.InetAddress; | |
| 43 | 38 | import java.util.*; |
| 44 | 39 | |
| 45 | 40 | /** |
| ... | ... | @@ -389,18 +384,18 @@ public class StreamProxyServiceImpl implements IStreamProxyService { |
| 389 | 384 | String type = "PULL"; |
| 390 | 385 | |
| 391 | 386 | // 发送redis消息 |
| 392 | - List<MediaItem> mediaItems = redisCatchStorage.getStreams(mediaServerId, type); | |
| 393 | - if (mediaItems.size() > 0) { | |
| 394 | - for (MediaItem mediaItem : mediaItems) { | |
| 387 | + List<OnStreamChangedHookParam> onStreamChangedHookParams = redisCatchStorage.getStreams(mediaServerId, type); | |
| 388 | + if (onStreamChangedHookParams.size() > 0) { | |
| 389 | + for (OnStreamChangedHookParam onStreamChangedHookParam : onStreamChangedHookParams) { | |
| 395 | 390 | JSONObject jsonObject = new JSONObject(); |
| 396 | 391 | jsonObject.put("serverId", userSetting.getServerId()); |
| 397 | - jsonObject.put("app", mediaItem.getApp()); | |
| 398 | - jsonObject.put("stream", mediaItem.getStream()); | |
| 392 | + jsonObject.put("app", onStreamChangedHookParam.getApp()); | |
| 393 | + jsonObject.put("stream", onStreamChangedHookParam.getStream()); | |
| 399 | 394 | jsonObject.put("register", false); |
| 400 | 395 | jsonObject.put("mediaServerId", mediaServerId); |
| 401 | 396 | redisCatchStorage.sendStreamChangeMsg(type, jsonObject); |
| 402 | 397 | // 移除redis内流的信息 |
| 403 | - redisCatchStorage.removeStream(mediaServerId, type, mediaItem.getApp(), mediaItem.getStream()); | |
| 398 | + redisCatchStorage.removeStream(mediaServerId, type, onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream()); | |
| 404 | 399 | } |
| 405 | 400 | } |
| 406 | 401 | } |
| ... | ... | @@ -415,6 +410,47 @@ public class StreamProxyServiceImpl implements IStreamProxyService { |
| 415 | 410 | return streamProxyMapper.updateStatus(app, stream, status); |
| 416 | 411 | } |
| 417 | 412 | |
| 413 | + private void syncPullStream(String mediaServerId){ | |
| 414 | + MediaServerItem mediaServer = mediaServerService.getOne(mediaServerId); | |
| 415 | + if (mediaServer != null) { | |
| 416 | + List<OnStreamChangedHookParam> allPullStream = redisCatchStorage.getStreams(mediaServerId, "PULL"); | |
| 417 | + if (allPullStream.size() > 0) { | |
| 418 | + zlmresTfulUtils.getMediaList(mediaServer, jsonObject->{ | |
| 419 | + Map<String, StreamInfo> stringStreamInfoMap = new HashMap<>(); | |
| 420 | + if (jsonObject.getInteger("code") == 0) { | |
| 421 | + JSONArray data = jsonObject.getJSONArray("data"); | |
| 422 | + if(data != null && data.size() > 0) { | |
| 423 | + for (int i = 0; i < data.size(); i++) { | |
| 424 | + JSONObject streamJSONObj = data.getJSONObject(i); | |
| 425 | + if ("rtsp".equals(streamJSONObj.getString("schema"))) { | |
| 426 | + StreamInfo streamInfo = new StreamInfo(); | |
| 427 | + String app = streamJSONObj.getString("app"); | |
| 428 | + String stream = streamJSONObj.getString("stream"); | |
| 429 | + streamInfo.setApp(app); | |
| 430 | + streamInfo.setStream(stream); | |
| 431 | + stringStreamInfoMap.put(app+stream, streamInfo); | |
| 432 | + } | |
| 433 | + } | |
| 434 | + } | |
| 435 | + } | |
| 436 | + if (stringStreamInfoMap.size() == 0) { | |
| 437 | + redisCatchStorage.removeStream(mediaServerId, "PULL"); | |
| 438 | + }else { | |
| 439 | + for (String key : stringStreamInfoMap.keySet()) { | |
| 440 | + StreamInfo streamInfo = stringStreamInfoMap.get(key); | |
| 441 | + if (stringStreamInfoMap.get(streamInfo.getApp() + streamInfo.getStream()) == null) { | |
| 442 | + redisCatchStorage.removeStream(mediaServerId, "PULL", streamInfo.getApp(), | |
| 443 | + streamInfo.getStream()); | |
| 444 | + } | |
| 445 | + } | |
| 446 | + } | |
| 447 | + }); | |
| 448 | + } | |
| 449 | + | |
| 450 | + } | |
| 451 | + | |
| 452 | + } | |
| 453 | + | |
| 418 | 454 | @Override |
| 419 | 455 | public ResourceBaceInfo getOverview() { |
| 420 | 456 | return streamProxyMapper.getOverview(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
| 1 | 1 | package com.genersoft.iot.vmp.service.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONArray; | |
| 5 | -import com.alibaba.fastjson.JSONObject; | |
| 6 | -import com.alibaba.fastjson.TypeReference; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONArray; | |
| 5 | +import com.alibaba.fastjson2.JSONObject; | |
| 6 | +import com.alibaba.fastjson2.TypeReference; | |
| 7 | 7 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 8 | 8 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 9 | 9 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| ... | ... | @@ -11,6 +11,8 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 11 | 11 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; |
| 12 | 12 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 13 | 13 | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| 14 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | |
| 15 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OriginType; | |
| 14 | 16 | import com.genersoft.iot.vmp.service.IGbStreamService; |
| 15 | 17 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 16 | 18 | import com.genersoft.iot.vmp.service.IStreamPushService; |
| ... | ... | @@ -29,7 +31,6 @@ import org.springframework.stereotype.Service; |
| 29 | 31 | import org.springframework.transaction.TransactionDefinition; |
| 30 | 32 | import org.springframework.transaction.TransactionStatus; |
| 31 | 33 | import org.springframework.util.ObjectUtils; |
| 32 | -import org.springframework.util.StringUtils; | |
| 33 | 34 | |
| 34 | 35 | import java.util.*; |
| 35 | 36 | import java.util.stream.Collectors; |
| ... | ... | @@ -93,8 +94,8 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 93 | 94 | |
| 94 | 95 | Map<String, StreamPushItem> result = new HashMap<>(); |
| 95 | 96 | |
| 96 | - List<MediaItem> mediaItems = JSON.parseObject(jsonData, new TypeReference<List<MediaItem>>() {}); | |
| 97 | - for (MediaItem item : mediaItems) { | |
| 97 | + List<OnStreamChangedHookParam> onStreamChangedHookParams = JSON.parseObject(jsonData, new TypeReference<List<OnStreamChangedHookParam>>() {}); | |
| 98 | + for (OnStreamChangedHookParam item : onStreamChangedHookParams) { | |
| 98 | 99 | |
| 99 | 100 | // 不保存国标推理以及拉流代理的流 |
| 100 | 101 | if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() |
| ... | ... | @@ -112,7 +113,7 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 112 | 113 | return new ArrayList<>(result.values()); |
| 113 | 114 | } |
| 114 | 115 | @Override |
| 115 | - public StreamPushItem transform(MediaItem item) { | |
| 116 | + public StreamPushItem transform(OnStreamChangedHookParam item) { | |
| 116 | 117 | StreamPushItem streamPushItem = new StreamPushItem(); |
| 117 | 118 | streamPushItem.setApp(item.getApp()); |
| 118 | 119 | streamPushItem.setMediaServerId(item.getMediaServerId()); |
| ... | ... | @@ -206,8 +207,8 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 206 | 207 | List<StreamPushItem> pushList = getPushList(mediaServerId); |
| 207 | 208 | Map<String, StreamPushItem> pushItemMap = new HashMap<>(); |
| 208 | 209 | // redis记录 |
| 209 | - List<MediaItem> mediaItems = redisCatchStorage.getStreams(mediaServerId, "PUSH"); | |
| 210 | - Map<String, MediaItem> streamInfoPushItemMap = new HashMap<>(); | |
| 210 | + List<OnStreamChangedHookParam> onStreamChangedHookParams = redisCatchStorage.getStreams(mediaServerId, "PUSH"); | |
| 211 | + Map<String, OnStreamChangedHookParam> streamInfoPushItemMap = new HashMap<>(); | |
| 211 | 212 | if (pushList.size() > 0) { |
| 212 | 213 | for (StreamPushItem streamPushItem : pushList) { |
| 213 | 214 | if (ObjectUtils.isEmpty(streamPushItem.getGbId())) { |
| ... | ... | @@ -215,9 +216,9 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 215 | 216 | } |
| 216 | 217 | } |
| 217 | 218 | } |
| 218 | - if (mediaItems.size() > 0) { | |
| 219 | - for (MediaItem mediaItem : mediaItems) { | |
| 220 | - streamInfoPushItemMap.put(mediaItem.getApp() + mediaItem.getStream(), mediaItem); | |
| 219 | + if (onStreamChangedHookParams.size() > 0) { | |
| 220 | + for (OnStreamChangedHookParam onStreamChangedHookParam : onStreamChangedHookParams) { | |
| 221 | + streamInfoPushItemMap.put(onStreamChangedHookParam.getApp() + onStreamChangedHookParam.getStream(), onStreamChangedHookParam); | |
| 221 | 222 | } |
| 222 | 223 | } |
| 223 | 224 | zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ |
| ... | ... | @@ -258,19 +259,19 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 258 | 259 | } |
| 259 | 260 | |
| 260 | 261 | } |
| 261 | - Collection<MediaItem> offlineMediaItemList = streamInfoPushItemMap.values(); | |
| 262 | - if (offlineMediaItemList.size() > 0) { | |
| 262 | + Collection<OnStreamChangedHookParam> offlineOnStreamChangedHookParamList = streamInfoPushItemMap.values(); | |
| 263 | + if (offlineOnStreamChangedHookParamList.size() > 0) { | |
| 263 | 264 | String type = "PUSH"; |
| 264 | - for (MediaItem offlineMediaItem : offlineMediaItemList) { | |
| 265 | + for (OnStreamChangedHookParam offlineOnStreamChangedHookParam : offlineOnStreamChangedHookParamList) { | |
| 265 | 266 | JSONObject jsonObject = new JSONObject(); |
| 266 | 267 | jsonObject.put("serverId", userSetting.getServerId()); |
| 267 | - jsonObject.put("app", offlineMediaItem.getApp()); | |
| 268 | - jsonObject.put("stream", offlineMediaItem.getStream()); | |
| 268 | + jsonObject.put("app", offlineOnStreamChangedHookParam.getApp()); | |
| 269 | + jsonObject.put("stream", offlineOnStreamChangedHookParam.getStream()); | |
| 269 | 270 | jsonObject.put("register", false); |
| 270 | 271 | jsonObject.put("mediaServerId", mediaServerId); |
| 271 | 272 | redisCatchStorage.sendStreamChangeMsg(type, jsonObject); |
| 272 | 273 | // 移除redis内流的信息 |
| 273 | - redisCatchStorage.removeStream(mediaServerItem.getId(), "PUSH", offlineMediaItem.getApp(), offlineMediaItem.getStream()); | |
| 274 | + redisCatchStorage.removeStream(mediaServerItem.getId(), "PUSH", offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream()); | |
| 274 | 275 | } |
| 275 | 276 | } |
| 276 | 277 | })); |
| ... | ... | @@ -288,15 +289,15 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 288 | 289 | // 发送流停止消息 |
| 289 | 290 | String type = "PUSH"; |
| 290 | 291 | // 发送redis消息 |
| 291 | - List<MediaItem> streamInfoList = redisCatchStorage.getStreams(mediaServerId, type); | |
| 292 | + List<OnStreamChangedHookParam> streamInfoList = redisCatchStorage.getStreams(mediaServerId, type); | |
| 292 | 293 | if (streamInfoList.size() > 0) { |
| 293 | - for (MediaItem mediaItem : streamInfoList) { | |
| 294 | + for (OnStreamChangedHookParam onStreamChangedHookParam : streamInfoList) { | |
| 294 | 295 | // 移除redis内流的信息 |
| 295 | - redisCatchStorage.removeStream(mediaServerId, type, mediaItem.getApp(), mediaItem.getStream()); | |
| 296 | + redisCatchStorage.removeStream(mediaServerId, type, onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream()); | |
| 296 | 297 | JSONObject jsonObject = new JSONObject(); |
| 297 | 298 | jsonObject.put("serverId", userSetting.getServerId()); |
| 298 | - jsonObject.put("app", mediaItem.getApp()); | |
| 299 | - jsonObject.put("stream", mediaItem.getStream()); | |
| 299 | + jsonObject.put("app", onStreamChangedHookParam.getApp()); | |
| 300 | + jsonObject.put("stream", onStreamChangedHookParam.getStream()); | |
| 300 | 301 | jsonObject.put("register", false); |
| 301 | 302 | jsonObject.put("mediaServerId", mediaServerId); |
| 302 | 303 | redisCatchStorage.sendStreamChangeMsg(type, jsonObject); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java
| 1 | 1 | package com.genersoft.iot.vmp.service.redisMsg; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java
| 1 | 1 | package com.genersoft.iot.vmp.service.redisMsg; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java
| 1 | 1 | package com.genersoft.iot.vmp.service.redisMsg; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | 4 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 6 | 6 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java
| 1 | 1 | package com.genersoft.iot.vmp.service.redisMsg; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | 4 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.service.bean.MessageForPushChannelResponse; |
| 6 | 6 | import org.slf4j.Logger; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java
| 1 | 1 | package com.genersoft.iot.vmp.service.redisMsg; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 6 | 6 | import com.genersoft.iot.vmp.service.IGbStreamService; |
| 7 | 7 | import com.genersoft.iot.vmp.service.IMediaServerService; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java
| 1 | 1 | package com.genersoft.iot.vmp.service.redisMsg; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 6 | 6 | import com.genersoft.iot.vmp.service.IStreamPushService; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisStreamMsgListener.java
| 1 | 1 | package com.genersoft.iot.vmp.service.redisMsg; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 6 | |
| 7 | 7 | import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; |
| 8 | -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | |
| 8 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | |
| 9 | 9 | import org.slf4j.Logger; |
| 10 | 10 | import org.slf4j.LoggerFactory; |
| 11 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -66,20 +66,20 @@ public class RedisStreamMsgListener implements MessageListener { |
| 66 | 66 | String stream = steamMsgJson.getString("stream"); |
| 67 | 67 | boolean register = steamMsgJson.getBoolean("register"); |
| 68 | 68 | String mediaServerId = steamMsgJson.getString("mediaServerId"); |
| 69 | - MediaItem mediaItem = new MediaItem(); | |
| 70 | - mediaItem.setSeverId(serverId); | |
| 71 | - mediaItem.setApp(app); | |
| 72 | - mediaItem.setStream(stream); | |
| 73 | - mediaItem.setRegist(register); | |
| 74 | - mediaItem.setMediaServerId(mediaServerId); | |
| 75 | - mediaItem.setCreateStamp(System.currentTimeMillis()/1000); | |
| 76 | - mediaItem.setAliveSecond(0L); | |
| 77 | - mediaItem.setTotalReaderCount("0"); | |
| 78 | - mediaItem.setOriginType(0); | |
| 79 | - mediaItem.setOriginTypeStr("0"); | |
| 80 | - mediaItem.setOriginTypeStr("unknown"); | |
| 69 | + OnStreamChangedHookParam onStreamChangedHookParam = new OnStreamChangedHookParam(); | |
| 70 | + onStreamChangedHookParam.setSeverId(serverId); | |
| 71 | + onStreamChangedHookParam.setApp(app); | |
| 72 | + onStreamChangedHookParam.setStream(stream); | |
| 73 | + onStreamChangedHookParam.setRegist(register); | |
| 74 | + onStreamChangedHookParam.setMediaServerId(mediaServerId); | |
| 75 | + onStreamChangedHookParam.setCreateStamp(System.currentTimeMillis()/1000); | |
| 76 | + onStreamChangedHookParam.setAliveSecond(0L); | |
| 77 | + onStreamChangedHookParam.setTotalReaderCount("0"); | |
| 78 | + onStreamChangedHookParam.setOriginType(0); | |
| 79 | + onStreamChangedHookParam.setOriginTypeStr("0"); | |
| 80 | + onStreamChangedHookParam.setOriginTypeStr("unknown"); | |
| 81 | 81 | if (register) { |
| 82 | - zlmMediaListManager.addPush(mediaItem); | |
| 82 | + zlmMediaListManager.addPush(onStreamChangedHookParam); | |
| 83 | 83 | }else { |
| 84 | 84 | zlmMediaListManager.removeMedia(app, stream); |
| 85 | 85 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
| 1 | 1 | package com.genersoft.iot.vmp.storager; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.common.SystemAllInfo; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 7 | 7 | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| 8 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | |
| 8 | 9 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| 9 | 10 | import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; |
| 10 | -import com.genersoft.iot.vmp.service.bean.SSRCInfo; | |
| 11 | 11 | import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; |
| 12 | 12 | import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; |
| 13 | 13 | |
| ... | ... | @@ -131,7 +131,7 @@ public interface IRedisCatchStorage { |
| 131 | 131 | * @param app |
| 132 | 132 | * @param streamId |
| 133 | 133 | */ |
| 134 | - void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, MediaItem item); | |
| 134 | + void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, OnStreamChangedHookParam item); | |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * 移除流信息从redis |
| ... | ... | @@ -165,7 +165,7 @@ public interface IRedisCatchStorage { |
| 165 | 165 | */ |
| 166 | 166 | ThirdPartyGB queryMemberNoGBId(String queryKey); |
| 167 | 167 | |
| 168 | - List<MediaItem> getStreams(String mediaServerId, String pull); | |
| 168 | + List<OnStreamChangedHookParam> getStreams(String mediaServerId, String pull); | |
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | 171 | * 将device信息写入redis |
| ... | ... | @@ -191,7 +191,7 @@ public interface IRedisCatchStorage { |
| 191 | 191 | |
| 192 | 192 | void resetAllSN(); |
| 193 | 193 | |
| 194 | - MediaItem getStreamInfo(String app, String streamId, String mediaServerId); | |
| 194 | + OnStreamChangedHookParam getStreamInfo(String app, String streamId, String mediaServerId); | |
| 195 | 195 | |
| 196 | 196 | void addCpuInfo(double cpuInfo); |
| 197 | 197 | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
| 1 | 1 | package com.genersoft.iot.vmp.storager.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 6 | 6 | import com.genersoft.iot.vmp.common.SystemAllInfo; |
| 7 | 7 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 8 | 8 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 9 | 9 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 10 | -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; | |
| 10 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | |
| 11 | 11 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 12 | 12 | import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; |
| 13 | 13 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| ... | ... | @@ -573,14 +573,14 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | @Override |
| 576 | - public void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, MediaItem mediaItem) { | |
| 576 | + public void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, OnStreamChangedHookParam onStreamChangedHookParam) { | |
| 577 | 577 | // 查找是否使用了callID |
| 578 | 578 | StreamAuthorityInfo streamAuthorityInfo = getStreamAuthorityInfo(app, streamId); |
| 579 | 579 | String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerItem.getId(); |
| 580 | 580 | if (streamAuthorityInfo != null) { |
| 581 | - mediaItem.setCallId(streamAuthorityInfo.getCallId()); | |
| 581 | + onStreamChangedHookParam.setCallId(streamAuthorityInfo.getCallId()); | |
| 582 | 582 | } |
| 583 | - RedisUtil.set(key, mediaItem); | |
| 583 | + RedisUtil.set(key, onStreamChangedHookParam); | |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | @Override |
| ... | ... | @@ -625,7 +625,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| 625 | 625 | public ThirdPartyGB queryMemberNoGBId(String queryKey) { |
| 626 | 626 | String key = VideoManagerConstants.WVP_STREAM_GB_ID_PREFIX + queryKey; |
| 627 | 627 | JSONObject jsonObject = (JSONObject)RedisUtil.get(key); |
| 628 | - return JSONObject.toJavaObject(jsonObject, ThirdPartyGB.class); | |
| 628 | + return jsonObject.to(ThirdPartyGB.class); | |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | @Override |
| ... | ... | @@ -638,13 +638,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | @Override |
| 641 | - public List<MediaItem> getStreams(String mediaServerId, String type) { | |
| 642 | - List<MediaItem> result = new ArrayList<>(); | |
| 641 | + public List<OnStreamChangedHookParam> getStreams(String mediaServerId, String type) { | |
| 642 | + List<OnStreamChangedHookParam> result = new ArrayList<>(); | |
| 643 | 643 | String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_*_*_" + mediaServerId; |
| 644 | 644 | List<Object> streams = RedisUtil.scan(key); |
| 645 | 645 | for (Object stream : streams) { |
| 646 | - MediaItem mediaItem = (MediaItem)RedisUtil.get((String) stream); | |
| 647 | - result.add(mediaItem); | |
| 646 | + OnStreamChangedHookParam onStreamChangedHookParam = (OnStreamChangedHookParam)RedisUtil.get((String) stream); | |
| 647 | + result.add(onStreamChangedHookParam); | |
| 648 | 648 | } |
| 649 | 649 | return result; |
| 650 | 650 | } |
| ... | ... | @@ -716,14 +716,14 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| 716 | 716 | |
| 717 | 717 | |
| 718 | 718 | @Override |
| 719 | - public MediaItem getStreamInfo(String app, String streamId, String mediaServerId) { | |
| 719 | + public OnStreamChangedHookParam getStreamInfo(String app, String streamId, String mediaServerId) { | |
| 720 | 720 | String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId; |
| 721 | 721 | |
| 722 | - MediaItem result = null; | |
| 722 | + OnStreamChangedHookParam result = null; | |
| 723 | 723 | List<Object> keys = RedisUtil.scan(scanKey); |
| 724 | 724 | if (keys.size() > 0) { |
| 725 | 725 | String key = (String) keys.get(0); |
| 726 | - result = (MediaItem)RedisUtil.get(key); | |
| 726 | + result = (OnStreamChangedHookParam)RedisUtil.get(key); | |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | return result; | ... | ... |
src/main/java/com/genersoft/iot/vmp/utils/SystemInfoUtils.java
| 1 | 1 | package com.genersoft.iot.vmp.utils; |
| 2 | 2 | |
| 3 | +import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookListener; | |
| 4 | +import org.slf4j.Logger; | |
| 5 | +import org.slf4j.LoggerFactory; | |
| 3 | 6 | import org.springframework.util.ObjectUtils; |
| 4 | 7 | import oshi.SystemInfo; |
| 5 | 8 | import oshi.hardware.*; |
| ... | ... | @@ -21,6 +24,8 @@ import java.util.concurrent.TimeUnit; |
| 21 | 24 | */ |
| 22 | 25 | public class SystemInfoUtils { |
| 23 | 26 | |
| 27 | + private final static Logger logger = LoggerFactory.getLogger(SystemInfoUtils.class); | |
| 28 | + | |
| 24 | 29 | /** |
| 25 | 30 | * 获取cpu信息 |
| 26 | 31 | * @return |
| ... | ... | @@ -73,7 +78,7 @@ public class SystemInfoUtils { |
| 73 | 78 | try { |
| 74 | 79 | Thread.sleep(1000); |
| 75 | 80 | } catch (InterruptedException e) { |
| 76 | - throw new RuntimeException(e); | |
| 81 | + logger.error("[线程休眠失败] : {}", e.getMessage()); | |
| 77 | 82 | } |
| 78 | 83 | List<NetworkIF> afterNetworkIFs = hal.getNetworkIFs(); |
| 79 | 84 | NetworkIF afterNet = afterNetworkIFs.get(afterNetworkIFs.size() - 1); | ... | ... |
src/main/java/com/genersoft/iot/vmp/utils/redis/FastJsonRedisSerializer.java
| ... | ... | @@ -2,11 +2,13 @@ package com.genersoft.iot.vmp.utils.redis; |
| 2 | 2 | |
| 3 | 3 | import java.nio.charset.Charset; |
| 4 | 4 | |
| 5 | +import com.alibaba.fastjson2.JSONReader; | |
| 6 | +import com.alibaba.fastjson2.JSONWriter; | |
| 5 | 7 | import org.springframework.data.redis.serializer.RedisSerializer; |
| 6 | 8 | import org.springframework.data.redis.serializer.SerializationException; |
| 7 | 9 | |
| 8 | -import com.alibaba.fastjson.JSON; | |
| 9 | -import com.alibaba.fastjson.serializer.SerializerFeature; | |
| 10 | +import com.alibaba.fastjson2.JSON; | |
| 11 | +import com.alibaba.fastjson2.JSONWriter.Feature; | |
| 10 | 12 | |
| 11 | 13 | /** |
| 12 | 14 | * @description:使用fastjson实现redis的序列化 |
| ... | ... | @@ -29,7 +31,7 @@ public class FastJsonRedisSerializer<T> implements RedisSerializer<T> { |
| 29 | 31 | if (t == null) { |
| 30 | 32 | return new byte[0]; |
| 31 | 33 | } |
| 32 | - return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); | |
| 34 | + return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET); | |
| 33 | 35 | } |
| 34 | 36 | |
| 35 | 37 | @Override |
| ... | ... | @@ -38,6 +40,6 @@ public class FastJsonRedisSerializer<T> implements RedisSerializer<T> { |
| 38 | 40 | return null; |
| 39 | 41 | } |
| 40 | 42 | String str = new String(bytes, DEFAULT_CHARSET); |
| 41 | - return (T) JSON.parseObject(str, clazz); | |
| 43 | + return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); | |
| 42 | 44 | } |
| 43 | 45 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java
| ... | ... | @@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.utils.redis; |
| 3 | 3 | import java.util.*; |
| 4 | 4 | import java.util.concurrent.TimeUnit; |
| 5 | 5 | |
| 6 | -import com.alibaba.fastjson.JSONObject; | |
| 6 | +import com.alibaba.fastjson2.JSONObject; | |
| 7 | 7 | import com.genersoft.iot.vmp.utils.SpringBeanFactory; |
| 8 | 8 | import gov.nist.javax.sip.stack.UDPMessageChannel; |
| 9 | 9 | import org.springframework.data.redis.core.*; | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | |
| 8 | 8 | package com.genersoft.iot.vmp.vmanager.gb28181.device; |
| 9 | 9 | |
| 10 | -import com.alibaba.fastjson.JSONObject; | |
| 10 | +import com.alibaba.fastjson2.JSONObject; | |
| 11 | 11 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 12 | 12 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 13 | 13 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | |
| 8 | 8 | package com.genersoft.iot.vmp.vmanager.gb28181.device; |
| 9 | 9 | |
| 10 | -import com.alibaba.fastjson.JSONObject; | |
| 10 | +import com.alibaba.fastjson2.JSONObject; | |
| 11 | 11 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 12 | 12 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 13 | 13 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.gb28181.device; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.Device; | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.gb28181.platform; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 7 | 7 | import com.genersoft.iot.vmp.conf.UserSetting; | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.gb28181.play; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONArray; | |
| 3 | +import com.alibaba.fastjson2.JSONArray; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| ... | ... | @@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.PostMapping; |
| 33 | 33 | import org.springframework.web.bind.annotation.RequestMapping; |
| 34 | 34 | import org.springframework.web.bind.annotation.RestController; |
| 35 | 35 | |
| 36 | -import com.alibaba.fastjson.JSONObject; | |
| 36 | +import com.alibaba.fastjson2.JSONObject; | |
| 37 | 37 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 38 | 38 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 39 | 39 | import org.springframework.web.context.request.async.DeferredResult; | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java
| 1 | 1 | //package com.genersoft.iot.vmp.vmanager.record; |
| 2 | 2 | // |
| 3 | -//import com.alibaba.fastjson.JSONObject; | |
| 3 | +//import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | //import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 5 | 5 | //import com.genersoft.iot.vmp.service.IRecordInfoServer; |
| 6 | 6 | //import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo; | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.server; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.VManageBootstrap; |
| 6 | 6 | import com.genersoft.iot.vmp.common.SystemAllInfo; |
| 7 | 7 | import com.genersoft.iot.vmp.common.VersionPo; | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.streamProxy; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 6 | 6 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | ... | ... |
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
| 1 | 1 | package com.genersoft.iot.vmp.web.gb28181; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | ... | ... |
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiController.java
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java
| 1 | 1 | package com.genersoft.iot.vmp.web.gb28181; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONArray; | |
| 4 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONArray; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 7 | 7 | import com.genersoft.iot.vmp.service.IDeviceService; | ... | ... |
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
| 1 | 1 | package com.genersoft.iot.vmp.web.gb28181; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; | ... | ... |
src/main/resources/all-application.yml
web_src/src/components/console/ConsoleResource.vue
| 1 | 1 | <template > |
| 2 | 2 | <div id="consoleResource" style="width: 100%; height: 100%; background: #FFFFFF; text-align: center"> |
| 3 | 3 | <div style="width: 50%;height: 50%; float:left; "> |
| 4 | - <el-progress :width="100" :stroke-width="8" type="circle" :percentage="deviceInfo.online/deviceInfo.total*100" style="margin-top: 20px; font-size: 18px"></el-progress> | |
| 4 | + <el-progress :width="100" :stroke-width="8" type="circle" :percentage="Math.floor(deviceInfo.online/deviceInfo.total*100)" style="margin-top: 20px; font-size: 18px"></el-progress> | |
| 5 | 5 | <div class="resourceInfo"> |
| 6 | 6 | 设备总数:{{deviceInfo.total}}<br/> |
| 7 | 7 | 在线数:{{deviceInfo.online}} |
| 8 | 8 | </div> |
| 9 | 9 | </div> |
| 10 | 10 | <div style="width: 50%;height: 50%; float:left; "> |
| 11 | - <el-progress :width="100" :stroke-width="10" type="circle" :percentage="channelInfo.online/channelInfo.total*100" style="margin-top: 20px"></el-progress> | |
| 11 | + <el-progress :width="100" :stroke-width="10" type="circle" :percentage="Math.floor(channelInfo.online/channelInfo.total*100)" style="margin-top: 20px"></el-progress> | |
| 12 | 12 | <div class="resourceInfo"> |
| 13 | 13 | 通道总数:{{channelInfo.total}}<br/> |
| 14 | 14 | 在线数:{{channelInfo.online}} |
| 15 | 15 | </div> |
| 16 | 16 | </div> |
| 17 | 17 | <div style="width: 50%;height: 50%; float:left; "> |
| 18 | - <el-progress :width="100" :stroke-width="10" type="circle" :percentage="pushInfo.online/pushInfo.total*100" style="margin-top: 20px"></el-progress> | |
| 18 | + <el-progress :width="100" :stroke-width="10" type="circle" :percentage="Math.floor(pushInfo.online/pushInfo.total*100)" style="margin-top: 20px"></el-progress> | |
| 19 | 19 | <div class="resourceInfo"> |
| 20 | 20 | 推流总数:{{pushInfo.total}}<br/> |
| 21 | 21 | 在线数:{{pushInfo.online}} |
| 22 | 22 | </div> |
| 23 | 23 | </div> |
| 24 | 24 | <div style="width: 50%;height: 50%; float:left; "> |
| 25 | - <el-progress :width="100" :stroke-width="10" type="circle" :percentage="proxyInfo.online/proxyInfo.total*100" style="margin-top: 20px"></el-progress> | |
| 25 | + <el-progress :width="100" :stroke-width="10" type="circle" :percentage="Math.floor(proxyInfo.online/proxyInfo.total*100)" style="margin-top: 20px"></el-progress> | |
| 26 | 26 | <div class="resourceInfo"> |
| 27 | 27 | 拉流代理总数:{{proxyInfo.total}}<br/> |
| 28 | 28 | 在线数:{{proxyInfo.online}} | ... | ... |
web_src/src/components/dialog/devicePlayer.vue
| ... | ... | @@ -121,6 +121,10 @@ |
| 121 | 121 | <el-tag >RTC:</el-tag> |
| 122 | 122 | <span>{{ streamInfo.rtc.url }}</span> |
| 123 | 123 | </el-dropdown-item> |
| 124 | + <el-dropdown-item :command="streamInfo.rtcs.url"> | |
| 125 | + <el-tag >RTCS:</el-tag> | |
| 126 | + <span>{{ streamInfo.rtcs }}</span> | |
| 127 | + </el-dropdown-item> | |
| 124 | 128 | <el-dropdown-item :command="streamInfo.rtmp.url"> |
| 125 | 129 | <el-tag >RTMP:</el-tag> |
| 126 | 130 | <span>{{ streamInfo.rtmp.url }}</span> |
| ... | ... | @@ -322,7 +326,7 @@ export default { |
| 322 | 326 | player: { |
| 323 | 327 | jessibuca : ["ws_flv", "wss_flv"], |
| 324 | 328 | livePlayer : ["ws_flv", "wss_flv"], |
| 325 | - webRTC: ["rtc", "rtc"], | |
| 329 | + webRTC: ["rtc", "rtcs"], | |
| 326 | 330 | }, |
| 327 | 331 | videoHistory: { |
| 328 | 332 | date: '', |
| ... | ... | @@ -393,7 +397,7 @@ export default { |
| 393 | 397 | changePlayer: function (tab) { |
| 394 | 398 | console.log(this.player[tab.name][0]) |
| 395 | 399 | this.activePlayer = tab.name; |
| 396 | - this.videoUrl = this.streamInfo[this.player[tab.name][0]].url | |
| 400 | + this.videoUrl = this.getUrlByStreamInfo() | |
| 397 | 401 | console.log(this.videoUrl) |
| 398 | 402 | }, |
| 399 | 403 | openDialog: function (tab, deviceId, channelId, param) { | ... | ... |
web_src/src/components/dialog/rtcPlayer.vue
| ... | ... | @@ -51,7 +51,7 @@ export default { |
| 51 | 51 | }); |
| 52 | 52 | |
| 53 | 53 | webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS,(e)=>{//获取到了远端流,可以播放 |
| 54 | - console.error('播放成功',e.streams) | |
| 54 | + console.log('播放成功',e.streams) | |
| 55 | 55 | this.eventcallbacK("playing", "播放成功") |
| 56 | 56 | }); |
| 57 | 57 | |
| ... | ... | @@ -59,7 +59,7 @@ export default { |
| 59 | 59 | console.error('offer anwser 交换失败',e) |
| 60 | 60 | this.eventcallbacK("OFFER ANSWER ERROR ", "offer anwser 交换失败") |
| 61 | 61 | if (e.code ==-400 && e.msg=="流不存在"){ |
| 62 | - console.log("111111") | |
| 62 | + console.log("流不存在") | |
| 63 | 63 | this.timer = setTimeout(()=>{ |
| 64 | 64 | this.webrtcPlayer.close(); |
| 65 | 65 | this.play(url) | ... | ... |
web_src/src/components/live.vue
| ... | ... | @@ -138,8 +138,14 @@ export default { |
| 138 | 138 | url: '/api/play/start/' + deviceId + '/' + channelId |
| 139 | 139 | }).then(function (res) { |
| 140 | 140 | if (res.data.code === 0 && res.data.data) { |
| 141 | - itemData.playUrl = res.data.data.https_flv.url | |
| 142 | - that.setPlayUrl(res.data.data.ws_flv.url, idxTmp) | |
| 141 | + let videoUrl; | |
| 142 | + if (location.protocol === "https:") { | |
| 143 | + videoUrl = res.data.data.wss_flv.url; | |
| 144 | + } else { | |
| 145 | + videoUrl = res.data.data.ws_flv.url; | |
| 146 | + } | |
| 147 | + itemData.playUrl = videoUrl; | |
| 148 | + that.setPlayUrl(videoUrl, idxTmp); | |
| 143 | 149 | } else { |
| 144 | 150 | that.$message.error(res.data.msg); |
| 145 | 151 | } | ... | ... |