From 4c0cf1c83f802f8408d824085b88c1cdedfc7237 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Mon, 18 Sep 2023 15:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E9=80=9A=E9=81=93=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/device/DeviceProxyService.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java index e795d5c..d7ce62a 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java @@ -60,7 +60,7 @@ public class DeviceProxyService { public TaskProcessor playbackTask(){ return (SIPRequest request,String callId,String fromUrl, String toUrl, MockingDevice device, String key, long time) -> { - Optional.ofNullable(callbackTask.get(device.getDeviceCode())).ifPresent(task->{ + Optional.ofNullable(callbackTask.get(callId)).ifPresent(task->{ task.getWatchdog().destroyProcess(); }); Flow.Subscriber subscriber = byeSubscriber(key, device, callbackTask); @@ -72,18 +72,8 @@ public class DeviceProxyService { public TaskProcessor downloadTask(){ return (SIPRequest request,String callId,String fromUrl, String toUrl, MockingDevice device, String key, long time)->{ - Optional.ofNullable(downloadTask.get(device.getDeviceCode())).ifPresent(task->{ + Optional.ofNullable(downloadTask.get(callId)).ifPresent(task->{ task.getWatchdog().destroyProcess(); - log.info("{} 推流结束, 发送媒体通知", key); - MediaStatusRequestDTO mediaStatusRequestDTO = MediaStatusRequestDTO.builder() - .sn(String.valueOf((int) ((Math.random() * 9 + 1) * 100000))) - .deviceId(device.getGbChannelId()) - .build(); - - String tag = request.getFromHeader().getTag(); - CallIdHeader requestCallId = request.getCallId(); - sender.sendRequest(((provider, ip, port) -> SipRequestBuilder.createMessageRequest(device, - ip, port, 1, XmlUtils.toXml(mediaStatusRequestDTO), SipUtil.generateViaTag(), tag, requestCallId))); }); Flow.Subscriber subscriber = byeSubscriber(key, device, downloadTask); subscribe.getByeSubscribe().addSubscribe(key, subscriber); @@ -157,6 +147,9 @@ public class DeviceProxyService { public ExecuteResultHandler mediaStatus(SIPRequest request, MockingDevice device,String key){ return new ExecuteResultHandler() { private void mediaStatus(){ + CallIdHeader requestCallId = request.getCallId(); + String callId = requestCallId.getCallId(); + callbackTask.remove(callId); log.info("{} 推流结束, 发送媒体通知", key); MediaStatusRequestDTO mediaStatusRequestDTO = MediaStatusRequestDTO.builder() .sn(String.valueOf((int) ((Math.random() * 9 + 1) * 100000))) @@ -164,7 +157,6 @@ public class DeviceProxyService { .build(); String tag = request.getFromHeader().getTag(); - CallIdHeader requestCallId = request.getCallId(); sender.sendRequest(((provider, ip, port) -> SipRequestBuilder.createMessageRequest(device, ip, port, 1, XmlUtils.toXml(mediaStatusRequestDTO), SipUtil.generateViaTag(), tag, requestCallId))); }