Commit 5ba39861d73ee8c0332a2e37c1e5e65531f14f28
1 parent
87acd73e
修复添加级联平台是三个布尔字段无效的bug
Showing
10 changed files
with
112 additions
and
32 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java
| ... | ... | @@ -81,7 +81,7 @@ public class ParentPlatform { |
| 81 | 81 | /** |
| 82 | 82 | * 允许云台控制 |
| 83 | 83 | */ |
| 84 | - private boolean PTZEnable; | |
| 84 | + private boolean ptz; | |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * RTCP流保活 |
| ... | ... | @@ -220,12 +220,12 @@ public class ParentPlatform { |
| 220 | 220 | this.characterSet = characterSet; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - public boolean isPTZEnable() { | |
| 224 | - return PTZEnable; | |
| 223 | + public boolean isPtz() { | |
| 224 | + return ptz; | |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - public void setPTZEnable(boolean PTZEnable) { | |
| 228 | - this.PTZEnable = PTZEnable; | |
| 227 | + public void setPtz(boolean ptz) { | |
| 228 | + this.ptz = ptz; | |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | public boolean isRtcp() { |
| ... | ... | @@ -251,4 +251,5 @@ public class ParentPlatform { |
| 251 | 251 | public void setChannelCount(int channelCount) { |
| 252 | 252 | this.channelCount = channelCount; |
| 253 | 253 | } |
| 254 | + | |
| 254 | 255 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| ... | ... | @@ -117,6 +117,10 @@ public class ZLMHttpHookListener { |
| 117 | 117 | if (logger.isDebugEnabled()) { |
| 118 | 118 | logger.debug("ZLM HOOK on_play API调用,参数:" + json.toString()); |
| 119 | 119 | } |
| 120 | + ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_play, json); | |
| 121 | + if (subscribe != null ) { | |
| 122 | + subscribe.response(json); | |
| 123 | + } | |
| 120 | 124 | JSONObject ret = new JSONObject(); |
| 121 | 125 | ret.put("code", 0); |
| 122 | 126 | ret.put("msg", "success"); | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
| ... | ... | @@ -70,6 +70,27 @@ public class ZLMHttpHookSubscribe { |
| 70 | 70 | return event; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | + public void removeSubscribe(HookType type, JSONObject hookResponse) { | |
| 74 | + Map<JSONObject, Event> eventMap = allSubscribes.get(type); | |
| 75 | + if (eventMap == null) { | |
| 76 | + return; | |
| 77 | + } | |
| 78 | + for (JSONObject key : eventMap.keySet()) { | |
| 79 | + Boolean result = null; | |
| 80 | + for (String s : key.keySet()) { | |
| 81 | + if (result == null) { | |
| 82 | + result = key.getString(s).equals(hookResponse.getString(s)); | |
| 83 | + }else { | |
| 84 | + result = result && key.getString(s).equals(hookResponse.getString(s)); | |
| 85 | + } | |
| 86 | + | |
| 87 | + } | |
| 88 | + if (result) { | |
| 89 | + eventMap.remove(key); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + } | |
| 93 | + | |
| 73 | 94 | /** |
| 74 | 95 | * 获取某个类型的所有的订阅 |
| 75 | 96 | * @param type | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
| ... | ... | @@ -42,6 +42,9 @@ public class ZLMMediaListManager { |
| 42 | 42 | @Autowired |
| 43 | 43 | private IStreamPushService streamPushService; |
| 44 | 44 | |
| 45 | + @Autowired | |
| 46 | + private ZLMHttpHookSubscribe subscribe; | |
| 47 | + | |
| 45 | 48 | |
| 46 | 49 | public void updateMediaList() { |
| 47 | 50 | storager.clearMediaList(); |
| ... | ... | @@ -66,6 +69,15 @@ public class ZLMMediaListManager { |
| 66 | 69 | |
| 67 | 70 | if (streamPushItems != null) { |
| 68 | 71 | storager.updateMediaList(streamPushItems); |
| 72 | + for (StreamPushItem streamPushItem : streamPushItems) { | |
| 73 | + JSONObject jsonObject = new JSONObject(); | |
| 74 | + jsonObject.put("app", streamPushItem.getApp()); | |
| 75 | + jsonObject.put("stream", streamPushItem.getStream()); | |
| 76 | + subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_play,jsonObject,(response)->{ | |
| 77 | + System.out.println(1222211111); | |
| 78 | + updateMedia(response.getString("app"), response.getString("stream")); | |
| 79 | + }); | |
| 80 | + } | |
| 69 | 81 | } |
| 70 | 82 | })); |
| 71 | 83 | |
| ... | ... | @@ -73,6 +85,12 @@ public class ZLMMediaListManager { |
| 73 | 85 | |
| 74 | 86 | public void addMedia(String app, String streamId) { |
| 75 | 87 | //使用异步更新推流 |
| 88 | + updateMedia(app, streamId); | |
| 89 | + } | |
| 90 | + | |
| 91 | + | |
| 92 | + public void updateMedia(String app, String streamId) { | |
| 93 | + //使用异步更新推流 | |
| 76 | 94 | zlmresTfulUtils.getMediaList(app, streamId, "rtmp", json->{ |
| 77 | 95 | |
| 78 | 96 | if (json == null) return; | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| ... | ... | @@ -123,7 +123,7 @@ public class ZLMRunner implements CommandLineRunner { |
| 123 | 123 | 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"); |
| 124 | 124 | param.put("hook.enable","1"); |
| 125 | 125 | param.put("hook.on_flow_report",""); |
| 126 | - param.put("hook.on_play",""); | |
| 126 | + param.put("hook.on_play",String.format("%s/on_play", hookPrex)); | |
| 127 | 127 | param.put("hook.on_http_access",""); |
| 128 | 128 | param.put("hook.on_publish",String.format("%s/on_publish", hookPrex)); |
| 129 | 129 | param.put("hook.on_record_mp4",""); | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java
| ... | ... | @@ -14,10 +14,10 @@ import java.util.List; |
| 14 | 14 | public interface ParentPlatformMapper { |
| 15 | 15 | |
| 16 | 16 | @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + |
| 17 | - " devicePort, username, password, expires, keepTimeout, transport, characterSet, PTZEnable, rtcp, " + | |
| 17 | + " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " + | |
| 18 | 18 | " status) " + |
| 19 | 19 | " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " + |
| 20 | - " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${PTZEnable}, ${rtcp}, " + | |
| 20 | + " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " + | |
| 21 | 21 | " ${status})") |
| 22 | 22 | int addParentPlatform(ParentPlatform parentPlatform); |
| 23 | 23 | |
| ... | ... | @@ -36,7 +36,7 @@ public interface ParentPlatformMapper { |
| 36 | 36 | "keepTimeout=#{keepTimeout}, " + |
| 37 | 37 | "transport=#{transport}, " + |
| 38 | 38 | "characterSet=#{characterSet}, " + |
| 39 | - "PTZEnable=#{PTZEnable}, " + | |
| 39 | + "ptz=#{ptz}, " + | |
| 40 | 40 | "rtcp=#{rtcp}, " + |
| 41 | 41 | "status=#{status} " + |
| 42 | 42 | "WHERE serverGBId=#{serverGBId}") | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.vmanager.server; | |
| 2 | + | |
| 3 | +import com.genersoft.iot.vmp.VManageBootstrap; | |
| 4 | +import com.genersoft.iot.vmp.utils.SpringBeanFactory; | |
| 5 | +import com.genersoft.iot.vmp.vmanager.gbStream.bean.GbStreamParam; | |
| 6 | +import gov.nist.javax.sip.SipStackImpl; | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.context.ConfigurableApplicationContext; | |
| 9 | +import org.springframework.web.bind.annotation.*; | |
| 10 | + | |
| 11 | +import javax.sip.ListeningPoint; | |
| 12 | +import javax.sip.ObjectInUseException; | |
| 13 | +import javax.sip.SipProvider; | |
| 14 | +import java.util.Iterator; | |
| 15 | + | |
| 16 | +@CrossOrigin | |
| 17 | +@RestController | |
| 18 | +@RequestMapping("/api/server") | |
| 19 | +public class ServerController { | |
| 20 | + | |
| 21 | + @Autowired | |
| 22 | + private ConfigurableApplicationContext context; | |
| 23 | + | |
| 24 | + | |
| 25 | + @RequestMapping(value = "/restart") | |
| 26 | + @ResponseBody | |
| 27 | + public Object restart(){ | |
| 28 | + Thread restartThread = new Thread(new Runnable() { | |
| 29 | + @Override | |
| 30 | + public void run() { | |
| 31 | + try { | |
| 32 | + Thread.sleep(3000); | |
| 33 | + SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); | |
| 34 | + SipStackImpl stack = (SipStackImpl)up.getSipStack(); | |
| 35 | + stack.stop(); | |
| 36 | + Iterator listener = stack.getListeningPoints(); | |
| 37 | + while (listener.hasNext()) { | |
| 38 | + stack.deleteListeningPoint((ListeningPoint) listener.next()); | |
| 39 | + } | |
| 40 | + Iterator providers = stack.getSipProviders(); | |
| 41 | + while (providers.hasNext()) { | |
| 42 | + stack.deleteSipProvider((SipProvider) providers.next()); | |
| 43 | + } | |
| 44 | + VManageBootstrap.restart(); | |
| 45 | + } catch (InterruptedException ignored) { | |
| 46 | + } catch (ObjectInUseException e) { | |
| 47 | + e.printStackTrace(); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + }); | |
| 51 | + | |
| 52 | + restartThread.setDaemon(false); | |
| 53 | + restartThread.start(); | |
| 54 | + return "success"; | |
| 55 | + } | |
| 56 | +} | ... | ... |
src/main/resources/wvp.sqlite
No preview for this file type
web_src/src/components/PushVideoList.vue
| ... | ... | @@ -15,8 +15,6 @@ |
| 15 | 15 | </el-table-column> |
| 16 | 16 | <el-table-column prop="stream" label="流ID" width="240" align="center"> |
| 17 | 17 | </el-table-column> |
| 18 | - <el-table-column prop="totalReaderCount" label="在线人数" width="240" align="center"> | |
| 19 | - </el-table-column> | |
| 20 | 18 | <el-table-column prop="gbId" label="国标编码" width="150" align="center"> |
| 21 | 19 | </el-table-column> |
| 22 | 20 | <el-table-column label="开始时间" align="center" > | ... | ... |
web_src/src/components/dialog/platformEdit.vue
| ... | ... | @@ -75,7 +75,7 @@ |
| 75 | 75 | </el-form-item> |
| 76 | 76 | <el-form-item label="其他选项"> |
| 77 | 77 | <el-checkbox label="启用" v-model="platform.enable" @change="checkExpires"></el-checkbox> |
| 78 | - <el-checkbox label="云台控制" v-model="platform.PTZEnable"></el-checkbox> | |
| 78 | + <el-checkbox label="云台控制" v-model="platform.ptz"></el-checkbox> | |
| 79 | 79 | <el-checkbox label="RTCP保活" v-model="platform.rtcp"></el-checkbox> |
| 80 | 80 | </el-form-item> |
| 81 | 81 | <el-form-item> |
| ... | ... | @@ -120,28 +120,10 @@ export default { |
| 120 | 120 | showDialog: false, |
| 121 | 121 | isLoging: false, |
| 122 | 122 | onSubmit_text: "立即创建", |
| 123 | - // platform: { | |
| 124 | - // enable: false, | |
| 125 | - // PTZEnable: true, | |
| 126 | - // rtcp: false, | |
| 127 | - // name: null, | |
| 128 | - // serverGBId: null, | |
| 129 | - // serverGBDomain: null, | |
| 130 | - // serverIP: null, | |
| 131 | - // serverPort: null, | |
| 132 | - // deviceGBId: null, | |
| 133 | - // deviceIp: null, | |
| 134 | - // devicePort: null, | |
| 135 | - // username: null, | |
| 136 | - // password: null, | |
| 137 | - // expires: 300, | |
| 138 | - // keepTimeout: 60, | |
| 139 | - // transport: "UDP", | |
| 140 | - // characterSet: "GB2312", | |
| 141 | - // }, | |
| 123 | + | |
| 142 | 124 | platform: { |
| 143 | 125 | enable: true, |
| 144 | - PTZEnable: true, | |
| 126 | + ptz: true, | |
| 145 | 127 | rtcp: false, |
| 146 | 128 | name: "测试001", |
| 147 | 129 | serverGBId: "34020000002000000001", | ... | ... |