| | |
| | | package com.genersoft.iot.vmp.service.redisMsg; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.conf.DynamicTask; |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| | |
| | | while (!taskQueue.isEmpty()) { |
| | | Message msg = taskQueue.poll(); |
| | | JSONObject msgJSON = JSON.parseObject(msg.getBody(), JSONObject.class); |
| | | WvpRedisMsg wvpRedisMsg = JSON.toJavaObject(msgJSON, WvpRedisMsg.class); |
| | | WvpRedisMsg wvpRedisMsg = JSON.to(WvpRedisMsg.class, msgJSON); |
| | | if (!userSetting.getServerId().equals(wvpRedisMsg.getToId())) { |
| | | continue; |
| | | } |
| | |
| | | |
| | | switch (wvpRedisMsg.getCmd()){ |
| | | case WvpRedisMsgCmd.GET_SEND_ITEM: |
| | | RequestSendItemMsg content = JSON.toJavaObject((JSONObject)wvpRedisMsg.getContent(), RequestSendItemMsg.class); |
| | | RequestSendItemMsg content = JSON.to(RequestSendItemMsg.class, wvpRedisMsg.getContent()); |
| | | requestSendItemMsgHand(content, wvpRedisMsg.getFromId(), wvpRedisMsg.getSerial()); |
| | | break; |
| | | case WvpRedisMsgCmd.REQUEST_PUSH_STREAM: |
| | | RequestPushStreamMsg param = JSON.toJavaObject((JSONObject)wvpRedisMsg.getContent(), RequestPushStreamMsg.class);; |
| | | RequestPushStreamMsg param = JSON.to(RequestPushStreamMsg.class, wvpRedisMsg.getContent());; |
| | | requestPushStreamMsgHand(param, wvpRedisMsg.getFromId(), wvpRedisMsg.getSerial()); |
| | | break; |
| | | default: |
| | |
| | | switch (wvpRedisMsg.getCmd()){ |
| | | case WvpRedisMsgCmd.GET_SEND_ITEM: |
| | | |
| | | WVPResult content = JSON.toJavaObject((JSONObject)wvpRedisMsg.getContent(), WVPResult.class); |
| | | WVPResult content = JSON.to(WVPResult.class, wvpRedisMsg.getContent()); |
| | | |
| | | String key = wvpRedisMsg.getSerial(); |
| | | switch (content.getCode()) { |
| | | case 0: |
| | | ResponseSendItemMsg responseSendItemMsg =JSON.toJavaObject((JSONObject)content.getData(), ResponseSendItemMsg.class); |
| | | ResponseSendItemMsg responseSendItemMsg =JSON.to(ResponseSendItemMsg.class, content.getData()); |
| | | PlayMsgCallback playMsgCallback = callbacks.get(key); |
| | | if (playMsgCallback != null) { |
| | | callbacksForError.remove(key); |
| | | try { |
| | | playMsgCallback.handler(responseSendItemMsg); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | logger.error("[REDIS消息处理异常] ", e); |
| | | } |
| | | } |
| | | break; |
| | |
| | | } |
| | | break; |
| | | case WvpRedisMsgCmd.REQUEST_PUSH_STREAM: |
| | | WVPResult wvpResult = JSON.toJavaObject((JSONObject)wvpRedisMsg.getContent(), WVPResult.class); |
| | | WVPResult wvpResult = JSON.to(WVPResult.class, wvpRedisMsg.getContent()); |
| | | String serial = wvpRedisMsg.getSerial(); |
| | | switch (wvpResult.getCode()) { |
| | | case 0: |
| | |
| | | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, content.getIp(), |
| | | content.getPort(), content.getSsrc(), content.getPlatformId(), |
| | | content.getApp(), content.getStream(), content.getChannelId(), |
| | | content.getTcp()); |
| | | content.getTcp(), content.getRtcp()); |
| | | |
| | | WVPResult<ResponseSendItemMsg> result = new WVPResult<>(); |
| | | result.setCode(0); |
| | |
| | | * @param callback 得到信息的回调 |
| | | */ |
| | | public void sendMsg(String serverId, String mediaServerId, String app, String stream, String ip, int port, String ssrc, |
| | | String platformId, String channelId, boolean isTcp, String platformName, PlayMsgCallback callback, PlayMsgErrorCallback errorCallback) { |
| | | String platformId, String channelId, boolean isTcp, boolean rtcp, String platformName, PlayMsgCallback callback, PlayMsgErrorCallback errorCallback) { |
| | | RequestSendItemMsg requestSendItemMsg = RequestSendItemMsg.getInstance( |
| | | serverId, mediaServerId, app, stream, ip, port, ssrc, platformId, channelId, isTcp, platformName); |
| | | serverId, mediaServerId, app, stream, ip, port, ssrc, platformId, channelId, isTcp, rtcp, platformName); |
| | | requestSendItemMsg.setServerId(serverId); |
| | | String key = UUID.randomUUID().toString(); |
| | | WvpRedisMsg redisMsg = WvpRedisMsg.getRequestInstance(userSetting.getServerId(), serverId, WvpRedisMsgCmd.GET_SEND_ITEM, |