From 5364db2982fb3dfff22659d535344d3df82e838a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期日, 03 七月 2022 22:27:04 +0800 Subject: [PATCH] 优化对讲逻辑 --- src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 29 +++++++++++++++++++++-------- 1 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 6422cfc..1a8c5de 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; +import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; @@ -74,6 +75,9 @@ @Autowired private IRedisCatchStorage redisCatchStorage; + + @Autowired + private ZLMRTPServerFactory zlmrtpServerFactory; @Autowired private DeferredResultHolder resultHolder; @@ -138,7 +142,7 @@ result.onCompletion(()->{ // 鐐规挱缁撴潫鏃惰皟鐢ㄦ埅鍥炬帴鍙� // TODO 搴旇鍦ㄤ笂娴佹椂璋冪敤鏇村ソ锛岀粨鏉熶篃鍙兘鏄敊璇粨鏉� - String path = "static/static/snap/"; + String path = "snap"; String fileName = deviceId + "_" + channelId + ".jpg"; ResponseEntity responseEntity = (ResponseEntity)result.getResult(); if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) { @@ -190,10 +194,7 @@ redisCatchStorage.stopPlay(streamInfo); storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); streamInfo = null; - } - - } if (streamInfo == null) { String streamId = null; @@ -681,9 +682,17 @@ if (audioBroadcastManager.exit(device.getDeviceId(), channelId)) { SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(device.getDeviceId(), channelId, null, null); if (sendRtpItem != null && sendRtpItem.isOnlyAudio()) { - logger.warn("璇煶骞挎挱宸茬粡寮�鍚細 {}", channelId); - event.call("璇煶骞挎挱宸茬粡寮�鍚�"); - return; + // 鏌ヨ娴佹槸鍚﹀瓨鍦紝涓嶅瓨鍦ㄥ垯璁や负鏄紓甯哥姸鎬� + MediaServerItem mediaServerItem = mediaServerService.getOne(sendRtpItem.getMediaServerId()); + Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, sendRtpItem.getApp(), sendRtpItem.getStreamId()); + if (streamReady) { + logger.warn("璇煶骞挎挱宸茬粡寮�鍚細 {}", channelId); + event.call("璇煶骞挎挱宸茬粡寮�鍚�"); + return; + }else { + audioBroadcastManager.del(deviceChannel.getDeviceId(),channelId); + redisCatchStorage.deleteSendRTPServer(device.getDeviceId(), channelId, sendRtpItem.getCallId(), sendRtpItem.getStreamId()); + } } } @@ -704,7 +713,7 @@ public void stopAudioBroadcast(String deviceId, String channelId){ AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId); if (audioBroadcastCatch != null) { - audioBroadcastManager.del(deviceId, audioBroadcastCatch.getChannelId()); + try { SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null); if (sendRtpItem != null) { @@ -715,10 +724,14 @@ param.put("app", sendRtpItem.getApp()); param.put("stream", sendRtpItem.getStreamId()); zlmresTfulUtils.stopSendRtp(mediaInfo, param); + // 绔嬪埢缁撴潫璁惧鐨勬帹娴侊紝绛夊緟鑷缁撴潫澶參 + zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId()); } if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) { cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getRequest(), null); } + audioBroadcastManager.del(deviceId, channelId); + } catch (SipException e) { throw new RuntimeException(e); } catch (ParseException e) { -- Gitblit v1.8.0