| | |
| | | import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | |
| | | public void process(RequestEvent evt) { |
| | | |
| | | try { |
| | | responseAck(getServerTransaction(evt), Response.OK); |
| | | responseAck((SIPRequest) evt.getRequest(), Response.OK); |
| | | } catch (SipException | InvalidArgumentException | ParseException e) { |
| | | logger.error("[回复BYE信息失败],{}", e.getMessage()); |
| | | } |
| | |
| | | if (sendRtpItem != null){ |
| | | logger.info("[收到bye] {}/{}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId()); |
| | | String streamId = sendRtpItem.getStreamId(); |
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(sendRtpItem.getMediaServerId()); |
| | | if (mediaServerItem == null) { |
| | | return; |
| | | } |
| | | |
| | | Boolean ready = zlmrtpServerFactory.isStreamReady(mediaServerItem, sendRtpItem.getApp(), streamId); |
| | | if (!ready) { |
| | | logger.info("[收到bye] 发现流{}/{}已经结束,不需处理", sendRtpItem.getApp(), sendRtpItem.getStreamId()); |
| | | return; |
| | | } |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("vhost","__defaultVhost__"); |
| | | param.put("app",sendRtpItem.getApp()); |
| | |
| | | MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); |
| | | redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), callIdHeader.getCallId(), null); |
| | | zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param); |
| | | |
| | | int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId); |
| | | if (totalReaderCount <= 0) { |
| | | logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId); |
| | | if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) { |
| | | Device device = deviceService.queryDevice(sendRtpItem.getDeviceId()); |
| | | Device device = deviceService.getDevice(sendRtpItem.getDeviceId()); |
| | | if (device == null) { |
| | | logger.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId); |
| | | } |
| | |
| | | redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel); |
| | | } |
| | | } |
| | | |
| | | playService.stopAudioBroadcast(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); |
| | | } |
| | | |