| | |
| | | import com.ard.common.core.domain.R; |
| | | import com.ard.common.core.domain.RtpServerParam; |
| | | import com.ard.common.core.exception.ServiceException; |
| | | import com.ard.gb28181.api.domain.Device; |
| | | import com.ard.gb28181.api.domain.DeviceChannel; |
| | | import com.ard.gb28181.api.domain.*; |
| | | import com.ard.gb28181.config.UserSetting; |
| | | import com.ard.gb28181.domain.GbChannel; |
| | | import com.ard.gb28181.domain.GbDevice; |
| | | import com.ard.gb28181.service.IDeviceService; |
| | | import com.ard.gb28181.service.IGbChannelService; |
| | | import com.ard.gb28181.service.IGbDeviceService; |
| | | import com.ard.gb28181.service.ISIPCommander; |
| | | import com.ard.gb28181.session.SipInviteSessionManager; |
| | | import com.ard.zlm.api.RemoteZlmService; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.context.request.async.DeferredResult; |
| | | |
| | | import javax.sip.ResponseEvent; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private RemoteZlmService remoteZlmService; |
| | | |
| | | @Autowired |
| | | private IGbDeviceService gbDeviceService; |
| | | |
| | | @Autowired |
| | | private IGbChannelService gbChannelService; |
| | | |
| | | /** |
| | | * 根据设备id获取设备 |
| | |
| | | } |
| | | frontEndCommand(deviceId, channelId, cmdCode, switchId, 0, 0); |
| | | } |
| | | |
| | | // ==================== GbDevice / GbChannel 管理接口 ==================== |
| | | |
| | | /** |
| | | * 根据国标设备ID获取GbDevice |
| | | */ |
| | | @GetMapping("/getGbDevice/{gbDeviceId}") |
| | | public R<GbDeviceDTO> getGbDevice(@PathVariable String gbDeviceId) { |
| | | GbDevice gbDevice = gbDeviceService.selectGbDeviceByGbDeviceId(gbDeviceId); |
| | | if (gbDevice == null) { |
| | | return R.fail("GbDevice不存在 gbDeviceId:" + gbDeviceId); |
| | | } |
| | | return R.ok(toGbDeviceDTO(gbDevice)); |
| | | } |
| | | |
| | | /** |
| | | * 获取所有GbDevice列表 |
| | | */ |
| | | @GetMapping("/getAllGbDevices") |
| | | public R<List<GbDeviceDTO>> getAllGbDevices() { |
| | | List<GbDevice> list = gbDeviceService.selectGbDeviceList(new GbDevice()); |
| | | List<GbDeviceDTO> dtoList = new ArrayList<>(); |
| | | for (GbDevice d : list) { |
| | | dtoList.add(toGbDeviceDTO(d)); |
| | | } |
| | | return R.ok(dtoList); |
| | | } |
| | | |
| | | /** |
| | | * 根据主键ID获取GbChannel |
| | | */ |
| | | @GetMapping("/getGbChannelById/{id}") |
| | | public R<GbChannelDTO> getGbChannelById(@PathVariable Long id) { |
| | | GbChannel gbChannel = gbChannelService.selectGbChannelById(id); |
| | | if (gbChannel == null) { |
| | | return R.fail("GbChannel不存在 id:" + id); |
| | | } |
| | | return R.ok(toGbChannelDTO(gbChannel)); |
| | | } |
| | | |
| | | /** |
| | | * 根据国标设备ID和通道ID获取GbChannel |
| | | */ |
| | | @GetMapping("/getGbChannel/{gbDeviceId}/{gbChannelId}") |
| | | public R<GbChannelDTO> getGbChannel(@PathVariable String gbDeviceId, @PathVariable String gbChannelId) { |
| | | GbChannel gbChannel = gbChannelService.selectByGbDeviceIdAndGbChannelId(gbDeviceId, gbChannelId); |
| | | if (gbChannel == null) { |
| | | return R.fail("GbChannel不存在 gbDeviceId:" + gbDeviceId + " gbChannelId:" + gbChannelId); |
| | | } |
| | | return R.ok(toGbChannelDTO(gbChannel)); |
| | | } |
| | | |
| | | /** |
| | | * 根据国标设备ID获取所有通道 |
| | | */ |
| | | @GetMapping("/getGbChannelsByDeviceId/{gbDeviceId}") |
| | | public R<List<GbChannelDTO>> getGbChannelsByDeviceId(@PathVariable String gbDeviceId) { |
| | | List<GbChannel> list = gbChannelService.selectGbChannelByGbDeviceId(gbDeviceId); |
| | | List<GbChannelDTO> dtoList = new ArrayList<>(); |
| | | for (GbChannel c : list) { |
| | | dtoList.add(toGbChannelDTO(c)); |
| | | } |
| | | return R.ok(dtoList); |
| | | } |
| | | |
| | | /** |
| | | * 更新GbChannel流状态 |
| | | */ |
| | | @PostMapping("/updateGbChannelStream") |
| | | R<Boolean> updateGbChannelStream(@RequestBody GbChannelDTO dto) { |
| | | GbChannel gbChannel = new GbChannel(); |
| | | gbChannel.setId(dto.getId()); |
| | | gbChannel.setStreamStatus(dto.getStreamStatus()); |
| | | gbChannel.setStreamKey(dto.getStreamKey()); |
| | | gbChannel.setMediaServerId(dto.getMediaServerId()); |
| | | gbChannel.setSnap(dto.getSnap()); |
| | | gbChannelService.updateGbChannelStream(gbChannel); |
| | | return R.ok(true); |
| | | } |
| | | |
| | | private GbDeviceDTO toGbDeviceDTO(GbDevice d) { |
| | | GbDeviceDTO dto = new GbDeviceDTO(); |
| | | dto.setId(d.getId()); |
| | | dto.setGbDeviceId(d.getGbDeviceId()); |
| | | dto.setDeviceName(d.getDeviceName()); |
| | | dto.setDeviceCode(d.getDeviceCode()); |
| | | dto.setIp(d.getIp()); |
| | | dto.setPort(d.getPort()); |
| | | dto.setManufacturer(d.getManufacturer()); |
| | | dto.setModel(d.getModel()); |
| | | dto.setFirmware(d.getFirmware()); |
| | | dto.setOnLine(d.getOnLine()); |
| | | return dto; |
| | | } |
| | | |
| | | private GbChannelDTO toGbChannelDTO(GbChannel c) { |
| | | GbChannelDTO dto = new GbChannelDTO(); |
| | | dto.setId(c.getId()); |
| | | dto.setGbDeviceId(c.getGbDeviceId()); |
| | | dto.setGbChannelId(c.getGbChannelId()); |
| | | dto.setChannelName(c.getChannelName()); |
| | | dto.setDeviceCode(c.getDeviceCode()); |
| | | dto.setStreamMode(c.getStreamMode()); |
| | | dto.setEnableMp4(c.getEnableMp4()); |
| | | dto.setStreamStatus(c.getStreamStatus()); |
| | | dto.setMediaServerId(c.getMediaServerId()); |
| | | dto.setStreamKey(c.getStreamKey()); |
| | | dto.setSnap(c.getSnap()); |
| | | return dto; |
| | | } |
| | | } |