临时提交

This commit is contained in:
648540858
2024-09-09 00:07:00 +08:00
parent 3fafe83e88
commit 489fbe31a5
21 changed files with 279 additions and 338 deletions

View File

@@ -23,6 +23,7 @@ import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.service.ISendRtpServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
@@ -83,10 +84,7 @@ public class DeviceServiceImpl implements IDeviceService {
private DeviceChannelMapper deviceChannelMapper;
@Autowired
DataSourceTransactionManager dataSourceTransactionManager;
@Autowired
TransactionDefinition transactionDefinition;
private ISendRtpServerService sendRtpServerService;
@Autowired
private UserSetting userSetting;
@@ -239,9 +237,9 @@ public class DeviceServiceImpl implements IDeviceService {
if (audioBroadcastCatches.size() > 0) {
for (AudioBroadcastCatch audioBroadcastCatch : audioBroadcastCatches) {
SendRtpInfo sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
SendRtpInfo sendRtpItem = sendRtpServerService.queryByChannelId(audioBroadcastCatch.getChannelId());
if (sendRtpItem != null) {
redisCatchStorage.deleteSendRTPServer(deviceId, sendRtpItem.getChannelId(), null, null);
sendRtpServerService.delete(sendRtpItem);
MediaServer mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
mediaServerService.stopSendRtp(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStream(), null);
}

View File

@@ -25,6 +25,7 @@ import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
import com.genersoft.iot.vmp.media.event.mediaServer.MediaSendRtpStoppedEvent;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.service.ISendRtpServerService;
import com.genersoft.iot.vmp.service.bean.*;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
@@ -101,28 +102,29 @@ public class PlatformServiceImpl implements IPlatformService {
@Autowired
private IGbChannelService channelService;
@Autowired
private ISendRtpServerService sendRtpServerService;
/**
* 流离开的处理
*/
@Async("taskExecutor")
@EventListener
public void onApplicationEvent(MediaDepartureEvent event) {
List<SendRtpInfo> sendRtpItems = redisCatchStorage.querySendRTPServerByStream(event.getStream());
if (!sendRtpItems.isEmpty()) {
for (SendRtpInfo sendRtpItem : sendRtpItems) {
if (sendRtpItem != null && sendRtpItem.getApp().equals(event.getApp())) {
String platformId = sendRtpItem.getPlatformId();
Platform platform = platformMapper.getParentPlatByServerGBId(platformId);
CommonGBChannel channel = channelService.getOne(sendRtpItem.getChannelId());
try {
if (platform != null && channel != null) {
commanderForPlatform.streamByeCmd(platform, sendRtpItem, channel);
redisCatchStorage.deleteSendRTPServer(platformId, channel.getGbDeviceId(),
sendRtpItem.getCallId(), sendRtpItem.getStream());
}
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 发送BYE: {}", e.getMessage());
SendRtpInfo sendRtpItems = sendRtpServerService.queryByStream(event.getStream());
if (sendRtpItems != null) {
if (sendRtpItem != null && sendRtpItem.getApp().equals(event.getApp())) {
String platformId = sendRtpItem.getPlatformId();
Platform platform = platformMapper.getParentPlatByServerGBId(platformId);
CommonGBChannel channel = channelService.getOne(sendRtpItem.getChannelId());
try {
if (platform != null && channel != null) {
commanderForPlatform.streamByeCmd(platform, sendRtpItem, channel);
redisCatchStorage.deleteSendRTPServer(platformId, channel.getGbDeviceId(),
sendRtpItem.getCallId(), sendRtpItem.getStream());
}
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 发送BYE: {}", e.getMessage());
}
}
}