From 046e7802f319dc8d5f1a428f0cea0d22ece14a0e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 9 Jul 2024 17:55:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/dao/DeviceChannelMapper.java | 346 ++++++++++++------ .../vmp/gb28181/session/CatalogDataCatch.java | 2 +- .../request/impl/ByeRequestProcessor.java | 5 +- .../cmd/CatalogResponseMessageHandler.java | 2 +- .../vmp/service/IDeviceChannelService.java | 12 +- .../impl/DeviceChannelServiceImpl.java | 24 +- .../vmp/service/impl/DeviceServiceImpl.java | 10 +- .../service/impl/InviteStreamServiceImpl.java | 6 +- .../vmp/service/impl/MediaServiceImpl.java | 10 +- .../iot/vmp/service/impl/PlayServiceImpl.java | 8 +- .../vmp/storager/IVideoManagerStorage.java | 15 - .../impl/VideoManagerStorageImpl.java | 10 - .../vmanager/gb28181/play/PlayController.java | 7 +- .../vmp/web/gb28181/ApiStreamController.java | 8 +- 14 files changed, 295 insertions(+), 170 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index 241c96f2..c2e02a14 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -32,87 +32,138 @@ public interface DeviceChannelMapper { @Update(value = {" "}) int update(DeviceChannel channel); + @Update(value = {" "}) + int updateCustomInfo(DeviceChannel channel); + @Select(value = {" "}) List queryChannels(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List channelIds); + + @Select("select\n" + + " id,\n" + + " device_db_id,\n" + + " create_time,\n" + + " update_time,\n" + + " sub_count,\n" + + " stream_id,\n" + + " has_audio,\n" + + " gps_time,\n" + + " stream_identification,\n" + + " coalesce(gb_device_id, device_id) as device_id,\n" + + " coalesce(gb_name, name) as name,\n" + + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + + " coalesce(gb_model, model) as model,\n" + + " coalesce(gb_owner, owner) as owner,\n" + + " coalesce(gb_civil_code, civil_code) as civil_code,\n" + + " coalesce(gb_block, block) as block,\n" + + " coalesce(gb_address, address) as address,\n" + + " coalesce(gb_parental, parental) as parental,\n" + + " coalesce(gb_parent_id, parent_id) as parent_id,\n" + + " coalesce(gb_safety_way, safety_way) as safety_way,\n" + + " coalesce(gb_register_way, register_way) as register_way,\n" + + " coalesce(gb_cert_num, cert_num) as cert_num,\n" + + " coalesce(gb_certifiable, certifiable) as certifiable,\n" + + " coalesce(gb_err_code, err_code) as err_code,\n" + + " coalesce(gb_end_time, end_time) as end_time,\n" + + " coalesce(gb_secrecy, secrecy) as secrecy,\n" + + " coalesce(gb_ip_address, ip_address) as ip_address,\n" + + " coalesce(gb_port, port) as port,\n" + + " coalesce(gb_password, password) as password,\n" + + " coalesce(gb_status, status) as status,\n" + + " coalesce(gb_longitude, longitude) as longitude,\n" + + " coalesce(gb_latitude, latitude) as latitude,\n" + + " coalesce(gb_ptz_type, ptz_type) as ptz_type,\n" + + " coalesce(gb_position_type, position_type) as position_type,\n" + + " coalesce(gb_room_type, room_type) as room_type,\n" + + " coalesce(gb_use_type, use_type) as use_type,\n" + + " coalesce(gb_supply_light_type, supply_light_type) as supply_light_type,\n" + + " coalesce(gb_direction_type, direction_type) as direction_type,\n" + + " coalesce(gb_resolution, resolution) as resolution,\n" + + " coalesce(gb_business_group_id, business_group_id) as business_group_id,\n" + + " coalesce(gb_download_speed, download_speed) as download_speed,\n" + + " coalesce(gb_svc_space_support_mod, svc_space_support_mod) as svc_space_support_mod,\n" + + " coalesce(gb_svc_time_support_mode svc_time_support_mode) as svc_time_support_mode\n" + + "from wvp_device_channel\n" + + "where device_db_id = #{deviceDbId}") + List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); + + + @Select(value = {" "}) List queryChannelsWithDeviceInfo(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List channelIds); - - @Select(value = {" "}) - List queryChannelsByDeviceIdWithStartAndLimit(@Param("deviceId") String deviceId, @Param("channelIds") List channelIds, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("start") int start, @Param("limit") int limit); - - @Select("SELECT * FROM wvp_device_channel WHERE device_id=#{deviceId} AND channel_id=#{channelId}") + @Select("SELECT " + + " dc.device_db_id,\n" + + " dc.create_time,\n" + + " dc.update_time,\n" + + " dc.sub_count,\n" + + " dc.stream_id,\n" + + " dc.has_audio,\n" + + " dc.gps_time,\n" + + " dc.stream_identification,\n" + + " coalesce(dc.gb_device_id, dc.device_id) as device_id,\n" + + " coalesce(dc.gb_name, dc.name) as name,\n" + + " coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacturer,\n" + + " coalesce(dc.gb_model, dc.model) as model,\n" + + " coalesce(dc.gb_owner, dc.owner) as owner,\n" + + " coalesce(dc.gb_civil_code, dc.civil_code) as civil_code,\n" + + " coalesce(dc.gb_block, dc.block) as block,\n" + + " coalesce(dc.gb_address, dc.address) as address,\n" + + " coalesce(dc.gb_parental, dc.parental) as parental,\n" + + " coalesce(dc.gb_parent_id, dc.parent_id) as parent_id,\n" + + " coalesce(dc.gb_safety_way, dc.safety_way) as safety_way,\n" + + " coalesce(dc.gb_register_way, dc.register_way) as register_way,\n" + + " coalesce(dc.gb_cert_num, dc.cert_num) as cert_num,\n" + + " coalesce(dc.gb_certifiable, dc.certifiable) as certifiable,\n" + + " coalesce(dc.gb_err_code, dc.err_code) as err_code,\n" + + " coalesce(dc.gb_end_time, dc.end_time) as end_time,\n" + + " coalesce(dc.gb_secrecy, dc.secrecy) as secrecy,\n" + + " coalesce(dc.gb_ip_address, dc.ip_address) as ip_address,\n" + + " coalesce(dc.gb_port, dc.port) as port,\n" + + " coalesce(dc.gb_password, dc.password) as password,\n" + + " coalesce(dc.gb_status, dc.status) as status,\n" + + " coalesce(dc.gb_longitude, dc.longitude) as longitude,\n" + + " coalesce(dc.gb_latitude, dc.latitude) as latitude,\n" + + " coalesce(dc.gb_ptz_type, dc.ptz_type) as ptz_type,\n" + + " coalesce(dc.gb_position_type, dc.position_type) as position_type,\n" + + " coalesce(dc.gb_room_type, dc.room_type) as room_type,\n" + + " coalesce(dc.gb_use_type, dc.use_type) as use_type,\n" + + " coalesce(dc.gb_supply_light_type, dc.supply_light_type) as supply_light_type,\n" + + " coalesce(dc.gb_direction_type, dc.direction_type) as direction_type,\n" + + " coalesce(dc.gb_resolution, dc.resolution) as resolution,\n" + + " coalesce(dc.gb_business_group_id, dc.business_group_id) as business_group_id,\n" + + " coalesce(dc.gb_download_speed, dc.download_speed) as download_speed,\n" + + " coalesce(dc.gb_svc_space_support_mod, dc.svc_space_support_mod) as svc_space_support_mod,\n" + + " coalesce(dc.gb_svc_time_support_mode dc.svc_time_support_mode) as svc_time_support_mode\n" + + " FROM wvp_device_channel dc " + + " left join wvp_device d on d.id=dc.device_db_id" + + " WHERE d.device_id=#{deviceId} AND dc.device_id=#{channelId}") DeviceChannel queryChannel(@Param("deviceId") String deviceId,@Param("channelId") String channelId); - @Delete("DELETE FROM wvp_device_channel WHERE device_id=#{deviceId}") - int cleanChannelsByDeviceId(@Param("deviceId") String deviceId); + @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") + int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); - @Delete("DELETE FROM wvp_device_channel WHERE device_id=#{deviceId} AND channel_id=#{channelId}") - int del(@Param("deviceId") String deviceId, @Param("channelId") String channelId); + @Delete("DELETE FROM wvp_device_channel WHERE id=#{id}") + int del(@Param("id") int id); @Update(value = {"UPDATE wvp_device_channel SET stream_id=null WHERE device_id=#{deviceId} AND channel_id=#{channelId}"}) void stopPlay(@Param("deviceId") String deviceId, @Param("channelId") String channelId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java index e792cf0d..d3543a01 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java @@ -119,7 +119,7 @@ public class CatalogDataCatch { if (catalogData.getTotal() == catalogData.getChannelList().size()) { deviceChannelService.resetChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); }else { - deviceChannelService.updateChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); + deviceChannelService.updateChannels(catalogData.getDevice(), catalogData.getChannelList()); } String errorMsg = "更新成功,共" + catalogData.getTotal() + "条,已更新" + catalogData.getChannelList().size() + "条"; catalogData.setErrorMsg(errorMsg); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java index 66f228bd..1182dd79 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java @@ -60,6 +60,9 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In @Autowired private IDeviceService deviceService; + @Autowired + private IDeviceChannelService deviceChannelService; + @Autowired private AudioBroadcastManager audioBroadcastManager; @@ -216,7 +219,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId()); if (inviteInfo != null) { - storager.stopPlay(ssrcTransaction.getDeviceId(), channel.getDeviceId()); + deviceChannelService.stopPlay(ssrcTransaction.getDeviceId(), channel.getDeviceId()); inviteStreamService.removeInviteInfo(inviteInfo); if (inviteInfo.getStreamInfo() != null) { mediaServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServerId(), inviteInfo.getStreamInfo().getStream()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index 4a215094..eee131f7 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -100,7 +100,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp if (sumNum == 0) { log.info("[收到通道]设备:{}的: 0个", take.getDevice().getDeviceId()); // 数据已经完整接收 - deviceChannelService.cleanChannelsForDevice(take.getDevice().getDeviceId()); + deviceChannelService.cleanChannelsForDevice(take.getDevice().getId()); catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), null); } else { Iterator deviceListIterator = deviceListElement.elementIterator(); diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java index d0cdd08a..81aa1d84 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java @@ -24,11 +24,8 @@ public interface IDeviceChannelService { /** * 批量添加设备通道 - * - * @param deviceId 设备id - * @param channels 多个通道 */ - int updateChannels(String deviceId, List channels); + int updateChannels(Device device, List channels); /** * 获取统计信息 @@ -93,7 +90,10 @@ public interface IDeviceChannelService { void updateChannelGPS(Device device, DeviceChannel deviceChannel, MobilePosition mobilePosition); + void startPlay(String deviceId, String channelId, String stream); + void stopPlay(String deviceId, String channelId); + void batchUpdateChannelGPS(List channelList); void batchAddMobilePosition(List addMobilePositionList); @@ -104,7 +104,9 @@ public interface IDeviceChannelService { void delete(DeviceChannel channel); - void cleanChannelsForDevice(String deviceId); + void cleanChannelsForDevice(int deviceId); boolean resetChannels(String deviceId, List deviceChannels); + + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index 45decc9d..9acbc628 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -84,17 +84,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } @Override - public int updateChannels(String deviceId, List channels) { + public int updateChannels(Device device, List channels) { List addChannels = new ArrayList<>(); List updateChannels = new ArrayList<>(); HashMap channelsInStore = new HashMap<>(); - Device device = deviceMapper.getDeviceByDeviceId(deviceId); if (channels != null && channels.size() > 0) { - List channelList = channelMapper.queryChannels(deviceId, null, null, null, null,null); - if (channelList.size() == 0) { + List channelList = channelMapper.queryChannelsByDeviceDbId(device.getId()); + if (channelList.isEmpty()) { for (DeviceChannel channel : channels) { - channel.setDeviceId(deviceId); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channel.getDeviceId()); + channel.setDeviceDbId(device.getId()); + InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId()); if (inviteInfo != null && inviteInfo.getStreamInfo() != null) { channel.setStreamId(inviteInfo.getStreamInfo().getStream()); } @@ -108,8 +107,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { channelsInStore.put(deviceChannel.getDeviceId(), deviceChannel); } for (DeviceChannel channel : channels) { - channel.setDeviceId(deviceId); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channel.getDeviceId()); + channel.setDeviceDbId(device.getId()); + InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId()); if (inviteInfo != null && inviteInfo.getStreamInfo() != null) { channel.setStreamId(inviteInfo.getStreamInfo().getStream()); } @@ -231,7 +230,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { @Override public void delete(DeviceChannel channel) { - channelMapper.del(channel.getDeviceId(), channel.getDeviceId()); + channelMapper.del(channel.getId()); } @Override @@ -344,6 +343,11 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } } + @Override + public void startPlay(String deviceId, String channelId, String stream) { + channelMapper.startPlay(deviceId, channelId, stream); + } + @Override public void stopPlay(String deviceId, String channelId) { channelMapper.stopPlay(deviceId, channelId); @@ -393,7 +397,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } @Override - public void cleanChannelsForDevice(String deviceId) { + public void cleanChannelsForDevice(int deviceId) { channelMapper.cleanChannelsByDeviceId(deviceId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 86733db8..5b2c63b5 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.common.CommonCallback; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; @@ -24,6 +25,7 @@ import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper; import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -409,7 +411,7 @@ public class DeviceServiceImpl implements IDeviceService { if (!deviceChannels.isEmpty()) { List deviceChannelsForStore = new ArrayList<>(); deviceChannelsForStore.addAll(deviceChannels); - deviceChannelService.updateChannels(device.getDeviceId(), deviceChannelsForStore); + deviceChannelService.updateChannels(device, deviceChannelsForStore); } } @@ -545,11 +547,15 @@ public class DeviceServiceImpl implements IDeviceService { @Override public boolean delete(String deviceId) { + Device device = deviceMapper.getDeviceByDeviceId(deviceId); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId); + } TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); boolean result = false; try { platformChannelMapper.delChannelForDeviceId(deviceId); - deviceChannelMapper.cleanChannelsByDeviceId(deviceId); + deviceChannelMapper.cleanChannelsByDeviceId(device.getId()); if ( deviceMapper.del(deviceId) < 0 ) { //事务回滚 dataSourceTransactionManager.rollback(transactionStatus); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java index d833fdb3..96f5ea58 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java @@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent; import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; @@ -39,6 +40,9 @@ public class InviteStreamServiceImpl implements IInviteStreamService { @Autowired private IVideoManagerStorage storage; + @Autowired + private IDeviceChannelService deviceChannelService; + @Autowired private UserSetting userSetting; @@ -63,7 +67,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService { InviteInfo inviteInfo = getInviteInfoByStream(null, event.getStream()); if (inviteInfo != null && (inviteInfo.getType() == InviteSessionType.PLAY || inviteInfo.getType() == InviteSessionType.PLAYBACK)) { removeInviteInfo(inviteInfo); - storage.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); + deviceChannelService.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java index 38435c1c..14af6503 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java @@ -13,10 +13,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.bean.ResultForOnPublish; import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.service.IMediaService; -import com.genersoft.iot.vmp.service.IUserService; +import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy; @@ -59,6 +56,9 @@ public class MediaServiceImpl implements IMediaService { @Autowired private IInviteStreamService inviteStreamService; + @Autowired + private IDeviceChannelService deviceChannelService; + @Autowired private VideoStreamSessionManager sessionManager; @@ -267,7 +267,7 @@ public class MediaServiceImpl implements IMediaService { inviteStreamService.removeInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(), inviteInfo.getChannelId(), inviteInfo.getStream()); - storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); + deviceChannelService.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); return result; } SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, stream, null); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index a2a3d8d4..9f018889 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -314,7 +314,7 @@ public class PlayServiceImpl implements IPlayService { }else { // 点播发起了但是尚未成功, 仅注册回调等待结果即可 inviteStreamService.once(InviteSessionType.PLAY, deviceId, channelId, null, callback); - storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); + channelService.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); } } @@ -698,7 +698,7 @@ public class PlayServiceImpl implements IPlayService { DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); if (deviceChannel != null) { deviceChannel.setStreamId(streamInfo.getStream()); - storager.startPlay(deviceId, channelId, streamInfo.getStream()); + channelService.startPlay(deviceId, channelId, streamInfo.getStream()); } InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); if (inviteInfo != null) { @@ -719,7 +719,7 @@ public class PlayServiceImpl implements IPlayService { DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); if (deviceChannel != null) { deviceChannel.setStreamId(streamInfo.getStream()); - storager.startPlay(deviceId, channelId, streamInfo.getStream()); + channelService.startPlay(deviceId, channelId, streamInfo.getStream()); } InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, mediaInfo.getStream()); if (inviteInfo != null) { @@ -1638,7 +1638,7 @@ public class PlayServiceImpl implements IPlayService { } } inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channelId); - storager.stopPlay(device.getDeviceId(), channelId); + channelService.stopPlay(device.getDeviceId(), channelId); channelService.stopPlay(device.getDeviceId(), channelId); if (inviteInfo.getStreamInfo() != null) { mediaServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServerId(), inviteInfo.getStream()); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java index 7e077f3c..274f8371 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -24,21 +24,6 @@ public interface IVideoManagerStorage { * @return true:存在 false:不存在 */ public boolean exists(String deviceId); - - /** - * 开始播放 - * @param deviceId 设备id - * @param channelId 通道ID - * @param streamId 流地址 - */ - public void startPlay(String deviceId, String channelId, String streamId); - - /** - * 停止播放 - * @param deviceId 设备id - * @param channelId 通道ID - */ - public void stopPlay(String deviceId, String channelId); /** * 获取设备 diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 980d1588..52f7ccbf 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -104,16 +104,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } - @Override - public void startPlay(String deviceId, String channelId, String streamId) { - deviceChannelMapper.startPlay(deviceId, channelId, streamId); - } - - @Override - public void stopPlay(String deviceId, String channelId) { - deviceChannelMapper.stopPlay(deviceId, channelId); - } - /** * 获取设备 * diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index 3cc4ed29..bca40927 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; @@ -74,6 +75,10 @@ public class PlayController { @Autowired private UserSetting userSetting; + + @Autowired + private IDeviceChannelService deviceChannelService; + @Operation(summary = "开始点播", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true) @@ -102,7 +107,7 @@ public class PlayController { requestMessage.setData(wvpResult); resultHolder.invokeAllResult(requestMessage); inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - storager.stopPlay(deviceId, channelId); + deviceChannelService.stopPlay(deviceId, channelId); }); // 录像查询以channelId作为deviceId查询 diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java index 0652a642..bc497db2 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java @@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.media.bean.MediaServer; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.service.IPlayService; @@ -46,6 +47,9 @@ public class ApiStreamController { @Autowired private IDeviceService deviceService; + @Autowired + private IDeviceChannelService deviceChannelService; + @Autowired private IPlayService playService; @@ -96,7 +100,7 @@ public class ApiStreamController { resultJSON.put("error","timeout"); result.setResult(resultJSON); inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, serial, code); - storager.stopPlay(serial, code); + deviceChannelService.stopPlay(serial, code); // 清理RTP server }); @@ -240,7 +244,7 @@ public class ApiStreamController { return result; } inviteStreamService.removeInviteInfo(inviteInfo); - storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); + deviceChannelService.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); return null; }