| | |
| | | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| | | import com.genersoft.iot.vmp.gb28181.SipLayer; |
| | | import com.genersoft.iot.vmp.gb28181.bean.*; |
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; |
| | | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| | | import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| | | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| | | 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.MediaServerItem; |
| | | import com.genersoft.iot.vmp.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| | | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.utils.GitUtil; |
| | | import com.genersoft.iot.vmp.utils.SerializeUtils; |
| | | import gov.nist.javax.sip.SIPConstants; |
| | | import gov.nist.javax.sip.SipProviderImpl; |
| | | import gov.nist.javax.sip.SipStackImpl; |
| | | import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | import gov.nist.javax.sip.message.MessageFactoryImpl; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import gov.nist.javax.sip.message.SIPResponse; |
| | | 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.lang.Nullable; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.sip.*; |
| | | import javax.sip.header.*; |
| | | import javax.sip.InvalidArgumentException; |
| | | import javax.sip.ResponseEvent; |
| | | import javax.sip.SipException; |
| | | import javax.sip.header.CallIdHeader; |
| | | import javax.sip.header.WWWAuthenticateHeader; |
| | | import javax.sip.message.Request; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | |
| | | @Autowired |
| | | private ZLMRTPServerFactory zlmrtpServerFactory; |
| | | |
| | | @Lazy |
| | | @Autowired |
| | | @Qualifier(value="tcpSipProvider") |
| | | private SipProviderImpl tcpSipProvider; |
| | | |
| | | @Lazy |
| | | @Autowired |
| | | @Qualifier(value="udpSipProvider") |
| | | private SipProviderImpl udpSipProvider; |
| | | private SipLayer sipLayer; |
| | | |
| | | @Autowired |
| | | private SipFactory sipFactory; |
| | | private SIPSender sipSender; |
| | | |
| | | @Autowired |
| | | private SubscribeHolder subscribeHolder; |
| | | private ZlmHttpHookSubscribe subscribe; |
| | | |
| | | @Autowired |
| | | private UserSetting userSetting; |
| | | |
| | | |
| | | @Autowired |
| | | private VideoStreamSessionManager streamSession; |
| | | |
| | | @Override |
| | | public void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException { |
| | |
| | | SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain, boolean isRegister) throws SipException, InvalidArgumentException, ParseException { |
| | | Request request; |
| | | if (!registerAgain ) { |
| | | CallIdHeader callIdHeader = null; |
| | | if(parentPlatform.getTransport().equalsIgnoreCase("TCP")) { |
| | | callIdHeader = tcpSipProvider.getNewCallId(); |
| | | } |
| | | if(parentPlatform.getTransport().equalsIgnoreCase("UDP")) { |
| | | callIdHeader = udpSipProvider.getNewCallId(); |
| | | } |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, |
| | | redisCatchStorage.getCSEQ(), SipUtils.getNewFromTag(), |
| | |
| | | }); |
| | | |
| | | }else { |
| | | CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| | | : udpSipProvider.getNewCallId(); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, SipUtils.getNewFromTag(), null, callId, www, callIdHeader, isRegister); |
| | | } |
| | | |
| | | transmitRequest(parentPlatform, request, null, okEvent); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, okEvent); |
| | | } |
| | | |
| | | @Override |
| | |
| | | keepaliveXml.append("<Status>OK</Status>\r\n"); |
| | | keepaliveXml.append("</Notify>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| | | : udpSipProvider.getNewCallId(); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest( |
| | | parentPlatform, |
| | |
| | | SipUtils.getNewFromTag(), |
| | | SipUtils.getNewViaTag(), |
| | | callIdHeader); |
| | | transmitRequest(parentPlatform, request, errorEvent, okEvent); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, errorEvent, okEvent); |
| | | return callIdHeader.getCallId(); |
| | | } |
| | | |
| | | private void transmitRequest(ParentPlatform parentPlatform, Request request) throws SipException { |
| | | transmitRequest(parentPlatform, request, null, null); |
| | | } |
| | | |
| | | private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent) throws SipException { |
| | | transmitRequest(parentPlatform, request, errorEvent, null); |
| | | } |
| | | |
| | | private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException { |
| | | logger.debug("\n发送消息:\n{}", request); |
| | | if("TCP".equalsIgnoreCase(parentPlatform.getTransport())) { |
| | | tcpSipProvider.sendRequest(request); |
| | | |
| | | } else if("UDP".equalsIgnoreCase(parentPlatform.getTransport())) { |
| | | udpSipProvider.sendRequest(request); |
| | | } |
| | | |
| | | CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME); |
| | | // 添加错误订阅 |
| | | if (errorEvent != null) { |
| | | sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), errorEvent); |
| | | } |
| | | // 添加订阅 |
| | | if (okEvent != null) { |
| | | sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), okEvent); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | String catalogXml = getCatalogXml(channels, sn, parentPlatform, size); |
| | | |
| | | // callid |
| | | CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| | | : udpSipProvider.getNewCallId(); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | transmitRequest(parentPlatform, request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size()); |
| | | // callid |
| | | CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| | | : udpSipProvider.getNewCallId(); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | transmitRequest(parentPlatform, request, null, eventResult -> { |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, eventResult -> { |
| | | int indexNext = index + parentPlatform.getCatalogGroup(); |
| | | try { |
| | | sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext); |
| | |
| | | deviceInfoXml.append("<Result>OK</Result>\r\n"); |
| | | deviceInfoXml.append("</Response>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| | | : udpSipProvider.getNewCallId(); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | transmitRequest(parentPlatform, request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | } |
| | | |
| | | /** |
| | |
| | | deviceStatusXml.append("<Status>OK</Status>\r\n"); |
| | | deviceStatusXml.append("</Response>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| | | : udpSipProvider.getNewCallId(); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | transmitRequest(parentPlatform, request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | logger.info("[发送报警通知] {}/{}->{},{}: {}", parentPlatform.getServerGBId(), deviceAlarm.getChannelId(), |
| | | deviceAlarm.getLongitude(), deviceAlarm.getLatitude(), JSONObject.toJSON(deviceAlarm)); |
| | | deviceAlarm.getLongitude(), deviceAlarm.getLatitude(), JSON.toJSONString(deviceAlarm)); |
| | | String characterSet = parentPlatform.getCharacterSet(); |
| | | StringBuffer deviceStatusXml = new StringBuffer(600); |
| | | deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| | |
| | | deviceStatusXml.append("</info>\r\n"); |
| | | deviceStatusXml.append("</Notify>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| | | : udpSipProvider.getNewCallId(); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader); |
| | | transmitRequest(parentPlatform, request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | |
| | | } |
| | | |
| | |
| | | private void sendNotify(ParentPlatform parentPlatform, String catalogXmlContent, |
| | | SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent ) |
| | | throws SipException, ParseException, InvalidArgumentException { |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); |
| | | String characterSet = parentPlatform.getCharacterSet(); |
| | | // 设置编码, 防止中文乱码 |
| | | messageFactory.setDefaultContentEncodingCharset(characterSet); |
| | | |
| | | SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo); |
| | | |
| | | transmitRequest(parentPlatform, notifyRequest); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), notifyRequest); |
| | | } |
| | | |
| | | private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List<DeviceChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) { |
| | |
| | | recordXml.append("</Response>\r\n"); |
| | | |
| | | // callid |
| | | CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() |
| | | : udpSipProvider.getNewCallId(); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | transmitRequest(parentPlatform, request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void sendMediaStatusNotify(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { |
| | | if (sendRtpItem == null || platform == null) { |
| | | public void sendMediaStatusNotify(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { |
| | | if (sendRtpItem == null || parentPlatform == null) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | String characterSet = platform.getCharacterSet(); |
| | | String characterSet = parentPlatform.getCharacterSet(); |
| | | StringBuffer mediaStatusXml = new StringBuffer(200); |
| | | mediaStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| | | mediaStatusXml.append("<Notify>\r\n"); |
| | |
| | | mediaStatusXml.append("<NotifyType>121</NotifyType>\r\n"); |
| | | mediaStatusXml.append("</Notify>\r\n"); |
| | | |
| | | SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(platform, mediaStatusXml.toString(), |
| | | SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(parentPlatform, mediaStatusXml.toString(), |
| | | sendRtpItem); |
| | | |
| | | transmitRequest(platform, messageRequest); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(),messageRequest); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @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("[向上级发送BYE], sendRtpItem 为NULL"); |
| | | return; |
| | |
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); |
| | | if (mediaServerItem != null) { |
| | | mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc()); |
| | | zlmrtpServerFactory.closeRTPServer(mediaServerItem, sendRtpItem.getStreamId()); |
| | | zlmrtpServerFactory.closeRtpServer(mediaServerItem, sendRtpItem.getStreamId()); |
| | | } |
| | | SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(platform, sendRtpItem); |
| | | if (byeRequest == null) { |
| | | logger.warn("[向上级发送bye]:无法创建 byeRequest"); |
| | | } |
| | | transmitRequest(platform,byeRequest); |
| | | sipSender.transmitRequest(platform.getDeviceIp(),byeRequest); |
| | | } |
| | | |
| | | @Override |
| | | public void streamByeCmd(ParentPlatform platform, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { |
| | | SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(platform.getServerGBId(), channelId, callId, stream); |
| | | if (ssrcTransaction == null) { |
| | | throw new SsrcTransactionNotFoundException(platform.getServerGBId(), channelId, callId, stream); |
| | | } |
| | | |
| | | mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc()); |
| | | mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream()); |
| | | streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); |
| | | |
| | | Request byteRequest = headerProviderPlatformProvider.createByteRequest(platform, channelId, ssrcTransaction.getSipTransactionInfo()); |
| | | sipSender.transmitRequest(sipLayer.getLocalIp(platform.getDeviceIp()), byteRequest, null, okEvent); |
| | | } |
| | | |
| | | @Override |
| | | public void broadcastResultCmd(ParentPlatform platform, DeviceChannel deviceChannel, String sn, boolean result, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { |
| | | if (platform == null || deviceChannel == null) { |
| | | return; |
| | | } |
| | | String characterSet = platform.getCharacterSet(); |
| | | StringBuffer mediaStatusXml = new StringBuffer(200); |
| | | mediaStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| | | mediaStatusXml.append("<Notify>\r\n"); |
| | | mediaStatusXml.append("<CmdType>Broadcast</CmdType>\r\n"); |
| | | mediaStatusXml.append("<SN>" + sn + "</SN>\r\n"); |
| | | mediaStatusXml.append("<DeviceID>" + deviceChannel.getChannelId() + "</DeviceID>\r\n"); |
| | | mediaStatusXml.append("<Result>" + (result?"OK":"ERROR") + "</Result>\r\n"); |
| | | mediaStatusXml.append("</Notify>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(platform.getDeviceIp(), platform.getTransport()); |
| | | |
| | | SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(platform, mediaStatusXml.toString(), |
| | | SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader); |
| | | |
| | | sipSender.transmitRequest(platform.getDeviceIp(),messageRequest, errorEvent, okEvent); |
| | | } |
| | | |
| | | @Override |
| | | public void broadcastInviteCmd(ParentPlatform platform, String channelId, MediaServerItem mediaServerItem, |
| | | SSRCInfo ssrcInfo, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, |
| | | SipSubscribe.Event errorEvent) throws ParseException, SipException, InvalidArgumentException { |
| | | String stream = ssrcInfo.getStream(); |
| | | |
| | | if (platform == null) { |
| | | return; |
| | | } |
| | | |
| | | logger.info("{} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); |
| | | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId()); |
| | | subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { |
| | | if (event != null) { |
| | | event.response(mediaServerItemInUse, json); |
| | | subscribe.removeSubscribe(hookSubscribe); |
| | | } |
| | | }); |
| | | String sdpIp = mediaServerItem.getSdpIp(); |
| | | |
| | | StringBuffer content = new StringBuffer(200); |
| | | content.append("v=0\r\n"); |
| | | content.append("o=" + channelId + " 0 0 IN IP4 " + sdpIp + "\r\n"); |
| | | content.append("s=Play\r\n"); |
| | | content.append("c=IN IP4 " + sdpIp + "\r\n"); |
| | | content.append("t=0 0\r\n"); |
| | | |
| | | if ("TCP-PASSIVE".equalsIgnoreCase(userSetting.getBroadcastForPlatform())) { |
| | | content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 8 96\r\n"); |
| | | } else if ("TCP-ACTIVE".equalsIgnoreCase(userSetting.getBroadcastForPlatform())) { |
| | | content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 8 96\r\n"); |
| | | } else if ("UDP".equalsIgnoreCase(userSetting.getBroadcastForPlatform())) { |
| | | content.append("m=video " + ssrcInfo.getPort() + " RTP/AVP 8 96\r\n"); |
| | | } |
| | | |
| | | content.append("a=recvonly\r\n"); |
| | | content.append("a=rtpmap:8 PCMA/8000\r\n"); |
| | | content.append("a=rtpmap:96 PS/90000\r\n"); |
| | | if ("TCP-PASSIVE".equalsIgnoreCase(userSetting.getBroadcastForPlatform())) { |
| | | content.append("a=setup:passive\r\n"); |
| | | content.append("a=connection:new\r\n"); |
| | | }else if ("TCP-ACTIVE".equalsIgnoreCase(userSetting.getBroadcastForPlatform())) { |
| | | content.append("a=setup:active\r\n"); |
| | | content.append("a=connection:new\r\n"); |
| | | } |
| | | |
| | | content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(platform.getDeviceIp()), platform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createInviteRequest(platform, channelId, |
| | | content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(), |
| | | callIdHeader ,platform.getTransport()); |
| | | sipSender.transmitRequest(sipLayer.getLocalIp(platform.getDeviceIp()), request, (e -> { |
| | | streamSession.remove(platform.getServerGBId(), channelId, ssrcInfo.getStream()); |
| | | mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); |
| | | errorEvent.response(e); |
| | | }), e -> { |
| | | // 这里为例避免一个通道的点播只有一个callID这个参数使用一个固定值 |
| | | ResponseEvent responseEvent = (ResponseEvent) e.event; |
| | | SIPResponse response = (SIPResponse) responseEvent.getResponse(); |
| | | streamSession.put(platform.getServerGBId(), channelId, callIdHeader.getCallId(), stream, ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.play); |
| | | okEvent.response(e); |
| | | }); |
| | | } |
| | | } |