Merge branch 'refs/heads/2.7.0' into 271-优化notify存储
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java # src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java # src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMobilePositionMapper.java
This commit is contained in:
@@ -102,4 +102,9 @@ public interface IDeviceChannelService {
|
||||
|
||||
void batchAddMobilePosition(List<MobilePosition> addMobilePositionList);
|
||||
|
||||
void online(DeviceChannel channel);
|
||||
|
||||
void offline(DeviceChannel channel);
|
||||
|
||||
void delete(DeviceChannel channel);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -247,26 +248,50 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
return channelMapper.batchOnline(channels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void online(DeviceChannel channel) {
|
||||
channelMapper.online(channel.getDeviceId(), channel.getChannelId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int channelsOffline(List<DeviceChannel> channels) {
|
||||
return channelMapper.batchOffline(channels);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void offline(DeviceChannel channel) {
|
||||
channelMapper.offline(channel.getDeviceId(), channel.getChannelId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DeviceChannel channel) {
|
||||
channelMapper.del(channel.getDeviceId(), channel.getChannelId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceChannel getOne(String deviceId, String channelId){
|
||||
return channelMapper.queryChannel(deviceId, channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchUpdateChannel(List<DeviceChannel> channels) {
|
||||
public synchronized void batchUpdateChannel(List<DeviceChannel> channels) {
|
||||
String now = DateUtil.getNow();
|
||||
for (DeviceChannel channel : channels) {
|
||||
channel.setUpdateTime(now);
|
||||
}
|
||||
channelMapper.batchUpdate(channels);
|
||||
for (DeviceChannel channel : channels) {
|
||||
if (channel.getParentId() != null) {
|
||||
channelMapper.updateChannelSubCount(channel.getDeviceId(), channel.getParentId());
|
||||
int limitCount = 1000;
|
||||
if (!channels.isEmpty()) {
|
||||
if (channels.size() > limitCount) {
|
||||
for (int i = 0; i < channels.size(); i += limitCount) {
|
||||
int toIndex = i + limitCount;
|
||||
if (i + limitCount > channels.size()) {
|
||||
toIndex = channels.size();
|
||||
}
|
||||
channelMapper.batchUpdate(channels.subList(i, toIndex));
|
||||
}
|
||||
}else {
|
||||
channelMapper.batchUpdate(channels);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,15 +380,45 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void batchUpdateChannelGPS(List<DeviceChannel> channelList) {
|
||||
channelMapper.batchUpdatePosition(channelList);
|
||||
for (DeviceChannel deviceChannel : channelList) {
|
||||
deviceChannel.setUpdateTime(DateUtil.getNow());
|
||||
if (deviceChannel.getGpsTime() == null) {
|
||||
deviceChannel.setGpsTime(DateUtil.getNow());
|
||||
}
|
||||
}
|
||||
int count = 1000;
|
||||
if (channelList.size() > count) {
|
||||
for (int i = 0; i < channelList.size(); i+=count) {
|
||||
int toIndex = i+count;
|
||||
if ( i + count > channelList.size()) {
|
||||
toIndex = channelList.size();
|
||||
}
|
||||
List<DeviceChannel> channels = channelList.subList(i, toIndex);
|
||||
channelMapper.batchUpdatePosition(channels);
|
||||
}
|
||||
}else {
|
||||
channelMapper.batchUpdatePosition(channelList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void batchAddMobilePosition(List<MobilePosition> mobilePositions) {
|
||||
deviceMobilePositionMapper.batchInsert(mobilePositions);
|
||||
// int count = 500;
|
||||
// if (mobilePositions.size() > count) {
|
||||
// for (int i = 0; i < mobilePositions.size(); i+=count) {
|
||||
// int toIndex = i+count;
|
||||
// if ( i + count > mobilePositions.size()) {
|
||||
// toIndex = mobilePositions.size();
|
||||
// }
|
||||
// List<MobilePosition> mobilePositionsSub = mobilePositions.subList(i, toIndex);
|
||||
// deviceMobilePositionMapper.batchadd(mobilePositionsSub);
|
||||
// }
|
||||
// }else {
|
||||
// deviceMobilePositionMapper.batchadd(mobilePositions);
|
||||
// }
|
||||
deviceMobilePositionMapper.batchadd(mobilePositions);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -149,7 +149,6 @@ public class PlayServiceImpl implements IPlayService {
|
||||
logger.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", deviceId, channelId);
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm");
|
||||
}
|
||||
|
||||
Device device = redisCatchStorage.getDevice(deviceId);
|
||||
if (device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE") && !mediaServerItem.isRtpEnable()) {
|
||||
logger.warn("[点播] 单端口收流时不支持TCP主动方式收流 deviceId: {},channelId:{}", deviceId, channelId);
|
||||
@@ -163,6 +162,8 @@ public class PlayServiceImpl implements IPlayService {
|
||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId);
|
||||
if (inviteInfo != null ) {
|
||||
if (inviteInfo.getStreamInfo() == null) {
|
||||
// 释放生成的ssrc,使用上一次申请的
|
||||
ssrcFactory.releaseSsrc(mediaServerItem.getId(), ssrc);
|
||||
// 点播发起了但是尚未成功, 仅注册回调等待结果即可
|
||||
inviteStreamService.once(InviteSessionType.PLAY, deviceId, channelId, null, callback);
|
||||
logger.info("[点播开始] 已经请求中,等待结果, deviceId: {}, channelId: {}", device.getDeviceId(), channelId);
|
||||
|
||||
@@ -170,15 +170,19 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
callback.run(ErrorCode.ERROR100.getCode(), "保存失败", null);
|
||||
return;
|
||||
}
|
||||
HookSubscribeForStreamChange hookSubscribeForStreamChange = HookSubscribeFactory.on_stream_changed(param.getApp(), param.getStream(), true, "rtsp", mediaInfo.getId());
|
||||
hookSubscribe.addSubscribe(hookSubscribeForStreamChange, (mediaServerItem, response) -> {
|
||||
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
|
||||
mediaInfo, param.getApp(), param.getStream(), null, null);
|
||||
callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
|
||||
});
|
||||
|
||||
if (param.isEnable()) {
|
||||
String talkKey = UUID.randomUUID().toString();
|
||||
String delayTalkKey = UUID.randomUUID().toString();
|
||||
HookSubscribeForStreamChange hookSubscribeForStreamChange = HookSubscribeFactory.on_stream_changed(param.getApp(), param.getStream(), true, "rtsp", mediaInfo.getId());
|
||||
hookSubscribe.addSubscribe(hookSubscribeForStreamChange, (mediaServerItem, response) -> {
|
||||
dynamicTask.stop(delayTalkKey);
|
||||
hookSubscribe.removeSubscribe(hookSubscribeForStreamChange);
|
||||
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
|
||||
mediaInfo, param.getApp(), param.getStream(), null, null);
|
||||
callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
|
||||
});
|
||||
|
||||
dynamicTask.startDelay(delayTalkKey, ()->{
|
||||
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false);
|
||||
if (streamInfo != null) {
|
||||
@@ -324,6 +328,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
zlmresTfulUtils.closeStreams(mediaServerItem, param.getApp(), param.getStream());
|
||||
}
|
||||
if ("ffmpeg".equalsIgnoreCase(param.getType())){
|
||||
if (param.getTimeoutMs() == 0) {
|
||||
param.setTimeoutMs(15);
|
||||
}
|
||||
result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrcUrl().trim(), param.getDstUrl(),
|
||||
param.getTimeoutMs() + "", param.isEnableAudio(), param.isEnableMp4(),
|
||||
param.getFfmpegCmdKey());
|
||||
@@ -379,6 +386,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
gbStreamMapper.del(app, stream);
|
||||
videoManagerStorager.deleteStreamProxy(app, stream);
|
||||
redisCatchStorage.removeStream(streamProxyItem.getMediaServerId(), "PULL", app, stream);
|
||||
redisCatchStorage.removeStream(streamProxyItem.getMediaServerId(), "PUSH", app, stream);
|
||||
JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyItem);
|
||||
if (jsonObject != null && jsonObject.getInteger("code") == 0) {
|
||||
logger.info("[移除代理]: 代理: {}/{}, 从zlm移除成功", app, stream);
|
||||
|
||||
Reference in New Issue
Block a user