修复添加级联平台是三个布尔字段无效的bug
This commit is contained in:
@@ -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","");
|
||||
|
||||
Reference in New Issue
Block a user