| | |
| | | import javax.sip.header.CallIdHeader;
|
| | | import javax.sip.message.Request;
|
| | | import java.text.ParseException;
|
| | | import java.util.List;
|
| | |
|
| | | /**
|
| | | * @description:设备能力接口,用于定义设备的控制、查询能力
|
| | |
| | | }), e -> {
|
| | | ResponseEvent responseEvent = (ResponseEvent) e.event;
|
| | | SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
| | | streamSession.put(device.getDeviceId(), channelId, "play", stream, ssrcInfo.getSsrc(), mediaServerItem.getId(), response,
|
| | | String callId = response.getCallIdHeader().getCallId();
|
| | | streamSession.put(device.getDeviceId(), channelId, callId, stream, ssrcInfo.getSsrc(), mediaServerItem.getId(), response,
|
| | | InviteSessionType.PLAY);
|
| | | okEvent.response(e);
|
| | | });
|
| | |
| | | */
|
| | | @Override
|
| | | public void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
|
| | | SsrcTransaction ssrcTransaction;
|
| | | if (callId != null) {
|
| | | ssrcTransaction = streamSession.getSsrcTransaction(null, null, callId, null);
|
| | | }else {
|
| | | ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, null, stream);
|
| | | if (device == null) {
|
| | | logger.warn("[发送BYE] device为null");
|
| | | return;
|
| | | }
|
| | | if (ssrcTransaction == null) {
|
| | | List<SsrcTransaction> ssrcTransactionList = streamSession.getSsrcTransactionForAll(device.getDeviceId(), channelId, callId, stream);
|
| | | if (ssrcTransactionList == null || ssrcTransactionList.isEmpty()) {
|
| | | logger.info("[发送BYE] 未找到事务信息,设备: device: {}, channel: {}", device.getDeviceId(), channelId);
|
| | | throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream);
|
| | | }
|
| | |
|
| | | mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc());
|
| | | mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream());
|
| | | streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
| | | for (SsrcTransaction ssrcTransaction : ssrcTransactionList) {
|
| | | logger.info("[发送BYE] 设备: device: {}, channel: {}, callId: {}", device.getDeviceId(), channelId, ssrcTransaction.getCallId());
|
| | | mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc());
|
| | |
|
| | | Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo());
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent);
|
| | | mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream());
|
| | | streamSession.removeByCallId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getCallId());
|
| | | Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo());
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent);
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
|
| | | Request byteRequest = headerProvider.createByteRequest(device, channelId, sipTransactionInfo);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void streamByeCmdForDeviceInvite(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
|
| | | Request byteRequest = headerProvider.createByteRequestForDeviceInvite(device, channelId, sipTransactionInfo);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent);
|
| | | }
|
| | |
|
| | |
| | | catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
| | | catalogXml.append("</Query>\r\n");
|
| | |
|
| | | |
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | |
|