Commit 4c8e2beb4d369865893ec791430d95420d4acfad
1 parent
f762e03f
优化hook处理速度
Showing
24 changed files
with
509 additions
and
471 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| ... | ... | @@ -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; |
| ... | ... | @@ -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,7 +179,7 @@ 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); |
| ... | ... | @@ -258,21 +226,23 @@ public class ZLMHttpHookListener { |
| 258 | 226 | |
| 259 | 227 | ret.put("code", 0); |
| 260 | 228 | ret.put("msg", "success"); |
| 261 | - ret.put("enable_hls", true); | |
| 229 | + ret.put("enable_hls", false); | |
| 230 | + | |
| 262 | 231 | if (!"rtp".equals(param.getApp())) { |
| 263 | 232 | ret.put("enable_audio", true); |
| 264 | 233 | } |
| 265 | 234 | |
| 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"); | |
| 235 | + taskExecutor.execute(()->{ | |
| 236 | + ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); | |
| 237 | + if (subscribe != null) { | |
| 238 | + if (mediaInfo != null) { | |
| 239 | + subscribe.response(mediaInfo, json); | |
| 240 | + }else { | |
| 241 | + ret.put("code", 1); | |
| 242 | + ret.put("msg", "zlm not register"); | |
| 243 | + } | |
| 274 | 244 | } |
| 275 | - } | |
| 245 | + }); | |
| 276 | 246 | |
| 277 | 247 | if ("rtp".equals(param.getApp())) { |
| 278 | 248 | ret.put("enable_mp4", userSetting.getRecordSip()); |
| ... | ... | @@ -292,111 +262,8 @@ public class ZLMHttpHookListener { |
| 292 | 262 | ret.put("mp4_max_second", 10); |
| 293 | 263 | ret.put("enable_mp4", true); |
| 294 | 264 | 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 | 265 | } |
| 394 | - | |
| 395 | 266 | } |
| 396 | - | |
| 397 | - JSONObject ret = new JSONObject(); | |
| 398 | - ret.put("code", 0); | |
| 399 | - ret.put("msg", "success"); | |
| 400 | 267 | return ret; |
| 401 | 268 | } |
| 402 | 269 | |
| ... | ... | @@ -406,137 +273,139 @@ public class ZLMHttpHookListener { |
| 406 | 273 | */ |
| 407 | 274 | @ResponseBody |
| 408 | 275 | @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 | - } | |
| 276 | + public JSONObject onStreamChanged(@RequestBody OnStreamChangedHookParam param){ | |
| 277 | + | |
| 278 | + if (param.isRegist()) { | |
| 279 | + logger.info("[ZLM HOOK] 流注册, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); | |
| 441 | 280 | }else { |
| 442 | - redisCatchStorage.removeStreamAuthorityInfo(app, stream); | |
| 281 | + logger.info("[ZLM HOOK] 流注销, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); | |
| 443 | 282 | } |
| 444 | 283 | |
| 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); | |
| 284 | + | |
| 285 | + JSONObject json = (JSONObject) JSON.toJSON(param); | |
| 286 | + taskExecutor.execute(()->{ | |
| 287 | + ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); | |
| 288 | + if (subscribe != null ) { | |
| 289 | + MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); | |
| 290 | + if (mediaInfo != null) { | |
| 291 | + subscribe.response(mediaInfo, json); | |
| 292 | + } | |
| 456 | 293 | } |
| 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); | |
| 294 | + // 流消失移除redis play | |
| 295 | + List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks(); | |
| 296 | + if (param.isRegist()) { | |
| 297 | + if (param.getOriginType() == OriginType.RTMP_PUSH.ordinal() | |
| 298 | + || param.getOriginType() == OriginType.RTSP_PUSH.ordinal() | |
| 299 | + || param.getOriginType() == OriginType.RTC_PUSH.ordinal()) { | |
| 300 | + | |
| 301 | + StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); | |
| 302 | + if (streamAuthorityInfo == null) { | |
| 303 | + streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); | |
| 304 | + }else { | |
| 305 | + streamAuthorityInfo.setOriginType(param.getOriginType()); | |
| 306 | + streamAuthorityInfo.setOriginTypeStr(param.getOriginTypeStr()); | |
| 467 | 307 | } |
| 308 | + redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); | |
| 468 | 309 | } |
| 469 | 310 | }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) { | |
| 311 | + redisCatchStorage.removeStreamAuthorityInfo(param.getApp(), param.getStream()); | |
| 312 | + } | |
| 313 | + | |
| 314 | + if ("rtsp".equals(param.getSchema())){ | |
| 315 | + if (param.isRegist()) { | |
| 316 | + mediaServerService.addCount(param.getMediaServerId()); | |
| 317 | + }else { | |
| 318 | + mediaServerService.removeCount(param.getMediaServerId()); | |
| 319 | + } | |
| 320 | + if (param.getOriginType() == OriginType.PULL.ordinal() | |
| 321 | + || param.getOriginType() == OriginType.FFMPEG_PULL.ordinal()) { | |
| 322 | + // 设置拉流代理上线/离线 | |
| 323 | + streamProxyService.updateStatus(param.isRegist(), param.getApp(), param.getStream()); | |
| 324 | + } | |
| 325 | + if ("rtp".equals(param.getApp()) && !param.isRegist() ) { | |
| 326 | + StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(param.getStream()); | |
| 327 | + if (streamInfo!=null){ | |
| 328 | + redisCatchStorage.stopPlay(streamInfo); | |
| 329 | + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); | |
| 330 | + }else{ | |
| 331 | + streamInfo = redisCatchStorage.queryPlayback(null, null, param.getStream(), null); | |
| 332 | + if (streamInfo != null) { | |
| 333 | + redisCatchStorage.stopPlayback(streamInfo.getDeviceID(), streamInfo.getChannelId(), | |
| 334 | + streamInfo.getStream(), null); | |
| 335 | + } | |
| 336 | + } | |
| 337 | + }else { | |
| 338 | + if (!"rtp".equals(param.getApp())){ | |
| 339 | + String type = OriginType.values()[param.getOriginType()].getType(); | |
| 340 | + MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); | |
| 341 | + | |
| 342 | + if (mediaServerItem != null){ | |
| 343 | + if (param.isRegist()) { | |
| 344 | + StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); | |
| 345 | + String callId = null; | |
| 346 | + if (streamAuthorityInfo != null) { | |
| 347 | + callId = streamAuthorityInfo.getCallId(); | |
| 348 | + } | |
| 349 | + StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem, | |
| 350 | + param.getApp(), param.getStream(), tracks, callId); | |
| 351 | + param.setStreamInfo(streamInfoByAppAndStream); | |
| 352 | + redisCatchStorage.addStream(mediaServerItem, type, param.getApp(), param.getStream(), param); | |
| 353 | + if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal() | |
| 354 | + || param.getOriginType() == OriginType.RTMP_PUSH.ordinal() | |
| 355 | + || param.getOriginType() == OriginType.RTC_PUSH.ordinal() ) { | |
| 356 | + param.setSeverId(userSetting.getServerId()); | |
| 357 | + zlmMediaListManager.addPush(param); | |
| 358 | + } | |
| 359 | + }else { | |
| 360 | + // 兼容流注销时类型从redis记录获取 | |
| 361 | + OnStreamChangedHookParam onStreamChangedHookParam = redisCatchStorage.getStreamInfo(param.getApp(), param.getStream(), param.getMediaServerId()); | |
| 362 | + if (onStreamChangedHookParam != null) { | |
| 363 | + type = OriginType.values()[onStreamChangedHookParam.getOriginType()].getType(); | |
| 364 | + redisCatchStorage.removeStream(mediaServerItem.getId(), type, param.getApp(), param.getStream()); | |
| 365 | + } | |
| 366 | + GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream()); | |
| 367 | + if (gbStream != null) { | |
| 500 | 368 | // eventPublisher.catalogEventPublishForStream(null, gbStream, CatalogEvent.OFF); |
| 369 | + } | |
| 370 | + zlmMediaListManager.removeMedia(param.getApp(), param.getStream()); | |
| 371 | + } | |
| 372 | + if (type != null) { | |
| 373 | + // 发送流变化redis消息 | |
| 374 | + JSONObject jsonObject = new JSONObject(); | |
| 375 | + jsonObject.put("serverId", userSetting.getServerId()); | |
| 376 | + jsonObject.put("app", param.getApp()); | |
| 377 | + jsonObject.put("stream", param.getStream()); | |
| 378 | + jsonObject.put("register", param.isRegist()); | |
| 379 | + jsonObject.put("mediaServerId", param.getMediaServerId()); | |
| 380 | + redisCatchStorage.sendStreamChangeMsg(type, jsonObject); | |
| 501 | 381 | } |
| 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 | 382 | } |
| 514 | 383 | } |
| 515 | 384 | } |
| 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()); | |
| 385 | + if (!param.isRegist()) { | |
| 386 | + List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(param.getStream()); | |
| 387 | + if (sendRtpItems.size() > 0) { | |
| 388 | + for (SendRtpItem sendRtpItem : sendRtpItems) { | |
| 389 | + if (sendRtpItem.getApp().equals(param.getApp())) { | |
| 390 | + String platformId = sendRtpItem.getPlatformId(); | |
| 391 | + ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); | |
| 392 | + Device device = deviceService.getDevice(platformId); | |
| 393 | + | |
| 394 | + try { | |
| 395 | + if (platform != null) { | |
| 396 | + commanderFroPlatform.streamByeCmd(platform, sendRtpItem); | |
| 397 | + }else { | |
| 398 | + cmder.streamByeCmd(device, sendRtpItem.getChannelId(), param.getStream(), sendRtpItem.getCallId()); | |
| 399 | + } | |
| 400 | + } catch (SipException | InvalidArgumentException | ParseException | SsrcTransactionNotFoundException e) { | |
| 401 | + logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); | |
| 531 | 402 | } |
| 532 | - } catch (SipException | InvalidArgumentException | ParseException | SsrcTransactionNotFoundException e) { | |
| 533 | - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); | |
| 534 | 403 | } |
| 535 | 404 | } |
| 536 | 405 | } |
| 537 | 406 | } |
| 538 | 407 | } |
| 539 | - } | |
| 408 | + }); | |
| 540 | 409 | |
| 541 | 410 | JSONObject ret = new JSONObject(); |
| 542 | 411 | ret.put("code", 0); |
| ... | ... | @@ -550,19 +419,16 @@ public class ZLMHttpHookListener { |
| 550 | 419 | */ |
| 551 | 420 | @ResponseBody |
| 552 | 421 | @PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8") |
| 553 | - public JSONObject onStreamNoneReader(@RequestBody JSONObject json){ | |
| 422 | + public JSONObject onStreamNoneReader(@RequestBody OnStreamNoneReaderHookParam param){ | |
| 554 | 423 | |
| 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"); | |
| 424 | + logger.info("[ZLM HOOK]流无人观看:{]->{}->{}/{}" + param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); | |
| 559 | 425 | JSONObject ret = new JSONObject(); |
| 560 | 426 | ret.put("code", 0); |
| 561 | 427 | // 录像下载 |
| 562 | - ret.put("close", userSetting.getStreamOnDemand()); | |
| 563 | - if ("rtp".equals(app)){ | |
| 428 | + if ("rtp".equals(param.getApp())){ | |
| 429 | + ret.put("close", userSetting.getStreamOnDemand()); | |
| 564 | 430 | // 国标流, 点播/录像回放/录像下载 |
| 565 | - StreamInfo streamInfoForPlayCatch = redisCatchStorage.queryPlayByStreamId(streamId); | |
| 431 | + StreamInfo streamInfoForPlayCatch = redisCatchStorage.queryPlayByStreamId(param.getStream()); | |
| 566 | 432 | // 点播 |
| 567 | 433 | if (streamInfoForPlayCatch != null) { |
| 568 | 434 | // 收到无人观看说明流也没有在往上级推送 |
| ... | ... | @@ -596,7 +462,7 @@ public class ZLMHttpHookListener { |
| 596 | 462 | return ret; |
| 597 | 463 | } |
| 598 | 464 | // 录像回放 |
| 599 | - StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null); | |
| 465 | + StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, param.getStream(), null); | |
| 600 | 466 | if (streamInfoForPlayBackCatch != null ) { |
| 601 | 467 | if (streamInfoForPlayBackCatch.isPause()) { |
| 602 | 468 | ret.put("close", false); |
| ... | ... | @@ -617,7 +483,7 @@ public class ZLMHttpHookListener { |
| 617 | 483 | return ret; |
| 618 | 484 | } |
| 619 | 485 | // 录像下载 |
| 620 | - StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, streamId, null); | |
| 486 | + StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, param.getStream(), null); | |
| 621 | 487 | // 进行录像下载时无人观看不断流 |
| 622 | 488 | if (streamInfoForDownload != null) { |
| 623 | 489 | ret.put("close", false); |
| ... | ... | @@ -626,19 +492,19 @@ public class ZLMHttpHookListener { |
| 626 | 492 | }else { |
| 627 | 493 | // 非国标流 推流/拉流代理 |
| 628 | 494 | // 拉流代理 |
| 629 | - StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(app, streamId); | |
| 495 | + StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); | |
| 630 | 496 | if (streamProxyItem != null ) { |
| 631 | 497 | if (streamProxyItem.isEnable_remove_none_reader()) { |
| 632 | 498 | // 无人观看自动移除 |
| 633 | 499 | ret.put("close", true); |
| 634 | - streamProxyService.del(app, streamId); | |
| 500 | + streamProxyService.del(param.getApp(), param.getStream()); | |
| 635 | 501 | String url = streamProxyItem.getUrl() != null?streamProxyItem.getUrl():streamProxyItem.getSrc_url(); |
| 636 | - logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", app, streamId, url); | |
| 502 | + logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", param.getApp(), param.getStream(), url); | |
| 637 | 503 | }else if (streamProxyItem.isEnable_disable_none_reader()) { |
| 638 | 504 | // 无人观看停用 |
| 639 | 505 | ret.put("close", true); |
| 640 | 506 | // 修改数据 |
| 641 | - streamProxyService.stop(app, streamId); | |
| 507 | + streamProxyService.stop(param.getApp(), param.getStream()); | |
| 642 | 508 | }else { |
| 643 | 509 | ret.put("close", false); |
| 644 | 510 | } |
| ... | ... | @@ -660,35 +526,33 @@ public class ZLMHttpHookListener { |
| 660 | 526 | */ |
| 661 | 527 | @ResponseBody |
| 662 | 528 | @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); | |
| 529 | + public JSONObject onStreamNotFound(@RequestBody OnStreamNotFoundHookParam param){ | |
| 530 | + logger.info("[ZLM HOOK] 流未找到:{}->{}->{}/{}" + param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); | |
| 531 | + taskExecutor.execute(()->{ | |
| 532 | + MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); | |
| 533 | + if (userSetting.isAutoApplyPlay() && mediaInfo != null) { | |
| 534 | + if ("rtp".equals(param.getApp())) { | |
| 535 | + if (mediaInfo.isRtpEnable()) { | |
| 536 | + String[] s = param.getStream().split("_"); | |
| 537 | + if (s.length == 2) { | |
| 538 | + String deviceId = s[0]; | |
| 539 | + String channelId = s[1]; | |
| 540 | + Device device = redisCatchStorage.getDevice(deviceId); | |
| 541 | + if (device != null) { | |
| 542 | + playService.play(mediaInfo,deviceId, channelId, null, null, null); | |
| 543 | + } | |
| 681 | 544 | } |
| 682 | 545 | } |
| 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); | |
| 546 | + }else { | |
| 547 | + // 拉流代理 | |
| 548 | + StreamProxyItem streamProxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); | |
| 549 | + if (streamProxyByAppAndStream != null && streamProxyByAppAndStream.isEnable_disable_none_reader()) { | |
| 550 | + streamProxyService.start(param.getApp(), param.getStream()); | |
| 551 | + } | |
| 689 | 552 | } |
| 690 | 553 | } |
| 691 | - } | |
| 554 | + }); | |
| 555 | + | |
| 692 | 556 | |
| 693 | 557 | JSONObject ret = new JSONObject(); |
| 694 | 558 | ret.put("code", 0); |
| ... | ... | @@ -704,22 +568,20 @@ public class ZLMHttpHookListener { |
| 704 | 568 | @PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8") |
| 705 | 569 | public JSONObject onServerStarted(HttpServletRequest request, @RequestBody JSONObject jsonObject){ |
| 706 | 570 | |
| 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); | |
| 571 | + jsonObject.put("ip", request.getRemoteAddr()); | |
| 572 | + ZLMServerConfig zlmServerConfig = JSON.to(ZLMServerConfig.class, jsonObject); | |
| 573 | + zlmServerConfig.setIp(request.getRemoteAddr()); | |
| 574 | + logger.info("[ZLM HOOK] zlm 启动 " + zlmServerConfig.getGeneralMediaServerId()); | |
| 575 | + taskExecutor.execute(()->{ | |
| 576 | + List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started); | |
| 577 | + if (subscribes != null && subscribes.size() > 0) { | |
| 578 | + for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { | |
| 579 | + subscribe.response(null, jsonObject); | |
| 580 | + } | |
| 716 | 581 | } |
| 717 | - } | |
| 718 | - | |
| 719 | - ZLMServerConfig zlmServerConfig = jsonObject.to(ZLMServerConfig.class); | |
| 720 | - if (zlmServerConfig !=null ) { | |
| 721 | 582 | mediaServerService.zlmServerOnline(zlmServerConfig); |
| 722 | - } | |
| 583 | + }); | |
| 584 | + | |
| 723 | 585 | JSONObject ret = new JSONObject(); |
| 724 | 586 | ret.put("code", 0); |
| 725 | 587 | ret.put("msg", "success"); |
| ... | ... | @@ -731,33 +593,33 @@ public class ZLMHttpHookListener { |
| 731 | 593 | */ |
| 732 | 594 | @ResponseBody |
| 733 | 595 | @PostMapping(value = "/on_send_rtp_stopped", produces = "application/json;charset=UTF-8") |
| 734 | - public JSONObject onSendRtpStopped(HttpServletRequest request, @RequestBody JSONObject jsonObject){ | |
| 596 | + public JSONObject onSendRtpStopped(HttpServletRequest request, @RequestBody OnSendRtpStoppedHookParam param){ | |
| 735 | 597 | |
| 736 | - logger.info("[ ZLM HOOK ]on_send_rtp_stopped API调用,参数:" + jsonObject); | |
| 598 | + logger.info("[ZLM HOOK] 发送rtp被动关闭:{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream()); | |
| 737 | 599 | |
| 738 | 600 | JSONObject ret = new JSONObject(); |
| 739 | 601 | ret.put("code", 0); |
| 740 | 602 | ret.put("msg", "success"); |
| 741 | 603 | |
| 742 | 604 | // 查找对应的上级推流,发送停止 |
| 743 | - String app = jsonObject.getString("app"); | |
| 744 | - if (!"rtp".equals(app)) { | |
| 605 | + if (!"rtp".equals(param.getApp())) { | |
| 745 | 606 | return ret; |
| 746 | 607 | } |
| 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()); | |
| 608 | + taskExecutor.execute(()->{ | |
| 609 | + List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(param.getStream()); | |
| 610 | + if (sendRtpItems.size() > 0) { | |
| 611 | + for (SendRtpItem sendRtpItem : sendRtpItems) { | |
| 612 | + ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); | |
| 613 | + try { | |
| 614 | + commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId()); | |
| 615 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 616 | + logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); | |
| 617 | + } | |
| 618 | + redisCatchStorage.deleteSendRTPServer(parentPlatform.getServerGBId(), sendRtpItem.getChannelId(), | |
| 619 | + sendRtpItem.getCallId(), sendRtpItem.getStreamId()); | |
| 756 | 620 | } |
| 757 | - redisCatchStorage.deleteSendRTPServer(parentPlatform.getServerGBId(), sendRtpItem.getChannelId(), | |
| 758 | - sendRtpItem.getCallId(), sendRtpItem.getStreamId()); | |
| 759 | 621 | } |
| 760 | - } | |
| 622 | + }); | |
| 761 | 623 | |
| 762 | 624 | |
| 763 | 625 | 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/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
| ... | ... | @@ -4,6 +4,7 @@ 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/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/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; |
| ... | ... | @@ -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
| ... | ... | @@ -7,7 +7,6 @@ import com.genersoft.iot.vmp.common.StreamInfo; |
| 7 | 7 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 8 | 8 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 9 | 9 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 10 | -import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam; | |
| 11 | 10 | import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; |
| 12 | 11 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 13 | 12 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| ... | ... | @@ -16,7 +15,6 @@ import com.genersoft.iot.vmp.service.IMediaService; |
| 16 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | 16 | import org.springframework.stereotype.Service; |
| 18 | 17 | import org.springframework.util.ObjectUtils; |
| 19 | -import org.springframework.util.StringUtils; | |
| 20 | 18 | |
| 21 | 19 | @Service |
| 22 | 20 | public class MediaServiceImpl implements IMediaService { | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
| ... | ... | @@ -6,12 +6,10 @@ 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 | } |
| ... | ... | @@ -418,7 +413,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { |
| 418 | 413 | private void syncPullStream(String mediaServerId){ |
| 419 | 414 | MediaServerItem mediaServer = mediaServerService.getOne(mediaServerId); |
| 420 | 415 | if (mediaServer != null) { |
| 421 | - List<MediaItem> allPullStream = redisCatchStorage.getStreams(mediaServerId, "PULL"); | |
| 416 | + List<OnStreamChangedHookParam> allPullStream = redisCatchStorage.getStreams(mediaServerId, "PULL"); | |
| 422 | 417 | if (allPullStream.size() > 0) { |
| 423 | 418 | zlmresTfulUtils.getMediaList(mediaServer, jsonObject->{ |
| 424 | 419 | Map<String, StreamInfo> stringStreamInfoMap = new HashMap<>(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
| ... | ... | @@ -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/RedisStreamMsgListener.java
| ... | ... | @@ -5,7 +5,7 @@ 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
| ... | ... | @@ -5,9 +5,9 @@ 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
| ... | ... | @@ -7,7 +7,7 @@ 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 |
| ... | ... | @@ -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; | ... | ... |
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" v-if="deviceInfo.total === 0" :percentage="0" style="margin-top: 20px; font-size: 18px"></el-progress> | |
| 5 | + <el-progress :width="100" :stroke-width="8" type="circle" v-if="deviceInfo.total > 0" :percentage="(deviceInfo.online/deviceInfo.total*100).toFixed(2)" style="margin-top: 20px; font-size: 18px"></el-progress> | |
| 5 | 6 | <div class="resourceInfo"> |
| 6 | 7 | 设备总数:{{deviceInfo.total}}<br/> |
| 7 | 8 | 在线数:{{deviceInfo.online}} |
| 8 | 9 | </div> |
| 9 | 10 | </div> |
| 10 | 11 | <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> | |
| 12 | + <el-progress :width="100" :stroke-width="10" type="circle" v-if="channelInfo.total === 0" :percentage="0" style="margin-top: 20px"></el-progress> | |
| 13 | + <el-progress :width="100" :stroke-width="10" type="circle" v-if="channelInfo.total > 0" :percentage="(channelInfo.online/channelInfo.total*100).toFixed(2)" style="margin-top: 20px"></el-progress> | |
| 12 | 14 | <div class="resourceInfo"> |
| 13 | 15 | 通道总数:{{channelInfo.total}}<br/> |
| 14 | 16 | 在线数:{{channelInfo.online}} |
| 15 | 17 | </div> |
| 16 | 18 | </div> |
| 17 | 19 | <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> | |
| 20 | + <el-progress :width="100" :stroke-width="10" type="circle" v-if="pushInfo.total === 0" :percentage="0" style="margin-top: 20px"></el-progress> | |
| 21 | + <el-progress :width="100" :stroke-width="10" type="circle" v-if="pushInfo.total > 0" :percentage="(pushInfo.online/pushInfo.total*100).toFixed(2)" style="margin-top: 20px"></el-progress> | |
| 19 | 22 | <div class="resourceInfo"> |
| 20 | 23 | 推流总数:{{pushInfo.total}}<br/> |
| 21 | 24 | 在线数:{{pushInfo.online}} |
| 22 | 25 | </div> |
| 23 | 26 | </div> |
| 24 | 27 | <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> | |
| 28 | + <el-progress :width="100" :stroke-width="10" type="circle" v-if="proxyInfo.total === 0" :percentage="0" style="margin-top: 20px"></el-progress> | |
| 29 | + <el-progress :width="100" :stroke-width="10" type="circle" v-if="proxyInfo.total > 0" :percentage="(proxyInfo.online/proxyInfo.total*100).toFixed(2)" style="margin-top: 20px"></el-progress> | |
| 26 | 30 | <div class="resourceInfo"> |
| 27 | 31 | 拉流代理总数:{{proxyInfo.total}}<br/> |
| 28 | 32 | 在线数:{{proxyInfo.online}} | ... | ... |