| | |
| | | return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 自定义异常处理, 处理controller中返回的错误 |
| | | * @param e 异常 |
| | |
| | | package com.genersoft.iot.vmp.conf; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.core.MethodParameter; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.converter.HttpMessageConverter; |
| | | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
| | | import org.springframework.http.server.ServerHttpRequest; |
| | | import org.springframework.http.server.ServerHttpResponse; |
| | | import org.springframework.web.bind.annotation.RestControllerAdvice; |
| | | import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 全局统一返回结果 |
| | |
| | | public boolean supports(@NotNull MethodParameter returnType, @NotNull Class<? extends HttpMessageConverter<?>> converterType) { |
| | | return true; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Object beforeBodyWrite(Object body, @NotNull MethodParameter returnType, @NotNull MediaType selectedContentType, @NotNull Class<? extends HttpMessageConverter<?>> selectedConverterType, @NotNull ServerHttpRequest request, @NotNull ServerHttpResponse response) { |
| | |
| | | |
| | | return WVPResult.success(body); |
| | | } |
| | | |
| | | /** |
| | | * 防止返回string时出错 |
| | | * @return |
| | | */ |
| | | @Bean |
| | | public HttpMessageConverters custHttpMessageConverter() { |
| | | return new HttpMessageConverters(new FastJsonHttpMessageConverter()); |
| | | } |
| | | } |
| | |
| | | logger.info("[发送错误订阅]"); |
| | | SipSubscribe.Event subscribe = sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()); |
| | | SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(timeoutEvent); |
| | | subscribe.response(eventResult); |
| | | if (subscribe != null){ |
| | | subscribe.response(eventResult); |
| | | } |
| | | sipSubscribe.removeOkSubscribe(callIdHeader.getCallId()); |
| | | sipSubscribe.removeErrorSubscribe(callIdHeader.getCallId()); |
| | | } |
| | |
| | | if (!"rtp".equals(param.getApp())) {
|
| | | Map<String, String> paramMap = urlParamToMap(param.getParams());
|
| | | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream());
|
| | | if (streamAuthorityInfo == null
|
| | | || (streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(paramMap.get("callId")))) {
|
| | | if (streamAuthorityInfo != null && streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(paramMap.get("callId"))) {
|
| | | ret.put("code", 401);
|
| | | ret.put("msg", "Unauthorized");
|
| | | return new ResponseEntity<>(ret.toString(),HttpStatus.OK);
|
| | |
| | | if (mediaServerItem != null){
|
| | | if (regist) {
|
| | | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
|
| | | String callId = null;
|
| | | if (streamAuthorityInfo != null) {
|
| | | callId = streamAuthorityInfo.getCallId();
|
| | | }
|
| | | StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem,
|
| | | app, stream, tracks, streamAuthorityInfo.getCallId());
|
| | | app, stream, tracks, callId);
|
| | | item.setStreamInfo(streamInfoByAppAndStream);
|
| | | redisCatchStorage.addStream(mediaServerItem, type, app, stream, item);
|
| | | if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
| | |
| | | if (mediaInfo == null) { |
| | | return null; |
| | | } |
| | | String calld = null; |
| | | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); |
| | | if (streamAuthorityInfo == null) { |
| | | return null; |
| | | if (streamAuthorityInfo != null) { |
| | | calld = streamAuthorityInfo.getCallId(); |
| | | } |
| | | JSONObject mediaList = zlmresTfulUtils.getMediaList(mediaInfo, app, stream); |
| | | if (mediaList != null) { |
| | |
| | | JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class); |
| | | JSONArray tracks = mediaJSON.getJSONArray("tracks"); |
| | | if (authority) { |
| | | streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,streamAuthorityInfo.getCallId()); |
| | | streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr, calld); |
| | | }else { |
| | | streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,null); |
| | | } |
| | |
| | | public boolean start(String app, String stream) { |
| | | boolean result = false; |
| | | StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream); |
| | | if (!streamProxy.isEnable() ) { |
| | | if (streamProxy != null && !streamProxy.isEnable() ) { |
| | | JSONObject jsonObject = addStreamProxyToZlm(streamProxy); |
| | | if (jsonObject == null) { |
| | | return false; |
| | |
| | | "WHERE " + |
| | | "1=1 " + |
| | | " <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " + |
| | | " <if test='pushing == true' > AND (gs.gbId is null OR st.status=1)</if>" + |
| | | " <if test='pushing == false' > AND st.status=0</if>" + |
| | | " <if test='pushing == true' > AND (gs.gbId is null OR st.pushIng=1)</if>" + |
| | | " <if test='pushing == false' > AND st.pushIng=0</if>" + |
| | | " <if test='mediaServerId != null' > AND st.mediaServerId=#{mediaServerId} </if>" + |
| | | "order by st.createTime desc" + |
| | | " </script>"}) |
| | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| | |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| | | import com.genersoft.iot.vmp.service.IDeviceService; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import com.github.pagehelper.util.StringUtil; |
| | | |
| | |
| | | @Parameter(name = "expires", description = "订阅超时时间", required = true) |
| | | @Parameter(name = "interval", description = "上报时间间隔", required = true) |
| | | @GetMapping("/subscribe/{deviceId}") |
| | | public String positionSubscribe(@PathVariable String deviceId, |
| | | public void positionSubscribe(@PathVariable String deviceId, |
| | | @RequestParam String expires, |
| | | @RequestParam String interval) { |
| | | String msg = ((expires.equals("0")) ? "取消" : "") + "订阅设备" + deviceId + "的移动位置"; |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug(msg); |
| | | } |
| | | |
| | | if (StringUtil.isEmpty(interval)) { |
| | | interval = "5"; |
| | |
| | | device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires)); |
| | | device.setMobilePositionSubmissionInterval(Integer.parseInt(interval)); |
| | | deviceService.updateDevice(device); |
| | | String result = msg; |
| | | if (deviceService.removeMobilePositionSubscribe(device)) { |
| | | result += ",成功"; |
| | | } else { |
| | | result += ",失败"; |
| | | if (!deviceService.removeMobilePositionSubscribe(device)) { |
| | | throw new ControllerException(ErrorCode.ERROR100); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | } |
| | |
| | | @Operation(summary = "远程启动控制命令") |
| | | @Parameter(name = "deviceId", description = "设备国标编号", required = true) |
| | | @GetMapping("/teleboot/{deviceId}") |
| | | public String teleBootApi(@PathVariable String deviceId) { |
| | | public void teleBootApi(@PathVariable String deviceId) { |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("设备远程启动API调用"); |
| | | } |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | boolean sucsess = cmder.teleBootCmd(device); |
| | | if (sucsess) { |
| | | JSONObject json = new JSONObject(); |
| | | json.put("DeviceID", deviceId); |
| | | json.put("Result", "OK"); |
| | | return json.toJSONString(); |
| | | } else { |
| | | logger.warn("设备远程启动API调用失败!"); |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备远程启动API调用失败!"); |
| | | if (!cmder.teleBootCmd(device)) { |
| | | logger.warn("设备远程启动API调用失败!"); |
| | | throw new ControllerException(ErrorCode.ERROR100); |
| | | } |
| | | } |
| | | |
| | |
| | | @Parameter(name = "serverGBId", description = "上级平台的国标编号") |
| | | @DeleteMapping("/delete/{serverGBId}") |
| | | @ResponseBody |
| | | public String deletePlatform(@PathVariable String serverGBId) { |
| | | public void deletePlatform(@PathVariable String serverGBId) { |
| | | |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("删除上级平台API调用"); |
| | |
| | | dynamicTask.stop(key); |
| | | // 删除缓存的订阅信息 |
| | | subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); |
| | | if (deleteResult) { |
| | | return null; |
| | | } else { |
| | | if (!deleteResult) { |
| | | throw new ControllerException(ErrorCode.ERROR100); |
| | | } |
| | | } |
| | |
| | | assetsPublicPath: '/', |
| | | proxyTable: { |
| | | '/debug': { |
| | | target: 'http://localhost:18080', |
| | | target: 'http://localhost:38080', |
| | | changeOrigin: true, |
| | | pathRewrite: { |
| | | '^/debug': '/' |
| | | } |
| | | }, |
| | | '/static/snap': { |
| | | target: 'http://localhost:18080', |
| | | target: 'http://localhost:38080', |
| | | changeOrigin: true, |
| | | // pathRewrite: { |
| | | // '^/static/snap': '/static/snap' |
| | |
| | | this.getListLoading = true; |
| | | this.$axios({ |
| | | method: 'get', |
| | | url:`/api/media/stream_info_by_app_and_stream`, |
| | | url:`/api/push/getPlayUrl`, |
| | | params: { |
| | | app: row.app, |
| | | stream: row.stream, |