liusuyi
2026-06-01 3496700a5ba18be8ca0590a79e21a867782d1ea9
ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/controller/ZlmController.java
@@ -11,8 +11,8 @@
import com.ard.gb28181.api.domain.Device;
import com.ard.gb28181.api.domain.DeviceChannel;
import com.ard.gb28181.api.domain.GbChannelDTO;
import com.ard.qs.api.RemoteQsDeviceService;
import com.ard.qs.api.domain.QsDevice;
import com.ard.zlm.domain.StreamChannel;
import com.ard.zlm.service.ZlmStreamService;
import com.ard.work.api.RemoteCameraService;
import com.ard.zlm.api.domain.*;
import com.ard.zlm.common.InviteErrorCode;
@@ -68,7 +68,7 @@
    private RemoteGb28181Service remoteGb28181Service;
    @Resource
    private RemoteQsDeviceService remoteQsDeviceService;
    private ZlmStreamService zlmStreamService;
    @Resource
    @Lazy
@@ -502,50 +502,50 @@
        log.info("[gb28181 开始点播] id:{} ", id);
        Assert.notNull(id, "设备id");
        R<QsDevice> qsDevicer = remoteQsDeviceService.getQsDeviceInfo(id, SecurityConstants.INNER);
        R<StreamChannel> qsDevicer = zlmStreamService.getQsDeviceInfo(id, SecurityConstants.INNER);
        if (qsDevicer.getCode() != Constants.SUCCESS) {
            throw new RuntimeException("获取设备信息失败 id:" + id);
        }
        Assert.notNull(qsDevicer.getData(), "设备不存在 id:" + id);
        QsDevice qsDevice = qsDevicer.getData();
        StreamChannel streamChannel = qsDevicer.getData();
        if ("OFFLINE".equals(qsDevice.getDeviceStatus())) {
        if (!Boolean.TRUE.equals(streamChannel.getDeviceOnLine())) {
            throw new RuntimeException("设备不在线 id:" + id);
        }
        R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(qsDevice.getGbDeviceId(), SecurityConstants.INNER);
        R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(streamChannel.getGbDeviceId(), SecurityConstants.INNER);
        if (deviceR.getCode() != Constants.SUCCESS) {
            throw new RuntimeException("gb28181 获取设备信息失败 id:" + qsDevice.getGbDeviceId());
            throw new RuntimeException("gb28181 获取设备信息失败 id:" + streamChannel.getGbDeviceId());
        }
        Assert.notNull(deviceR.getData(), "gb28181 国标设备不存在 id:" + qsDevice.getGbDeviceId());
        Assert.notNull(deviceR.getData(), "gb28181 国标设备不存在 id:" + streamChannel.getGbDeviceId());
        if (!deviceR.getData().isOnLine()) {
            throw new RuntimeException("gb28181 国标设备不在线失败 id:" + qsDevice.getGbDeviceId());
            throw new RuntimeException("gb28181 国标设备不在线失败 id:" + streamChannel.getGbDeviceId());
        }
        R<DeviceChannel> deviceChannelR = remoteGb28181Service.getDeviceChannelByChannelId(qsDevice.getGbDeviceId(), qsDevice.getGbChannelId(), SecurityConstants.INNER);
        R<DeviceChannel> deviceChannelR = remoteGb28181Service.getDeviceChannelByChannelId(streamChannel.getGbDeviceId(), streamChannel.getGbChannelId(), SecurityConstants.INNER);
        if (deviceChannelR.getCode() != Constants.SUCCESS) {
            throw new RuntimeException("gb28181 获取设备通道失败 gbDeviceId:" + qsDevice.getGbDeviceId() + ",gbChannelId:" + qsDevice.getGbChannelId());
            throw new RuntimeException("gb28181 获取设备通道失败 gbDeviceId:" + streamChannel.getGbDeviceId() + ",gbChannelId:" + streamChannel.getGbChannelId());
        }
        Assert.notNull(deviceChannelR.getData(), "gb28181 获取设备通道失败不存在 gbDeviceId:" + qsDevice.getGbDeviceId() + ",gbChannelId:" + qsDevice.getGbChannelId());
        Assert.notNull(deviceChannelR.getData(), "gb28181 获取设备通道失败不存在 gbDeviceId:" + streamChannel.getGbDeviceId() + ",gbChannelId:" + streamChannel.getGbChannelId());
        if (!"ON".equals(deviceChannelR.getData().getStatus())) {
            throw new RuntimeException("gb28181 国标设备通道不在线失败 gbDeviceId:" + qsDevice.getGbDeviceId() + ",gbChannelId:" + qsDevice.getGbChannelId());
            throw new RuntimeException("gb28181 国标设备通道不在线失败 gbDeviceId:" + streamChannel.getGbDeviceId() + ",gbChannelId:" + streamChannel.getGbChannelId());
        }
        DeferredResult<R<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
        result.onTimeout(() -> {
            log.info("[点播等待超时] gbDeviceId:{}, gbChannelId:{}, ", qsDevice.getGbDeviceId(), qsDevice.getGbChannelId());
            log.info("[点播等待超时] gbDeviceId:{}, gbChannelId:{}, ", streamChannel.getGbDeviceId(), streamChannel.getGbChannelId());
            // 释放rtpserver
            R<StreamContent> wvpResult = R.fail();
            wvpResult.setMsg("点播超时");
            result.setResult(wvpResult);
            inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, qsDevice.getId());
            mediaServerService.stopGb28181Play(InviteSessionType.PLAY, qsDevice, deviceR.getData(), qsDevice.getDeviceCode());
            inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, streamChannel.getId());
            mediaServerService.stopGb28181Play(InviteSessionType.PLAY, streamChannel, deviceR.getData(), streamChannel.getDeviceCode());
        });
        ErrorCallback<StreamInfo> callback = (code, msg, streamInfo) -> {
@@ -578,8 +578,8 @@
            }
        };
        qsDevice.setStreamMode(deviceR.getData().getStreamMode());
        mediaServerService.startGb28181Play(qsDevice, deviceR.getData(), callback);
        streamChannel.setStreamMode(deviceR.getData().getStreamMode());
        mediaServerService.startGb28181Play(streamChannel, deviceR.getData(), callback);
        return result;
    }
