diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java index 0aec8855..56d5e9ce 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java @@ -81,7 +81,7 @@ public class ParentPlatform { /** * 允许云台控制 */ - private boolean PTZEnable; + private boolean ptz; /** * RTCP流保活 @@ -220,12 +220,12 @@ public class ParentPlatform { this.characterSet = characterSet; } - public boolean isPTZEnable() { - return PTZEnable; + public boolean isPtz() { + return ptz; } - public void setPTZEnable(boolean PTZEnable) { - this.PTZEnable = PTZEnable; + public void setPtz(boolean ptz) { + this.ptz = ptz; } public boolean isRtcp() { @@ -251,4 +251,5 @@ public class ParentPlatform { public void setChannelCount(int channelCount) { this.channelCount = channelCount; } + } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index 0065b214..835dd9cb 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -117,6 +117,10 @@ public class ZLMHttpHookListener { if (logger.isDebugEnabled()) { logger.debug("ZLM HOOK on_play API调用,参数:" + json.toString()); } + ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_play, json); + if (subscribe != null ) { + subscribe.response(json); + } JSONObject ret = new JSONObject(); ret.put("code", 0); ret.put("msg", "success"); diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java index 5aee00cd..1633f432 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java @@ -70,6 +70,27 @@ public class ZLMHttpHookSubscribe { return event; } + public void removeSubscribe(HookType type, JSONObject hookResponse) { + Map eventMap = allSubscribes.get(type); + if (eventMap == null) { + return; + } + for (JSONObject key : eventMap.keySet()) { + Boolean result = null; + for (String s : key.keySet()) { + if (result == null) { + result = key.getString(s).equals(hookResponse.getString(s)); + }else { + result = result && key.getString(s).equals(hookResponse.getString(s)); + } + + } + if (result) { + eventMap.remove(key); + } + } + } + /** * 获取某个类型的所有的订阅 * @param type diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java index 1bf51621..659502e9 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java @@ -42,6 +42,9 @@ public class ZLMMediaListManager { @Autowired private IStreamPushService streamPushService; + @Autowired + private ZLMHttpHookSubscribe subscribe; + public void updateMediaList() { storager.clearMediaList(); @@ -66,12 +69,27 @@ public class ZLMMediaListManager { if (streamPushItems != null) { storager.updateMediaList(streamPushItems); + for (StreamPushItem streamPushItem : streamPushItems) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("app", streamPushItem.getApp()); + jsonObject.put("stream", streamPushItem.getStream()); + subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_play,jsonObject,(response)->{ + System.out.println(1222211111); + updateMedia(response.getString("app"), response.getString("stream")); + }); + } } })); } public void addMedia(String app, String streamId) { + //使用异步更新推流 + updateMedia(app, streamId); + } + + + public void updateMedia(String app, String streamId) { //使用异步更新推流 zlmresTfulUtils.getMediaList(app, streamId, "rtmp", json->{ diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java index edce4113..6e0bc607 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java @@ -123,7 +123,7 @@ public class ZLMRunner implements CommandLineRunner { param.put("ffmpeg.cmd","%s -fflags nobuffer -rtsp_transport tcp -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s"); param.put("hook.enable","1"); param.put("hook.on_flow_report",""); - param.put("hook.on_play",""); + param.put("hook.on_play",String.format("%s/on_play", hookPrex)); param.put("hook.on_http_access",""); param.put("hook.on_publish",String.format("%s/on_publish", hookPrex)); param.put("hook.on_record_mp4",""); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java index 257ca9ee..3049e5be 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java @@ -14,10 +14,10 @@ import java.util.List; public interface ParentPlatformMapper { @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + - " devicePort, username, password, expires, keepTimeout, transport, characterSet, PTZEnable, rtcp, " + + " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " + " status) " + " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " + - " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${PTZEnable}, ${rtcp}, " + + " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " + " ${status})") int addParentPlatform(ParentPlatform parentPlatform); @@ -36,7 +36,7 @@ public interface ParentPlatformMapper { "keepTimeout=#{keepTimeout}, " + "transport=#{transport}, " + "characterSet=#{characterSet}, " + - "PTZEnable=#{PTZEnable}, " + + "ptz=#{ptz}, " + "rtcp=#{rtcp}, " + "status=#{status} " + "WHERE serverGBId=#{serverGBId}") diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java new file mode 100644 index 00000000..675fc01f --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java @@ -0,0 +1,56 @@ +package com.genersoft.iot.vmp.vmanager.server; + +import com.genersoft.iot.vmp.VManageBootstrap; +import com.genersoft.iot.vmp.utils.SpringBeanFactory; +import com.genersoft.iot.vmp.vmanager.gbStream.bean.GbStreamParam; +import gov.nist.javax.sip.SipStackImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.web.bind.annotation.*; + +import javax.sip.ListeningPoint; +import javax.sip.ObjectInUseException; +import javax.sip.SipProvider; +import java.util.Iterator; + +@CrossOrigin +@RestController +@RequestMapping("/api/server") +public class ServerController { + + @Autowired + private ConfigurableApplicationContext context; + + + @RequestMapping(value = "/restart") + @ResponseBody + public Object restart(){ + Thread restartThread = new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(3000); + SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); + SipStackImpl stack = (SipStackImpl)up.getSipStack(); + stack.stop(); + Iterator listener = stack.getListeningPoints(); + while (listener.hasNext()) { + stack.deleteListeningPoint((ListeningPoint) listener.next()); + } + Iterator providers = stack.getSipProviders(); + while (providers.hasNext()) { + stack.deleteSipProvider((SipProvider) providers.next()); + } + VManageBootstrap.restart(); + } catch (InterruptedException ignored) { + } catch (ObjectInUseException e) { + e.printStackTrace(); + } + } + }); + + restartThread.setDaemon(false); + restartThread.start(); + return "success"; + } +} diff --git a/src/main/resources/wvp.sqlite b/src/main/resources/wvp.sqlite index 3cb64cf4..2e73cdb6 100644 Binary files a/src/main/resources/wvp.sqlite and b/src/main/resources/wvp.sqlite differ diff --git a/web_src/src/components/PushVideoList.vue b/web_src/src/components/PushVideoList.vue index 6e73f370..1199a391 100644 --- a/web_src/src/components/PushVideoList.vue +++ b/web_src/src/components/PushVideoList.vue @@ -15,8 +15,6 @@ - - diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue index 4a916e8a..c3c5ac9e 100644 --- a/web_src/src/components/dialog/platformEdit.vue +++ b/web_src/src/components/dialog/platformEdit.vue @@ -75,7 +75,7 @@ - + @@ -120,28 +120,10 @@ export default { showDialog: false, isLoging: false, onSubmit_text: "立即创建", - // platform: { - // enable: false, - // PTZEnable: true, - // rtcp: false, - // name: null, - // serverGBId: null, - // serverGBDomain: null, - // serverIP: null, - // serverPort: null, - // deviceGBId: null, - // deviceIp: null, - // devicePort: null, - // username: null, - // password: null, - // expires: 300, - // keepTimeout: 60, - // transport: "UDP", - // characterSet: "GB2312", - // }, + platform: { enable: true, - PTZEnable: true, + ptz: true, rtcp: false, name: "测试001", serverGBId: "34020000002000000001",