Commit b0fc21ef9c7f0d68c72351f097cd2af8d8762453
1 parent
da458ece
refactor: 流未找到事件,返回结果404
1、流未找到事件,返回结果404 2、调整日志级别
Showing
6 changed files
with
26 additions
and
14 deletions
... | ... | @@ -10,10 +10,13 @@ import org.json.JSONObject; |
10 | 10 | import org.springframework.web.bind.annotation.*; |
11 | 11 | import org.springframework.web.context.request.async.DeferredResult; |
12 | 12 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
13 | +import org.thingsboard.server.common.data.yunteng.config.media.UserSetting; | |
13 | 14 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
15 | +import org.thingsboard.server.common.data.yunteng.dto.sip.MediaServerDTO; | |
14 | 16 | import org.thingsboard.server.common.data.yunteng.dto.sip.VideoChanelDTO; |
15 | 17 | import org.thingsboard.server.common.data.yunteng.dto.sip.hook.param.*; |
16 | 18 | import org.thingsboard.server.controller.BaseController; |
19 | +import org.thingsboard.server.dao.yunteng.service.media.TkCacheStorageService; | |
17 | 20 | import org.thingsboard.server.dao.yunteng.service.media.TkMediaServerService; |
18 | 21 | import org.thingsboard.server.dao.yunteng.service.media.TkVideoChannelService; |
19 | 22 | import org.thingsboard.server.queue.util.TbCoreComponent; |
... | ... | @@ -27,9 +30,11 @@ import org.thingsboard.server.service.yunteng.media.TkVideoControlService; |
27 | 30 | @RequiredArgsConstructor |
28 | 31 | @Slf4j |
29 | 32 | public class ZLMediaKitHookController extends BaseController { |
33 | + private final TkCacheStorageService tkCacheStorageService; | |
30 | 34 | private final TkMediaServerService tkMediaServerService; |
31 | 35 | private final TkVideoChannelService tkVideoChannelService; |
32 | 36 | private final TkVideoControlService controlService; |
37 | + private final UserSetting userSetting; | |
33 | 38 | |
34 | 39 | @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8") |
35 | 40 | @ApiOperation(value = "保持流媒体服务器的心跳") |
... | ... | @@ -93,12 +98,11 @@ public class ZLMediaKitHookController extends BaseController { |
93 | 98 | |
94 | 99 | DeferredResult<HookResult> defaultResult = new DeferredResult<>(); |
95 | 100 | |
96 | - // MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); | |
97 | - // if (!userSetting.isAutoApplyPlay() || mediaInfo == null) { | |
98 | - // defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), | |
99 | - // ErrorCode.ERROR404.getMsg())); | |
100 | - // return defaultResult; | |
101 | - // } | |
101 | + MediaServerDTO mediaServerItem = tkCacheStorageService.findInfoByMediaServerId(param.getMediaServerId()); | |
102 | + if (!userSetting.getAutoApplyPlay() || mediaServerItem == null) { | |
103 | + defaultResult.setResult(new HookResult(404,"资源未找到")); | |
104 | + return defaultResult; | |
105 | + } | |
102 | 106 | // |
103 | 107 | // if ("rtp".equals(param.getApp())) { |
104 | 108 | // String[] s = param.getStream().split("_"); | ... | ... |
... | ... | @@ -997,7 +997,7 @@ public class DefaultTransportApiService implements TransportApiService { |
997 | 997 | log.info("启动流媒体【ZLMedia】验证,流媒体编号【{}】", mediaServerItem.getMediaServerId()); |
998 | 998 | JsonNode responseJson = zlMediaKitRestFulUtils.getMediaServerConfig(mediaServerItem); |
999 | 999 | if (responseJson == null) { |
1000 | - log.error( | |
1000 | + log.trace( | |
1001 | 1001 | "流媒体【{}】服务地址【{}:{}】无法访问", |
1002 | 1002 | mediaServerItem.getMediaServerId(), |
1003 | 1003 | mediaServerItem.getIp(), |
... | ... | @@ -1011,7 +1011,7 @@ public class DefaultTransportApiService implements TransportApiService { |
1011 | 1011 | return org.thingsboard.server.common.data.yunteng.utils.JacksonUtil.convertValue( |
1012 | 1012 | data.get(0), ZLMediaKitServerConfig.class); |
1013 | 1013 | } else { |
1014 | - log.error( | |
1014 | + log.trace( | |
1015 | 1015 | "流媒体【{}:{}】调用失败,失败原因【{}】", |
1016 | 1016 | mediaServerItem.getIp(), |
1017 | 1017 | mediaServerItem.getHttpPort(), | ... | ... |
... | ... | @@ -7,12 +7,19 @@ import org.springframework.stereotype.Component; |
7 | 7 | @Data |
8 | 8 | public class UserSetting { |
9 | 9 | private String serverId = "000000"; |
10 | + /**部分设备需要扩展SDP,需要打开此设置*/ | |
10 | 11 | private Boolean seniorSdp = Boolean.FALSE; |
11 | 12 | private Boolean pushAuthority = Boolean.TRUE; |
13 | + /**国标是否录制*/ | |
12 | 14 | private Boolean recordSip = Boolean.TRUE; |
15 | + /**推流直播是否录制*/ | |
13 | 16 | private Boolean recordPushLive = Boolean.TRUE; |
14 | 17 | private String recordPath = null; |
18 | + /**国标点播 按需拉流, true:有人观看拉流,无人观看释放, false:拉起后不自动释放*/ | |
15 | 19 | private Boolean streamOnDemand = Boolean.TRUE; |
16 | 20 | private Boolean sipUseSourceIpAsRemoteAddress = Boolean.FALSE; |
21 | + /***点播等待超时时间,单位:毫秒*/ | |
17 | 22 | private Integer playTimeout = 30000; |
23 | + /**自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true*/ | |
24 | + private Boolean autoApplyPlay = Boolean.FALSE; | |
18 | 25 | } | ... | ... |
... | ... | @@ -145,7 +145,7 @@ public class SIPProcessorObserver extends SIPRequestProcessorParent |
145 | 145 | CSeqHeader cseqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME); |
146 | 146 | String methodName = cseqHeader.getMethod(); |
147 | 147 | SIPResponse request = (SIPResponse) responseEvent.getResponse(); |
148 | - log.info( | |
148 | + log.trace( | |
149 | 149 | "收到ResponseEvent,方法类型【{}】,状态码【{}】,事件内容【{}】", |
150 | 150 | methodName, |
151 | 151 | status, |
... | ... | @@ -181,7 +181,7 @@ public class SIPProcessorObserver extends SIPRequestProcessorParent |
181 | 181 | } else if ((status >= Response.TRYING) && (status < Response.OK)) { |
182 | 182 | // 增加其它无需回复的响应,如101、180等 |
183 | 183 | } else { |
184 | - log.error( | |
184 | + log.trace( | |
185 | 185 | "收到ResponseEvent,设备【{}】,状态码【{}】,失败原因【{}】,ResponseEvent内容【{}】", |
186 | 186 | response.getHeader(FromHeader.NAME), |
187 | 187 | status, |
... | ... | @@ -214,7 +214,7 @@ public class SIPProcessorObserver extends SIPRequestProcessorParent |
214 | 214 | public void processRequest(RequestEvent requestEvent) { |
215 | 215 | String methodName = requestEvent.getRequest().getMethod(); |
216 | 216 | SIPRequest request = (SIPRequest) requestEvent.getRequest(); |
217 | - log.info( | |
217 | + log.trace( | |
218 | 218 | "收到RequestEvent,方法类型【{}】,事件内容【{}】", |
219 | 219 | methodName, |
220 | 220 | request.getRawContent() == null ? null : new String(request.getRawContent())); |
... | ... | @@ -477,7 +477,7 @@ public class SIPProcessorObserver extends SIPRequestProcessorParent |
477 | 477 | } catch (ParseException | InvalidArgumentException | SipException ex) { |
478 | 478 | throw new RuntimeException(ex); |
479 | 479 | } |
480 | - log.error("摄像头【{}】使用凭证【{}】在平台进行鉴权失败。", camaraAddress, deviceId, e); | |
480 | + log.trace("摄像头【{}】使用凭证【{}】在平台进行鉴权失败。", camaraAddress, deviceId, e); | |
481 | 481 | } |
482 | 482 | }); |
483 | 483 | |
... | ... | @@ -779,7 +779,7 @@ public class SIPProcessorObserver extends SIPRequestProcessorParent |
779 | 779 | UUID sessionId, TransportProtos.ToDeviceRpcRequestMsg rpcRequest) { |
780 | 780 | |
781 | 781 | try { |
782 | - log.error("【{}】下发RPC命令【{}】", sessionId, rpcRequest.getParams()); | |
782 | + log.trace("【{}】下发RPC命令【{}】", sessionId, rpcRequest.getParams()); | |
783 | 783 | JsonNode rpcBody = JacksonUtil.toJsonNode(rpcRequest.getParams()); |
784 | 784 | String cameraCode = rpcParamVal(rpcBody, FastIotConstants.ZLMediaBody.CAMERA_CODE); |
785 | 785 | GbtDeviceSessionCtx devSession = deviceSessions.get(cameraCode); | ... | ... |
... | ... | @@ -90,7 +90,7 @@ public class TcpGatewayDeviceSessionCtx extends TcpDeviceWareSessionContext impl |
90 | 90 | |
91 | 91 | @Override |
92 | 92 | public void onToDeviceRpcRequest(UUID sessionId, TransportProtos.ToDeviceRpcRequestMsg request) { |
93 | - log.error("【{}】下发RPC命令【{}】给网关子设备", sessionId, request.getParams()); | |
93 | + log.trace("【{}】下发RPC命令【{}】给网关子设备", sessionId, request.getParams()); | |
94 | 94 | try { |
95 | 95 | parent.getPayloadAdaptor().convertToPublish(this, request).ifPresent( |
96 | 96 | payload -> { | ... | ... |