old mode 100644
new mode 100755
| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.VManageBootstrap; |
| | | import com.genersoft.iot.vmp.common.SystemAllInfo; |
| | | import com.genersoft.iot.vmp.common.VersionPo; |
| | | import com.genersoft.iot.vmp.conf.SipConfig; |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.conf.VersionInfo; |
| | | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| | | import com.genersoft.iot.vmp.conf.security.JwtUtils; |
| | | import com.genersoft.iot.vmp.media.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager; |
| | | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.service.*; |
| | | import com.genersoft.iot.vmp.service.bean.MediaServerLoad; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.utils.SpringBeanFactory; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ResourceInfo; |
| | | import com.genersoft.iot.vmp.vmanager.bean.SystemConfigInfo; |
| | | import gov.nist.javax.sip.SipStackImpl; |
| | | |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.sip.ListeningPoint; |
| | | import javax.sip.ObjectInUseException; |
| | | import javax.sip.SipProvider; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @SuppressWarnings("rawtypes") |
| | | @Tag(name = "服务控制") |
| | | @CrossOrigin |
| | | |
| | | @RestController |
| | | @RequestMapping("/api/server") |
| | | public class ServerController { |
| | |
| | | |
| | | |
| | | @Autowired |
| | | private ThreadPoolTaskExecutor taskExecutor; |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | private SendRtpPortManager sendRtpPortManager; |
| | | |
| | | |
| | | @GetMapping(value = "/media_server/list") |
| | | @ResponseBody |
| | | @Operation(summary = "流媒体服务列表") |
| | | @Operation(summary = "流媒体服务列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | public List<MediaServerItem> getMediaServerList() { |
| | | return mediaServerService.getAll(); |
| | | } |
| | | |
| | | @GetMapping(value = "/media_server/online/list") |
| | | @ResponseBody |
| | | @Operation(summary = "在线流媒体服务列表") |
| | | @Operation(summary = "在线流媒体服务列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | public List<MediaServerItem> getOnlineMediaServerList() { |
| | | return mediaServerService.getAllOnline(); |
| | | } |
| | | |
| | | @GetMapping(value = "/media_server/one/{id}") |
| | | @ResponseBody |
| | | @Operation(summary = "停止视频回放") |
| | | @Operation(summary = "停止视频回放", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | @Parameter(name = "id", description = "流媒体服务ID", required = true) |
| | | public MediaServerItem getMediaServer(@PathVariable String id) { |
| | | return mediaServerService.getOne(id); |
| | | } |
| | | |
| | | @Operation(summary = "测试流媒体服务") |
| | | @Operation(summary = "测试流媒体服务", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | @Parameter(name = "ip", description = "流媒体服务IP", required = true) |
| | | @Parameter(name = "port", description = "流媒体服务HTT端口", required = true) |
| | | @Parameter(name = "secret", description = "流媒体服务secret", required = true) |
| | | @GetMapping(value = "/media_server/check") |
| | | @ResponseBody |
| | | public MediaServerItem checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret) { |
| | | return mediaServerService.checkMediaServer(ip, port, secret); |
| | | public MediaServerItem checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret, @RequestParam String type) { |
| | | return mediaServerService.checkMediaServer(ip, port, secret, type); |
| | | } |
| | | |
| | | @Operation(summary = "测试流媒体录像管理服务") |
| | | @Operation(summary = "测试流媒体录像管理服务", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | @Parameter(name = "ip", description = "流媒体服务IP", required = true) |
| | | @Parameter(name = "port", description = "流媒体服务HTT端口", required = true) |
| | | @GetMapping(value = "/media_server/record/check") |
| | |
| | | } |
| | | } |
| | | |
| | | @Operation(summary = "保存流媒体服务") |
| | | @Operation(summary = "保存流媒体服务", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | @Parameter(name = "mediaServerItem", description = "流媒体信息", required = true) |
| | | @PostMapping(value = "/media_server/save") |
| | | @ResponseBody |
| | | public void saveMediaServer(@RequestBody MediaServerItem mediaServerItem) { |
| | | MediaServerItem mediaServerItemInDatabase = mediaServerService.getOne(mediaServerItem.getId()); |
| | | MediaServerItem mediaServerItemInDatabase = mediaServerService.getOneFromDatabase(mediaServerItem.getId()); |
| | | |
| | | if (mediaServerItemInDatabase != null) { |
| | | if (ObjectUtils.isEmpty(mediaServerItemInDatabase.getSendRtpPortRange()) && ObjectUtils.isEmpty(mediaServerItem.getSendRtpPortRange())) { |
| | | mediaServerItem.setSendRtpPortRange("30000,30500"); |
| | | } |
| | | mediaServerService.update(mediaServerItem); |
| | | } else { |
| | | if (ObjectUtils.isEmpty(mediaServerItem.getSendRtpPortRange())) { |
| | | mediaServerItem.setSendRtpPortRange("30000,30500"); |
| | | } |
| | | mediaServerService.add(mediaServerItem); |
| | | } |
| | | } |
| | | |
| | | @Operation(summary = "移除流媒体服务") |
| | | @Operation(summary = "移除流媒体服务", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | @Parameter(name = "id", description = "流媒体ID", required = true) |
| | | @DeleteMapping(value = "/media_server/delete") |
| | | @ResponseBody |
| | | public void deleteMediaServer(@RequestParam String id) { |
| | | if (mediaServerService.getOne(id) == null) { |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到此节点"); |
| | | } |
| | | mediaServerService.delete(id); |
| | | mediaServerService.deleteDb(id); |
| | | } |
| | | |
| | | |
| | | @Operation(summary = "重启服务") |
| | | @Operation(summary = "重启服务", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | @GetMapping(value = "/restart") |
| | | @ResponseBody |
| | | public void restart() { |
| | |
| | | // }); |
| | | }; |
| | | |
| | | @Operation(summary = "获取系统信息信息") |
| | | @Operation(summary = "获取系统信息信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | @GetMapping(value = "/system/configInfo") |
| | | @ResponseBody |
| | | public SystemConfigInfo getConfigInfo() { |
| | |
| | | return systemConfigInfo; |
| | | } |
| | | |
| | | @Operation(summary = "获取版本信息") |
| | | @Operation(summary = "获取版本信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) |
| | | @GetMapping(value = "/version") |
| | | @ResponseBody |
| | | public VersionPo VersionPogetVersion() { |
| | |
| | | @Operation(summary = "获取负载信息") |
| | | public ResourceInfo getResourceInfo() { |
| | | ResourceInfo result = new ResourceInfo(); |
| | | ResourceBaceInfo deviceInfo = deviceService.getOverview(); |
| | | ResourceBaseInfo deviceInfo = deviceService.getOverview(); |
| | | result.setDevice(deviceInfo); |
| | | ResourceBaceInfo channelInfo = channelService.getOverview(); |
| | | ResourceBaseInfo channelInfo = channelService.getOverview(); |
| | | result.setChannel(channelInfo); |
| | | ResourceBaceInfo pushInfo = pushService.getOverview(); |
| | | ResourceBaseInfo pushInfo = pushService.getOverview(); |
| | | result.setPush(pushInfo); |
| | | ResourceBaceInfo proxyInfo = proxyService.getOverview(); |
| | | ResourceBaseInfo proxyInfo = proxyService.getOverview(); |
| | | result.setProxy(proxyInfo); |
| | | |
| | | return result; |