| | |
| | | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.conf.DynamicTask; |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| | | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| | | import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| | | 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.media.zlm.ZLMServerFactory; |
| | | import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; |
| | | import com.genersoft.iot.vmp.media.bean.MediaServer; |
| | | import com.genersoft.iot.vmp.service.IDeviceService; |
| | | import com.genersoft.iot.vmp.media.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.service.IDeviceService; |
| | | import com.genersoft.iot.vmp.service.IPlayService; |
| | | import com.genersoft.iot.vmp.service.bean.RequestPushStreamMsg; |
| | | import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener; |
| | | import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.sip.InvalidArgumentException; |
| | | import javax.sip.RequestEvent; |
| | | import javax.sip.SipException; |
| | | import javax.sip.address.SipURI; |
| | | import javax.sip.header.CallIdHeader; |
| | | import javax.sip.header.FromHeader; |
| | | import javax.sip.header.HeaderAddress; |
| | | import javax.sip.header.ToHeader; |
| | | import java.text.ParseException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * SIP命令类型: ACK请求 |
| | |
| | | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | @Autowired |
| | | private IRedisRpcService redisRpcService; |
| | | |
| | | @Autowired |
| | | private UserSetting userSetting; |
| | |
| | | private IDeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private ZLMServerFactory zlmServerFactory; |
| | | |
| | | @Autowired |
| | | private HookSubscribe hookSubscribe; |
| | | |
| | | @Autowired |
| | | private IMediaServerService mediaServerService; |
| | | |
| | | @Autowired |
| | | private DynamicTask dynamicTask; |
| | | |
| | | @Autowired |
| | | private RedisGbPlayMsgListener redisGbPlayMsgListener; |
| | | |
| | | @Autowired |
| | | private IPlayService playService; |
| | |
| | | logger.info("[收到ACK]: 来自->{}", fromUserId); |
| | | SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId()); |
| | | if (sendRtpItem == null) { |
| | | logger.warn("[收到ACK]:未找到来自{},目标为({})的推流信息",fromUserId, toUserId); |
| | | logger.warn("[收到ACK]:未找到来自{},callId: {}", fromUserId, callIdHeader.getCallId()); |
| | | return; |
| | | } |
| | | // tcp主动时,此时是级联下级平台,在回复200ok时,本地已经请求zlm开启监听,跳过下面步骤 |
| | |
| | | |
| | | if (parentPlatform != null) { |
| | | if (!userSetting.getServerId().equals(sendRtpItem.getServerId())) { |
| | | RequestPushStreamMsg requestPushStreamMsg = RequestPushStreamMsg.getInstance( |
| | | sendRtpItem.getMediaServerId(), sendRtpItem.getApp(), sendRtpItem.getStream(), |
| | | sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc(), sendRtpItem.isTcp(), |
| | | sendRtpItem.getLocalPort(), sendRtpItem.getPt(), sendRtpItem.isUsePs(), sendRtpItem.isOnlyAudio()); |
| | | redisGbPlayMsgListener.sendMsgForStartSendRtpStream(sendRtpItem.getServerId(), requestPushStreamMsg, json -> { |
| | | playService.startSendRtpStreamFailHand(sendRtpItem, parentPlatform, callIdHeader); |
| | | }); |
| | | WVPResult wvpResult = redisRpcService.startSendRtp(sendRtpItem.getRedisKey(), sendRtpItem); |
| | | if (wvpResult.getCode() == 0) { |
| | | redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, parentPlatform); |
| | | } |
| | | } else { |
| | | try { |
| | | if (sendRtpItem.isTcpActive()) { |
| | | mediaServerService.startSendRtpPassive(mediaInfo, parentPlatform, sendRtpItem, null); |
| | | mediaServerService.startSendRtpPassive(mediaInfo,sendRtpItem, null); |
| | | } else { |
| | | mediaServerService.startSendRtpStream(mediaInfo, parentPlatform, sendRtpItem); |
| | | mediaServerService.startSendRtp(mediaInfo, sendRtpItem); |
| | | } |
| | | redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, parentPlatform); |
| | | }catch (ControllerException e) { |
| | | logger.error("RTP推流失败: {}", e.getMessage()); |
| | | playService.startSendRtpStreamFailHand(sendRtpItem, parentPlatform, callIdHeader); |
| | |
| | | } |
| | | try { |
| | | if (sendRtpItem.isTcpActive()) { |
| | | mediaServerService.startSendRtpPassive(mediaInfo, null, sendRtpItem, null); |
| | | mediaServerService.startSendRtpPassive(mediaInfo, sendRtpItem, null); |
| | | } else { |
| | | mediaServerService.startSendRtpStream(mediaInfo, null, sendRtpItem); |
| | | mediaServerService.startSendRtp(mediaInfo, sendRtpItem); |
| | | } |
| | | }catch (ControllerException e) { |
| | | logger.error("RTP推流失败: {}", e.getMessage()); |