修复添加级联平台是三个布尔字段无效的bug
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -70,6 +70,27 @@ public class ZLMHttpHookSubscribe {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void removeSubscribe(HookType type, JSONObject hookResponse) {
|
||||
Map<JSONObject, Event> 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
|
||||
|
||||
@@ -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->{
|
||||
|
||||
|
||||
@@ -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","");
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user