From 06bbe3fe01e5af9486c309693a975077df813f7c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 29 九月 2022 16:27:59 +0800
Subject: [PATCH] 添加第二种语音对讲实现

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java                                                   |  142 +++--
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java                                                            |   27 -
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java |    5 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java                            |    4 
 src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java                                                            |    2 
 pom.xml                                                                                                                           |    2 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java                                                       |   32 
 src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamPush.java                                                 |   42 +
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java                                 |   14 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java                                            |   33 +
 web_src/src/components/dialog/devicePlayer.vue                                                                                    |   61 +-
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java                                  |  154 +++---
 src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java                                                            |    2 
 src/main/java/com/genersoft/iot/vmp/service/IPlayService.java                                                                     |   13 
 web_src/config/index.js                                                                                                           |    4 
 src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java                                                               |    3 
 src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java                                                             |  386 +++++++++++----
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java                                                           |    2 
 src/main/java/com/genersoft/iot/vmp/gb28181/bean/AudioBroadcastCatch.java                                                         |   24 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java                                  |   40 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java                             |   22 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java                               |  191 ++-----
 src/main/java/com/genersoft/iot/vmp/conf/exception/SsrcTransactionNotFoundException.java                                          |    6 
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java                                                            |  153 +++++
 src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java                                                                   |    3 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java                                        |    2 
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java                                                     |   61 --
 src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java                                                       |   16 
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java                       |   18 
 29 files changed, 882 insertions(+), 582 deletions(-)

diff --git a/pom.xml b/pom.xml
index 25bdb81..94c8277 100644
--- a/pom.xml
+++ b/pom.xml
@@ -273,7 +273,6 @@
 					<dateFormat>yyyyMMdd</dateFormat>
 				</configuration>
 			</plugin>
-
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-surefire-plugin</artifactId>
@@ -282,7 +281,6 @@
 					<skipTests>true</skipTests>
 				</configuration>
 			</plugin>
-
 		</plugins>
 		<resources>
 			<resource>
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/exception/SsrcTransactionNotFoundException.java b/src/main/java/com/genersoft/iot/vmp/conf/exception/SsrcTransactionNotFoundException.java
index 4038cd1..0501518 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/exception/SsrcTransactionNotFoundException.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/exception/SsrcTransactionNotFoundException.java
@@ -39,12 +39,12 @@
     @Override
     public String getMessage() {
         StringBuffer msg = new StringBuffer();
-        msg.append(StringFormatter.format("缂撳瓨浜嬪姟淇℃伅鏈壘鍒帮紝device锛�%s channel: %s ",  deviceId, channelId));
+        msg.append(String.format("缂撳瓨浜嬪姟淇℃伅鏈壘鍒帮紝device锛�%s channel: %s ",  deviceId, channelId));
         if (callId != null) {
-            msg.append("callId: " + callId);
+            msg.append(",callId: " + callId);
         }
         if (stream != null) {
-            msg.append("stream: " + stream);
+            msg.append(",stream: " + stream);
         }
         return msg.toString();
     }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AudioBroadcastCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AudioBroadcastCatch.java
index 93a0d16..e2adddc 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AudioBroadcastCatch.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AudioBroadcastCatch.java
@@ -2,6 +2,7 @@
 
 
 import gov.nist.javax.sip.message.SIPRequest;
+import gov.nist.javax.sip.message.SIPResponse;
 import gov.nist.javax.sip.stack.SIPDialog;
 
 import javax.sip.Dialog;
@@ -40,12 +41,7 @@
     /**
      * 璇锋眰淇℃伅
      */
-    private SIPRequest request;
-
-    /**
-     * 浼氳瘽淇℃伅
-     */
-    private SIPDialog dialog;
+    private SipTransactionInfo sipTransactionInfo;
 
 
     public String getDeviceId() {
@@ -72,19 +68,15 @@
         this.status = status;
     }
 
