diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTDeviceConfig.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTDeviceConfig.java index a8a37edb1..ad3bdc4e2 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTDeviceConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTDeviceConfig.java @@ -217,6 +217,15 @@ public class JTDeviceConfig { @ConfigAttribute(id = 0x76, type="ChannelListParam", description = "音视频通道列表设置") private ChannelListParam channelListParam; + @ConfigAttribute(id = 0x77, type="ChannelParam", description = "音视频通道列表设置") + private ChannelParam channelParam; + + @ConfigAttribute(id = 0x79, type="AlarmRecordingParam", description = "特殊报警录像参数设置") + private AlarmRecordingParam alarmRecordingParam; + + @ConfigAttribute(id = 0x79, type="VideoAlarmBit", description = "视频相关报警屏蔽字") + private VideoAlarmBit videoAlarmBit; + @ConfigAttribute(id = 0x80, type="Long", description = "车辆里程表读数,单位'1/10km") private Long mileage; @@ -946,6 +955,22 @@ public class JTDeviceConfig { this.channelListParam = channelListParam; } + public ChannelParam getChannelParam() { + return channelParam; + } + + public void setChannelParam(ChannelParam channelParam) { + this.channelParam = channelParam; + } + + public AlarmRecordingParam getAlarmRecordingParam() { + return alarmRecordingParam; + } + + public void setAlarmRecordingParam(AlarmRecordingParam alarmRecordingParam) { + this.alarmRecordingParam = alarmRecordingParam; + } + @Override public String toString() { return "JTDeviceConfig{" + diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/AlarmRecordingParam.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/AlarmRecordingParam.java new file mode 100644 index 000000000..d2dcb07dd --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/AlarmRecordingParam.java @@ -0,0 +1,66 @@ +package com.genersoft.iot.vmp.jt1078.bean.config; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +/** + * 特殊报警录像参数 + */ +public class AlarmRecordingParam implements JTDeviceSubConfig{ + + /** + * 特殊报警录像存储阈值, 分比,取值 特殊报警录像占用主存储器存储阈值百 1 ~ 99,默认值为 20 + */ + private int storageLimit; + + /** + * 特殊报警录像持续时间,特殊报警录像的最长持续时间,单位为分钟(min) ,默认值为 5 + */ + private int duration; + + /** + * 特殊报警标识起始时间, 特殊报警发生前进行标记的录像时间, 单位为分钟( min) ,默认值为 1 + */ + private int startTime; + + public int getStorageLimit() { + return storageLimit; + } + + public void setStorageLimit(int storageLimit) { + this.storageLimit = storageLimit; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public int getStartTime() { + return startTime; + } + + public void setStartTime(int startTime) { + this.startTime = startTime; + } + + @Override + public ByteBuf encode() { + ByteBuf byteBuf = Unpooled.buffer(); + byteBuf.writeByte(storageLimit); + byteBuf.writeByte(duration); + byteBuf.writeByte(startTime); + return byteBuf; + } + + public static AlarmRecordingParam decode(ByteBuf byteBuf) { + AlarmRecordingParam alarmRecordingParam = new AlarmRecordingParam(); + alarmRecordingParam.setStorageLimit(byteBuf.readUnsignedByte()); + alarmRecordingParam.setDuration(byteBuf.readUnsignedByte()); + alarmRecordingParam.setStartTime(byteBuf.readUnsignedByte()); + return alarmRecordingParam; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/ChannelParam.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/ChannelParam.java new file mode 100644 index 000000000..92d4dcd90 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/ChannelParam.java @@ -0,0 +1,47 @@ +package com.genersoft.iot.vmp.jt1078.bean.config; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +import java.util.ArrayList; +import java.util.List; + +/** + * 单独视频通道参数设置 + */ +public class ChannelParam implements JTDeviceSubConfig { + + /** + * 单独通道视频参数设置列表 + */ + private List jtAloneChanelList; + + public List getJtAloneChanelList() { + return jtAloneChanelList; + } + + public void setJtAloneChanelList(List jtAloneChanelList) { + this.jtAloneChanelList = jtAloneChanelList; + } + + @Override + public ByteBuf encode() { + ByteBuf byteBuf = Unpooled.buffer(); + byteBuf.writeByte(jtAloneChanelList.size()); + for (JTAloneChanel jtAloneChanel : jtAloneChanelList) { + byteBuf.writeBytes(jtAloneChanel.encode()); + } + return byteBuf; + } + + public static ChannelParam decode(ByteBuf byteBuf) { + ChannelParam channelParam = new ChannelParam(); + int length = byteBuf.readUnsignedByte(); + List jtAloneChanelList = new ArrayList<>(length); + for (int i = 0; i < length; i++) { + jtAloneChanelList.add(JTAloneChanel.decode(byteBuf)); + } + channelParam.setJtAloneChanelList(jtAloneChanelList); + return channelParam; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/JTAloneChanel.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/JTAloneChanel.java new file mode 100644 index 000000000..aafda5584 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/JTAloneChanel.java @@ -0,0 +1,228 @@ +package com.genersoft.iot.vmp.jt1078.bean.config; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +/** + * 单独通道视频 + */ +public class JTAloneChanel implements JTDeviceSubConfig{ + + /** + * 逻辑通道号 + */ + private int logicChannelId; + + /** + * 实时流编码模式 + * 0:CBR( 固定码率) ; + * 1:VBR( 可变码率) ; + * 2:ABR( 平均码率) ; + * 100 ~ 127:自定义 + */ + private int liveStreamCodeRateType; + + /** + * 实时流分辨率 + * 0:QCIF; + * 1:CIF; + * 2:WCIF; + * 3:D1; + * 4:WD1; + * 5:720P; + * 6:1 080P; + * 100 ~ 127:自定义 + */ + private int liveStreamResolving; + + /** + * 实时流关键帧间隔, 范围(1 ~ 1 000) 帧 + */ + private int liveStreamIInterval; + + /** + * 实时流目标帧率,范围(1 ~ 120) 帧 / s + */ + private int liveStreamFrameRate; + + /** + * 实时流目标码率,单位为千位每秒( kbps) + */ + private long liveStreamCodeRate; + + + /** + * 存储流编码模式 + * 0:CBR( 固定码率) ; + * 1:VBR( 可变码率) ; + * 2:ABR( 平均码率) ; + * 100 ~ 127:自定义 + */ + private int storageStreamCodeRateType; + + /** + * 存储流分辨率 + * 0:QCIF; + * 1:CIF; + * 2:WCIF; + * 3:D1; + * 4:WD1; + * 5:720P; + * 6:1 080P; + * 100 ~ 127:自定义 + */ + private int storageStreamResolving; + + /** + * 存储流关键帧间隔, 范围(1 ~ 1 000) 帧 + */ + private int storageStreamIInterval; + + /** + * 存储流目标帧率,范围(1 ~ 120) 帧 / s + */ + private int storageStreamFrameRate; + + /** + * 存储流目标码率,单位为千位每秒( kbps) + */ + private long storageStreamCodeRate; + + /** + * 字幕叠加设置 + */ + private OSDConfig osd; + + public int getLogicChannelId() { + return logicChannelId; + } + + public void setLogicChannelId(int logicChannelId) { + this.logicChannelId = logicChannelId; + } + + public int getLiveStreamCodeRateType() { + return liveStreamCodeRateType; + } + + public void setLiveStreamCodeRateType(int liveStreamCodeRateType) { + this.liveStreamCodeRateType = liveStreamCodeRateType; + } + + public int getLiveStreamResolving() { + return liveStreamResolving; + } + + public void setLiveStreamResolving(int liveStreamResolving) { + this.liveStreamResolving = liveStreamResolving; + } + + public int getLiveStreamIInterval() { + return liveStreamIInterval; + } + + public void setLiveStreamIInterval(int liveStreamIInterval) { + this.liveStreamIInterval = liveStreamIInterval; + } + + public int getLiveStreamFrameRate() { + return liveStreamFrameRate; + } + + public void setLiveStreamFrameRate(int liveStreamFrameRate) { + this.liveStreamFrameRate = liveStreamFrameRate; + } + + public long getLiveStreamCodeRate() { + return liveStreamCodeRate; + } + + public void setLiveStreamCodeRate(long liveStreamCodeRate) { + this.liveStreamCodeRate = liveStreamCodeRate; + } + + public int getStorageStreamCodeRateType() { + return storageStreamCodeRateType; + } + + public void setStorageStreamCodeRateType(int storageStreamCodeRateType) { + this.storageStreamCodeRateType = storageStreamCodeRateType; + } + + public int getStorageStreamResolving() { + return storageStreamResolving; + } + + public void setStorageStreamResolving(int storageStreamResolving) { + this.storageStreamResolving = storageStreamResolving; + } + + public int getStorageStreamIInterval() { + return storageStreamIInterval; + } + + public void setStorageStreamIInterval(int storageStreamIInterval) { + this.storageStreamIInterval = storageStreamIInterval; + } + + public int getStorageStreamFrameRate() { + return storageStreamFrameRate; + } + + public void setStorageStreamFrameRate(int storageStreamFrameRate) { + this.storageStreamFrameRate = storageStreamFrameRate; + } + + public long getStorageStreamCodeRate() { + return storageStreamCodeRate; + } + + public void setStorageStreamCodeRate(long storageStreamCodeRate) { + this.storageStreamCodeRate = storageStreamCodeRate; + } + + public OSDConfig getOsd() { + return osd; + } + + public void setOsd(OSDConfig osd) { + this.osd = osd; + } + + @Override + public ByteBuf encode() { + ByteBuf byteBuf = Unpooled.buffer(); + byteBuf.writeByte(logicChannelId); + byteBuf.writeByte(liveStreamCodeRateType); + byteBuf.writeByte(liveStreamResolving); + byteBuf.writeShort((short)(liveStreamIInterval & 0xffff)); + byteBuf.writeByte(liveStreamFrameRate); + byteBuf.writeInt((int) (liveStreamCodeRate & 0xffffffffL)); + + byteBuf.writeByte(storageStreamCodeRateType); + byteBuf.writeByte(storageStreamResolving); + byteBuf.writeShort((short)(storageStreamIInterval & 0xffff)); + byteBuf.writeByte(storageStreamFrameRate); + byteBuf.writeInt((int) (storageStreamCodeRate & 0xffffffffL)); + byteBuf.writeBytes(osd.encode()); + return byteBuf; + } + + public static JTAloneChanel decode(ByteBuf buf) { + JTAloneChanel jtAloneChanel = new JTAloneChanel(); + jtAloneChanel.setLogicChannelId(buf.readByte()); + jtAloneChanel.setLiveStreamCodeRateType(buf.readByte()); + jtAloneChanel.setLiveStreamResolving(buf.readByte()); + jtAloneChanel.setLiveStreamIInterval(buf.readUnsignedShort()); + jtAloneChanel.setLiveStreamFrameRate(buf.readByte()); + jtAloneChanel.setLiveStreamCodeRate(buf.readUnsignedInt()); + + jtAloneChanel.setStorageStreamCodeRateType(buf.readByte()); + jtAloneChanel.setStorageStreamResolving(buf.readByte()); + jtAloneChanel.setStorageStreamIInterval(buf.readUnsignedShort()); + jtAloneChanel.setStorageStreamFrameRate(buf.readByte()); + jtAloneChanel.setStorageStreamCodeRate(buf.readUnsignedInt()); + jtAloneChanel.setOsd(OSDConfig.decode(buf)); + return null; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/JTChanel.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/JTChanel.java index ebc1868e2..ef2d040fb 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/JTChanel.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/JTChanel.java @@ -11,7 +11,7 @@ import java.util.Stack; public class JTChanel implements JTDeviceSubConfig{ /** - * 物理通道号 + * 物理通道号 单独 */ private int physicalChannelId; diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/VideoAlarmBit.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/VideoAlarmBit.java new file mode 100644 index 000000000..ada8514bd --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/config/VideoAlarmBit.java @@ -0,0 +1,143 @@ +package com.genersoft.iot.vmp.jt1078.bean.config; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +/** + * 视频报警标志位 + */ +public class VideoAlarmBit implements JTDeviceSubConfig{ + + /** + * 视频信号丢失报警 + */ + private boolean lossSignal; + /** + * 视频信号遮挡报警 + */ + private boolean occlusionSignal; + /** + * 存储单元故障报警 + */ + private boolean storageFault; + /** + * 其他视频设备故障报警 + */ + private boolean otherDeviceFailure; + /** + * 客车超员报警 + */ + private boolean overcrowding; + /** + * 异常驾驶行为报警 + */ + private boolean abnormalDriving; + /** + * 特殊报警录像达到存储阈值报警 + */ + private boolean storageLimit; + + public boolean isLossSignal() { + return lossSignal; + } + + public void setLossSignal(boolean lossSignal) { + this.lossSignal = lossSignal; + } + + public boolean isOcclusionSignal() { + return occlusionSignal; + } + + public void setOcclusionSignal(boolean occlusionSignal) { + this.occlusionSignal = occlusionSignal; + } + + public boolean isStorageFault() { + return storageFault; + } + + public void setStorageFault(boolean storageFault) { + this.storageFault = storageFault; + } + + public boolean isOtherDeviceFailure() { + return otherDeviceFailure; + } + + public void setOtherDeviceFailure(boolean otherDeviceFailure) { + this.otherDeviceFailure = otherDeviceFailure; + } + + public boolean isOvercrowding() { + return overcrowding; + } + + public void setOvercrowding(boolean overcrowding) { + this.overcrowding = overcrowding; + } + + public boolean isAbnormalDriving() { + return abnormalDriving; + } + + public void setAbnormalDriving(boolean abnormalDriving) { + this.abnormalDriving = abnormalDriving; + } + + public boolean isStorageLimit() { + return storageLimit; + } + + public void setStorageLimit(boolean storageLimit) { + this.storageLimit = storageLimit; + } + + @Override + public ByteBuf encode() { + ByteBuf byteBuf = Unpooled.buffer(); + byte content = 0; + if (lossSignal) { + content = content |= 1; + } + if (occlusionSignal) { + content = content |= (1 << 1); + } + if (storageFault) { + content = content |= (1 << 2); + } + if (otherDeviceFailure) { + content = content |= (1 << 3); + } + if (overcrowding) { + content = content |= (1 << 4); + } + if (abnormalDriving) { + content = content |= (1 << 5); + } + if (storageLimit) { + content = content |= (1 << 6); + } + byteBuf.writeByte(content); + byteBuf.writeByte(0); + byteBuf.writeByte(0); + byteBuf.writeByte(0); + return byteBuf; + } + + public static VideoAlarmBit decode(ByteBuf byteBuf) { + VideoAlarmBit videoAlarmBit = new VideoAlarmBit(); + byte content = byteBuf.readByte(); + videoAlarmBit.setLossSignal((content & 1) == 1); + videoAlarmBit.setOcclusionSignal((content >>> 1 & 1) == 1); + videoAlarmBit.setStorageFault((content >>> 2 & 1) == 1); + videoAlarmBit.setOtherDeviceFailure((content >>> 3 & 1) == 1); + videoAlarmBit.setOvercrowding((content >>> 4 & 1) == 1); + videoAlarmBit.setAbnormalDriving((content >>> 5 & 1) == 1); + videoAlarmBit.setStorageLimit((content >>> 6 & 1) == 1); + byteBuf.readByte(); + byteBuf.readByte(); + byteBuf.readByte(); + return videoAlarmBit; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0104.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0104.java index 1c316df1c..aba37dea1 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0104.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/request/J0104.java @@ -135,6 +135,20 @@ public class J0104 extends Re { ChannelListParam channelListParam = ChannelListParam.decode(buf); Method methodForChannelListParam = deviceConfig.getClass().getDeclaredMethod("set" + StringUtils.capitalize(field.getName()), ChannelListParam.class); methodForChannelListParam.invoke(deviceConfig, channelListParam); + case "ChannelParam": + ChannelParam channelParam = ChannelParam.decode(buf); + Method methodForChannelParam = deviceConfig.getClass().getDeclaredMethod("set" + StringUtils.capitalize(field.getName()), ChannelParam.class); + methodForChannelParam.invoke(deviceConfig, channelParam); + continue; + case "alarmRecordingParam": + AlarmRecordingParam alarmRecordingParam = AlarmRecordingParam.decode(buf); + Method methodForAlarmRecordingParam = deviceConfig.getClass().getDeclaredMethod("set" + StringUtils.capitalize(field.getName()), AlarmRecordingParam.class); + methodForAlarmRecordingParam.invoke(deviceConfig, alarmRecordingParam); + continue; + case "VideoAlarmBit": + VideoAlarmBit videoAlarmBit = VideoAlarmBit.decode(buf); + Method methodForVideoAlarmBit = deviceConfig.getClass().getDeclaredMethod("set" + StringUtils.capitalize(field.getName()), VideoAlarmBit.class); + methodForVideoAlarmBit.invoke(deviceConfig, videoAlarmBit); continue; default: System.err.println(field.getGenericType().getTypeName()); diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java index adb56f154..f7aad5bf1 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java @@ -90,6 +90,10 @@ public class J8103 extends Rs { case "GnssPositioningMode": case "VideoParam": case "ChannelListParam": + case "ChannelParam": + case "AlarmRecordingParam": + case "AlarmShielding": + case "VideoAlarmBit": field.setAccessible(true); JTDeviceSubConfig subConfig = (JTDeviceSubConfig)field.get(config); ByteBuf bytesForIllegalDrivingPeriods = subConfig.encode();