diff --git a/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java b/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java index d00e0ce11..b2730eabd 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java +++ b/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java @@ -1,8 +1,5 @@ package com.genersoft.iot.vmp.common.enums; -import java.util.HashMap; -import java.util.Map; - /** * 支持的通道数据类型 */ @@ -13,12 +10,11 @@ public class ChannelDataType { public final static int STREAM_PUSH = 2; public final static int STREAM_PROXY = 3; - public static Map getDescMap() { - Map map = new HashMap<>(); - map.put("国标28181", ChannelDataType.GB28181); - map.put("推流设备", ChannelDataType.STREAM_PUSH); - map.put("拉流代理", ChannelDataType.STREAM_PROXY); - return map; - } + public final static String PLAY_SERVICE = "sourceChannelPlayService"; + public final static String PLAYBACK_SERVICE = "sourceChannelPlaybackService"; + public final static String DOWNLOAD_SERVICE = "sourceChannelDownloadService"; + public final static String PTZ_SERVICE = "sourceChannelPTZService"; + + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java index aee8eaba5..699d18d50 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java @@ -195,7 +195,7 @@ public class DeviceChannel extends CommonGBChannel { @Schema(description = "通道类型, 默认0, 0: 普通通道,1 行政区划 2 业务分组/虚拟组织") private int channelType; - private Integer dataType = ChannelDataType.GB28181.value; + private Integer dataType = ChannelDataType.GB28181; public void setPtzType(int ptzType) { this.ptzType = ptzType; @@ -255,7 +255,7 @@ public class DeviceChannel extends CommonGBChannel { commonGBChannel.setGbId(id); commonGBChannel.setGbDeviceId(deviceId); commonGBChannel.setGbName(name); - commonGBChannel.setDataType(ChannelDataType.GB28181.value); + commonGBChannel.setDataType(ChannelDataType.GB28181); commonGBChannel.setDataDeviceId(getDataDeviceId()); return commonGBChannel; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlaybackController.java index 3b1fb108c..1dc6e42e5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlaybackController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlaybackController.java @@ -165,10 +165,10 @@ public class PlaybackController { @Operation(summary = "回放暂停", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "streamId", description = "回放流ID", required = true) @GetMapping("/pause/{streamId}") - public void playPause(@PathVariable String streamId) { + public void playbackPause(@PathVariable String streamId) { log.info("[回放暂停] streamId: {}", streamId); try { - playService.pauseRtp(streamId); + playService.playbackPause(streamId); } catch (ServiceException e) { throw new ControllerException(ErrorCode.ERROR400.getCode(), e.getMessage()); } catch (InvalidArgumentException | ParseException | SipException e) { @@ -183,7 +183,7 @@ public class PlaybackController { public void playResume(@PathVariable String streamId) { log.info("playResume: "+streamId); try { - playService.resumeRtp(streamId); + playService.playbackResume(streamId); } catch (ServiceException e) { throw new ControllerException(ErrorCode.ERROR400.getCode(), e.getMessage()); } catch (InvalidArgumentException | ParseException | SipException e) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java index 8f1526599..af5b8e0c4 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java @@ -64,7 +64,7 @@ public class DeviceChannelProvider { public String queryChannels(Map params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where data_type = " + ChannelDataType.GB28181.value); + sqlBuild.append(" where data_type = " + ChannelDataType.GB28181); if (params.get("dataDeviceId") != null) { sqlBuild.append(" AND dc.data_device_id = #{dataDeviceId} "); } @@ -122,14 +122,14 @@ public class DeviceChannelProvider { public String queryChannelsByDeviceDbId(Map params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where data_type = " + ChannelDataType.GB28181.value + " and dc.data_device_id = #{dataDeviceId}"); + sqlBuild.append(" where data_type = " + ChannelDataType.GB28181 + " and dc.data_device_id = #{dataDeviceId}"); return sqlBuild.toString(); } public String queryAllChannels(Map params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where data_type = " + ChannelDataType.GB28181.value + " and dc.data_device_id = #{dataDeviceId}"); + sqlBuild.append(" where data_type = " + ChannelDataType.GB28181 + " and dc.data_device_id = #{dataDeviceId}"); return sqlBuild.toString(); } @@ -143,25 +143,25 @@ public class DeviceChannelProvider { public String getOneByDeviceId(Map params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where data_type = " + ChannelDataType.GB28181.value + " and dc.data_device_id=#{dataDeviceId} and coalesce(dc.gb_device_id, dc.device_id) = #{channelId}"); + sqlBuild.append(" where data_type = " + ChannelDataType.GB28181 + " and dc.data_device_id=#{dataDeviceId} and coalesce(dc.gb_device_id, dc.device_id) = #{channelId}"); return sqlBuild.toString(); } public String queryByDeviceId(Map params ){ - return getBaseSelectSql() + " where data_type = " + ChannelDataType.GB28181.value + " and channel_type = 0 and coalesce(gb_device_id, device_id) = #{gbDeviceId}"; + return getBaseSelectSql() + " where data_type = " + ChannelDataType.GB28181 + " and channel_type = 0 and coalesce(gb_device_id, device_id) = #{gbDeviceId}"; } public String queryById(Map params ){ - return getBaseSelectSql() + " where data_type = " + ChannelDataType.GB28181.value + " and channel_type = 0 and id = #{gbId}"; + return getBaseSelectSql() + " where data_type = " + ChannelDataType.GB28181 + " and channel_type = 0 and id = #{gbId}"; } public String queryList(Map params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where channel_type = 0 and data_type = " + ChannelDataType.GB28181.value); + sqlBuild.append(" where channel_type = 0 and data_type = " + ChannelDataType.GB28181); if (params.get("query") != null) { sqlBuild.append(" AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%')" + " OR coalesce(gb_name, name) LIKE concat('%',#{query},'%') )") diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java index ca65e352a..2930c4fd4 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceService.java @@ -200,5 +200,6 @@ public interface IDeviceService { void deviceInfo(Device device, ErrorCallback callback); - void queryPreset(Device device, String channelId, ErrorCallback callback); + void queryPreset(Device device, String channelId, ErrorCallback> callback); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelControlService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelControlService.java index 93f673761..bc28dbd5a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelControlService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelControlService.java @@ -11,11 +11,9 @@ public interface IGbChannelControlService { void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback); void fi(CommonGBChannel channel, FrontEndControlCodeForFI frontEndControlCode, ErrorCallback callback); void preset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback callback); - void queryPreset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback callback); void tour(CommonGBChannel channel, FrontEndControlCodeForTour frontEndControlCode, ErrorCallback callback); void scan(CommonGBChannel channel, FrontEndControlCodeForScan frontEndControlCode, ErrorCallback callback); void wiper(CommonGBChannel channel, FrontEndControlCodeForWiper controlCode, ErrorCallback callback); void auxiliary(CommonGBChannel channel, FrontEndControlCodeForAuxiliary frontEndControlCode, ErrorCallback callback); - void queryPreset(CommonGBChannel channel, ErrorCallback> callback); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java index 4656116e8..07214651a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelPlayService.java @@ -9,25 +9,24 @@ import com.genersoft.iot.vmp.service.bean.ErrorCallback; public interface IGbChannelPlayService { - void start(CommonGBChannel channel, InviteMessageInfo inviteInfo, Platform platform, ErrorCallback callback); + void startInvite(CommonGBChannel channel, InviteMessageInfo inviteInfo, Platform platform, ErrorCallback callback); - void stopPlay(InviteSessionType type, CommonGBChannel channel, String stream); + void stopInvite(InviteSessionType type, CommonGBChannel channel, String stream); + + void playback(CommonGBChannel channel, Long startTime, Long stopTime, ErrorCallback callback); + + void download(CommonGBChannel channel, Long startTime, Long stopTime, Integer downloadSpeed, + ErrorCallback callback); + + void stopPlay(CommonGBChannel channel, String stream); void play(CommonGBChannel channel, Platform platform, Boolean record, ErrorCallback callback); - void playGbDeviceChannel(CommonGBChannel channel, Boolean record, ErrorCallback callback); + void stopPlayback(CommonGBChannel channel, String stream); - void stopPlayDeviceChannel(InviteSessionType type, CommonGBChannel channel, String stream); + void stopDownload(CommonGBChannel channel, String stream); - void playProxy(CommonGBChannel channel, Boolean record, ErrorCallback callback); + void playbackPause(CommonGBChannel channel, String streamId); - void stopPlayProxy(CommonGBChannel channel); - - void playPush(CommonGBChannel channel, String platformDeviceId, String platformName, ErrorCallback callback); - - void stopPlayPush(CommonGBChannel channel); - - void pauseRtp(String streamId); - - void resumeRtp(String streamId); + void playbackResume(CommonGBChannel channel, String streamId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPTZService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPTZService.java index c825c1cce..2a871d8da 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPTZService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPTZService.java @@ -4,21 +4,18 @@ package com.genersoft.iot.vmp.gb28181.service; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Preset; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; import java.util.List; public interface IPTZService { - - List queryPresetList(String deviceId, String channelDeviceId); - - void addPreset(Preset preset); - - void deletePreset(Integer qq); - void ptz(Device device, String channelId, int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed); void frontEndCommand(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combindCode2); void frontEndCommand(CommonGBChannel channel, Integer cmdCode, Integer parameter1, Integer parameter2, Integer combindCode2); + + void queryPresetList(CommonGBChannel channel, ErrorCallback> callback); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java index 50c49776a..3c94c63f6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java @@ -48,9 +48,9 @@ public interface IPlayService { void stopAudioBroadcast(Device device, DeviceChannel channel); - void pauseRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException; + void playbackPause(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException; - void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException; + void playbackResume(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException; void startPushStream(SendRtpInfo sendRtpItem, DeviceChannel channel, SIPResponse sipResponse, Platform platform, CallIdHeader callIdHeader); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourceDownloadService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourceDownloadService.java new file mode 100644 index 000000000..26c406411 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourceDownloadService.java @@ -0,0 +1,15 @@ +package com.genersoft.iot.vmp.gb28181.service; + +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; + +/** + * 资源能力接入-录像下载 + */ +public interface ISourceDownloadService { + + void download(CommonGBChannel channel, Long startTime, Long stopTime, Integer downloadSpeed, ErrorCallback callback); + + void stopDownload(CommonGBChannel channel, String stream); +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePTZService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePTZService.java new file mode 100644 index 000000000..9679fb5b3 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePTZService.java @@ -0,0 +1,28 @@ +package com.genersoft.iot.vmp.gb28181.service; + +import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; + +import java.util.List; + +/** + * 资源能力接入-云台控制 + */ +public interface ISourcePTZService { + + void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback); + + void preset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback callback); + + void fi(CommonGBChannel channel, FrontEndControlCodeForFI frontEndControlCode, ErrorCallback callback); + + void tour(CommonGBChannel channel, FrontEndControlCodeForTour frontEndControlCode, ErrorCallback callback); + + void scan(CommonGBChannel channel, FrontEndControlCodeForScan frontEndControlCode, ErrorCallback callback); + + void auxiliary(CommonGBChannel channel, FrontEndControlCodeForAuxiliary frontEndControlCode, ErrorCallback callback); + + void wiper(CommonGBChannel channel, FrontEndControlCodeForWiper frontEndControlCode, ErrorCallback callback); + + void queryPreset(CommonGBChannel channel, ErrorCallback> callback); +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePlayService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePlayService.java index 9dad8f364..8886db469 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePlayService.java @@ -2,11 +2,15 @@ package com.genersoft.iot.vmp.gb28181.service; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.service.bean.ErrorCallback; +/** + * 资源能力接入-实时录像 + */ public interface ISourcePlayService { - void play(CommonGBChannel channel, Boolean record, ErrorCallback callback); + void play(CommonGBChannel channel, Platform platform, Boolean record, ErrorCallback callback); void stopPlay(CommonGBChannel channel, String stream); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePlaybackService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePlaybackService.java new file mode 100644 index 000000000..c478501e1 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/ISourcePlaybackService.java @@ -0,0 +1,17 @@ +package com.genersoft.iot.vmp.gb28181.service; + +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; + +/** + * 资源能力接入-录像回放 + */ +public interface ISourcePlaybackService { + + void playback(CommonGBChannel channel, Long startTime, Long stopTime, ErrorCallback callback); + + void stopPlayback(CommonGBChannel channel, String stream); + + void playbackPause(CommonGBChannel channel, String stream); +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index cceae23e8..d5cd7fc8b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -780,7 +780,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { @Override public void addChannel(DeviceChannel channel) { - channel.setDataType(ChannelDataType.GB28181.value); + channel.setDataType(ChannelDataType.GB28181); channel.setDataDeviceId(channel.getDataDeviceId()); channelMapper.add(channel); } @@ -826,7 +826,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { @Override public void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback callback) { - if (channel.getDataType() != ChannelDataType.GB28181.value){ + if (channel.getDataType() != ChannelDataType.GB28181){ // 只支持国标的语音喊话 log.warn("[INFO 消息] 非国标设备, 通道ID: {}", channel.getGbId()); callback.run(ErrorCode.ERROR100.getCode(), "非国标设备", null); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java index a55e903f6..1c919d940 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java @@ -691,7 +691,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner { @Override public List getAllByStatus(Boolean status) { - return deviceMapper.getDevices(ChannelDataType.GB28181.value, status); + return deviceMapper.getDevices(ChannelDataType.GB28181, status); } @Override @@ -852,7 +852,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner { .replaceAll("%", "/%") .replaceAll("_", "/_"); } - List all = deviceMapper.getDeviceList(ChannelDataType.GB28181.value, query, status); + List all = deviceMapper.getDeviceList(ChannelDataType.GB28181, query, status); return new PageInfo<>(all); } @@ -863,12 +863,12 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner { @Override public Device getDeviceByChannelId(Integer channelId) { - return deviceMapper.queryByChannelId(ChannelDataType.GB28181.value,channelId); + return deviceMapper.queryByChannelId(ChannelDataType.GB28181,channelId); } @Override public Device getDeviceBySourceChannelDeviceId(String channelId) { - return deviceMapper.getDeviceBySourceChannelDeviceId(ChannelDataType.GB28181.value,channelId); + return deviceMapper.getDeviceBySourceChannelDeviceId(ChannelDataType.GB28181,channelId); } @Override @@ -1252,9 +1252,9 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner { } @Override - public void queryPreset(Device device, String channelId, ErrorCallback callback) { + public void queryPreset(Device device, String channelId, ErrorCallback> callback) { if (!userSetting.getServerId().equals(device.getServerId())) { - WVPResult result = redisRpcService.queryPreset(device.getServerId(), device, channelId); + WVPResult> result = redisRpcService.queryPreset(device.getServerId(), device, channelId); callback.run(result.getCode(), result.getMsg(), result.getData()); return; } @@ -1267,4 +1267,6 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner { throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); } } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelControlServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelControlServiceImpl.java index 070f05ce2..3409a843f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelControlServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelControlServiceImpl.java @@ -1,14 +1,17 @@ package com.genersoft.iot.vmp.gb28181.service.impl; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelControlService; +import com.genersoft.iot.vmp.gb28181.service.ISourcePTZService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.sip.message.Response; import java.util.List; +import java.util.Map; @Service @Slf4j @@ -16,54 +19,110 @@ public class GbChannelControlServiceImpl implements IGbChannelControlService { @Autowired - private IDeviceChannelService deviceChannelService; + private Map sourcePTZServiceMap; @Override public void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback) { -// log.info("[通用通道] 云台控制, 通道: {}", channel.getGbDeviceId()); -// if (channel.getDataType() == ChannelDataType.GB28181.value) { -// -// }else if() + log.info("[通用通道] 云台控制, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePTZService sourcePTZService = sourcePTZServiceMap.get(ChannelDataType.PTZ_SERVICE + dataType); + if (sourcePTZService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型: {} 不支持云台控制", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); + } + sourcePTZService.ptz(channel, frontEndControlCode, callback); } @Override public void preset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback callback) { - log.info("[通用通道] 预置位, 通道: {}", channel.getGbDeviceId()); + log.info("[通用通道] 预置位控制, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePTZService sourcePTZService = sourcePTZServiceMap.get(ChannelDataType.PTZ_SERVICE + dataType); + if (sourcePTZService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型: {} 不支持预置位控制", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); + } + sourcePTZService.preset(channel, frontEndControlCode, callback); } @Override public void fi(CommonGBChannel channel, FrontEndControlCodeForFI frontEndControlCode, ErrorCallback callback) { - log.info("[通用通道] FI指令, 通道: {}", channel.getGbDeviceId()); + log.info("[通用通道] FI指令, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePTZService sourcePTZService = sourcePTZServiceMap.get(ChannelDataType.PTZ_SERVICE + dataType); + if (sourcePTZService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型: {} 不支持FI指令", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); + } + sourcePTZService.fi(channel, frontEndControlCode, callback); } @Override public void tour(CommonGBChannel channel, FrontEndControlCodeForTour frontEndControlCode, ErrorCallback callback) { - + log.info("[通用通道] 巡航指令, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePTZService sourcePTZService = sourcePTZServiceMap.get(ChannelDataType.PTZ_SERVICE + dataType); + if (sourcePTZService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型: {} 不支持巡航指令", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); + } + sourcePTZService.tour(channel, frontEndControlCode, callback); } @Override public void scan(CommonGBChannel channel, FrontEndControlCodeForScan frontEndControlCode, ErrorCallback callback) { - + log.info("[通用通道] 扫描指令, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePTZService sourcePTZService = sourcePTZServiceMap.get(ChannelDataType.PTZ_SERVICE + dataType); + if (sourcePTZService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型: {} 不支持扫描指令", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); + } + sourcePTZService.scan(channel, frontEndControlCode, callback); } @Override public void auxiliary(CommonGBChannel channel, FrontEndControlCodeForAuxiliary frontEndControlCode, ErrorCallback callback) { - + log.info("[通用通道] 辅助开关控制指令, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePTZService sourcePTZService = sourcePTZServiceMap.get(ChannelDataType.PTZ_SERVICE + dataType); + if (sourcePTZService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型: {} 不支持辅助开关控制指令", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); + } + sourcePTZService.auxiliary(channel, frontEndControlCode, callback); } @Override - public void queryPreset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback callback) { - - } - - @Override - public void wiper(CommonGBChannel channel, FrontEndControlCodeForWiper controlCode, ErrorCallback callback) { - + public void wiper(CommonGBChannel channel, FrontEndControlCodeForWiper frontEndControlCode, ErrorCallback callback) { + log.info("[通用通道] 雨刷控制, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePTZService sourcePTZService = sourcePTZServiceMap.get(ChannelDataType.PTZ_SERVICE + dataType); + if (sourcePTZService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型: {} 不支持雨刷控制", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); + } + sourcePTZService.wiper(channel, frontEndControlCode, callback); } @Override public void queryPreset(CommonGBChannel channel, ErrorCallback> callback) { - + log.info("[通用通道] 预置位查询, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePTZService sourcePTZService = sourcePTZServiceMap.get(ChannelDataType.PTZ_SERVICE + dataType); + if (sourcePTZService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型: {} 不支持预置位查询", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); + } + sourcePTZService.queryPreset(channel, callback); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java index 20a7897fa..10321911f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java @@ -4,50 +4,38 @@ import com.genersoft.iot.vmp.common.InviteSessionType; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.conf.exception.ServiceException; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.InviteMessageInfo; import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.PlayException; -import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; -import com.genersoft.iot.vmp.gb28181.service.IPlayService; -import com.genersoft.iot.vmp.gb28181.service.ISourcePlayService; +import com.genersoft.iot.vmp.gb28181.service.*; import com.genersoft.iot.vmp.service.bean.ErrorCallback; -import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyPlayService; -import com.genersoft.iot.vmp.streamPush.service.IStreamPushPlayService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; import javax.sip.message.Response; -import java.text.ParseException; import java.util.Map; @Slf4j @Service public class GbChannelPlayServiceImpl implements IGbChannelPlayService { - @Autowired - private IPlayService deviceChannelPlayService; - - @Autowired - private IStreamProxyPlayService streamProxyPlayService; - - @Autowired - private IStreamPushPlayService streamPushPlayService; - @Autowired private UserSetting userSetting; @Autowired private Map sourcePlayServiceMap; + @Autowired + private Map sourcePlaybackServiceMap; + + @Autowired + private Map sourceDownloadServiceMap; + @Override - public void start(CommonGBChannel channel, InviteMessageInfo inviteInfo, Platform platform, ErrorCallback callback) { + public void startInvite(CommonGBChannel channel, InviteMessageInfo inviteInfo, Platform platform, ErrorCallback callback) { if (channel == null || inviteInfo == null || callback == null || channel.getDataType() == null) { log.warn("[通用通道点播] 参数异常, channel: {}, inviteInfo: {}, callback: {}", channel != null, inviteInfo != null, callback != null); throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); @@ -57,46 +45,11 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { if ("Play".equalsIgnoreCase(inviteInfo.getSessionName())) { play(channel, platform, userSetting.getRecordSip(), callback); }else if ("Playback".equals(inviteInfo.getSessionName())) { - if (channel.getDataType() == ChannelDataType.GB28181.value) { - // 国标通道 - playbackGbDeviceChannel(channel, inviteInfo.getStartTime(), inviteInfo.getStopTime(), callback); - } else if (channel.getDataType() == ChannelDataType.STREAM_PROXY.value) { - // 拉流代理 - log.warn("[回放通用通道] 不支持回放拉流代理的录像: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.FORBIDDEN, "forbidden"); - } else if (channel.getDataType() == ChannelDataType.STREAM_PUSH.value) { - // 推流 - log.warn("[回放通用通道] 不支持回放推流的录像: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.FORBIDDEN, "forbidden"); - } else { - // 通道数据异常 - log.error("[回放通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); - } + playback(channel, inviteInfo.getStartTime(), inviteInfo.getStopTime(), callback); }else if ("Download".equals(inviteInfo.getSessionName())) { - if (channel.getDataType() == ChannelDataType.GB28181.value) { - int downloadSpeed = 4; - try { - if (inviteInfo.getDownloadSpeed() != null){ - downloadSpeed = Integer.parseInt(inviteInfo.getDownloadSpeed()); - } - }catch (Exception ignored) {} - - // 国标通道 - downloadGbDeviceChannel(channel, inviteInfo.getStartTime(), inviteInfo.getStopTime(), downloadSpeed, callback); - } else if (channel.getDataType() == ChannelDataType.STREAM_PROXY.value) { - // 拉流代理 - log.warn("[下载通用通道录像] 不支持下载拉流代理的录像: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.FORBIDDEN, "forbidden"); - } else if (channel.getDataType() == ChannelDataType.STREAM_PUSH.value) { - // 推流 - log.warn("[下载通用通道录像] 不支持下载推流的录像: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.FORBIDDEN, "forbidden"); - } else { - // 通道数据异常 - log.error("[回放通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); - } + Integer downloadSpeed = Integer.parseInt(inviteInfo.getDownloadSpeed()); + // 国标通道 + download(channel, inviteInfo.getStartTime(), inviteInfo.getStopTime(), downloadSpeed, callback); }else { // 不支持的点播方式 log.error("[点播通用通道] 不支持的点播方式:{}, {}({})", inviteInfo.getSessionName(), channel.getGbName(), channel.getGbDeviceId()); @@ -105,20 +58,21 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { } @Override - public void stopPlay(InviteSessionType type, CommonGBChannel channel, String stream) { - if (channel.getDataType() == ChannelDataType.GB28181.value) { - // 国标通道 - stopPlayDeviceChannel(type, channel, stream); - } else if (channel.getDataType() == ChannelDataType.STREAM_PROXY.value) { - // 拉流代理 - stopPlayProxy(channel); - } else if (channel.getDataType() == ChannelDataType.STREAM_PUSH.value) { - // 推流 - stopPlayPush(channel); - } else { - // 通道数据异常 - log.error("[点播通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); + public void stopInvite(InviteSessionType type, CommonGBChannel channel, String stream) { + switch (type) { + case PLAY: + stopPlay(channel, stream); + break; + case PLAYBACK: + stopPlayback(channel, stream); + break; + case DOWNLOAD: + stopDownload(channel, stream); + break; + default: + // 通道数据异常 + log.error("[点播通用通道] 类型编号: {} 不支持此类型请求", type); + throw new PlayException(Response.BUSY_HERE, "channel not support"); } } @@ -126,140 +80,102 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { public void play(CommonGBChannel channel, Platform platform, Boolean record, ErrorCallback callback) { log.info("[通用通道] 播放, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); Integer dataType = channel.getDataType(); - ISourcePlayService sourceChannelPlayService = sourcePlayServiceMap.get("SourceChannelPlayService" + dataType); + ISourcePlayService sourceChannelPlayService = sourcePlayServiceMap.get(ChannelDataType.PLAY_SERVICE + dataType); if (sourceChannelPlayService == null) { // 通道数据异常 log.error("[点播通用通道] 类型编号: {} 不支持实时流预览", dataType); throw new PlayException(Response.BUSY_HERE, "channel not support"); } - sourceChannelPlayService.play(channel, record, callback); - - - - if (channel.getDataType() == ChannelDataType.GB28181.value) { - // 国标通道 - playGbDeviceChannel(channel, record, callback); - } else if (channel.getDataType() == ChannelDataType.STREAM_PROXY.value) { - // 拉流代理 - playProxy(channel, record, callback); - } else if (channel.getDataType() == ChannelDataType.STREAM_PUSH.value) { - if (platform != null) { - // 推流 - playPush(channel, platform.getServerGBId(), platform.getName(), callback); - }else { - // 推流 - playPush(channel, null, null, callback); - } - } else { + sourceChannelPlayService.play(channel, platform, record, callback); + } + @Override + public void playback(CommonGBChannel channel, Long startTime, Long stopTime, ErrorCallback callback) { + log.info("[通用通道] 回放, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); + if (playbackService == null) { // 通道数据异常 - log.error("[点播通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId()); - throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); + log.error("[点播通用通道] 类型编号: {} 不支持回放", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); } + playbackService.playback(channel, startTime, stopTime, callback); } @Override - public void playGbDeviceChannel(CommonGBChannel channel, Boolean record, ErrorCallback callback){ - // 国标通道 - try { - deviceChannelPlayService.play(channel, record, callback); - } catch (PlayException e) { - callback.run(e.getCode(), e.getMsg(), null); - } catch (ControllerException e) { - log.error("[点播失败] {}({}), {}", channel.getGbName(), channel.getGbDeviceId(), e.getMsg()); - callback.run(Response.BUSY_HERE, "busy here", null); - } catch (Exception e) { - log.error("[点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); - callback.run(Response.BUSY_HERE, "busy here", null); + public void download(CommonGBChannel channel, Long startTime, Long stopTime, Integer downloadSpeed, + ErrorCallback callback){ + log.info("[通用通道] 录像下载, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourceDownloadService downloadService = sourceDownloadServiceMap.get(ChannelDataType.DOWNLOAD_SERVICE + dataType); + if (downloadService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型编号: {} 不支持录像下载", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); } + downloadService.download(channel, startTime, stopTime, downloadSpeed, callback); } @Override - public void stopPlayDeviceChannel(InviteSessionType type, CommonGBChannel channel, String stream) { - // 国标通道 - try { - deviceChannelPlayService.stop(type, channel, stream); - } catch (Exception e) { - log.error("[停止点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + public void stopPlay(CommonGBChannel channel, String stream) { + Integer dataType = channel.getDataType(); + ISourcePlayService sourceChannelPlayService = sourcePlayServiceMap.get(ChannelDataType.PLAY_SERVICE + dataType); + if (sourceChannelPlayService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型编号: {} 不支持停止实时流", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); } + sourceChannelPlayService.stopPlay(channel, stream); } @Override - public void playProxy(CommonGBChannel channel, Boolean record, ErrorCallback callback){ - // 拉流代理通道 - try { - streamProxyPlayService.start(channel.getDataDeviceId(), record, callback); - }catch (Exception e) { - callback.run(Response.BUSY_HERE, "busy here", null); + public void stopPlayback(CommonGBChannel channel, String stream) { + log.info("[通用通道] 停止回放, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + Integer dataType = channel.getDataType(); + ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); + if (playbackService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型编号: {} 不支持回放", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); } + playbackService.stopPlayback(channel, stream); } @Override - public void stopPlayProxy(CommonGBChannel channel) { - // 拉流代理通道 - try { - streamProxyPlayService.stop(channel.getDataDeviceId()); - }catch (Exception e) { - log.error("[停止点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + public void stopDownload(CommonGBChannel channel, String stream) { + log.info("[通用通道] 停止录像下载, 类型: {}, 编号:{} stream: {}", channel.getDataType(), channel.getGbDeviceId(), stream); + Integer dataType = channel.getDataType(); + ISourceDownloadService downloadService = sourceDownloadServiceMap.get(ChannelDataType.DOWNLOAD_SERVICE + dataType); + if (downloadService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型编号: {} 不支持录像下载", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); } + downloadService.stopDownload(channel, stream); } @Override - public void playPush(CommonGBChannel channel, String platformDeviceId, String platformName, ErrorCallback callback){ - // 推流 - try { - streamPushPlayService.start(channel.getDataDeviceId(), callback, platformDeviceId, platformName); - }catch (PlayException e) { - callback.run(e.getCode(), e.getMsg(), null); - }catch (Exception e) { - log.error("[点播推流通道失败] 通道: {}({})", channel.getGbName(), channel.getGbDeviceId(), e); - callback.run(Response.BUSY_HERE, "busy here", null); + public void playbackPause(CommonGBChannel channel, String stream) { + log.info("[通用通道] 回放暂停, 类型: {}, 编号:{} stream:{}", channel.getDataType(), channel.getGbDeviceId(), stream); + Integer dataType = channel.getDataType(); + ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); + if (playbackService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型编号: {} 不支持回放暂停", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); } + playbackService.playbackPause(channel, stream); } @Override - public void stopPlayPush(CommonGBChannel channel) { - // 推流 - try { - streamPushPlayService.stop(channel.getDataDeviceId()); - }catch (Exception e) { - log.error("[停止点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + public void playbackResume(CommonGBChannel channel, String stream) { + log.info("[通用通道] 回放暂停恢复, 类型: {}, 编号:{} stream:{}", channel.getDataType(), channel.getGbDeviceId(), stream); + Integer dataType = channel.getDataType(); + ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); + if (playbackService == null) { + // 通道数据异常 + log.error("[点播通用通道] 类型编号: {} 不支持回放暂停恢复", dataType); + throw new PlayException(Response.BUSY_HERE, "channel not support"); } + playbackService.playbackPause(channel, stream); } - - private void playbackGbDeviceChannel(CommonGBChannel channel, Long startTime, Long stopTime, ErrorCallback callback){ - try { - deviceChannelPlayService.playBack(channel, startTime, stopTime, callback); - } catch (PlayException e) { - callback.run(e.getCode(), e.getMsg(), null); - } catch (Exception e) { - callback.run(Response.BUSY_HERE, "busy here", null); - } - } - - @Override - public void pauseRtp(String streamId) { - try { - deviceChannelPlayService.pauseRtp(streamId); - } catch (ServiceException | InvalidArgumentException | ParseException | SipException ignore) {} - } - - @Override - public void resumeRtp(String streamId) { - try { - deviceChannelPlayService.resumeRtp(streamId); - } catch (ServiceException | InvalidArgumentException | ParseException | SipException ignore) {} - } - - private void downloadGbDeviceChannel(CommonGBChannel channel, Long startTime, Long stopTime, Integer downloadSpeed, - ErrorCallback callback){ - try { - deviceChannelPlayService.download(channel, startTime, stopTime, downloadSpeed, callback); - } catch (PlayException e) { - callback.run(e.getCode(), e.getMsg(), null); - } catch (Exception e) { - callback.run(Response.BUSY_HERE, "busy here", null); - } - } - - } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index faeecf4ba..addb7a49e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -366,12 +366,12 @@ public class GbChannelServiceImpl implements IGbChannelService { log.warn("[重置国标通道] 未找到对应Id的通道: id: {}", id); throw new ControllerException(ErrorCode.ERROR400); } - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { log.warn("[重置国标通道] 非国标下级通道无法重置: id: {}", id); throw new ControllerException(ErrorCode.ERROR100.getCode(), "非国标下级通道无法重置"); } // 这个多加一个参数,为了防止将非国标的通道通过此方法清空内容,导致意外发生 - commonGBChannelMapper.reset(id, ChannelDataType.GB28181.value, channel.getDataDeviceId(), DateUtil.getNow()); + commonGBChannelMapper.reset(id, ChannelDataType.GB28181, channel.getDataDeviceId(), DateUtil.getNow()); CommonGBChannel channelNew = getOne(id); // 发送通过更新通知 try { @@ -494,7 +494,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public void addChannelToRegionByGbDevice(String civilCode, List deviceIds) { - List channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds); + List channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181, deviceIds); if (channelList.isEmpty()) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } @@ -515,7 +515,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public void deleteChannelToRegionByGbDevice(List deviceIds) { - List channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds); + List channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181, deviceIds); if (channelList.isEmpty()) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } @@ -632,7 +632,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override @Transactional public void addChannelToGroupByGbDevice(String parentId, String businessGroup, List deviceIds) { - List channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds); + List channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181, deviceIds); if (channelList.isEmpty()) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } @@ -660,7 +660,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public void deleteChannelToGroupByGbDevice(List deviceIds) { - List channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds); + List channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181, deviceIds); if (channelList.isEmpty()) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } @@ -702,7 +702,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public List queryListByStreamPushList(List streamPushList) { - return commonGBChannelMapper.queryListByStreamPushList(ChannelDataType.STREAM_PUSH.value, streamPushList); + return commonGBChannelMapper.queryListByStreamPushList(ChannelDataType.STREAM_PUSH, streamPushList); } @Override @@ -719,13 +719,13 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback callback) { - if (channel.getDataType() == ChannelDataType.GB28181.value) { + if (channel.getDataType() == ChannelDataType.GB28181) { deviceChannelService.queryRecordInfo(channel, startTime, endTime, callback); - } else if (channel.getDataType() == ChannelDataType.STREAM_PROXY.value) { + } else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) { // 拉流代理 log.warn("[下载通用通道录像] 不支持下载拉流代理的录像: {}({})", channel.getGbName(), channel.getGbDeviceId()); throw new PlayException(Response.FORBIDDEN, "forbidden"); - } else if (channel.getDataType() == ChannelDataType.STREAM_PUSH.value) { + } else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) { // 推流 log.warn("[下载通用通道录像] 不支持下载推流的录像: {}({})", channel.getGbName(), channel.getGbDeviceId()); throw new PlayException(Response.FORBIDDEN, "forbidden"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PTZServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PTZServiceImpl.java index 3fabadb2a..011331f47 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PTZServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PTZServiceImpl.java @@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.gb28181.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.service.IPTZService; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import lombok.extern.slf4j.Slf4j; @@ -21,7 +22,6 @@ import org.springframework.util.Assert; import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; -import java.util.Collections; import java.util.List; @Slf4j @@ -78,7 +78,7 @@ public class PTZServiceImpl implements IPTZService { @Override public void frontEndCommand(CommonGBChannel channel, Integer cmdCode, Integer parameter1, Integer parameter2, Integer combindCode2) { - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 只有国标通道的支持云台控制 log.warn("[INFO 消息] 只有国标通道的支持云台控制, 通道ID: {}", channel.getGbId()); throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持"); @@ -92,17 +92,20 @@ public class PTZServiceImpl implements IPTZService { } @Override - public List queryPresetList(String deviceId, String channelDeviceId) { - return Collections.emptyList(); - } - - @Override - public void addPreset(Preset preset) { - - } - - @Override - public void deletePreset(Integer qq) { - + public void queryPresetList(CommonGBChannel channel, ErrorCallback> callback) { + if (channel.getDataType() != ChannelDataType.GB28181) { + // 只有国标通道的支持云台控制 + log.warn("[INFO 消息] 只有国标通道的支持云台控制, 通道ID: {}", channel.getGbId()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持"); + } + Device device = deviceService.getDevice(channel.getDataDeviceId()); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备"); + } + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId()); + if (deviceChannel == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到通道"); + } + deviceService.queryPreset(device, deviceChannel.getDeviceId(), callback); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index f4bd244a2..1cfdcb833 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -296,14 +296,14 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @Override @Transactional public void addChannelByDevice(Integer platformId, List deviceIds) { - List channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(ChannelDataType.GB28181.value, deviceIds); + List channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(ChannelDataType.GB28181, deviceIds); addChannels(platformId, channelList); } @Override @Transactional public void removeChannelByDevice(Integer platformId, List deviceIds) { - List channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(ChannelDataType.GB28181.value, deviceIds); + List channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(ChannelDataType.GB28181, deviceIds); removeChannels(platformId, channelList); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index 46a4fb32d..bb895e17b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -1392,7 +1392,7 @@ public class PlayServiceImpl implements IPlayService { } @Override - public void pauseRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException { + public void playbackPause(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException { InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId); if (null == inviteInfo || inviteInfo.getStreamInfo() == null) { @@ -1403,7 +1403,7 @@ public class PlayServiceImpl implements IPlayService { throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备不存在"); } if (!userSetting.getServerId().equals(device.getServerId())) { - redisRpcPlayService.pauseRtp(device.getServerId(), streamId); + redisRpcPlayService.playbackPause(device.getServerId(), streamId); return; } @@ -1430,7 +1430,7 @@ public class PlayServiceImpl implements IPlayService { } @Override - public void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException { + public void playbackResume(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException { InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId); if (null == inviteInfo || inviteInfo.getStreamInfo() == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "streamId不存在"); @@ -1440,7 +1440,7 @@ public class PlayServiceImpl implements IPlayService { throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备不存在"); } if (!userSetting.getServerId().equals(device.getServerId())) { - redisRpcPlayService.resumeRtp(device.getServerId(), streamId); + redisRpcPlayService.playbackResume(device.getServerId(), streamId); return; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourceDownloadServiceForGbImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourceDownloadServiceForGbImpl.java new file mode 100644 index 000000000..283083e3a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourceDownloadServiceForGbImpl.java @@ -0,0 +1,35 @@ +package com.genersoft.iot.vmp.gb28181.service.impl; + +import com.genersoft.iot.vmp.common.InviteSessionType; +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.service.IPlayService; +import com.genersoft.iot.vmp.gb28181.service.ISourceDownloadService; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Slf4j +@Service(ChannelDataType.DOWNLOAD_SERVICE + ChannelDataType.GB28181) +public class SourceDownloadServiceForGbImpl implements ISourceDownloadService { + + @Autowired + private IPlayService deviceChannelPlayService; + + @Override + public void download(CommonGBChannel channel, Long startTime, Long stopTime, Integer downloadSpeed, ErrorCallback callback) { + + } + + @Override + public void stopDownload(CommonGBChannel channel, String stream) { + // 国标通道 + try { + deviceChannelPlayService.stop(InviteSessionType.DOWNLOAD, channel, stream); + } catch (Exception e) { + log.error("[停止下载失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + } + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePTZServiceForGbImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePTZServiceForGbImpl.java new file mode 100644 index 000000000..f355c2067 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePTZServiceForGbImpl.java @@ -0,0 +1,297 @@ +package com.genersoft.iot.vmp.gb28181.service.impl; + +import com.genersoft.iot.vmp.common.enums.ChannelDataType; +import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.gb28181.service.IPTZService; +import com.genersoft.iot.vmp.gb28181.service.ISourcePTZService; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Slf4j +@Service(ChannelDataType.PTZ_SERVICE + ChannelDataType.GB28181) +public class SourcePTZServiceForGbImpl implements ISourcePTZService { + + @Autowired + private IPTZService ptzService; + + public void frontEndCommand(CommonGBChannel channel, Integer cmdCode, Integer parameter1, Integer parameter2, Integer combindCode2){ + + if (parameter1 == null || parameter1 < 0 || parameter1 > 100) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "parameter1 为 0-255的数字"); + } + // 返回转换为国标定义的范围 + parameter1 = (int)(parameter1/100D* 255); + if (parameter2 == null || parameter2 < 0 || parameter2 > 100) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "parameter2 为 0-255的数字"); + } + // 返回转换为国标定义的范围 + parameter2 = (int)(parameter2/100D* 255); + if (combindCode2 == null || combindCode2 < 0 || combindCode2 > 100) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "combindCode2 为 0-15的数字"); + } + combindCode2 = (int)(combindCode2/100D* 16); + ptzService.frontEndCommand(channel, cmdCode, parameter1, parameter2, combindCode2); + } + + + @Override + public void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback) { + try { + int cmdCode = 0; + int panSpeed = 0; + int titleSpeed = 0; + int zoomSpeed = 0; + if (frontEndControlCode != null) { + if (frontEndControlCode.getPan() != null) { + if (frontEndControlCode.getPan() == 0) { + cmdCode = cmdCode | 1 << 1; + } else if (frontEndControlCode.getPan() == 1) { + cmdCode = cmdCode | 1; + } + } + if (frontEndControlCode.getTilt() != null) { + if (frontEndControlCode.getTilt() == 0) { + cmdCode = cmdCode | 1 << 3; + } else if (frontEndControlCode.getTilt() == 1) { + cmdCode = cmdCode | 1 << 2; + } + } + + if (frontEndControlCode.getZoom() != null) { + if (frontEndControlCode.getZoom() == 0) { + cmdCode = cmdCode | 1 << 5; + } else if (frontEndControlCode.getZoom() == 1) { + cmdCode = cmdCode | 1 << 4; + } + } + panSpeed = frontEndControlCode.getPanSpeed(); + titleSpeed = frontEndControlCode.getTiltSpeed(); + zoomSpeed = frontEndControlCode.getZoomSpeed(); + } + frontEndCommand(channel, cmdCode, panSpeed, titleSpeed, zoomSpeed); + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); + }catch (Exception e) { + log.error("[云台控制失败] ", e); + callback.run(ErrorCode.ERROR100.getCode(), e.getMessage(), null); + } + } + + @Override + public void preset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback callback) { + try { + int cmdCode = 0; + int parameter1 = 0; + int parameter2 = 0; + int parameter3 = 0; + if (frontEndControlCode != null) { + if (frontEndControlCode.getCode() != null) { + if (frontEndControlCode.getCode() == 1) { + cmdCode = 0x81; + } else if (frontEndControlCode.getCode() == 2) { + cmdCode = 0x82; + }else if (frontEndControlCode.getCode() == 3) { + cmdCode = 0x83; + } + } + if (frontEndControlCode.getPresetId() != null) { + parameter2 = frontEndControlCode.getPresetId(); + } + + } + frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); + }catch (Exception e) { + log.error("[预置位控制失败] ", e); + callback.run(ErrorCode.ERROR100.getCode(), e.getMessage(), null); + } + } + + @Override + public void fi(CommonGBChannel channel, FrontEndControlCodeForFI frontEndControlCode, ErrorCallback callback) { + try { + int cmdCode = 1 << 6; + int focusSpeed = 0; + int irisSpeed = 0; + int parameter3 = 0; + if (frontEndControlCode != null) { + if (frontEndControlCode.getFocus() != null) { + if (frontEndControlCode.getFocus() == 0) { + cmdCode = cmdCode | 1 << 1; + } else if (frontEndControlCode.getFocus() == 1) { + cmdCode = cmdCode | 1; + }else { + log.error("[FI失败] 未知的聚焦指令 {}", frontEndControlCode.getFocus()); + callback.run(ErrorCode.ERROR100.getCode(), "未知的指令", null); + } + } + if (frontEndControlCode.getIris() != null) { + if (frontEndControlCode.getIris() == 0) { + cmdCode = cmdCode | 1 << 3; + } else if (frontEndControlCode.getIris() == 1) { + cmdCode = cmdCode | 1 << 2; + }else { + log.error("[FI失败] 未知的光圈指令 {}", frontEndControlCode.getIris()); + callback.run(ErrorCode.ERROR100.getCode(), "未知的指令", null); + } + } + if (frontEndControlCode.getFocusSpeed() != null) { + focusSpeed = frontEndControlCode.getFocusSpeed(); + } + if (frontEndControlCode.getIrisSpeed() != null) { + irisSpeed = frontEndControlCode.getIrisSpeed(); + } + } + frontEndCommand(channel, cmdCode, focusSpeed, irisSpeed, parameter3); + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); + }catch (Exception e) { + log.error("[云台控制失败] ", e); + callback.run(ErrorCode.ERROR100.getCode(), e.getMessage(), null); + } + } + + @Override + public void tour(CommonGBChannel channel, FrontEndControlCodeForTour frontEndControlCode, ErrorCallback callback) { + try { + int cmdCode = 0; + int parameter1 = 0; + int parameter2 = 0; + int parameter3 = 0; + if (frontEndControlCode != null) { + if (frontEndControlCode.getCode() != null) { + if (frontEndControlCode.getCode() == 1) { + cmdCode = 0x84; + } else if (frontEndControlCode.getCode() == 2) { + cmdCode = 0x85; + }else if (frontEndControlCode.getCode() == 3) { + cmdCode = 0x86; + parameter3 = frontEndControlCode.getTourSpeed(); + }else if (frontEndControlCode.getCode() == 4) { + cmdCode = 0x87; + parameter3 = frontEndControlCode.getTourTime(); + }else if (frontEndControlCode.getCode() == 5) { + cmdCode = 0x88; + }else { + log.error("[巡航控制失败] 未知的指令 {}", frontEndControlCode.getCode()); + callback.run(ErrorCode.ERROR100.getCode(), "未知的指令", null); + } + parameter1 = frontEndControlCode.getTourId(); + } + if (frontEndControlCode.getPresetId() != null) { + parameter2 = frontEndControlCode.getPresetId(); + } + + } + frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); + }catch (Exception e) { + log.error("[巡航控制失败] ", e); + callback.run(ErrorCode.ERROR100.getCode(), e.getMessage(), null); + } + } + + @Override + public void scan(CommonGBChannel channel, FrontEndControlCodeForScan frontEndControlCode, ErrorCallback callback) { + try { + int cmdCode = 0; + int parameter1 = 0; + int parameter2 = 0; + int parameter3 = 0; + if (frontEndControlCode != null) { + if (frontEndControlCode.getCode() != null) { + if (frontEndControlCode.getCode() == 1) { + cmdCode = 0x89; + parameter1 = frontEndControlCode.getScanId(); + } else if (frontEndControlCode.getCode() == 2) { + cmdCode = 0x89; + parameter1 = frontEndControlCode.getScanId(); + parameter2 = 1; + }else if (frontEndControlCode.getCode() == 3) { + cmdCode = 0x89; + parameter1 = frontEndControlCode.getScanId(); + parameter2 = 2; + }else if (frontEndControlCode.getCode() == 4) { + cmdCode = 0x8A; + parameter1 = frontEndControlCode.getScanId(); + parameter2 = frontEndControlCode.getScanSpeed(); + }else if (frontEndControlCode.getCode() == 5) { + }else { + log.error("[巡航控制失败] 未知的指令 {}", frontEndControlCode.getCode()); + callback.run(ErrorCode.ERROR100.getCode(), "未知的指令", null); + } + } + } + frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); + }catch (Exception e) { + log.error("[巡航控制失败] ", e); + callback.run(ErrorCode.ERROR100.getCode(), e.getMessage(), null); + } + } + + @Override + public void auxiliary(CommonGBChannel channel, FrontEndControlCodeForAuxiliary frontEndControlCode, ErrorCallback callback) { + try { + int cmdCode = 0; + int parameter1 = 0; + int parameter2 = 0; + int parameter3 = 0; + if (frontEndControlCode != null) { + if (frontEndControlCode.getCode() != null) { + if (frontEndControlCode.getCode() == 1) { + cmdCode = 0x8C; + parameter1 = frontEndControlCode.getAuxiliaryId(); + } else if (frontEndControlCode.getCode() == 2) { + cmdCode = 0x8D; + parameter1 = frontEndControlCode.getAuxiliaryId(); + }else { + log.error("[辅助开关失败] 未知的指令 {}", frontEndControlCode.getCode()); + callback.run(ErrorCode.ERROR100.getCode(), "未知的指令", null); + } + } + } + frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); + }catch (Exception e) { + log.error("[辅助开关失败] ", e); + callback.run(ErrorCode.ERROR100.getCode(), e.getMessage(), null); + } + } + + @Override + public void wiper(CommonGBChannel channel, FrontEndControlCodeForWiper frontEndControlCode, ErrorCallback callback) { + try { + int cmdCode = 0; + int parameter1 = 1; + int parameter2 = 0; + int parameter3 = 0; + if (frontEndControlCode != null) { + if (frontEndControlCode.getCode() != null) { + if (frontEndControlCode.getCode() == 1) { + cmdCode = 0x8C; + } else if (frontEndControlCode.getCode() == 2) { + cmdCode = 0x8D; + }else { + log.error("[雨刷开关失败] 未知的指令 {}", frontEndControlCode.getCode()); + callback.run(ErrorCode.ERROR100.getCode(), "未知的指令", null); + } + } + } + frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); + }catch (Exception e) { + log.error("[雨刷开关失败] ", e); + callback.run(ErrorCode.ERROR100.getCode(), e.getMessage(), null); + } + } + + @Override + public void queryPreset(CommonGBChannel channel, ErrorCallback> callback) { + ptzService.queryPresetList(channel, callback); + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePlayServiceForGbImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePlayServiceForGbImpl.java index 5c9a4ed0b..0ceff47d2 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePlayServiceForGbImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePlayServiceForGbImpl.java @@ -1,22 +1,51 @@ package com.genersoft.iot.vmp.gb28181.service.impl; +import com.genersoft.iot.vmp.common.InviteSessionType; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.enums.ChannelDataType; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.Platform; +import com.genersoft.iot.vmp.gb28181.bean.PlayException; +import com.genersoft.iot.vmp.gb28181.service.IPlayService; import com.genersoft.iot.vmp.gb28181.service.ISourcePlayService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -@Service("SourcePlayService" + ChannelDataType.GB28181) +import javax.sip.message.Response; + +@Slf4j +@Service(ChannelDataType.PLAY_SERVICE + ChannelDataType.GB28181) public class SourcePlayServiceForGbImpl implements ISourcePlayService { - @Override - public void play(CommonGBChannel channel, Boolean record, ErrorCallback callback) { + @Autowired + private IPlayService deviceChannelPlayService; + @Override + public void play(CommonGBChannel channel, Platform platform, Boolean record, ErrorCallback callback) { + // 国标通道 + try { + deviceChannelPlayService.play(channel, record, callback); + } catch (PlayException e) { + callback.run(e.getCode(), e.getMsg(), null); + } catch (ControllerException e) { + log.error("[点播失败] {}({}), {}", channel.getGbName(), channel.getGbDeviceId(), e.getMsg()); + callback.run(Response.BUSY_HERE, "busy here", null); + } catch (Exception e) { + log.error("[点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + callback.run(Response.BUSY_HERE, "busy here", null); + } } @Override public void stopPlay(CommonGBChannel channel, String stream) { - + // 国标通道 + try { + deviceChannelPlayService.stop(InviteSessionType.PLAY, channel, stream); + } catch (Exception e) { + log.error("[停止点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePlaybackServiceForGbImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePlaybackServiceForGbImpl.java new file mode 100644 index 000000000..a051df437 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePlaybackServiceForGbImpl.java @@ -0,0 +1,49 @@ +package com.genersoft.iot.vmp.gb28181.service.impl; + +import com.genersoft.iot.vmp.common.InviteSessionType; +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlayException; +import com.genersoft.iot.vmp.gb28181.service.IPlayService; +import com.genersoft.iot.vmp.gb28181.service.ISourcePlaybackService; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.sip.message.Response; + +@Slf4j +@Service(ChannelDataType.PLAYBACK_SERVICE + ChannelDataType.GB28181) +public class SourcePlaybackServiceForGbImpl implements ISourcePlaybackService { + + @Autowired + private IPlayService deviceChannelPlayService; + + @Override + public void playback(CommonGBChannel channel, Long startTime, Long stopTime, ErrorCallback callback) { + try { + deviceChannelPlayService.playBack(channel, startTime, stopTime, callback); + } catch (PlayException e) { + callback.run(e.getCode(), e.getMsg(), null); + } catch (Exception e) { + callback.run(Response.BUSY_HERE, "busy here", null); + } + } + + @Override + public void stopPlayback(CommonGBChannel channel, String stream) { + // 国标通道 + try { + deviceChannelPlayService.stop(InviteSessionType.PLAYBACK, channel, stream); + } catch (Exception e) { + log.error("[停止点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + } + } + + @Override + public void playbackPause(CommonGBChannel channel, String stream) { + + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 4d252d5d2..0fffa2ac3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -16,6 +16,7 @@ import gov.nist.javax.sip.message.SIPRequest; import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; +import java.util.List; /** * @description:设备能力接口,用于定义设备的控制、查询能力 @@ -256,7 +257,7 @@ public interface ISIPCommander { * * @param device 视频设备 */ - void presetQuery(Device device, String channelId, ErrorCallback callback) throws InvalidArgumentException, SipException, ParseException; + void presetQuery(Device device, String channelId, ErrorCallback> callback) throws InvalidArgumentException, SipException, ParseException; /** * 查询移动设备位置数据 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index fcc20381f..6d405efc2 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -40,6 +40,7 @@ import javax.sip.SipFactory; import javax.sip.header.CallIdHeader; import javax.sip.message.Request; import java.text.ParseException; +import java.util.List; /** * @description:设备能力接口,用于定义设备的控制、查询能力 @@ -1118,7 +1119,7 @@ public class SIPCommander implements ISIPCommander { * @param device 视频设备 */ @Override - public void presetQuery(Device device, String channelId, ErrorCallback callback) throws InvalidArgumentException, SipException, ParseException { + public void presetQuery(Device device, String channelId, ErrorCallback> callback) throws InvalidArgumentException, SipException, ParseException { String cmdType = "PresetQuery"; int sn = (int) ((Math.random() * 9 + 1) * 100000); @@ -1136,7 +1137,7 @@ public class SIPCommander implements ISIPCommander { } cmdXml.append("\r\n"); - MessageEvent messageEvent = MessageEvent.getInstance(cmdType, sn + "", channelId, 4000L, callback); + MessageEvent> messageEvent = MessageEvent.getInstance(cmdType, sn + "", channelId, 4000L, callback); messageSubscribe.addSubscribe(messageEvent); log.info("[预置位查询] 设备编号: {}, 通道编号: {}, SN: {}", device.getDeviceId(), channelId, sn); Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 5ba83e85b..894d13f31 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -161,7 +161,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements log.error("[命令发送失败] 上级Invite TRYING: {}", e.getMessage()); } - channelPlayService.start(channel, inviteInfo, platform, ((code, msg, streamInfo) -> { + channelPlayService.startInvite(channel, inviteInfo, platform, ((code, msg, streamInfo) -> { if (code != InviteErrorCode.SUCCESS.getCode()) { try { responseAck(request, Response.BUSY_HERE , msg); @@ -247,6 +247,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } catch (SipException | InvalidArgumentException | ParseException sendException) { log.error("[命令发送失败] invite 点播失败: {}", sendException.getMessage()); } + }catch (Exception e) { + log.error("[Invite处理异常] ", e); + try { + responseAck(request, Response.SERVER_INTERNAL_ERROR, ""); + } catch (SipException | InvalidArgumentException | ParseException sendException) { + log.error("[命令发送失败] invite 点播失败: {}", sendException.getMessage()); + } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java index 8e2b42c75..02408aa8d 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java @@ -102,7 +102,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I return; } // 判断通道类型 - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 非国标通道不支持录像回放控制 log.warn("[INFO 消息] 非国标通道不支持录像回放控制: 通道ID: {}", sendRtpInfo.getChannelId()); responseAck(request, Response.FORBIDDEN, ""); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index 536bf223a..e22e136ae 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -140,7 +140,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent * 处理云台指令 */ private void handlePtzCmd(CommonGBChannel channel, Element rootElement, SIPRequest request, DeviceControlType type) { - if (channel.getDataType() == ChannelDataType.GB28181.value) { + if (channel.getDataType() == ChannelDataType.GB28181) { deviceChannelService.handlePtzCmd(channel.getDataDeviceId(), channel.getGbId(), rootElement, type, ((code, msg, data) -> { try { @@ -166,7 +166,11 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent case PTZ: channelControlService.ptz(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> { try { - responseAck(request, code, msg); + if (code == ErrorCode.SUCCESS.getCode()) { + responseAck(request, Response.OK); + }else { + responseAck(request, Response.FORBIDDEN); + } } catch (InvalidArgumentException | SipException | ParseException exception) { log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); } @@ -175,45 +179,65 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent case FI: channelControlService.fi(channel, (FrontEndControlCodeForFI) frontEndControlCode, ((code, msg, data) -> { try { - responseAck(request, code, msg); + if (code == ErrorCode.SUCCESS.getCode()) { + responseAck(request, Response.OK); + }else { + responseAck(request, Response.FORBIDDEN); + } } catch (InvalidArgumentException | SipException | ParseException exception) { - log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + log.error("[命令发送失败] FI指令: {}", exception.getMessage()); } })); break; case PRESET: channelControlService.preset(channel, (FrontEndControlCodeForPreset) frontEndControlCode, ((code, msg, data) -> { try { - responseAck(request, code, msg); + if (code == ErrorCode.SUCCESS.getCode()) { + responseAck(request, Response.OK); + }else { + responseAck(request, Response.FORBIDDEN); + } } catch (InvalidArgumentException | SipException | ParseException exception) { - log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + log.error("[命令发送失败] 预置位指令: {}", exception.getMessage()); } })); break; case TOUR: channelControlService.tour(channel, (FrontEndControlCodeForTour) frontEndControlCode, ((code, msg, data) -> { try { - responseAck(request, code, msg); + if (code == ErrorCode.SUCCESS.getCode()) { + responseAck(request, Response.OK); + }else { + responseAck(request, Response.FORBIDDEN); + } } catch (InvalidArgumentException | SipException | ParseException exception) { - log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + log.error("[命令发送失败] 巡航指令: {}", exception.getMessage()); } })); break; case SCAN: channelControlService.scan(channel, (FrontEndControlCodeForScan) frontEndControlCode, ((code, msg, data) -> { try { - responseAck(request, code, msg); + if (code == ErrorCode.SUCCESS.getCode()) { + responseAck(request, Response.OK); + }else { + responseAck(request, Response.FORBIDDEN); + } } catch (InvalidArgumentException | SipException | ParseException exception) { - log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + log.error("[命令发送失败] 扫描指令: {}", exception.getMessage()); } })); break; case AUXILIARY: channelControlService.auxiliary(channel, (FrontEndControlCodeForAuxiliary) frontEndControlCode, ((code, msg, data) -> { try { - responseAck(request, code, msg); + if (code == ErrorCode.SUCCESS.getCode()) { + responseAck(request, Response.OK); + }else { + responseAck(request, Response.FORBIDDEN); + } } catch (InvalidArgumentException | SipException | ParseException exception) { - log.error("[命令发送失败] 云台指令: {}", exception.getMessage()); + log.error("[命令发送失败] 辅助开关指令: {}", exception.getMessage()); } })); break; @@ -232,7 +256,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent * 处理强制关键帧 */ private void handleIFameCmd(CommonGBChannel channel, SIPRequest request) { - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 只支持国标的云台控制 log.warn("[INFO 消息] 只支持国标的处理强制关键帧, 通道ID: {}", channel.getGbId()); try { @@ -280,7 +304,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent * 处理重启命令 */ private void handleTeleBootCmd(CommonGBChannel channel, SIPRequest request) { - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 只支持国标的云台控制 log.warn("[INFO 消息] 只支持国标的重启命令, 通道ID: {}", channel.getGbId()); try { @@ -315,7 +339,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent * 处理拉框控制 */ private void handleDragZoom(CommonGBChannel channel, Element rootElement, SIPRequest request, DeviceControlType type) { - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 只支持国标的云台控制 log.warn("[deviceControl-DragZoom] 只支持国标的拉框控制, 通道ID: {}", channel.getGbId()); try { @@ -380,7 +404,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent * 处理看守位命令 */ private void handleHomePositionCmd(CommonGBChannel channel, Element rootElement, SIPRequest request, DeviceControlType type) { - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 只支持国标的云台控制 log.warn("[INFO 消息] 只支持国标的看守位命令, 通道ID: {}", channel.getGbId()); try { @@ -436,7 +460,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent * 处理告警消息 */ private void handleAlarmCmd(CommonGBChannel channel, Element rootElement, SIPRequest request) { - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 只支持国标的云台控制 log.warn("[INFO 消息] 只支持国标的告警消息, 通道ID: {}", channel.getGbId()); try { @@ -486,7 +510,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent * 处理录像控制 */ private void handleRecordCmd(CommonGBChannel channel, Element rootElement, SIPRequest request, DeviceControlType type) { - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 只支持国标的云台控制 log.warn("[INFO 消息] 只支持国标的息录像控制, 通道ID: {}", channel.getGbId()); try { @@ -542,7 +566,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent * 处理报警布防/撤防命令 */ private void handleGuardCmd(CommonGBChannel channel, Element rootElement, SIPRequest request, DeviceControlType type) { - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 只支持国标的云台控制 log.warn("[INFO 消息] 只支持国标的报警布防/撤防命令, 通道ID: {}", channel.getGbId()); try { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java index 71e08fe57..d1854088c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java @@ -107,7 +107,7 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp responseAck(request, Response.NOT_FOUND, "TargetID not found"); return; } - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 只支持国标的语音喊话 log.warn("[INFO 消息] 只支持国标的语音喊话命令, 通道ID: {}", channel.getGbId()); try { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java index ae4366811..648ea6771 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java @@ -94,7 +94,7 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp return; } // 判断通道类型 - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { // 非国标通道不支持录像回放控制 log.warn("[DeviceInfo] 非国标通道不支持录像回放控制: 通道ID: {}", channel.getGbId()); try { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java index ecabdcb14..f555520ad 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java @@ -105,7 +105,7 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp } return; } - if (channel.getDataType() != ChannelDataType.GB28181.value) { + if (channel.getDataType() != ChannelDataType.GB28181) { log.info("[平台查询录像记录] 只支持查询国标28181的录像数据 {}/{}", platform.getName(), channelId ); try { responseAck(request, Response.NOT_IMPLEMENTED); // 回复未实现 diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java index 9b5ecb3b3..e5ae2bc48 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcPlayService.java @@ -20,9 +20,9 @@ public interface IRedisRpcPlayService { void queryRecordInfo(String serverId, Integer channelId, String startTime, String endTime, ErrorCallback callback); - void pauseRtp(String serverId, String streamId); + void playbackPause(String serverId, String streamId); - void resumeRtp(String serverId, String streamId); + void playbackResume(String serverId, String streamId); String frontEndCommand(String serverId, Integer channelId, int cmdCode, int parameter1, int parameter2, int combindCode2); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcService.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcService.java index 549af39b7..dec5fcf9d 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/IRedisRpcService.java @@ -6,6 +6,8 @@ import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; +import java.util.List; + public interface IRedisRpcService { SendRtpInfo getSendRtpItem(String callId); @@ -63,5 +65,5 @@ public interface IRedisRpcService { WVPResult deviceInfo(String serverId, Device device); - WVPResult queryPreset(String serverId, Device device, String channelId); + WVPResult> queryPreset(String serverId, Device device, String channelId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java index 84b444084..c51f4fd55 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/control/RedisRpcChannelPlayController.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.service.redisMsg.control; -import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.common.InviteSessionType; import com.genersoft.iot.vmp.conf.UserSetting; @@ -10,9 +9,7 @@ import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest; import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; -import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.InviteMessageInfo; -import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.service.IPTZService; @@ -81,7 +78,7 @@ public class RedisRpcChannelPlayController extends RpcController { InviteMessageInfo inviteInfo = new InviteMessageInfo(); inviteInfo.setSessionName("Play"); - channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{ + channelPlayService.startInvite(channel, inviteInfo, null, (code, msg, data) ->{ if (code == InviteErrorCode.SUCCESS.getCode()) { response.setStatusCode(ErrorCode.SUCCESS.getCode()); response.setBody(data); @@ -118,7 +115,7 @@ public class RedisRpcChannelPlayController extends RpcController { response.setBody("param error"); return response; } - + try { channelService.queryRecordInfo(channel, startTime, endTime, (code, msg, data) ->{ if (code == InviteErrorCode.SUCCESS.getCode()) { @@ -134,15 +131,15 @@ public class RedisRpcChannelPlayController extends RpcController { response.setStatusCode(ErrorCode.ERROR100.getCode()); response.setBody(e.getMessage()); } - + return null; } /** * 暂停录像回放 */ - @RedisRpcMapping("pauseRtp") - public RedisRpcResponse pauseRtp(RedisRpcRequest request) { + @RedisRpcMapping("playbackPause") + public RedisRpcResponse playbackPause(RedisRpcRequest request) { String streamId = request.getParam().toString(); RedisRpcResponse response = request.getResponse(); @@ -153,7 +150,7 @@ public class RedisRpcChannelPlayController extends RpcController { } try { - channelPlayService.pauseRtp(streamId); +// channelPlayService.playbackPause(streamId); response.setStatusCode(ErrorCode.SUCCESS.getCode()); }catch (ControllerException e) { response.setStatusCode(ErrorCode.ERROR100.getCode()); @@ -166,8 +163,8 @@ public class RedisRpcChannelPlayController extends RpcController { /** * 恢复录像回放 */ - @RedisRpcMapping("resumeRtp") - public RedisRpcResponse resumeRtp(RedisRpcRequest request) { + @RedisRpcMapping("playbackResume") + public RedisRpcResponse playbackResume(RedisRpcRequest request) { String streamId = request.getParam().toString(); RedisRpcResponse response = request.getResponse(); @@ -178,7 +175,7 @@ public class RedisRpcChannelPlayController extends RpcController { } try { - channelPlayService.resumeRtp(streamId); +// channelPlayService.playbackResume(streamId); response.setStatusCode(ErrorCode.SUCCESS.getCode()); }catch (ControllerException e) { response.setStatusCode(ErrorCode.ERROR100.getCode()); @@ -216,7 +213,7 @@ public class RedisRpcChannelPlayController extends RpcController { return response; } try { - channelPlayService.stopPlay(type, channel, stream); + channelPlayService.stopInvite(type, channel, stream); response.setStatusCode(ErrorCode.SUCCESS.getCode()); }catch (Exception e){ response.setStatusCode(Response.SERVER_INTERNAL_ERROR); @@ -253,7 +250,7 @@ public class RedisRpcChannelPlayController extends RpcController { inviteInfo.setSessionName("Playback"); inviteInfo.setStartTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)); inviteInfo.setStopTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime)); - channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{ + channelPlayService.startInvite(channel, inviteInfo, null, (code, msg, data) ->{ if (code == InviteErrorCode.SUCCESS.getCode()) { response.setStatusCode(ErrorCode.SUCCESS.getCode()); response.setBody(data); @@ -296,7 +293,7 @@ public class RedisRpcChannelPlayController extends RpcController { inviteInfo.setStartTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)); inviteInfo.setStopTime(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime)); inviteInfo.setDownloadSpeed(downloadSpeed + ""); - channelPlayService.start(channel, inviteInfo, null, (code, msg, data) ->{ + channelPlayService.startInvite(channel, inviteInfo, null, (code, msg, data) ->{ if (code == InviteErrorCode.SUCCESS.getCode()) { response.setStatusCode(ErrorCode.SUCCESS.getCode()); response.setBody(data); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java index 42e171372..0e2e2e8ce 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcPlayServiceImpl.java @@ -121,8 +121,8 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { } @Override - public void pauseRtp(String serverId, String streamId) { - RedisRpcRequest request = buildRequest("channel/pauseRtp", streamId); + public void playbackPause(String serverId, String streamId) { + RedisRpcRequest request = buildRequest("channel/playbackPause", streamId); request.setToId(serverId); RedisRpcResponse response = redisRpcConfig.request(request, 5, TimeUnit.SECONDS); if (response == null) { @@ -135,8 +135,8 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService { } @Override - public void resumeRtp(String serverId, String streamId) { - RedisRpcRequest request = buildRequest("channel/resumeRtp", streamId); + public void playbackResume(String serverId, String streamId) { + RedisRpcRequest request = buildRequest("channel/playbackResume", streamId); request.setToId(serverId); RedisRpcResponse response = redisRpcConfig.request(request, 5, TimeUnit.SECONDS); if (response == null) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcServiceImpl.java index 531ef6aaf..408380fe4 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/service/RedisRpcServiceImpl.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import java.util.List; import java.util.concurrent.TimeUnit; @Slf4j @@ -406,7 +407,7 @@ public class RedisRpcServiceImpl implements IRedisRpcService { } @Override - public WVPResult queryPreset(String serverId, Device device, String channelId) { + public WVPResult> queryPreset(String serverId, Device device, String channelId) { JSONObject jsonObject = new JSONObject(); jsonObject.put("device", device.getDeviceId()); jsonObject.put("channelId", channelId); diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java index 61f6e6553..4f9e5e91c 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java @@ -79,7 +79,7 @@ public class StreamProxy extends CommonGBChannel { if (ObjectUtils.isEmpty(this.getGbName())) { this.setGbName( app+ "-" +stream); } - this.setDataType(ChannelDataType.STREAM_PROXY.value); + this.setDataType(ChannelDataType.STREAM_PROXY); this.setDataDeviceId(this.getId()); return this; } diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/provider/StreamProxyProvider.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/provider/StreamProxyProvider.java index 968a74b70..e61c710a7 100644 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/provider/StreamProxyProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/provider/StreamProxyProvider.java @@ -9,7 +9,7 @@ public class StreamProxyProvider { public String getBaseSelectSql(){ return "SELECT " + " st.*, " + - ChannelDataType.STREAM_PROXY.value + " as data_type, " + + ChannelDataType.STREAM_PROXY + " as data_type, " + " st.id as data_device_id, " + " wdc.*, " + " wdc.id as gb_id" + diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/SourcePlayServiceForStreamProxyImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/SourcePlayServiceForStreamProxyImpl.java new file mode 100644 index 000000000..899356960 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/SourcePlayServiceForStreamProxyImpl.java @@ -0,0 +1,42 @@ +package com.genersoft.iot.vmp.streamProxy.service.impl; + +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.Platform; +import com.genersoft.iot.vmp.gb28181.service.ISourcePlayService; +import com.genersoft.iot.vmp.service.bean.ErrorCallback; +import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyPlayService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.sip.message.Response; + +@Slf4j +@Service(ChannelDataType.PLAY_SERVICE + ChannelDataType.STREAM_PROXY) +public class SourcePlayServiceForStreamProxyImpl implements ISourcePlayService { + + @Autowired + private IStreamProxyPlayService playService; + + @Override + public void play(CommonGBChannel channel, Platform platform, Boolean record, ErrorCallback callback) { + // 拉流代理通道 + try { + playService.start(channel.getDataDeviceId(), record, callback); + }catch (Exception e) { + callback.run(Response.BUSY_HERE, "busy here", null); + } + } + + @Override + public void stopPlay(CommonGBChannel channel, String stream) { + // 拉流代理通道 + try { + playService.stop(channel.getDataDeviceId()); + }catch (Exception e) { + log.error("[停止点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + } + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java index b6d8261b3..54cf8a4ca 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java @@ -179,7 +179,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { streamProxy.setCreateTime(DateUtil.getNow()); streamProxy.setUpdateTime(DateUtil.getNow()); streamProxyMapper.add(streamProxy); - streamProxy.setDataType(ChannelDataType.STREAM_PROXY.value); + streamProxy.setDataType(ChannelDataType.STREAM_PROXY); streamProxy.setDataDeviceId(streamProxy.getId()); } diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java index 7ae700471..6e460d8fb 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java @@ -105,7 +105,7 @@ public class StreamPush extends CommonGBChannel implements Comparable callback) { + String serverGBId = null; + String platformName = null; + if (platform != null) { + // 推流 + serverGBId = platform.getServerGBId(); + platformName = platform.getName(); + } + // 推流 + try { + playService.start(channel.getDataDeviceId(), callback, serverGBId, platformName); + }catch (PlayException e) { + callback.run(e.getCode(), e.getMsg(), null); + }catch (Exception e) { + log.error("[点播推流通道失败] 通道: {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + callback.run(Response.BUSY_HERE, "busy here", null); + } + } + + @Override + public void stopPlay(CommonGBChannel channel, String stream) { + // 推流 + try { + playService.stop(channel.getDataDeviceId()); + }catch (Exception e) { + log.error("[停止点播失败] {}({})", channel.getGbName(), channel.getGbDeviceId(), e); + } + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java index ee2f9da4a..5d2bc5f4b 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.common.SystemAllInfo; import com.genersoft.iot.vmp.common.VersionPo; -import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.VersionInfo; @@ -45,7 +44,10 @@ import oshi.software.os.OperatingSystem; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.text.DecimalFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; @SuppressWarnings("rawtypes") @Tag(name = "服务控制") @@ -334,21 +336,6 @@ public class ServerController { return result; } - @GetMapping(value = "/channel/datatype") - @ResponseBody - @Operation(summary = "获取系统接入的数据类型", security = @SecurityRequirement(name = JwtUtils.HEADER)) - public List> getDataType() { - List> result = new LinkedList<>(); - Map descMap = ChannelDataType.getDescMap(); - for (String key : descMap.keySet()) { - Map map = new LinkedHashMap<>(); - map.put("key", key); - map.put("value", descMap.get(key)); - result.add(map); - } - return result; - } - /** * 单位转换 */ diff --git a/web/src/api/commonChannel.js b/web/src/api/commonChannel.js index 0d613547a..ff32d17db 100644 --- a/web/src/api/commonChannel.js +++ b/web/src/api/commonChannel.js @@ -463,15 +463,15 @@ export function wiper({ channelId, command }) { }) } -export function ptz({ channelId, command, horizonSpeed, verticalSpeed, zoomSpeed }) { +export function ptz({ channelId, command, panSpeed, tiltSpeed, zoomSpeed }) { return request({ method: 'get', url: '/api/common/channel/front-end/ptz', params: { channelId: channelId, command: command, - horizonSpeed: horizonSpeed, - verticalSpeed: verticalSpeed, + panSpeed: panSpeed, + tiltSpeed: tiltSpeed, zoomSpeed: zoomSpeed } }) diff --git a/web/src/views/common/channelPlayer/index.vue b/web/src/views/common/channelPlayer/index.vue index 89cebde0d..c1ac34fb4 100755 --- a/web/src/views/common/channelPlayer/index.vue +++ b/web/src/views/common/channelPlayer/index.vue @@ -535,29 +535,29 @@ export default { ptzCamera: function(command) { console.log('云台控制:' + command) this.$store.dispatch('commonChanel/ptz', - [ - this.channelId, - command, - parseInt(this.controSpeed * 255 / 100), - parseInt(this.controSpeed * 255 / 100), - parseInt(this.controSpeed * 16 / 100) - ]) + { + channelId: this.channelId, + command: command, + panSpeed: this.controSpeed, + tiltSpeed: this.controSpeed, + zoomSpeed: this.controSpeed + }) }, irisCamera: function(command) { this.$store.dispatch('commonChanel/iris', - [ - this.channelId, - command, - parseInt(this.controSpeed * 255 / 100) - ]) + { + channelId: this.channelId, + command: command, + speed: this.controSpeed + }) }, focusCamera: function(command) { this.$store.dispatch('commonChanel/focus', - [ - this.channelId, - command, - parseInt(this.controSpeed * 255 / 100) - ]) + { + channelId: this.channelId, + command: command, + speed: this.controSpeed + }) }, // ////////////////////播放器事件处理////////////////////////// videoError: function(e) {