From dd53e1800eb04044922a29880bdfccc2736ed8d1 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期五, 16 四月 2021 17:57:01 +0800 Subject: [PATCH] Merge pull request #87 from Dectinc/patch-1 --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 579e168..84c0898 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; -// import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; @@ -341,7 +340,7 @@ @Override public void playStreamCmd(Device device, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent) { try { - + if (device == null) return; String ssrc = streamSession.createPlaySsrc(); String streamId = null; if (rtpEnable) { @@ -366,9 +365,14 @@ // 娣诲姞璁㈤槄 JSONObject subscribeKey = new JSONObject(); subscribeKey.put("app", "rtp"); - subscribeKey.put("id", streamId); + subscribeKey.put("stream", streamId); + subscribeKey.put("regist", true); - subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, subscribeKey, event); + subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, json->{ + if (json.getJSONArray("tracks") == null) return; + event.response(json); + subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey); + }); // StringBuffer content = new StringBuffer(200); content.append("v=0\r\n"); @@ -466,9 +470,14 @@ // 娣诲姞璁㈤槄 JSONObject subscribeKey = new JSONObject(); subscribeKey.put("app", "rtp"); - subscribeKey.put("id", streamId); + subscribeKey.put("stream", streamId); + subscribeKey.put("regist", true); - subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, subscribeKey, event); + subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, json->{ + if (json.getJSONArray("tracks") == null) return; + event.response(json); + subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey); + }); StringBuffer content = new StringBuffer(200); content.append("v=0\r\n"); -- Gitblit v1.8.0