@@ -595,43 +595,43 @@
        log.info("[gb28181 停止点播] id:{} ", id);
        Assert.notNull(id, "设备id");
        R<QsDevice> qsDevicer = remoteQsDeviceService.getQsDeviceInfo(id, SecurityConstants.INNER);
        R<StreamChannel> qsDevicer = zlmStreamService.getQsDeviceInfo(id, SecurityConstants.INNER);
        if (qsDevicer.getCode() != Constants.SUCCESS) {
            throw new RuntimeException("获取设备信息失败 id:" + id);
        }
        Assert.notNull(qsDevicer.getData(), "设备不存在 id:" + id);
        QsDevice qsDevice = qsDevicer.getData();
        StreamChannel streamChannel = qsDevicer.getData();
        if ("OFFLINE".equals(qsDevice.getDeviceStatus())) {
        if (!Boolean.TRUE.equals(streamChannel.getDeviceOnLine())) {
            throw new RuntimeException("设备不在线 id:" + id);
        }
        R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(qsDevice.getGbDeviceId(), SecurityConstants.INNER);
        R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(streamChannel.getGbDeviceId(), SecurityConstants.INNER);
        if (deviceR.getCode() != Constants.SUCCESS) {
            throw new RuntimeException("gb28181 获取设备信息失败 id:" + qsDevice.getGbDeviceId());
            throw new RuntimeException("gb28181 获取设备信息失败 id:" + streamChannel.getGbDeviceId());
        }
        Assert.notNull(deviceR.getData(), "gb28181 国标设备不存在 id:" + qsDevice.getGbDeviceId());
        Assert.notNull(deviceR.getData(), "gb28181 国标设备不存在 id:" + streamChannel.getGbDeviceId());
        if (!deviceR.getData().isOnLine()) {
            throw new RuntimeException("gb28181 国标设备不在线失败 id:" + qsDevice.getGbDeviceId());
            throw new RuntimeException("gb28181 国标设备不在线失败 id:" + streamChannel.getGbDeviceId());
        }
        R<DeviceChannel> deviceChannelR = remoteGb28181Service.getDeviceChannelByChannelId(qsDevice.getGbDeviceId(), qsDevice.getGbChannelId(), SecurityConstants.INNER);
        R<DeviceChannel> deviceChannelR = remoteGb28181Service.getDeviceChannelByChannelId(streamChannel.getGbDeviceId(), streamChannel.getGbChannelId(), SecurityConstants.INNER);
        if (deviceChannelR.getCode() != Constants.SUCCESS) {
            throw new RuntimeException("gb28181 获取设备通道失败 gbDeviceId:" + qsDevice.getGbDeviceId() + ",gbChannelId:" + qsDevice.getGbChannelId());
            throw new RuntimeException("gb28181 获取设备通道失败 gbDeviceId:" + streamChannel.getGbDeviceId() + ",gbChannelId:" + streamChannel.getGbChannelId());
        }
        Assert.notNull(deviceChannelR.getData(), "gb28181 获取设备通道失败不存在 gbDeviceId:" + qsDevice.getGbDeviceId() + ",gbChannelId:" + qsDevice.getGbChannelId());
        Assert.notNull(deviceChannelR.getData(), "gb28181 获取设备通道失败不存在 gbDeviceId:" + streamChannel.getGbDeviceId() + ",gbChannelId:" + streamChannel.getGbChannelId());
        if (!"ON".equals(deviceChannelR.getData().getStatus())) {
            throw new RuntimeException("gb28181 国标设备通道不在线失败 gbDeviceId:" + qsDevice.getGbDeviceId() + ",gbChannelId:" + qsDevice.getGbChannelId());
            throw new RuntimeException("gb28181 国标设备通道不在线失败 gbDeviceId:" + streamChannel.getGbDeviceId() + ",gbChannelId:" + streamChannel.getGbChannelId());
        }
        mediaServerService.stopGb28181Play(InviteSessionType.PLAY, qsDevice, deviceR.getData(), qsDevice.getDeviceCode());
        mediaServerService.stopGb28181Play(InviteSessionType.PLAY, streamChannel, deviceR.getData(), streamChannel.getDeviceCode());
        JSONObject json = new JSONObject();
        json.put("deviceId", qsDevice.getGbDeviceId());
        json.put("channelId", qsDevice.getGbChannelId());
        json.put("deviceId", streamChannel.getGbDeviceId());
        json.put("channelId", streamChannel.getGbChannelId());
        return AjaxResult.success(json);
    }