-    public void setDialog(SIPDialog dialog) {
-        this.dialog = dialog;
+    public SipTransactionInfo getSipTransactionInfo() {
+        return sipTransactionInfo;
     }
 
-    public SIPDialog getDialog() {
-        return dialog;
+    public void setSipTransactionInfo(SipTransactionInfo sipTransactionInfo) {
+        this.sipTransactionInfo = sipTransactionInfo;
     }
 
-    public SIPRequest getRequest() {
-        return request;
-    }
-
-    public void setRequest(SIPRequest request) {
-        this.request = request;
+    public void setSipTransactionInfoByRequset(SIPResponse response) {
+        this.sipTransactionInfo = new SipTransactionInfo(response);
     }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java
index 24d509f..a3098fb 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java
@@ -2,7 +2,7 @@
 
 public enum InviteStreamType {
 
-    PLAY,PLAYBACK,PUSH,PROXY,CLOUD_RECORD_PUSH,CLOUD_RECORD_PROXY
+    PLAY,PLAYBACK,PUSH,PROXY,CLOUD_RECORD_PUSH,CLOUD_RECORD_PROXY,TALK
 
 
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
index e5b995e..a4ec52a 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
@@ -1,5 +1,6 @@
 package com.genersoft.iot.vmp.gb28181.event;
 
+import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
 import com.genersoft.iot.vmp.gb28181.bean.DeviceNotFoundEvent;
 import gov.nist.javax.sip.message.SIPRequest;
 import org.slf4j.Logger;
@@ -57,7 +58,7 @@
         logger.debug("errorSubscribes.size:{}",errorSubscribes.size());
     }
 
-    public interface Event { void response(EventResult eventResult) ;
+    public interface Event { void response(EventResult eventResult);
     }
 
     /**
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
index 860560d..f95dc13 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
@@ -8,18 +8,12 @@
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import gov.nist.javax.sip.message.SIPRequest;
-import gov.nist.javax.sip.message.SIPRequest;
-import gov.nist.javax.sip.stack.SIPDialog;
 
-import javax.sip.Dialog;
-import javax.sip.InvalidArgumentException;
-import javax.sip.SipException;
-import java.text.ParseException;
 import javax.sip.InvalidArgumentException;
 import javax.sip.PeerUnavailableException;
 import javax.sip.SipException;
-import javax.sip.message.Request;
 import java.text.ParseException;
+import javax.sip.message.Request;
 
 /**    
  * @description:璁惧鑳藉姏鎺ュ彛锛岀敤浜庡畾涔夎澶囩殑鎺у埗銆佹煡璇㈣兘鍔�   
@@ -130,13 +124,17 @@
 						   String startTime, String endTime, int downloadSpeed, InviteStreamCallback inviteStreamCallback, InviteStreamCallback hookEvent,
 						   SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
 
+
 	/**
 	 * 瑙嗛娴佸仠姝�
 	 */
-	void streamByeCmd(String deviceId, String channelId, String stream, String callId, SipSubscribe.Event okEvent);
-	void streamByeCmd(String deviceId, String channelId, String stream, String callId);
 	void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
+
+	void talkStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, String callId, ZlmHttpHookSubscribe.Event event, ZlmHttpHookSubscribe.Event eventForPush, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
+
 	void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;
+
+	void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
 
 	/**
 	 * 鍥炴斁鏆傚仠
@@ -168,22 +166,12 @@
 
 
     /**
-
-	/**
-	 * 璇煶骞挎挱
-	 * 
-	 * @param device  瑙嗛璁惧
-	 */
-	boolean audioBroadcastCmd(Device device, String channelId, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent);
-	void audioBroadcastCmd(Device device,String channelId);
-
-	/**
+	 * /**
 	 * 璇煶骞挎挱
 	 *
-	 * @param device  瑙嗛璁惧
+	 * @param device 瑙嗛璁惧
 	 */
-	void audioBroadcastCmd(Device device, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
-	void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException;
+	void audioBroadcastCmd(Device device, String channelId, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
 
 	/**
 	 * 闊宠棰戝綍鍍忔帶鍒�
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
index 1374ddf..1f4f73c 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
@@ -326,4 +326,37 @@
 
 		return request;
 	}
+
+	public Request createBroadcastMessageRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
+		Request request = null;
+		// sipuri
+		SipURI requestURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
+		// via
+		ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
+		ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
+		viaHeader.setRPort();
+		viaHeaders.add(viaHeader);
+		// from
+		SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
+		Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
+		FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag);
+		// to
+		SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
+		Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
+		ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag);
+
+		// Forwards
+		MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
+		// ceq
+		CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
+
+		ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
+
+		request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
+				toHeader, viaHeaders, maxForwards, contentTypeHeader, content);
+
+		request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
+
+		return request;
+	}
 }
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 8d70f2f..5d3caf7 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
@@ -2,7 +2,6 @@
 
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.StreamInfo;
-import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
@@ -12,45 +11,32 @@
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider;
 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
+import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
+import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamPush;
 import com.genersoft.iot.vmp.utils.DateUtil;
 import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
 import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
-import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.GitUtil;
-import gov.nist.javax.sip.SIPConstants;
 import gov.nist.javax.sip.SipProviderImpl;
-import gov.nist.javax.sip.SipStackImpl;
 import gov.nist.javax.sip.message.SIPRequest;
 import gov.nist.javax.sip.message.SIPResponse;
-import gov.nist.javax.sip.stack.SIPClientTransaction;
-import gov.nist.javax.sip.stack.SIPClientTransactionImpl;
-import gov.nist.javax.sip.stack.SIPDialog;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.DependsOn;
-import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
 
 import javax.sip.*;
-import javax.sip.address.Address;
-import javax.sip.address.SipURI;
 import javax.sip.header.*;
 import javax.sip.message.Request;
-import javax.sip.message.Response;
-import java.lang.reflect.Field;
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
 
 /**
  * @description:璁惧鑳藉姏鎺ュ彛锛岀敤浜庡畾涔夎澶囩殑鎺у埗銆佹煡璇㈣兘鍔�
@@ -97,6 +83,9 @@
 
     @Autowired
     private IMediaServerService mediaServerService;
+
+    @Autowired
+    private ZLMRTPServerFactory zlmrtpServerFactory;
 
 
     /**
@@ -591,11 +580,73 @@
         });
     }
 
+    @Override
+    public void talkStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, String callId, ZlmHttpHookSubscribe.Event event, ZlmHttpHookSubscribe.Event eventForPush, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
+
+        String stream = ssrcInfo.getStream();
+
+        if (device == null) {
+            return;
+        }
+        if (!mediaServerItem.isRtpEnable()) {
+            // 鍗曠鍙f殏涓嶆敮鎸佽闊冲璁�
+            logger.info("[璇煶瀵硅] 鍗曠鍙f殏涓嶆敮鎸佹鎿嶄綔");
+            return;
+        }
+
+        logger.info("[璇煶瀵硅] {} 鍒嗛厤鐨刏LM涓�: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort());
+        HookSubscribeForStreamChange hookSubscribeForStreamChange = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId());
+        subscribe.addSubscribe(hookSubscribeForStreamChange, (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
+            if (event != null) {
+                event.response(mediaServerItemInUse, json);
+                subscribe.removeSubscribe(hookSubscribeForStreamChange);
+            }
+        });
+
+        CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
+                : udpSipProvider.getNewCallId();
+        callIdHeader.setCallId(callId);
+        HookSubscribeForStreamPush hookSubscribeForStreamPush = HookSubscribeFactory.on_publish("rtp", stream,  null, mediaServerItem.getId());
+        subscribe.addSubscribe(hookSubscribeForStreamPush, (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
+            if (eventForPush != null) {
+                eventForPush.response(mediaServerItemInUse, json);
+            }
+        });
+        //
+        StringBuffer content = new StringBuffer(200);
+        content.append("v=0\r\n");
+        content.append("o=" + channelId + " 0 0 IN IP4 " + mediaServerItem.getSdpIp() + "\r\n");
+        content.append("s=Talk\r\n");
+        content.append("c=IN IP4 " + mediaServerItem.getSdpIp() + "\r\n");
+        content.append("t=0 0\r\n");
+
+        content.append("m=audio " + ssrcInfo.getPort() + " RTP/AVP 8\r\n");
+        content.append("a=sendrecv\r\n");
+        content.append("a=rtpmap:8 PCMA/8000\r\n");
+
+        content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc
+        // f瀛楁:f= v/缂栫爜鏍煎紡/鍒嗚鲸鐜�/甯х巼/鐮佺巼绫诲瀷/鐮佺巼澶у皬a/缂栫爜鏍煎紡/鐮佺巼澶у皬/閲囨牱鐜�
+        content.append("f=v/////a/1/8/1" + "\r\n");
+
+        Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(), callIdHeader);
+        transmitRequest(device.getTransport(), request, (e -> {
+            streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
+            mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
+            errorEvent.response(e);
+        }), e -> {
+            // 杩欓噷涓轰緥閬垮厤涓�涓�氶亾鐨勭偣鎾彧鏈変竴涓猚allID杩欎釜鍙傛暟浣跨敤涓�涓浐瀹氬��
+            ResponseEvent responseEvent = (ResponseEvent) e.event;
+            SIPResponse response = (SIPResponse) responseEvent.getResponse();
+            streamSession.put(device.getDeviceId(), channelId, "talk", stream, ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.play);
+            okEvent.response(e);
+        });
+    }
+
     /**
      * 瑙嗛娴佸仠姝�, 涓嶄娇鐢ㄥ洖璋�
      */
     @Override
-    public void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException {
+    public synchronized void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException {
         streamByeCmd(device, channelId, stream, callId, null);
     }
 
@@ -603,7 +654,7 @@
      * 瑙嗛娴佸仠姝�
      */
     @Override
-    public void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
+    public synchronized void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
         SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, callId, stream);
         if (ssrcTransaction == null) {
             throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream);
@@ -617,67 +668,34 @@
         transmitRequest(device.getTransport(), byteRequest, null, okEvent);
     }
 
-    /**
+    @Override
+    public synchronized void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
+        Request byteRequest = headerProvider.createByteRequest(device, channelId, sipTransactionInfo);
+        transmitRequest(device.getTransport(), byteRequest, null, okEvent);
+    }
+
+	/**
      * 璇煶骞挎挱
      *
      * @param device 瑙嗛璁惧
      */
-    @Override
-    public void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException {
-
-        StringBuffer broadcastXml = new StringBuffer(200);
-        String charset = device.getCharset();
-        broadcastXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
-        broadcastXml.append("<Notify>\r\n");
-        broadcastXml.append("<CmdType>Broadcast</CmdType>\r\n");
-        broadcastXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
-        broadcastXml.append("<SourceID>" + sipConfig.getId() + "</SourceID>\r\n");
-        broadcastXml.append("<TargetID>" + device.getDeviceId() + "</TargetID>\r\n");
-        broadcastXml.append("</Notify>\r\n");
-	/**
-	 * 璇煶骞挎挱
-	 *
-	 * @param device  瑙嗛璁惧
-	 */
 	@Override
-	public boolean audioBroadcastCmd(Device device,String channelId, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) {
-		try {
-			StringBuffer broadcastXml = new StringBuffer(200);
-			String charset = device.getCharset();
-			broadcastXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
-			broadcastXml.append("<Notify>\r\n");
-			broadcastXml.append("<CmdType>Broadcast</CmdType>\r\n");
-			broadcastXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
-			broadcastXml.append("<SourceID>" + sipConfig.getId() + "</SourceID>\r\n");
-			broadcastXml.append("<TargetID>" + channelId + "</TargetID>\r\n");
-			broadcastXml.append("</Notify>\r\n");
-
-        CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
-                : udpSipProvider.getNewCallId();
-
-        Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader);
-        transmitRequest(device.getTransport(), request);
-
-    }
-
-    @Override
-    public void audioBroadcastCmd(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
-
+	public void audioBroadcastCmd(Device device, String channelId, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
         StringBuffer broadcastXml = new StringBuffer(200);
         String charset = device.getCharset();
         broadcastXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
         broadcastXml.append("<Notify>\r\n");
         broadcastXml.append("<CmdType>Broadcast</CmdType>\r\n");
-        broadcastXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
+        broadcastXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
         broadcastXml.append("<SourceID>" + sipConfig.getId() + "</SourceID>\r\n");
-        broadcastXml.append("<TargetID>" + device.getDeviceId() + "</TargetID>\r\n");
+        broadcastXml.append("<TargetID>" + channelId + "</TargetID>\r\n");
         broadcastXml.append("</Notify>\r\n");
 
         CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
                 : udpSipProvider.getNewCallId();
 
         Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader);
-        transmitRequest(device.getTransport(), request, errorEvent);
+        transmitRequest(device.getTransport(), request, errorEvent, okEvent);
 
     }
 
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
index 7712350..0ab542b 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
@@ -676,7 +676,7 @@
     }
 
     @Override
-    public void streamByeCmd(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException {
+    public synchronized void streamByeCmd(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException {
         if (sendRtpItem == null ) {
             logger.info("[鍚戜笂绾у彂閫丅YE]锛� sendRtpItem 涓篘ULL");
             return;
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
index c005f2c..c61e2c1 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
@@ -1,12 +1,12 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request;
 
+import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
 import gov.nist.javax.sip.SipProviderImpl;
 import gov.nist.javax.sip.SipStackImpl;
 import gov.nist.javax.sip.message.SIPRequest;
 import gov.nist.javax.sip.message.SIPResponse;
-import gov.nist.javax.sip.stack.SIPServerTransaction;
 import gov.nist.javax.sip.stack.SIPServerTransactionImpl;
 import org.apache.commons.lang3.ArrayUtils;
 import org.dom4j.Document;
@@ -27,8 +27,6 @@
 import javax.sip.message.Request;
 import javax.sip.message.Response;
 import java.io.ByteArrayInputStream;
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -51,6 +49,9 @@
 	@Qualifier(value="udpSipProvider")
 	private SipProviderImpl udpSipProvider;
 
+	@Autowired
+	private SipConfig sipConfig;
+
 	/**
 	 * 鏍规嵁 RequestEvent 鑾峰彇 ServerTransaction
 	 * @param evt
@@ -60,13 +61,15 @@
 		Request request = evt.getRequest();
 		SIPServerTransactionImpl serverTransaction = (SIPServerTransactionImpl)evt.getServerTransaction();
 		// 鍒ゆ柇TCP杩樻槸UDP
+		boolean isTcp = false;
 		ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
 		String transport = reqViaHeader.getTransport();
+		if (transport.equalsIgnoreCase("TCP")) {
+			isTcp = true;
+		}
 		if (serverTransaction != null && serverTransaction.getOriginalRequest() == null) {
 			serverTransaction.setOriginalRequest((SIPRequest) evt.getRequest());
 		}
-		boolean isTcp = "TCP".equals(transport);
-
 		if (serverTransaction == null) {
 			try {
 				if (isTcp) {
@@ -187,7 +190,6 @@
 	 * 鍥炲甯dp鐨�200
 	 */
 	public SIPResponse responseSdpAck(ServerTransaction serverTransaction, String sdp, ParentPlatform platform) throws SipException, InvalidArgumentException, ParseException {
-
 		ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
 
 		// 鍏煎鍥芥爣涓殑浣跨敤缂栫爜@鍩熷悕浣滀负RequestURI鐨勬儏鍐�
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
index 9bc10a6..3e7fbeb 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
@@ -2,6 +2,7 @@
 
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.conf.DynamicTask;
+import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
@@ -14,6 +15,7 @@
 import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
 import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
+import com.genersoft.iot.vmp.service.IDeviceService;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.service.bean.RequestPushStreamMsg;
 import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener;
@@ -21,7 +23,6 @@
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import gov.nist.javax.sip.message.SIPRequest;
 import gov.nist.javax.sip.stack.SIPDialog;
-import com.genersoft.iot.vmp.utils.SerializeUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.InitializingBean;
@@ -82,6 +83,9 @@
 	private ISIPCommander cmder;
 
 	@Autowired
+	private IDeviceService deviceService;
+
+	@Autowired
 	private ISIPCommanderForPlatform commanderForPlatform;
 
 	@Autowired
@@ -106,7 +110,7 @@
 		// 鍙栨秷璁剧疆鐨勮秴鏃朵换鍔�
 		dynamicTask.stop(callIdHeader.getCallId());
 		String channelId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser();
-		SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(platformGbId, channelId, null, callIdHeader.getCallId());
+		SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId());
 		if (sendRtpItem == null) {
 			logger.warn("[鏀跺埌ACK]锛氭湭鎵惧埌閫氶亾({})鐨勬帹娴佷俊鎭�", channelId);
 			return;
@@ -123,7 +127,7 @@
 		param.put("pt", sendRtpItem.getPt());
 		param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0");
 		param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0");
-		if (!sendRtpItem.isTcp() && parentPlatform.isRtcp()) {
+		if (!sendRtpItem.isTcp() && parentPlatform != null && parentPlatform.isRtcp()) {
 			// 寮�鍚痳tcp淇濇椿
 			param.put("udp_rtcp_timeout", "1");
 		}
@@ -141,29 +145,28 @@
 			if (jsonObject == null) {
 				logger.error("RTP鎺ㄦ祦澶辫触: 璇锋鏌LM鏈嶅姟");
 			} else if (jsonObject.getInteger("code") == 0) {
-
-				if (sendRtpItem.isOnlyAudio()) {
-					AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
-					audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.Ok);
-					audioBroadcastCatch.setDialog((SIPDialog) evt.getDialog());
-					audioBroadcastCatch.setRequest((SIPRequest) evt.getRequest());
-					audioBroadcastManager.update(audioBroadcastCatch);
-					String waiteStreamTimeoutTaskKey = "waite-stream-" + audioBroadcastCatch.getDeviceId() + audioBroadcastCatch.getChannelId();
-					dynamicTask.stop(waiteStreamTimeoutTaskKey);
-				}
 				logger.info("RTP鎺ㄦ祦鎴愬姛[ {}/{} ]锛寋}->{}:{}, ", param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port"));
 			} else {
 				logger.error("RTP鎺ㄦ祦澶辫触: {}, 鍙傛暟锛歿}", jsonObject.getString("msg"), JSONObject.toJSON(param));
 				if (sendRtpItem.isOnlyAudio()) {
 					// 璇煶瀵硅
-					try {
-						cmder.streamByeCmd((SIPDialog) evt.getDialog(), sendRtpItem.getChannelId(), (SIPRequest) evt.getRequest(), null);
-					} catch (SipException | ParseException | InvalidArgumentException e) {
-						logger.error("[鍛戒护鍙戦�佸け璐 鍋滄璇煶瀵硅: {}", e.getMessage());
+					Device device = deviceService.queryDevice(platformGbId);
+					if (device != null) {
+						try {
+							cmder.streamByeCmd(device, sendRtpItem.getChannelId(), sendRtpItem.getStreamId(), null);
+						} catch (SipException | ParseException | InvalidArgumentException |
+								 SsrcTransactionNotFoundException e) {
+							logger.error("[鍛戒护鍙戦�佸け璐 鍋滄璇煶瀵硅: {}", e.getMessage());
+						}
 					}
+
 				} else {
 					// 鍚戜笂绾у钩鍙�
-					commanderForPlatform.streamByeCmd(parentPlatform, callIdHeader.getCallId());
+					try {
+						commanderForPlatform.streamByeCmd(parentPlatform, callIdHeader.getCallId());
+					} catch (SipException | InvalidArgumentException | ParseException e) {
+						logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈锛� 鍥炲BYE: {}", e.getMessage());
+					}
 				}
 				if (mediaInfo == null) {
 					RequestPushStreamMsg requestPushStreamMsg = RequestPushStreamMsg.getInstance(
@@ -179,7 +182,6 @@
 				}
 
 
-			}
 		}
 	}
 	private void startSendRtpStreamHand(RequestEvent evt, SendRtpItem sendRtpItem, ParentPlatform parentPlatform,
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
index a20030f..1192b07 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
@@ -2,10 +2,8 @@
 
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
-import com.genersoft.iot.vmp.gb28181.bean.Device;
-import com.genersoft.iot.vmp.gb28181.bean.InviteStreamType;
-import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
-import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
+import com.genersoft.iot.vmp.gb28181.bean.*;
+import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
@@ -55,6 +53,9 @@
 	private IDeviceService deviceService;
 
 	@Autowired
+	private AudioBroadcastManager audioBroadcastManager;
+
+	@Autowired
 	private IVideoManagerStorage storager;
 
 	@Autowired
@@ -91,78 +92,79 @@
 			logger.error("[鍥炲BYE淇℃伅澶辫触]锛寋}", e.getMessage());
 		}
 		CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME);
-			String platformGbId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser();
-			String channelId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser();
-			SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(platformGbId, channelId, null, callIdHeader.getCallId());
-			logger.info("[鏀跺埌bye] {}/{}", platformGbId, channelId);
-			if (sendRtpItem != null){
-				String streamId = sendRtpItem.getStreamId();
-				Map<String, Object> param = new HashMap<>();
-				param.put("vhost","__defaultVhost__");
-				param.put("app",sendRtpItem.getApp());
-				param.put("stream",streamId);
-				param.put("ssrc",sendRtpItem.getSsrc());
-				logger.info("[鏀跺埌bye] 鍋滄鍚戜笂绾ф帹娴侊細{}", streamId);
-				MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
-				redisCatchStorage.deleteSendRTPServer(platformGbId, channelId, callIdHeader.getCallId(), null);
-				zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
-				int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
-				if (totalReaderCount <= 0) {
-					logger.info("[鏀跺埌bye] {} 鏃犲叾瀹冭鐪嬭�咃紝閫氱煡璁惧鍋滄鎺ㄦ祦", streamId);
-					if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) {
-						Device device = deviceService.queryDevice(sendRtpItem.getDeviceId());
-						if (device == null) {
-							logger.info("[鏀跺埌bye] {} 閫氱煡璁惧鍋滄鎺ㄦ祦鏃舵湭鎵惧埌璁惧淇℃伅", streamId);
-						}
-						try {
-							logger.warn("[鍋滄鐐规挱] {}/{}", sendRtpItem.getDeviceId(), channelId);
-							cmder.streamByeCmd(device, channelId, streamId, null);
-						} catch (InvalidArgumentException | ParseException | SipException |
-								 SsrcTransactionNotFoundException e) {
-							logger.error("[鏀跺埌bye] {} 鏃犲叾瀹冭鐪嬭�咃紝閫氱煡璁惧鍋滄鎺ㄦ祦锛� 鍙戦�丅YE澶辫触 {}",streamId, e.getMessage());
-						}
-					}
-					if (sendRtpItem.isOnlyAudio()) {
-						playService.stopAudioBroadcast(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
-					}
-					if (sendRtpItem.getPlayType().equals(InviteStreamType.PUSH)) {
-						MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0,
-								sendRtpItem.getApp(), sendRtpItem.getStreamId(), sendRtpItem.getChannelId(),
-								sendRtpItem.getPlatformId(), null, null, sendRtpItem.getMediaServerId());
-						redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel);
-					}
-				}
-			}
-			// 鍙兘鏄澶囦富鍔ㄥ仠姝�
-			Device device = storager.queryVideoDeviceByChannelId(platformGbId);
-			if (device != null) {
-				storager.stopPlay(device.getDeviceId(), channelId);
-				StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
-				if (streamInfo != null) {
-					redisCatchStorage.stopPlay(streamInfo);
-					mediaServerService.closeRTPServer(streamInfo.getMediaServerId(), streamInfo.getStream());
-				}
-				SsrcTransaction ssrcTransactionForPlay = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, "play", null);
-				if (ssrcTransactionForPlay != null){
-					if (ssrcTransactionForPlay.getCallId().equals(callIdHeader.getCallId())){
-						// 閲婃斁ssrc
-						MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransactionForPlay.getMediaServerId());
-						if (mediaServerItem != null) {
-							mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransactionForPlay.getSsrc());
-						}
-						streamSession.remove(device.getDeviceId(), channelId, ssrcTransactionForPlay.getStream());
-					}
-				}
-				SsrcTransaction ssrcTransactionForPlayBack = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, callIdHeader.getCallId(), null);
-				if (ssrcTransactionForPlayBack != null) {
-					// 閲婃斁ssrc
-					MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransactionForPlayBack.getMediaServerId());
-					if (mediaServerItem != null) {
-						mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransactionForPlayBack.getSsrc());
-					}
-					streamSession.remove(device.getDeviceId(), channelId, ssrcTransactionForPlayBack.getStream());
-				}
-			}
+		SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId());
 
+		if (sendRtpItem != null){
+			logger.info("[鏀跺埌bye] {}/{}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId());
+			String streamId = sendRtpItem.getStreamId();
+			Map<String, Object> param = new HashMap<>();
+			param.put("vhost","__defaultVhost__");
+			param.put("app",sendRtpItem.getApp());
+			param.put("stream",streamId);
+			param.put("ssrc",sendRtpItem.getSsrc());
+			logger.info("[鏀跺埌bye] 鍋滄鍚戜笂绾ф帹娴侊細{}", streamId);
+			MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
+			redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), callIdHeader.getCallId(), null);
+			zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
+			int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
+			if (totalReaderCount <= 0) {
+				logger.info("[鏀跺埌bye] {} 鏃犲叾瀹冭鐪嬭�咃紝閫氱煡璁惧鍋滄鎺ㄦ祦", streamId);
+				if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) {
+					Device device = deviceService.queryDevice(sendRtpItem.getDeviceId());
+					if (device == null) {
+						logger.info("[鏀跺埌bye] {} 閫氱煡璁惧鍋滄鎺ㄦ祦鏃舵湭鎵惧埌璁惧淇℃伅", streamId);
+					}
+					try {
+						logger.warn("[鍋滄鐐规挱] {}/{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+						cmder.streamByeCmd(device, sendRtpItem.getChannelId(), streamId, null);
+					} catch (InvalidArgumentException | ParseException | SipException |
+							 SsrcTransactionNotFoundException e) {
+						logger.error("[鏀跺埌bye] {} 鏃犲叾瀹冭鐪嬭�咃紝閫氱煡璁惧鍋滄鎺ㄦ祦锛� 鍙戦�丅YE澶辫触 {}",streamId, e.getMessage());
+					}
+				}
+
+				if (sendRtpItem.getPlayType().equals(InviteStreamType.PUSH)) {
+					MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0,
+							sendRtpItem.getApp(), sendRtpItem.getStreamId(), sendRtpItem.getChannelId(),
+							sendRtpItem.getPlatformId(), null, null, sendRtpItem.getMediaServerId());
+					redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel);
+				}
+			}
+			playService.stopAudioBroadcast(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+		}
+
+		String platformGbId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser();
+		String channelId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser();
+
+		// 鍙兘鏄澶囦富鍔ㄥ仠姝�
+		Device device = storager.queryVideoDeviceByChannelId(platformGbId);
+		if (device != null) {
+			storager.stopPlay(device.getDeviceId(), channelId);
+			StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
+			if (streamInfo != null) {
+				redisCatchStorage.stopPlay(streamInfo);
+				mediaServerService.closeRTPServer(streamInfo.getMediaServerId(), streamInfo.getStream());
+			}
+			SsrcTransaction ssrcTransactionForPlay = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, "play", null);
+			if (ssrcTransactionForPlay != null){
+				if (ssrcTransactionForPlay.getCallId().equals(callIdHeader.getCallId())){
+					// 閲婃斁ssrc
+					MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransactionForPlay.getMediaServerId());
+					if (mediaServerItem != null) {
+						mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransactionForPlay.getSsrc());
+					}
+					streamSession.remove(device.getDeviceId(), channelId, ssrcTransactionForPlay.getStream());
+				}
+			}
+			SsrcTransaction ssrcTransactionForPlayBack = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, callIdHeader.getCallId(), null);
+			if (ssrcTransactionForPlayBack != null) {
+				// 閲婃斁ssrc
+				MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransactionForPlayBack.getMediaServerId());
+				if (mediaServerItem != null) {
+					mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransactionForPlayBack.getSsrc());
+				}
+				streamSession.remove(device.getDeviceId(), channelId, ssrcTransactionForPlayBack.getStream());
+			}
+		}
 	}
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
index 49a4452..78adfd1 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
@@ -1,11 +1,10 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
 import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
