Commit f961515317a33fe965287ca5c978b85e9ce1abcc
1 parent
5a7a7a12
合并主线
Showing
7 changed files
with
45 additions
and
54 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
| @@ -56,7 +56,7 @@ public class SIPRequestHeaderPlarformProvider { | @@ -56,7 +56,7 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 56 | //via | 56 | //via |
| 57 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 57 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 58 | ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), | 58 | ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), |
| 59 | - Integer.parseInt(parentPlatform.getDevicePort()), parentPlatform.getTransport(), SipUtils.getNewViaTag()); | 59 | + parentPlatform.getDevicePort(), parentPlatform.getTransport(), SipUtils.getNewViaTag()); |
| 60 | viaHeader.setRPort(); | 60 | viaHeader.setRPort(); |
| 61 | viaHeaders.add(viaHeader); | 61 | viaHeaders.add(viaHeader); |
| 62 | //from | 62 | //from |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -6,9 +6,7 @@ import com.genersoft.iot.vmp.conf.SipConfig; | @@ -6,9 +6,7 @@ import com.genersoft.iot.vmp.conf.SipConfig; | ||
| 6 | import com.genersoft.iot.vmp.conf.UserSetting; | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; | 7 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 8 | import com.genersoft.iot.vmp.gb28181.SipLayer; | 8 | import com.genersoft.iot.vmp.gb28181.SipLayer; |
| 9 | -import com.genersoft.iot.vmp.gb28181.bean.Device; | ||
| 10 | -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; | ||
| 11 | -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; | 9 | +import com.genersoft.iot.vmp.gb28181.bean.*; |
| 12 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 10 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 13 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | 11 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 14 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; | 12 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| @@ -624,9 +622,9 @@ public class SIPCommander implements ISIPCommander { | @@ -624,9 +622,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 624 | 622 | ||
| 625 | logger.info("[语音喊话] {} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), sendRtpItem.getPort()); | 623 | logger.info("[语音喊话] {} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), sendRtpItem.getPort()); |
| 626 | HookSubscribeForStreamChange hookSubscribeForStreamChange = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId()); | 624 | HookSubscribeForStreamChange hookSubscribeForStreamChange = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId()); |
| 627 | - subscribe.addSubscribe(hookSubscribeForStreamChange, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { | 625 | + subscribe.addSubscribe(hookSubscribeForStreamChange, (mediaServerItemInUse, hookParam) -> { |
| 628 | if (event != null) { | 626 | if (event != null) { |
| 629 | - event.response(mediaServerItemInUse, json); | 627 | + event.response(mediaServerItemInUse, hookParam); |
| 630 | subscribe.removeSubscribe(hookSubscribeForStreamChange); | 628 | subscribe.removeSubscribe(hookSubscribeForStreamChange); |
| 631 | } | 629 | } |
| 632 | }); | 630 | }); |
| @@ -634,9 +632,9 @@ public class SIPCommander implements ISIPCommander { | @@ -634,9 +632,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 634 | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()), device.getTransport()); | 632 | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()), device.getTransport()); |
| 635 | callIdHeader.setCallId(callId); | 633 | callIdHeader.setCallId(callId); |
| 636 | HookSubscribeForStreamPush hookSubscribeForStreamPush = HookSubscribeFactory.on_publish("rtp", stream, null, mediaServerItem.getId()); | 634 | HookSubscribeForStreamPush hookSubscribeForStreamPush = HookSubscribeFactory.on_publish("rtp", stream, null, mediaServerItem.getId()); |
| 637 | - subscribe.addSubscribe(hookSubscribeForStreamPush, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { | 635 | + subscribe.addSubscribe(hookSubscribeForStreamPush, (mediaServerItemInUse, hookParam) -> { |
| 638 | if (eventForPush != null) { | 636 | if (eventForPush != null) { |
| 639 | - eventForPush.response(mediaServerItemInUse, json); | 637 | + eventForPush.response(mediaServerItemInUse, hookParam); |
| 640 | } | 638 | } |
| 641 | }); | 639 | }); |
| 642 | // | 640 | // |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| @@ -19,6 +19,7 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | @@ -19,6 +19,7 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | ||
| 19 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | 19 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| 20 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | 20 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| 21 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 21 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 22 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam; | ||
| 22 | import com.genersoft.iot.vmp.service.IMediaServerService; | 23 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 23 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | 24 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| 24 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 25 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| @@ -899,9 +900,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -899,9 +900,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 899 | 900 | ||
| 900 | logger.info("{} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); | 901 | logger.info("{} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); |
| 901 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId()); | 902 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId()); |
| 902 | - subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { | 903 | + subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, HookParam hookParam) -> { |
| 903 | if (event != null) { | 904 | if (event != null) { |
| 904 | - event.response(mediaServerItemInUse, json); | 905 | + event.response(mediaServerItemInUse, hookParam); |
| 905 | subscribe.removeSubscribe(hookSubscribe); | 906 | subscribe.removeSubscribe(hookSubscribe); |
| 906 | } | 907 | } |
| 907 | }); | 908 | }); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java
| @@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag | @@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag | ||
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; | 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; |
| 11 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; | 11 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 12 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 12 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 13 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | ||
| 13 | import com.genersoft.iot.vmp.service.IDeviceService; | 14 | import com.genersoft.iot.vmp.service.IDeviceService; |
| 14 | import com.genersoft.iot.vmp.service.IMediaServerService; | 15 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 15 | import com.genersoft.iot.vmp.service.IPlatformService; | 16 | import com.genersoft.iot.vmp.service.IPlatformService; |
| @@ -127,10 +128,9 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp | @@ -127,10 +128,9 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp | ||
| 127 | 128 | ||
| 128 | // 消息发送成功, 向上级发送invite,获取推流 | 129 | // 消息发送成功, 向上级发送invite,获取推流 |
| 129 | try { | 130 | try { |
| 130 | - platformService.broadcastInvite(platform, deviceChannel.getChannelId(), mediaServerForMinimumLoad, (mediaServerItem, response)->{ | 131 | + platformService.broadcastInvite(platform, deviceChannel.getChannelId(), mediaServerForMinimumLoad, (mediaServerItem, hookParam)->{ |
| 132 | + OnStreamChangedHookParam streamChangedHookParam = (OnStreamChangedHookParam)hookParam; | ||
| 131 | // 上级平台推流成功 | 133 | // 上级平台推流成功 |
| 132 | - String app = response.getString("app"); | ||
| 133 | - String stream = response.getString("stream"); | ||
| 134 | AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(device.getDeviceId(), targetId); | 134 | AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(device.getDeviceId(), targetId); |
| 135 | if (broadcastCatch != null ) { | 135 | if (broadcastCatch != null ) { |
| 136 | if (playService.audioBroadcastInUse(device, targetId)) { | 136 | if (playService.audioBroadcastInUse(device, targetId)) { |
| @@ -138,24 +138,24 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp | @@ -138,24 +138,24 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp | ||
| 138 | platform.getServerGBId(), deviceChannel.getChannelId()); | 138 | platform.getServerGBId(), deviceChannel.getChannelId()); |
| 139 | // 查看语音通道已经建立且已经占用 回复BYE | 139 | // 查看语音通道已经建立且已经占用 回复BYE |
| 140 | try { | 140 | try { |
| 141 | - platformService.stopBroadcast(platform, deviceChannel.getChannelId(), stream); | 141 | + platformService.stopBroadcast(platform, deviceChannel.getChannelId(), streamChangedHookParam.getStream()); |
| 142 | } catch (InvalidArgumentException | ParseException | SsrcTransactionNotFoundException | | 142 | } catch (InvalidArgumentException | ParseException | SsrcTransactionNotFoundException | |
| 143 | SipException e) { | 143 | SipException e) { |
| 144 | logger.info("[消息发送失败] 国标级联 语音喊话 platform: {}, channel: {}", platform.getServerGBId(), deviceChannel.getChannelId()); | 144 | logger.info("[消息发送失败] 国标级联 语音喊话 platform: {}, channel: {}", platform.getServerGBId(), deviceChannel.getChannelId()); |
| 145 | } | 145 | } |
| 146 | }else { | 146 | }else { |
| 147 | // 查看语音通道已经建立但是未占用 | 147 | // 查看语音通道已经建立但是未占用 |
| 148 | - broadcastCatch.setApp(app); | ||
| 149 | - broadcastCatch.setStream(stream); | 148 | + broadcastCatch.setApp(streamChangedHookParam.getApp()); |
| 149 | + broadcastCatch.setStream(streamChangedHookParam.getStream()); | ||
| 150 | broadcastCatch.setMediaServerItem(mediaServerItem); | 150 | broadcastCatch.setMediaServerItem(mediaServerItem); |
| 151 | audioBroadcastManager.update(broadcastCatch); | 151 | audioBroadcastManager.update(broadcastCatch); |
| 152 | // 推流到设备 | 152 | // 推流到设备 |
| 153 | - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, targetId, stream, null); | 153 | + SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, targetId, streamChangedHookParam.getStream(), null); |
| 154 | if (sendRtpItem == null) { | 154 | if (sendRtpItem == null) { |
| 155 | - logger.warn("[国标级联] 语音喊话 异常,未找到发流信息, channelId: {}, stream: {}", targetId, stream); | ||
| 156 | - logger.info("[国标级联] 语音喊话 重新开始,channelId: {}, stream: {}", targetId, stream); | 155 | + logger.warn("[国标级联] 语音喊话 异常,未找到发流信息, channelId: {}, stream: {}", targetId, streamChangedHookParam.getStream()); |
| 156 | + logger.info("[国标级联] 语音喊话 重新开始,channelId: {}, stream: {}", targetId, streamChangedHookParam.getStream()); | ||
| 157 | try { | 157 | try { |
| 158 | - playService.audioBroadcastCmd(device, targetId, mediaServerItem, app, stream, 60, true, msg -> { | 158 | + playService.audioBroadcastCmd(device, targetId, mediaServerItem, streamChangedHookParam.getApp(), streamChangedHookParam.getStream(), 60, true, msg -> { |
| 159 | logger.info("[语音喊话] 通道建立成功, device: {}, channel: {}", device.getDeviceId(), targetId); | 159 | logger.info("[语音喊话] 通道建立成功, device: {}, channel: {}", device.getDeviceId(), targetId); |
| 160 | }); | 160 | }); |
| 161 | } catch (SipException | InvalidArgumentException | ParseException e) { | 161 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| @@ -173,7 +173,7 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp | @@ -173,7 +173,7 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp | ||
| 173 | } | 173 | } |
| 174 | }else { | 174 | }else { |
| 175 | try { | 175 | try { |
| 176 | - playService.audioBroadcastCmd(device, targetId, mediaServerItem, app, stream, 60, true, msg -> { | 176 | + playService.audioBroadcastCmd(device, targetId, mediaServerItem, streamChangedHookParam.getApp(), streamChangedHookParam.getStream(), 60, true, msg -> { |
| 177 | logger.info("[语音喊话] 通道建立成功, device: {}, channel: {}", device.getDeviceId(), targetId); | 177 | logger.info("[语音喊话] 通道建立成功, device: {}, channel: {}", device.getDeviceId(), targetId); |
| 178 | }); | 178 | }); |
| 179 | } catch (SipException | InvalidArgumentException | ParseException e) { | 179 | } catch (SipException | InvalidArgumentException | ParseException e) { |
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
| @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | ||
| 7 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 7 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 8 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | 8 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 9 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 9 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 10 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam; | ||
| 10 | import com.genersoft.iot.vmp.service.bean.ErrorCallback; | 11 | import com.genersoft.iot.vmp.service.bean.ErrorCallback; |
| 11 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 12 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 12 | import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult; | 13 | import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult; |
| @@ -28,7 +29,7 @@ public interface IPlayService { | @@ -28,7 +29,7 @@ public interface IPlayService { | ||
| 28 | ErrorCallback<Object> callback); | 29 | ErrorCallback<Object> callback); |
| 29 | SSRCInfo play(MediaServerItem mediaServerItem, String deviceId, String channelId, ErrorCallback<Object> callback); | 30 | SSRCInfo play(MediaServerItem mediaServerItem, String deviceId, String channelId, ErrorCallback<Object> callback); |
| 30 | 31 | ||
| 31 | - StreamInfo onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId); | 32 | + StreamInfo onPublishHandlerForPlay(MediaServerItem mediaServerItem, HookParam hookParam, String deviceId, String channelId); |
| 32 | 33 | ||
| 33 | MediaServerItem getNewMediaServerItem(Device device); | 34 | MediaServerItem getNewMediaServerItem(Device device); |
| 34 | 35 |
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
| 1 | package com.genersoft.iot.vmp.service.impl; | 1 | package com.genersoft.iot.vmp.service.impl; |
| 2 | 2 | ||
| 3 | -import com.alibaba.fastjson2.JSONObject; | ||
| 4 | import com.genersoft.iot.vmp.common.InviteInfo; | 3 | import com.genersoft.iot.vmp.common.InviteInfo; |
| 5 | import com.genersoft.iot.vmp.common.InviteSessionType; | 4 | import com.genersoft.iot.vmp.common.InviteSessionType; |
| 6 | import com.genersoft.iot.vmp.conf.DynamicTask; | 5 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| @@ -16,6 +15,7 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | @@ -16,6 +15,7 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | ||
| 16 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | 15 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| 17 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | 16 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| 18 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 17 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 18 | +import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; | ||
| 19 | import com.genersoft.iot.vmp.service.IInviteStreamService; | 19 | import com.genersoft.iot.vmp.service.IInviteStreamService; |
| 20 | import com.genersoft.iot.vmp.service.IMediaServerService; | 20 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 21 | import com.genersoft.iot.vmp.service.IPlatformService; | 21 | import com.genersoft.iot.vmp.service.IPlatformService; |
| @@ -442,10 +442,11 @@ public class PlatformServiceImpl implements IPlatformService { | @@ -442,10 +442,11 @@ public class PlatformServiceImpl implements IPlatformService { | ||
| 442 | inviteStreamService.removeInviteInfo(inviteInfo); | 442 | inviteStreamService.removeInviteInfo(inviteInfo); |
| 443 | }else { | 443 | }else { |
| 444 | // 流确实尚在推流,直接回调结果 | 444 | // 流确实尚在推流,直接回调结果 |
| 445 | - JSONObject json = new JSONObject(); | ||
| 446 | - json.put("app", inviteInfo.getStreamInfo().getApp()); | ||
| 447 | - json.put("stream", inviteInfo.getStreamInfo().getStream()); | ||
| 448 | - hookEvent.response(mediaServerItemForStreamInfo, json); | 445 | + OnStreamChangedHookParam hookParam = new OnStreamChangedHookParam(); |
| 446 | + hookParam.setApp(inviteInfo.getStreamInfo().getApp()); | ||
| 447 | + hookParam.setStream(inviteInfo.getStreamInfo().getStream()); | ||
| 448 | + | ||
| 449 | + hookEvent.response(mediaServerItemForStreamInfo, hookParam); | ||
| 449 | return; | 450 | return; |
| 450 | } | 451 | } |
| 451 | } | 452 | } |
| @@ -498,14 +499,14 @@ public class PlatformServiceImpl implements IPlatformService { | @@ -498,14 +499,14 @@ public class PlatformServiceImpl implements IPlatformService { | ||
| 498 | } | 499 | } |
| 499 | } | 500 | } |
| 500 | }, userSetting.getPlayTimeout()); | 501 | }, userSetting.getPlayTimeout()); |
| 501 | - commanderForPlatform.broadcastInviteCmd(platform, channelId, mediaServerItem, ssrcInfo, (mediaServerItemForInvite, response)->{ | 502 | + commanderForPlatform.broadcastInviteCmd(platform, channelId, mediaServerItem, ssrcInfo, (mediaServerItemForInvite, hookParam)->{ |
| 502 | logger.info("[国标级联] 发起语音喊话 收到上级推流 deviceId: {}, channelId: {}", platform.getServerGBId(), channelId); | 503 | logger.info("[国标级联] 发起语音喊话 收到上级推流 deviceId: {}, channelId: {}", platform.getServerGBId(), channelId); |
| 503 | dynamicTask.stop(timeOutTaskKey); | 504 | dynamicTask.stop(timeOutTaskKey); |
| 504 | // hook响应 | 505 | // hook响应 |
| 505 | - playService.onPublishHandlerForPlay(mediaServerItemForInvite, response, platform.getServerGBId(), channelId); | 506 | + playService.onPublishHandlerForPlay(mediaServerItemForInvite, hookParam, platform.getServerGBId(), channelId); |
| 506 | // 收到流 | 507 | // 收到流 |
| 507 | if (hookEvent != null) { | 508 | if (hookEvent != null) { |
| 508 | - hookEvent.response(mediaServerItem, response); | 509 | + hookEvent.response(mediaServerItem, hookParam); |
| 509 | } | 510 | } |
| 510 | }, event -> { | 511 | }, event -> { |
| 511 | // 收到200OK 检测ssrc是否有变化,防止上级自定义了ssrc | 512 | // 收到200OK 检测ssrc是否有变化,防止上级自定义了ssrc |
| @@ -524,30 +525,20 @@ public class PlatformServiceImpl implements IPlatformService { | @@ -524,30 +525,20 @@ public class PlatformServiceImpl implements IPlatformService { | ||
| 524 | logger.info("[点播消息] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse); | 525 | logger.info("[点播消息] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse); |
| 525 | if (!mediaServerItem.isRtpEnable()) { | 526 | if (!mediaServerItem.isRtpEnable()) { |
| 526 | logger.info("[点播消息] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse); | 527 | logger.info("[点播消息] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse); |
| 527 | - | ||
| 528 | - if (!ssrcFactory.checkSsrc(mediaServerItem.getId(), ssrcInResponse)) { | ||
| 529 | - // ssrc 不可用 | ||
| 530 | - // 释放ssrc | ||
| 531 | - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); | ||
| 532 | - streamSession.remove(platform.getServerGBId(), channelId, ssrcInfo.getStream()); | ||
| 533 | - event.msg = "下级自定义了ssrc,但是此ssrc不可用"; | ||
| 534 | - event.statusCode = 400; | ||
| 535 | - errorEvent.response(event); | ||
| 536 | - return; | ||
| 537 | - } | ||
| 538 | - | 528 | + // 释放ssrc |
| 529 | + mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); | ||
| 539 | // 单端口模式streamId也有变化,需要重新设置监听 | 530 | // 单端口模式streamId也有变化,需要重新设置监听 |
| 540 | if (!mediaServerItem.isRtpEnable()) { | 531 | if (!mediaServerItem.isRtpEnable()) { |
| 541 | // 添加订阅 | 532 | // 添加订阅 |
| 542 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); | 533 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); |
| 543 | subscribe.removeSubscribe(hookSubscribe); | 534 | subscribe.removeSubscribe(hookSubscribe); |
| 544 | hookSubscribe.getContent().put("stream", String.format("%08x", Integer.parseInt(ssrcInResponse)).toUpperCase()); | 535 | hookSubscribe.getContent().put("stream", String.format("%08x", Integer.parseInt(ssrcInResponse)).toUpperCase()); |
| 545 | - subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject response) -> { | ||
| 546 | - logger.info("[ZLM HOOK] ssrc修正后收到订阅消息: " + response.toJSONString()); | 536 | + subscribe.addSubscribe(hookSubscribe, (mediaServerItemInUse, hookParam) -> { |
| 537 | + logger.info("[ZLM HOOK] ssrc修正后收到订阅消息: " + hookParam); | ||
| 547 | dynamicTask.stop(timeOutTaskKey); | 538 | dynamicTask.stop(timeOutTaskKey); |
| 548 | // hook响应 | 539 | // hook响应 |
| 549 | - playService.onPublishHandlerForPlay(mediaServerItemInUse, response, platform.getServerGBId(), channelId); | ||
| 550 | - hookEvent.response(mediaServerItemInUse, response); | 540 | + playService.onPublishHandlerForPlay(mediaServerItemInUse, hookParam, platform.getServerGBId(), channelId); |
| 541 | + hookEvent.response(mediaServerItemInUse, hookParam); | ||
| 551 | }); | 542 | }); |
| 552 | } | 543 | } |
| 553 | // 关闭rtp server | 544 | // 关闭rtp server |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -293,12 +293,12 @@ public class PlayServiceImpl implements IPlayService { | @@ -293,12 +293,12 @@ public class PlayServiceImpl implements IPlayService { | ||
| 293 | 293 | ||
| 294 | // 查看设备是否已经在推流 | 294 | // 查看设备是否已经在推流 |
| 295 | try { | 295 | try { |
| 296 | - cmder.talkStreamCmd(mediaServerItem, sendRtpItem, device, channelId, callId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> { | ||
| 297 | - logger.info("[语音对讲] 流已生成, 开始推流: " + response.toJSONString()); | 296 | + cmder.talkStreamCmd(mediaServerItem, sendRtpItem, device, channelId, callId, (mediaServerItemInuse, hookParam) -> { |
| 297 | + logger.info("[语音对讲] 流已生成, 开始推流: " + hookParam); | ||
| 298 | dynamicTask.stop(timeOutTaskKey); | 298 | dynamicTask.stop(timeOutTaskKey); |
| 299 | // TODO 暂不做处理 | 299 | // TODO 暂不做处理 |
| 300 | - }, (MediaServerItem mediaServerItemInuse, JSONObject json) -> { | ||
| 301 | - logger.info("[语音对讲] 设备开始推流: " + json.toJSONString()); | 300 | + }, (mediaServerItemInuse, hookParam) -> { |
| 301 | + logger.info("[语音对讲] 设备开始推流: " + hookParam); | ||
| 302 | dynamicTask.stop(timeOutTaskKey); | 302 | dynamicTask.stop(timeOutTaskKey); |
| 303 | 303 | ||
| 304 | }, (event) -> { | 304 | }, (event) -> { |
| @@ -617,10 +617,10 @@ public class PlayServiceImpl implements IPlayService { | @@ -617,10 +617,10 @@ public class PlayServiceImpl implements IPlayService { | ||
| 617 | } | 617 | } |
| 618 | 618 | ||
| 619 | @Override | 619 | @Override |
| 620 | - public StreamInfo onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId) { | ||
| 621 | - StreamInfo streamInfo = onPublishHandler(mediaServerItem, response, deviceId, channelId); | 620 | + public StreamInfo onPublishHandlerForPlay(MediaServerItem mediaServerItem, HookParam hookParam, String deviceId, String channelId) { |
| 621 | + OnStreamChangedHookParam streamChangedHookParam = (OnStreamChangedHookParam) hookParam; | ||
| 622 | + StreamInfo streamInfo = onPublishHandler(mediaServerItem, streamChangedHookParam, deviceId, channelId); | ||
| 622 | Device device = redisCatchStorage.getDevice(deviceId); | 623 | Device device = redisCatchStorage.getDevice(deviceId); |
| 623 | - OnStreamChangedHookParam streamChangedHookParam = (OnStreamChangedHookParam)hookParam; | ||
| 624 | if (streamInfo != null) { | 624 | if (streamInfo != null) { |
| 625 | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); | 625 | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); |
| 626 | if (deviceChannel != null) { | 626 | if (deviceChannel != null) { |
| @@ -1571,7 +1571,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -1571,7 +1571,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 1571 | } | 1571 | } |
| 1572 | } | 1572 | } |
| 1573 | 1573 | ||
| 1574 | - talk(mediaServerItem, device, channelId, stream, (MediaServerItem mediaServerItem1, JSONObject response) -> { | 1574 | + talk(mediaServerItem, device, channelId, stream, (mediaServerItem1, hookParam) -> { |
| 1575 | logger.info("[语音对讲] 收到设备发来的流"); | 1575 | logger.info("[语音对讲] 收到设备发来的流"); |
| 1576 | }, eventResult -> { | 1576 | }, eventResult -> { |
| 1577 | logger.warn("[语音对讲] 失败,{}/{}, 错误码 {} {}", device.getDeviceId(), channelId, eventResult.statusCode, eventResult.msg); | 1577 | logger.warn("[语音对讲] 失败,{}/{}, 错误码 {} {}", device.getDeviceId(), channelId, eventResult.statusCode, eventResult.msg); |