@@ -662,7 +662,7 @@
        }
        Assert.notNull(channelR.getData(), "GbChannel不存在 gbDeviceId:" + gbDeviceId + " gbChannelId:" + gbChannelId);
        GbChannelDTO gbChannelDTO = channelR.getData();
        StreamChannel streamChannel = ZlmStreamService.toStreamChannel(channelR.getData());
        // 2. 查询国标设备
        R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(gbDeviceId, SecurityConstants.INNER);
@@ -694,8 +694,8 @@
            fail.setMsg("点播超时");
            result.setResult(fail);
            inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, gbChannelDTO.getId());
            mediaServerService.stopGb28181PlayByGbChannel(InviteSessionType.PLAY, gbChannelDTO, deviceR.getData(), gbChannelDTO.getDeviceCode());
            inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, streamChannel.getId());
            mediaServerService.stopGb28181PlayByGbChannel(InviteSessionType.PLAY, streamChannel, deviceR.getData(), streamChannel.getDeviceCode());
        });
        ErrorCallback<StreamInfo> callback = (code, msg, streamInfo) -> {
@@ -728,7 +728,7 @@
            }
        };
        mediaServerService.startGb28181PlayByGbChannel(gbChannelDTO, deviceR.getData(), callback);
        mediaServerService.startGb28181PlayByGbChannel(streamChannel, deviceR.getData(), callback);
        return result;
    }
