支持通用通道播放

结构优化
648540858 2024-01-17 18:05:39 +08:00
parent 20be213faf
commit f38d561e60
9 changed files with 99 additions and 16 deletions

View File

@ -57,20 +57,20 @@ public class GB28181ResourceServiceImpl implements IResourceService {
assert callback != null;
if (!CommonGbChannelType.GB28181.equals(commonGbChannel.getType())) {
logger.warn("[资源类-国标28181] 收到播放通道: {} 时发现类型不为28181", commonGbChannel.getCommonGbId());
callback.call(commonGbChannel, null, ErrorCode.ERROR500.getCode(), ErrorCode.ERROR500.getMsg(), null);
callback.call(commonGbChannel, null, ErrorCode.ERROR100.getCode(), "数据关系错误", null);
return;
}
DeviceChannel channel = deviceChannelMapper.getChannelByCommonChannelId(commonGbChannel.getCommonGbId());
if (channel == null) {
logger.warn("[资源类-国标28181] 收到播放通道: {} 时未找到国标通道", commonGbChannel.getCommonGbId());
callback.call(commonGbChannel, null, ErrorCode.ERROR500.getCode(), ErrorCode.ERROR500.getMsg(), null);
callback.call(commonGbChannel, null, ErrorCode.ERROR100.getCode(), "未找到通道", null);
return;
}
Device device = deviceMapper.getDeviceByDeviceId(channel.getDeviceId());
if (device == null) {
logger.warn("[资源类-国标28181] 收到播放通道: {} 时未找到通道 {} 所属的国标设备",
commonGbChannel.getCommonGbId(), channel.getDeviceId());
callback.call(commonGbChannel, null, ErrorCode.ERROR500.getCode(), ErrorCode.ERROR500.getMsg(), null);
callback.call(commonGbChannel, null, ErrorCode.ERROR100.getCode(), "未找到设备", null);
return;
}
MediaServerItem mediaServerItem = playService.getNewMediaServerItem(device);
@ -78,7 +78,7 @@ public class GB28181ResourceServiceImpl implements IResourceService {
if (code == InviteErrorCode.SUCCESS.getCode()) {
if (data != null) {
StreamInfo streamInfo = (StreamInfo)data;
callback.call(commonGbChannel, mediaServerItem, ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
callback.call(commonGbChannel, mediaServerItem, ErrorCode.ERROR100.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
}
}else {
callback.call(commonGbChannel, null, code, msg, null);
@ -91,7 +91,7 @@ public class GB28181ResourceServiceImpl implements IResourceService {
if (!CommonGbChannelType.GB28181.equals(commonGbChannel.getType())) {
logger.warn("[资源类-国标28181] 收到停止播放通道: {} 时发现类型不为28181", commonGbChannel.getCommonGbId());
if (callback != null) {
callback.call(commonGbChannel,null, ErrorCode.ERROR500.getCode(), ErrorCode.ERROR500.getMsg(), null);
callback.call(commonGbChannel,null, ErrorCode.ERROR100.getCode(), "数据关系错误", null);
}
return;
}
@ -99,7 +99,7 @@ public class GB28181ResourceServiceImpl implements IResourceService {
if (channel == null) {
logger.warn("[资源类-国标28181] 收到停止播放通道: {} 时未找到国标通道", commonGbChannel.getCommonGbId());
if (callback != null) {
callback.call(commonGbChannel, null, ErrorCode.ERROR500.getCode(), ErrorCode.ERROR500.getMsg(), null);
callback.call(commonGbChannel, null, ErrorCode.ERROR100.getCode(), "未找到通道", null);
}
return;
}

View File

@ -80,7 +80,7 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
List<CommonGbChannel> commonGbChannelList = platformChannelService.queryChannelList(parentPlatform);
try {
if (commonGbChannelList.size() > 0) {
if (!commonGbChannelList.isEmpty()) {
cmderFroPlatform.catalogQuery(commonGbChannelList, parentPlatform, sn, fromHeader.getTag());
}else {
// 回复无通道

View File

@ -23,6 +23,7 @@ public interface ICommonGbChannelService {
int add(CommonGbChannel channel);
int update(CommonGbChannel channel);
int updateForForm(CommonGbChannel channel);
PageInfo<CommonGbChannel> getChannelsInRegion(String regionDeviceId, String query, int page, int count);

View File

@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.common.BatchLimit;
import com.genersoft.iot.vmp.common.CommonGbChannel;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEventType;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
@ -10,6 +11,7 @@ import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.service.bean.*;
import com.genersoft.iot.vmp.storager.dao.CommonChannelMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion;
import com.github.pagehelper.PageHelper;
@ -115,6 +117,25 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
return result;
}
@Override
public int updateForForm(CommonGbChannel channel) {
assert channel.getCommonGbId() >= 0;
assert channel.getCommonGbDeviceID() != null;
assert channel.getCommonGbName() != null;
channel.setUpdateTime(DateUtil.getNow());
CommonGbChannel commonGbChannel = commonGbChannelMapper.queryByDeviceID(channel.getCommonGbDeviceID());
if (commonGbChannel != null && commonGbChannel.getCommonGbId() != channel.getCommonGbId()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "失败: 编号 " + channel.getCommonGbDeviceID() + " 已存在");
}
int result = commonGbChannelMapper.updateForForm(channel);
if (result == 0) {
return 0;
}
sendCatalogEvent(channel, CatalogEventType.UPDATE);
return result;
}
@Override
public void deleteGbChannelsFromList(List<DeviceChannel> channelList) {
if (channelList.isEmpty()) {
@ -235,14 +256,24 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
public void startPlay(CommonGbChannel channel, IResourcePlayCallback callback) {
IResourceService resourceService = resourceServiceMap.get(channel.getType());
assert resourceService != null;
resourceService.startPlay(channel, callback);
resourceService.startPlay(channel, ((commonGbChannel, mediaServerItem, code, message, streamInfo) -> {
if (code == InviteErrorCode.SUCCESS.getCode()) {
// 记录到数据库
}
callback.call(commonGbChannel, mediaServerItem, code, message, streamInfo);
}));
}
@Override
public void stopPlay(CommonGbChannel channel, IResourcePlayCallback callback) {
IResourceService resourceService = resourceServiceMap.get(channel.getType());
assert resourceService != null;
resourceService.stopPlay(channel,callback);
resourceService.stopPlay(channel,((commonGbChannel, mediaServerItem, code, message, streamInfo) -> {
if (code == InviteErrorCode.SUCCESS.getCode()) {
// 记录到数据库
}
callback.call(commonGbChannel, mediaServerItem, code, message, streamInfo);
}));
}
@Override
@ -257,9 +288,11 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
toIndex = commonGbChannels.size();
}
commonGbChannelMapper.batchAdd(commonGbChannels.subList(i, toIndex));
System.out.println(11);
}
}else {
commonGbChannelMapper.batchAdd(commonGbChannels);
System.out.println(11);
}
}

View File

@ -292,11 +292,15 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
@Override
public void batchAddChannel(List<DeviceChannel> channels) {
List<CommonGbChannel> commonGbChannelList = new ArrayList<>();
Map<String, CommonGbChannel> channelMap = new HashMap<>();
channels.stream().forEach(channel->{
commonGbChannelList.add(CommonGbChannel.getInstance(null, channel));
channelMap.put(channel.getChannelId(),CommonGbChannel.getInstance(null, channel));
});
commonGbChannelService.batchAdd(commonGbChannelList);
commonGbChannelService.batchAdd(new ArrayList<>(channelMap.values()));
for (DeviceChannel channel : channels) {
channel.setCommonGbChannelId(channelMap.get(channel.getChannelId()).getCommonGbId());
}
channelMapper.batchAdd(channels);
for (DeviceChannel channel : channels) {
if (channel.getParentId() != null) {

View File

@ -146,7 +146,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
}
}
return null;
return result;
}
@Override

View File

@ -194,11 +194,54 @@ public interface CommonChannelMapper {
" <if test='commonGbBusinessGroupID != null' > ,common_gb_business_group_id= #{ commonGbBusinessGroupID} </if>" +
" <if test='commonGbDownloadSpeed != null' > ,common_gb_download_speed= #{ commonGbDownloadSpeed} </if>" +
" <if test='commonGbSVCTimeSupportMode != null' > ,common_gb_svc_time_support_mode= #{ commonGbSVCTimeSupportMode} </if>" +
" <if test='commonGbSVCSpaceSupportMode != null' > ,common_gb_svc_space_support_mode= #{commonGbSVCSpaceSupportMode} </if>" +
" <if test='type != null' > ,type= #{ type} </if>" +
" WHERE common_gb_id=#{commonGbId}" +
"</script>")
int update(CommonGbChannel channel);
@Update(value = "<script>" +
"UPDATE wvp_common_channel SET " +
"update_time= #{ updateTime}" +
", common_gb_device_id= #{ commonGbDeviceID}" +
", common_gb_name= #{ commonGbName} " +
", common_gb_manufacturer= #{ commonGbManufacturer} " +
", common_gb_model= #{ commonGbModel} " +
", common_gb_owner= #{ commonGbOwner} " +
", common_gb_civilCode= #{ commonGbCivilCode} " +
", common_gb_block= #{ commonGbBlock} " +
", common_gb_address= #{ commonGbAddress} " +
", common_gb_parental= #{ commonGbParental} " +
", common_gb_parent_id= #{ commonGbParentID} " +
", common_gb_safety_way= #{ commonGbSafetyWay} " +
", common_gb_register_way= #{ commonGbRegisterWay} " +
", common_gb_cert_num= #{ commonGbCertNum} " +
", common_gb_certifiable= #{ commonGbCertifiable} " +
", common_gb_err_code= #{ commonGbErrCode} " +
", common_gb_end_time= #{ commonGbEndTime} " +
", common_gb_secrecy= #{ commonGbSecrecy} " +
", common_gb_ip_address= #{ commonGbIPAddress} " +
", common_gb_port= #{ commonGbPort} " +
", common_gb_password= #{ commonGbPassword} " +
", common_gb_status= #{ commonGbStatus} " +
", common_gb_longitude= #{ commonGbLongitude} " +
", common_gb_latitude= #{ commonGbLatitude} " +
", common_gb_ptz_type= #{ commonGbPtzType} " +
", common_gb_position_type= #{ commonGbPositionType} " +
", common_gb_room_type= #{ commonGbRoomType} " +
", common_gb_use_type= #{ commonGbUseType} " +
", common_gb_supply_light_type= #{ commonGbSupplyLightType} " +
", common_gb_direction_type= #{ commonGbDirectionType} " +
", common_gb_resolution= #{ commonGbResolution} " +
", common_gb_business_group_id= #{ commonGbBusinessGroupID} " +
", common_gb_download_speed= #{ commonGbDownloadSpeed} " +
", common_gb_svc_time_support_mode= #{ commonGbSVCTimeSupportMode} " +
", common_gb_svc_space_support_mode= #{commonGbSVCSpaceSupportMode} " +
", type= #{ type} " +
" WHERE common_gb_id=#{commonGbId}" +
" </script>")
int updateForForm(CommonGbChannel channel);
@Select("select count(1)\n" +
"from wvp_common_channel gc " +
"right join wvp_common_platform_channel pc " +
@ -565,6 +608,7 @@ public interface CommonChannelMapper {
" WHERE common_gb_id=#{item.commonGbId}" +
"</foreach>" +
"</script>"})
@Options(useGeneratedKeys=true, keyProperty="commonGbId", keyColumn="common_gb_id")
int batchUpdate(@Param("commonGbChannels") List<CommonGbChannel> commonGbChannels);

View File

@ -24,7 +24,7 @@ public interface LogMapper {
@Select(value = {"<script>" +
" SELECT * FROM wvp_log " +
" WHERE 1=1 " +
" <if test='query != null'> AND (name LIKE concat('%',#{query},'%'))</if> " +
" <if test='query != null'> AND (name LIKE concat('%',#{query},'%') or uri LIKE concat('%',#{query},'%'))</if> " +
" <if test='type != null' > AND type = #{type}</if>" +
" <if test='startTime != null' > AND create_time &gt;= #{startTime} </if>" +
" <if test='endTime != null' > AND create_time &lt;= #{endTime} </if>" +

View File

@ -57,7 +57,7 @@ public class CommonChannelController {
@PostMapping("/update")
public void update(@RequestBody CommonGbChannel commonGbChannel
){
commonGbChannelService.update(commonGbChannel);
commonGbChannelService.updateForForm(commonGbChannel);
}
/**
@ -172,7 +172,7 @@ public class CommonChannelController {
@Operation(summary = "播放通道")
@Parameter(name = "channelDeviceId", description = "通道国标编号", required = true)
@ResponseBody
@PostMapping("/play")
@GetMapping("/play")
public DeferredResult<WVPResult<StreamContent>> play(HttpServletRequest request, String channelDeviceId){
logger.info("[播放通道] channelDeviceId{} ", channelDeviceId);
assert !ObjectUtils.isEmpty(channelDeviceId);
@ -210,6 +210,7 @@ public class CommonChannelController {
streamInfo.channgeStreamIp(host);
}
wvpResult.setData(new StreamContent(streamInfo));
result.setResult(wvpResult);
}
}else {
WVPResult<StreamContent> wvpResult = new WVPResult<>();