1078-音视频参数设置+音视频通道列表设置

This commit is contained in:
648540858
2024-05-21 23:56:51 +08:00
parent e085258d74
commit 82ab524fc4
12 changed files with 595 additions and 19 deletions

View File

@@ -1,10 +1,7 @@
package com.genersoft.iot.vmp.jt1078.bean;
import com.genersoft.iot.vmp.jt1078.bean.common.ConfigAttribute;
import com.genersoft.iot.vmp.jt1078.bean.config.CollisionAlarmParams;
import com.genersoft.iot.vmp.jt1078.bean.config.GnssPositioningMode;
import com.genersoft.iot.vmp.jt1078.bean.config.IllegalDrivingPeriods;
import com.genersoft.iot.vmp.jt1078.bean.config.CameraTimer;
import com.genersoft.iot.vmp.jt1078.bean.config.*;
import io.swagger.v3.oas.annotations.media.Schema;
/**
@@ -214,6 +211,12 @@ public class JTDeviceConfig {
@ConfigAttribute(id = 0x74, type="Long", description = "色度设置范围为0 ~ 255")
private Long chroma;
@ConfigAttribute(id = 0x75, type="VideoParam", description = "音视频参数设置")
private VideoParam videoParam;
@ConfigAttribute(id = 0x76, type="ChannelListParam", description = "音视频通道列表设置")
private ChannelListParam channelListParam;
@ConfigAttribute(id = 0x80, type="Long", description = "车辆里程表读数,单位'1/10km")
private Long mileage;

View File

@@ -1,5 +1,8 @@
package com.genersoft.iot.vmp.jt1078.bean.config;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
/**
* 定时拍照控制
*/
@@ -157,7 +160,8 @@ public class CameraTimer implements JTDeviceSubConfig{
}
@Override
public byte[] encode() {
public ByteBuf encode() {
ByteBuf byteBuf = Unpooled.buffer();
byte[] bytes = new byte[4];
bytes[0] = 0;
if (switchForChannel1) {
@@ -195,6 +199,7 @@ public class CameraTimer implements JTDeviceSubConfig{
if (timeUnit) {
bytes[3] = (byte)(bytes[3] | 1);
}
return bytes;
byteBuf.writeBytes(bytes);
return byteBuf;
}
}

View File

@@ -0,0 +1,89 @@
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 ChannelListParam implements JTDeviceSubConfig{
/**
* 音视频通道总数
*/
private int videoAndAudioCount;
/**
* 音频通道总数
*/
private int audioCount;
/**
* 视频通道总数
*/
private int videoCount;
private List<JTChanel> chanelList;
public int getVideoAndAudioCount() {
return videoAndAudioCount;
}
public void setVideoAndAudioCount(int videoAndAudioCount) {
this.videoAndAudioCount = videoAndAudioCount;
}
public int getAudioCount() {
return audioCount;
}
public void setAudioCount(int audioCount) {
this.audioCount = audioCount;
}
public int getVideoCount() {
return videoCount;
}
public void setVideoCount(int videoCount) {
this.videoCount = videoCount;
}
public List<JTChanel> getChanelList() {
return chanelList;
}
public void setChanelList(List<JTChanel> chanelList) {
this.chanelList = chanelList;
}
@Override
public ByteBuf encode() {
ByteBuf byteBuf = Unpooled.buffer();
byteBuf.writeByte(videoAndAudioCount);
byteBuf.writeByte(audioCount);
byteBuf.writeByte(videoCount);
for (JTChanel jtChanel : chanelList) {
byteBuf.writeBytes(jtChanel.encode());
}
return byteBuf;
}
public static ChannelListParam decode(ByteBuf byteBuf) {
ChannelListParam channelListParam = new ChannelListParam();
channelListParam.setVideoAndAudioCount(byteBuf.readUnsignedByte());
channelListParam.setAudioCount(byteBuf.readUnsignedByte());
channelListParam.setVideoCount(byteBuf.readUnsignedByte());
int total = channelListParam.getVideoAndAudioCount() + channelListParam.getVideoCount() + channelListParam.getAudioCount();
List<JTChanel> chanelList = new ArrayList<>(total);
for (int i = 0; i < total; i++) {
chanelList.add(JTChanel.decode(byteBuf));
}
channelListParam.setChanelList(chanelList);
return channelListParam;
}
}

View File

@@ -1,5 +1,8 @@
package com.genersoft.iot.vmp.jt1078.bean.config;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
/**
* 碰撞报警参数设置
*/
@@ -32,10 +35,12 @@ public class CollisionAlarmParams implements JTDeviceSubConfig{
}
@Override
public byte[] encode() {
public ByteBuf encode() {
ByteBuf byteBuf = Unpooled.buffer();
byte[] bytes = new byte[2];
bytes[0] = (byte) (collisionAlarmTime & 0xff);
bytes[1] = (byte) (collisionAcceleration & 0xff);
return bytes;
byteBuf.writeBytes(bytes);
return byteBuf;
}
}

View File

@@ -1,5 +1,8 @@
package com.genersoft.iot.vmp.jt1078.bean.config;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
/**
* GNSS 定位模式
*/
@@ -55,7 +58,8 @@ public class GnssPositioningMode implements JTDeviceSubConfig{
}
@Override
public byte[] encode() {
public ByteBuf encode() {
ByteBuf byteBuf = Unpooled.buffer();
byte[] bytes = new byte[1];
bytes[0] = 0;
if (gps) {
@@ -70,6 +74,7 @@ public class GnssPositioningMode implements JTDeviceSubConfig{
if (gaLiLeo) {
bytes[0] = (byte)(bytes[0] | 8);
}
return bytes;
byteBuf.writeBytes(bytes);
return byteBuf;
}
}

View File

@@ -1,5 +1,8 @@
package com.genersoft.iot.vmp.jt1078.bean.config;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
/**
* 违规行驶时段范围 ,精确到分
*/
@@ -31,7 +34,8 @@ public class IllegalDrivingPeriods implements JTDeviceSubConfig{
}
@Override
public byte[] encode() {
public ByteBuf encode() {
ByteBuf byteBuf = Unpooled.buffer();
byte[] bytes = new byte[4];
String[] startTimeArray = startTime.split(":");
String[] endTimeArray = endTime.split(":");
@@ -39,6 +43,7 @@ public class IllegalDrivingPeriods implements JTDeviceSubConfig{
bytes[1] = (byte)Integer.parseInt(startTimeArray[1]);
bytes[2] = (byte)Integer.parseInt(endTimeArray[0]);
bytes[3] = (byte)Integer.parseInt(endTimeArray[1]);
return bytes;
byteBuf.writeBytes(bytes);
return byteBuf;
}
}

View File

@@ -0,0 +1,86 @@
package com.genersoft.iot.vmp.jt1078.bean.config;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Stack;
/**
* 音视频通道
*/
public class JTChanel implements JTDeviceSubConfig{
/**
* 物理通道号
*/
private int physicalChannelId;
/**
* 逻辑通道号
*/
private int logicChannelId;
/**
* 通道类型:
* 0:音视频;
* 1:音频
* 2:视频
*/
private int channelType;
/**
* 是否连接云台: 通道类型为 0 和 2 时,此字段有效
* 0:未连接;1:连接
*/
private int ptzEnable;
public int getPhysicalChannelId() {
return physicalChannelId;
}
public void setPhysicalChannelId(int physicalChannelId) {
this.physicalChannelId = physicalChannelId;
}
public int getLogicChannelId() {
return logicChannelId;
}
public void setLogicChannelId(int logicChannelId) {
this.logicChannelId = logicChannelId;
}
public int getChannelType() {
return channelType;
}
public void setChannelType(int channelType) {
this.channelType = channelType;
}
public int getPtzEnable() {
return ptzEnable;
}
public void setPtzEnable(int ptzEnable) {
this.ptzEnable = ptzEnable;
}
@Override
public ByteBuf encode() {
ByteBuf byteBuf = Unpooled.buffer();
byteBuf.writeByte(physicalChannelId);
byteBuf.writeByte(logicChannelId);
byteBuf.writeByte(channelType);
byteBuf.writeByte(ptzEnable);
return byteBuf;
}
public static JTChanel decode(ByteBuf byteBuf) {
JTChanel jtChanel = new JTChanel();
jtChanel.setPhysicalChannelId(byteBuf.readUnsignedByte());
jtChanel.setLogicChannelId(byteBuf.readUnsignedByte());
jtChanel.setChannelType(byteBuf.readUnsignedByte());
jtChanel.setPtzEnable(byteBuf.readUnsignedByte());
return jtChanel;
}
}

View File

@@ -1,5 +1,8 @@
package com.genersoft.iot.vmp.jt1078.bean.config;
import io.netty.buffer.ByteBuf;
public interface JTDeviceSubConfig {
byte[] encode();
ByteBuf encode();
}

View File

@@ -0,0 +1,144 @@
package com.genersoft.iot.vmp.jt1078.bean.config;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
/**
* OSD字幕叠加设置
*/
public class OSDConfig {
/**
* 日期和时间
*/
private boolean time;
/**
* 车牌号码
*/
private boolean licensePlate;
/**
* 逻辑通道号
*/
private boolean channelId;
/**
* 经纬度
*/
private boolean position;
/**
* 行驶记录速度
*/
private boolean speed;
/**
* 卫星定位速度
*/
private boolean speedForGPS;
/**
* 连续驾驶时间
*/
private boolean drivingTime;
public boolean isTime() {
return time;
}
public void setTime(boolean time) {
this.time = time;
}
public boolean isLicensePlate() {
return licensePlate;
}
public void setLicensePlate(boolean licensePlate) {
this.licensePlate = licensePlate;
}
public boolean isChannelId() {
return channelId;
}
public void setChannelId(boolean channelId) {
this.channelId = channelId;
}
public boolean isPosition() {
return position;
}
public void setPosition(boolean position) {
this.position = position;
}
public boolean isSpeed() {
return speed;
}
public void setSpeed(boolean speed) {
this.speed = speed;
}
public boolean isSpeedForGPS() {
return speedForGPS;
}
public void setSpeedForGPS(boolean speedForGPS) {
this.speedForGPS = speedForGPS;
}
public boolean isDrivingTime() {
return drivingTime;
}
public void setDrivingTime(boolean drivingTime) {
this.drivingTime = drivingTime;
}
public ByteBuf encode(){
ByteBuf byteBuf = Unpooled.buffer();
byte content = 0;
if (time) {
content = (byte)(content | 1);
}
if (licensePlate) {
content = (byte)(content | (1 << 1));
}
if (channelId) {
content = (byte)(content | (1 << 2));
}
if (position) {
content = (byte)(content | (1 << 3));
}
if (speed) {
content = (byte)(content | (1 << 4));
}
if (speedForGPS) {
content = (byte)(content | (1 << 5));
}
if (drivingTime) {
content = (byte)(content | (1 << 6));
}
byteBuf.writeByte(content);
byteBuf.writeByte(0);
return byteBuf;
}
public static OSDConfig decode(ByteBuf buf) {
OSDConfig config = new OSDConfig();
int content = buf.readUnsignedShort();
config.setTime((content & 1) == 1);
config.setLicensePlate((content >>> 1 & 1) == 1);
config.setChannelId((content >>> 2 & 1) == 1);
config.setPosition((content >>> 3 & 1) == 1);
config.setSpeed((content >>> 4 & 1) == 1);
config.setSpeedForGPS((content >>> 5 & 1) == 1);
config.setDrivingTime((content >>> 6 & 1) == 1);
return config;
}
}

View File

@@ -0,0 +1,228 @@
package com.genersoft.iot.vmp.jt1078.bean.config;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
/**
* 违规行驶时段范围 ,精确到分
*/
public class VideoParam implements JTDeviceSubConfig{
/**
* 实时流编码模式
* 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;
/**
* 是否启用音频输出, 0:不启用;1:启用
*/
private int audioEnable;
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;
}
public int getAudioEnable() {
return audioEnable;
}
public void setAudioEnable(int audioEnable) {
this.audioEnable = audioEnable;
}
@Override
public ByteBuf encode() {
ByteBuf byteBuf = Unpooled.buffer();
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());
byteBuf.writeByte(audioEnable);
return byteBuf;
}
public static VideoParam decode(ByteBuf buf) {
VideoParam videoParam = new VideoParam();
videoParam.setLiveStreamCodeRateType(buf.readByte());
videoParam.setLiveStreamResolving(buf.readByte());
videoParam.setLiveStreamIInterval(buf.readUnsignedShort());
videoParam.setLiveStreamFrameRate(buf.readByte());
videoParam.setLiveStreamCodeRate(buf.readUnsignedInt());
videoParam.setStorageStreamCodeRateType(buf.readByte());
videoParam.setStorageStreamResolving(buf.readByte());
videoParam.setStorageStreamIInterval(buf.readUnsignedShort());
videoParam.setStorageStreamFrameRate(buf.readByte());
videoParam.setStorageStreamCodeRate(buf.readUnsignedInt());
videoParam.setOsd(OSDConfig.decode(buf));
videoParam.setAudioEnable(buf.readByte());
return null;
}
}

View File

@@ -5,10 +5,7 @@ import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
import com.genersoft.iot.vmp.jt1078.bean.JTDevice;
import com.genersoft.iot.vmp.jt1078.bean.JTDeviceConfig;
import com.genersoft.iot.vmp.jt1078.bean.common.ConfigAttribute;
import com.genersoft.iot.vmp.jt1078.bean.config.CameraTimer;
import com.genersoft.iot.vmp.jt1078.bean.config.CollisionAlarmParams;
import com.genersoft.iot.vmp.jt1078.bean.config.GnssPositioningMode;
import com.genersoft.iot.vmp.jt1078.bean.config.IllegalDrivingPeriods;
import com.genersoft.iot.vmp.jt1078.bean.config.*;
import com.genersoft.iot.vmp.jt1078.proc.Header;
import com.genersoft.iot.vmp.jt1078.proc.response.J8001;
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
@@ -129,6 +126,11 @@ public class J0104 extends Re {
Method methodForGnssPositioningMode = deviceConfig.getClass().getDeclaredMethod("set" + StringUtils.capitalize(field.getName()), GnssPositioningMode.class);
methodForGnssPositioningMode.invoke(deviceConfig, gnssPositioningMode);
continue;
case "VideoParam":
VideoParam videoParam = VideoParam.decode(buf);
Method methodForVideoParam = deviceConfig.getClass().getDeclaredMethod("set" + StringUtils.capitalize(field.getName()), VideoParam.class);
methodForVideoParam.invoke(deviceConfig, videoParam);
continue;
default:
System.err.println(field.getGenericType().getTypeName());
continue;

View File

@@ -88,10 +88,11 @@ public class J8103 extends Rs {
case "CollisionAlarmParams":
case "CameraTimer":
case "GnssPositioningMode":
case "VideoParam":
field.setAccessible(true);
JTDeviceSubConfig subConfig = (JTDeviceSubConfig)field.get(config);
byte[] bytesForIllegalDrivingPeriods = subConfig.encode();
buffer.writeByte(bytesForIllegalDrivingPeriods.length);
ByteBuf bytesForIllegalDrivingPeriods = subConfig.encode();
buffer.writeByte(bytesForIllegalDrivingPeriods.readableBytes());
buffer.writeBytes(bytesForIllegalDrivingPeriods);
continue;
}