@@ -755,7 +755,7 @@
            throw new RuntimeException("GbChannel不存在 gbDeviceId:" + gbDeviceId + " gbChannelId:" + gbChannelId);
        }
        GbChannelDTO gbChannelDTO = channelR.getData();
        StreamChannel streamChannel = ZlmStreamService.toStreamChannel(channelR.getData());
        // 2. 查询国标设备
        R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(gbDeviceId, SecurityConstants.INNER);
@@ -771,8 +771,8 @@
        }
        Assert.notNull(deviceChannelR.getData(), "gb28181 国标设备通道不存在 gbDeviceId:" + gbDeviceId + " gbChannelId:" + gbChannelId);
        mediaServerService.stopGb28181PlayByGbChannel(InviteSessionType.PLAY, gbChannelDTO,
                deviceR.getData(), gbChannelDTO.getDeviceCode());
        mediaServerService.stopGb28181PlayByGbChannel(InviteSessionType.PLAY, streamChannel,
                deviceR.getData(), streamChannel.getDeviceCode());
        JSONObject json = new JSONObject();
        json.put("gbDeviceId", gbDeviceId);
@@ -803,9 +803,9 @@
        }
        Assert.notNull(channelR.getData(), "GbChannel不存在 channelId:" + channelId);
        GbChannelDTO gbChannelDTO = channelR.getData();
        String gbDeviceId = gbChannelDTO.getGbDeviceId();
        String gbChannelId = gbChannelDTO.getGbChannelId();
        StreamChannel streamChannel = ZlmStreamService.toStreamChannel(channelR.getData());
        String gbDeviceId = streamChannel.getGbDeviceId();
        String gbChannelId = streamChannel.getGbChannelId();
        // 2. 查询国标设备
        R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(gbDeviceId, SecurityConstants.INNER);
@@ -837,8 +837,8 @@
            fail.setMsg("点播超时");
            result.setResult(fail);
            inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, gbChannelDTO.getId());
            mediaServerService.stopGb28181PlayByGbChannel(InviteSessionType.PLAY, gbChannelDTO, deviceR.getData(), gbChannelDTO.getDeviceCode());
            inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, streamChannel.getId());
            mediaServerService.stopGb28181PlayByGbChannel(InviteSessionType.PLAY, streamChannel, deviceR.getData(), streamChannel.getDeviceCode());
        });
        ErrorCallback<StreamInfo> callback = (code, msg, streamInfo) -> {
@@ -871,7 +871,7 @@
            }
        };
        mediaServerService.startGb28181PlayByGbChannel(gbChannelDTO, deviceR.getData(), callback);
        mediaServerService.startGb28181PlayByGbChannel(streamChannel, deviceR.getData(), callback);
        return result;
    }
@@ -893,9 +893,9 @@
            throw new RuntimeException("GbChannel不存在 channelId:" + channelId);
        }
        GbChannelDTO gbChannelDTO = channelR.getData();
        String gbDeviceId = gbChannelDTO.getGbDeviceId();
        String gbChannelId = gbChannelDTO.getGbChannelId();
        StreamChannel streamChannel = ZlmStreamService.toStreamChannel(channelR.getData());
        String gbDeviceId = streamChannel.getGbDeviceId();
        String gbChannelId = streamChannel.getGbChannelId();
        // 2. 查询国标设备
        R<Device> deviceR = remoteGb28181Service.getDeviceByDeviceId(gbDeviceId, SecurityConstants.INNER);
@@ -911,8 +911,8 @@
        }
        Assert.notNull(deviceChannelR.getData(), "gb28181 国标设备通道不存在 gbDeviceId:" + gbDeviceId + " gbChannelId:" + gbChannelId);
        mediaServerService.stopGb28181PlayByGbChannel(InviteSessionType.PLAY, gbChannelDTO,
                deviceR.getData(), gbChannelDTO.getDeviceCode());
        mediaServerService.stopGb28181PlayByGbChannel(InviteSessionType.PLAY, streamChannel,
                deviceR.getData(), streamChannel.getDeviceCode());
        JSONObject json = new JSONObject();
        json.put("channelId", channelId);