Commit 562dbb0857e4e6f7a250d69752270c0c165d5141
Merge remote-tracking branch 'origin/main-dev' into main-dev
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java # src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
Showing
4 changed files
with
40 additions
and
47 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -40,6 +40,7 @@ import javax.sip.SipFactory; | @@ -40,6 +40,7 @@ import javax.sip.SipFactory; | ||
| 40 | import javax.sip.header.CallIdHeader; | 40 | import javax.sip.header.CallIdHeader; |
| 41 | import javax.sip.message.Request; | 41 | import javax.sip.message.Request; |
| 42 | import java.text.ParseException; | 42 | import java.text.ParseException; |
| 43 | +import java.util.ArrayList; | ||
| 43 | import java.util.List; | 44 | import java.util.List; |
| 44 | 45 | ||
| 45 | /** | 46 | /** |
| @@ -696,7 +697,6 @@ public class SIPCommander implements ISIPCommander { | @@ -696,7 +697,6 @@ public class SIPCommander implements ISIPCommander { | ||
| 696 | streamSession.removeByCallId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getCallId()); | 697 | streamSession.removeByCallId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getCallId()); |
| 697 | Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo()); | 698 | Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo()); |
| 698 | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); | 699 | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); |
| 699 | - | ||
| 700 | } | 700 | } |
| 701 | } | 701 | } |
| 702 | 702 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
| @@ -217,7 +217,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In | @@ -217,7 +217,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In | ||
| 217 | if (mediaServerItem != null) { | 217 | if (mediaServerItem != null) { |
| 218 | mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc()); | 218 | mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc()); |
| 219 | } | 219 | } |
| 220 | - streamSession.removeByCallId(device.getDeviceId(), channel.getChannelId(), ssrcTransaction.getCallId()); | 220 | + streamSession.removeByCallId(device.getDeviceId(), channel.getChannelId(), ssrcTransaction.getCallId()); |
| 221 | if (ssrcTransaction.getType() == InviteSessionType.BROADCAST) { | 221 | if (ssrcTransaction.getType() == InviteSessionType.BROADCAST) { |
| 222 | // 查找来源的对讲设备,发送停止 | 222 | // 查找来源的对讲设备,发送停止 |
| 223 | Device sourceDevice = storager.queryVideoDeviceByPlatformIdAndChannelId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); | 223 | Device sourceDevice = storager.queryVideoDeviceByPlatformIdAndChannelId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -267,7 +267,7 @@ public class ZLMHttpHookListener { | @@ -267,7 +267,7 @@ public class ZLMHttpHookListener { | ||
| 267 | result.setEnable_mp4(userSetting.isRecordPushLive()); | 267 | result.setEnable_mp4(userSetting.isRecordPushLive()); |
| 268 | } | 268 | } |
| 269 | // 国标流 | 269 | // 国标流 |
| 270 | - if ("rtp".equals(param.getApp()) ) { | 270 | + if ("rtp".equals(param.getApp())) { |
| 271 | 271 | ||
| 272 | InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream()); | 272 | InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream()); |
| 273 | 273 | ||
| @@ -318,13 +318,17 @@ public class ZLMHttpHookListener { | @@ -318,13 +318,17 @@ public class ZLMHttpHookListener { | ||
| 318 | result.setEnable_audio(true); | 318 | result.setEnable_audio(true); |
| 319 | } | 319 | } |
| 320 | } | 320 | } |
| 321 | + } else if (param.getApp().equals("broadcast")) { | ||
| 322 | + result.setEnable_audio(true); | ||
| 323 | + } else if (param.getApp().equals("talk")) { | ||
| 324 | + result.setEnable_audio(true); | ||
| 321 | } | 325 | } |
| 322 | if (param.getApp().equalsIgnoreCase("rtp")) { | 326 | if (param.getApp().equalsIgnoreCase("rtp")) { |
| 323 | String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + param.getStream(); | 327 | String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + param.getStream(); |
| 324 | - OtherRtpSendInfo otherRtpSendInfo = (OtherRtpSendInfo)redisTemplate.opsForValue().get(receiveKey); | 328 | + OtherRtpSendInfo otherRtpSendInfo = (OtherRtpSendInfo) redisTemplate.opsForValue().get(receiveKey); |
| 325 | 329 | ||
| 326 | String receiveKeyForPS = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_" + param.getStream(); | 330 | String receiveKeyForPS = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_" + param.getStream(); |
| 327 | - OtherPsSendInfo otherPsSendInfo = (OtherPsSendInfo)redisTemplate.opsForValue().get(receiveKeyForPS); | 331 | + OtherPsSendInfo otherPsSendInfo = (OtherPsSendInfo) redisTemplate.opsForValue().get(receiveKeyForPS); |
| 328 | if (otherRtpSendInfo != null || otherPsSendInfo != null) { | 332 | if (otherRtpSendInfo != null || otherPsSendInfo != null) { |
| 329 | result.setEnable_mp4(true); | 333 | result.setEnable_mp4(true); |
| 330 | } | 334 | } |
| @@ -347,13 +351,10 @@ public class ZLMHttpHookListener { | @@ -347,13 +351,10 @@ public class ZLMHttpHookListener { | ||
| 347 | logger.info("[ZLM HOOK] 流注销, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); | 351 | logger.info("[ZLM HOOK] 流注销, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); |
| 348 | } | 352 | } |
| 349 | 353 | ||
| 350 | - JSONObject ret = new JSONObject(); | ||
| 351 | - ret.put("code", 0); | ||
| 352 | - ret.put("msg", "success"); | ||
| 353 | - MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); | ||
| 354 | JSONObject json = (JSONObject) JSON.toJSON(param); | 354 | JSONObject json = (JSONObject) JSON.toJSON(param); |
| 355 | taskExecutor.execute(() -> { | 355 | taskExecutor.execute(() -> { |
| 356 | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); | 356 | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); |
| 357 | + MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); | ||
| 357 | if (mediaInfo == null) { | 358 | if (mediaInfo == null) { |
| 358 | logger.info("[ZLM HOOK] 流变化未找到ZLM, {}", param.getMediaServerId()); | 359 | logger.info("[ZLM HOOK] 流变化未找到ZLM, {}", param.getMediaServerId()); |
| 359 | return; | 360 | return; |
| @@ -500,7 +501,7 @@ public class ZLMHttpHookListener { | @@ -500,7 +501,7 @@ public class ZLMHttpHookListener { | ||
| 500 | GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream()); | 501 | GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream()); |
| 501 | if (gbStream != null) { | 502 | if (gbStream != null) { |
| 502 | if (userSetting.isUsePushingAsStatus()) { | 503 | if (userSetting.isUsePushingAsStatus()) { |
| 503 | - eventPublisher.catalogEventPublishForStream(null, gbStream, param.isRegist()?CatalogEvent.ON:CatalogEvent.OFF); | 504 | + eventPublisher.catalogEventPublishForStream(null, gbStream, param.isRegist() ? CatalogEvent.ON : CatalogEvent.OFF); |
| 504 | } | 505 | } |
| 505 | } | 506 | } |
| 506 | if (type != null) { | 507 | if (type != null) { |
| @@ -524,33 +525,31 @@ public class ZLMHttpHookListener { | @@ -524,33 +525,31 @@ public class ZLMHttpHookListener { | ||
| 524 | ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); | 525 | ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); |
| 525 | Device device = deviceService.getDevice(platformId); | 526 | Device device = deviceService.getDevice(platformId); |
| 526 | 527 | ||
| 527 | - try { | ||
| 528 | - if (platform != null) { | ||
| 529 | - commanderFroPlatform.streamByeCmd(platform, sendRtpItem); | ||
| 530 | - redisCatchStorage.deleteSendRTPServer(platformId, sendRtpItem.getChannelId(), | ||
| 531 | - sendRtpItem.getCallId(), sendRtpItem.getStream()); | ||
| 532 | - } else { | ||
| 533 | - cmder.streamByeCmd(device, sendRtpItem.getChannelId(), param.getStream(), sendRtpItem.getCallId()); | ||
| 534 | - if (sendRtpItem.getPlayType().equals(InviteStreamType.BROADCAST) | ||
| 535 | - || sendRtpItem.getPlayType().equals(InviteStreamType.TALK)) { | ||
| 536 | - AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); | ||
| 537 | - if (audioBroadcastCatch != null) { | ||
| 538 | - // 来自上级平台的停止对讲 | ||
| 539 | - logger.info("[停止对讲] 来自上级,平台:{}, 通道:{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); | ||
| 540 | - audioBroadcastManager.del(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); | ||
| 541 | - } | 528 | + try { |
| 529 | + if (platform != null) { | ||
| 530 | + commanderFroPlatform.streamByeCmd(platform, sendRtpItem); | ||
| 531 | + redisCatchStorage.deleteSendRTPServer(platformId, sendRtpItem.getChannelId(), | ||
| 532 | + sendRtpItem.getCallId(), sendRtpItem.getStream()); | ||
| 533 | + } else { | ||
| 534 | + cmder.streamByeCmd(device, sendRtpItem.getChannelId(), param.getStream(), sendRtpItem.getCallId()); | ||
| 535 | + if (sendRtpItem.getPlayType().equals(InviteStreamType.BROADCAST) | ||
| 536 | + || sendRtpItem.getPlayType().equals(InviteStreamType.TALK)) { | ||
| 537 | + AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); | ||
| 538 | + if (audioBroadcastCatch != null) { | ||
| 539 | + // 来自上级平台的停止对讲 | ||
| 540 | + logger.info("[停止对讲] 来自上级,平台:{}, 通道:{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); | ||
| 541 | + audioBroadcastManager.del(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); | ||
| 542 | } | 542 | } |
| 543 | } | 543 | } |
| 544 | - } catch (SipException | InvalidArgumentException | ParseException | | ||
| 545 | - SsrcTransactionNotFoundException e) { | ||
| 546 | - logger.error("[命令发送失败] 发送BYE: {}", e.getMessage()); | ||
| 547 | } | 544 | } |
| 545 | + } catch (SipException | InvalidArgumentException | ParseException | | ||
| 546 | + SsrcTransactionNotFoundException e) { | ||
| 547 | + logger.error("[命令发送失败] 发送BYE: {}", e.getMessage()); | ||
| 548 | } | 548 | } |
| 549 | } | 549 | } |
| 550 | } | 550 | } |
| 551 | } | 551 | } |
| 552 | } | 552 | } |
| 553 | - | ||
| 554 | } | 553 | } |
| 555 | }); | 554 | }); |
| 556 | return HookResult.SUCCESS(); | 555 | return HookResult.SUCCESS(); |
| @@ -612,14 +611,14 @@ public class ZLMHttpHookListener { | @@ -612,14 +611,14 @@ public class ZLMHttpHookListener { | ||
| 612 | if (info != null) { | 611 | if (info != null) { |
| 613 | cmder.streamByeCmd(device, inviteInfo.getChannelId(), | 612 | cmder.streamByeCmd(device, inviteInfo.getChannelId(), |
| 614 | inviteInfo.getStream(), null); | 613 | inviteInfo.getStream(), null); |
| 615 | - }else { | 614 | + } else { |
| 616 | logger.info("[无人观看] 未找到设备的点播信息: {}, 流:{}", inviteInfo.getDeviceId(), param.getStream()); | 615 | logger.info("[无人观看] 未找到设备的点播信息: {}, 流:{}", inviteInfo.getDeviceId(), param.getStream()); |
| 617 | } | 616 | } |
| 618 | } catch (InvalidArgumentException | ParseException | SipException | | 617 | } catch (InvalidArgumentException | ParseException | SipException | |
| 619 | SsrcTransactionNotFoundException e) { | 618 | SsrcTransactionNotFoundException e) { |
| 620 | logger.error("[无人观看]点播, 发送BYE失败 {}", e.getMessage()); | 619 | logger.error("[无人观看]点播, 发送BYE失败 {}", e.getMessage()); |
| 621 | } | 620 | } |
| 622 | - }else { | 621 | + } else { |
| 623 | logger.info("[无人观看] 未找到设备: {},流:{}", inviteInfo.getDeviceId(), param.getStream()); | 622 | logger.info("[无人观看] 未找到设备: {},流:{}", inviteInfo.getDeviceId(), param.getStream()); |
| 624 | } | 623 | } |
| 625 | 624 | ||
| @@ -729,7 +728,7 @@ public class ZLMHttpHookListener { | @@ -729,7 +728,7 @@ public class ZLMHttpHookListener { | ||
| 729 | }); | 728 | }); |
| 730 | } | 729 | } |
| 731 | return result; | 730 | return result; |
| 732 | - }else if(s.length == 4){ | 731 | + } else if (s.length == 4) { |
| 733 | // 此时为录像回放, 录像回放格式为> 设备ID_通道ID_开始时间_结束时间 | 732 | // 此时为录像回放, 录像回放格式为> 设备ID_通道ID_开始时间_结束时间 |
| 734 | String startTimeStr = s[2]; | 733 | String startTimeStr = s[2]; |
| 735 | String endTimeStr = s[3]; | 734 | String endTimeStr = s[3]; |
| @@ -763,14 +762,14 @@ public class ZLMHttpHookListener { | @@ -763,14 +762,14 @@ public class ZLMHttpHookListener { | ||
| 763 | 762 | ||
| 764 | if (!exist) { | 763 | if (!exist) { |
| 765 | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaInfo, param.getStream(), null, | 764 | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaInfo, param.getStream(), null, |
| 766 | - device.isSsrcCheck(), true, 0, false, false, device.getStreamModeForParam()); | 765 | + device.isSsrcCheck(), true, 0, false, false, device.getStreamModeForParam()); |
| 767 | playService.playBack(mediaInfo, ssrcInfo, deviceId, channelId, startTime, endTime, (code, message, data) -> { | 766 | playService.playBack(mediaInfo, ssrcInfo, deviceId, channelId, startTime, endTime, (code, message, data) -> { |
| 768 | msg.setData(new HookResult(code, message)); | 767 | msg.setData(new HookResult(code, message)); |
| 769 | resultHolder.invokeResult(msg); | 768 | resultHolder.invokeResult(msg); |
| 770 | }); | 769 | }); |
| 771 | } | 770 | } |
| 772 | return result; | 771 | return result; |
| 773 | - }else { | 772 | + } else { |
| 774 | defaultResult.setResult(HookResult.SUCCESS()); | 773 | defaultResult.setResult(HookResult.SUCCESS()); |
| 775 | return defaultResult; | 774 | return defaultResult; |
| 776 | } | 775 | } |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -21,24 +21,24 @@ import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | @@ -21,24 +21,24 @@ import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | ||
| 21 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 21 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 22 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | 22 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 23 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | 23 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 24 | -import com.genersoft.iot.vmp.media.zlm.*; | ||
| 25 | -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | ||
| 26 | -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | ||
| 27 | -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | ||
| 28 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 24 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 29 | import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; | 25 | import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; |
| 30 | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | 26 | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 31 | import com.genersoft.iot.vmp.media.zlm.dto.*; | 27 | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| 28 | +import com.genersoft.iot.vmp.media.zlm.*; | ||
| 29 | +import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | ||
| 30 | +import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | ||
| 31 | +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | ||
| 32 | import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam; | 32 | import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam; |
| 33 | import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRecordMp4HookParam; | 33 | import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRecordMp4HookParam; |
| 34 | import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | 34 | import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; |
| 35 | import com.genersoft.iot.vmp.service.*; | 35 | import com.genersoft.iot.vmp.service.*; |
| 36 | +import com.genersoft.iot.vmp.service.bean.*; | ||
| 36 | import com.genersoft.iot.vmp.service.bean.ErrorCallback; | 37 | import com.genersoft.iot.vmp.service.bean.ErrorCallback; |
| 37 | import com.genersoft.iot.vmp.service.bean.InviteErrorCode; | 38 | import com.genersoft.iot.vmp.service.bean.InviteErrorCode; |
| 38 | import com.genersoft.iot.vmp.service.bean.RequestPushStreamMsg; | 39 | import com.genersoft.iot.vmp.service.bean.RequestPushStreamMsg; |
| 39 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 40 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 40 | import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener; | 41 | import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener; |
| 41 | -import com.genersoft.iot.vmp.service.bean.*; | ||
| 42 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 42 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 43 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 43 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 44 | import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper; | 44 | import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper; |
| @@ -101,19 +101,13 @@ public class PlayServiceImpl implements IPlayService { | @@ -101,19 +101,13 @@ public class PlayServiceImpl implements IPlayService { | ||
| 101 | private IInviteStreamService inviteStreamService; | 101 | private IInviteStreamService inviteStreamService; |
| 102 | 102 | ||
| 103 | @Autowired | 103 | @Autowired |
| 104 | - private SendRtpPortManager sendRtpPortManager; | ||
| 105 | - | ||
| 106 | - @Autowired | ||
| 107 | private ZlmHttpHookSubscribe subscribe; | 104 | private ZlmHttpHookSubscribe subscribe; |
| 108 | 105 | ||
| 109 | @Autowired | 106 | @Autowired |
| 110 | - private ZLMRESTfulUtils zlmresTfulUtils; | ||
| 111 | - | ||
| 112 | - @Autowired | ||
| 113 | - private AssistRESTfulUtils assistRESTfulUtils; | 107 | + private SendRtpPortManager sendRtpPortManager; |
| 114 | 108 | ||
| 115 | @Autowired | 109 | @Autowired |
| 116 | - private ZLMServerFactory zlmServerFactory; | 110 | + private ZLMRESTfulUtils zlmresTfulUtils; |
| 117 | 111 | ||
| 118 | @Autowired | 112 | @Autowired |
| 119 | private IMediaService mediaService; | 113 | private IMediaService mediaService; |