aprs
sh123 2022-08-13 20:48:45 +03:00
rodzic 8ab5f3cf94
commit f6480ac927
12 zmienionych plików z 86 dodań i 83 usunięć

Wyświetl plik

@ -10,7 +10,6 @@ import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.AudioTrack;
import android.media.MediaRecorder;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@ -540,7 +539,7 @@ public class AppWorker extends Thread {
try {
_protocol.initialize(_transport, _context, _protocolCallback);
_recordAudioBuffer = new short[_protocol.getPcmAudioBufferSize()];
_recordAudioBuffer = new short[_protocol.getPcmAudioRecordBufferSize()];
startWorkerMessageHandler();
Looper.loop();
} catch (IOException e) {

Wyświetl plik

@ -72,13 +72,13 @@ public class Aprs implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
return _childProtocol.getPcmAudioBufferSize();
public int getPcmAudioRecordBufferSize() {
return _childProtocol.getPcmAudioRecordBufferSize();
}
@Override
public void sendCompressedAudio(String src, String dst, int codec2Mode, byte[] frame) {
throw new UnsupportedOperationException();
public void sendCompressedAudio(String src, String dst, int codec2Mode, byte[] frame) throws IOException {
_childProtocol.sendCompressedAudio(src, dst, codec2Mode, frame);
}
@Override
@ -119,7 +119,7 @@ public class Aprs implements Protocol {
ProtocolCallback _protocolCallback = new ProtocolCallback() {
@Override
protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePosition(position);
}
@Override
@ -130,7 +130,7 @@ public class Aprs implements Protocol {
@Override
protected void onReceiveCompressedAudio(String src, String dst, int codec2Mode, byte[] audioFrame) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceiveCompressedAudio(src, dst, codec2Mode, audioFrame);
}
@Override
@ -187,7 +187,7 @@ public class Aprs implements Protocol {
@Override
protected void onTransmitPosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onTransmitPosition(position);
}
@Override

Wyświetl plik

@ -14,7 +14,6 @@ public class AudioCodec2 implements Protocol {
private final Protocol _childProtocol;
private long _codec2Con;
private int _codec2Mode;
private int _audioBufferSize;
private char[] _recordAudioEncodedBuffer;
@ -35,18 +34,18 @@ public class AudioCodec2 implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
public int getPcmAudioRecordBufferSize() {
return _audioBufferSize;
}
@Override
public void sendCompressedAudio(String src, String dst, int codec2Mode, byte[] frame) {
throw new UnsupportedOperationException();
public void sendCompressedAudio(String src, String dst, int codec2Mode, byte[] frame) throws IOException {
_childProtocol.sendCompressedAudio(src, dst, codec2Mode, frame);
}
@Override
public void sendTextMessage(TextMessage textMessage) {
throw new UnsupportedOperationException();
public void sendTextMessage(TextMessage textMessage) throws IOException {
_childProtocol.sendTextMessage(textMessage);
}
@Override
@ -76,12 +75,12 @@ public class AudioCodec2 implements Protocol {
ProtocolCallback _protocolCallback = new ProtocolCallback() {
@Override
protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePosition(position);
}
@Override
protected void onReceivePcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePcmAudio(src, dst, codec, pcmFrame);
}
@Override
@ -112,7 +111,7 @@ public class AudioCodec2 implements Protocol {
@Override
protected void onTransmitPcmAudio(String src, String dst, int codec, short[] frame) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onTransmitPcmAudio(src, dst, codec, frame);
}
@Override
@ -127,7 +126,7 @@ public class AudioCodec2 implements Protocol {
@Override
protected void onTransmitPosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onTransmitPosition(position);
}
@Override
@ -152,8 +151,8 @@ public class AudioCodec2 implements Protocol {
};
@Override
public void sendPosition(Position position) {
throw new UnsupportedOperationException();
public void sendPosition(Position position) throws IOException {
_childProtocol.sendPosition(position);
}
@Override
@ -171,7 +170,6 @@ public class AudioCodec2 implements Protocol {
if (_codec2Con != 0) {
Codec2.destroy(_codec2Con);
}
_codec2Mode = codecMode;
_codec2Con = Codec2.create(codecMode);
_audioBufferSize = Codec2.getSamplesPerFrame(_codec2Con);

Wyświetl plik

@ -51,8 +51,8 @@ public class AudioFrameAggregator implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
throw new UnsupportedOperationException();
public int getPcmAudioRecordBufferSize() {
return _childProtocol.getPcmAudioRecordBufferSize();
}
public int getPcmAudioBufferSize(int codec2ModeId) {
@ -77,12 +77,12 @@ public class AudioFrameAggregator implements Protocol {
@Override
public void sendTextMessage(TextMessage textMessage) throws IOException {
throw new UnsupportedOperationException();
_childProtocol.sendTextMessage(textMessage);
}
@Override
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) throws IOException {
_childProtocol.sendPcmAudio(src, dst, codec, pcmFrame);
}
@Override
@ -98,12 +98,12 @@ public class AudioFrameAggregator implements Protocol {
ProtocolCallback _protocolCallback = new ProtocolCallback() {
@Override
protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePosition(position);
}
@Override
protected void onReceivePcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePcmAudio(src, dst, codec, pcmFrame);
}
@Override
@ -160,7 +160,7 @@ public class AudioFrameAggregator implements Protocol {
@Override
protected void onTransmitPosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onTransmitPosition(position);
}
@Override

Wyświetl plik

@ -47,8 +47,8 @@ public class Ax25 implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
throw new UnsupportedOperationException();
public int getPcmAudioRecordBufferSize() {
return _childProtocol.getPcmAudioRecordBufferSize();
}
@Override
@ -75,12 +75,12 @@ public class Ax25 implements Protocol {
@Override
public void sendTextMessage(TextMessage textMessage) throws IOException {
throw new UnsupportedOperationException();
_childProtocol.sendTextMessage(textMessage);
}
@Override
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) throws IOException {
_childProtocol.sendPcmAudio(src, dst, codec, pcmFrame);
}
@Override
@ -110,12 +110,12 @@ public class Ax25 implements Protocol {
ProtocolCallback _protocolCallback = new ProtocolCallback() {
@Override
protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePosition(position);
}
@Override
protected void onReceivePcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePcmAudio(src, dst, codec, pcmFrame);
}
@Override
@ -173,7 +173,7 @@ public class Ax25 implements Protocol {
@Override
protected void onTransmitPosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onTransmitPosition(position);
}
@Override
@ -198,8 +198,8 @@ public class Ax25 implements Protocol {
};
@Override
public void sendPosition(Position position) {
throw new UnsupportedOperationException();
public void sendPosition(Position position) throws IOException {
_childProtocol.sendPosition(position);
}
@Override

Wyświetl plik

@ -51,7 +51,7 @@ public class Freedv implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
public int getPcmAudioRecordBufferSize() {
return Codec2.freedvGetNSpeechSamples(_freedv);
}
@ -65,18 +65,22 @@ public class Freedv implements Protocol {
@Override
public void sendCompressedAudio(String src, String dst, int codec, byte[] frame) throws IOException {
Log.w(TAG, "sendCompressedAudio() is not supported");
}
@Override
public void sendTextMessage(TextMessage textMessage) throws IOException {
Log.w(TAG, "sendTextMessage() is not supported");
}
@Override
public void sendData(String src, String dst, byte[] dataPacket) throws IOException {
// TODO, send as data
}
@Override
public boolean receive() throws IOException {
// TODO, distinguish between audio and data and call onReceiveData on parent callback
int nin = Codec2.freedvNin(_freedv);
short[] buf = new short[nin];
int bytesRead = _transport.read(buf);
@ -96,6 +100,7 @@ public class Freedv implements Protocol {
@Override
public void sendPosition(Position position) throws IOException {
Log.w(TAG, "sendPosition() is not supported");
}
@Override

Wyświetl plik

@ -32,7 +32,6 @@ public class Hdlc implements Protocol {
private final int _prefixSymCount;
private int _readByte = 0;
private int _prevHdlc = 0;
public Hdlc(SharedPreferences sharedPreferences) {
double preambleLenSec = Integer.parseInt(sharedPreferences.getString(PreferenceKeys.PORTS_SOUND_MODEM_PREAMBLE, "200")) / 1000.0;
@ -50,13 +49,14 @@ public class Hdlc implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
throw new UnsupportedOperationException();
public int getPcmAudioRecordBufferSize() {
Log.w(TAG, "getPcmAudioBufferSize() is not supported");
return -1;
}
@Override
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) throws IOException {
throw new UnsupportedOperationException();
Log.w(TAG, "sendPcmAudio() is not supported");
}
@Override
@ -66,7 +66,7 @@ public class Hdlc implements Protocol {
@Override
public void sendTextMessage(TextMessage textMessage) throws IOException {
throw new UnsupportedOperationException();
Log.w(TAG, "sendTextMessage() is not supported");
}
@Override
@ -117,7 +117,6 @@ public class Hdlc implements Protocol {
}
_currentFrameBuffer.clear();
_readByte = 0;
_prevHdlc = 0;
} else {
try {
_currentFrameBuffer.put(bit);
@ -125,7 +124,6 @@ public class Hdlc implements Protocol {
e.printStackTrace();
_currentFrameBuffer.clear();
}
_prevHdlc++;
}
}
}
@ -134,7 +132,7 @@ public class Hdlc implements Protocol {
@Override
public void sendPosition(Position position) {
throw new UnsupportedOperationException();
Log.w(TAG, "sendPosition() is not supported");
}
@Override

Wyświetl plik

@ -14,7 +14,6 @@ import com.radio.codec2talkie.R;
import com.radio.codec2talkie.protocol.message.TextMessage;
import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.radio.codec2talkie.tools.DebugTools;
import com.radio.codec2talkie.transport.Transport;
import java.io.IOException;
@ -61,12 +60,12 @@ public class Kiss implements Protocol {
GET_CMD,
GET_DATA,
ESCAPE
};
}
private enum DataType {
RAW,
SIGNAL_REPORT
};
}
private DataType _kissDataType = DataType.RAW;
private State _kissState = State.GET_START;
@ -145,8 +144,9 @@ public class Kiss implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
throw new UnsupportedOperationException();
public int getPcmAudioRecordBufferSize() {
Log.w(TAG, "getPcmAudioBufferSize() is not supported");
return -1;
}
private void initializeExtended() throws IOException {
@ -211,12 +211,12 @@ public class Kiss implements Protocol {
@Override
public void sendTextMessage(TextMessage textMessage) throws IOException {
throw new UnsupportedOperationException();
Log.w(TAG, "sendTextMessage() is not supported");
}
@Override
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
Log.w(TAG, "sendPcmAudio() is not supported");
}
@Override
@ -237,7 +237,7 @@ public class Kiss implements Protocol {
@Override
public void sendPosition(Position position) {
throw new UnsupportedOperationException();
Log.w(TAG, "sendPosition() is not supported");
}
@Override

Wyświetl plik

@ -12,7 +12,7 @@ public interface Protocol {
// init
void initialize(Transport transport, Context context, ProtocolCallback protocolCallback) throws IOException;
// audio
int getPcmAudioBufferSize();
int getPcmAudioRecordBufferSize();
void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) throws IOException;
void sendCompressedAudio(String src, String dst, int codec, byte[] frame) throws IOException;
// messaging

Wyświetl plik

@ -1,6 +1,7 @@
package com.radio.codec2talkie.protocol;
import android.content.Context;
import android.util.Log;
import com.radio.codec2talkie.protocol.message.TextMessage;
import com.radio.codec2talkie.protocol.position.Position;
@ -10,6 +11,7 @@ import java.io.IOException;
import java.util.Arrays;
public class Raw implements Protocol {
private static final String TAG = Raw.class.getSimpleName();
private static final int RX_BUFFER_SIZE = 8192;
@ -29,8 +31,9 @@ public class Raw implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
throw new UnsupportedOperationException();
public int getPcmAudioRecordBufferSize() {
Log.w(TAG, "getPcmAudioBufferSize() is not supported");
return -1;
}
@Override
@ -40,12 +43,12 @@ public class Raw implements Protocol {
@Override
public void sendTextMessage(TextMessage textMessage) throws IOException {
throw new UnsupportedOperationException();
Log.w(TAG, "sendTextMessage() is not supported");
}
@Override
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
Log.w(TAG, "sendPcmAudio() is not supported");
}
@Override
@ -65,7 +68,7 @@ public class Raw implements Protocol {
@Override
public void sendPosition(Position position) {
throw new UnsupportedOperationException();
Log.w(TAG, "sendPosition() is not supported");
}
@Override

Wyświetl plik

@ -54,8 +54,8 @@ public class Recorder implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
throw new UnsupportedOperationException();
public int getPcmAudioRecordBufferSize() {
return _childProtocol.getPcmAudioRecordBufferSize();
}
@Override
@ -67,12 +67,12 @@ public class Recorder implements Protocol {
@Override
public void sendTextMessage(TextMessage textMessage) throws IOException {
throw new UnsupportedOperationException();
_childProtocol.sendTextMessage(textMessage);
}
@Override
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) throws IOException {
_childProtocol.sendPcmAudio(src, dst, codec, pcmFrame);
}
@Override
@ -88,12 +88,12 @@ public class Recorder implements Protocol {
ProtocolCallback _protocolCallback = new ProtocolCallback() {
@Override
protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePosition(position);
}
@Override
protected void onReceivePcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePcmAudio(src, dst, codec, pcmFrame);
}
@Override
@ -140,7 +140,7 @@ public class Recorder implements Protocol {
@Override
protected void onTransmitPosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onTransmitPosition(position);
}
@Override
@ -165,8 +165,8 @@ public class Recorder implements Protocol {
};
@Override
public void sendPosition(Position position) {
throw new UnsupportedOperationException();
public void sendPosition(Position position) throws IOException {
_childProtocol.sendPosition(position);
}
@Override

Wyświetl plik

@ -46,8 +46,8 @@ public class Scrambler implements Protocol {
}
@Override
public int getPcmAudioBufferSize() {
throw new UnsupportedOperationException();
public int getPcmAudioRecordBufferSize() {
return _childProtocol.getPcmAudioRecordBufferSize();
}
@Override
@ -62,12 +62,12 @@ public class Scrambler implements Protocol {
@Override
public void sendTextMessage(TextMessage textMessage) throws IOException {
throw new UnsupportedOperationException();
_childProtocol.sendTextMessage(textMessage);
}
@Override
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
public void sendPcmAudio(String src, String dst, int codec, short[] pcmFrame) throws IOException {
_childProtocol.sendPcmAudio(src, dst, codec, pcmFrame);
}
@Override
@ -88,12 +88,12 @@ public class Scrambler implements Protocol {
ProtocolCallback _protocolCallback = new ProtocolCallback() {
@Override
protected void onReceivePosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePosition(position);
}
@Override
protected void onReceivePcmAudio(String src, String dst, int codec, short[] pcmFrame) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onReceivePcmAudio(src, dst, codec, pcmFrame);
}
@Override
@ -149,7 +149,7 @@ public class Scrambler implements Protocol {
@Override
protected void onTransmitPosition(Position position) {
throw new UnsupportedOperationException();
_parentProtocolCallback.onTransmitPosition(position);
}
@Override
@ -174,8 +174,8 @@ public class Scrambler implements Protocol {
};
@Override
public void sendPosition(Position position) {
throw new UnsupportedOperationException();
public void sendPosition(Position position) throws IOException {
_childProtocol.sendPosition(position);
}
@Override