master
sh123 2023-12-09 21:08:35 +02:00
rodzic 4b8321e425
commit 49f8060635
1 zmienionych plików z 2 dodań i 6 usunięć

Wyświetl plik

@ -80,7 +80,6 @@ public class AudioOpus implements Protocol {
@Override @Override
public void sendPcmAudio(String src, String dst, short[] pcmFrame) throws IOException { public void sendPcmAudio(String src, String dst, short[] pcmFrame) throws IOException {
_parentProtocolCallback.onTransmitPcmAudio(src, dst, pcmFrame); _parentProtocolCallback.onTransmitPcmAudio(src, dst, pcmFrame);
Log.v(TAG, DebugTools.shortsToHex(pcmFrame));
int encodedBytesCnt = Opus.encode(_opusCon, pcmFrame, _pcmFrameSize, _recordAudioEncodedBuffer); int encodedBytesCnt = Opus.encode(_opusCon, pcmFrame, _pcmFrameSize, _recordAudioEncodedBuffer);
if (encodedBytesCnt == 0) { if (encodedBytesCnt == 0) {
Log.w(TAG, "Nothing was encoded"); Log.w(TAG, "Nothing was encoded");
@ -88,9 +87,7 @@ public class AudioOpus implements Protocol {
} }
if (encodedBytesCnt > 0) { if (encodedBytesCnt > 0) {
byte[] frame = new byte[encodedBytesCnt]; byte[] frame = new byte[encodedBytesCnt];
for (int i = 0; i < encodedBytesCnt; i++) { System.arraycopy(_recordAudioEncodedBuffer, 0, frame, 0, encodedBytesCnt);
frame[i] = (byte) _recordAudioEncodedBuffer[i];
}
Log.v(TAG, "pcm count: " + pcmFrame.length + ", encoded bytes count: " + encodedBytesCnt); Log.v(TAG, "pcm count: " + pcmFrame.length + ", encoded bytes count: " + encodedBytesCnt);
_childProtocol.sendCompressedAudio(src, dst, frame); _childProtocol.sendCompressedAudio(src, dst, frame);
} else { } else {
@ -130,8 +127,7 @@ public class AudioOpus implements Protocol {
} }
short [] decodedSamples = new short[decodedSamplesCnt]; short [] decodedSamples = new short[decodedSamplesCnt];
if (decodedSamplesCnt > 0) { if (decodedSamplesCnt > 0) {
System.arraycopy(_playbackAudioBuffer, 0, decodedSamples, 0, decodedSamplesCnt); System.arraycopy(_playbackAudioBuffer, 0, decodedSamples, 0, decodedSamplesCnt)
Log.v(TAG, DebugTools.shortsToHex(decodedSamples));
} else { } else {
Log.e(TAG, "Decode error: " + decodedSamplesCnt); Log.e(TAG, "Decode error: " + decodedSamplesCnt);
_parentProtocolCallback.onProtocolRxError(); _parentProtocolCallback.onProtocolRxError();