| | |
| | | import com.ard.gb28181.api.domain.Device; |
| | | import com.ard.qs.api.RemoteQsDeviceService; |
| | | import com.ard.qs.api.domain.QsDevice; |
| | | import com.ard.work.api.RemoteCameraService; |
| | | import com.ard.zlm.api.domain.*; |
| | | import com.ard.zlm.api.hook.OriginType; |
| | | import com.ard.zlm.common.InviteErrorCode; |
| | |
| | | import com.ard.zlm.service.*; |
| | | import com.ard.zlm.session.SSRCFactory; |
| | | import com.ard.zlm.utils.ZLMRESTfulUtils; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Service |
| | | public class MediaServerServiceImpl implements IMediaServerService { |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private MediaServerMapper mediaServerMapper; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private UserSetting userSetting; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private Map<String, IMediaNodeServerService> nodeServerServiceMap; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private ApplicationEventPublisher applicationEventPublisher; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private MediaConfig mediaConfig; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private IMediaNodeServerService mediaNodeServerService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private DynamicTask dynamicTask; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private HookSubscribe subscribe; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private RemoteQsDeviceService remoteQsDeviceService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private ZLMRESTfulUtils zlmresTfulUtils; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private SSRCFactory ssrcFactory; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | @Lazy |
| | | private IReceiveRtpServerService receiveRtpServerService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | @Lazy |
| | | private IInviteStreamService inviteStreamService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private IZlmCloudRecordService zlmCloudRecordService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private RemoteGb28181Service remoteGb28181Service; |
| | | |
| | | |
| | |
| | | callback.run(InviteErrorCode.FAIL.getCode(), "无可用的节点", null); |
| | | return; |
| | | } |
| | | R<QsDevice> devicer = remoteQsDeviceService.getQsDeviceInfo(streamPullPlay.getDeviceId(), SecurityConstants |
| | | .INNER); |
| | | if (devicer.getCode() != Constants.SUCCESS) { |
| | | throw new RuntimeException("获取设备信息失败" + streamPullPlay.getDeviceId()); |
| | | } |
| | | |
| | | if (devicer.getData() == null) { |
| | | throw new RuntimeException("设备不存在" + streamPullPlay.getDeviceId()); |
| | | } |
| | | |
| | | if ("OFFLINE".equals(devicer.getData().getDeviceStatus())) { |
| | | throw new RuntimeException("设备不在线" + streamPullPlay.getDeviceId()); |
| | | } |
| | | // R<QsDevice> devicer = remoteQsDeviceService.getQsDeviceInfo(streamPullPlay.getDeviceId(), SecurityConstants |
| | | // .INNER); |
| | | // if (devicer.getCode() != Constants.SUCCESS) { |
| | | // throw new RuntimeException("获取设备信息失败" + streamPullPlay.getDeviceId()); |
| | | // } |
| | | // |
| | | // if (devicer.getData() == null) { |
| | | // throw new RuntimeException("设备不存在" + streamPullPlay.getDeviceId()); |
| | | // } |
| | | // |
| | | // if ("OFFLINE".equals(devicer.getData().getDeviceStatus())) { |
| | | // throw new RuntimeException("设备不在线" + streamPullPlay.getDeviceId()); |
| | | // } |
| | | |
| | | StreamInfo stream = getStreamInfoByAppAndStreamWithCheck(streamPullPlay.getApp(), streamPullPlay.getStream(), |
| | | mediaServer.getId(), null, false); |
| | |
| | | callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); |
| | | subscribe.removeSubscribe(rtpHook); |
| | | |
| | | QsDevice qsDevice = new QsDevice(); |
| | | qsDevice.setId(streamPullPlay.getDeviceId()); |
| | | qsDevice.setSnap(filePath); |
| | | R<Boolean> r = remoteQsDeviceService.updateQsDevice(qsDevice, SecurityConstants.INNER); |
| | | if (r.getCode() != Constants.SUCCESS) { |
| | | throw new RuntimeException("更新设备失败"); |
| | | } |
| | | // QsDevice qsDevice = new QsDevice(); |
| | | // qsDevice.setId(streamPullPlay.getDeviceId()); |
| | | // qsDevice.setSnap(filePath); |
| | | // R<Boolean> r = remoteQsDeviceService.updateQsDevice(qsDevice, SecurityConstants.INNER); |
| | | // if (r.getCode() != Constants.SUCCESS) { |
| | | // throw new RuntimeException("更新设备失败"); |
| | | // } |
| | | }); |
| | | |
| | | IMediaNodeServerService mediaNodeServerService = nodeServerServiceMap.get(mediaServer.getType()); |
| | |
| | | } |
| | | |
| | | String key = mediaNodeServerService.startProxy(mediaServer, streamPullPlay); |
| | | QsDevice qsDevice = new QsDevice(); |
| | | qsDevice.setId(streamPullPlay.getDeviceId()); |
| | | qsDevice.setStreamKey(key); |
| | | qsDevice.setMediaServerId(mediaServer.getId()); |
| | | qsDevice.setStreamStatus("1"); |
| | | R<Boolean> r = remoteQsDeviceService.updateQsDevice(qsDevice, SecurityConstants.INNER); |
| | | if (r.getCode() != Constants.SUCCESS) { |
| | | log.error("更新设备失败"); |
| | | callback.run(InviteErrorCode.FAIL.getCode(), "更新设备失败", null); |
| | | } |
| | | // QsDevice qsDevice = new QsDevice(); |
| | | // qsDevice.setId(streamPullPlay.getDeviceId()); |
| | | // qsDevice.setStreamKey(key); |
| | | // qsDevice.setMediaServerId(mediaServer.getId()); |
| | | // qsDevice.setStreamStatus("1"); |
| | | // R<Boolean> r = remoteQsDeviceService.updateQsDevice(qsDevice, SecurityConstants.INNER); |
| | | // if (r.getCode() != Constants.SUCCESS) { |
| | | // log.error("更新设备失败"); |
| | | // callback.run(InviteErrorCode.FAIL.getCode(), "更新设备失败", null); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param rtpServerParam 创建rtp端口请求参数 |
| | | * @param device 设备信息 |
| | | * @param ssrc ssrc |
| | | * @param record 是否录制 |
| | | * @param callback 回调 |
| | | * @return |
| | | */ |