package com.ard.work.component.netty.command.settings; import com.ard.work.domain.dto.settings.VideoStreamSettingDTO; import com.ard.work.component.netty.command.BaseCmd; import io.netty.buffer.ByteBuf; /** * 设置视频码流指令 * * @author liusuyi * @date 2024年10月30日16:20 **/ public class VideoStreamSettingCmd extends BaseCmd { private final int resolutionWidth; // 水平像素 private final int resolutionHeight; // 垂直像素 private final int bitrate; // 码率 private final byte frameRate; // 帧率 public VideoStreamSettingCmd(VideoStreamSettingDTO videoStreamSettingDTO) { setDataHeader((short) 0x7479); setDataLength((short) 27); setBoxSn(videoStreamSettingDTO.getBoxSn().getBytes()); setCmdCode((byte) 0xD2); this.bitrate = videoStreamSettingDTO.getBitrate(); this.resolutionWidth = videoStreamSettingDTO.getResolutionWidth(); this.resolutionHeight = videoStreamSettingDTO.getResolutionHeight(); this.frameRate = videoStreamSettingDTO.getFrameRate(); } public void encode(ByteBuf out) { out.writeShort(getDataHeader()); // 写入数据头 out.writeShort(getDataLength()); // 写入数据长度 out.writeBytes(getBoxSn()); // 写入盒子SN out.writeByte(getCmdCode()); // 写入命令码 out.writeByte(0x00); // 写入加密标志 out.writeByte(0x05); // 写入动作编号 out.writeInt(resolutionWidth); // 写入水平像素 out.writeInt(resolutionHeight); // 写入垂直像素 out.writeByte(frameRate); // 写入帧率 out.writeInt(bitrate); // 写入码率 } }