| | |
| | | import com.genersoft.iot.vmp.gb28181.bean.*; |
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| | | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; |
| | | import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; |
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| | |
| | | |
| | | MediaServerItem mediaServerItem = null; |
| | | StreamPushItem streamPushItem = null; |
| | | StreamProxyItem proxyByAppAndStream =null; |
| | | StreamProxyItem proxyByAppAndStream = null; |
| | | // 不是通道可能是直播流 |
| | | if (channel != null && gbStream == null) { |
| | | // 通道存在,发100,TRYING |
| | |
| | | if (!userSetting.getPushStreamAfterAck()) { |
| | | playService.startPushStream(sendRtpItem, sipResponse, platform, request.getCallIdHeader()); |
| | | } |
| | | } catch (SipException e) { |
| | | e.printStackTrace(); |
| | | } catch (InvalidArgumentException e) { |
| | | e.printStackTrace(); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } catch (SipException | InvalidArgumentException | ParseException e) { |
| | | logger.error("[命令发送失败] 国标级联 回复SdpAck", e); |
| | | } |
| | | }; |
| | | SipSubscribe.Event errorEvent = ((event) -> { |
| | |
| | | Response response = getMessageFactory().createResponse(event.statusCode, evt.getRequest()); |
| | | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); |
| | | } catch (ParseException | SipException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } |
| | | }); |
| | | sendRtpItem.setApp("rtp"); |
| | |
| | | } |
| | | } |
| | | } else if (gbStream != null) { |
| | | if(ssrc.equals(ssrcDefault)) |
| | | { |
| | | SsrcConfig ssrcConfig = mediaServerItem.getSsrcConfig(); |
| | | if(ssrcConfig != null) |
| | | { |
| | | ssrc = ssrcConfig.getPlaySsrc(); |
| | | ssrcConfig.releaseSsrc(ssrc); |
| | | } |
| | | } |
| | | if("push".equals(gbStream.getStreamType())) { |
| | | if (streamPushItem != null && streamPushItem.isPushIng()) { |
| | | // 推流状态 |
| | |
| | | } catch (SdpParseException e) { |
| | | logger.error("sdp解析错误", e); |
| | | } catch (SdpException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } |
| | | } |
| | | |
| | |
| | | mediaListManager.removedChannelOnlineEventLister(gbStream.getApp(), gbStream.getStream()); |
| | | responseAck(request, Response.REQUEST_TIMEOUT); // 超时 |
| | | } catch (SipException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } catch (InvalidArgumentException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } |
| | | }, userSetting.getPlatformPlayTimeout()); |
| | | // 添加监听 |
| | |
| | | try { |
| | | responseAck(request, Response.BUSY_HERE); |
| | | } catch (SipException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } catch (InvalidArgumentException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } |
| | | return; |
| | | } |
| | |
| | | try { |
| | | responseAck(request, Response.BUSY_HERE); |
| | | } catch (SipException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } catch (InvalidArgumentException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } |
| | | return; |
| | | } |
| | |
| | | content.append("s=Play\r\n"); |
| | | content.append("c=IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); |
| | | content.append("t=0 0\r\n"); |
| | | content.append("m=video " + sendRtpItem.getLocalPort() + " RTP/AVP 96\r\n"); |
| | | // 非严格模式端口不统一, 增加兼容性,修改为一个不为0的端口 |
| | | int localPort = sendRtpItem.getLocalPort(); |
| | | if(localPort == 0) |
| | | { |
| | | localPort = new Random().nextInt(65535) + 1; |
| | | } |
| | | content.append("m=video " + localPort + " RTP/AVP 96\r\n"); |
| | | content.append("a=sendonly\r\n"); |
| | | content.append("a=rtpmap:96 PS/90000\r\n"); |
| | | if (sendRtpItem.isTcp()) { |
| | |
| | | } |
| | | return sipResponse; |
| | | } catch (SipException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } catch (InvalidArgumentException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | logger.error("未处理的异常 ", e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public void inviteFromDeviceHandle(SIPRequest request, String requesterId, String channelId) { |
| | | |
| | | String realChannelId = null; |
| | | |
| | | // 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备) |
| | | Device device = redisCatchStorage.getDevice(requesterId); |
| | | AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(requesterId, channelId); |
| | | // 判断requesterId是设备还是通道 |
| | | if (device == null) { |
| | | device = storager.queryVideoDeviceByChannelId(requesterId); |
| | | realChannelId = requesterId; |
| | | } |
| | | if (device == null) { |
| | | // 检查channelID是否可用 |
| | | device = redisCatchStorage.getDevice(channelId); |
| | | if (device == null) { |
| | | device = storager.queryVideoDeviceByChannelId(channelId); |
| | | realChannelId = channelId; |
| | | } |
| | | } |
| | | |
| | | if (device == null) { |
| | | logger.warn("来自设备的Invite请求,无法从请求信息中确定所属设备,已忽略,requesterId: {}/{}", requesterId, channelId); |
| | | try { |
| | | responseAck(request, Response.FORBIDDEN); |
| | | } catch (SipException | InvalidArgumentException | ParseException e) { |
| | | logger.error("[命令发送失败] 来自设备的Invite请求,无法从请求信息中确定所属设备 FORBIDDEN: {}", e.getMessage()); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(device.getDeviceId(), realChannelId); |
| | | if (broadcastCatch == null) { |
| | | logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId); |
| | | try { |
| | |
| | | |
| | | |
| | | CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); |
| | | sendRtpItem.setPlayType(InviteStreamType.TALK); |
| | | sendRtpItem.setPlayType(InviteStreamType.BROADCAST); |
| | | sendRtpItem.setCallId(callIdHeader.getCallId()); |
| | | sendRtpItem.setPlatformId(requesterId); |
| | | sendRtpItem.setStatus(1); |
| | |
| | | } |
| | | |
| | | } catch (SipException | InvalidArgumentException | ParseException | SdpParseException e) { |
| | | logger.error("[命令发送失败] 语音对讲 回复200OK(SDP): {}", e.getMessage()); |
| | | logger.error("[命令发送失败] 语音喊话 回复200OK(SDP): {}", e.getMessage()); |
| | | } |
| | | return sipResponse; |
| | | } |