|
@@ -107,8 +107,8 @@ public class JingWeiCardServerHandler extends HexBinaryAcceptanceHandlerAdapter
|
|
|
break;
|
|
|
} else {
|
|
|
logger.info("微聊对讲数据[TK]:" + advice.toString());
|
|
|
- VoiceMsgVo msgVo = splitVoiceMsg(msg, advice.getDeviceId(), in);
|
|
|
- voiceMsgClient.insVoiceMsg(msgVo);
|
|
|
+ VoiceMsgVo msgVo = splitVoiceMsg(advice.getDeviceId(), req);
|
|
|
+// voiceMsgClient.insVoiceMsg(msgVo);
|
|
|
normalReply(advice, channel, "TK,1");
|
|
|
normalReply(channel, msgVo,msg);
|
|
|
}
|
|
@@ -128,7 +128,7 @@ public class JingWeiCardServerHandler extends HexBinaryAcceptanceHandlerAdapter
|
|
|
}
|
|
|
//[3G*YYYYYYYYYY*LEN*TK,AMR 格式音频数据]
|
|
|
|
|
|
- protected VoiceMsgVo splitVoiceMsg(String msg, String deviceId, ByteBuf byteBufIn) {
|
|
|
+ protected VoiceMsgVo splitVoiceMsg(String deviceId, byte[] req) {
|
|
|
VoiceMsgVo voiceMsg = new VoiceMsgVo();
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
|
|
|
String time = df.format(new Date());
|
|
@@ -137,16 +137,26 @@ public class JingWeiCardServerHandler extends HexBinaryAcceptanceHandlerAdapter
|
|
|
voiceMsg.setNu(1);
|
|
|
voiceMsg.setVoiceTime(time);
|
|
|
try {
|
|
|
- int startIndex = msg.indexOf(",");
|
|
|
- int endIndex = msg.indexOf("]");
|
|
|
- String mic = msg.substring(startIndex + 1,endIndex);
|
|
|
- byte[] bytes = mic.getBytes();
|
|
|
+ byte[] bytes = subByte(req, 23, req.length - 24);
|
|
|
voiceMsg.setMsg(bytes);
|
|
|
} catch (Exception e) {
|
|
|
logger.warn("语音解析错误" + JSON.toJSONString(voiceMsg) + ":" + e.getStackTrace());
|
|
|
}
|
|
|
return voiceMsg;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 截取byte数组 不改变原数组
|
|
|
+ * @param b 原数组
|
|
|
+ * @param off 偏差值(索引)
|
|
|
+ * @param length 长度
|
|
|
+ * @return 截取后的数组
|
|
|
+ */
|
|
|
+ public byte[] subByte(byte[] b, int off, int length){
|
|
|
+ byte[] b1 = new byte[length];
|
|
|
+ System.arraycopy(b, off, b1, 0, length);
|
|
|
+ return b1;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|