@@ -14,7 +13,8 @@
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
@@ -30,19 +30,15 @@
 import com.genersoft.iot.vmp.service.IStreamPushService;
 import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
-import com.genersoft.iot.vmp.service.impl.RedisGbPlayMsgListener;
 import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener;
 import com.genersoft.iot.vmp.service.redisMsg.RedisPushStreamResponseListener;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.DateUtil;
-import com.genersoft.iot.vmp.utils.SerializeUtils;
 import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import gov.nist.javax.sdp.TimeDescriptionImpl;
 import gov.nist.javax.sdp.fields.TimeField;
-import gov.nist.javax.sip.message.SIPRequest;
-import gov.nist.javax.sip.stack.SIPDialog;
 import gov.nist.javax.sip.message.SIPRequest;
 import gov.nist.javax.sip.message.SIPResponse;
 import org.slf4j.Logger;
@@ -72,7 +68,7 @@
     private final String method = "INVITE";
 
     @Autowired
-    private SIPCommanderFroPlatform cmderFroPlatform;
+    private ISIPCommanderForPlatform cmderFroPlatform;
 
     @Autowired
     private IVideoManagerStorage storager;
@@ -174,7 +170,7 @@
             // 鏌ヨ璇锋眰鏄惁鏉ヨ嚜涓婄骇骞冲彴\璁惧
             ParentPlatform platform = storager.queryParentPlatByServerGBId(requesterId);
             if (platform == null) {
-                inviteFromDeviceHandle(serverTransaction, requesterId);
+                inviteFromDeviceHandle(serverTransaction, requesterId, channelId);
             } else {
                 // 鏌ヨ骞冲彴涓嬫槸鍚︽湁璇ラ�氶亾
                 DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId);
@@ -393,14 +389,15 @@
                     };
                     SipSubscribe.Event errorEvent = ((event) -> {
                         // 鏈煡閿欒銆傜洿鎺ヨ浆鍙戣澶囩偣鎾殑閿欒
-                        Response response = null;
                         try {
-                            response = getMessageFactory().createResponse(event.statusCode, evt.getRequest());
+                            Response response = getMessageFactory().createResponse(event.statusCode, evt.getRequest());
                             serverTransaction.sendResponse(response);
                             System.out.println("鏈煡閿欒銆傜洿鎺ヨ浆鍙戣澶囩偣鎾殑閿欒");
                             if (serverTransaction.getDialog() != null) {
                                 serverTransaction.getDialog().delete();
                             }
+                            serverTransaction.getDialog().delete();
+
                         } catch (ParseException | SipException | InvalidArgumentException e) {
                             e.printStackTrace();
                         }
@@ -817,7 +814,6 @@
     }
 
     public void inviteFromDeviceHandle(ServerTransaction serverTransaction, String requesterId, String channelId) throws InvalidArgumentException, ParseException, SipException, SdpException {
-
         // 闈炰笂绾у钩鍙拌姹傦紝鏌ヨ鏄惁璁惧璇锋眰锛堥�氬父涓烘帴鏀惰闊冲箍鎾殑璁惧锛�
         Device device = redisCatchStorage.getDevice(requesterId);
         AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(requesterId, channelId);
@@ -918,125 +914,64 @@
             sendRtpItem.setOnlyAudio(true);
             redisCatchStorage.updateSendRTPSever(sendRtpItem);
 
-            // hook鐩戝惉绛夊緟璁惧鎺ㄦ祦涓婃潵
-            // 娣诲姞璁㈤槄
-            HookSubscribeForStreamChange subscribeKey = HookSubscribeFactory.on_stream_changed(app, stream, true, "rtsp", mediaServerItem.getId());
-
-            String finalSsrc = ssrc;
-            // 娴佸凡缁忓瓨鍦ㄦ椂鐩存帴鎺ㄦ祦
-                // 璁剧疆绛夊緟鎺ㄦ祦鐨勮秴鏃�; 榛樿20s
-                String waiteStreamTimeoutTaskKey = "waite-stream-" + device.getDeviceId() + audioBroadcastCatch.getChannelId();
-                dynamicTask.startDelay(waiteStreamTimeoutTaskKey, ()->{
-                    logger.info("绛夊緟鎺ㄦ祦瓒呮椂: {}/{}", app, stream);
-                    subscribe.removeSubscribe(subscribeKey);
-                    playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
-                    // 鍙戦�乥ye
-                    try {
-                        responseAck(evt, Response.BUSY_HERE);
-                    } catch (SipException e) {
-                        throw new RuntimeException(e);
-                    } catch (InvalidArgumentException e) {
-                        throw new RuntimeException(e);
-                    } catch (ParseException e) {
-                        throw new RuntimeException(e);
-                    }
-                }, 20*1000);
-
-                boolean finalMediaTransmissionTCP = mediaTransmissionTCP;
-                subscribe.addSubscribe(subscribeKey,
-                        (MediaServerItem mediaServerItemInUse, JSONObject json)->{
-                            logger.info("鏀跺埌璇煶瀵硅鎺ㄦ祦");
-                            dynamicTask.stop(waiteStreamTimeoutTaskKey);
-                            MediaItem mediaItem = JSON.toJavaObject(json, MediaItem.class);
-                            Integer audioCodecId = null;
-                            if (mediaItem.getTracks() != null && mediaItem.getTracks().size() > 0) {
-                                for (int i = 0; i < mediaItem.getTracks().size(); i++) {
-                                    MediaItem.MediaTrack mediaTrack = mediaItem.getTracks().get(i);
-                                    if (mediaTrack.getCodecType() == 1) {
-                                        audioCodecId = mediaTrack.getCodecId();
-                                        break;
-                                    }
-                                }
-                            }
-
-                            try {
-                                sendRtpItem.setStatus(2);
-                                redisCatchStorage.updateSendRTPSever(sendRtpItem);
-                                StringBuffer content = new StringBuffer(200);
-                                content.append("v=0\r\n");
-                                content.append("o="+ config.getId() +" "+ sdp.getOrigin().getSessionId() +" " + sdp.getOrigin().getSessionVersion()  + " IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
-                                content.append("s=Play\r\n");
-                                content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
-                                content.append("t=0 0\r\n");
-                                if (audioCodecId == null) {
-                                    if (finalMediaTransmissionTCP) {
-                                        content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 8\r\n");
-                                    }else {
-                                        content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 8\r\n");
-                                    }
-
-                                    content.append("a=rtpmap:8 PCMA/8000\r\n");
-                                }else {
-                                    if (audioCodecId == 4) {
-                                        if (finalMediaTransmissionTCP) {
-                                            content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 0\r\n");
-                                        }else {
-                                            content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 0\r\n");
-                                        }
-                                        content.append("a=rtpmap:0 PCMU/8000\r\n");
-                                    }else {
-                                        if (finalMediaTransmissionTCP) {
-                                            content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 8\r\n");
-                                        }else {
-                                            content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 8\r\n");
-                                        }
-                                        content.append("a=rtpmap:8 PCMA/8000\r\n");
-                                    }
-                                }
-                                content.append("a=sendonly\r\n");
-                                if (sendRtpItem.isTcp()) {
-                                    content.append("a=connection:new\r\n");
-                                    if (!sendRtpItem.isTcpActive()) {
-                                        content.append("a=setup:active\r\n");
-                                    }else {
-                                        content.append("a=setup:passive\r\n");
-                                    }
-                                }
-                                content.append("y="+ finalSsrc + "\r\n");
-                                content.append("f=v/////a/1/8/1\r\n");
-
-                                ParentPlatform parentPlatform = new ParentPlatform();
-                                parentPlatform.setServerIP(device.getIp());
-                                parentPlatform.setServerPort(device.getPort());
-                                parentPlatform.setServerGBId(device.getDeviceId());
-
-                                responseSdpAck(serverTransaction, content.toString(), parentPlatform);
-                                Dialog dialog = evt.getDialog();
-                                audioBroadcastCatch.setDialog((SIPDialog) dialog);
-                                audioBroadcastCatch.setRequest((SIPRequest) request);
-                                audioBroadcastManager.update(audioBroadcastCatch);
-                            } catch (SipException | InvalidArgumentException | ParseException | SdpParseException e) {
-                                logger.error("[鍛戒护鍙戦�佸け璐 璇煶瀵硅: {}", e.getMessage());
-                            }
-                        });
-//            }
-            String key = DeferredResultHolder.CALLBACK_CMD_BROADCAST + device.getDeviceId();
-            WVPResult<AudioBroadcastResult> wvpResult = new WVPResult<>();
-            wvpResult.setCode(0);
-            wvpResult.setMsg("success");
-            AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
-            audioBroadcastResult.setApp(app);
-            audioBroadcastResult.setStream(stream);
-            audioBroadcastResult.setStreamInfo(mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, stream, null, null, null,false));
-            audioBroadcastResult.setCodec("G.711");
-            wvpResult.setData(audioBroadcastResult);
-            RequestMessage requestMessage = new RequestMessage();
-            requestMessage.setKey(key);
-            requestMessage.setData(wvpResult);
-            resultHolder.invokeAllResult(requestMessage);
+            Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream);
+            if (streamReady) {
+                sendOk(device,  sendRtpItem, sdp, serverTransaction, mediaServerItem, mediaTransmissionTCP, ssrc);
+            }else {
+                logger.warn("[璇煶閫氳瘽]锛� 鏈彂鐜板緟鎺ㄩ�佺殑娴�,app={},stream={}", app, stream);
+                playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
+            }
         } else {
             logger.warn("鏉ヨ嚜鏃犳晥璁惧/骞冲彴鐨勮姹�");
             responseAck(serverTransaction, Response.BAD_REQUEST);
         }
     }
