| | |
| | | import com.ard.common.core.domain.R; |
| | | import com.ard.gb28181.api.RemoteGb28181Service; |
| | | import com.ard.gb28181.api.domain.Device; |
| | | import com.ard.qs.api.RemoteQsDeviceService; |
| | | import com.ard.qs.api.domain.QsDevice; |
| | | import com.ard.zlm.service.ZlmStreamService; |
| | | import com.ard.zlm.domain.StreamChannel; |
| | | import com.ard.zlm.api.domain.RTPServerParam; |
| | | import com.ard.zlm.api.domain.StreamPullPlay; |
| | | import com.ard.zlm.api.domain.ZlmMediaServer; |
| | |
| | | public class MediaServiceImpl implements IMediaService { |
| | | |
| | | @Autowired |
| | | private RemoteQsDeviceService remoteQsDeviceService; |
| | | private ZlmStreamService zlmStreamService; |
| | | |
| | | @Autowired |
| | | private IMediaServerService mediaServerService; |
| | |
| | | @Override |
| | | public boolean closeStreamOnNoneReader(String mediaServerId, String app, String stream, String schema) { |
| | | |
| | | R<QsDevice> r = remoteQsDeviceService.getQsDeviceStream(stream, SecurityConstants.INNER); |
| | | if (r.getCode() != Constants.SUCCESS) { |
| | | return false; |
| | | } |
| | | |
| | | QsDevice data = r.getData(); |
| | | if (data == null) { |
| | | return false; |
| | | } |
| | | |
| | | // 拉流代理 |
| | | if ("rtsp".equals(app) || "rtmp".equals(app) || "flv".equals(app) || "hls".equals(app)) { |
| | | if ("1".equals(data.getEnableDisableNoneReader())) { |
| | | // 无人观看停用 |
| | | // 修改数据 |
| | | StreamPullPlay streamPullPlay = new StreamPullPlay(); |
| | | streamPullPlay.setDeviceId(data.getId()); |
| | | streamPullPlay.setStreamKey(data.getStreamKey()); |
| | | streamPullPlay.setMediaServerId(data.getMediaServerId()); |
| | | |
| | | mediaServerService.stopStreamPullPlay(streamPullPlay); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } else if ("haikang".equals(app) || "haikang_isup".equals(app) || "dahua".equals(app)) { |
| | | if ("1".equals(data.getEnableDisableNoneReader())) { |
| | | // 无人观看停用 |
| | | RTPServerParam rtpServerParam = new RTPServerParam(); |
| | | rtpServerParam.setId(data.getId()); |
| | | rtpServerParam.setType(data.getType()); |
| | | rtpServerParam.setStreamId(stream); |
| | | mediaServerService.stopRtpPlay(rtpServerParam); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } else if ("push".equals(app)) { |
| | | if ("1".equals(data.getEnableDisableNoneReader())) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } else if ("gb28181".equals(app)) { |
| | | if ("1".equals(data.getEnableDisableNoneReader())) { |
| | | R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(data.getGbDeviceId(), SecurityConstants.INNER); |
| | | if (deviceR.getCode() == Constants.SUCCESS && deviceR.getData() != null) { |
| | | mediaServerService.stopGb28181Play(InviteSessionType.PLAY, data, deviceR.getData(), data.getDeviceCode()); |
| | | } |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | // R<StreamChannel> r = zlmStreamService.getQsDeviceStream(stream, SecurityConstants.INNER); |
| | | // if (r.getCode() != Constants.SUCCESS) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // StreamChannel data = r.getData(); |
| | | // if (data == null) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // // 拉流代理 |
| | | // if ("rtsp".equals(app) || "rtmp".equals(app) || "flv".equals(app) || "hls".equals(app)) { |
| | | // if ("1".equals(data.getEnableDisableNoneReader())) { |
| | | // // 无人观看停用 |
| | | // // 修改数据 |
| | | // StreamPullPlay streamPullPlay = new StreamPullPlay(); |
| | | // streamPullPlay.setDeviceId(data.getId()); |
| | | // streamPullPlay.setStreamKey(data.getStreamKey()); |
| | | // streamPullPlay.setMediaServerId(data.getMediaServerId()); |
| | | // |
| | | // mediaServerService.stopStreamPullPlay(streamPullPlay); |
| | | // return true; |
| | | // } else { |
| | | // return false; |
| | | // } |
| | | // } else if ("haikang".equals(app) || "haikang_isup".equals(app) || "dahua".equals(app)) { |
| | | // if ("1".equals(data.getEnableDisableNoneReader())) { |
| | | // // 无人观看停用 |
| | | // RTPServerParam rtpServerParam = new RTPServerParam(); |
| | | // rtpServerParam.setId(data.getId()); |
| | | // rtpServerParam.setType(data.getType()); |
| | | // rtpServerParam.setStreamId(stream); |
| | | // mediaServerService.stopRtpPlay(rtpServerParam); |
| | | // return true; |
| | | // } else { |
| | | // return false; |
| | | // } |
| | | // } else if ("push".equals(app)) { |
| | | // if ("1".equals(data.getEnableDisableNoneReader())) { |
| | | // return true; |
| | | // } else { |
| | | // return false; |
| | | // } |
| | | // } else if ("gb28181".equals(app)) { |
| | | // if ("1".equals(data.getEnableDisableNoneReader())) { |
| | | // R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(data.getGbDeviceId(), SecurityConstants.INNER); |
| | | // if (deviceR.getCode() == Constants.SUCCESS && deviceR.getData() != null) { |
| | | // mediaServerService.stopGb28181Play(InviteSessionType.PLAY, data, deviceR.getData(), data.getDeviceCode()); |
| | | // } |
| | | // return true; |
| | | // } else { |
| | | // return false; |
| | | // } |
| | | // } |
| | | return true; |
| | | } |
| | | |
| | |
| | | |
| | | // 海康sdk 海康isup 大华sdk |
| | | if ("haikang".equals(app) || "haikang_isup".equals(app) || "dahua".equals(app)) { |
| | | R<QsDevice> r = remoteQsDeviceService.getQsDeviceStream(stream, SecurityConstants.INNER); |
| | | R<StreamChannel> r = zlmStreamService.getQsDeviceStream(stream, SecurityConstants.INNER); |
| | | |
| | | if (r.getCode() != Constants.SUCCESS) { |
| | | result.setEnable_mp4(false); |
| | |
| | | } |
| | | // 推流 |
| | | if ("push".equals(app)) { |
| | | R<QsDevice> r = remoteQsDeviceService.getQsDeviceStream(stream, SecurityConstants.INNER); |
| | | R<StreamChannel> r = zlmStreamService.getQsDeviceStream(stream, SecurityConstants.INNER); |
| | | |
| | | if (r.getCode() != Constants.SUCCESS) { |
| | | result.setEnable_mp4(false); |