设备离线清空语音对讲通道
parent
49e937c396
commit
16f3b0553d
|
@ -83,4 +83,19 @@ public class AudioBroadcastManager {
|
||||||
|
|
||||||
return audioBroadcastCatch;
|
return audioBroadcastCatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<AudioBroadcastCatch> get(String deviceId) {
|
||||||
|
List<AudioBroadcastCatch> audioBroadcastCatchList= new ArrayList<>();
|
||||||
|
if (SipUtils.isFrontEnd(deviceId)) {
|
||||||
|
audioBroadcastCatchList.add(data.get(deviceId));
|
||||||
|
}else {
|
||||||
|
for (String key : data.keySet()) {
|
||||||
|
if (key.startsWith(deviceId)) {
|
||||||
|
audioBroadcastCatchList.add(data.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return audioBroadcastCatchList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,15 @@ package com.genersoft.iot.vmp.service.impl;
|
||||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
|
||||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
|
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
|
import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
|
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.service.IDeviceChannelService;
|
import com.genersoft.iot.vmp.service.IDeviceChannelService;
|
||||||
import com.genersoft.iot.vmp.service.IDeviceService;
|
import com.genersoft.iot.vmp.service.IDeviceService;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
|
@ -32,9 +35,7 @@ import javax.sip.InvalidArgumentException;
|
||||||
import javax.sip.SipException;
|
import javax.sip.SipException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,6 +90,12 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IMediaServerService mediaServerService;
|
private IMediaServerService mediaServerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AudioBroadcastManager audioBroadcastManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ZLMRESTfulUtils zlmresTfulUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void online(Device device) {
|
public void online(Device device) {
|
||||||
logger.info("[设备上线] deviceId:{}->{}:{}", device.getDeviceId(), device.getIp(), device.getPort());
|
logger.info("[设备上线] deviceId:{}->{}:{}", device.getDeviceId(), device.getIp(), device.getPort());
|
||||||
|
@ -183,6 +190,23 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
// 移除订阅
|
// 移除订阅
|
||||||
removeCatalogSubscribe(device);
|
removeCatalogSubscribe(device);
|
||||||
removeMobilePositionSubscribe(device);
|
removeMobilePositionSubscribe(device);
|
||||||
|
List<AudioBroadcastCatch> audioBroadcastCatches = audioBroadcastManager.get(deviceId);
|
||||||
|
if (audioBroadcastCatches.size() > 0) {
|
||||||
|
for (AudioBroadcastCatch audioBroadcastCatch : audioBroadcastCatches) {
|
||||||
|
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
|
||||||
|
if (sendRtpItem != null) {
|
||||||
|
redisCatchStorage.deleteSendRTPServer(deviceId, sendRtpItem.getChannelId(), null, null);
|
||||||
|
MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
|
||||||
|
Map<String, Object> param = new HashMap<>();
|
||||||
|
param.put("vhost", "__defaultVhost__");
|
||||||
|
param.put("app", sendRtpItem.getApp());
|
||||||
|
param.put("stream", sendRtpItem.getStreamId());
|
||||||
|
zlmresTfulUtils.stopSendRtp(mediaInfo, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
audioBroadcastManager.del(deviceId, audioBroadcastCatch.getChannelId());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,10 +58,7 @@ import javax.sip.header.CallIdHeader;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@SuppressWarnings(value = {"rawtypes", "unchecked"})
|
@SuppressWarnings(value = {"rawtypes", "unchecked"})
|
||||||
@Service
|
@Service
|
||||||
|
@ -1067,25 +1064,31 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopAudioBroadcast(String deviceId, String channelId) {
|
public void stopAudioBroadcast(String deviceId, String channelId) {
|
||||||
AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId);
|
List<AudioBroadcastCatch> audioBroadcastCatchList = new ArrayList<>();
|
||||||
if (audioBroadcastCatch != null) {
|
if (channelId == null) {
|
||||||
|
audioBroadcastCatchList.addAll(audioBroadcastManager.get(deviceId));
|
||||||
|
}else {
|
||||||
|
audioBroadcastCatchList.add(audioBroadcastManager.get(deviceId, channelId));
|
||||||
|
}
|
||||||
|
if (audioBroadcastCatchList.size() > 0) {
|
||||||
|
for (AudioBroadcastCatch audioBroadcastCatch : audioBroadcastCatchList) {
|
||||||
|
Device device = deviceService.getDevice(deviceId);
|
||||||
|
if (device == null || audioBroadcastCatch == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
|
||||||
|
if (sendRtpItem != null) {
|
||||||
|
redisCatchStorage.deleteSendRTPServer(deviceId, sendRtpItem.getChannelId(), null, null);
|
||||||
|
MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
|
||||||
|
Map<String, Object> param = new HashMap<>();
|
||||||
|
param.put("vhost", "__defaultVhost__");
|
||||||
|
param.put("app", sendRtpItem.getApp());
|
||||||
|
param.put("stream", sendRtpItem.getStreamId());
|
||||||
|
zlmresTfulUtils.stopSendRtp(mediaInfo, param);
|
||||||
|
}
|
||||||
|
|
||||||
Device device = deviceService.getDevice(deviceId);
|
audioBroadcastManager.del(deviceId, channelId);
|
||||||
if (device == null) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
|
|
||||||
if (sendRtpItem != null) {
|
|
||||||
redisCatchStorage.deleteSendRTPServer(deviceId, sendRtpItem.getChannelId(), null, null);
|
|
||||||
MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
|
|
||||||
Map<String, Object> param = new HashMap<>();
|
|
||||||
param.put("vhost", "__defaultVhost__");
|
|
||||||
param.put("app", sendRtpItem.getApp());
|
|
||||||
param.put("stream", sendRtpItem.getStreamId());
|
|
||||||
zlmresTfulUtils.stopSendRtp(mediaInfo, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
audioBroadcastManager.del(deviceId, channelId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue