|
@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.common.StreamInfo;
|
|
|
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.GBStore;
|
|
|
import com.genersoft.iot.vmp.gb28181.SipLayer;
|
|
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
|
|
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
|
@@ -22,6 +23,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
|
|
|
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.IVideoManagerStorage;
|
|
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
|
|
import gov.nist.javax.sip.message.SIPRequest;
|
|
|
import gov.nist.javax.sip.message.SIPResponse;
|
|
@@ -51,6 +53,8 @@ public class SIPCommander implements ISIPCommander {
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(SIPCommander.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IVideoManagerStorage storager;
|
|
|
@Autowired
|
|
|
private SipConfig sipConfig;
|
|
|
|
|
@@ -80,6 +84,9 @@ public class SIPCommander implements ISIPCommander {
|
|
|
@Autowired
|
|
|
private TestInviteRequestProcessor testInviteRequestProcessor;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private GBStore gbStore;
|
|
|
+
|
|
|
/**
|
|
|
* 云台方向放控制,使用配置文件中的默认镜头移动速度
|
|
|
*
|
|
@@ -559,12 +566,34 @@ public class SIPCommander implements ISIPCommander {
|
|
|
// device.getHostAddress(),
|
|
|
// device.getPort()
|
|
|
// );
|
|
|
- testInviteRequestProcessor.responseBroadcastSdpACK(request,
|
|
|
+
|
|
|
+ SIPResponse sipResponse = testInviteRequestProcessor.responseBroadcastSdpACK(request,
|
|
|
sdpContent,
|
|
|
sipConfig.getId(),
|
|
|
mediaServerItem.getSdpIp(),
|
|
|
sipConfig.getPort()
|
|
|
);
|
|
|
+ logger.info("[语音广播] 添加sip信息至流媒体服务中");
|
|
|
+ streamSession.put(device.getDeviceId(),
|
|
|
+ device.getDeviceId(),
|
|
|
+ "broadcast",
|
|
|
+ ssrcInfo.getStream(),
|
|
|
+ ssrcInfo.getSsrc(),
|
|
|
+ mediaServerItem.getId(),
|
|
|
+ sipResponse,
|
|
|
+ VideoStreamSessionManager.SessionType.broadcast);
|
|
|
+
|
|
|
+// ResponseEvent responseEvent = (ResponseEvent) e.event;
|
|
|
+// SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
|
|
+// streamSession.put(
|
|
|
+// device.getDeviceId(),
|
|
|
+// broadcastItem.getChannelId(),
|
|
|
+// "play",
|
|
|
+// broadcastItem.getRecv_stream(),
|
|
|
+// ssrcInfo.getSsrc(),
|
|
|
+// mediaServerItem.getId(),
|
|
|
+// response,
|
|
|
+// VideoStreamSessionManager.SessionType.play);
|
|
|
}catch(SipException e){
|
|
|
logger.warn("返回audio invite 失败");
|
|
|
if(errorEvent != null){
|
|
@@ -739,11 +768,49 @@ public class SIPCommander implements ISIPCommander {
|
|
|
mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc());
|
|
|
mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream());
|
|
|
streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
|
|
-
|
|
|
+// if(ssrcTransaction.getApp){
|
|
|
+// // JSONObject result = mediaServerService.closeStreams(mediaServerItem, param.getApp(), param.getStream());
|
|
|
+// }
|
|
|
Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo());
|
|
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent);
|
|
|
}
|
|
|
|
|
|
+ public void streamByeBroadcastCmd(Device device,String channelId){
|
|
|
+
|
|
|
+ // 关闭推流通道
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public boolean stopBroadCast(String deviceId) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
|
|
|
+ String gbStoreKey = "broadcast_"+deviceId;
|
|
|
+ BroadcastItem broadcastItem = gbStore.queryBroadcastStore(gbStoreKey);
|
|
|
+ if(broadcastItem == null){
|
|
|
+ logger.error("无法找到该语音广播信息");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Device device = storager.queryVideoDevice(deviceId);
|
|
|
+ SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(),device.getDeviceId(), "broadcast", broadcastItem.getRecv_stream());
|
|
|
+ logger.info("关闭语音广播:{}",ssrcTransaction);
|
|
|
+ MediaServerItem mediaServerItem = mediaServerService.getOne(broadcastItem.getMediaId());
|
|
|
+ if(mediaServerItem == null){
|
|
|
+ logger.warn("无法连接至语音广播对应的媒体服务器,不尝试从流媒体服务器中获取语音广播信息");
|
|
|
+ }else{
|
|
|
+ // 从mediaServer 中关闭推流通道
|
|
|
+ if(ssrcTransaction != null){
|
|
|
+ mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc());
|
|
|
+ mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream());
|
|
|
+ }
|
|
|
+ // 关闭webrtc推流通道
|
|
|
+ mediaServerService.closeStreams(mediaServerItem,broadcastItem.getApp(),broadcastItem.getStream());
|
|
|
+ }
|
|
|
+ gbStore.delBroadcastStore(gbStoreKey);
|
|
|
+ // 发送bye给设备
|
|
|
+ Request byteRequest = headerProvider.createByteRequest(device, broadcastItem.getChannelId(), ssrcTransaction.getSipTransactionInfo());
|
|
|
+ sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, null);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|