|
|
|
@ -212,10 +212,10 @@ object BleService { |
|
|
|
scanHandler = Handler(Looper.getMainLooper()) |
|
|
|
|
|
|
|
recordfile = RecordingFile(this.context) |
|
|
|
recordfile!!.fileName = "不拆分" |
|
|
|
recordfile!!.fileName = "耳机端" |
|
|
|
|
|
|
|
recordfile1 = RecordingFile(this.context) |
|
|
|
recordfile1!!.fileName = "重新压缩" |
|
|
|
recordfile1!!.fileName = "手机端" |
|
|
|
|
|
|
|
// 初始化Opus音频管理器 |
|
|
|
if (!opusAudioManager.initialize()) { |
|
|
|
@ -325,19 +325,7 @@ object BleService { |
|
|
|
this@BleService.notifyWakeupSignalReceived() |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取录音文件实例 |
|
|
|
*/ |
|
|
|
override fun getRecordFile(): RecordingFile? { |
|
|
|
return recordfile |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取录音文件实例1 |
|
|
|
*/ |
|
|
|
override fun getRecordFile1(): RecordingFile? { |
|
|
|
return recordfile1 |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
@ -875,14 +863,14 @@ object BleService { |
|
|
|
// 统计接收到的字节数 |
|
|
|
bytesReceivedInCurrentSecond += data.size |
|
|
|
processAudioData(data) |
|
|
|
Log.i(TAG, "lxm--收到音频特征数据, 字节数=${data.size}") |
|
|
|
// Log.i(TAG, "lxm--收到音频特征数据, 字节数=${data.size}") |
|
|
|
} |
|
|
|
BleConst.CALL_RECEIVE_AUDIO_CHAR_UUID -> { |
|
|
|
|
|
|
|
// 统计接收到的字节数 |
|
|
|
bytesReceivedInCurrentSecond += data.size |
|
|
|
processAudioData(data) |
|
|
|
Log.i(TAG, "lxm--收到通话音频特征数据, 字节数=${data.size}") |
|
|
|
//Log.i(TAG, "lxm--收到通话音频特征数据, 字节数=${data.size}") |
|
|
|
} |
|
|
|
// 通知特征数据(命令和控制) |
|
|
|
BleConst.NOTIFY_CHAR_UUID -> { |
|
|
|
@ -1119,6 +1107,8 @@ object BleService { |
|
|
|
sampleRate: Int = 16000, |
|
|
|
packetSize: Int = 40 |
|
|
|
): Boolean { |
|
|
|
recordfile?.creatingFiles(); |
|
|
|
|
|
|
|
return opusAudioManager.startDecodeStream(hasHeader, channel, sampleRate, packetSize) |
|
|
|
} |
|
|
|
|
|
|
|
@ -1204,6 +1194,7 @@ object BleService { |
|
|
|
|
|
|
|
if (audioChunk != null) { |
|
|
|
// 发送音频数据块并等待回调 |
|
|
|
recordfile1?.saveAudioDataToWav(audioChunk) |
|
|
|
sendAudioChunkWithCallback(audioChunk) |
|
|
|
Thread.sleep(AUDIO_SEND_INTERVAL) |
|
|
|
} |
|
|
|
@ -1259,7 +1250,7 @@ object BleService { |
|
|
|
isWaitingForWriteCallback = true |
|
|
|
|
|
|
|
callWriteChar?.value = chunk |
|
|
|
recordfile1?.saveAudioDataToWav(chunk) |
|
|
|
|
|
|
|
//recordfile1?.saveAudioDataAsUtf8Hex(chunk, true) |
|
|
|
val isSuccess = bluetoothGatt?.writeCharacteristic(callWriteChar) |
|
|
|
|
|
|
|
@ -1439,7 +1430,7 @@ object BleService { |
|
|
|
fun openA2DPDecoder(channelMode: Int = BleConst.AUDIO_CHANNEL_STEREO): Boolean { |
|
|
|
Log.i(TAG, "打开A2DP解码器...") |
|
|
|
startOpusEncodeStream() |
|
|
|
|
|
|
|
recordfile1?.creatingFiles(); |
|
|
|
startOpusStreamDecoding(false, 2, 16000, 80) |
|
|
|
val cmdData = byteArrayOf( |
|
|
|
BleConst.CODEC_CONTROL_A2DP_PLAY.toByte(), |
|
|
|
|