Commit 0cc0a21206de86b6892331d97d891c628924f49b
1 parent
ce56d9c0
增加无人观看时关闭zlm拉流
Showing
1 changed file
with
15 additions
and
0 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| ... | ... | @@ -83,6 +83,9 @@ public class ZLMHttpHookListener { |
| 83 | 83 | @Autowired |
| 84 | 84 | private MediaConfig mediaConfig; |
| 85 | 85 | |
| 86 | + @Autowired | |
| 87 | + private ZLMRESTfulUtils zlmresTfulUtils; | |
| 88 | + | |
| 86 | 89 | /** |
| 87 | 90 | * 服务器定时上报时间,上报间隔可配置,默认10s上报一次 |
| 88 | 91 | * |
| ... | ... | @@ -465,6 +468,18 @@ public class ZLMHttpHookListener { |
| 465 | 468 | streamProxyService.del(app, streamId); |
| 466 | 469 | String url = streamProxyItem.getUrl() != null?streamProxyItem.getUrl():streamProxyItem.getSrc_url(); |
| 467 | 470 | logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", app, streamId, url); |
| 471 | + | |
| 472 | + }else if (streamProxyItem != null && streamProxyItem.isEnable()) { | |
| 473 | + MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); | |
| 474 | + if(null!=mediaServerItem){ | |
| 475 | + JSONObject jsonObject = zlmresTfulUtils.closeStreams(mediaServerItem,streamProxyItem.getApp(), streamProxyItem.getStream()); | |
| 476 | + if (jsonObject.getInteger("code") == 0) { | |
| 477 | + streamProxyItem.setEnable(false); | |
| 478 | + storager.updateStreamProxy(streamProxyItem); | |
| 479 | + } | |
| 480 | + }else { | |
| 481 | + ret.put("close", false); | |
| 482 | + } | |
| 468 | 483 | }else { |
| 469 | 484 | ret.put("close", false); |
| 470 | 485 | } | ... | ... |