+
+    void sendOk(Device device, SendRtpItem sendRtpItem, SessionDescription sdp, ServerTransaction serverTransaction,  MediaServerItem mediaServerItem, boolean mediaTransmissionTCP, String ssrc){
+        try {
+            sendRtpItem.setStatus(2);
+            redisCatchStorage.updateSendRTPSever(sendRtpItem);
+            StringBuffer content = new StringBuffer(200);
+            content.append("v=0\r\n");
+            content.append("o="+ config.getId() +" "+ sdp.getOrigin().getSessionId() +" " + sdp.getOrigin().getSessionVersion()  + " IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
+            content.append("s=Play\r\n");
+            content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
+            content.append("t=0 0\r\n");
+
+            if (mediaTransmissionTCP) {
+                content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 8\r\n");
+            }else {
+                content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 8\r\n");
+            }
+
+            content.append("a=rtpmap:8 PCMA/8000/1\r\n");
+
+            content.append("a=sendonly\r\n");
+            if (sendRtpItem.isTcp()) {
+                content.append("a=connection:new\r\n");
+                if (!sendRtpItem.isTcpActive()) {
+                    content.append("a=setup:active\r\n");
+                }else {
+                    content.append("a=setup:passive\r\n");
+                }
+            }
+            content.append("y="+ ssrc + "\r\n");
+            content.append("f=v/////a/1/8/1\r\n");
+
+            ParentPlatform parentPlatform = new ParentPlatform();
+            parentPlatform.setServerIP(device.getIp());
+            parentPlatform.setServerPort(device.getPort());
+            parentPlatform.setServerGBId(device.getDeviceId());
+
+            SIPResponse sipResponse = responseSdpAck(serverTransaction, content.toString(), parentPlatform);
+
+            AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(device.getDeviceId(), sendRtpItem.getChannelId());
+
+            audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.Ok);
+            audioBroadcastCatch.setSipTransactionInfoByRequset(sipResponse);
+            audioBroadcastManager.update(audioBroadcastCatch);
+        } catch (SipException | InvalidArgumentException | ParseException | SdpParseException e) {
+            logger.error("[鍛戒护鍙戦�佸け璐 璇煶瀵硅 鍥炲200OK锛圫DP锛�: {}", e.getMessage());
+        }
+    }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
index 8bab8f5..e23177a 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
@@ -20,12 +20,8 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
 
-import javax.sip.InvalidArgumentException;
-import javax.sip.RequestEvent;
-import javax.sip.ServerTransaction;
-import javax.sip.SipException;
+import javax.sip.*;
 import javax.sip.header.*;
 import javax.sip.message.Request;
 import javax.sip.message.Response;
@@ -116,10 +112,12 @@
 
             if (expiresHeader == null) {
                 response = getMessageFactory().createResponse(Response.BAD_REQUEST, request);
-                ServerTransaction serverTransaction = getServerTransaction(evt);
-                serverTransaction.sendResponse(response);
-                if (serverTransaction.getDialog() != null) {
-                    serverTransaction.getDialog().delete();
+                if (evt.getDialog() != null ) {
+                    if (evt.getDialog().isServer()) {
+                        ServerTransaction serverTransaction = getServerTransaction(evt);
+                        serverTransaction.sendResponse(response);
+                        serverTransaction.getDialog().delete();
+                    }
                 }
                 return;
             }
@@ -176,19 +174,13 @@
         } catch (SipException | InvalidArgumentException | NoSuchAlgorithmException | ParseException e) {
             e.printStackTrace();
         }
-
     }
 
     private void sendResponse(RequestEvent evt, Response response) throws InvalidArgumentException, SipException {
         ServerTransaction serverTransaction = getServerTransaction(evt);
-        if (serverTransaction == null) {
-            logger.warn("[鍥炲澶辫触]锛歿}", response);
-            return;
-        }
         serverTransaction.sendResponse(response);
         if (serverTransaction.getDialog() != null) {
             serverTransaction.getDialog().delete();
         }
     }
-
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
index 2ec4023..56dce36 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
@@ -1,20 +1,16 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
 
-import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.CmdType;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
 import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
-import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask;
 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
-import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import gov.nist.javax.sip.SipProviderImpl;
 import gov.nist.javax.sip.message.SIPRequest;
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java
index cf7d112..18c6824 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java
@@ -3,11 +3,15 @@
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
+import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.AckRequestProcessor;
 import org.dom4j.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import javax.sip.InvalidArgumentException;
 import javax.sip.RequestEvent;
+import javax.sip.ServerTransaction;
 import javax.sip.SipException;
 import javax.sip.message.Response;
 import java.text.ParseException;
@@ -17,6 +21,8 @@
 import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText;
 
 public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent implements IMessageHandler{
+
+    private Logger logger = LoggerFactory.getLogger(MessageHandlerAbstract.class);
 
     public Map<String, IMessageHandler> messageHandlerMap = new ConcurrentHashMap<>();
 
@@ -48,14 +54,10 @@
 
     public void handNullCmd(RequestEvent evt){
         try {
-            responseAck(evt, Response.OK);
-        } catch (SipException e) {
-            throw new RuntimeException(e);
-        } catch (InvalidArgumentException e) {
-            throw new RuntimeException(e);
-        } catch (ParseException e) {
-            throw new RuntimeException(e);
+            ServerTransaction serverTransaction = getServerTransaction(evt);
+            responseAck(serverTransaction, Response.OK);
+        } catch (SipException | InvalidArgumentException | ParseException e) {
+            logger.error("[鍛戒护鍙戦�佸け璐 鍥炲200 OK: {}", e.getMessage());
         }
-        return;
     }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java
index e86e3fd..5470374 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java
@@ -52,16 +52,17 @@
     public void handForDevice(RequestEvent evt, Device device, Element rootElement) {
         try {
             String channelId = getText(rootElement, "DeviceID");
+            ServerTransaction serverTransaction = getServerTransaction(evt);
             if (!audioBroadcastManager.exit(device.getDeviceId(), channelId)) {
                 // 鍥炲410
-                responseAck(evt, Response.GONE);
+                responseAck(serverTransaction, Response.GONE);
                 return;
             }
             logger.info("鏀跺埌璇煶骞挎挱鐨勫洖澶嶏細{}/{}", device.getDeviceId(), channelId );
             AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(device.getDeviceId(), channelId);
             audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.WaiteInvite);
             audioBroadcastManager.update(audioBroadcastCatch);
-            responseAck(evt, Response.OK);
+            responseAck(serverTransaction, Response.OK);
         } catch (ParseException | SipException | InvalidArgumentException e) {
             logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 璇煶鍠婅瘽: {}", e.getMessage());
         }
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
index bf2a0ee..d97450f 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
@@ -113,4 +113,7 @@
         return builder.toString();
     }
 
+    public static String getNewCallId() {
+        return (int) Math.floor(Math.random() * 10000) + "";
+    }
 }
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 b043cad..5194a9a 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
@@ -11,12 +11,16 @@
 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
+import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
+import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
 import com.genersoft.iot.vmp.media.zlm.dto.*;
 import com.genersoft.iot.vmp.service.*;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
+import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -51,7 +55,13 @@
 	private SIPCommander cmder;
 
 	@Autowired
-	private SIPCommanderFroPlatform commanderFroPlatform;
+	private ISIPCommanderForPlatform commanderFroPlatform;
+
+	@Autowired
+	private AudioBroadcastManager audioBroadcastManager;
+
+	@Autowired
+	private ZLMRTPServerFactory zlmrtpServerFactory;
 
 	@Autowired
 	private IPlayService playService;
@@ -466,7 +476,127 @@
 								streamInfo.getStream(), null);
 					}
 				}
