| | |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.gb28181.bean.*; |
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| | | import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; |
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| | |
| | | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | |
| | | @Autowired |
| | | private SSRCFactory ssrcFactory; |
| | | |
| | | @Autowired |
| | | private DynamicTask dynamicTask; |
| | |
| | | return; |
| | | } |
| | | String username = sdp.getOrigin().getUsername(); |
| | | String addressStr = sdp.getOrigin().getAddress(); |
| | | String addressStr = sdp.getConnection().getAddress(); |
| | | |
| | | logger.info("[上级点播]用户:{}, 通道:{}, 地址:{}:{}, ssrc:{}", username, channelId, addressStr, port, ssrc); |
| | | Device device = null; |
| | |
| | | }, 60 * 1000); |
| | | responseSdpAck(request, content.toString(), platform); |
| | | |
| | | } 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"); |
| | | if ("Playback".equalsIgnoreCase(sessionName)) { |
| | | sendRtpItem.setPlayType(InviteStreamType.PLAYBACK); |
| | | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, device.isSsrcCheck(), true); |
| | | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam()); |
| | | sendRtpItem.setStreamId(ssrcInfo.getStream()); |
| | | // 写入redis, 超时时回复 |
| | | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| | |
| | | if (mediaServerItem.isRtpEnable()) { |
| | | streamId = String.format("%s_%s", device.getDeviceId(), channelId); |
| | | } |
| | | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, null, device.isSsrcCheck(), false); |
| | | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, null, device.isSsrcCheck(), false, 0, false, device.getStreamModeForParam()); |
| | | logger.info(JSONObject.toJSONString(ssrcInfo)); |
| | | sendRtpItem.setStreamId(ssrcInfo.getStream()); |
| | | sendRtpItem.setSsrc(ssrc.equals(ssrcDefault) ? ssrcInfo.getSsrc() : ssrc); |
| | |
| | | redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); |
| | | }); |
| | | } else { |
| | | // 当前系统作为下级平台使用,当上级平台点播时不携带ssrc时,并且设备在当前系统中已经点播了。这个时候需要重新给生成一个ssrc,不使用默认的"0000000000"。 |
| | | if (ssrc.equals(ssrcDefault)) { |
| | | ssrc = ssrcFactory.getPlaySsrc(mediaServerItem.getId()); |
| | | ssrcFactory.releaseSsrc(mediaServerItem.getId(), ssrc); |
| | | sendRtpItem.setSsrc(ssrc); |
| | | } |
| | | |
| | | sendRtpItem.setStreamId(playTransaction.getStream()); |
| | | // 写入redis, 超时时回复 |
| | | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| | |
| | | } |
| | | } |
| | | } else if (gbStream != null) { |
| | | if(ssrc.equals(ssrcDefault)) |
| | | { |
| | | ssrc = ssrcFactory.getPlaySsrc(mediaServerItem.getId()); |
| | | ssrcFactory.releaseSsrc(mediaServerItem.getId(), 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()) { |
| | |
| | | try { |
| | | return responseSdpAck(request, content.toString(), platform); |
| | | } 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; |
| | | } |
| | |
| | | return; |
| | | } |
| | | String username = sdp.getOrigin().getUsername(); |
| | | String addressStr = sdp.getOrigin().getAddress(); |
| | | String addressStr = sdp.getConnection().getAddress(); |
| | | logger.info("设备{}请求语音流,地址:{}:{},ssrc:{}", username, addressStr, port, ssrc); |
| | | } catch (SdpException e) { |
| | | logger.error("[SDP解析异常]", e); |