1078-存储多媒体数据上传命令
This commit is contained in:
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -35,6 +36,10 @@ public class J0801 extends Re {
|
||||
ByteBuf byteBuf = buf.readSlice(28);
|
||||
positionBaseInfo = JTPositionBaseInfo.decode(byteBuf);
|
||||
String fileName = "mediaEvent/" + mediaEventInfo.getId() + ".";
|
||||
File mediaEventFile = new File("mediaEvent");
|
||||
if (!mediaEventFile.exists()) {
|
||||
mediaEventFile.mkdirs();
|
||||
}
|
||||
switch (mediaEventInfo.getCode()){
|
||||
case 0:
|
||||
fileName += "jpg";
|
||||
@@ -54,6 +59,10 @@ public class J0801 extends Re {
|
||||
}
|
||||
try {
|
||||
ByteBuf dst = buf.readBytes(buf.readableBytes());
|
||||
File file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(fileName);
|
||||
fileOutputStream.write(dst.array());
|
||||
fileOutputStream.close();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.response;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTQueryMediaDataCommand;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* 存储多媒体数据上传命令
|
||||
*/
|
||||
@MsgId(id = "8803")
|
||||
public class J8803 extends Rs {
|
||||
|
||||
JTQueryMediaDataCommand command;
|
||||
|
||||
@Override
|
||||
public ByteBuf encode() {
|
||||
return command.decode();
|
||||
}
|
||||
|
||||
public JTQueryMediaDataCommand getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(JTQueryMediaDataCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.response;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTQueryMediaDataCommand;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
/**
|
||||
* 录音开始/停止命令
|
||||
*/
|
||||
@MsgId(id = "8804")
|
||||
public class J8804 extends Rs {
|
||||
|
||||
/**
|
||||
* 录音命令, 0:停止录音;0X01:开始录音
|
||||
*/
|
||||
private int commond;
|
||||
|
||||
/**
|
||||
* 录音时长,单位为秒(s) ,0 表示一直录音
|
||||
*/
|
||||
private int duration;
|
||||
|
||||
/**
|
||||
* 保存标志, 0:实时上传;1:保存
|
||||
*/
|
||||
private int save;
|
||||
|
||||
/**
|
||||
* 音频采样率, 0:8K;1:11K;2:23K;3:32K;其他保留
|
||||
*/
|
||||
private int samplingRate;
|
||||
|
||||
@Override
|
||||
public ByteBuf encode() {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeByte(commond);
|
||||
byteBuf.writeShort((short)(duration & 0xffff));
|
||||
byteBuf.writeByte(save);
|
||||
byteBuf.writeByte(samplingRate);
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public int getCommond() {
|
||||
return commond;
|
||||
}
|
||||
|
||||
public void setCommond(int commond) {
|
||||
this.commond = commond;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public int getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public void setSave(int save) {
|
||||
this.save = save;
|
||||
}
|
||||
|
||||
public int getSamplingRate() {
|
||||
return samplingRate;
|
||||
}
|
||||
|
||||
public void setSamplingRate(int samplingRate) {
|
||||
this.samplingRate = samplingRate;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user