-			}else {
+			}else if ("broadcast".equals(app)){
+				// 璇煶瀵硅鎺ㄦ祦  stream闇�瑕佹弧瓒虫牸寮廳eviceId_channelId
+				if (regist && stream.indexOf("_") > 0) {
+					String[] streamArray = stream.split("_");
+					if (streamArray.length == 2) {
+						String deviceId = streamArray[0];
+						String channelId = streamArray[1];
+						Device device = deviceService.queryDevice(deviceId);
+						if (device != null) {
+							DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
+							if (deviceChannel != null) {
+								if (audioBroadcastManager.exit(deviceId, channelId)) {
+									// 鐩存帴鎺ㄦ祦
+									SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(null, null, stream, null);
+									if (sendRtpItem == null) {
+										// TODO 鍙兘鏁版嵁閿欒锛岄噸鏂板紑鍚闊抽�氶亾
+									}else {
+										String is_Udp = sendRtpItem.isTcp() ? "0" : "1";
+										MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
+										logger.info("rtp/{}寮�濮嬪悜涓婄骇鎺ㄦ祦, 鐩爣={}:{}锛孲SRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc());
+										Map<String, Object> param = new HashMap<>(12);
+										param.put("vhost","__defaultVhost__");
+										param.put("app",sendRtpItem.getApp());
+										param.put("stream",sendRtpItem.getStreamId());
+										param.put("ssrc", sendRtpItem.getSsrc());
+										param.put("src_port", sendRtpItem.getLocalPort());
+										param.put("pt", sendRtpItem.getPt());
+										param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0");
+										param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0");
+
+										JSONObject jsonObject;
+										if (sendRtpItem.isTcpActive()) {
+											jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param);
+										} else {
+											param.put("is_udp", is_Udp);
+											param.put("dst_url", sendRtpItem.getIp());
+											param.put("dst_port", sendRtpItem.getPort());
+											jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
+										}
+										if (jsonObject != null && jsonObject.getInteger("code") == 0) {
+											logger.info("[璇煶瀵硅] 鑷姩鎺ㄦ祦鎴愬姛, device: {}, channel: {}", deviceId, channelId);
+										}
+
+									}
+								}else {
+									// 寮�鍚闊冲璁查�氶亾
+									try {
+										playService.audioBroadcastCmd(device, channelId, 60, (msg)->{
+											logger.info("[璇煶瀵硅] 閫氶亾寤虹珛鎴愬姛, device: {}, channel: {}", deviceId, channelId);
+										});
+									} catch (InvalidArgumentException | ParseException | SipException e) {
+										logger.error("[鍛戒护鍙戦�佸け璐 璇煶瀵硅: {}", e.getMessage());
+									}
+								}
+
+							}
+						}
+					}
+				}
+
+			}else if ("talk".equals(app)){
+				// 璇煶瀵硅鎺ㄦ祦  stream闇�瑕佹弧瓒虫牸寮廳eviceId_channelId
+				if (regist && stream.indexOf("_") > 0) {
+					String[] streamArray = stream.split("_");
+					if (streamArray.length == 2) {
+						String deviceId = streamArray[0];
+						String channelId = streamArray[1];
+						Device device = deviceService.queryDevice(deviceId);
+						if (device != null) {
+							DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
+							if (deviceChannel != null) {
+								if (audioBroadcastManager.exit(deviceId, channelId)) {
+									// 鐩存帴鎺ㄦ祦
+									SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(null, null, stream, null);
+									if (sendRtpItem == null) {
+										// TODO 鍙兘鏁版嵁閿欒锛岄噸鏂板紑鍚闊抽�氶亾
+									}else {
+										String is_Udp = sendRtpItem.isTcp() ? "0" : "1";
+										MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
+										logger.info("rtp/{}寮�濮嬪悜涓婄骇鎺ㄦ祦, 鐩爣={}:{}锛孲SRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc());
+										Map<String, Object> param = new HashMap<>(12);
+										param.put("vhost","__defaultVhost__");
+										param.put("app",sendRtpItem.getApp());
+										param.put("stream",sendRtpItem.getStreamId());
+										param.put("ssrc", sendRtpItem.getSsrc());
+										param.put("src_port", sendRtpItem.getLocalPort());
+										param.put("pt", sendRtpItem.getPt());
+										param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0");
+										param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0");
+
+										JSONObject jsonObject;
+										if (sendRtpItem.isTcpActive()) {
+											jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param);
+										} else {
+											param.put("is_udp", is_Udp);
+											param.put("dst_url", sendRtpItem.getIp());
+											param.put("dst_port", sendRtpItem.getPort());
+											jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
+										}
+										if (jsonObject != null && jsonObject.getInteger("code") == 0) {
+											logger.info("[璇煶瀵硅] 鑷姩鎺ㄦ祦鎴愬姛, device: {}, channel: {}", deviceId, channelId);
+										}
+									}
+								}else {
+									// 寮�鍚闊冲璁查�氶亾
+									MediaServerItem mediaServerForMinimumLoad = mediaServerService.getMediaServerForMinimumLoad();
+									playService.talk(mediaServerForMinimumLoad, device, channelId, (mediaServerItem, jsonObject)->{
+										System.out.println("寮�濮嬫帹娴�");
+									}, eventResult -> {
+										System.out.println(eventResult.msg);
+									}, ()->{
+										System.out.println("瓒呮椂");
+									});
+								}
+
+							}
+						}
+					}
+				}
+
+			}else{
 				if (!"rtp".equals(app)){
 					String type = OriginType.values()[item.getOriginType()].getType();
 					MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
@@ -521,10 +651,23 @@
 						if (sendRtpItem.getApp().equals(app)) {
 							String platformId = sendRtpItem.getPlatformId();
 							ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
+							Device device = deviceService.queryDevice(platformId);
 
 							try {
-								commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
-							} catch (SipException | InvalidArgumentException | ParseException e) {
+								if (platform != null) {
+									commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
+								}else {
+									if (sendRtpItem.isOnlyAudio()) {
+										AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
+										if (device != null && audioBroadcastCatch != null) {
+//											cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null);
+										}
+									}else {
+										cmder.streamByeCmd(device, sendRtpItem.getChannelId(), stream, sendRtpItem.getCallId());
+									}
+
+								}
+							} catch (SipException | InvalidArgumentException | ParseException | SsrcTransactionNotFoundException e) {
 								logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 鍙戦�丅YE: {}", e.getMessage());
 							}
 						}
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
index 80ae95e..2bd9a95 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
@@ -164,33 +164,6 @@
         return result;
     }
 
-//    private int getPortFromportRange(MediaServerItem mediaServerItem) {
-//        int currentPort = mediaServerItem.getCurrentPort();
-//        if (currentPort == 0) {
-//            String[] portRangeStrArray = mediaServerItem.getSendRtpPortRange().split(",");
-//            if (portRangeStrArray.length != 2) {
-//                portRangeArray[0] = 30000;
-//                portRangeArray[1] = 30500;
-//            }else {
-//                portRangeArray[0] = Integer.parseInt(portRangeStrArray[0]);
-//                portRangeArray[1] = Integer.parseInt(portRangeStrArray[1]);
-//            }
-//        }
-//
-//        if (currentPort == 0 || currentPort++ > portRangeArray[1]) {
-//            currentPort = portRangeArray[0];
-//            mediaServerItem.setCurrentPort(currentPort);
-//            return portRangeArray[0];
-//        } else {
-//            if (currentPort % 2 == 1) {
-//                currentPort++;
-//            }
-//            currentPort++;
-//            mediaServerItem.setCurrentPort(currentPort);
-//            return currentPort;
-//        }
-//    }
-
     /**
      * 鍒涘缓涓�涓浗鏍囨帹娴�
      * @param ip 鎺ㄦ祦ip
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 19ffdc4..5cc2a66 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
@@ -38,6 +38,7 @@
             hookSubscribe.setExpires(expiresInstant);
         }
         allSubscribes.computeIfAbsent(hookSubscribe.getHookType(), k -> new ConcurrentHashMap<>()).put(hookSubscribe, event);
+        System.out.println(allSubscribes);
     }
 
     public ZlmHttpHookSubscribe.Event sendNotify(HookType type, JSONObject hookResponse) {
@@ -48,6 +49,7 @@
         }
         for (IHookSubscribe key : eventMap.keySet()) {
             Boolean result = null;
+
             for (String s : key.getContent().keySet()) {
                 if (result == null) {
                     result = key.getContent().getString(s).equals(hookResponse.getString(s));
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java
index 92172f3..b844918 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java
@@ -24,10 +24,26 @@
         return hookSubscribe;
     }
 
+    public static HookSubscribeForStreamPush on_publish(String app, String stream, String scheam, String mediaServerId) {
+        HookSubscribeForStreamPush hookSubscribe = new HookSubscribeForStreamPush();
+        JSONObject subscribeKey = new com.alibaba.fastjson.JSONObject();
+        subscribeKey.put("app", app);
+        subscribeKey.put("stream", stream);
+        if (scheam != null) {
+            subscribeKey.put("schema", scheam);
+        }
+        subscribeKey.put("mediaServerId", mediaServerId);
+        hookSubscribe.setContent(subscribeKey);
+
+        return hookSubscribe;
+    }
+
+
     public static HookSubscribeForServerStarted on_server_started() {
         HookSubscribeForServerStarted hookSubscribe = new HookSubscribeForServerStarted();
         hookSubscribe.setContent(new JSONObject());
 
         return hookSubscribe;
     }
+
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamPush.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamPush.java
new file mode 100644
index 0000000..48e2e3c
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamPush.java
@@ -0,0 +1,42 @@
+package com.genersoft.iot.vmp.media.zlm.dto;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.time.Instant;
+
+/**
+ * hook璁㈤槄-寮�濮嬫帹娴�
+ * @author lin
+ */
+public class HookSubscribeForStreamPush implements IHookSubscribe{
+
+    private HookType hookType = HookType.on_publish;
+
+    private JSONObject content;
+
+    private Instant expires;
+
+    @Override
+    public HookType getHookType() {
+        return hookType;
+    }
+
+    @Override
+    public JSONObject getContent() {
+        return content;
+    }
+
+    public void setContent(JSONObject content) {
+        this.content = content;
+    }
+
+    @Override
+    public Instant getExpires() {
+        return expires;
+    }
+
+    @Override
+    public void setExpires(Instant expires) {
+        this.expires = expires;
+    }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
index 9a2bb58..1eac2c8 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
@@ -11,10 +11,15 @@
 import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback;
 import com.genersoft.iot.vmp.service.bean.PlayBackCallback;
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
+import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
 import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
 import org.springframework.web.context.request.async.DeferredResult;
+
+import javax.sip.InvalidArgumentException;
+import javax.sip.SipException;
+import java.text.ParseException;
 
 /**
  * 鐐规挱澶勭悊
@@ -22,6 +27,10 @@
 public interface IPlayService {
 
     void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId, String uuid);
+
+    void talk(MediaServerItem mediaServerItem, Device device, String channelId,
+              ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
+              Runnable timeoutCallback);
 
     void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
               ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
@@ -44,6 +53,8 @@
 
     void zlmServerOnline(String mediaServerId);
 
-    void audioBroadcast(Device device, String channelId, int timeout, AudioBroadcastEvent event);
+    AudioBroadcastResult audioBroadcast(Device device, String channelId);
     void stopAudioBroadcast(String deviceId, String channelId);
+
+    void audioBroadcastCmd(Device device, String channelId, int timeout, AudioBroadcastEvent event) throws InvalidArgumentException, ParseException, SipException;
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
index 734a674..4785afe 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
@@ -69,7 +69,7 @@
                 JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class);
                 JSONArray tracks = mediaJSON.getJSONArray("tracks");
                 if (authority) {
-                    streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr, calld);
+                    streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr, calld, true);
                 }else {
                     streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,null, true);
                 }
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
index d6c3d5f..68055a4 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -12,8 +12,10 @@
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
-import com.genersoft.iot.vmp.gb28181.bean.*;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
+import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
 import com.genersoft.iot.vmp.service.IDeviceService;
+import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,7 +38,6 @@
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
 import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
@@ -54,32 +55,9 @@
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
-import com.genersoft.iot.vmp.utils.redis.RedisUtil;
-import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
-import com.genersoft.iot.vmp.utils.DateUtil;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent;
 import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
-
-import gov.nist.javax.sip.stack.SIPDialog;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Service;
-import org.springframework.util.ResourceUtils;
-import org.springframework.web.context.request.async.DeferredResult;
-
-import javax.sip.ResponseEvent;
-import javax.sip.SipException;
-import java.io.FileNotFoundException;
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.math.RoundingMode;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 @SuppressWarnings(value = {"rawtypes", "unchecked"})
 @Service
@@ -97,7 +75,10 @@
     private AudioBroadcastManager audioBroadcastManager;
 
     @Autowired
-    private SIPCommanderFroPlatform sipCommanderFroPlatform;
+    private IDeviceService deviceService;
+
+    @Autowired
+    private ISIPCommanderForPlatform sipCommanderFroPlatform;
 
     @Autowired
     private IRedisCatchStorage redisCatchStorage;
@@ -123,10 +104,6 @@
     @Autowired
     private VideoStreamSessionManager streamSession;
 
-
-    @Autowired
-    private IDeviceService deviceService;
-
     @Autowired
     private UserSetting userSetting;
 
@@ -143,7 +120,6 @@
     @Qualifier("taskExecutor")
     @Autowired
     private ThreadPoolTaskExecutor taskExecutor;
-
 
 
     @Override
@@ -169,15 +145,15 @@
         StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
         playResult.setDevice(device);
 
-        result.onCompletion(()->{
+        result.onCompletion(() -> {
             // 鐐规挱缁撴潫鏃惰皟鐢ㄦ埅鍥炬帴鍙�
-            taskExecutor.execute(()->{
+            taskExecutor.execute(() -> {
                 // TODO 搴旇鍦ㄤ笂娴佹椂璋冪敤鏇村ソ锛岀粨鏉熶篃鍙兘鏄敊璇粨鏉�
-                String path =  "snap";
-                String fileName =  deviceId + "_" + channelId + ".jpg";
-                WVPResult wvpResult =  (WVPResult)result.getResult();
+                String path = "snap";
+                String fileName = deviceId + "_" + channelId + ".jpg";
+                WVPResult wvpResult = (WVPResult) result.getResult();
                 if (Objects.requireNonNull(wvpResult).getCode() == 0) {
-                    StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData();
+                    StreamInfo streamInfoForSuccess = (StreamInfo) wvpResult.getData();
                     MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
                     String streamUrl = streamInfoForSuccess.getFmp4();
                     // 璇锋眰鎴浘
@@ -201,7 +177,7 @@
             MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
 
             JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId);
-            if(rtpInfo.getInteger("code") == 0){
+            if (rtpInfo.getInteger("code") == 0) {
                 if (rtpInfo.getBoolean("exist")) {
                     int localPort = rtpInfo.getInteger("local_port");
                     if (localPort == 0) {
@@ -214,7 +190,7 @@
 
                         resultHolder.invokeAllResult(msg);
                         return playResult;
-                    }else {
+                    } else {
                         WVPResult wvpResult = new WVPResult();
                         wvpResult.setCode(ErrorCode.SUCCESS.getCode());
                         wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
@@ -227,12 +203,12 @@
                         }
                     }
 
-                }else {
+                } else {
                     redisCatchStorage.stopPlay(streamInfo);
                     storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
                     streamInfo = null;
                 }
-            }else {
+            } else {
                 //zlm杩炴帴澶辫触
                 redisCatchStorage.stopPlay(streamInfo);
                 storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
@@ -246,7 +222,7 @@
             }
             SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false);
             logger.info(JSONObject.toJSONString(ssrcInfo));
-            play(mediaServerItem, ssrcInfo, device, channelId, (mediaServerItemInUse, response)->{
+            play(mediaServerItem, ssrcInfo, device, channelId, (mediaServerItemInUse, response) -> {
                 if (hookEvent != null) {
                     hookEvent.response(mediaServerItem, response);
                 }
@@ -260,13 +236,13 @@
                 if (errorEvent != null) {
                     errorEvent.response(event);
                 }
-            }, (code, msgStr)->{
+            }, (code, msgStr) -> {
                 // invite鐐规挱瓒呮椂
                 WVPResult wvpResult = new WVPResult();
                 wvpResult.setCode(ErrorCode.ERROR100.getCode());
                 if (code == 0) {
                     wvpResult.setMsg("鐐规挱瓒呮椂锛岃绋嶅�欓噸璇�");
-                }else if (code == 1) {
+                } else if (code == 1) {
                     wvpResult.setMsg("鏀舵祦瓒呮椂锛岃绋嶅�欓噸璇�");
                 }
                 msg.setData(wvpResult);
@@ -277,6 +253,186 @@
         return playResult;
     }
 
+    @Override
+    public void talk(MediaServerItem mediaServerItem, Device device, String channelId,
+                     ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
+                     Runnable timeoutCallback) {
+        String streamId = null;
+        if (mediaServerItem.isRtpEnable()) {
+            streamId = String.format("%s_%s", device.getDeviceId(), channelId);
+        }
+        SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false);
+        logger.info("[瀵硅寮�濮媇 deviceId: {}, channelId: {},鏀舵祦绔彛锛� {}, 鏀舵祦妯″紡锛歿}, SSRC: {}, SSRC鏍¢獙锛歿}", device.getDeviceId(), channelId, ssrcInfo.getPort(), device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck());
+        // 瓒呮椂澶勭悊
+        String timeOutTaskKey = UUID.randomUUID().toString();
+        SSRCInfo finalSsrcInfo = ssrcInfo;
+        System.out.println("璁剧疆瓒呮椂浠诲姟锛� " + timeOutTaskKey);
+        dynamicTask.startDelay(timeOutTaskKey, () -> {
+
+            logger.info("[瀵硅瓒呮椂] 鏀舵祦瓒呮椂 deviceId: {}, channelId: {}锛岀鍙o細{}, SSRC: {}", device.getDeviceId(), channelId, finalSsrcInfo.getPort(), finalSsrcInfo.getSsrc());
+            timeoutCallback.run();
+            // 鐐规挱瓒呮椂鍥炲BYE 鍚屾椂閲婃斁ssrc浠ュ強姝ゆ鐐规挱鐨勮祫婧�
+            try {
+                cmder.streamByeCmd(device, channelId, finalSsrcInfo.getStream(), null);
+            } catch (InvalidArgumentException | ParseException | SipException e) {
+                logger.error("[瀵硅瓒呮椂]锛� 鍙戦�丅YE澶辫触 {}", e.getMessage());
+            } catch (SsrcTransactionNotFoundException e) {
+                timeoutCallback.run();
+                mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
+                mediaServerService.closeRTPServer(mediaServerItem, finalSsrcInfo.getStream());
+                streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
+            }
+        }, userSetting.getPlayTimeout());
+        final String ssrc = ssrcInfo.getSsrc();
+        final String stream = ssrcInfo.getStream();
+        //绔彛鑾峰彇澶辫触鐨剆srcInfo 娌℃湁蹇呰鍙戦�佺偣鎾寚浠�
+        if (ssrcInfo.getPort() <= 0) {
+            logger.info("[瀵硅] 绔彛鍒嗛厤寮傚父锛宒eviceId={},channelId={},ssrcInfo={}", device.getDeviceId(), channelId, ssrcInfo);
+            return;
+        }
+        try {
+            String callId = SipUtils.getNewCallId();
+            cmder.talkStreamCmd(mediaServerItem, ssrcInfo, device, channelId, callId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> {
+                logger.info("[瀵硅] 娴佸凡鐢熸垚锛� 寮�濮嬫帹娴侊細 " + response.toJSONString());
+                dynamicTask.stop(timeOutTaskKey);
+                // TODO 鏆備笉鍋氬鐞�
+            }, (MediaServerItem mediaServerItemInuse, JSONObject json) -> {
+                logger.info("[瀵硅] 寮�濮嬫帹娴侊細 " + json.toJSONString());
+                dynamicTask.stop(timeOutTaskKey);
+                // 鑾峰彇杩滅▼IP绔彛 浣滀负鍥炲璇煶娴佺殑鍦板潃
+                String ip = json.getString("ip");
+                Integer port = json.getInteger("port");
+                logger.info("[杩滅璁惧寮�濮嬫帹娴乚{}/{}, 鏉ヨ嚜ip锛歿}, 绔彛锛歿}", device.getDeviceId(), channelId, ip, port);
+                // 鏌ョ湅骞冲彴鎺ㄦ祦鏄惁灏辩华
+                Boolean ready = zlmrtpServerFactory.isStreamReady(mediaServerItemInuse, "talk", stream);
+                if (!ready) {
+                    try {
+                        cmder.streamByeCmd(device, channelId, finalSsrcInfo.getStream(), null);
+                    } catch (InvalidArgumentException | ParseException | SipException e) {
+                        logger.error("[瀵硅瓒呮椂]锛� 鍙戦�丅YE澶辫触 {}", e.getMessage());
+                    } catch (SsrcTransactionNotFoundException e) {
+                        timeoutCallback.run();
+                        mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
+                        mediaServerService.closeRTPServer(mediaServerItem, finalSsrcInfo.getStream());
+                        streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
+                    }
+                }else {
+                    SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, ip, port, ssrcInfo.getSsrc(), device.getDeviceId(),
+                            device.getDeviceId(), channelId,
+                            false);
+
+                    sendRtpItem.setTcpActive(false);
+                    if (sendRtpItem == null || sendRtpItem.getLocalPort() == 0) {
+                        logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�");
+                        try {
+                            cmder.streamByeCmd(device, channelId, finalSsrcInfo.getStream(), null);
+                        } catch (InvalidArgumentException | ParseException | SipException e) {
+                            logger.error("[瀵硅瓒呮椂]锛� 鍙戦�丅YE澶辫触 {}", e.getMessage());
+                        } catch (SsrcTransactionNotFoundException e) {
+                            timeoutCallback.run();
+                            mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
+                            mediaServerService.closeRTPServer(mediaServerItem, finalSsrcInfo.getStream());
+                            streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
+                        }
+                        return;
+                    }
+                    sendRtpItem.setCallId(callId);
+                    sendRtpItem.setPlayType(InviteStreamType.TALK);
+                    sendRtpItem.setStatus(1);
+                    sendRtpItem.setIp(ip);
+                    sendRtpItem.setPort(port);
+                    sendRtpItem.setTcpActive(false);
+                    sendRtpItem.setStreamId(ssrcInfo.getStream());
+                    sendRtpItem.setApp("talk");
+                    sendRtpItem.setSsrc(ssrc);
+                    redisCatchStorage.updateSendRTPSever(sendRtpItem);
+
+                    Map<String, Object> param = new HashMap<>(12);
+                    param.put("vhost","__defaultVhost__");
+                    param.put("app",sendRtpItem.getApp());
+                    param.put("stream",sendRtpItem.getStreamId());
+                    param.put("ssrc", sendRtpItem.getSsrc());
+                    param.put("src_port", sendRtpItem.getLocalPort());
+                    param.put("pt", sendRtpItem.getPt());
+                    param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0");
+                    param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0");
+                    JSONObject jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaServerItemInuse, param);
+                    System.out.println(11111);
+                    System.out.println(jsonObject);
+                }
+
+            }, (event) -> {
+//                ResponseEvent responseEvent = (ResponseEvent) event.event;
+//                String contentString = new String(responseEvent.getResponse().getRawContent());
+//                // 鑾峰彇ssrc
+//                int ssrcIndex = contentString.indexOf("y=");
+//                // 妫�鏌ユ槸鍚︽湁y瀛楁
+//                if (ssrcIndex >= 0) {
+//                    //ssrc瑙勫畾闀垮害涓�10瀛楄妭锛屼笉鍙栦綑涓嬮暱搴︿互閬垮厤鍚庣画杩樻湁鈥渇=鈥濆瓧娈� TODO 鍚庣画瀵逛笉瑙勮寖鐨勯潪10浣峴src鍏煎
+//                    String ssrcInResponse = contentString.substring(ssrcIndex + 2, ssrcIndex + 12);
+//                    // 鏌ヨ鍒皊src涓嶄竴鑷翠笖寮�鍚簡ssrc鏍¢獙鍒欓渶瑕侀拡瀵瑰鐞�
+//                    if (ssrc.equals(ssrcInResponse)) {
+//                        return;
+//                    }
+//                    logger.info("[瀵硅娑堟伅] 鏀跺埌invite 200, 鍙戠幇涓嬬骇鑷畾涔変簡ssrc: {}", ssrcInResponse);
+//                    if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) {
+//                        logger.info("[瀵硅娑堟伅] SSRC淇 {}->{}", ssrc, ssrcInResponse);
+//
+//                        if (!mediaServerItem.getSsrcConfig().checkSsrc(ssrcInResponse)) {
+//                            // ssrc 涓嶅彲鐢�
+//                            // 閲婃斁ssrc
+//                            mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
+//                            streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
+//                            event.msg = "涓嬬骇鑷畾涔変簡ssrc,浣嗘槸姝src涓嶅彲鐢�";
+//                            event.statusCode = 400;
+//                            errorEvent.response(event);
+//                            return;
+//                        }
+//
+//                        // 鍗曠鍙fā寮弒treamId涔熸湁鍙樺寲锛岄渶瑕侀噸鏂拌缃洃鍚�
+//                        if (!mediaServerItem.isRtpEnable()) {
+//                            // 娣诲姞璁㈤槄
+//                            HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId());
+//                            subscribe.removeSubscribe(hookSubscribe);
+//                            hookSubscribe.getContent().put("stream", String.format("%08x", Integer.parseInt(ssrcInResponse)).toUpperCase());
+//                            subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject response) -> {
+//                                logger.info("[ZLM HOOK] ssrc淇鍚庢敹鍒拌闃呮秷鎭細 " + response.toJSONString());
+//                                dynamicTask.stop(timeOutTaskKey);
+//                                // hook鍝嶅簲
+//                                onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid);
+//                                hookEvent.response(mediaServerItemInUse, response);
+//                            });
+//                        }
+//                        // 鍏抽棴rtp server
+//                        mediaServerService.closeRTPServer(mediaServerItem, finalSsrcInfo.getStream());
+//                        // 閲嶆柊寮�鍚痵src server
+//                        mediaServerService.openRTPServer(mediaServerItem, finalSsrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), false, finalSsrcInfo.getPort());
+//
+//                    }
+//                }
+            }, (event) -> {
+                dynamicTask.stop(timeOutTaskKey);
+                mediaServerService.closeRTPServer(mediaServerItem, finalSsrcInfo.getStream());
+                // 閲婃斁ssrc
+                mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
+
+                streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
+                errorEvent.response(event);
+            });
+        } catch (InvalidArgumentException | SipException | ParseException e) {
+
+            logger.error("[鍛戒护鍙戦�佸け璐 瀵硅娑堟伅: {}", e.getMessage());
+            dynamicTask.stop(timeOutTaskKey);
+            mediaServerService.closeRTPServer(mediaServerItem, finalSsrcInfo.getStream());
+            // 閲婃斁ssrc
+            mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
+
+            streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
+            SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(new CmdSendFailEvent(null));
+            eventResult.msg = "鍛戒护鍙戦�佸け璐�";
+            errorEvent.response(eventResult);
+        }
+    }
 
 
     @Override
@@ -291,12 +447,12 @@
         if (ssrcInfo == null) {
             ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false);
         }
-        logger.info("[鐐规挱寮�濮媇 deviceId: {}, channelId: {},鏀舵祦绔彛锛� {}, 鏀舵祦妯″紡锛歿}, SSRC: {}, SSRC鏍¢獙锛歿}", device.getDeviceId(), channelId, ssrcInfo.getPort(), device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck() );
+        logger.info("[鐐规挱寮�濮媇 deviceId: {}, channelId: {},鏀舵祦绔彛锛� {}, 鏀舵祦妯″紡锛歿}, SSRC: {}, SSRC鏍¢獙锛歿}", device.getDeviceId(), channelId, ssrcInfo.getPort(), device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck());
         // 瓒呮椂澶勭悊
         String timeOutTaskKey = UUID.randomUUID().toString();
         SSRCInfo finalSsrcInfo = ssrcInfo;
         System.out.println("璁剧疆瓒呮椂浠诲姟锛� " + timeOutTaskKey);
-        dynamicTask.startDelay( timeOutTaskKey,()->{
+        dynamicTask.startDelay(timeOutTaskKey, () -> {
 
             logger.info("[鐐规挱瓒呮椂] 鏀舵祦瓒呮椂 deviceId: {}, channelId: {}锛岀鍙o細{}, SSRC: {}", device.getDeviceId(), channelId, finalSsrcInfo.getPort(), finalSsrcInfo.getSsrc());
             timeoutCallback.run(1, "鏀舵祦瓒呮椂");
@@ -315,7 +471,7 @@
         final String ssrc = ssrcInfo.getSsrc();
         final String stream = ssrcInfo.getStream();
         //绔彛鑾峰彇澶辫触鐨剆srcInfo 娌℃湁蹇呰鍙戦�佺偣鎾寚浠�
-        if(ssrcInfo.getPort() <= 0){
+        if (ssrcInfo.getPort() <= 0) {
             logger.info("[鐐规挱绔彛鍒嗛厤寮傚父]锛宒eviceId={},channelId={},ssrcInfo={}", device.getDeviceId(), channelId, ssrcInfo);
             return;
         }
@@ -330,7 +486,7 @@
                 logger.info("[鐐规挱鎴愬姛] deviceId: {}, channelId: {}", device.getDeviceId(), channelId);
 
             }, (event) -> {
-                ResponseEvent responseEvent = (ResponseEvent)event.event;
+                ResponseEvent responseEvent = (ResponseEvent) event.event;
                 String contentString = new String(responseEvent.getResponse().getRawContent());
                 // 鑾峰彇ssrc
                 int ssrcIndex = contentString.indexOf("y=");
@@ -342,7 +498,7 @@
                     if (ssrc.equals(ssrcInResponse)) {
                         return;
                     }
-                    logger.info("[鐐规挱娑堟伅] 鏀跺埌invite 200, 鍙戠幇涓嬬骇鑷畾涔変簡ssrc: {}", ssrcInResponse );
+                    logger.info("[鐐规挱娑堟伅] 鏀跺埌invite 200, 鍙戠幇涓嬬骇鑷畾涔変簡ssrc: {}", ssrcInResponse);
                     if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) {
                         logger.info("[鐐规挱娑堟伅] SSRC淇 {}->{}", ssrc, ssrcInResponse);
 
@@ -363,13 +519,13 @@
                             HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId());
                             subscribe.removeSubscribe(hookSubscribe);
                             hookSubscribe.getContent().put("stream", String.format("%08x", Integer.parseInt(ssrcInResponse)).toUpperCase());
-                            subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject response)->{
-                                        logger.info("[ZLM HOOK] ssrc淇鍚庢敹鍒拌闃呮秷鎭細 " + response.toJSONString());
-                                        dynamicTask.stop(timeOutTaskKey);
-                                        // hook鍝嶅簲
-                                        onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid);
-                                        hookEvent.response(mediaServerItemInUse, response);
-                                    });
+                            subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject response) -> {
+                                logger.info("[ZLM HOOK] ssrc淇鍚庢敹鍒拌闃呮秷鎭細 " + response.toJSONString());
+                                dynamicTask.stop(timeOutTaskKey);
+                                // hook鍝嶅簲
+                                onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid);
+                                hookEvent.response(mediaServerItemInUse, response);
+                            });
                         }
                         // 鍏抽棴rtp server
                         mediaServerService.closeRTPServer(mediaServerItem, finalSsrcInfo.getStream());
@@ -441,7 +597,7 @@
         MediaServerItem mediaServerItem;
         if (mediaServerId == null) {
             mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
-        }else {
+        } else {
             mediaServerItem = mediaServerService.getOne(mediaServerId);
         }
         if (mediaServerItem == null) {
@@ -452,8 +608,8 @@
 
     @Override
     public DeferredResult<WVPResult<StreamInfo>> playBack(String deviceId, String channelId, String startTime,
-                                                           String endTime,InviteStreamCallback inviteStreamCallback,
-                                                           PlayBackCallback callback) {
+                                                          String endTime, InviteStreamCallback inviteStreamCallback,
+                                                          PlayBackCallback callback) {
         Device device = storager.queryVideoDevice(deviceId);
         if (device == null) {
             return null;
@@ -466,9 +622,9 @@
 
     @Override
     public DeferredResult<WVPResult<StreamInfo>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,
-                                                           String deviceId, String channelId, String startTime,
-                                                           String endTime, InviteStreamCallback infoCallBack,
-                                                           PlayBackCallback playBackCallback) {
+                                                          String deviceId, String channelId, String startTime,
+                                                          String endTime, InviteStreamCallback infoCallBack,
+                                                          PlayBackCallback playBackCallback) {
         if (mediaServerItem == null || ssrcInfo == null) {
             return null;
         }
@@ -485,7 +641,7 @@
         requestMessage.setKey(key);
         PlayBackResult<RequestMessage> playBackResult = new PlayBackResult<>();
         String playBackTimeOutTaskKey = UUID.randomUUID().toString();
-        dynamicTask.startDelay(playBackTimeOutTaskKey, ()->{
+        dynamicTask.startDelay(playBackTimeOutTaskKey, () -> {
             logger.warn(String.format("璁惧鍥炴斁瓒呮椂锛宒eviceId锛�%s 锛宑hannelId锛�%s", deviceId, channelId));
             playBackResult.setCode(ErrorCode.ERROR100.getCode());
             playBackResult.setMsg("鍥炴斁瓒呮椂");
@@ -545,7 +701,7 @@
             cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack,
                     hookEvent, eventResult -> {
                         if (eventResult.type == SipSubscribe.EventResultType.response) {
-                            ResponseEvent responseEvent = (ResponseEvent)eventResult.event;
+                            ResponseEvent responseEvent = (ResponseEvent) eventResult.event;
                             String contentString = new String(responseEvent.getResponse().getRawContent());
                             // 鑾峰彇ssrc
                             int ssrcIndex = contentString.indexOf("y=");
@@ -557,7 +713,7 @@
                                 if (ssrcInfo.getSsrc().equals(ssrcInResponse)) {
                                     return;
                                 }
-                                logger.info("[鍥炴斁娑堟伅] 鏀跺埌invite 200, 鍙戠幇涓嬬骇鑷畾涔変簡ssrc: {}", ssrcInResponse );
+                                logger.info("[鍥炴斁娑堟伅] 鏀跺埌invite 200, 鍙戠幇涓嬬骇鑷畾涔変簡ssrc: {}", ssrcInResponse);
                                 if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) {
                                     logger.info("[鍥炴斁娑堟伅] SSRC淇 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse);
 
@@ -578,7 +734,7 @@
                                         HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId());
                                         subscribe.removeSubscribe(hookSubscribe);
                                         hookSubscribe.getContent().put("stream", String.format("%08x", Integer.parseInt(ssrcInResponse)).toUpperCase());
-                                        subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject response)->{
+                                        subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject response) -> {
                                             logger.info("[ZLM HOOK] ssrc淇鍚庢敹鍒拌闃呮秷鎭細 " + response.toJSONString());
                                             dynamicTask.stop(playBackTimeOutTaskKey);
                                             // hook鍝嶅簲
@@ -614,7 +770,7 @@
         MediaServerItem newMediaServerItem = getNewMediaServerItem(device);
         SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true, true);
 
-        return download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed,infoCallBack, hookCallBack);
+        return download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, infoCallBack, hookCallBack);
     }
 
     @Override
@@ -640,7 +796,7 @@
         downloadResult.setData(requestMessage);
 
         String downLoadTimeOutTaskKey = UUID.randomUUID().toString();
-        dynamicTask.startDelay(downLoadTimeOutTaskKey, ()->{
+        dynamicTask.startDelay(downLoadTimeOutTaskKey, () -> {
             logger.warn(String.format("褰曞儚涓嬭浇璇锋眰瓒呮椂锛宒eviceId锛�%s 锛宑hannelId锛�%s", deviceId, channelId));
             wvpResult.setCode(ErrorCode.ERROR100.getCode());
             wvpResult.setMsg("褰曞儚涓嬭浇璇锋眰瓒呮椂");
@@ -723,15 +879,15 @@
 
                     if (duration == 0) {
                         streamInfo.setProgress(0);
-                    }else {
+                    } else {
                         String startTime = streamInfo.getStartTime();
                         String endTime = streamInfo.getEndTime();
                         long start = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime);
                         long end = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime);
 
-                        BigDecimal currentCount = new BigDecimal(duration/1000);
-                        BigDecimal totalCount = new BigDecimal(end-start);
-                        BigDecimal divide = currentCount.divide(totalCount,2, RoundingMode.HALF_UP);
+                        BigDecimal currentCount = new BigDecimal(duration / 1000);
+                        BigDecimal totalCount = new BigDecimal(end - start);
+                        BigDecimal divide = currentCount.divide(totalCount, 2, RoundingMode.HALF_UP);
                         double process = divide.doubleValue();
                         streamInfo.setProgress(process);
                     }
@@ -762,7 +918,7 @@
     public StreamInfo onPublishHandler(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId) {
         String streamId = resonse.getString("stream");
         JSONArray tracks = resonse.getJSONArray("tracks");
-        StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(mediaServerItem,"rtp", streamId, tracks, null);
+        StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(mediaServerItem, "rtp", streamId, tracks, null);
         streamInfo.setDeviceID(deviceId);
         streamInfo.setChannelId(channelId);
         return streamInfo;
@@ -788,7 +944,7 @@
         List<SsrcTransaction> allSsrc = streamSession.getAllSsrc();
         if (allSsrc.size() > 0) {
             for (SsrcTransaction ssrcTransaction : allSsrc) {
-                if(ssrcTransaction.getMediaServerId().equals(mediaServerId)) {
+                if (ssrcTransaction.getMediaServerId().equals(mediaServerId)) {
                     Device device = deviceService.queryDevice(ssrcTransaction.getDeviceId());
                     if (device == null) {
                         continue;
@@ -806,10 +962,36 @@
     }
 
     @Override
-    public void audioBroadcast(Device device, String channelId, int timeout, AudioBroadcastEvent event) {
+    public AudioBroadcastResult audioBroadcast(Device device, String channelId) {
+        if (device == null || channelId == null) {
+            return null;
+        }
+        logger.info("[璇煶鍠婅瘽] device锛� {}, channel: {}", device.getDeviceId(), channelId);
+        DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId);
+        if (deviceChannel == null) {
+            logger.warn("寮�鍚闊冲箍鎾殑鏃跺�欐湭鎵惧埌閫氶亾锛� {}", channelId);
+            return null;
+        }
+        MediaServerItem mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
+//        String app = "broadcast";
+        // TODO 浠巗ip user agent涓垽鏂槸浠�涔堝搧鐗岃澶囷紝澶у崕榛樿浣跨敤talk妯″紡锛屽叾浠栦娇鐢╞roadcast妯″紡
+        String app = "talk";
+        String stream = device.getDeviceId() + "_" + channelId;
+        StreamInfo broadcast = mediaService.getStreamInfoByAppAndStream(mediaServerItem, "broadcast", stream, null, null, null, false);
+        AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
+        audioBroadcastResult.setApp(app);
+        audioBroadcastResult.setStream(stream);
+        audioBroadcastResult.setStreamInfo(mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, stream, null, null, null,false));
+        audioBroadcastResult.setCodec("G.711");
+        return audioBroadcastResult;
+    }
+
+    @Override
+    public void audioBroadcastCmd(Device device, String channelId, int timeout, AudioBroadcastEvent event) throws InvalidArgumentException, ParseException, SipException {
         if (device == null || channelId == null) {
             return;
         }
+        logger.info("[璇煶鍠婅瘽] device锛� {}, channel: {}", device.getDeviceId(), channelId);
         DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId);
         if (deviceChannel == null) {
             logger.warn("寮�鍚闊冲箍鎾殑鏃跺�欐湭鎵惧埌閫氶亾锛� {}", channelId);
@@ -818,7 +1000,7 @@
         }
         // 鏌ヨ閫氶亾浣跨敤鐘舵��
         if (audioBroadcastManager.exit(device.getDeviceId(), channelId)) {
-            SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(device.getDeviceId(), channelId, null, null);
+            SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(device.getDeviceId(), channelId, null, null);
             if (sendRtpItem != null && sendRtpItem.isOnlyAudio()) {
                 // 鏌ヨ娴佹槸鍚﹀瓨鍦紝涓嶅瓨鍦ㄥ垯璁や负鏄紓甯哥姸鎬�
                 MediaServerItem mediaServerItem = mediaServerService.getOne(sendRtpItem.getMediaServerId());
@@ -827,8 +1009,8 @@
                     logger.warn("璇煶骞挎挱宸茬粡寮�鍚細 {}", channelId);
                     event.call("璇煶骞挎挱宸茬粡寮�鍚�");
                     return;
-                }else {
-                    audioBroadcastManager.del(deviceChannel.getDeviceId(),channelId);
+                } else {
+                    audioBroadcastManager.del(deviceChannel.getDeviceId(), channelId);
                     redisCatchStorage.deleteSendRTPServer(device.getDeviceId(), channelId, sendRtpItem.getCallId(), sendRtpItem.getStreamId());
                 }
             }
@@ -847,39 +1029,33 @@
         });
     }
 
+
+
     @Override
-    public void stopAudioBroadcast(String deviceId, String channelId){
+    public void stopAudioBroadcast(String deviceId, String channelId) {
         AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId);
         if (audioBroadcastCatch != null) {
 
-            try {
-                SendRtpItem sendRtpItem =  redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
-                if (sendRtpItem != null) {
-                    redisCatchStorage.deleteSendRTPServer(deviceId, sendRtpItem.getChannelId(), null, null);
-                    MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
-                    Map<String, Object> param = new HashMap<>();
-                    param.put("vhost", "__defaultVhost__");
-                    param.put("app", sendRtpItem.getApp());
-                    param.put("stream", sendRtpItem.getStreamId());
-                    zlmresTfulUtils.stopSendRtp(mediaInfo, param);
-                    // 绔嬪埢缁撴潫璁惧鐨勬帹娴侊紝绛夊緟鑷缁撴潫澶參
-                    zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId());
-                }
-                if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) {
-                    cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getChannelId(), audioBroadcastCatch.getRequest(), null);
-                }
-                audioBroadcastManager.del(deviceId, channelId);
-
-            } catch (SipException e) {
-                throw new RuntimeException(e);
-            } catch (ParseException e) {
-                throw new RuntimeException(e);
-            } catch (InvalidArgumentException e) {
-                throw new RuntimeException(e);
+            Device device = deviceService.queryDevice(deviceId);
+            if (device == null) {
+                return;
             }
+//            if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) {
+//                cmder.streamByeCmd(device, audioBroadcastCatch.getChannelId(), null, audioBroadcastCatch.getSipTransactionInfo().getCallId());
+//            }
+            SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
+            if (sendRtpItem != null) {
+                redisCatchStorage.deleteSendRTPServer(deviceId, sendRtpItem.getChannelId(), null, null);
+                MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
+                Map<String, Object> param = new HashMap<>();
+                param.put("vhost", "__defaultVhost__");
+                param.put("app", sendRtpItem.getApp());
+                param.put("stream", sendRtpItem.getStreamId());
+                zlmresTfulUtils.stopSendRtp(mediaInfo, param);
+            }
+
+            audioBroadcastManager.del(deviceId, channelId);
         }
-
-
     }
 
     @Override
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
index ff9a39a..bcd8bf1 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
@@ -216,65 +216,20 @@
 	@Parameter(name = "timeout", description = "鎺ㄦ祦瓒呮椂鏃堕棿(绉�)", required = true)
 	@GetMapping("/broadcast/{deviceId}/{channelId}")
 	@PostMapping("/broadcast/{deviceId}/{channelId}")
-    public DeferredResult<String> broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout) {
+    public AudioBroadcastResult broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout) {
         if (logger.isDebugEnabled()) {
             logger.debug("璇煶骞挎挱API璋冪敤");
         }
         Device device = storager.queryVideoDevice(deviceId);
-		DeferredResult<String> result = new DeferredResult<>(3 * 1000L);
 		if (device == null) {
-			result.setResult("鏈壘鍒拌澶囷細 " + deviceId);
-			return result;
+			throw new ControllerException(ErrorCode.ERROR400.getCode(), "鏈壘鍒拌澶囷細 " + deviceId);
 		}
 		if (channelId == null) {
-			result.setResult("鏈壘鍒伴�氶亾锛� " + channelId);
-			return result;
+			throw new ControllerException(ErrorCode.ERROR400.getCode(), "鏈壘鍒伴�氶亾锛� " + channelId);
 		}
-		String key  = DeferredResultHolder.CALLBACK_CMD_BROADCAST + deviceId;
-		if (resultHolder.exist(key, null)) {
-			result.setResult("璁惧浣跨敤涓�");
-			return result;
-		}
-		if (timeout == null){
-			timeout = 30;
-		}
-		String uuid  = UUID.randomUUID().toString();
 
-		result.onTimeout(() -> {
-			logger.warn("璇煶骞挎挱鎿嶄綔瓒呮椂, 璁惧鏈繑鍥炲簲绛旀寚浠�");
-			RequestMessage msg = new RequestMessage();
-			msg.setKey(key);
-			msg.setId(uuid);
-			JSONObject json = new JSONObject();
-			json.put("DeviceID", deviceId);
-			json.put("CmdType", "Broadcast");
-			json.put("Result", "Failed");
-			json.put("Error", "Timeout. Device did not response to broadcast command.");
-			msg.setData(json);
-			resultHolder.invokeResult(msg);
-		});
+		return playService.audioBroadcast(device, channelId);
 
-		result.onTimeout(()->{
-			WVPResult<AudioBroadcastResult> wvpResult = new WVPResult<>();
-			wvpResult.setCode(-1);
-			wvpResult.setMsg("璇锋眰瓒呮椂");
-			RequestMessage requestMessage = new RequestMessage();
-			requestMessage.setKey(key);
-			requestMessage.setData(wvpResult);
-			resultHolder.invokeAllResult(requestMessage);
-		});
-		playService.audioBroadcast(device, channelId, timeout, (msg)->{
-			WVPResult<AudioBroadcastResult> wvpResult = new WVPResult<>();
-			wvpResult.setCode(-1);
-			wvpResult.setMsg(msg);
-			RequestMessage requestMessage = new RequestMessage();
-			requestMessage.setKey(key);
-			requestMessage.setData(wvpResult);
-			resultHolder.invokeAllResult(requestMessage);
-		});
-		resultHolder.put(key, uuid, result);
-
-		return result;
 	}
 
 
@@ -283,10 +238,16 @@
 	@Parameter(name = "channelId", description = "閫氶亾Id", required = true)
 	@GetMapping("/broadcast/stop/{deviceId}/{channelId}")
 	@PostMapping("/broadcast/stop/{deviceId}/{channelId}")
-	public void stopBroadcastA(@PathVariable String deviceId, @PathVariable String channelId) {
+	public void stopBroadcast(@PathVariable String deviceId, @PathVariable String channelId) {
 		if (logger.isDebugEnabled()) {
 			logger.debug("鍋滄璇煶骞挎挱API璋冪敤");
 		}
+//		try {
+//			playService.stopAudioBroadcast(deviceId, channelId);
+//		} catch (InvalidArgumentException | ParseException | SsrcTransactionNotFoundException | SipException e) {
+//			logger.error("[鍛戒护鍙戦�佸け璐 鍋滄璇煶: {}", e.getMessage());
+//			throw new ControllerException(ErrorCode.ERROR100.getCode(), "鍛戒护鍙戦�佸け璐�: " +  e.getMessage());
+//		}
 		playService.stopAudioBroadcast(deviceId, channelId);
 	}
 
diff --git a/web_src/config/index.js b/web_src/config/index.js
index c5a7452..c6287d0 100644
--- a/web_src/config/index.js
+++ b/web_src/config/index.js
@@ -12,14 +12,14 @@
     assetsPublicPath: '/',
     proxyTable: {
       '/debug': {
-        target: 'http://localhost:38080',
+        target: 'https://default.wvp-pro.cn:18080',
         changeOrigin: true,
         pathRewrite: {
           '^/debug': '/'
         }
       },
       '/static/snap': {
-        target: 'http://localhost:38080',
+        target: 'https://default.wvp-pro.cn:18080',
         changeOrigin: true,
         // pathRewrite: {
         //   '^/static/snap': '/static/snap'
diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue
index ee5fd7b..4c8f264 100644
--- a/web_src/src/components/dialog/devicePlayer.vue
+++ b/web_src/src/components/dialog/devicePlayer.vue
@@ -1,7 +1,7 @@
 <template>
 <div id="devicePlayer" v-loading="isLoging">
 
-    <el-dialog title="瑙嗛鎾斁" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" :destroy-on-close="true" @close="close()">
+    <el-dialog title="瑙嗛鎾斁" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()">
         <!-- <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></LivePlayer> -->
       <div style="width: 100%; height: 100%">
         <el-tabs type="card" :stretch="true" v-model="activePlayer" @tab-click="changePlayer" v-if="Object.keys(this.player).length > 1">
@@ -118,6 +118,10 @@
                                 <el-dropdown-item :command="streamInfo.rtc">
                                   <el-tag >RTC:</el-tag>
                                   <span>{{ streamInfo.rtc }}</span>
+                                </el-dropdown-item>
+                                <el-dropdown-item :command="streamInfo.rtcs">
+                                  <el-tag >RTCS:</el-tag>
+                                  <span>{{ streamInfo.rtcs }}</span>
                                 </el-dropdown-item>
                                 <el-dropdown-item :command="streamInfo.rtmp">
                                   <el-tag >RTMP:</el-tag>
@@ -875,7 +879,8 @@
                 }
               });
             }else if (this.broadcastStatus === 1) {
-              this.stopBroadcast()
+                this.broadcastStatus = -1;
+                this.broadcastRtc.close()
             }
         },
         startBroadcast(url){
@@ -890,6 +895,7 @@
                 message: "鑾峰彇鎺ㄦ祦閴存潈Key澶辫触",
                 type: "error",
               });
+              this.broadcastStatus = -1;
             }else {
               let pushKey = res.data.data.pushKey;
               // 鑾峰彇鎺ㄦ祦閴存潈KEY
@@ -923,6 +929,7 @@
                   message: '涓嶆敮鎸亀ebrtc, 鏃犳硶杩涜璇煶瀵硅',
                   type: 'error'
                 });
+                this.broadcastStatus = -1;
               });
 
               this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,(e)=>{// ICE 鍗忓晢鍑洪敊
@@ -932,6 +939,7 @@
                   message: 'ICE 鍗忓晢鍑洪敊',
                   type: 'error'
                 });
+                this.broadcastStatus = -1;
               });
 
               this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,(e)=>{// offer anwser 浜ゆ崲澶辫触
@@ -941,6 +949,7 @@
                   message: 'offer anwser 浜ゆ崲澶辫触' + e,
                   type: 'error'
                 });
+                this.broadcastStatus = -1;
               });
               this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE,(e)=>{// offer anwser 浜ゆ崲澶辫触
                 console.log('鐘舵�佹敼鍙�',e)
@@ -959,36 +968,38 @@
                   message: '鎹曡幏娴佸け璐�' + e,
                   type: 'error'
                 });
+                this.broadcastStatus = -1;
               });
             }
+          }).catch((e) => {
+            this.$message({
+              showClose: true,
+              message: e,
+              type: 'error'
+            });
+            this.broadcastStatus = -1;
           });
 
 
         },
         stopBroadcast(){
-          if (this.broadcastStatus === -1) {
-            this.broadcastStatus = 1;
-          }else {
-            this.broadcastStatus = -2;
-            this.broadcastRtc = null;
-            this.$axios({
-              method: 'get',
-              url: '/api/play/broadcast/stop/' + this.deviceId + '/' + this.channelId
-            }).then( (res)=> {
-              if (res.data.code == 0) {
-                // this.broadcastStatus = -1;
-                // this.broadcastRtc.close()
-              }else {
-                this.$message({
-                  showClose: true,
-                  message: res.data.msg,
-                  type: "error",
-                });
-              }
-            });
-          }
-
-
+          this.broadcastRtc.close();
+          this.broadcastStatus = -1;
+          this.$axios({
+            method: 'get',
+            url: '/api/play/broadcast/stop/' + this.deviceId + '/' + this.channelId
+          }).then( (res)=> {
+            if (res.data.code == 0) {
+              // this.broadcastStatus = -1;
+              // this.broadcastRtc.close()
+            }else {
+              this.$message({
+                showClose: true,
+                message: res.data.msg,
+                type: "error",
+              });
+            }
+          });
         }
     }
 };

--
Gitblit v1.8.0